Browse Source

Add save compatibility check

Ivan Savenko 1 year ago
parent
commit
50e8d1fd82
2 changed files with 11 additions and 2 deletions
  1. 9 1
      lib/bonuses/Bonus.h
  2. 2 1
      lib/serializer/ESerializationVersion.h

+ 9 - 1
lib/bonuses/Bonus.h

@@ -93,7 +93,15 @@ struct DLL_LINKAGE Bonus : public std::enable_shared_from_this<Bonus>
 		h & source;
 		h & val;
 		h & sid;
-		h & description;
+		if (h.version < Handler::Version::BONUS_META_STRING)
+		{
+			std::string oldDescription;
+			h & oldDescription;
+			description = MetaString::createFromRawString(oldDescription);
+		}
+		else
+			h & description;
+
 		h & additionalInfo;
 		h & turnsRemain;
 		h & valType;

+ 2 - 1
lib/serializer/ESerializationVersion.h

@@ -38,6 +38,7 @@ enum class ESerializationVersion : int32_t
 	CAMPAIGN_MAP_TRANSLATIONS, // 835 +campaigns include translations for its maps
 	JSON_FLAGS, // 836 json uses new format for flags
 	MANA_LIMIT,	// 837 change MANA_PER_KNOWLEGDE to percentage
+	BONUS_META_STRING,	// 838 bonuses use MetaString instead of std::string for descriptions
 
-	CURRENT = MANA_LIMIT
+	CURRENT = BONUS_META_STRING
 };