From 836210404c9b870796e37283986f9cd89fecef22 Mon Sep 17 00:00:00 2001 From: hg <4683435+hgtw@users.noreply.github.com> Date: Fri, 8 Jan 2021 20:12:36 -0500 Subject: [PATCH] Fix zone crash on spawn condition change The NPC pointer held by Spawn2 wasn't reset if the npc was depopped without a respawn timer by #depop commands or depop(false) quest apis. If the NPC was part of a spawn condition then the condition would try to dereference that pointer (which gets deleted) on condition change. --- zone/npc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zone/npc.cpp b/zone/npc.cpp index 434781841..e8110580a 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -968,9 +968,12 @@ void NPC::Depop(bool StartSpawnTimer) { if(emoteid != 0) this->DoNPCEmote(ONDESPAWN,emoteid); p_depop = true; - if (StartSpawnTimer) { - if (respawn2 != 0) { + if (respawn2) + { + if (StartSpawnTimer) { respawn2->DeathReset(); + } else { + respawn2->Depop(); } } }