mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-08 22:26:51 +02:00
Merge pull request #5293 from godric3/fix-using-specific-hero-in-campaing-bonus
Fix loading vcmp campaign with specific hero used in scenario bonuses
This commit is contained in:
@ -355,13 +355,15 @@ CampaignTravel CampaignHandler::readScenarioTravelFromJson(JsonNode & reader)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(int heroId = heroSpecialMap.at(bjson["hero"].String()))
|
auto heroIdentifier = bjson["hero"].String();
|
||||||
bonus.info1 = heroId;
|
auto it = heroSpecialMap.find(heroIdentifier);
|
||||||
|
if(it != heroSpecialMap.end())
|
||||||
|
bonus.info1 = it->second;
|
||||||
else
|
else
|
||||||
if(auto identifier = VLC->identifiers()->getIdentifier(ModScope::scopeMap(), "hero", bjson["hero"].String()))
|
if(auto identifier = VLC->identifiers()->getIdentifier(ModScope::scopeMap(), "hero", heroIdentifier))
|
||||||
bonus.info1 = identifier.value();
|
bonus.info1 = identifier.value();
|
||||||
else
|
else
|
||||||
logGlobal->warn("VCMP Loading: unresolved hero identifier %s", bjson["hero"].String());
|
logGlobal->warn("VCMP Loading: unresolved hero identifier %s", heroIdentifier);
|
||||||
|
|
||||||
bonus.info3 = bjson["amount"].Integer();
|
bonus.info3 = bjson["amount"].Integer();
|
||||||
|
|
||||||
@ -418,13 +420,15 @@ CampaignTravel CampaignHandler::readScenarioTravelFromJson(JsonNode & reader)
|
|||||||
bonus.type = CampaignBonusType::HERO;
|
bonus.type = CampaignBonusType::HERO;
|
||||||
bonus.info1 = bjson["playerColor"].Integer(); //player color
|
bonus.info1 = bjson["playerColor"].Integer(); //player color
|
||||||
|
|
||||||
if(int heroId = heroSpecialMap.at(bjson["hero"].String()))
|
auto heroIdentifier = bjson["hero"].String();
|
||||||
bonus.info2 = heroId;
|
auto it = heroSpecialMap.find(heroIdentifier);
|
||||||
|
if(it != heroSpecialMap.end())
|
||||||
|
bonus.info2 = it->second;
|
||||||
else
|
else
|
||||||
if (auto identifier = VLC->identifiers()->getIdentifier(ModScope::scopeMap(), "hero", bjson["hero"].String()))
|
if (auto identifier = VLC->identifiers()->getIdentifier(ModScope::scopeMap(), "hero", heroIdentifier))
|
||||||
bonus.info2 = identifier.value();
|
bonus.info2 = identifier.value();
|
||||||
else
|
else
|
||||||
logGlobal->warn("VCMP Loading: unresolved hero identifier %s", bjson["hero"].String());
|
logGlobal->warn("VCMP Loading: unresolved hero identifier %s", heroIdentifier);
|
||||||
|
|
||||||
ret.bonusesToChoose.push_back(bonus);
|
ret.bonusesToChoose.push_back(bonus);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user