mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 17:49:10 +00:00
feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)
This commit is contained in:
@@ -47,33 +47,6 @@
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
uint32 GuidHigh2TypeId(uint32 guid_hi)
|
||||
{
|
||||
switch (guid_hi)
|
||||
{
|
||||
case HIGHGUID_ITEM:
|
||||
return TYPEID_ITEM;
|
||||
//case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER == HIGHGUID_ITEM currently
|
||||
case HIGHGUID_UNIT:
|
||||
return TYPEID_UNIT;
|
||||
case HIGHGUID_PET:
|
||||
return TYPEID_UNIT;
|
||||
case HIGHGUID_PLAYER:
|
||||
return TYPEID_PLAYER;
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
return TYPEID_DYNAMICOBJECT;
|
||||
case HIGHGUID_CORPSE:
|
||||
return TYPEID_CORPSE;
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_VEHICLE:
|
||||
return TYPEID_UNIT;
|
||||
}
|
||||
return NUM_CLIENT_OBJECT_TYPES; // unknown
|
||||
}
|
||||
|
||||
Object::Object() : m_PackGUID(sizeof(uint64) + 1)
|
||||
{
|
||||
m_objectTypeId = TYPEID_OBJECT;
|
||||
@@ -86,8 +59,6 @@ Object::Object() : m_PackGUID(sizeof(uint64) + 1)
|
||||
m_inWorld = false;
|
||||
m_objectUpdated = false;
|
||||
|
||||
m_PackGUID.appendPackGUID(0);
|
||||
|
||||
sScriptMgr->OnConstructObject(this);
|
||||
}
|
||||
|
||||
@@ -103,7 +74,7 @@ WorldObject::~WorldObject()
|
||||
{
|
||||
if (GetTypeId() == TYPEID_CORPSE)
|
||||
{
|
||||
LOG_FATAL("server", "Object::~Object Corpse guid=" UI64FMTD ", type=%d, entry=%u deleted but still in map!!", GetGUID(), ((Corpse*)this)->GetType(), GetEntry());
|
||||
LOG_FATAL("server", "Object::~Object Corpse %s, type=%d deleted but still in map!!", GetGUID().ToString().c_str(), ((Corpse*)this)->GetType());
|
||||
ABORT();
|
||||
}
|
||||
ResetMap();
|
||||
@@ -116,18 +87,16 @@ Object::~Object()
|
||||
|
||||
if (IsInWorld())
|
||||
{
|
||||
LOG_FATAL("server", "Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in world!!", GetGUID(), GetTypeId(), GetEntry());
|
||||
LOG_FATAL("server", "Object::~Object - %s deleted but still in world!!", GetGUID().ToString().c_str());
|
||||
if (isType(TYPEMASK_ITEM))
|
||||
LOG_FATAL("server", "Item slot %u", ((Item*)this)->GetSlot());
|
||||
ABORT();
|
||||
RemoveFromWorld();
|
||||
}
|
||||
|
||||
if (m_objectUpdated)
|
||||
{
|
||||
LOG_FATAL("server", "Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in update list!!", GetGUID(), GetTypeId(), GetEntry());
|
||||
LOG_FATAL("server", "Object::~Object - %s deleted but still in update list!!", GetGUID().ToString().c_str());
|
||||
ABORT();
|
||||
sObjectAccessor->RemoveUpdateObject(this);
|
||||
}
|
||||
|
||||
delete [] m_uint32Values;
|
||||
@@ -144,15 +113,14 @@ void Object::_InitValues()
|
||||
m_objectUpdated = false;
|
||||
}
|
||||
|
||||
void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
|
||||
void Object::_Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
|
||||
{
|
||||
if (!m_uint32Values) _InitValues();
|
||||
|
||||
uint64 guid = MAKE_NEW_GUID(guidlow, entry, guidhigh);
|
||||
SetUInt64Value(OBJECT_FIELD_GUID, guid);
|
||||
ObjectGuid guid(guidhigh, entry, guidlow);
|
||||
SetGuidValue(OBJECT_FIELD_GUID, guid);
|
||||
SetUInt32Value(OBJECT_FIELD_TYPE, m_objectType);
|
||||
m_PackGUID.wpos(0);
|
||||
m_PackGUID.appendPackGUID(GetGUID());
|
||||
m_PackGUID.Set(guid);
|
||||
}
|
||||
|
||||
std::string Object::_ConcatFields(uint16 startIndex, uint16 size) const
|
||||
@@ -173,7 +141,8 @@ void Object::AddToWorld()
|
||||
m_inWorld = true;
|
||||
|
||||
// synchronize values mirror with values array (changes will send in updatecreate opcode any way
|
||||
ClearUpdateMask(true);
|
||||
ASSERT(!m_objectUpdated);
|
||||
ClearUpdateMask(false);
|
||||
}
|
||||
|
||||
void Object::RemoveFromWorld()
|
||||
@@ -192,7 +161,7 @@ void Object::BuildMovementUpdateBlock(UpdateData* data, uint32 flags) const
|
||||
ByteBuffer buf(500);
|
||||
|
||||
buf << uint8(UPDATETYPE_MOVEMENT);
|
||||
buf.append(GetPackGUID());
|
||||
buf << GetPackGUID();
|
||||
|
||||
BuildMovementUpdate(&buf, flags);
|
||||
|
||||
@@ -248,7 +217,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
|
||||
ByteBuffer buf(500);
|
||||
buf << (uint8)updatetype;
|
||||
buf.append(GetPackGUID());
|
||||
buf << GetPackGUID();
|
||||
buf << (uint8)m_objectTypeId;
|
||||
|
||||
BuildMovementUpdate(&buf, flags);
|
||||
@@ -272,7 +241,7 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) c
|
||||
ByteBuffer buf(500);
|
||||
|
||||
buf << (uint8) UPDATETYPE_VALUES;
|
||||
buf.append(GetPackGUID());
|
||||
buf << GetPackGUID();
|
||||
|
||||
BuildValuesUpdate(UPDATETYPE_VALUES, &buf, target);
|
||||
|
||||
@@ -295,14 +264,14 @@ void Object::DestroyForPlayer(Player* target, bool onDeath) const
|
||||
if (bg->isArena())
|
||||
{
|
||||
WorldPacket data(SMSG_ARENA_UNIT_DESTROYED, 8);
|
||||
data << uint64(GetGUID());
|
||||
data << GetGUID();
|
||||
target->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WorldPacket data(SMSG_DESTROY_OBJECT, 8 + 1);
|
||||
data << uint64(GetGUID());
|
||||
data << GetGUID();
|
||||
//! If the following bool is true, the client will call "void CGUnit_C::OnDeath()" for this object.
|
||||
//! OnDeath() does for eg trigger death animation and interrupts certain spells/missiles/auras/sounds...
|
||||
data << uint8(onDeath ? 1 : 0);
|
||||
@@ -353,7 +322,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
Transport* transport = object->GetTransport();
|
||||
|
||||
if (transport)
|
||||
data->append(transport->GetPackGUID());
|
||||
*data << transport->GetPackGUID();
|
||||
else
|
||||
*data << uint8(0);
|
||||
|
||||
@@ -411,7 +380,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
case TYPEID_GAMEOBJECT:
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
case TYPEID_CORPSE:
|
||||
*data << uint32(GetGUIDLow()); // GetGUIDLow()
|
||||
*data << uint32(GetGUID().GetCounter());
|
||||
break;
|
||||
//! Unit, Player and default here are sending wrong values.
|
||||
/// @todo Research the proper formula
|
||||
@@ -434,7 +403,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
if (flags & UPDATEFLAG_HAS_TARGET)
|
||||
{
|
||||
if (Unit* victim = unit->GetVictim())
|
||||
data->append(victim->GetPackGUID());
|
||||
*data << victim->GetPackGUID();
|
||||
else
|
||||
*data << uint8(0);
|
||||
}
|
||||
@@ -492,6 +461,15 @@ void Object::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* targe
|
||||
data->append(fieldBuffer);
|
||||
}
|
||||
|
||||
void Object::AddToObjectUpdateIfNeeded()
|
||||
{
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
AddToObjectUpdate();
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Object::ClearUpdateMask(bool remove)
|
||||
{
|
||||
_changesMask.Clear();
|
||||
@@ -499,7 +477,7 @@ void Object::ClearUpdateMask(bool remove)
|
||||
if (m_objectUpdated)
|
||||
{
|
||||
if (remove)
|
||||
sObjectAccessor->RemoveUpdateObject(this);
|
||||
RemoveFromObjectUpdate();
|
||||
m_objectUpdated = false;
|
||||
}
|
||||
}
|
||||
@@ -597,11 +575,7 @@ void Object::SetInt32Value(uint16 index, int32 value)
|
||||
m_int32Values[index] = value;
|
||||
_changesMask.SetBit(index);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,11 +588,7 @@ void Object::SetUInt32Value(uint16 index, uint32 value)
|
||||
m_uint32Values[index] = value;
|
||||
_changesMask.SetBit(index);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,6 +603,7 @@ void Object::UpdateUInt32Value(uint16 index, uint32 value)
|
||||
void Object::SetUInt64Value(uint16 index, uint64 value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
|
||||
if (*((uint64*) & (m_uint32Values[index])) != value)
|
||||
{
|
||||
m_uint32Values[index] = PAIR64_LOPART(value);
|
||||
@@ -640,29 +611,21 @@ void Object::SetUInt64Value(uint16 index, uint64 value)
|
||||
_changesMask.SetBit(index);
|
||||
_changesMask.SetBit(index + 1);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
bool Object::AddUInt64Value(uint16 index, uint64 value)
|
||||
bool Object::AddGuidValue(uint16 index, ObjectGuid value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
if (value && !*((uint64*) & (m_uint32Values[index])))
|
||||
|
||||
if (value && !*((ObjectGuid*)&(m_uint32Values[index])))
|
||||
{
|
||||
m_uint32Values[index] = PAIR64_LOPART(value);
|
||||
m_uint32Values[index + 1] = PAIR64_HIPART(value);
|
||||
*((ObjectGuid*)&(m_uint32Values[index])) = value;
|
||||
_changesMask.SetBit(index);
|
||||
_changesMask.SetBit(index + 1);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -670,21 +633,18 @@ bool Object::AddUInt64Value(uint16 index, uint64 value)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Object::RemoveUInt64Value(uint16 index, uint64 value)
|
||||
bool Object::RemoveGuidValue(uint16 index, ObjectGuid value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
if (value && *((uint64*) & (m_uint32Values[index])) == value)
|
||||
|
||||
if (value && *((ObjectGuid*)&(m_uint32Values[index])) == value)
|
||||
{
|
||||
m_uint32Values[index] = 0;
|
||||
m_uint32Values[index + 1] = 0;
|
||||
_changesMask.SetBit(index);
|
||||
_changesMask.SetBit(index + 1);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -692,6 +652,20 @@ bool Object::RemoveUInt64Value(uint16 index, uint64 value)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Object::SetGuidValue(uint16 index, ObjectGuid value)
|
||||
{
|
||||
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
|
||||
if (*((ObjectGuid*)&(m_uint32Values[index])) != value)
|
||||
{
|
||||
*((ObjectGuid*)&(m_uint32Values[index])) = value;
|
||||
_changesMask.SetBit(index);
|
||||
_changesMask.SetBit(index + 1);
|
||||
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
void Object::SetFloatValue(uint16 index, float value)
|
||||
{
|
||||
ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
||||
@@ -701,11 +675,7 @@ void Object::SetFloatValue(uint16 index, float value)
|
||||
m_floatValues[index] = value;
|
||||
_changesMask.SetBit(index);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,11 +695,7 @@ void Object::SetByteValue(uint16 index, uint8 offset, uint8 value)
|
||||
m_uint32Values[index] |= uint32(uint32(value) << (offset * 8));
|
||||
_changesMask.SetBit(index);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -749,11 +715,7 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
|
||||
m_uint32Values[index] |= uint32(uint32(value) << (offset * 16));
|
||||
_changesMask.SetBit(index);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,11 +778,7 @@ void Object::SetFlag(uint16 index, uint32 newFlag)
|
||||
m_uint32Values[index] = newval;
|
||||
_changesMask.SetBit(index);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,11 +795,7 @@ void Object::RemoveFlag(uint16 index, uint32 oldFlag)
|
||||
m_uint32Values[index] = newval;
|
||||
_changesMask.SetBit(index);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -860,11 +814,7 @@ void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
|
||||
m_uint32Values[index] |= uint32(uint32(newFlag) << (offset * 8));
|
||||
_changesMask.SetBit(index);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,11 +833,7 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag)
|
||||
m_uint32Values[index] &= ~uint32(uint32(oldFlag) << (offset * 8));
|
||||
_changesMask.SetBit(index);
|
||||
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -966,7 +912,7 @@ ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& st
|
||||
void MovementInfo::OutDebug()
|
||||
{
|
||||
LOG_INFO("server", "MOVEMENT INFO");
|
||||
LOG_INFO("server", "guid " UI64FMTD, guid);
|
||||
LOG_INFO("server", "guid %s", guid.ToString().c_str());
|
||||
LOG_INFO("server", "flags %u", flags);
|
||||
LOG_INFO("server", "flags2 %u", flags2);
|
||||
LOG_INFO("server", "time %u current time " UI64FMTD "", flags2, uint64(::time(nullptr)));
|
||||
@@ -974,7 +920,7 @@ void MovementInfo::OutDebug()
|
||||
if (flags & MOVEMENTFLAG_ONTRANSPORT)
|
||||
{
|
||||
LOG_INFO("server", "TRANSPORT:");
|
||||
LOG_INFO("server", "guid: " UI64FMTD, transport.guid);
|
||||
LOG_INFO("server", "guid: %s", transport.guid.ToString().c_str());
|
||||
LOG_INFO("server", "position: `%s`", transport.pos.ToString().c_str());
|
||||
LOG_INFO("server", "seat: %i", transport.seat);
|
||||
LOG_INFO("server", "time: %u", transport.time);
|
||||
@@ -1082,7 +1028,7 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
|
||||
RemoveFromWorld();
|
||||
}
|
||||
|
||||
void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
|
||||
void WorldObject::_Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask)
|
||||
{
|
||||
Object::_Create(guidlow, 0, guidhigh);
|
||||
SetPhaseMask(phaseMask, false);
|
||||
@@ -1122,7 +1068,7 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
|
||||
float sizefactor = GetObjectSize() + obj->GetObjectSize();
|
||||
float maxdist = dist2compare + sizefactor;
|
||||
|
||||
if (m_transport && obj->GetTransport() && obj->GetTransport()->GetGUIDLow() == m_transport->GetGUIDLow())
|
||||
if (m_transport && obj->GetTransport() && obj->GetTransport()->GetGUID() == m_transport->GetGUID())
|
||||
{
|
||||
float dtx = m_movementInfo.transport.pos.m_positionX - obj->m_movementInfo.transport.pos.m_positionX;
|
||||
float dty = m_movementInfo.transport.pos.m_positionY - obj->m_movementInfo.transport.pos.m_positionY;
|
||||
@@ -1951,11 +1897,7 @@ void WorldObject::SendPlayMusic(uint32 Music, bool OnlySelf)
|
||||
void Object::ForceValuesUpdateAtIndex(uint32 i)
|
||||
{
|
||||
_changesMask.SetBit(i);
|
||||
if (m_inWorld && !m_objectUpdated)
|
||||
{
|
||||
sObjectAccessor->AddUpdateObject(this);
|
||||
m_objectUpdated = true;
|
||||
}
|
||||
AddToObjectUpdateIfNeeded();
|
||||
}
|
||||
|
||||
namespace acore
|
||||
@@ -2120,7 +2062,7 @@ void WorldObject::MonsterWhisper(int32 textId, Player const* target, bool IsBoss
|
||||
void Unit::BuildHeartBeatMsg(WorldPacket* data) const
|
||||
{
|
||||
data->Initialize(MSG_MOVE_HEARTBEAT, 32);
|
||||
data->append(GetPackGUID());
|
||||
*data << GetPackGUID();
|
||||
BuildMovementPacket(data);
|
||||
}
|
||||
|
||||
@@ -2134,17 +2076,17 @@ void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*
|
||||
VisitNearbyWorldObject(dist, notifier);
|
||||
}
|
||||
|
||||
void WorldObject::SendObjectDeSpawnAnim(uint64 guid)
|
||||
void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid)
|
||||
{
|
||||
WorldPacket data(SMSG_GAMEOBJECT_DESPAWN_ANIM, 8);
|
||||
data << uint64(guid);
|
||||
data << guid;
|
||||
SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
void WorldObject::SetMap(Map* map)
|
||||
{
|
||||
ASSERT(map);
|
||||
ASSERT(!IsInWorld() || GetTypeId() == TYPEID_CORPSE);
|
||||
ASSERT(!IsInWorld());
|
||||
if (m_currMap == map) // command add npc: first create, than loadfromdb
|
||||
return;
|
||||
if (m_currMap)
|
||||
@@ -2197,7 +2139,7 @@ void WorldObject::AddObjectToRemoveList()
|
||||
Map* map = FindMap();
|
||||
if (!map)
|
||||
{
|
||||
LOG_ERROR("server", "Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list not have valid map (Id: %u).", GetTypeId(), GetEntry(), GetGUIDLow(), GetMapId());
|
||||
LOG_ERROR("server", "Object %s at attempt add to move list not have valid map (Id: %u).", GetGUID().ToString().c_str(), GetMapId());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2263,26 +2205,26 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
|
||||
switch (mask)
|
||||
{
|
||||
case UNIT_MASK_SUMMON:
|
||||
summon = new TempSummon(properties, summoner ? summoner->GetGUID() : 0, false);
|
||||
summon = new TempSummon(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false);
|
||||
break;
|
||||
case UNIT_MASK_GUARDIAN:
|
||||
summon = new Guardian(properties, summoner ? summoner->GetGUID() : 0, false);
|
||||
summon = new Guardian(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false);
|
||||
break;
|
||||
case UNIT_MASK_PUPPET:
|
||||
summon = new Puppet(properties, summoner ? summoner->GetGUID() : 0);
|
||||
summon = new Puppet(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
|
||||
break;
|
||||
case UNIT_MASK_TOTEM:
|
||||
summon = new Totem(properties, summoner ? summoner->GetGUID() : 0);
|
||||
summon = new Totem(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
|
||||
break;
|
||||
case UNIT_MASK_MINION:
|
||||
summon = new Minion(properties, summoner ? summoner->GetGUID() : 0, false);
|
||||
summon = new Minion(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false);
|
||||
break;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
|
||||
if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
|
||||
if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
|
||||
{
|
||||
delete summon;
|
||||
return nullptr;
|
||||
@@ -2293,7 +2235,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
|
||||
summon->SetHomePosition(pos);
|
||||
|
||||
summon->InitStats(duration);
|
||||
AddToMap(summon->ToCreature(), (IS_PLAYER_GUID(summon->GetOwnerGUID()) || (summoner && summoner->GetTransport())));
|
||||
AddToMap(summon->ToCreature(), summon->GetOwnerGUID().IsPlayer() || (summoner && summoner->GetTransport()));
|
||||
summon->InitSummon();
|
||||
|
||||
//ObjectAccessor::UpdateObjectVisibility(summon);
|
||||
@@ -2330,7 +2272,7 @@ GameObject* Map::SummonGameObject(uint32 entry, float x, float y, float z, float
|
||||
}
|
||||
|
||||
GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
|
||||
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
|
||||
if (!go->Create(GenerateLowGuid<HighGuid::GameObject>(), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
|
||||
{
|
||||
delete go;
|
||||
return nullptr;
|
||||
@@ -2363,6 +2305,11 @@ void WorldObject::SetZoneScript()
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObject::ClearZoneScript()
|
||||
{
|
||||
m_zoneScript = nullptr;
|
||||
}
|
||||
|
||||
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position& pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/, SummonPropertiesEntry const* properties) const
|
||||
{
|
||||
if (Map* map = FindMap())
|
||||
@@ -2391,7 +2338,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
|
||||
|
||||
Map* map = GetMap();
|
||||
GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
|
||||
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, GetPhaseMask(), x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
|
||||
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, GetPhaseMask(), x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
|
||||
{
|
||||
delete go;
|
||||
return nullptr;
|
||||
@@ -2857,7 +2804,7 @@ void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= nullptr*
|
||||
{
|
||||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
|
||||
data << uint32(sound_id);
|
||||
data << uint64(GetGUID());
|
||||
data << GetGUID();
|
||||
if (target)
|
||||
target->SendDirectMessage(&data);
|
||||
else
|
||||
@@ -2996,13 +2943,13 @@ struct WorldObjectChangeAccumulator
|
||||
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
{
|
||||
source = iter->GetSource();
|
||||
uint64 guid = source->GetCasterGUID();
|
||||
ObjectGuid guid = source->GetCasterGUID();
|
||||
|
||||
if (IS_PLAYER_GUID(guid))
|
||||
if (guid)
|
||||
{
|
||||
//Caster may be nullptr if DynObj is in removelist
|
||||
if (Player* caster = ObjectAccessor::FindPlayer(guid))
|
||||
if (caster->GetUInt64Value(PLAYER_FARSIGHT) == source->GetGUID())
|
||||
if (caster->GetGuidValue(PLAYER_FARSIGHT) == source->GetGUID())
|
||||
BuildPacket(caster);
|
||||
}
|
||||
}
|
||||
@@ -3011,10 +2958,10 @@ struct WorldObjectChangeAccumulator
|
||||
void BuildPacket(Player* player)
|
||||
{
|
||||
// Only send update once to a player
|
||||
if (i_playerSet.find(player->GetGUIDLow()) == i_playerSet.end() && player->HaveAtClient(&i_object))
|
||||
if (i_playerSet.find(player->GetGUID()) == i_playerSet.end() && player->HaveAtClient(&i_object))
|
||||
{
|
||||
i_object.BuildFieldsUpdate(player, i_updateDatas);
|
||||
i_playerSet.insert(player->GetGUIDLow());
|
||||
i_playerSet.insert(player->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3051,11 +2998,22 @@ void WorldObject::GetCreaturesWithEntryInRange(std::list<Creature*>& creatureLis
|
||||
cell.Visit(pair, grid_visitor, *(this->GetMap()), *this, radius);
|
||||
}
|
||||
|
||||
uint64 WorldObject::GetTransGUID() const
|
||||
void WorldObject::AddToObjectUpdate()
|
||||
{
|
||||
GetMap()->AddUpdateObject(this);
|
||||
}
|
||||
|
||||
void WorldObject::RemoveFromObjectUpdate()
|
||||
{
|
||||
GetMap()->RemoveUpdateObject(this);
|
||||
}
|
||||
|
||||
ObjectGuid WorldObject::GetTransGUID() const
|
||||
{
|
||||
if (GetTransport())
|
||||
return GetTransport()->GetGUID();
|
||||
return 0;
|
||||
|
||||
return ObjectGuid::Empty;
|
||||
}
|
||||
|
||||
float WorldObject::GetMapHeight(float x, float y, float z, bool vmap/* = true*/, float distanceToSearch/* = DEFAULT_HEIGHT_SEARCH*/) const
|
||||
|
||||
Reference in New Issue
Block a user