From f9ac46576b347534de5f22873fd4c21b934461f6 Mon Sep 17 00:00:00 2001 From: godric3 Date: Mon, 29 Oct 2018 21:33:13 +0100 Subject: [PATCH] Add description for bonuses from hero specialty --- lib/CHeroHandler.cpp | 10 ++++++++-- lib/CHeroHandler.h | 2 +- lib/HeroBonus.cpp | 3 +++ lib/mapObjects/CGHeroInstance.cpp | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index 28aff408d..037ca6d54 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -564,11 +564,12 @@ std::vector> SpecialtyInfoToBonuses(const SSpecialtyInfo } // convert deprecated format -std::vector> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec) +std::vector> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec, int sid) { std::vector> result; for(std::shared_ptr oldBonus : spec.bonuses) { + oldBonus->sid = sid; if(oldBonus->type == Bonus::SPECIAL_SPELL_LEV || oldBonus->type == Bonus::SPECIAL_BLESS_DAMAGE) { // these bonuses used to auto-scale with hero level @@ -860,6 +861,11 @@ void CHeroHandler::afterLoadFinalization() { for(ConstTransitivePtr hero : heroes) { + for(auto bonus : hero->specialty) + { + bonus->sid = hero->ID.getNum(); + } + if(hero->specDeprecated.size() > 0 || hero->specialtyDeprecated.size() > 0) { logMod->debug("Converting specialty format for hero %s(%s)", hero->identifier, VLC->townh->encodeFaction(hero->heroClass->faction)); @@ -871,7 +877,7 @@ void CHeroHandler::afterLoadFinalization() } for(const SSpecialtyBonus & spec : hero->specialtyDeprecated) { - for(std::shared_ptr b : SpecialtyBonusToBonuses(spec)) + for(std::shared_ptr b : SpecialtyBonusToBonuses(spec, hero->ID.getNum())) convertedBonuses.push_back(b); } hero->specDeprecated.clear(); diff --git a/lib/CHeroHandler.h b/lib/CHeroHandler.h index fd0407de2..67a1b4624 100644 --- a/lib/CHeroHandler.h +++ b/lib/CHeroHandler.h @@ -135,7 +135,7 @@ public: // convert deprecated format std::vector> SpecialtyInfoToBonuses(const SSpecialtyInfo & spec, int sid); -std::vector> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec); +std::vector> SpecialtyBonusToBonuses(const SSpecialtyBonus & spec, int sid); class DLL_LINKAGE CHeroClass { diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 2c926ee03..8246a67a5 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -1250,6 +1250,9 @@ std::string Bonus::Description() const case SECONDARY_SKILL: str << VLC->skillh->skillName(sid); break; + case HERO_SPECIAL: + str << VLC->heroh->heroes[sid]->name; + break; default: //todo: handle all possible sources str << "Unknown"; diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 1269f83d6..fb19185a3 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -552,7 +552,7 @@ void CGHeroInstance::recreateSpecialtyBonuses(std::vector & speci for(HeroSpecial * hs : specialtyDeprecated) { - for(std::shared_ptr b : SpecialtyBonusToBonuses(HeroSpecialToSpecialtyBonus(*hs))) + for(std::shared_ptr b : SpecialtyBonusToBonuses(HeroSpecialToSpecialtyBonus(*hs), type->ID.getNum())) addNewBonus(b); } }