aboutsummaryrefslogtreecommitdiff
path: root/src/game/UpdateData.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/UpdateData.cpp')
-rw-r--r--src/game/UpdateData.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/game/UpdateData.cpp b/src/game/UpdateData.cpp
index b9c1ec04c63..34547040cda 100644
--- a/src/game/UpdateData.cpp
+++ b/src/game/UpdateData.cpp
@@ -103,24 +103,20 @@ void UpdateData::Compress(void* dst, uint32 *dst_size, void* src, int src_size)
*dst_size = c_stream.total_out;
}
-bool UpdateData::BuildPacket(WorldPacket *packet, bool /*hasTransport*/)
+bool UpdateData::BuildPacket(WorldPacket *packet)
{
- ByteBuffer buf(m_data.size() + 10 + m_outOfRangeGUIDs.size()*8);
+ ByteBuffer buf(m_data.size());
buf << (uint32) (!m_outOfRangeGUIDs.empty() ? m_blockCount + 1 : m_blockCount);
- //buf << (uint8) (hasTransport ? 1 : 0);
if(!m_outOfRangeGUIDs.empty())
{
buf << (uint8) UPDATETYPE_OUT_OF_RANGE_OBJECTS;
buf << (uint32) m_outOfRangeGUIDs.size();
- for(std::set<uint64>::const_iterator i = m_outOfRangeGUIDs.begin();
- i != m_outOfRangeGUIDs.end(); ++i)
+ for(std::set<uint64>::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i)
{
- //buf.appendPackGUID(*i);
- buf << (uint8)0xFF;
- buf << (uint64) *i;
+ buf.appendPackGUID(*i);
}
}
@@ -128,24 +124,23 @@ bool UpdateData::BuildPacket(WorldPacket *packet, bool /*hasTransport*/)
packet->clear();
- if (m_data.size() > 50 )
+ size_t pSize = buf.size();
+
+ if (pSize > 100 ) // compress large packets
{
- uint32 destsize = buf.size() + buf.size()/10 + 16;
- packet->resize( destsize );
+ packet->resize(pSize);
- packet->put(0, (uint32)buf.size());
+ packet->put<uint32>(0, pSize);
- Compress(const_cast<uint8*>(packet->contents()) + sizeof(uint32),
- &destsize,
- (void*)buf.contents(),
- buf.size());
+ uint32 destsize = pSize;
+ Compress(const_cast<uint8*>(packet->contents()) + sizeof(uint32), &destsize, (void*)buf.contents(), pSize);
if (destsize == 0)
return false;
packet->resize( destsize + sizeof(uint32) );
packet->SetOpcode( SMSG_COMPRESSED_UPDATE_OBJECT );
}
- else
+ else // send small packets without compression
{
packet->append( buf );
packet->SetOpcode( SMSG_UPDATE_OBJECT );