From a78aa3cf4ef3f33903ec9f06d8fdc46e81c51cb3 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 10 Jul 2016 00:11:19 +0200 Subject: Core/PacketIO: Refactored building SMSG_UPDATE_OBJECT to append directly to final buffer and removed UpdateMask class --- src/server/game/Entities/GameObject/GameObject.cpp | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/server/game/Entities/GameObject') diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index ee7241a02d7..fd538c31809 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -34,6 +34,7 @@ #include "UpdateFieldFlags.h" #include "World.h" #include "Transport.h" +#include 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 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(data->contents() + maskPos)); } void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = NULL*/) const -- cgit v1.2.3