From 1730a314711cbba143d3026dbda081e3928254a7 Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Fri, 11 Dec 2015 16:01:51 +0300 Subject: [PATCH] HeroBonus: get rid of code that used getBonusList --- lib/CCreatureHandler.cpp | 10 ++++++++-- lib/mapObjects/CArmedInstance.cpp | 4 ++-- lib/mapObjects/CGHeroInstance.cpp | 2 +- lib/mapObjects/CGTownInstance.cpp | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/CCreatureHandler.cpp b/lib/CCreatureHandler.cpp index 2f30d3c48..dda125f32 100644 --- a/lib/CCreatureHandler.cpp +++ b/lib/CCreatureHandler.cpp @@ -452,8 +452,14 @@ void CCreatureHandler::loadCrExpBon() } do //parse everything that's left { - b.sid = parser.readNumber(); //id = this particular creature ID - loadStackExp(b, creatures[b.sid]->getBonusList(), parser); //add directly to CCreature Node + auto sid = parser.readNumber(); //id = this particular creature ID + b.sid = sid; + bl.clear(); + loadStackExp(b, bl, parser); + for(Bonus * b : bl) + { + creatures[sid]->addNewBonus(b); //add directly to CCreature Node + } } while (parser.endLine()); diff --git a/lib/mapObjects/CArmedInstance.cpp b/lib/mapObjects/CArmedInstance.cpp index adc47a7a5..fad613c81 100644 --- a/lib/mapObjects/CArmedInstance.cpp +++ b/lib/mapObjects/CArmedInstance.cpp @@ -46,7 +46,7 @@ void CArmedInstance::updateMoraleBonusFromArmy() if(!validTypes(false)) //object not randomized, don't bother return; - Bonus *b = getBonusList().getFirst(Selector::sourceType(Bonus::ARMY).And(Selector::type(Bonus::MORALE))); + Bonus *b = getExportedBonusList().getFirst(Selector::sourceType(Bonus::ARMY).And(Selector::type(Bonus::MORALE))); if(!b) { b = new Bonus(Bonus::PERMANENT, Bonus::MORALE, Bonus::ARMY, 0, -1); @@ -99,7 +99,7 @@ void CArmedInstance::updateMoraleBonusFromArmy() //-1 modifier for any Undead unit in army const ui8 UNDEAD_MODIFIER_ID = -2; - Bonus *undeadModifier = getBonusList().getFirst(Selector::source(Bonus::ARMY, UNDEAD_MODIFIER_ID)); + Bonus *undeadModifier = getExportedBonusList().getFirst(Selector::source(Bonus::ARMY, UNDEAD_MODIFIER_ID)); if(hasUndead) { if(!undeadModifier) diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index cf29848ae..d0896d441 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -818,7 +818,7 @@ void CGHeroInstance::updateSkill(SecondarySkill which, int val) Bonus::ValueType skillValType = skillVal ? Bonus::BASE_NUMBER : Bonus::INDEPENDENT_MIN; - if(Bonus * b = getBonusList().getFirst(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, which) + if(Bonus * b = getExportedBonusList().getFirst(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, which) .And(Selector::sourceType(Bonus::SECONDARY_SKILL)))) //only local hero bonus { b->val = skillVal; diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index ba1b8baca..ab661823e 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -856,7 +856,7 @@ void CGTownInstance::deserializationFix() void CGTownInstance::updateMoraleBonusFromArmy() { - Bonus *b = getBonusList().getFirst(Selector::sourceType(Bonus::ARMY).And(Selector::type(Bonus::MORALE))); + Bonus *b = getExportedBonusList().getFirst(Selector::sourceType(Bonus::ARMY).And(Selector::type(Bonus::MORALE))); if(!b) { b = new Bonus(Bonus::PERMANENT, Bonus::MORALE, Bonus::ARMY, 0, -1);