diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index b2f2c7171..99dcfc1bb 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -1469,7 +1469,12 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler) if(portrait >= 0) { if(portrait < legacyHeroes || portrait >= moddedStart) - handler.serializeId("portrait", portrait, -1); + { + int tempPortrait = portrait >= moddedStart + ? portrait - GameConstants::HERO_PORTRAIT_SHIFT + : portrait; + handler.serializeId("portrait", tempPortrait, -1); + } else handler.serializeInt("portrait", portrait, -1); } @@ -1479,7 +1484,11 @@ void CGHeroInstance::serializeCommonOptions(JsonSerializeFormat & handler) const JsonNode & portraitNode = handler.getCurrent()["portrait"]; if(portraitNode.getType() == JsonNode::JsonType::DATA_STRING) + { handler.serializeId("portrait", portrait, -1); + if(portrait >= legacyHeroes) + portrait += GameConstants::HERO_PORTRAIT_SHIFT; + } else handler.serializeInt("portrait", portrait, -1); }