mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Groups: Use full guid for group lookup
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user