summaryrefslogtreecommitdiff
path: root/src
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
commit124725d863f4463cad71b914e557281bc2fd0a37 (patch)
tree777642ae16d3801c33e04fa9aaaefeffe8c824f1 /src
parentc5313e3479045594788123d40999358c095c0691 (diff)
downloadopenttd-124725d863f4463cad71b914e557281bc2fd0a37.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')
-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)