mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-17 00:07:41 +02:00
Don't crash when spell school level is higher than 3 (which is another bug)
This commit is contained in:
@ -865,7 +865,7 @@ ui8 CGHeroInstance::getSpellSchoolLevel(const CSpell * spell, int *outSelectedSc
|
|||||||
|
|
||||||
spell->forEachSchool([&, this](const SpellSchoolInfo & cnf, bool & stop)
|
spell->forEachSchool([&, this](const SpellSchoolInfo & cnf, bool & stop)
|
||||||
{
|
{
|
||||||
int thisSchool = std::max<int>(getSecSkillLevel(cnf.skill), valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 1 << ((ui8)cnf.id)));
|
int thisSchool = std::max<int>(getSecSkillLevel(cnf.skill), valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 1 << ((ui8)cnf.id))); //FIXME: Bonus shouldn't be additive (Witchking Artifacts : Crown of Skies)
|
||||||
if(thisSchool > skill)
|
if(thisSchool > skill)
|
||||||
{
|
{
|
||||||
skill = thisSchool;
|
skill = thisSchool;
|
||||||
@ -877,7 +877,8 @@ ui8 CGHeroInstance::getSpellSchoolLevel(const CSpell * spell, int *outSelectedSc
|
|||||||
vstd::amax(skill, valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 0)); //any school bonus
|
vstd::amax(skill, valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 0)); //any school bonus
|
||||||
vstd::amax(skill, valOfBonuses(Bonus::SPELL, spell->id.toEnum())); //given by artifact or other effect
|
vstd::amax(skill, valOfBonuses(Bonus::SPELL, spell->id.toEnum())); //given by artifact or other effect
|
||||||
|
|
||||||
assert(skill >= 0 && skill <= 3);
|
vstd::amax(skill, 0); //in case we don't know any school
|
||||||
|
vstd::amin(skill, 3);
|
||||||
return skill;
|
return skill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user