From a2ed6be1f5056bdd7cfc81ce0a84ca42cb6c94ad Mon Sep 17 00:00:00 2001 From: zimp-wow <66187107+zimp-wow@users.noreply.github.com> Date: Fri, 7 Mar 2025 22:38:23 -0600 Subject: [PATCH] [Bug Fix] Zero out currentnpcid whenever spawn is reset. (#4763) --- zone/spawn2.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index b500f25fc..5ff22e1c6 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -356,6 +356,7 @@ void Spawn2::LoadGrid(int start_wp) { void Spawn2::Reset() { timer.Start(resetTimer()); npcthis = nullptr; + currentnpcid = 0; LogSpawns("Spawn2 [{}]: Spawn reset, repop in [{}] ms", spawn2_id, timer.GetRemainingTime()); } @@ -363,6 +364,7 @@ void Spawn2::Depop() { timer.Disable(); LogSpawns("Spawn2 [{}]: Spawn reset, repop disabled", spawn2_id); npcthis = nullptr; + currentnpcid = 0; } void Spawn2::Repop(uint32 delay) { @@ -374,6 +376,7 @@ void Spawn2::Repop(uint32 delay) { timer.Start(delay); } npcthis = nullptr; + currentnpcid = 0; } void Spawn2::ForceDespawn() @@ -392,12 +395,14 @@ void Spawn2::ForceDespawn() npcthis->Depop(true); IsDespawned = true; npcthis = nullptr; + currentnpcid = 0; return; } else { npcthis->Depop(false); npcthis = nullptr; + currentnpcid = 0; } } } @@ -429,6 +434,7 @@ void Spawn2::DeathReset(bool realdeath) //zero out our NPC since he is now gone npcthis = nullptr; + currentnpcid = 0; if(realdeath) { killcount++; } @@ -643,6 +649,7 @@ void Spawn2::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) { LogSpawns("Spawn2 [{}]: Our npcthis is currently not null. The zone thinks it is [{}]. Forcing a depop", spawn2_id, npcthis->GetName()); npcthis->Depop(false); //remove the current mob npcthis = nullptr; + currentnpcid = 0; } if(new_state) { // only get repawn timer remaining when the SpawnCondition is enabled. timer_remaining = database.GetSpawnTimeLeft(spawn2_id,zone->GetInstanceID());