diff options
author | Shauren <shauren.trinity@gmail.com> | 2014-10-22 00:35:00 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-09-29 00:15:41 +0200 |
commit | d2da9ce4ef7c7b0c138ed9d6f233e89bf7260c9b (patch) | |
tree | 022a8f7b4ab5470c789be5cfacece4a332851af6 /src | |
parent | 7eab6a791ae1c039de67a80ff8bd125bf69f7ba4 (diff) |
Core/Groups: Use full guid for group lookup
(cherry picked from commit e7d9830a06aa23c49b93053c4debb98d1bbcea69)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Battlefield/Battlefield.cpp | 4 | ||||
-rw-r--r-- | src/server/game/DungeonFinding/LFGMgr.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 23 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 6 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 17 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 6 | ||||
-rw-r--r-- | src/server/game/Groups/Group.cpp | 16 | ||||
-rw-r--r-- | src/server/game/Groups/GroupMgr.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Groups/GroupMgr.h | 2 |
9 files changed, 43 insertions, 41 deletions
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index f79a309c35b..614fdc5c66c 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -504,7 +504,7 @@ void Battlefield::ShowNpc(Creature* creature, bool aggressive) Group* Battlefield::GetFreeBfRaid(TeamId TeamId) { for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) - if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter())) + if (Group* group = sGroupMgr->GetGroupByGUID(*itr)) if (!group->IsFull()) return group; @@ -514,7 +514,7 @@ Group* Battlefield::GetFreeBfRaid(TeamId TeamId) Group* Battlefield::GetGroupPlayer(ObjectGuid guid, TeamId TeamId) { for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr) - if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter())) + if (Group* group = sGroupMgr->GetGroupByGUID(*itr)) if (group->IsMember(guid)) return group; diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 1bd949b4da9..96ae15543b8 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -640,7 +640,7 @@ void LFGMgr::LeaveLfg(ObjectGuid guid, bool disconnected) // Set the new state to LFG_STATE_DUNGEON/LFG_STATE_FINISHED_DUNGEON if the group is already in a dungeon // This is required in case a LFG group vote-kicks a player in a dungeon, queues, then leaves the queue (maybe to queue later again) - if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter())) + if (Group* group = sGroupMgr->GetGroupByGUID(gguid)) if (group->isLFGGroup() && GetDungeon(gguid) && (oldState == LFG_STATE_DUNGEON || oldState == LFG_STATE_FINISHED_DUNGEON)) newState = oldState; @@ -967,7 +967,7 @@ void LFGMgr::MakeNewGroup(LfgProposal const& proposal) LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId); ASSERT(dungeon); - Group* grp = !proposal.group.IsEmpty() ? sGroupMgr->GetGroupByGUID(proposal.group.GetCounter()) : nullptr; + Group* grp = !proposal.group.IsEmpty() ? sGroupMgr->GetGroupByGUID(proposal.group) : nullptr; for (GuidList::const_iterator it = players.begin(); it != players.end(); ++it) { ObjectGuid pguid = (*it); @@ -1326,7 +1326,7 @@ void LFGMgr::UpdateBoot(ObjectGuid guid, bool accept) SetVoteKick(gguid, false); if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player { - if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter())) + if (Group* group = sGroupMgr->GetGroupByGUID(gguid)) Player::RemoveFromGroup(group, boot.victim, GROUP_REMOVEMETHOD_KICK_LFG); DecreaseKicksLeft(gguid); } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index ba8ad1e613b..9e13f3d295b 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -250,7 +250,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) return true; } -Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipient(), m_lootRecipientGroup(0), _pickpocketLootRestore(0), +Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), m_groupLootTimer(0), m_PlayerDamageReq(0), _pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_ignoreCorpseDecayRatio(false), m_wanderDistance(0.0f), m_boundaryCheckTime(2500), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), @@ -737,17 +737,18 @@ void Creature::Update(uint32 diff) if (IsEngaged()) Unit::AIUpdateTick(diff); - if (m_groupLootTimer && lootingGroupLowGUID) + if (m_groupLootTimer && !lootingGroupLowGUID.IsEmpty()) { if (m_groupLootTimer <= diff) { - Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID); - if (group) + if (Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID)) group->EndRoll(&loot, GetMap()); + m_groupLootTimer = 0; - lootingGroupLowGUID = 0; + lootingGroupLowGUID.Clear(); } - else m_groupLootTimer -= diff; + else + m_groupLootTimer -= diff; } else if (m_corpseRemoveTime <= GameTime::GetGameTime()) { @@ -1245,13 +1246,15 @@ Player* Creature::GetLootRecipient() const { if (!m_lootRecipient) return nullptr; + return ObjectAccessor::FindConnectedPlayer(m_lootRecipient); } Group* Creature::GetLootRecipientGroup() const { - if (!m_lootRecipientGroup) + if (m_lootRecipientGroup.IsEmpty()) return nullptr; + return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup); } @@ -1264,7 +1267,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup) if (!unit) { m_lootRecipient.Clear(); - m_lootRecipientGroup = 0; + m_lootRecipientGroup.Clear(); RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE|UNIT_DYNFLAG_TAPPED); return; } @@ -1280,10 +1283,10 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup) if (withGroup) { if (Group* group = player->GetGroup()) - m_lootRecipientGroup = group->GetLowGUID(); + m_lootRecipientGroup = group->GetGUID(); } else - m_lootRecipientGroup = 0; + m_lootRecipientGroup = ObjectGuid::Empty; SetDynamicFlag(UNIT_DYNFLAG_TAPPED); } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 1c1504d74e3..85823112dd4 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -221,7 +221,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma ObjectGuid GetLootRecipientGUID() const { return m_lootRecipient; } Player* GetLootRecipient() const; Group* GetLootRecipientGroup() const; - bool hasLootRecipient() const { return !m_lootRecipient.IsEmpty() || m_lootRecipientGroup; } + bool hasLootRecipient() const { return !m_lootRecipient.IsEmpty() || !m_lootRecipientGroup.IsEmpty(); } bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party. void SetLootRecipient (Unit* unit, bool withGroup = true); @@ -282,7 +282,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma } uint32 m_groupLootTimer; // (msecs)timer used for group loot - ObjectGuid::LowType lootingGroupLowGUID; // used to find group which is looting corpse + ObjectGuid lootingGroupLowGUID; // used to find group which is looting corpse void SendZoneUnderAttackMessage(Player* attacker); @@ -388,7 +388,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma static float _GetHealthMod(int32 Rank); ObjectGuid m_lootRecipient; - uint32 m_lootRecipientGroup; + ObjectGuid m_lootRecipientGroup; /// Timers time_t _pickpocketLootRestore; diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 6b85c8bdb88..1b3b30e5dc2 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -134,9 +134,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(), m_spawnId = 0; - m_lootRecipientGroup = 0; m_groupLootTimer = 0; - lootingGroupLowGUID = 0; m_lootGenerationTime = 0; ResetLootMode(); // restore default loot mode @@ -747,13 +745,14 @@ void GameObject::Update(uint32 diff) { if (m_groupLootTimer <= diff) { - Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID); - if (group) + if (Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID)) group->EndRoll(&loot, GetMap()); + m_groupLootTimer = 0; - lootingGroupLowGUID = 0; + lootingGroupLowGUID.Clear(); } - else m_groupLootTimer -= diff; + else + m_groupLootTimer -= diff; } // Non-consumable chest was partially looted and restock time passed, restock all loot now @@ -2644,7 +2643,7 @@ void GameObject::SetLootRecipient(Unit* unit, Group* group) if (!unit) { m_lootRecipient.Clear(); - m_lootRecipientGroup = group ? group->GetLowGUID() : 0; + m_lootRecipientGroup = group ? group->GetGUID() : ObjectGuid::Empty; return; } @@ -2659,9 +2658,9 @@ void GameObject::SetLootRecipient(Unit* unit, Group* group) // either get the group from the passed parameter or from unit's one if (group) - m_lootRecipientGroup = group->GetLowGUID(); + m_lootRecipientGroup = group->GetGUID(); else if (Group* unitGroup = player->GetGroup()) - m_lootRecipientGroup = unitGroup->GetLowGUID(); + m_lootRecipientGroup = unitGroup->GetGUID(); } bool GameObject::IsLootAllowedFor(Player const* player) const diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index a047b4c9560..b762f5472a3 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -224,9 +224,9 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> Group* GetLootRecipientGroup() const; void SetLootRecipient(Unit* unit, Group* group = nullptr); bool IsLootAllowedFor(Player const* player) const; - bool HasLootRecipient() const { return !m_lootRecipient.IsEmpty() || m_lootRecipientGroup; } + bool HasLootRecipient() const { return !m_lootRecipient.IsEmpty() || !m_lootRecipientGroup.IsEmpty(); } uint32 m_groupLootTimer; // (msecs)timer used for group loot - ObjectGuid::LowType lootingGroupLowGUID; // used to find group which is looting + ObjectGuid lootingGroupLowGUID; // used to find group which is looting GameObject* GetLinkedTrap(); void SetLinkedTrap(GameObject* linkedTrap) { m_linkedTrap = linkedTrap->GetGUID(); } @@ -352,7 +352,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> Position m_stationaryPosition; ObjectGuid m_lootRecipient; - uint32 m_lootRecipientGroup; + ObjectGuid m_lootRecipientGroup; uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable uint32 m_lootGenerationTime; diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 2c6867bc9fa..d450c0d5eca 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -1141,12 +1141,12 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject) if (Creature* creature = pLootedObject->ToCreature()) { creature->m_groupLootTimer = 60000; - creature->lootingGroupLowGUID = GetLowGUID(); + creature->lootingGroupLowGUID = GetGUID(); } else if (GameObject* go = pLootedObject->ToGameObject()) { go->m_groupLootTimer = 60000; - go->lootingGroupLowGUID = GetLowGUID(); + go->lootingGroupLowGUID = GetGUID(); } } } @@ -1207,12 +1207,12 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject) if (Creature* creature = pLootedObject->ToCreature()) { creature->m_groupLootTimer = 60000; - creature->lootingGroupLowGUID = GetLowGUID(); + creature->lootingGroupLowGUID = GetGUID(); } else if (GameObject* go = pLootedObject->ToGameObject()) { go->m_groupLootTimer = 60000; - go->lootingGroupLowGUID = GetLowGUID(); + go->lootingGroupLowGUID = GetGUID(); } } else @@ -1288,12 +1288,12 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject) if (Creature* creature = lootedObject->ToCreature()) { creature->m_groupLootTimer = 60000; - creature->lootingGroupLowGUID = GetLowGUID(); + creature->lootingGroupLowGUID = GetGUID(); } else if (GameObject* go = lootedObject->ToGameObject()) { go->m_groupLootTimer = 60000; - go->lootingGroupLowGUID = GetLowGUID(); + go->lootingGroupLowGUID = GetGUID(); } } else @@ -1357,12 +1357,12 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject) if (Creature* creature = lootedObject->ToCreature()) { creature->m_groupLootTimer = 60000; - creature->lootingGroupLowGUID = GetLowGUID(); + creature->lootingGroupLowGUID = GetGUID(); } else if (GameObject* go = lootedObject->ToGameObject()) { go->m_groupLootTimer = 60000; - go->lootingGroupLowGUID = GetLowGUID(); + go->lootingGroupLowGUID = GetGUID(); } } else diff --git a/src/server/game/Groups/GroupMgr.cpp b/src/server/game/Groups/GroupMgr.cpp index 4a64c5a42a1..ebcaa0b9485 100644 --- a/src/server/game/Groups/GroupMgr.cpp +++ b/src/server/game/Groups/GroupMgr.cpp @@ -100,9 +100,9 @@ GroupMgr* GroupMgr::instance() return &instance; } -Group* GroupMgr::GetGroupByGUID(ObjectGuid::LowType groupId) const +Group* GroupMgr::GetGroupByGUID(ObjectGuid const& groupId) const { - GroupContainer::const_iterator itr = GroupStore.find(groupId); + GroupContainer::const_iterator itr = GroupStore.find(groupId.GetCounter()); if (itr != GroupStore.end()) return itr->second; diff --git a/src/server/game/Groups/GroupMgr.h b/src/server/game/Groups/GroupMgr.h index 5b20f285818..781264b78f7 100644 --- a/src/server/game/Groups/GroupMgr.h +++ b/src/server/game/Groups/GroupMgr.h @@ -32,7 +32,7 @@ public: typedef std::map<ObjectGuid::LowType, Group*> GroupContainer; typedef std::vector<Group*> GroupDbContainer; - Group* GetGroupByGUID(ObjectGuid::LowType guid) const; + Group* GetGroupByGUID(ObjectGuid const& guid) const; uint32 GenerateNewGroupDbStoreId(); void RegisterGroupDbStoreId(uint32 storageId, Group* group); |