From e7d9830a06aa23c49b93053c4debb98d1bbcea69 Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 22 Oct 2014 00:35:00 +0200 Subject: Core/Groups: Use full guid for group lookup --- src/server/game/Entities/Creature/Creature.cpp | 23 +++++++++++++---------- src/server/game/Entities/Creature/Creature.h | 6 +++--- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src/server/game/Entities/Creature') 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, 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, 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, public MapObject static float _GetHealthMod(int32 Rank); ObjectGuid m_lootRecipient; - uint32 m_lootRecipientGroup; + ObjectGuid m_lootRecipientGroup; ObjectGuid _skinner; /// Timers -- cgit v1.2.3