summaryrefslogtreecommitdiff
path: root/ai
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-08-22 21:14:45 +0000
committertruelight <truelight@openttd.org>2006-08-22 21:14:45 +0000
commitceb523c29f364f24b5e6b68b13249187ff6ac371 (patch)
tree3b5390c9adf2806b379ecf5be65b211d1a2e8b4d /ai
parent3cdabcbbac5ae64c132f0162090079d8c5cf3f90 (diff)
downloadopenttd-ceb523c29f364f24b5e6b68b13249187ff6ac371.tar.xz
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
Diffstat (limited to 'ai')
-rw-r--r--ai/default/default.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index 3de583bf4..08af2b119 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -441,14 +441,12 @@ typedef struct FoundRoute {
static Town *AiFindRandomTown(void)
{
- Town *t = GetTown(RandomRange(GetTownArraySize()));
- return IsValidTown(t) ? t : NULL;
+ return GetRandomTown();
}
static Industry *AiFindRandomIndustry(void)
{
- Industry *i = GetIndustry(RandomRange(GetIndustryArraySize()));
- return IsValidIndustry(i) ? i : NULL;
+ return GetRandomIndustry();
}
static void AiFindSubsidyIndustryRoute(FoundRoute *fr)