From dc9c3a5fe4e6d2b0c233fcaf17e8a7fe27625452 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Mon, 22 Nov 2021 16:07:55 +0100 Subject: [PATCH] =?UTF-8?q?fix(Core/GameObjects):=20Lockpicking=20timer=20?= =?UTF-8?q?on=20gameobjects=20should=20reset=20=E2=80=A6=20(#9203)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(Core/GameObjects): Lockpicking timer on gameobjects should reset after 10 minutes. Fixes #8936 --- .../game/Entities/GameObject/GameObject.cpp | 35 +++++++++++++++++++ .../game/Entities/GameObject/GameObject.h | 14 ++------ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index ba01eba05..0cdd9301c 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -430,6 +430,22 @@ void GameObject::Update(uint32 diff) } } + for (std::unordered_map::iterator itr = m_SkillupList.begin(); itr != m_SkillupList.end();) + { + if (itr->second > 0) + { + if (itr->second > static_cast(diff)) + { + itr->second -= static_cast(diff); + ++itr; + } + else + { + itr = m_SkillupList.erase(itr); + } + } + } + switch (m_lootState) { case GO_NOT_READY: @@ -2848,3 +2864,22 @@ SpellInfo const* GameObject::GetSpellForLock(Player const* player) const return nullptr; } + +void GameObject::AddToSkillupList(ObjectGuid playerGuid) +{ + int32 timer = GetMap()->IsDungeon() ? -1 : 10 * MINUTE * IN_MILLISECONDS; + m_SkillupList[playerGuid] = timer; +} + +bool GameObject::IsInSkillupList(ObjectGuid playerGuid) const +{ + for (auto const& itr : m_SkillupList) + { + if (itr.first == playerGuid) + { + return true; + } + } + + return false; +} diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 2cc5a80eb..1a71c1f38 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -854,16 +854,8 @@ public: void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; } void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; } - void AddToSkillupList(ObjectGuid playerGuid) { m_SkillupList.push_back(playerGuid); } - [[nodiscard]] bool IsInSkillupList(ObjectGuid playerGuid) const - { - for (ObjectGuid const& guid : m_SkillupList) - if (guid == playerGuid) - return true; - - return false; - } - void ClearSkillupList() { m_SkillupList.clear(); } + void AddToSkillupList(ObjectGuid playerGuid); + [[nodiscard]] bool IsInSkillupList(ObjectGuid playerGuid) const; void AddUniqueUse(Player* player); void AddUse() { ++m_usetimes; } @@ -991,7 +983,7 @@ protected: bool m_spawnedByDefault; uint32 m_cooldownTime; // used as internal reaction delay time store (not state change reaction). // For traps this: spell casting cooldown, for doors/buttons: reset time. - GuidList m_SkillupList; + std::unordered_map m_SkillupList; ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner) GuidSet m_unique_users;