diff options
author | Shauren <shauren.trinity@gmail.com> | 2014-10-22 00:35:00 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2014-10-22 00:35:00 +0200 |
commit | e7d9830a06aa23c49b93053c4debb98d1bbcea69 (patch) | |
tree | 216e91793e259fe6d50f9304bf58e277c45e0a15 | |
parent | 7ae708acf57899721d77e4d09e1636281582f8e7 (diff) |
Core/Groups: Use full guid for group lookup
-rw-r--r-- | src/server/game/Battlefield/Battlefield.cpp | 4 | ||||
-rw-r--r-- | src/server/game/DungeonFinding/LFGMgr.cpp | 4 | ||||
-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 | 15 | ||||
-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, 41 insertions, 39 deletions
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index deab0dee14f..e1759c0d34c 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -483,7 +483,7 @@ void Battlefield::ShowNpc(Creature* creature, bool aggressive) Group* Battlefield::GetFreeBfRaid(TeamId TeamId) { for (GuidSet::const_iterator 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; @@ -493,7 +493,7 @@ Group* Battlefield::GetFreeBfRaid(TeamId TeamId) Group* Battlefield::GetGroupPlayer(ObjectGuid guid, TeamId TeamId) { for (GuidSet::const_iterator 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 9ce0d3093db..f8cb76298d8 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -863,7 +863,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()) : NULL; + Group* grp = !proposal.group.IsEmpty() ? sGroupMgr->GetGroupByGUID(proposal.group) : NULL; for (GuidList::const_iterator it = players.begin(); it != players.end(); ++it) { ObjectGuid pguid = (*it); @@ -1210,7 +1210,7 @@ void LFGMgr::UpdateBoot(ObjectGuid guid, bool accept) SetState(gguid, LFG_STATE_DUNGEON); 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 3a7de2caf6e..827e51c31af 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -142,8 +142,8 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) } Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), -m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), -m_lootRecipient(), m_lootRecipientGroup(0), _skinner(), _pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0), +m_groupLootTimer(0), m_PlayerDamageReq(0), +_pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), @@ -494,17 +494,18 @@ void Creature::Update(uint32 diff) if (m_deathState != CORPSE) break; - 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); + m_groupLootTimer = 0; - lootingGroupLowGUID = 0; + lootingGroupLowGUID.Clear(); } - else m_groupLootTimer -= diff; + else + m_groupLootTimer -= diff; } else if (m_corpseRemoveTime <= time(NULL)) { @@ -875,13 +876,15 @@ Player* Creature::GetLootRecipient() const { if (!m_lootRecipient) return NULL; + return ObjectAccessor::FindConnectedPlayer(m_lootRecipient); } Group* Creature::GetLootRecipientGroup() const { - if (!m_lootRecipientGroup) + if (m_lootRecipientGroup.IsEmpty()) return NULL; + return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup); } @@ -894,7 +897,7 @@ void Creature::SetLootRecipient(Unit* unit) if (!unit) { m_lootRecipient.Clear(); - m_lootRecipientGroup = 0; + m_lootRecipientGroup.Clear(); RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE|UNIT_DYNFLAG_TAPPED); return; } @@ -908,7 +911,7 @@ void Creature::SetLootRecipient(Unit* unit) m_lootRecipient = player->GetGUID(); if (Group* group = player->GetGroup()) - m_lootRecipientGroup = group->GetLowGUID(); + m_lootRecipientGroup = group->GetGUID(); SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED); } diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index c147c3e3f27..41c2f00dcfd 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -556,7 +556,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject ObjectGuid GetSkinner() const { return _skinner; } // Returns the player who skinned this creature 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); @@ -616,7 +616,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject void SetRespawnRadius(float dist) { m_respawnradius = dist; } uint32 m_groupLootTimer; // (msecs)timer used for group loot - uint32 lootingGroupLowGUID; // used to find group which is looting corpse + ObjectGuid lootingGroupLowGUID; // used to find group which is looting corpse void SendZoneUnderAttackMessage(Player* attacker); @@ -686,7 +686,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject static float _GetHealthMod(int32 Rank); ObjectGuid m_lootRecipient; - uint32 m_lootRecipientGroup; + ObjectGuid m_lootRecipientGroup; ObjectGuid _skinner; /// Timers diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 5d035286c25..947b4e81b04 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -57,9 +57,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(), m_DBTableGuid = 0; m_rotation = 0; - m_lootRecipientGroup = 0; m_groupLootTimer = 0; - lootingGroupLowGUID = 0; ResetLootMode(); // restore default loot mode m_stationaryPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f); @@ -560,13 +558,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); + m_groupLootTimer = 0; - lootingGroupLowGUID = 0; + lootingGroupLowGUID.Clear(); } - else m_groupLootTimer -= diff; + else + m_groupLootTimer -= diff; } break; case GAMEOBJECT_TYPE_TRAP: @@ -2204,7 +2203,7 @@ void GameObject::SetLootRecipient(Unit* unit) if (!unit) { m_lootRecipient.Clear(); - m_lootRecipientGroup = 0; + m_lootRecipientGroup.Clear(); return; } @@ -2217,7 +2216,7 @@ void GameObject::SetLootRecipient(Unit* unit) m_lootRecipient = player->GetGUID(); if (Group* group = player->GetGroup()) - m_lootRecipientGroup = group->GetLowGUID(); + m_lootRecipientGroup = group->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 4eeb3ae2b31..adb25d1854f 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -780,9 +780,9 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map Group* GetLootRecipientGroup() const; void SetLootRecipient(Unit* unit); 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 - uint32 lootingGroupLowGUID; // used to find group which is looting + ObjectGuid lootingGroupLowGUID; // used to find group which is looting bool hasQuest(uint32 quest_id) const override; bool hasInvolvedQuest(uint32 quest_id) const override; @@ -881,7 +881,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map 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 private: void RemoveFromOwner(); diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index e17e9b0b834..463b12379fa 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -1016,12 +1016,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 @@ -1077,12 +1077,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 @@ -1158,12 +1158,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 @@ -1221,12 +1221,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 23b6998d688..c98a40a48d1 100644 --- a/src/server/game/Groups/GroupMgr.cpp +++ b/src/server/game/Groups/GroupMgr.cpp @@ -92,9 +92,9 @@ uint32 GroupMgr::GenerateGroupId() return NextGroupId++; } -Group* GroupMgr::GetGroupByGUID(uint32 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 556df1bc351..3e053921f74 100644 --- a/src/server/game/Groups/GroupMgr.h +++ b/src/server/game/Groups/GroupMgr.h @@ -36,7 +36,7 @@ public: typedef std::map<uint32, Group*> GroupContainer; typedef std::vector<Group*> GroupDbContainer; - Group* GetGroupByGUID(uint32 guid) const; + Group* GetGroupByGUID(ObjectGuid const& guid) const; uint32 GenerateNewGroupDbStoreId(); void RegisterGroupDbStoreId(uint32 storageId, Group* group); |