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;