Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool UpdateData::BuildPacket(WorldPacket *packet, bool hasTransport)
- {
- //ByteBuffer buf(m_data.size() + 10 + m_outOfRangeGUIDs.size()*8);
- ByteBuffer buf(4 + 1 + (m_outOfRangeGUIDs.empty() ? 0 : 1 + 4 + 9 * m_outOfRangeGUIDs.size()) + 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++)
- {
- //buf.appendPackGUID(*i);
- buf << uint8(0xFF);
- buf << uint64(*i);
- }
- }
- buf.append(m_data);
- packet->clear();
- if (m_data.size() > 50)
- {
- uint32 destsize = buf.size() + buf.size()/10 + 16;
- packet->resize(destsize);
- packet->put(0, (uint32)buf.size());
- Compress(const_cast<uint8*>(packet->contents()) + sizeof(uint32),
- &destsize,
- (void*)buf.contents(),
- buf.size());
- if (destsize == 0)
- return false;
- packet->resize(destsize + sizeof(uint32));
- packet->SetOpcode(SMSG_COMPRESSED_UPDATE_OBJECT);
- }
- else
- {
- packet->append(buf);
- packet->SetOpcode(SMSG_UPDATE_OBJECT);
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment