Ver Fonte

Fixed crash when starting a game with new creatures on map using „Creature N” placeholders in armies.

Michał W. Urbańczyk há 13 anos atrás
pai
commit
1fce4770fb
1 ficheiros alterados com 3 adições e 5 exclusões
  1. 3 5
      lib/CObjectHandler.cpp

+ 3 - 5
lib/CObjectHandler.cpp

@@ -6855,11 +6855,9 @@ void CArmedInstance::randomizeArmy(int type)
 		int randID = j->second->idRand;
 		if(randID > max)
 		{
-			if(randID % 2)
-				j->second->setType(VLC->townh->towns[type].creatures[(randID-197) / 2 -1][0]);
-			else
-				j->second->setType(VLC->townh->towns[type].creatures[(randID-197) / 2 -1][1]);
-
+			int level = (randID-VLC->creh->creatures.size()) / 2 -1;
+			bool upgrade = !(randID % 2);
+			j->second->setType(VLC->townh->towns[type].creatures[level][upgrade]);
 			randID = -1;
 		}