changeset 18555:9dd1621dadfe draft

(svn r23399) -Fix (r23362): a randomizer should return a random value, not always the first
author truebrain <truebrain@openttd.org>
date Fri, 02 Dec 2011 23:40:32 +0000
parents 861edb824eb8
children 78924e0c9900
files src/ai/ai_scanner.cpp
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -81,13 +81,15 @@
 
 	/* 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)