From 4694de7ce0b210787128221e04c05ec0a339e93d Mon Sep 17 00:00:00 2001 From: avirar Date: Sun, 22 Dec 2024 15:17:34 +1100 Subject: [PATCH] Update RaidUlduarBossHelper.cpp --- .../raids/ulduar/RaidUlduarBossHelper.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/strategy/raids/ulduar/RaidUlduarBossHelper.cpp b/src/strategy/raids/ulduar/RaidUlduarBossHelper.cpp index 2b41fc38..3ce25b04 100644 --- a/src/strategy/raids/ulduar/RaidUlduarBossHelper.cpp +++ b/src/strategy/raids/ulduar/RaidUlduarBossHelper.cpp @@ -133,8 +133,24 @@ bool RazorscaleBossHelper::AreRolesAssigned() const bool RazorscaleBossHelper::CanSwapRoles() const { + // Identify the GUID of the current bot + ObjectGuid botGuid = bot->GetGUID(); + if (!botGuid) + return false; + + // If no entry exists yet for this bot, initialize it to 0 + auto it = _lastRoleSwapTime.find(botGuid); + if (it == _lastRoleSwapTime.end()) + { + _lastRoleSwapTime[botGuid] = 0; + it = _lastRoleSwapTime.find(botGuid); + } + + // Compare the current time against the stored time std::time_t currentTime = std::time(nullptr); - return (currentTime - _lastRoleSwapTime) >= _roleSwapCooldown; + std::time_t lastSwapTime = it->second; + + return (currentTime - lastSwapTime) >= _roleSwapCooldown; } void RazorscaleBossHelper::AssignRolesBasedOnHealth()