From c41c14f9532523f9e33d84ccabadd605b31ca61f Mon Sep 17 00:00:00 2001 From: Joshua Tyree Date: Sun, 12 Feb 2023 10:14:44 -0600 Subject: [PATCH] Prevent pets from Ticking if they're marked for deletion --- src/map/zone_entities.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/map/zone_entities.cpp b/src/map/zone_entities.cpp index bc2b58cb7cb..16b6878c76c 100644 --- a/src/map/zone_entities.cpp +++ b/src/map/zone_entities.cpp @@ -1434,15 +1434,11 @@ void CZoneEntities::ZoneServer(time_point tick, bool check_trigger_areas) // : this way, but we need to do this to keep allies working (for now). if (auto* PPet = static_cast(it->second)) { - PPet->PRecastContainer->Check(); - PPet->StatusEffectContainer->CheckEffectsExpiry(tick); - if (tick > m_EffectCheckTime) - { - PPet->StatusEffectContainer->TickRegen(tick); - PPet->StatusEffectContainer->TickEffects(tick); - } - PPet->PAI->Tick(tick); - + /* + * Pets specifically need to be removed prior to evaluating their AI Tick + * to prevent a number of issues which can result as a Pet having a + * deleted/nullptr'd PMaster + */ if (PPet->status == STATUS_TYPE::DISAPPEAR) { for (auto PMobIt : m_mobList) @@ -1461,6 +1457,15 @@ void CZoneEntities::ZoneServer(time_point tick, bool check_trigger_areas) m_petList.erase(it++); continue; } + + PPet->PRecastContainer->Check(); + PPet->StatusEffectContainer->CheckEffectsExpiry(tick); + if (tick > m_EffectCheckTime) + { + PPet->StatusEffectContainer->TickRegen(tick); + PPet->StatusEffectContainer->TickEffects(tick); + } + PPet->PAI->Tick(tick); } it++; }