Explorar o código

Diagnostics for #924.

Michał W. Urbańczyk %!s(int64=13) %!d(string=hai) anos
pai
achega
d55d48b978
Modificáronse 1 ficheiros con 14 adicións e 1 borrados
  1. 14 1
      lib/CObjectHandler.cpp

+ 14 - 1
lib/CObjectHandler.cpp

@@ -799,7 +799,20 @@ void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= NULL*/)
 
 	for(int stackNo=0; stackNo < howManyStacks; stackNo++)
 	{
-		int creID = (VLC->creh->nameToID[type->refTypeStack[stackNo]]);
+		int creID = 0;
+		auto creItr = VLC->creh->nameToID.find(type->refTypeStack[stackNo]);
+		if(creItr == VLC->creh->nameToID.end())
+		{
+			tlog1 << "Cannot find a creature named " << type->refTypeStack[stackNo] << std::endl;
+			tlog1 << "Available creatures: \n";
+			BOOST_FOREACH(auto i, VLC->creh->nameToID)
+			{
+				tlog1 << boost::format("\t%s => %d\n") % i.first % i.second;
+			}
+		}
+		else
+			creID = creItr->second;
+
 		int range = type->highStack[stackNo] - type->lowStack[stackNo];
 		int count = ran()%(range+1) + type->lowStack[stackNo];