ariel- committed 2016-01-11 01:50:45 -03:00
1 parent 694c89d76d
commit b3ea9fbbe5
163 files changed
+2448 -2328

No files matched your search

+55 -88
View File
@@ -90,14 +90,12 @@ Object::~Object()
if (isType(TYPEMASK_ITEM))
TC_LOG_FATAL("misc", "Item slot %u", ((Item*)this)->GetSlot());
ASSERT(false);
RemoveFromWorld();
}
if (m_objectUpdated)
{
TC_LOG_FATAL("misc", "Object::~Object %s deleted but still in update list!!", GetGUID().ToString().c_str());
ASSERT(false);
sObjectAccessor->RemoveUpdateObject(this);
}
delete [] m_uint32Values;
@@ -142,7 +140,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()
@@ -168,17 +167,17 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
if (target == this) // building packet for yourself
flags |= UPDATEFLAG_SELF;
switch (GetGUIDHigh())
switch (GetGUID().GetHigh())
{
case HIGHGUID_PLAYER:
case HIGHGUID_PET:
case HIGHGUID_CORPSE:
case HIGHGUID_DYNAMICOBJECT:
case HIGHGUID_AREATRIGGER:
case HighGuid::Player:
case HighGuid::Pet:
case HighGuid::Corpse:
case HighGuid::DynamicObject:
case HighGuid::AreaTrigger:
updateType = UPDATETYPE_CREATE_OBJECT2;
break;
case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
case HighGuid::Unit:
case HighGuid::Vehicle:
{
if (TempSummon const* summon = ToUnit()->ToTempSummon())
if (summon->GetSummonerGUID().IsPlayer())
@@ -186,7 +185,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
break;
}
case HIGHGUID_GAMEOBJECT:
case HighGuid::GameObject:
{
if (ToGameObject()->GetOwnerGUID().IsPlayer())
updateType = UPDATETYPE_CREATE_OBJECT2;
@@ -692,6 +691,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();
@@ -699,7 +707,7 @@ void Object::ClearUpdateMask(bool remove)
if (m_objectUpdated)
{
if (remove)
sObjectAccessor->RemoveUpdateObject(this);
RemoveFromObjectUpdate();
m_objectUpdated = false;
}
}
@@ -800,11 +808,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();
}
}
@@ -817,11 +821,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();
}
}
@@ -843,11 +843,7 @@ 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();
}
}
@@ -860,11 +856,7 @@ bool Object::AddGuidValue(uint16 index, ObjectGuid value)
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
return true;
}
@@ -882,11 +874,7 @@ bool Object::RemoveGuidValue(uint16 index, ObjectGuid value)
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
return true;
}
@@ -903,11 +891,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();
}
}
@@ -927,11 +911,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();
}
}
@@ -951,11 +931,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();
}
}
@@ -968,11 +944,7 @@ void Object::SetGuidValue(uint16 index, ObjectGuid value)
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -1042,11 +1014,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();
}
}
@@ -1063,11 +1031,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();
}
}
@@ -1107,11 +1071,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();
}
}
@@ -1130,11 +1090,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();
}
}
@@ -1349,7 +1305,7 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
float sizefactor = GetObjectSize() + obj->GetObjectSize();
float maxdist = dist2compare + sizefactor;
if (GetTransport() && obj->GetTransport() && obj->GetTransport()->GetGUIDLow() == GetTransport()->GetGUIDLow())
if (GetTransport() && obj->GetTransport() && obj->GetTransport()->GetGUID().GetCounter() == GetTransport()->GetGUID().GetCounter())
{
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;
@@ -1931,11 +1887,7 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj, bool checkAlert) co
void Object::ForceValuesUpdateAtIndex(uint32 i)
{
_changesMask.SetBit(i);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
void WorldObject::SendMessageToSet(WorldPacket* data, bool self)
@@ -2006,7 +1958,7 @@ void WorldObject::AddObjectToRemoveList()
Map* map = FindMap();
if (!map)
{
TC_LOG_ERROR("misc", "Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list not have valid map (Id: %u).", GetTypeId(), GetEntry(), GetGUIDLow(), GetMapId());
TC_LOG_ERROR("misc", "Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list not have valid map (Id: %u).", GetTypeId(), GetEntry(), GetGUID().GetCounter(), GetMapId());
return;
}
@@ -2083,7 +2035,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
break;
}
if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), this, 0, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, 0, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
{
delete summon;
return NULL;
@@ -2140,6 +2092,11 @@ void WorldObject::SetZoneScript()
}
}
void WorldObject::ClearZoneScript()
{
m_zoneScript = nullptr;
}
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position &pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/) const
{
if (Map* map = FindMap())
@@ -2180,7 +2137,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
Map* map = GetMap();
GameObject* go = new GameObject();
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, GetPhaseMask(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3, 100, GO_STATE_READY))
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, GetPhaseMask(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3, 100, GO_STATE_READY))
{
delete go;
return NULL;
@@ -2466,7 +2423,7 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle)
if (!Trinity::IsValidMapCoord(destx, desty, pos.m_positionZ))
{
TC_LOG_FATAL("misc", "WorldObject::MovePosition: Object (TypeId: %u Entry: %u GUID: %u) has invalid coordinates X: %f and Y: %f were passed!",
GetTypeId(), GetEntry(), GetGUIDLow(), destx, desty);
GetTypeId(), GetEntry(), GetGUID().GetCounter(), destx, desty);
return;
}
@@ -2889,6 +2846,16 @@ void WorldObject::BuildUpdate(UpdateDataMapType& data_map)
ClearUpdateMask(false);
}
void WorldObject::AddToObjectUpdate()
{
GetMap()->AddUpdateObject(this);
}
void WorldObject::RemoveFromObjectUpdate()
{
GetMap()->RemoveUpdateObject(this);
}
ObjectGuid WorldObject::GetTransGUID() const
{
if (GetTransport())