1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-15 11:46:56 +02:00

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

This commit is contained in:
Ivan Savenko 2024-05-21 14:11:40 +00:00
parent 3ad618e0d8
commit f8a206b0c6
4 changed files with 16 additions and 4 deletions

View File

@ -202,7 +202,18 @@ public:
std::string key; std::string key;
auto sz = stringsLocalizations.size(); 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) if(h.saving)
{ {
for(auto s : stringsLocalizations) for(auto s : stringsLocalizations)

View File

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

View File

@ -44,5 +44,7 @@ enum class ESerializationVersion : int32_t
RELEASE_150 = ARTIFACT_COSTUMES, // for convenience 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
}; };

View File

@ -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)); 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 //this is need for displaying hit animation
bat.flags |= BattleAttack::SPELL_LIKE; bat.flags |= BattleAttack::SPELL_LIKE;