2
0
Эх сурвалжийг харах

Restore save compatibility with 1.5

Ivan Savenko 11 сар өмнө
parent
commit
c3c5f73a63

+ 10 - 1
lib/bonuses/Limiters.h

@@ -108,7 +108,16 @@ public:
 	template <typename Handler> void serialize(Handler &h)
 	{
 		h & static_cast<ILimiter&>(*this);
-		h & creatureID;
+
+		if (h.version < Handler::Version::REMOVE_TOWN_PTR)
+		{
+			bool isNull = false;
+			h & isNull;
+			if(!isNull)
+				h & creatureID;
+		}
+		else
+			h & creatureID;
 		h & includeUpgrades;
 	}
 };

+ 18 - 1
lib/mapObjects/CGMarket.h

@@ -78,7 +78,24 @@ public:
 	template <typename Handler> void serialize(Handler &h)
 	{
 		h & static_cast<CGMarket&>(*this);
-		h & artifacts;
+		if (h.version < Handler::Version::REMOVE_VLC_POINTERS)
+		{
+			int32_t size = 0;
+			h & size;
+			for (int32_t i = 0; i < size; ++i)
+			{
+				bool isNull = false;
+				ArtifactID artifact;
+				h & isNull;
+				if (!isNull)
+					h & artifact;
+				artifacts.push_back(artifact);
+			}
+		}
+		else
+		{
+			h & artifacts;
+		}
 	}
 };
 

+ 19 - 1
lib/mapping/CMap.h

@@ -222,7 +222,25 @@ public:
 		// static members
 		h & obeliskCount;
 		h & obelisksVisited;
-		h & townMerchantArtifacts;
+
+		if (h.version < Handler::Version::REMOVE_VLC_POINTERS)
+		{
+			int32_t size = 0;
+			h & size;
+			for (int32_t i = 0; i < size; ++i)
+			{
+				bool isNull = false;
+				ArtifactID artifact;
+				h & isNull;
+				if (!isNull)
+					h & artifact;
+				townMerchantArtifacts.push_back(artifact);
+			}
+		}
+		else
+		{
+			h & townMerchantArtifacts;
+		}
 		h & townUniversitySkills;
 
 		h & instanceNames;

+ 3 - 4
lib/mapping/CMapDefines.h

@@ -146,10 +146,9 @@ struct DLL_LINKAGE TerrainTile
 		{
 			bool isNull = false;
 			h & isNull;
-			if (isNull)
+			if (!isNull)
 				h & terrainType;
 		}
-		h & terrainType;
 		h & terView;
 		if (h.version >= Handler::Version::REMOVE_VLC_POINTERS)
 		{
@@ -159,7 +158,7 @@ struct DLL_LINKAGE TerrainTile
 		{
 			bool isNull = false;
 			h & isNull;
-			if (isNull)
+			if (!isNull)
 				h & riverType;
 		}
 		h & riverDir;
@@ -171,7 +170,7 @@ struct DLL_LINKAGE TerrainTile
 		{
 			bool isNull = false;
 			h & isNull;
-			if (isNull)
+			if (!isNull)
 				h & roadType;
 		}
 		h & roadDir;