mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-17 05:29:43 -04:00
Core/Entities: Use ObjectGuid class in game project
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user