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 /src/server/game/Entities | |
| parent | 7ae708acf57899721d77e4d09e1636281582f8e7 (diff) | |
Core/Groups: Use full guid for group lookup
Diffstat (limited to 'src/server/game/Entities')
| -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 |
4 files changed, 26 insertions, 24 deletions
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(); |
