1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Fix crash on removing object during visit

This commit is contained in:
Ivan Savenko 2023-09-06 12:32:26 +03:00
parent ad25bfb4bb
commit f92af94f19

View File

@ -140,13 +140,11 @@ void Rewardable::Interface::grantRewardAfterLevelup(IGameCallback * cb, const Re
caster.setActualCaster(hero);
caster.setSpellSchoolLevel(info.reward.spellCast.second);
cb->castSpell(&caster, info.reward.spellCast.first, int3{-1, -1, -1});
if(info.reward.removeObject)
logMod->warn("Removal of object with spell casts is not supported!");
}
else if(info.reward.removeObject) //FIXME: object can't track spell cancel or finish, so removeObject leads to crash
if(info.reward.removeObject)
if(auto * instance = dynamic_cast<const CGObjectInstance*>(this))
cb->removeObject(instance);
cb->removeAfterVisit(instance);
}
VCMI_LIB_NAMESPACE_END