Skip to content

Commit d2da9ce

Browse files
committed
Core/Groups: Use full guid for group lookup
(cherry picked from commit e7d9830)
1 parent 7eab6a7 commit d2da9ce

File tree

9 files changed

+43
-41
lines changed

9 files changed

+43
-41
lines changed

src/server/game/Battlefield/Battlefield.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ void Battlefield::ShowNpc(Creature* creature, bool aggressive)
504504
Group* Battlefield::GetFreeBfRaid(TeamId TeamId)
505505
{
506506
for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
507-
if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter()))
507+
if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
508508
if (!group->IsFull())
509509
return group;
510510

@@ -514,7 +514,7 @@ Group* Battlefield::GetFreeBfRaid(TeamId TeamId)
514514
Group* Battlefield::GetGroupPlayer(ObjectGuid guid, TeamId TeamId)
515515
{
516516
for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
517-
if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter()))
517+
if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
518518
if (group->IsMember(guid))
519519
return group;
520520

src/server/game/DungeonFinding/LFGMgr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ void LFGMgr::LeaveLfg(ObjectGuid guid, bool disconnected)
640640

641641
// Set the new state to LFG_STATE_DUNGEON/LFG_STATE_FINISHED_DUNGEON if the group is already in a dungeon
642642
// 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)
643-
if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
643+
if (Group* group = sGroupMgr->GetGroupByGUID(gguid))
644644
if (group->isLFGGroup() && GetDungeon(gguid) && (oldState == LFG_STATE_DUNGEON || oldState == LFG_STATE_FINISHED_DUNGEON))
645645
newState = oldState;
646646

@@ -967,7 +967,7 @@ void LFGMgr::MakeNewGroup(LfgProposal const& proposal)
967967
LFGDungeonData const* dungeon = GetLFGDungeon(proposal.dungeonId);
968968
ASSERT(dungeon);
969969

970-
Group* grp = !proposal.group.IsEmpty() ? sGroupMgr->GetGroupByGUID(proposal.group.GetCounter()) : nullptr;
970+
Group* grp = !proposal.group.IsEmpty() ? sGroupMgr->GetGroupByGUID(proposal.group) : nullptr;
971971
for (GuidList::const_iterator it = players.begin(); it != players.end(); ++it)
972972
{
973973
ObjectGuid pguid = (*it);
@@ -1326,7 +1326,7 @@ void LFGMgr::UpdateBoot(ObjectGuid guid, bool accept)
13261326
SetVoteKick(gguid, false);
13271327
if (agreeNum == LFG_GROUP_KICK_VOTES_NEEDED) // Vote passed - Kick player
13281328
{
1329-
if (Group* group = sGroupMgr->GetGroupByGUID(gguid.GetCounter()))
1329+
if (Group* group = sGroupMgr->GetGroupByGUID(gguid))
13301330
Player::RemoveFromGroup(group, boot.victim, GROUP_REMOVEMETHOD_KICK_LFG);
13311331
DecreaseKicksLeft(gguid);
13321332
}

src/server/game/Entities/Creature/Creature.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
250250
return true;
251251
}
252252

253-
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipient(), m_lootRecipientGroup(0), _pickpocketLootRestore(0),
253+
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), m_groupLootTimer(0), m_PlayerDamageReq(0), _pickpocketLootRestore(0),
254254
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_ignoreCorpseDecayRatio(false), m_wanderDistance(0.0f),
255255
m_boundaryCheckTime(2500), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE),
256256
m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0),
@@ -737,17 +737,18 @@ void Creature::Update(uint32 diff)
737737
if (IsEngaged())
738738
Unit::AIUpdateTick(diff);
739739

740-
if (m_groupLootTimer && lootingGroupLowGUID)
740+
if (m_groupLootTimer && !lootingGroupLowGUID.IsEmpty())
741741
{
742742
if (m_groupLootTimer <= diff)
743743
{
744-
Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID);
745-
if (group)
744+
if (Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID))
746745
group->EndRoll(&loot, GetMap());
746+
747747
m_groupLootTimer = 0;
748-
lootingGroupLowGUID = 0;
748+
lootingGroupLowGUID.Clear();
749749
}
750-
else m_groupLootTimer -= diff;
750+
else
751+
m_groupLootTimer -= diff;
751752
}
752753
else if (m_corpseRemoveTime <= GameTime::GetGameTime())
753754
{
@@ -1245,13 +1246,15 @@ Player* Creature::GetLootRecipient() const
12451246
{
12461247
if (!m_lootRecipient)
12471248
return nullptr;
1249+
12481250
return ObjectAccessor::FindConnectedPlayer(m_lootRecipient);
12491251
}
12501252

12511253
Group* Creature::GetLootRecipientGroup() const
12521254
{
1253-
if (!m_lootRecipientGroup)
1255+
if (m_lootRecipientGroup.IsEmpty())
12541256
return nullptr;
1257+
12551258
return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup);
12561259
}
12571260

