summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-02 23:40:32 +0000
committertruebrain <truebrain@openttd.org>2011-12-02 23:40:32 +0000
commit5a9523bfa023f6915ec97f4e7c0055c32911f415 (patch)
treef0fdfa2fe2b62ae181449d7f681cadb561c0f4d8 /src
parentf259e6bf5d99fd43ce881cb957ad5295ee9bd548 (diff)
downloadopenttd-5a9523bfa023f6915ec97f4e7c0055c32911f415.tar.xz
(svn r23399) -Fix (r23362): a randomizer should return a random value, not always the first
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_scanner.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp
index f903061e4..6dfebc4ac 100644
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -81,13 +81,15 @@ AIInfo *AIScannerInfo::SelectRandomAI() const
/* Find the Nth item from the array */
ScriptInfoList::const_iterator it = this->info_single_list.begin();
- AIInfo *i = static_cast<AIInfo *>((*it).second);
- while (!i->UseAsRandomAI()) it++;
+
+#define GetAIInfo(it) static_cast<AIInfo *>((*it).second)
+ while (!GetAIInfo(it)->UseAsRandomAI()) it++;
for (; pos > 0; pos--) {
it++;
- while (!i->UseAsRandomAI()) it++;
+ while (!GetAIInfo(it)->UseAsRandomAI()) it++;
}
- return i;
+ return GetAIInfo(it);
+#undef GetAIInfo
}
AIInfo *AIScannerInfo::FindInfo(const char *nameParam, int versionParam, bool force_exact_match)