mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Core/Groups: Use full guid for group lookup
(cherry picked from commit e7d9830a06)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user