avoid crash on remove caster when in a spell attack
This commit is contained in:
parent
9be94fe396
commit
14bb60caf8
@ -45,20 +45,18 @@ SpellProcess::~SpellProcess(){
|
||||
|
||||
void SpellProcess::RemoveCaster(Spawn* caster, bool lock_spell_process){
|
||||
if(lock_spell_process)
|
||||
MSpellProcess.lock_shared();
|
||||
MSpellProcess.lock();
|
||||
MutexList<LuaSpell*>::iterator active_spells_itr = active_spells.begin();
|
||||
while(active_spells_itr.Next()){
|
||||
LuaSpell* spell = active_spells_itr->value;
|
||||
spell->MSpellTargets.writelock(__FUNCTION__, __LINE__);
|
||||
if(spell->caster == caster) {
|
||||
spell->caster = nullptr;
|
||||
}
|
||||
if(spell->initial_target == caster->GetID())
|
||||
spell->initial_target = 0;
|
||||
spell->MSpellTargets.releasewritelock(__FUNCTION__, __LINE__);
|
||||
}
|
||||
if(lock_spell_process)
|
||||
MSpellProcess.unlock_shared();
|
||||
MSpellProcess.unlock();
|
||||
}
|
||||
|
||||
void SpellProcess::RemoveAllSpells(bool reload_spells){
|
||||
|
@ -1519,6 +1519,10 @@ void ZoneServer::DeleteSpawns(bool delete_all) {
|
||||
|
||||
lua_interface->SetLuaUserDataStale(spawn);
|
||||
|
||||
if (spellProcess) {
|
||||
spellProcess->RemoveCaster(spawn, true);
|
||||
}
|
||||
|
||||
if(movementMgr != nullptr) {
|
||||
movementMgr->RemoveMob((Entity*)spawn);
|
||||
}
|
||||
@ -6721,10 +6725,6 @@ void ZoneServer::RemoveSpawnSupportFunctions(Spawn* spawn, bool lock_spell_proce
|
||||
if(spawn->IsEntity())
|
||||
RemoveSpellTimersFromSpawn((Entity*)spawn, true, true, true, lock_spell_process);
|
||||
|
||||
if (spellProcess) {
|
||||
spellProcess->RemoveCaster(spawn, lock_spell_process);
|
||||
}
|
||||
|
||||
if(!shutdown) { // in case of shutdown, DeleteData(true) handles the cleanup later via DeleteSpawnScriptTimers
|
||||
StopSpawnScriptTimer(spawn, "");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user