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
23
UpdateData::UpdateData
(
uint32
map) : m_map(map), m_blockCount(0) { }
24
25
UpdateData::UpdateData
(
UpdateData
&& right) noexcept :
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
33
UpdateData
&
UpdateData::operator=
(
UpdateData
&& right)
noexcept
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
46
UpdateData::~UpdateData
() =
default
;
47
48
void
UpdateData::AddDestroyObject
(
ObjectGuid
guid)
49
{
50
m_destroyGUIDs
.
insert
(guid);
51
}
52
53
void
UpdateData::AddOutOfRangeGUID
(
ObjectGuid
guid)
54
{
55
m_outOfRangeGUIDs
.
insert
(guid);
56
}
57
58
bool
UpdateData::BuildPacket
(
WorldPacket
* packet)
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
67
if
(packet->
WriteBit
(!
m_outOfRangeGUIDs
.
empty
() || !
m_destroyGUIDs
.
empty
()))
68
{
69
*packet <<
uint16
(
m_destroyGUIDs
.
size
());
70
*packet <<
uint32
(
m_destroyGUIDs
.
size
() +
m_outOfRangeGUIDs
.
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
84
void
UpdateData::Clear
()
85
{
86
m_data
.
clear
();
87
m_destroyGUIDs
.
clear
();
88
m_outOfRangeGUIDs
.
clear
();
89
m_blockCount
= 0;
90
m_map
= 0;
91
}
uint16
uint16_t uint16
Definition
Define.h:155
uint32
uint32_t uint32
Definition
Define.h:154
Errors.h
ASSERT
#define ASSERT
Definition
Errors.h:80
SMSG_UPDATE_OBJECT
@ SMSG_UPDATE_OBJECT
Definition
Opcodes.h:2427
UpdateData.h
WorldPacket.h
ByteBuffer::append
void append(T value)
Definition
ByteBuffer.h:130
ByteBuffer::wpos
size_t wpos() const
Definition
ByteBuffer.h:461
ByteBuffer::WriteBit
bool WriteBit(bool bit)
Definition
ByteBuffer.h:158
ByteBuffer::clear
void clear()
Definition
ByteBuffer.h:120
ByteBuffer::size
size_t size() const
Definition
ByteBuffer.h:568
ByteBuffer::empty
bool empty() const
Definition
ByteBuffer.h:569
ObjectGuid
Definition
ObjectGuid.h:308
Trinity::Containers::FlatSet::clear
void clear()
Definition
FlatSet.h:95
Trinity::Containers::FlatSet::empty
bool empty() const
Definition
FlatSet.h:33
Trinity::Containers::FlatSet::size
auto size() const
Definition
FlatSet.h:34
Trinity::Containers::FlatSet::insert
std::pair< iterator, bool > insert(Key const &key)
Definition
FlatSet.h:82
UpdateData
Definition
UpdateData.h:37
UpdateData::AddDestroyObject
void AddDestroyObject(ObjectGuid guid)
Definition
UpdateData.cpp:48
UpdateData::AddOutOfRangeGUID
void AddOutOfRangeGUID(ObjectGuid guid)
Definition
UpdateData.cpp:53
UpdateData::m_blockCount
uint32 m_blockCount
Definition
UpdateData.h:54
UpdateData::UpdateData
UpdateData(uint32 map)
Definition
UpdateData.cpp:23
UpdateData::m_destroyGUIDs
Trinity::Containers::FlatSet< ObjectGuid > m_destroyGUIDs
Definition
UpdateData.h:55
UpdateData::m_outOfRangeGUIDs
Trinity::Containers::FlatSet< ObjectGuid > m_outOfRangeGUIDs
Definition
UpdateData.h:56
UpdateData::BuildPacket
bool BuildPacket(WorldPacket *packet)
Definition
UpdateData.cpp:58
UpdateData::~UpdateData
~UpdateData()
UpdateData::m_data
ByteBuffer m_data
Definition
UpdateData.h:57
UpdateData::Clear
void Clear()
Definition
UpdateData.cpp:84
UpdateData::m_map
uint32 m_map
Definition
UpdateData.h:53
UpdateData::operator=
UpdateData & operator=(UpdateData &&right) noexcept
Definition
UpdateData.cpp:33
WorldPacket
Definition
WorldPacket.h:26
WorldPacket::Initialize
void Initialize(uint32 opcode, size_t newres=200, ConnectionType connection=CONNECTION_TYPE_DEFAULT)
Definition
WorldPacket.h:75
server
game
Entities
Object
Updates
UpdateData.cpp
Generated on Sun May 10 2026 02:08:56 for TrinityCore by
1.9.8