Core/PacketIO: Refactored building SMSG_UPDATE_OBJECT to append directly to final buffer and removed UpdateMask class

This commit is contained in:
Shauren
2016-07-10 00:11:19 +02:00
parent dd20865cd7
commit a78aa3cf4e
19 changed files with 141 additions and 318 deletions
@@ -34,6 +34,7 @@
#include "UpdateFieldFlags.h"
#include "World.h"
#include "Transport.h"
#include <boost/dynamic_bitset.hpp>
GameObject::GameObject() : WorldObject(false), MapObject(),
m_model(NULL), m_goValue(), m_AI(NULL), _animKitId(0)
@@ -2299,23 +2300,24 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
bool forcedFlags = GetGoType() == GAMEOBJECT_TYPE_CHEST && GetGOInfo()->chest.usegrouplootrules && HasLootRecipient();
bool targetIsGM = target->IsGameMaster();
ByteBuffer fieldBuffer;
UpdateMask updateMask;
updateMask.SetCount(m_valuesCount);
boost::dynamic_bitset<uint32> updateMask(m_valuesCount);
uint32* flags = GameObjectUpdateFieldFlags;
uint32 visibleFlag = UF_FLAG_PUBLIC;
if (GetOwnerGUID() == target->GetGUID())
visibleFlag |= UF_FLAG_OWNER;
*data << uint8(updateMask.num_blocks());
std::size_t maskPos = data->wpos();
data->resize(data->size() + updateMask.num_blocks() * sizeof(uint32));
for (uint16 index = 0; index < m_valuesCount; ++index)
{
if (_fieldNotifyFlags & flags[index] ||
((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)) ||
((updateType == UPDATETYPE_VALUES ? _changesMask[index] : m_uint32Values[index]) && (flags[index] & visibleFlag)) ||
(index == GAMEOBJECT_FLAGS && forcedFlags))
{
updateMask.SetBit(index);
updateMask.set(index);
if (index == OBJECT_DYNAMIC_FLAGS)
{
@@ -2352,8 +2354,8 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
break;
}
fieldBuffer << uint16(dynFlags);
fieldBuffer << int16(pathProgress);
*data << uint16(dynFlags);
*data << int16(pathProgress);
}
else if (index == GAMEOBJECT_FLAGS)
{
@@ -2362,14 +2364,14 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
if (GetGOInfo()->chest.usegrouplootrules && !IsLootAllowedFor(target))
goFlags |= GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE;
fieldBuffer << goFlags;
*data << goFlags;
}
else if (index == GAMEOBJECT_LEVEL)
{
if (isStoppableTransport)
fieldBuffer << uint32(m_goValue.Transport.PathProgress);
*data << uint32(m_goValue.Transport.PathProgress);
else
fieldBuffer << m_uint32Values[index];
*data << m_uint32Values[index];
}
else if (index == GAMEOBJECT_BYTES_1)
{
@@ -2383,16 +2385,14 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
}
}
fieldBuffer << bytes1;
*data << bytes1;
}
else
fieldBuffer << m_uint32Values[index]; // other cases
*data << m_uint32Values[index]; // other cases
}
}
*data << uint8(updateMask.GetBlockCount());
updateMask.AppendToPacket(data);
data->append(fieldBuffer);
boost::to_block_range(updateMask, reinterpret_cast<uint32*>(data->contents() + maskPos));
}
void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = NULL*/) const