1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Merge pull request #5952 from IvanSavenko/spell_ban_fix

Fix artifacts providing hero with banned spells
This commit is contained in:
Ivan Savenko
2025-07-28 18:53:50 +03:00
committed by GitHub
10 changed files with 48 additions and 28 deletions

View File

@@ -1250,15 +1250,20 @@ std::vector<BonusSourceID> CGHeroInstance::getSourcesForSpell(const SpellID & sp
for(const auto & bonus : *getBonusesOfType(BonusType::SPELL, spellId))
sources.emplace_back(bonus->sid);
const auto spell = spellId.toSpell();
spell->forEachSchool([this, &sources](const SpellSchool & cnf, bool & stop)
{
for(const auto & bonus : *getBonusesOfType(BonusType::SPELLS_OF_SCHOOL, cnf))
sources.emplace_back(bonus->sid);
});
bool tomesGrantBannedSpells = cb->getSettings().getBoolean(EGameSettings::SPELLS_TOMES_GRANT_BANNED_SPELLS);
for(const auto & bonus : *getBonusesOfType(BonusType::SPELLS_OF_LEVEL, BonusCustomSubtype::spellLevel(spell->getLevel())))
sources.emplace_back(bonus->sid);
if (tomesGrantBannedSpells || cb->isAllowed(spellId))
{
const auto spell = spellId.toSpell();
spell->forEachSchool([this, &sources](const SpellSchool & cnf, bool & stop)
{
for(const auto & bonus : *getBonusesOfType(BonusType::SPELLS_OF_SCHOOL, cnf))
sources.emplace_back(bonus->sid);
});
for(const auto & bonus : *getBonusesOfType(BonusType::SPELLS_OF_LEVEL, BonusCustomSubtype::spellLevel(spell->getLevel())))
sources.emplace_back(bonus->sid);
}
return sources;
}