summaryrefslogtreecommitdiff
path: root/src/ai/default/default.cpp
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2007-03-16 10:11:16 +0000
committercelestar <celestar@openttd.org>2007-03-16 10:11:16 +0000
commit045d3dc05f03f717d2795bc8ab5c06922ef1f5c7 (patch)
tree777642ae16d3801c33e04fa9aaaefeffe8c824f1 /src/ai/default/default.cpp
parent50811a49ed4b574bfb6e98c9e997c23465e290ca (diff)
downloadopenttd-045d3dc05f03f717d2795bc8ab5c06922ef1f5c7.tar.xz
(svn r9251) -Fix(r6057, FS#644): Use a less CPU-intensive algorithm to find a random industry for the AI to prevent it slowing down the game. The AI now sucks a even a bit more than before (if that's even possible).
Diffstat (limited to 'src/ai/default/default.cpp')
-rw-r--r--src/ai/default/default.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index 20aa5d1e9..f77bd8a00 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -460,7 +460,10 @@ static Town *AiFindRandomTown()
static Industry *AiFindRandomIndustry()
{
- return GetRandomIndustry();
+ int num = RandomRange(GetMaxIndustryIndex());
+ if (IsValidIndustry(GetIndustry(num))) return GetIndustry(num);
+
+ return NULL;
}
static void AiFindSubsidyIndustryRoute(FoundRoute *fr)