TrinityCore
Loading...
Searching...
No Matches
UpdateData.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "UpdateData.h"
19#include "Errors.h"
20#include "WorldPacket.h"
21#include <utility>
22
23UpdateData::UpdateData(uint32 map) : m_map(map), m_blockCount(0) { }
24
26 m_map(right.m_map), m_blockCount(std::exchange(right.m_blockCount, 0)),
27 m_destroyGUIDs(std::move(right.m_destroyGUIDs)),
28 m_outOfRangeGUIDs(std::move(right.m_outOfRangeGUIDs)),
29 m_data(std::move(right.m_data))
30{
31}
32
34{
35 if (this != &right)
36 {
37 m_map = right.m_map;
38 m_blockCount = std::exchange(right.m_blockCount, 0);
39 m_destroyGUIDs = std::move(right.m_destroyGUIDs);
40 m_outOfRangeGUIDs = std::move(right.m_outOfRangeGUIDs);
41 m_data = std::move(right.m_data);
42 }
43 return *this;
44}
45
46UpdateData::~UpdateData() = default;
47
52
57
59{
60 ASSERT(packet->empty()); // shouldn't happen
61 packet->Initialize(SMSG_UPDATE_OBJECT, 4 + 2 + 1 + (2 + 4 + 17 * (m_destroyGUIDs.size() + m_outOfRangeGUIDs.size())) + m_data.wpos());
62
63 *packet << uint16(m_map);
64 *packet << uint32(m_blockCount);
65 packet->WriteBit(true); // unk
66
68 {
69 *packet << uint16(m_destroyGUIDs.size());
71
72 for (ObjectGuid const& destroyGuid : m_destroyGUIDs)
73 *packet << destroyGuid;
74
75 for (ObjectGuid const& outOfRangeGuid : m_outOfRangeGUIDs)
76 *packet << outOfRangeGuid;
77 }
78
79 *packet << uint32(m_data.size());
80 packet->append(m_data);
81 return true;
82}
83
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
#define ASSERT
Definition Errors.h:80
@ SMSG_UPDATE_OBJECT
Definition Opcodes.h:2427
void append(T value)
Definition ByteBuffer.h:130
size_t wpos() const
Definition ByteBuffer.h:461
bool WriteBit(bool bit)
Definition ByteBuffer.h:158
void clear()
Definition ByteBuffer.h:120
size_t size() const
Definition ByteBuffer.h:568
bool empty() const
Definition ByteBuffer.h:569
std::pair< iterator, bool > insert(Key const &key)
Definition FlatSet.h:82
void AddDestroyObject(ObjectGuid guid)
void AddOutOfRangeGUID(ObjectGuid guid)
uint32 m_blockCount
Definition UpdateData.h:54
UpdateData(uint32 map)
Trinity::Containers::FlatSet< ObjectGuid > m_destroyGUIDs
Definition UpdateData.h:55
Trinity::Containers::FlatSet< ObjectGuid > m_outOfRangeGUIDs
Definition UpdateData.h:56
bool BuildPacket(WorldPacket *packet)
ByteBuffer m_data
Definition UpdateData.h:57
void Clear()
uint32 m_map
Definition UpdateData.h:53
UpdateData & operator=(UpdateData &&right) noexcept
void Initialize(uint32 opcode, size_t newres=200, ConnectionType connection=CONNECTION_TYPE_DEFAULT)
Definition WorldPacket.h:75