Преглед изворни кода

Fixed save/load maps with removed objects. Fixed spell scroll handling (really).

Michał W. Urbańczyk пре 16 година
родитељ
комит
ccaf244a54
3 измењених фајлова са 12 додато и 1 уклоњено
  1. 2 1
      map.cpp
  2. 9 0
      map.h
  3. 1 0
      mapHandler.cpp

+ 2 - 1
map.cpp

@@ -1585,8 +1585,9 @@ void Mapa::readObjects( unsigned char * bufor, int &i)
 					{
 						art->army = readCreatureSet(bufor,i,7,(version>RoE));
 					}
+					i+=4;
 				}
-				if(areSettings || defInfo->id==93)
+				if(defInfo->id==93)
 				{
 					art->spell = readNormalNr(bufor,i); 
 					i+=4;

+ 9 - 0
map.h

@@ -402,8 +402,16 @@ struct DLL_EXPORT Mapa : public CMapHeader
 		for(int i=0; i<objects.size(); i++)
 		{
 			CGObjectInstance *&obj = objects[i];
+			ui8 exists = (obj!=NULL);
 			ui32 hlp;
 			si32 shlp;
+			h & exists;
+			if(!exists)
+			{
+				if(!h.saving)
+					obj = 0;
+				continue;
+			}
 			h & (h.saving ? (hlp=obj->ID) : hlp);
 			switch(hlp)
 			{
@@ -504,6 +512,7 @@ struct DLL_EXPORT Mapa : public CMapHeader
 
 			for(int i=0; i<objects.size(); i++)
 			{
+				if(!objects[i]) continue;
 				if(objects[i]->ID == 34)
 					heroes.push_back(static_cast<CGHeroInstance*>(objects[i]));
 				else if(objects[i]->ID == 98)

+ 1 - 0
mapHandler.cpp

@@ -357,6 +357,7 @@ void CMapHandler::initObjectRects()
 	//initializing objects / rects
 	for(size_t f=0; f < map->objects.size(); ++f)
 	{
+		if(!map->objects[f]) continue;
 		if((map->objects[f]->ID==34 && static_cast<CGHeroInstance*>(map->objects[f])->inTownGarrison)
 			|| !map->objects[f]->defInfo)
 		{