diff options
author | celestar <celestar@openttd.org> | 2007-03-16 10:11:16 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2007-03-16 10:11:16 +0000 |
commit | 045d3dc05f03f717d2795bc8ab5c06922ef1f5c7 (patch) | |
tree | 777642ae16d3801c33e04fa9aaaefeffe8c824f1 /src/ai/default/default.cpp | |
parent | 50811a49ed4b574bfb6e98c9e997c23465e290ca (diff) | |
download | openttd-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.cpp | 5 |
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) |