diff --git a/src/PlayerbotAI.h b/src/PlayerbotAI.h index 04deae3a..180606e8 100644 --- a/src/PlayerbotAI.h +++ b/src/PlayerbotAI.h @@ -601,6 +601,7 @@ public: NewRpgInfo rpgInfo; NewRpgStatistic rpgStatistic; std::unordered_set lowPriorityQuest; + time_t bgReleaseAttemptTime = 0; // Schedules a callback to run once after milliseconds. void AddTimedEvent(std::function callback, uint32 delayMs); diff --git a/src/strategy/actions/ReleaseSpiritAction.cpp b/src/strategy/actions/ReleaseSpiritAction.cpp index 0d725f74..666e42ab 100644 --- a/src/strategy/actions/ReleaseSpiritAction.cpp +++ b/src/strategy/actions/ReleaseSpiritAction.cpp @@ -192,12 +192,11 @@ bool AutoReleaseSpiritAction::ShouldDelayBattlegroundRelease() const { // The below delays release to spirit with 6 seconds. // This prevents currently casted (ranged) spells to be re-directed to the died bot's ghost. - const int32_t botId = bot->GetGUID().GetRawValue(); - // If the bot already is a spirit, erase release time and return true + // If the bot already is a spirit, reset release time and return true if (bot->HasPlayerFlag(PLAYER_FLAGS_GHOST)) { - m_botReleaseTimes.erase(botId); + botAI->bgReleaseAttemptTime = 0; return true; } @@ -205,14 +204,13 @@ bool AutoReleaseSpiritAction::ShouldDelayBattlegroundRelease() const const time_t now = time(nullptr); constexpr time_t RELEASE_DELAY = 6; - auto& lastReleaseTime = m_botReleaseTimes[botId]; - if (lastReleaseTime == 0) - lastReleaseTime = now; + if (botAI->bgReleaseAttemptTime == 0) + botAI->bgReleaseAttemptTime = now; - if (now - lastReleaseTime < RELEASE_DELAY) + if (now - botAI->bgReleaseAttemptTime < RELEASE_DELAY) return false; - m_botReleaseTimes.erase(botId); + botAI->bgReleaseAttemptTime = 0; return true; } diff --git a/src/strategy/actions/ReleaseSpiritAction.h b/src/strategy/actions/ReleaseSpiritAction.h index debeab84..57851214 100644 --- a/src/strategy/actions/ReleaseSpiritAction.h +++ b/src/strategy/actions/ReleaseSpiritAction.h @@ -38,7 +38,6 @@ private: bool ShouldAutoRelease() const; bool ShouldDelayBattlegroundRelease() const; - inline static std::unordered_map m_botReleaseTimes; time_t m_bgGossipTime = 0; };