(svn r9197) [NoAI] -Fix: std::map.end() is the item AFTER the last valid item, not the last item noai
authortruelight
Thu, 15 Mar 2007 11:53:41 +0000
branchnoai
changeset 9402 45581b218c98
parent 9401 04502c3557f2
child 9403 0a2377009af4
(svn r9197) [NoAI] -Fix: std::map.end() is the item AFTER the last valid item, not the last item
src/ai/core/ai_factory.hpp
--- a/src/ai/core/ai_factory.hpp	Thu Mar 15 10:29:43 2007 +0000
+++ b/src/ai/core/ai_factory.hpp	Thu Mar 15 11:53:41 2007 +0000
@@ -75,16 +75,16 @@
 		Factories::iterator first_it;
 		for (; i > 0; i--) it++;
 		first_it = it;
-		AIFactoryBase *f = (*it).second;
+		AIFactoryBase *f = it->second;
 
 		if (!f->AllowStartup()) {
 			/* We can't start this AI, try to find the next best */
 			do {
+				it++;
 				if (it == GetFactories().end()) it = GetFactories().begin();
-				else it++;
 				/* Back at the beginning? Drop out! */
 				if (first_it == it) break;
-				f = (*it).second;
+				f = it->second;
 			} while (!f->AllowStartup());
 			/* Unable to start any AI */
 			if (first_it == it) return NULL;