1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Fix portrait serialization

# Conflicts:
#	lib/mapObjects/CGHeroInstance.cpp
This commit is contained in:
nordsoft
2023-04-28 05:34:59 +04:00
parent 9296306fa3
commit f6d91cab35

View File

@@ -1469,7 +1469,12 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
if(portrait >= 0) if(portrait >= 0)
{ {
if(portrait < legacyHeroes || portrait >= moddedStart) if(portrait < legacyHeroes || portrait >= moddedStart)
handler.serializeId<si32, si32, HeroTypeID>("portrait", portrait, -1); {
int tempPortrait = portrait >= moddedStart
? portrait - GameConstants::HERO_PORTRAIT_SHIFT
: portrait;
handler.serializeId<si32, si32, HeroTypeID>("portrait", tempPortrait, -1);
}
else else
handler.serializeInt("portrait", portrait, -1); handler.serializeInt("portrait", portrait, -1);
} }
@@ -1479,7 +1484,11 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler)
const JsonNode & portraitNode = handler.getCurrent()["portrait"]; const JsonNode & portraitNode = handler.getCurrent()["portrait"];
if(portraitNode.getType() == JsonNode::JsonType::DATA_STRING) if(portraitNode.getType() == JsonNode::JsonType::DATA_STRING)
{
handler.serializeId<si32, si32, HeroTypeID>("portrait", portrait, -1); handler.serializeId<si32, si32, HeroTypeID>("portrait", portrait, -1);
if(portrait >= legacyHeroes)
portrait += GameConstants::HERO_PORTRAIT_SHIFT;
}
else else
handler.serializeInt("portrait", portrait, -1); handler.serializeInt("portrait", portrait, -1);
} }