aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/GameObject
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-09-14 16:14:12 +0200
committerShauren <shauren.trinity@gmail.com>2014-09-14 16:14:12 +0200
commita0e50ea35fca61447bf07fc45d93c98234ba59f7 (patch)
treeb4ee69a63866f42e466a3c03fc031ce0710ac762 /src/server/game/Entities/GameObject
parentce67a097bf3c0c3241f4441a808e32639ddbaafb (diff)
Core/Entities: Use ObjectGuid class in game project
Diffstat (limited to 'src/server/game/Entities/GameObject')
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp50
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h18
2 files changed, 32 insertions, 36 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 3717248afda..3ebe2bfe429 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -47,19 +47,16 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
m_respawnTime = 0;
m_respawnDelayTime = 300;
m_lootState = GO_NOT_READY;
- m_lootStateUnitGUID = 0;
m_spawnedByDefault = true;
m_usetimes = 0;
m_spellId = 0;
m_cooldownTime = 0;
m_goInfo = NULL;
- m_ritualOwnerGUID = 0;
m_goData = NULL;
m_DBTableGuid = 0;
m_rotation = 0;
- m_lootRecipient = 0;
m_lootRecipientGroup = 0;
m_groupLootTimer = 0;
lootingGroupLowGUID = 0;
@@ -108,7 +105,7 @@ void GameObject::CleanupsBeforeDelete(bool finalCleanup)
void GameObject::RemoveFromOwner()
{
- uint64 ownerGUID = GetOwnerGUID();
+ ObjectGuid ownerGUID = GetOwnerGUID();
if (!ownerGUID)
return;
@@ -119,15 +116,9 @@ void GameObject::RemoveFromOwner()
return;
}
- const char * ownerType = "creature";
- if (IS_PLAYER_GUID(ownerGUID))
- ownerType = "player";
- else if (IS_PET_GUID(ownerGUID))
- ownerType = "pet";
-
- TC_LOG_FATAL("misc", "Removed GameObject (GUID: %u Entry: %u SpellId: %u LinkedGO: %u) that just lost any reference to the owner (GUID: %u Type: '%s') GO list",
- GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(ownerGUID), ownerType);
- SetOwnerGUID(0);
+ TC_LOG_FATAL("misc", "Removed GameObject (GUID: %u Entry: %u SpellId: %u LinkedGO: %u) that just lost any reference to the owner (%s) GO list",
+ GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString().c_str());
+ SetOwnerGUID(ObjectGuid::Empty);
}
void GameObject::AddToWorld()
@@ -385,11 +376,11 @@ void GameObject::Update(uint32 diff)
time_t now = time(NULL);
if (m_respawnTime <= now) // timer expired
{
- uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_GAMEOBJECT);
+ ObjectGuid dbtableHighGuid(HIGHGUID_GAMEOBJECT, GetEntry(), m_DBTableGuid);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
if (linkedRespawntime) // Can't respawn, the master is dead
{
- uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
+ ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
@@ -594,7 +585,7 @@ void GameObject::Update(uint32 diff)
if (spellId)
{
- for (std::set<uint64>::const_iterator it = m_unique_users.begin(); it != m_unique_users.end(); ++it)
+ for (GuidSet::const_iterator it = m_unique_users.begin(); it != m_unique_users.end(); ++it)
// m_unique_users can contain only player GUIDs
if (Player* owner = ObjectAccessor::GetPlayer(*this, *it))
owner->CastSpell(owner, spellId, false);
@@ -981,14 +972,15 @@ bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const
return false;
// Always seen by owner and friendly units
- if (uint64 guid = GetOwnerGUID())
+ if (ObjectGuid guid = GetOwnerGUID())
{
if (seer->GetGUID() == guid)
return true;
Unit* owner = GetOwner();
- if (owner && seer->isType(TYPEMASK_UNIT) && owner->IsFriendlyTo(((Unit*)seer)))
- return true;
+ if (Unit const* unitSeer = seer->ToUnit())
+ if (owner && owner->IsFriendlyTo(unitSeer))
+ return true;
}
return false;
@@ -1239,9 +1231,9 @@ void GameObject::Use(Unit* user)
{
if (info->chair.slots > 0) // sometimes chairs in DB have error in fields and we dont know number of slots
for (uint32 i = 0; i < info->chair.slots; ++i)
- ChairListSlots[i] = 0; // Last user of current slot set to 0 (none sit here yet)
+ ChairListSlots[i].Clear(); // Last user of current slot set to 0 (none sit here yet)
else
- ChairListSlots[0] = 0; // error in DB, make one default slot
+ ChairListSlots[0].Clear(); // error in DB, make one default slot
}
Player* player = user->ToPlayer();
@@ -1274,10 +1266,10 @@ void GameObject::Use(Unit* user)
if (ChairUser->IsSitState() && ChairUser->getStandState() != UNIT_STAND_STATE_SIT && ChairUser->GetExactDist2d(x_i, y_i) < 0.1f)
continue; // This seat is already occupied by ChairUser. NOTE: Not sure if the ChairUser->getStandState() != UNIT_STAND_STATE_SIT check is required.
else
- itr->second = 0; // This seat is unoccupied.
+ itr->second.Clear(); // This seat is unoccupied.
}
else
- itr->second = 0; // The seat may of had an occupant, but they're offline.
+ itr->second.Clear(); // The seat may of had an occupant, but they're offline.
}
found_free_slot = true;
@@ -1557,7 +1549,7 @@ void GameObject::Use(Unit* user)
else
{
// reset ritual for this GO
- m_ritualOwnerGUID = 0;
+ m_ritualOwnerGUID.Clear();
m_unique_users.clear();
m_usetimes = 0;
}
@@ -1798,7 +1790,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, bool triggered /*= true
trigger->setFaction(14);
// Set owner guid for target if no owner available - needed by trigger auras
// - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell())
- trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, target ? target->GetGUID() : 0);
+ trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, target ? target->GetGUID() : ObjectGuid::Empty);
}
}
@@ -2039,7 +2031,11 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
void GameObject::SetLootState(LootState state, Unit* unit)
{
m_lootState = state;
- m_lootStateUnitGUID = unit ? unit->GetGUID() : 0;
+ if (unit)
+ m_lootStateUnitGUID = unit->GetGUID();
+ else
+ m_lootStateUnitGUID.Clear();
+
AI()->OnStateChanged(state, unit);
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
@@ -2134,7 +2130,7 @@ void GameObject::SetLootRecipient(Unit* unit)
if (!unit)
{
- m_lootRecipient = 0;
+ m_lootRecipient.Clear();
m_lootRecipientGroup = 0;
return;
}
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 6807fbf9387..09baae707ca 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -664,7 +664,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
bool LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap = true);
void DeleteFromDB();
- void SetOwnerGUID(uint64 owner)
+ void SetOwnerGUID(ObjectGuid owner)
{
// Owner already found and different than expected owner - remove object from old owner
if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
@@ -672,9 +672,9 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
ASSERT(false);
}
m_spawnedByDefault = false; // all object with owner is despawned after delay
- SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner);
+ SetGuidValue(OBJECT_FIELD_CREATED_BY, owner);
}
- uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); }
+ ObjectGuid GetOwnerGUID() const { return GetGuidValue(OBJECT_FIELD_CREATED_BY); }
Unit* GetOwner() const;
void SetSpellId(uint32 id)
@@ -764,7 +764,7 @@ 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 || m_lootRecipientGroup; }
+ bool HasLootRecipient() const { return !m_lootRecipient.IsEmpty() || m_lootRecipientGroup; }
uint32 m_groupLootTimer; // (msecs)timer used for group loot
uint32 lootingGroupLowGUID; // used to find group which is looting
@@ -843,17 +843,17 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),
uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer
LootState m_lootState;
- uint64 m_lootStateUnitGUID; // GUID of the unit passed with SetLootState(LootState, Unit*)
+ ObjectGuid m_lootStateUnitGUID; // GUID of the unit passed with SetLootState(LootState, Unit*)
bool m_spawnedByDefault;
time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction).
// For traps this: spell casting cooldown, for doors/buttons: reset time.
std::list<uint32> m_SkillupList;
- uint64 m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
- std::set<uint64> m_unique_users;
+ ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
+ GuidSet m_unique_users;
uint32 m_usetimes;
- typedef std::map<uint32, uint64> ChairSlotAndUser;
+ typedef std::map<uint32, ObjectGuid> ChairSlotAndUser;
ChairSlotAndUser ChairListSlots;
uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid
@@ -864,7 +864,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
uint64 m_rotation;
Position m_stationaryPosition;
- uint64 m_lootRecipient;
+ ObjectGuid m_lootRecipient;
uint32 m_lootRecipientGroup;
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
private: