Преглед на файлове

Fix serialization of size_t breaking 32<->64 bit compatibility

Ivan Savenko преди 1 година
родител
ревизия
f8a206b0c6
променени са 4 файла, в които са добавени 16 реда и са изтрити 4 реда
  1. 12 1
      lib/CGeneralTextHandler.h
  2. 0 1
      lib/constants/VariantIdentifier.h
  3. 3 1
      lib/serializer/ESerializationVersion.h
  4. 1 1
      server/battles/BattleActionProcessor.cpp

+ 12 - 1
lib/CGeneralTextHandler.h

@@ -202,7 +202,18 @@ public:
 
 		std::string key;
 		auto sz = stringsLocalizations.size();
-		h & sz;
+
+		if (h.version >= Handler::Version::REMOVE_TEXT_CONTAINER_SIZE_T)
+		{
+			int32_t size = sz;
+			h & size;
+			sz = size;
+		}
+		else
+		{
+			h & sz;
+		}
+
 		if(h.saving)
 		{
 			for(auto s : stringsLocalizations)

+ 0 - 1
lib/constants/VariantIdentifier.h

@@ -51,7 +51,6 @@ public:
 	IdentifierType as() const
 	{
 		auto * result = std::get_if<IdentifierType>(&value);
-		assert(result);
 
 		if (result)
 			return *result;

+ 3 - 1
lib/serializer/ESerializationVersion.h

@@ -44,5 +44,7 @@ enum class ESerializationVersion : int32_t
 
 	RELEASE_150 = ARTIFACT_COSTUMES, // for convenience
 
-	CURRENT = ARTIFACT_COSTUMES
+	REMOVE_TEXT_CONTAINER_SIZE_T, // Fixed serialization of size_t from text containers
+
+	CURRENT = REMOVE_TEXT_CONTAINER_SIZE_T
 };

+ 1 - 1
server/battles/BattleActionProcessor.cpp

@@ -971,7 +971,7 @@ void BattleActionProcessor::makeAttack(const CBattleInfoCallback & battle, const
 	}
 
 	std::shared_ptr<const Bonus> bonus = attacker->getFirstBonus(Selector::type()(BonusType::SPELL_LIKE_ATTACK));
-	if(bonus && ranged && bonus->subtype.as<SpellID>().hasValue()) //TODO: make it work in melee?
+	if(bonus && ranged) //TODO: make it work in melee?
 	{
 		//this is need for displaying hit animation
 		bat.flags |= BattleAttack::SPELL_LIKE;