Browse Source

Slight mod for crash fix

Emagi 10 months ago
parent
commit
8ef5843d7a
2 changed files with 4 additions and 4 deletions
  1. 3 3
      EQ2/source/WorldServer/SpellProcess.cpp
  2. 1 1
      EQ2/source/WorldServer/SpellProcess.h

+ 3 - 3
EQ2/source/WorldServer/SpellProcess.cpp

@@ -48,7 +48,7 @@ void SpellProcess::RemoveAllSpells(){
 
 	MutexList<LuaSpell*>::iterator active_spells_itr = active_spells.begin();
 	while(active_spells_itr.Next()){
-		DeleteCasterSpell(active_spells_itr->value, "", true);
+		DeleteCasterSpell(active_spells_itr->value, "", true, 0, true);
 	}
 
 	MSpellProcess.lock();
@@ -371,7 +371,7 @@ bool SpellProcess::DeleteCasterSpell(Spawn* caster, Spell* spell, string reason)
 	return ret;
 }
 
-bool SpellProcess::DeleteCasterSpell(LuaSpell* spell, string reason, bool removing_all_spells, Spawn* remove_target){
+bool SpellProcess::DeleteCasterSpell(LuaSpell* spell, string reason, bool removing_all_spells, Spawn* remove_target, bool zone_shutting_down){
     std::shared_lock lock(MSpellProcess);	
 
 	bool ret = false;
@@ -402,7 +402,7 @@ bool SpellProcess::DeleteCasterSpell(LuaSpell* spell, string reason, bool removi
 		
 		if (active_spells.count(spell) > 0)
 			active_spells.Remove(spell);
-		if (spell->caster) {
+		if (!zone_shutting_down && spell->caster) { // spell->caster ptr cannot be trusted during zone shutdown
 			if(spell->caster->GetThreatTransfer() && spell->caster->GetThreatTransfer()->Spell == spell) {
 				spell->caster->SetThreatTransfer(nullptr);
 			}

+ 1 - 1
EQ2/source/WorldServer/SpellProcess.h

@@ -265,7 +265,7 @@ public:
 
 	/// <summary>Remove the given spell from the ZpellProcess</summary>
 	/// <param name='spell'>LuaSpell to remove</param>
-	bool DeleteCasterSpell(LuaSpell* spell, string reason="", bool removing_all_spells = false, Spawn* remove_target = nullptr);
+	bool DeleteCasterSpell(LuaSpell* spell, string reason="", bool removing_all_spells = false, Spawn* remove_target = nullptr, bool zone_shutting_down = false);
 
 	/// <summary>Interrupt the spell</summary>
 	/// <param name='interrupt'>InterruptStruct that contains all the info</param>