mirror of
https://github.com/mangosfour/server.git
synced 2025-12-27 01:37:04 +00:00
Rebase resync
This commit is contained in:
parent
a0797532e8
commit
1997c1e903
3106 changed files with 11118 additions and 627576 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/**
|
||||
* This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -49,8 +49,7 @@ Object::Object()
|
|||
m_objectTypeId = TYPEID_OBJECT;
|
||||
m_objectType = TYPEMASK_OBJECT;
|
||||
|
||||
m_uint32Values = 0;
|
||||
m_uint32Values_mirror = 0;
|
||||
m_uint32Values = NULL;
|
||||
m_valuesCount = 0;
|
||||
|
||||
m_inWorld = false;
|
||||
|
|
@ -73,7 +72,6 @@ Object::~Object()
|
|||
}
|
||||
|
||||
delete[] m_uint32Values;
|
||||
delete[] m_uint32Values_mirror;
|
||||
}
|
||||
|
||||
void Object::_InitValues()
|
||||
|
|
@ -81,8 +79,7 @@ void Object::_InitValues()
|
|||
m_uint32Values = new uint32[ m_valuesCount ];
|
||||
memset(m_uint32Values, 0, m_valuesCount * sizeof(uint32));
|
||||
|
||||
m_uint32Values_mirror = new uint32[ m_valuesCount ];
|
||||
memset(m_uint32Values_mirror, 0, m_valuesCount * sizeof(uint32));
|
||||
m_changedValues.resize(m_valuesCount, false);
|
||||
|
||||
m_objectUpdated = false;
|
||||
}
|
||||
|
|
@ -416,7 +413,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
|
|||
|
||||
data->WriteGuidBytes<5, 7>(tGuid);
|
||||
*data << uint32(unit->m_movementInfo.GetTransportTime());
|
||||
*data << float(unit->m_movementInfo.GetTransportPos()->o);
|
||||
*data << float(NormalizeOrientation(unit->m_movementInfo.GetTransportPos()->o));
|
||||
|
||||
if (hasTransportTime2)
|
||||
*data << uint32(unit->m_movementInfo.GetTransportTime2());
|
||||
|
|
@ -430,7 +427,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
|
|||
if (hasTransportTime3)
|
||||
*data << uint32(unit->m_movementInfo.GetFallTime());
|
||||
|
||||
*data << int32(unit->m_movementInfo.GetTransportSeat());
|
||||
*data << int8(unit->m_movementInfo.GetTransportSeat());
|
||||
data->WriteGuidBytes<1, 6, 2, 4>(tGuid);
|
||||
}
|
||||
|
||||
|
|
@ -750,10 +747,7 @@ void Object::ClearUpdateMask(bool remove)
|
|||
if (m_uint32Values)
|
||||
{
|
||||
for (uint16 index = 0; index < m_valuesCount; ++index)
|
||||
{
|
||||
if (m_uint32Values_mirror[index] != m_uint32Values[index])
|
||||
m_uint32Values_mirror[index] = m_uint32Values[index];
|
||||
}
|
||||
m_changedValues[index] = false;
|
||||
}
|
||||
|
||||
if (m_objectUpdated)
|
||||
|
|
@ -789,11 +783,9 @@ void Object::_SetUpdateBits(UpdateMask *updateMask, Player* target) const
|
|||
if(GetTypeId() == TYPEID_PLAYER && target != this)
|
||||
valuesCount = PLAYER_END_NOT_SELF;
|
||||
|
||||
for( uint16 index = 0; index < valuesCount; ++index )
|
||||
{
|
||||
if (m_uint32Values_mirror[index] != m_uint32Values[index])
|
||||
for (uint16 index = 0; index < valuesCount; ++index )
|
||||
if (m_changedValues[index])
|
||||
updateMask->SetBit(index);
|
||||
}
|
||||
}
|
||||
|
||||
void Object::_SetCreateBits(UpdateMask *updateMask, Player* target) const
|
||||
|
|
@ -803,19 +795,18 @@ void Object::_SetCreateBits(UpdateMask *updateMask, Player* target) const
|
|||
valuesCount = PLAYER_END_NOT_SELF;
|
||||
|
||||
for (uint16 index = 0; index < valuesCount; ++index)
|
||||
{
|
||||
if (GetUInt32Value(index) != 0)
|
||||
updateMask->SetBit(index);
|
||||
}
|
||||
}
|
||||
|
||||
void Object::SetInt32Value(uint16 index, int32 value)
|
||||
{
|
||||
MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
||||
|
||||
if (m_int32Values[ index ] != value)
|
||||
if (m_int32Values[index] != value)
|
||||
{
|
||||
m_int32Values[ index ] = value;
|
||||
m_int32Values[index] = value;
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -824,9 +815,10 @@ void Object::SetUInt32Value(uint16 index, uint32 value)
|
|||
{
|
||||
MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
||||
|
||||
if (m_uint32Values[ index ] != value)
|
||||
if (m_uint32Values[index] != value)
|
||||
{
|
||||
m_uint32Values[ index ] = value;
|
||||
m_uint32Values[index] = value;
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -834,10 +826,12 @@ void Object::SetUInt32Value(uint16 index, uint32 value)
|
|||
void Object::SetUInt64Value(uint16 index, const uint64& value)
|
||||
{
|
||||
MANGOS_ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
|
||||
if (*((uint64*) & (m_uint32Values[ index ])) != value)
|
||||
if (*((uint64*) & (m_uint32Values[index])) != value)
|
||||
{
|
||||
m_uint32Values[ index ] = *((uint32*)&value);
|
||||
m_uint32Values[ index + 1 ] = *(((uint32*)&value) + 1);
|
||||
m_uint32Values[index] = *((uint32*)&value);
|
||||
m_uint32Values[index + 1] = *(((uint32*)&value) + 1);
|
||||
m_changedValues[index] = true;
|
||||
m_changedValues[index + 1] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -846,9 +840,10 @@ void Object::SetFloatValue(uint16 index, float value)
|
|||
{
|
||||
MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
||||
|
||||
if (m_floatValues[ index ] != value)
|
||||
if (m_floatValues[index] != value)
|
||||
{
|
||||
m_floatValues[ index ] = value;
|
||||
m_floatValues[index] = value;
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -863,10 +858,11 @@ void Object::SetByteValue(uint16 index, uint8 offset, uint8 value)
|
|||
return;
|
||||
}
|
||||
|
||||
if (uint8(m_uint32Values[ index ] >> (offset * 8)) != value)
|
||||
if (uint8(m_uint32Values[index] >> (offset * 8)) != value)
|
||||
{
|
||||
m_uint32Values[ index ] &= ~uint32(uint32(0xFF) << (offset * 8));
|
||||
m_uint32Values[ index ] |= uint32(uint32(value) << (offset * 8));
|
||||
m_uint32Values[index] &= ~uint32(uint32(0xFF) << (offset * 8));
|
||||
m_uint32Values[index] |= uint32(uint32(value) << (offset * 8));
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -881,10 +877,11 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
|
|||
return;
|
||||
}
|
||||
|
||||
if (uint16(m_uint32Values[ index ] >> (offset * 16)) != value)
|
||||
if (uint16(m_uint32Values[index] >> (offset * 16)) != value)
|
||||
{
|
||||
m_uint32Values[ index ] &= ~uint32(uint32(0xFFFF) << (offset * 16));
|
||||
m_uint32Values[ index ] |= uint32(uint32(value) << (offset * 16));
|
||||
m_uint32Values[index] &= ~uint32(uint32(0xFFFF) << (offset * 16));
|
||||
m_uint32Values[index] |= uint32(uint32(value) << (offset * 16));
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -940,12 +937,13 @@ void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply)
|
|||
void Object::SetFlag(uint16 index, uint32 newFlag)
|
||||
{
|
||||
MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
||||
uint32 oldval = m_uint32Values[ index ];
|
||||
uint32 oldval = m_uint32Values[index];
|
||||
uint32 newval = oldval | newFlag;
|
||||
|
||||
if (oldval != newval)
|
||||
{
|
||||
m_uint32Values[ index ] = newval;
|
||||
m_uint32Values[index] = newval;
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -953,12 +951,13 @@ void Object::SetFlag(uint16 index, uint32 newFlag)
|
|||
void Object::RemoveFlag(uint16 index, uint32 oldFlag)
|
||||
{
|
||||
MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
|
||||
uint32 oldval = m_uint32Values[ index ];
|
||||
uint32 oldval = m_uint32Values[index];
|
||||
uint32 newval = oldval & ~oldFlag;
|
||||
|
||||
if (oldval != newval)
|
||||
{
|
||||
m_uint32Values[ index ] = newval;
|
||||
m_uint32Values[index] = newval;
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -973,9 +972,10 @@ void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(uint8(m_uint32Values[ index ] >> (offset * 8)) & newFlag))
|
||||
if (!(uint8(m_uint32Values[index] >> (offset * 8)) & newFlag))
|
||||
{
|
||||
m_uint32Values[ index ] |= uint32(uint32(newFlag) << (offset * 8));
|
||||
m_uint32Values[index] |= uint32(uint32(newFlag) << (offset * 8));
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -990,9 +990,10 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag)
|
|||
return;
|
||||
}
|
||||
|
||||
if (uint8(m_uint32Values[ index ] >> (offset * 8)) & oldFlag)
|
||||
if (uint8(m_uint32Values[index] >> (offset * 8)) & oldFlag)
|
||||
{
|
||||
m_uint32Values[ index ] &= ~uint32(uint32(oldFlag) << (offset * 8));
|
||||
m_uint32Values[index] &= ~uint32(uint32(oldFlag) << (offset * 8));
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -1004,6 +1005,7 @@ void Object::SetShortFlag(uint16 index, bool highpart, uint16 newFlag)
|
|||
if (!(uint16(m_uint32Values[index] >> (highpart ? 16 : 0)) & newFlag))
|
||||
{
|
||||
m_uint32Values[index] |= uint32(uint32(newFlag) << (highpart ? 16 : 0));
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -1015,6 +1017,7 @@ void Object::RemoveShortFlag(uint16 index, bool highpart, uint16 oldFlag)
|
|||
if (uint16(m_uint32Values[index] >> (highpart ? 16 : 0)) & oldFlag)
|
||||
{
|
||||
m_uint32Values[index] &= ~uint32(uint32(oldFlag) << (highpart ? 16 : 0));
|
||||
m_changedValues[index] = true;
|
||||
MarkForClientUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -1247,7 +1250,7 @@ bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const
|
|||
{
|
||||
float x, y, z;
|
||||
GetPosition(x, y, z);
|
||||
return GetMap()->IsInLineOfSight(x, y, z + 2.0f, ox, oy, oz + 2.0f);
|
||||
return GetMap()->IsInLineOfSight(x, y, z + 2.0f, ox, oy, oz + 2.0f, GetPhaseMask());
|
||||
}
|
||||
|
||||
bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D /* = true */) const
|
||||
|
|
@ -1434,7 +1437,7 @@ void WorldObject::GetRandomPoint(float x, float y, float z, float distance, floa
|
|||
|
||||
void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const
|
||||
{
|
||||
float new_z = GetTerrain()->GetHeight(x, y, z, true);
|
||||
float new_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z);
|
||||
if (new_z > INVALID_HEIGHT)
|
||||
z = new_z + 0.05f; // just to be sure that we are not a few pixel under the surface
|
||||
}
|
||||
|
|
@ -1453,7 +1456,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
|
|||
float ground_z = z;
|
||||
float max_z = canSwim
|
||||
? GetTerrain()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK))
|
||||
: ((ground_z = GetTerrain()->GetHeight(x, y, z, true)));
|
||||
: ((ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z)));
|
||||
if (max_z > INVALID_HEIGHT)
|
||||
{
|
||||
if (z > max_z)
|
||||
|
|
@ -1464,7 +1467,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
|
|||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetTerrain()->GetHeight(x, y, z, true);
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
|
|
@ -1472,7 +1475,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
|
|||
}
|
||||
case TYPEID_PLAYER:
|
||||
{
|
||||
// for server controlled moves playr work same as creature (but it can always swim)
|
||||
// for server controlled moves player work same as creature (but it can always swim)
|
||||
if (!((Player const*)this)->CanFly())
|
||||
{
|
||||
float ground_z = z;
|
||||
|
|
@ -1487,7 +1490,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
|
|||
}
|
||||
else
|
||||
{
|
||||
float ground_z = GetTerrain()->GetHeight(x, y, z, true);
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z);
|
||||
if (z < ground_z)
|
||||
z = ground_z;
|
||||
}
|
||||
|
|
@ -1495,7 +1498,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
|
|||
}
|
||||
default:
|
||||
{
|
||||
float ground_z = GetTerrain()->GetHeight(x, y, z, true);
|
||||
float ground_z = GetMap()->GetHeight(GetPhaseMask(), x, y, z);
|
||||
if (ground_z > INVALID_HEIGHT)
|
||||
z = ground_z;
|
||||
break;
|
||||
|
|
@ -1637,8 +1640,11 @@ void WorldObject::BuildMonsterChat(WorldPacket* data, ObjectGuid senderGuid, uin
|
|||
*data << uint32(strlen(text) + 1);
|
||||
*data << text;
|
||||
*data << uint8(0); // ChatTag
|
||||
*data << float(0.0f);
|
||||
*data << uint8(0);
|
||||
if (msgtype == CHAT_MSG_RAID_BOSS_EMOTE || msgtype == CHAT_MSG_RAID_BOSS_WHISPER)
|
||||
{
|
||||
*data << float(0.0f);
|
||||
*data << uint8(0);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldObject::SendMessageToSet(WorldPacket* data, bool /*bToSelf*/)
|
||||
|
|
@ -1726,7 +1732,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pCreature->SetSummonPoint(pos);
|
||||
pCreature->SetRespawnCoord(pos);
|
||||
|
||||
// Active state set before added to map
|
||||
pCreature->SetActiveObjectState(asActiveObject);
|
||||
|
|
@ -1953,6 +1959,7 @@ void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= NULL*/)
|
|||
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
|
||||
data << uint32(sound_id);
|
||||
data << GetObjectGuid();
|
||||
data << GetObjectGuid();
|
||||
if (target)
|
||||
target->SendDirectMessage(&data);
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue