diff options
author | megamage <none@none> | 2009-05-31 15:56:51 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-05-31 15:56:51 -0500 |
commit | 5ed5513ca82712a6e3691add2c9a0f005d80426f (patch) | |
tree | 781e8589bb7f8e95e6b9126f7a555c2f0e1b03ca /src/game/UpdateData.cpp | |
parent | 19e12305515d958c5de586c2a409979b3d193ce6 (diff) |
Mangos [7911]. Author: tomrus88
Very big patch. May cause bugs.
--HG--
branch : trunk
Diffstat (limited to 'src/game/UpdateData.cpp')
-rw-r--r-- | src/game/UpdateData.cpp | 29 |
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 ); |