From 124725d863f4463cad71b914e557281bc2fd0a37 Mon Sep 17 00:00:00 2001 From: celestar Date: Fri, 16 Mar 2007 10:11:16 +0000 Subject: (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). --- src/ai/default/default.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/ai/default/default.cpp') 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) -- cgit v1.2.3-54-g00ecf