فهرست منبع

- one more crash at map loading

Ivan Savenko 13 سال پیش
والد
کامیت
828d9e70d2
2فایلهای تغییر یافته به همراه12 افزوده شده و 2 حذف شده
  1. 10 0
      lib/CGameState.cpp
  2. 2 2
      lib/map.cpp

+ 10 - 0
lib/CGameState.cpp

@@ -646,11 +646,21 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
 			std::pair<int,int> result(-1, -1);
 			int cid = VLC->townh->towns[faction].basicCreatures[level];
 
+			//golem factory is not in list of cregens but can be placed as random object
+			static const int factoryCreatures[] = {32, 33, 116, 117};
+			std::vector<int> factory(std::begin(factoryCreatures), std::end(factoryCreatures));
+			if (vstd::contains(factory, cid))
+				result = std::pair<int,int>(20, 1);
+
 			//NOTE: this will pick last dwelling with this creature (Mantis #900)
 			//check for block map equality is better but more complex solution
 			BOOST_FOREACH(auto &iter, VLC->objh->cregens)
 				if (iter.second == cid)
 					result = std::pair<int,int>(17, iter.first);
+
+			if (result.first == -1)
+				tlog0 << "Error: failed to find creature for dwelling of "<< int(faction) << " of level " << int(level) << "\n";
+
 			return result;
 		}
 	}

+ 2 - 2
lib/map.cpp

@@ -897,7 +897,7 @@ CGObjectInstance * Mapa::loadHero(const ui8 * bufor, int &i, int idToBeGiven)
 	{
 		bool areSpells = bufor[i]; ++i;
 
-		if(areSpells) //TODO: sprawdziæ //seems to be ok - tow
+		if(areSpells) //TODO: sprawdzi //seems to be ok - tow
 		{
 			nhi->spells.insert(0xffffffff); //placeholder "preset spells"
 			int ist = i;
@@ -2209,4 +2209,4 @@ bool TerrainTile::hasFavourableWinds() const
 bool TerrainTile::isWater() const
 {
 	return tertype == water;
-}
+}