@@ -1264,7 +1267,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup)
12641267
if (!unit)
12651268
{
12661269
m_lootRecipient.Clear();
1267-
m_lootRecipientGroup = 0;
1270+
m_lootRecipientGroup.Clear();
12681271
RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE|UNIT_DYNFLAG_TAPPED);
12691272
return;
12701273
}
@@ -1280,10 +1283,10 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup)
12801283
if (withGroup)
12811284
{
12821285
if (Group* group = player->GetGroup())
1283-
m_lootRecipientGroup = group->GetLowGUID();
1286+
m_lootRecipientGroup = group->GetGUID();
12841287
}
12851288
else
1286-
m_lootRecipientGroup = 0;
1289+
m_lootRecipientGroup = ObjectGuid::Empty;
12871290

12881291
SetDynamicFlag(UNIT_DYNFLAG_TAPPED);
12891292
}

src/server/game/Entities/Creature/Creature.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
221221
ObjectGuid GetLootRecipientGUID() const { return m_lootRecipient; }
222222
Player* GetLootRecipient() const;
223223
Group* GetLootRecipientGroup() const;
224-
bool hasLootRecipient() const { return !m_lootRecipient.IsEmpty() || m_lootRecipientGroup; }
224+
bool hasLootRecipient() const { return !m_lootRecipient.IsEmpty() || !m_lootRecipientGroup.IsEmpty(); }
225225
bool isTappedBy(Player const* player) const; // return true if the creature is tapped by the player or a member of his party.
226226

227227
void SetLootRecipient (Unit* unit, bool withGroup = true);
@@ -282,7 +282,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
282282
}
283283

284284
uint32 m_groupLootTimer; // (msecs)timer used for group loot
285-
ObjectGuid::LowType lootingGroupLowGUID; // used to find group which is looting corpse
285+
ObjectGuid lootingGroupLowGUID; // used to find group which is looting corpse
286286

287287
void SendZoneUnderAttackMessage(Player* attacker);
288288

@@ -388,7 +388,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
388388
static float _GetHealthMod(int32 Rank);
389389

390390
ObjectGuid m_lootRecipient;
391-
uint32 m_lootRecipientGroup;
391+
ObjectGuid m_lootRecipientGroup;
392392

393393
/// Timers
394394
time_t _pickpocketLootRestore;

src/server/game/Entities/GameObject/GameObject.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
134134

135135
m_spawnId = 0;
136136

137-
m_lootRecipientGroup = 0;
138137
m_groupLootTimer = 0;
139-
lootingGroupLowGUID = 0;
140138
m_lootGenerationTime = 0;
141139

142140
ResetLootMode(); // restore default loot mode
@@ -747,13 +745,14 @@ void GameObject::Update(uint32 diff)
747745
{
748746
if (m_groupLootTimer <= diff)
749747
{
750-
Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID);
751-
if (group)
748+
if (Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID))
752749
group->EndRoll(&loot, GetMap());
750+
753751
m_groupLootTimer = 0;
754-
lootingGroupLowGUID = 0;
752+
lootingGroupLowGUID.Clear();
755753
}
756-
else m_groupLootTimer -= diff;
754+
else
755+
m_groupLootTimer -= diff;
757756
}
758757

759758
// 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)
26442643
if (!unit)
26452644
{
26462645
m_lootRecipient.Clear();
2647-
m_lootRecipientGroup = group ? group->GetLowGUID() : 0;
2646+
m_lootRecipientGroup = group ? group->GetGUID() : ObjectGuid::Empty;
26482647
return;
26492648
}
26502649

@@ -2659,9 +2658,9 @@ void GameObject::SetLootRecipient(Unit* unit, Group* group)
26592658

26602659
// either get the group from the passed parameter or from unit's one
26612660
if (group)
2662-
m_lootRecipientGroup = group->GetLowGUID();
2661+
m_lootRecipientGroup = group->GetGUID();
26632662
else if (Group* unitGroup = player->GetGroup())
2664-
m_lootRecipientGroup = unitGroup->GetLowGUID();
2663+
m_lootRecipientGroup = unitGroup->GetGUID();
26652664
}
26662665

26672666
bool GameObject::IsLootAllowedFor(Player const* player) const

