diff options
author | killerwife <killerwife@gmail.com> | 2025-09-23 11:53:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-23 06:53:32 -0300 |
commit | 77d972acbb9cf13b99caebbdb7ce655e5cce6e43 (patch) | |
tree | d2f5e921fd24b45a88b2272eb0072acd5fc915da | |
parent | 78dea88d5d0e8532f2c926e1558ebb05f8e04894 (diff) |
fix(Core/Creature): prevent crash due to recursive call for help (#23008)
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 5 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 2 | ||||
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.h | 4 |
3 files changed, 10 insertions, 1 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 98b65d6acc..19fe38a3c9 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -272,7 +272,7 @@ bool TemporaryThreatModifierEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) Creature::Creature(): Unit(), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_lootRecipientGroup(0), m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f), m_boundaryCheckTime(2500), m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), - m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false), + m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_alreadyCallForHelp(false), m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_regenHealth(true), m_regenPower(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false), m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_detectionDistance(20.0f),_sparringPct(0.0f), m_waypointID(0), m_path_id(0), m_formation(nullptr), m_lastLeashExtensionTime(nullptr), m_cannotReachTimer(0), _isMissingSwimmingFlagOutOfCombat(false), m_assistanceTimer(0), _playerDamageReq(0), _damagedByPlayer(false), _isCombatMovementAllowed(true) @@ -2485,6 +2485,9 @@ void Creature::CallForHelp(float radius, Unit* target /*= nullptr*/) return; } + if (m_alreadyCallForHelp) // avoid recursive call for help for any reason + return; + Acore::CallOfHelpCreatureInRangeDo u_do(this, target, radius); Acore::CreatureWorker<Acore::CallOfHelpCreatureInRangeDo> worker(this, u_do); Cell::VisitObjects(this, worker, radius); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index e9326f0d13..a2c2947020 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -268,6 +268,7 @@ public: void DoFleeToGetAssistance(); void CallForHelp(float fRadius, Unit* target = nullptr); void CallAssistance(Unit* target = nullptr); + void SetNoCallForHelp(bool val) { m_alreadyCallForHelp = val; } void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; } void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; } bool HasSearchedAssistance() { return m_AlreadySearchedAssistance; } @@ -469,6 +470,7 @@ protected: uint8 m_equipmentId; int8 m_originalEquipmentId; // can be -1 + bool m_alreadyCallForHelp; bool m_AlreadyCallAssistance; bool m_AlreadySearchedAssistance; bool m_regenHealth; diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index d9556c77f6..d35e8600c1 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -1157,7 +1157,11 @@ namespace Acore return; if (u->AI()) + { + u->SetNoCallForHelp(true); // avoid recursive call for help causing stack overflow u->AI()->AttackStart(i_enemy); + u->SetNoCallForHelp(false); + } } private: Unit* const i_funit; |