Просмотр исходного кода

Restore save compatibility with 1.6 saves that have quests

Ivan Savenko 2 недель назад
Родитель
Сommit
47cdcb6f28
2 измененных файлов с 20 добавлено и 2 удалено
  1. 18 1
      lib/gameState/QuestInfo.h
  2. 2 1
      lib/serializer/BinaryDeserializer.h

+ 18 - 1
lib/gameState/QuestInfo.h

@@ -11,6 +11,7 @@
 
 #include "int3.h"
 #include "../constants/EntityIdentifiers.h"
+#include "../mapObjects/CGObjectInstance.h"
 
 VCMI_LIB_NAMESPACE_BEGIN
 
@@ -38,7 +39,23 @@ struct DLL_LINKAGE QuestInfo //universal interface for human and AI
 
 	template <typename Handler> void serialize(Handler &h)
 	{
-		h & obj;
+
+		if (h.hasFeature(Handler::Version::NO_RAW_POINTERS_IN_SERIALIZER))
+		{
+			h & obj;
+		}
+		else
+		{
+			std::shared_ptr<CQuest> questUnused;
+			std::shared_ptr<CGObjectInstance> objectPtr;
+			int3 tileUnused;
+			h & questUnused;
+			h & objectPtr;
+			h & tileUnused;
+
+			if (objectPtr)
+				obj = objectPtr->id;
+		}
 	}
 };
 

+ 2 - 1
lib/serializer/BinaryDeserializer.h

@@ -324,7 +324,8 @@ private:
 		T * internalPtr;
 		loadRawPointer(internalPtr);
 		data.reset(internalPtr);
-		loadedUniquePointers.insert(internalPtr);
+		if (internalPtr != nullptr)
+			loadedUniquePointers.insert(internalPtr);
 	}
 
 	template<typename T, size_t N>