From f3d6831587079f4a5b4284d0aacdd46aa12a7e51 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 31 May 2009 22:16:18 +0400 Subject: [PATCH] [7929] Some fixes and optimizations for work with packet guids. * Allocate only minimal required buffer size for object packet guid cache, avoid it realocation. * At adding aboyher buffer content copy only until wpos (really writed to buffer data) * In appendPackGUID check buffer size before data write. --- src/game/Object.cpp | 5 ++--- src/game/SpellAuras.cpp | 2 +- src/shared/ByteBuffer.h | 5 ++++- src/shared/revision_nr.h | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 6256ba5c8..dd8205db0 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -63,7 +63,7 @@ uint32 GuidHigh2TypeId(uint32 guid_hi) return NUM_CLIENT_OBJECT_TYPES; // unknown } -Object::Object( ) +Object::Object( ) : m_PackGUID(sizeof(uint64)+1) { m_objectTypeId = TYPEID_OBJECT; m_objectType = TYPEMASK_OBJECT; @@ -75,7 +75,6 @@ Object::Object( ) m_inWorld = false; m_objectUpdated = false; - m_PackGUID.clear(); m_PackGUID.appendPackGUID(0); } @@ -118,7 +117,7 @@ void Object::_Create( uint32 guidlow, uint32 entry, HighGuid guidhigh ) uint64 guid = MAKE_NEW_GUID(guidlow, entry, guidhigh); SetUInt64Value( OBJECT_FIELD_GUID, guid ); SetUInt32Value( OBJECT_FIELD_TYPE, m_objectType ); - m_PackGUID.clear(); + m_PackGUID.wpos(0); m_PackGUID.appendPackGUID(GetGUID()); } diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index fb07cb479..e6033a369 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3414,7 +3414,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real) else { m_target->SetUnitMovementFlags(0); // Clear movement flags - m_target->SetStandState(UNIT_STAND_STATE_STAND); + m_target->SetStandState(UNIT_STAND_STATE_STAND);// in 1.5 client } WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8); diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h index 5a13ea788..c289d34a7 100644 --- a/src/shared/ByteBuffer.h +++ b/src/shared/ByteBuffer.h @@ -309,11 +309,14 @@ class ByteBuffer } void append(const ByteBuffer& buffer) { - if(buffer.size()) append(buffer.contents(),buffer.size()); + if(buffer.size()) append(buffer.contents(),buffer.wpos()); } void appendPackGUID(uint64 guid) { + if (_storage.size() < _wpos + sizeof(guid) + 1) + _storage.resize(_wpos + sizeof(guid) + 1); + size_t mask_position = wpos(); *this << uint8(0); for(uint8 i = 0; i < 8; i++) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 6470b37e5..3fc4e00e4 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7928" + #define REVISION_NR "7929" #endif // __REVISION_NR_H__ -- 2.11.4.GIT