aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-06 20:23:56 -0500
committermegamage <none@none>2009-06-06 20:23:56 -0500
commit9f9a9f82073e712d38d1dae3f083af25c0f7e7c6 (patch)
tree0f52f175be355135cf49525907044c3b23e07b6b /src
parent1c1ead52dd85c51538ac5f26846ba67f951ba31b (diff)
[7968] In packet compression use real writed data size. Author: VladimirMangos
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/UpdateData.cpp9
-rw-r--r--src/shared/ByteBuffer.h2
2 files changed, 5 insertions, 6 deletions
diff --git a/src/game/UpdateData.cpp b/src/game/UpdateData.cpp
index 9273944b76c..d041c6100fc 100644
--- a/src/game/UpdateData.cpp
+++ b/src/game/UpdateData.cpp
@@ -105,7 +105,7 @@ void UpdateData::Compress(void* dst, uint32 *dst_size, void* src, int src_size)
bool UpdateData::BuildPacket(WorldPacket *packet)
{
- ByteBuffer buf(m_data.size() + 10 + m_outOfRangeGUIDs.size()*8);
+ ByteBuffer buf(4+(m_outOfRangeGUIDs.empty() ? 0 : 1+4+9*m_outOfRangeGUIDs.size())+m_data.wpos());
buf << (uint32) (!m_outOfRangeGUIDs.empty() ? m_blockCount + 1 : m_blockCount);
@@ -124,15 +124,14 @@ bool UpdateData::BuildPacket(WorldPacket *packet)
packet->clear();
- size_t pSize = buf.size();
+ size_t pSize = buf.wpos(); // use real used data size
if (pSize > 100 ) // compress large packets
{
- packet->resize(pSize * 1.1f + 16);
+ uint32 destsize = pSize;
+ packet->resize( destsize + sizeof(uint32) );
packet->put<uint32>(0, pSize);
-
- uint32 destsize = pSize;
Compress(const_cast<uint8*>(packet->contents()) + sizeof(uint32), &destsize, (void*)buf.contents(), pSize);
if (destsize == 0)
return false;
diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h
index f11746b8ce5..7ff6d32fd12 100644
--- a/src/shared/ByteBuffer.h
+++ b/src/shared/ByteBuffer.h
@@ -311,7 +311,7 @@ class ByteBuffer
}
void append(const ByteBuffer& buffer)
{
- if(buffer.size()) append(buffer.contents(),buffer.wpos());
+ if(buffer.wpos()) append(buffer.contents(),buffer.wpos());
}
void appendPackGUID(uint64 guid)