Browse Source

Add save compatibility

Ivan Savenko 1 year ago
parent
commit
a39469d165

+ 11 - 1
lib/CArtifactInstance.h

@@ -95,7 +95,17 @@ public:
 	{
 		h & static_cast<CBonusSystemNode&>(*this);
 		h & static_cast<CCombinedArtifactInstance&>(*this);
-		h & artTypeID;
+		if (h.version >= Handler::Version::REMOVE_VLC_POINTERS)
+		{
+			h & artTypeID;
+		}
+		else
+		{
+			bool isNull = false;
+			h & isNull;
+			if (!isNull)
+				h & artTypeID;
+		}
 		h & id;
 		BONUS_TREE_DESERIALIZATION_FIX
 	}

+ 39 - 4
lib/mapping/CMapDefines.h

@@ -138,15 +138,50 @@ struct DLL_LINKAGE TerrainTile
 	template <typename Handler>
 	void serialize(Handler & h)
 	{
+		if (h.version >= Handler::Version::REMOVE_VLC_POINTERS)
+		{
+			h & terrainType;
+		}
+		else
+		{
+			bool isNull = false;
+			h & isNull;
+			if (isNull)
+				h & terrainType;
+		}
 		h & terrainType;
 		h & terView;
-		h & riverType;
+		if (h.version >= Handler::Version::REMOVE_VLC_POINTERS)
+		{
+			h & riverType;
+		}
+		else
+		{
+			bool isNull = false;
+			h & isNull;
+			if (isNull)
+				h & riverType;
+		}
 		h & riverDir;
-		h & roadType;
+		if (h.version >= Handler::Version::REMOVE_VLC_POINTERS)
+		{
+			h & roadType;
+		}
+		else
+		{
+			bool isNull = false;
+			h & isNull;
+			if (isNull)
+				h & roadType;
+		}
 		h & roadDir;
 		h & extTileFlags;
-	//	h & visitable;
-	//	h & blocked;
+		if (h.version < Handler::Version::REMOVE_VLC_POINTERS)
+		{
+			bool unused;
+			h & unused;
+			h & unused;
+		}
 		h & visitableObjects;
 		h & blockingObjects;
 	}

+ 2 - 1
lib/serializer/ESerializationVersion.h

@@ -65,6 +65,7 @@ enum class ESerializationVersion : int32_t
 	LOCAL_PLAYER_STATE_DATA, // 866 - player state contains arbitrary client-side data
 	REMOVE_TOWN_PTR, // 867 - removed pointer to CTown from CGTownInstance
 	REMOVE_OBJECT_TYPENAME, // 868 - remove typename from CGObjectInstance
+	REMOVE_VLC_POINTERS, // 869 removed remaining pointers to VLC entities
 
-	CURRENT = REMOVE_OBJECT_TYPENAME
+	CURRENT = REMOVE_VLC_POINTERS
 };

+ 1 - 1
server/CGameHandler.cpp

@@ -2912,7 +2912,7 @@ bool CGameHandler::assembleArtifacts(ObjectInstanceID heroID, ArtifactPosition a
 
 		AssembledArtifact aa;
 		aa.al = dstLoc;
-		aa.artId = assembleTo->getId();
+		aa.artId = assembleTo;
 		sendAndApply(aa);
 	}
 	else