Crash fix on spell deletion, remove from pending spells if we already plan to delete

This commit is contained in:
Emagi 2025-06-17 08:14:10 -04:00
parent aa70c950b8
commit a6a0ca85ef
2 changed files with 5 additions and 8 deletions

View File

@ -1737,7 +1737,6 @@ void LuaInterface::DeletePendingSpells(bool all) {
if(!all) {
// rely on targets the spell->caster could be corrupt
bool spellDeleted = false;
if(spell->targets.size() > 0) {
spell->MSpellTargets.readlock(__FUNCTION__, __LINE__);
for (int8 i = 0; i < spell->targets.size(); i++) {
@ -1748,16 +1747,11 @@ void LuaInterface::DeletePendingSpells(bool all) {
if(target->IsEntity()) {
((Entity*)target)->RemoveWard(spell);
}
if(!spellDeleted && spell->zone && spell->zone->GetSpellProcess())
spell->zone->GetSpellProcess()->DeleteActiveSpell(spell, true);
spellDeleted = true;
}
spell->MSpellTargets.releasereadlock(__FUNCTION__, __LINE__);
}
if(!spellDeleted && spell->zone && spell->zone->GetSpellProcess()) {
if(spell->zone && spell->zone->GetSpellProcess()) {
spell->zone->GetSpellProcess()->DeleteActiveSpell(spell, true);
}
}

View File

@ -3067,9 +3067,12 @@ void SpellProcess::AddSelfAndPetToCharTargets(LuaSpell* spell, Spawn* caster, bo
spell->char_id_targets.insert(make_pair(charID, 0x00));
}
void SpellProcess::DeleteActiveSpell(LuaSpell* spell, bool skipRemoveCurrent) {
void SpellProcess::DeleteActiveSpell(LuaSpell* spell, bool skipRemoveCurrent) {
lua_interface->SetLuaUserDataStale(spell);
if(!skipRemoveCurrent)
lua_interface->RemoveCurrentSpell(spell->state, spell, true);
lua_interface->DeletePendingSpell(spell);
active_spells.Remove(spell, true, 10000);
}