src/server/game/Entities/GameObject/GameObject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
224224
Group* GetLootRecipientGroup() const;
225225
void SetLootRecipient(Unit* unit, Group* group = nullptr);
226226
bool IsLootAllowedFor(Player const* player) const;
227-
bool HasLootRecipient() const { return !m_lootRecipient.IsEmpty() || m_lootRecipientGroup; }
227+
bool HasLootRecipient() const { return !m_lootRecipient.IsEmpty() || !m_lootRecipientGroup.IsEmpty(); }
228228
uint32 m_groupLootTimer; // (msecs)timer used for group loot
229-
ObjectGuid::LowType lootingGroupLowGUID; // used to find group which is looting
229+
ObjectGuid lootingGroupLowGUID; // used to find group which is looting
230230

231231
GameObject* GetLinkedTrap();
232232
void SetLinkedTrap(GameObject* linkedTrap) { m_linkedTrap = linkedTrap->GetGUID(); }
@@ -352,7 +352,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
352352
Position m_stationaryPosition;
353353

354354
ObjectGuid m_lootRecipient;
355-
uint32 m_lootRecipientGroup;
355+
ObjectGuid m_lootRecipientGroup;
356356
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
357357
uint32 m_lootGenerationTime;
358358

src/server/game/Groups/Group.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,12 +1141,12 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject)
11411141
if (Creature* creature = pLootedObject->ToCreature())
11421142
{
11431143
creature->m_groupLootTimer = 60000;
1144-
creature->lootingGroupLowGUID = GetLowGUID();
1144+
creature->lootingGroupLowGUID = GetGUID();
11451145
}
11461146
else if (GameObject* go = pLootedObject->ToGameObject())
11471147
{
11481148
go->m_groupLootTimer = 60000;
1149-
go->lootingGroupLowGUID = GetLowGUID();
1149+
go->lootingGroupLowGUID = GetGUID();
11501150
}
11511151
}
11521152
}
@@ -1207,12 +1207,12 @@ void Group::GroupLoot(Loot* loot, WorldObject* pLootedObject)
12071207
if (Creature* creature = pLootedObject->ToCreature())
12081208
{
12091209
creature->m_groupLootTimer = 60000;
1210-
creature->lootingGroupLowGUID = GetLowGUID();
1210+
creature->lootingGroupLowGUID = GetGUID();
12111211
}
12121212
else if (GameObject* go = pLootedObject->ToGameObject())
12131213
{
12141214
go->m_groupLootTimer = 60000;
1215-
go->lootingGroupLowGUID = GetLowGUID();
1215+
go->lootingGroupLowGUID = GetGUID();
12161216
}
12171217
}
12181218
else
@@ -1288,12 +1288,12 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
12881288
if (Creature* creature = lootedObject->ToCreature())
12891289
{
12901290
creature->m_groupLootTimer = 60000;
1291-
creature->lootingGroupLowGUID = GetLowGUID();
1291+
creature->lootingGroupLowGUID = GetGUID();
12921292
}
12931293
else if (GameObject* go = lootedObject->ToGameObject())
12941294
{
12951295
go->m_groupLootTimer = 60000;
1296-
go->lootingGroupLowGUID = GetLowGUID();
1296+
go->lootingGroupLowGUID = GetGUID();
12971297
}
12981298
}
12991299
else
@@ -1357,12 +1357,12 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
13571357
if (Creature* creature = lootedObject->ToCreature())
13581358
{
13591359
creature->m_groupLootTimer = 60000;
1360-
creature->lootingGroupLowGUID = GetLowGUID();
1360+
creature->lootingGroupLowGUID = GetGUID();
13611361
}
13621362
else if (GameObject* go = lootedObject->ToGameObject())
13631363
{
13641364
go->m_groupLootTimer = 60000;
1365-
go->lootingGroupLowGUID = GetLowGUID();
1365+
go->lootingGroupLowGUID = GetGUID();
13661366
}
13671367
}
13681368
else

src/server/game/Groups/GroupMgr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ GroupMgr* GroupMgr::instance()
100100
return &instance;
101101
}
102102

103-
Group* GroupMgr::GetGroupByGUID(ObjectGuid::LowType groupId) const
103+
Group* GroupMgr::GetGroupByGUID(ObjectGuid const& groupId) const
104104
{
105-
GroupContainer::const_iterator itr = GroupStore.find(groupId);
105+
GroupContainer::const_iterator itr = GroupStore.find(groupId.GetCounter());
106106
if (itr != GroupStore.end())
107107
return itr->second;
108108

src/server/game/Groups/GroupMgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TC_GAME_API GroupMgr
3232
typedef std::map<ObjectGuid::LowType, Group*> GroupContainer;
3333
typedef std::vector<Group*> GroupDbContainer;
3434

35-
Group* GetGroupByGUID(ObjectGuid::LowType guid) const;
35+
Group* GetGroupByGUID(ObjectGuid const& guid) const;
3636

3737
uint32 GenerateNewGroupDbStoreId();
3838
void RegisterGroupDbStoreId(uint32 storageId, Group* group);

0 commit comments

Comments
 (0)