AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
UpdateMask Class Reference

#include "UpdateMask.h"

Public Types

enum  UpdateMaskCount { CLIENT_UPDATE_MASK_BITS = sizeof(ClientUpdateMaskType) * 8 }
 
typedef uint32 ClientUpdateMaskType
 Type representing how client reads update mask. More...
 

Public Member Functions

 UpdateMask ()=default
 
 UpdateMask (UpdateMask const &right)
 
 ~UpdateMask ()
 
void SetBit (uint32 index)
 
void UnsetBit (uint32 index)
 
bool GetBit (uint32 index) const
 
void AppendToPacket (ByteBuffer *data)
 
uint32 GetBlockCount () const
 
uint32 GetCount () const
 
void SetCount (uint32 valuesCount)
 
void Clear ()
 
UpdateMaskoperator= (UpdateMask const &right)
 
UpdateMaskoperator&= (UpdateMask const &right)
 
UpdateMaskoperator|= (UpdateMask const &right)
 
UpdateMask operator| (UpdateMask const &right)
 

Private Attributes

uint32 _fieldCount {0}
 
uint32 _blockCount {0}
 
uint8_bits {nullptr}
 

Detailed Description

Member Typedef Documentation

◆ ClientUpdateMaskType

Type representing how client reads update mask.

Member Enumeration Documentation

◆ UpdateMaskCount

Enumerator
CLIENT_UPDATE_MASK_BITS 
31 {
33 };
@ CLIENT_UPDATE_MASK_BITS
Definition: UpdateMask.h:32
uint32 ClientUpdateMaskType
Type representing how client reads update mask.
Definition: UpdateMask.h:28

Constructor & Destructor Documentation

◆ UpdateMask() [1/2]

UpdateMask::UpdateMask ( )
default

◆ UpdateMask() [2/2]

UpdateMask::UpdateMask ( UpdateMask const &  right)
inline
38 {
39 SetCount(right.GetCount());
40 memcpy(_bits, right._bits, sizeof(uint8) * _blockCount * 32);
41 }
std::uint8_t uint8
Definition: Define.h:109
uint8 * _bits
Definition: UpdateMask.h:120
uint32 _blockCount
Definition: UpdateMask.h:119
void SetCount(uint32 valuesCount)
Definition: UpdateMask.h:65

References _bits, _blockCount, GetCount(), and SetCount().

◆ ~UpdateMask()

UpdateMask::~UpdateMask ( )
inline
43{ delete[] _bits; }

References _bits.

Member Function Documentation

◆ AppendToPacket()

void UpdateMask::AppendToPacket ( ByteBuffer data)
inline
50 {
51 for (uint32 i = 0; i < GetBlockCount(); ++i)
52 {
53 ClientUpdateMaskType maskPart = 0;
54 for (uint32 j = 0; j < CLIENT_UPDATE_MASK_BITS; ++j)
55 if (_bits[CLIENT_UPDATE_MASK_BITS * i + j])
56 maskPart |= 1 << j;
57
58 *data << maskPart;
59 }
60 }
std::uint32_t uint32
Definition: Define.h:107
uint32 GetBlockCount() const
Definition: UpdateMask.h:62

References _bits, CLIENT_UPDATE_MASK_BITS, and GetBlockCount().

Referenced by Object::BuildValuesUpdate(), Corpse::BuildValuesUpdate(), GameObject::BuildValuesUpdate(), and Unit::BuildValuesUpdate().

◆ Clear()

void UpdateMask::Clear ( )
inline
77 {
78 if (_bits)
79 memset(_bits, 0, sizeof(uint8) * _blockCount * CLIENT_UPDATE_MASK_BITS);
80 }

References _bits, _blockCount, and CLIENT_UPDATE_MASK_BITS.

Referenced by Object::ClearUpdateMask().

◆ GetBit()

bool UpdateMask::GetBit ( uint32  index) const
inline

◆ GetBlockCount()

◆ GetCount()

uint32 UpdateMask::GetCount ( ) const
inline
63{ return _fieldCount; }
uint32 _fieldCount
Definition: UpdateMask.h:118

References _fieldCount.

Referenced by operator&=(), operator=(), operator|=(), and UpdateMask().

◆ operator&=()

UpdateMask & UpdateMask::operator&= ( UpdateMask const &  right)
inline
93 {
94 ASSERT(right.GetCount() <= GetCount());
95 for (uint32 i = 0; i < _fieldCount; ++i)
96 _bits[i] &= right._bits[i];
97
98 return *this;
99 }
#define ASSERT
Definition: Errors.h:68
uint32 GetCount() const
Definition: UpdateMask.h:63

References _bits, _fieldCount, ASSERT, and GetCount().

◆ operator=()

UpdateMask & UpdateMask::operator= ( UpdateMask const &  right)
inline
83 {
84 if (this == &right)
85 return *this;
86
87 SetCount(right.GetCount());
88 memcpy(_bits, right._bits, sizeof(uint8) * _blockCount * CLIENT_UPDATE_MASK_BITS);
89 return *this;
90 }

References _bits, _blockCount, CLIENT_UPDATE_MASK_BITS, GetCount(), and SetCount().

◆ operator|()

UpdateMask UpdateMask::operator| ( UpdateMask const &  right)
inline
111 {
112 UpdateMask ret(*this);
113 ret |= right;
114 return ret;
115 }
Definition: UpdateMask.h:25

◆ operator|=()

UpdateMask & UpdateMask::operator|= ( UpdateMask const &  right)
inline
102 {
103 ASSERT(right.GetCount() <= GetCount());
104 for (uint32 i = 0; i < _fieldCount; ++i)
105 _bits[i] |= right._bits[i];
106
107 return *this;
108 }

References _bits, _fieldCount, ASSERT, and GetCount().

◆ SetBit()

◆ SetCount()

◆ UnsetBit()

void UpdateMask::UnsetBit ( uint32  index)
inline
46{ _bits[index] = 0; }

References _bits.

Referenced by Unit::SetLevel().

Member Data Documentation

◆ _bits

◆ _blockCount

uint32 UpdateMask::_blockCount {0}
private

◆ _fieldCount

uint32 UpdateMask::_fieldCount {0}
private