aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/GameObject
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2016-07-10 00:11:19 +0200
committerShauren <shauren.trinity@gmail.com>2016-07-10 00:11:19 +0200
commita78aa3cf4ef3f33903ec9f06d8fdc46e81c51cb3 (patch)
tree3c94170a7b7c2a17ee8d30517388036d577301a5 /src/server/game/Entities/GameObject
parentdd20865cd7014c42146ea0c0ade511a9791dcc2a (diff)
Core/PacketIO: Refactored building SMSG_UPDATE_OBJECT to append directly to final buffer and removed UpdateMask class
Diffstat (limited to 'src/server/game/Entities/GameObject')
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp32
1 files changed, 16 insertions, 16 deletions
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 <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