1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Properly removing stuff from hero, fixes #1646.

This commit is contained in:
Michał W. Urbańczyk
2014-02-08 23:07:33 +00:00
parent d6f8a6d4bf
commit 343dd1a7d1
5 changed files with 46 additions and 15 deletions

View File

@ -1150,8 +1150,7 @@ void CGHeroInstance::initObj()
}
//initialize bonuses
for(auto skill_info : secSkills)
updateSkill(SecondarySkill(skill_info.first), skill_info.second);
recreateSecondarySkillsBonuses();
Updatespecialty();
mana = manaLimit(); //after all bonuses are taken into account, make sure this line is the last one
@ -1212,6 +1211,17 @@ void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuse
}
}
}
void CGHeroInstance::recreateSecondarySkillsBonuses()
{
auto secondarySkillsBonuses = getBonuses(Selector::sourceType(Bonus::SECONDARY_SKILL));
for(auto bonus : *secondarySkillsBonuses)
removeBonus(bonus);
for(auto skill_info : secSkills)
updateSkill(SecondarySkill(skill_info.first), skill_info.second);
}
void CGHeroInstance::updateSkill(SecondarySkill which, int val)
{
if(which == SecondarySkill::LEADERSHIP || which == SecondarySkill::LUCK)