diff options
| author | Shauren <shauren.trinity@gmail.com> | 2012-07-11 19:26:26 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2012-07-11 19:26:26 +0200 |
| commit | 492fd80b0621728889c6013682d07b420778ef9a (patch) | |
| tree | 6539618a8f34e937b5ca5af3044ca0fbcca15d7b /src/server/game/Entities/Object | |
| parent | 7611ab69be5982dfe558d6e7554545ea253cbb60 (diff) | |
Core/Misc
* Cleaned up packet manipulation methods, no need to keep duplicate sets of functions doing the same
* Added a very basic ObjectGuid structure for easier (and endian-safe) method of accessing individual guid bytes
Diffstat (limited to 'src/server/game/Entities/Object')
| -rwxr-xr-x | src/server/game/Entities/Object/Object.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 1a04f7b3053..01ad11ba2df 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -119,6 +119,62 @@ class Transport; typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType; +//! Structure to ease conversions from single 64 bit integer guid into individual bytes, for packet sending purposes +//! Nuke this out when porting ObjectGuid from MaNGOS, but preserve the per-byte storage +struct ObjectGuid +{ + public: + ObjectGuid() { _data.u64 = 0i64; } + ObjectGuid(uint64 guid) { _data.u64 = guid; } + ObjectGuid(ObjectGuid const& other) { _data.u64 = other._data.u64; } + + uint8& operator[](uint32 index) + { + ASSERT(index < sizeof(uint64)); + +#if TRINITY_ENDIAN == TRINITY_LITTLEENDIAN + return _data.byte[index]; +#else + return _data.byte[7 - index]; +#endif + } + + uint8 const& operator[](uint32 index) const + { + ASSERT(index < sizeof(uint64)); + +#if TRINITY_ENDIAN == TRINITY_LITTLEENDIAN + return _data.byte[index]; +#else + return _data.byte[7 - index]; +#endif + } + + operator uint64() + { + return _data.u64; + } + + ObjectGuid& operator=(uint64 guid) + { + _data.u64 = guid; + return *this; + } + + ObjectGuid& operator=(ObjectGuid const& other) + { + _data.u64 = other._data.u64; + return *this; + } + + private: + union + { + uint64 u64; + uint8 byte[8]; + } _data; +}; + class Object { public: |
