mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Add workaround for crash on attempt to use town portal map object
This commit is contained in:
@@ -3881,8 +3881,14 @@ void CGameHandler::castSpell(const spells::Caster * caster, SpellID spellID, con
|
||||
const CSpell * s = spellID.toSpell();
|
||||
s->adventureCast(spellEnv.get(), p);
|
||||
|
||||
if(const auto * hero = caster->getHeroCaster())
|
||||
useChargeBasedSpell(hero->id, spellID);
|
||||
// FIXME: hack to avoid attempts to use charges when spell is casted externally
|
||||
// For example, town gates map object in hota/wog
|
||||
// Proper fix would be to instead spend charges similar to existing caster::spendMana call
|
||||
if (dynamic_cast<const spells::ExternalCaster*>(caster) == nullptr)
|
||||
{
|
||||
if(const auto * hero = caster->getHeroCaster())
|
||||
useChargeBasedSpell(hero->id, spellID);
|
||||
}
|
||||
}
|
||||
|
||||
bool CGameHandler::swapStacks(const StackLocation & sl1, const StackLocation & sl2)
|
||||
|
||||
Reference in New Issue
Block a user