diff options
| author | Rat <gmstreetrat@gmail.com> | 2011-11-20 18:28:18 +0100 |
|---|---|---|
| committer | Rat <gmstreetrat@gmail.com> | 2011-11-20 18:28:18 +0100 |
| commit | d1affc4340ecb55a8d5251aaab0de7a106bc375c (patch) | |
| tree | 396fa7223920b947008a9454032d1f439b3ee3c2 /src/server/shared/Packets | |
| parent | 10b89d976fe7ce19db8bcb1f829b3789cc9785af (diff) | |
Initial Commit for client version change to 4.2.2 (14545)
- added known opcodes (handlers are commented till not updated)
- added bitstream support to bytebuffer
- updated realm auth for 14545
- updated world auth
- fixed char_enum,create,delete handlers
- added DB2 reader
- added opcode logging to debuglogmask (ignores loglevel)
- fixed compile in win64, others not yet tested
- using db2 values for item models at char_enum to prevent client crash
Lots of Thanks to All SingularityCore Members
Diffstat (limited to 'src/server/shared/Packets')
| -rwxr-xr-x | src/server/shared/Packets/ByteBuffer.h | 67 | ||||
| -rwxr-xr-x | src/server/shared/Packets/WorldPacket.h | 52 |
2 files changed, 63 insertions, 56 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 08318aa7a5b..93a9aaa6d80 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -51,19 +51,19 @@ class ByteBuffer const static size_t DEFAULT_SIZE = 0x1000; // constructor - ByteBuffer(): _rpos(0), _wpos(0) + ByteBuffer(): _rpos(0), _wpos(0), _bitpos(8), _curbitval(0) { _storage.reserve(DEFAULT_SIZE); } // constructor - ByteBuffer(size_t res): _rpos(0), _wpos(0) + ByteBuffer(size_t res): _rpos(0), _wpos(0), _bitpos(8), _curbitval(0) { _storage.reserve(res); } // copy constructor - ByteBuffer(const ByteBuffer &buf): _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage) { } + ByteBuffer(const ByteBuffer &buf): _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage), _bitpos(buf._bitpos), _curbitval(buf._curbitval) { } void clear() { @@ -73,10 +73,68 @@ class ByteBuffer template <typename T> void append(T value) { + flushBits(); EndianConvert(value); append((uint8 *)&value, sizeof(value)); } + void flushBits() + { + if (_bitpos == 8) + return; + + append((uint8 *)&_curbitval, sizeof(uint8)); + _curbitval = 0; + _bitpos = 8; + } + + bool writeBit(uint32 bit) + { + --_bitpos; + if (bit) + _curbitval |= (1 << (_bitpos)); + + if (_bitpos == 0) + { + _bitpos = 8; + append((uint8 *)&_curbitval, sizeof(_curbitval)); + _curbitval = 0; + } + + return (bit != 0); + } + + bool readBit() + { + ++_bitpos; + if (_bitpos > 7) + { + _bitpos = 0; + _curbitval = read<uint8>(); + } + bool bit = ((_curbitval >> (7-_bitpos)) & 1) != 0; + return bit; + } + + template <typename T> void writeBits(T value, size_t bits) + { + for (int32 i = bits-1; i >= 0; --i) + writeBit((value >> i) & 1); + } + + uint32 readBits(size_t bits) + { + uint32 value = 0; + for (int32 i = bits-1; i >= 0; --i) + { + if(readBit()) + { + value |= (1 << (_bitpos)); + } + } + return value; + } + template <typename T> void put(size_t pos, T value) { EndianConvert(value); @@ -489,7 +547,8 @@ class ByteBuffer } protected: - size_t _rpos, _wpos; + size_t _rpos, _wpos, _bitpos; + uint8 _curbitval; std::vector<uint8> _storage; }; diff --git a/src/server/shared/Packets/WorldPacket.h b/src/server/shared/Packets/WorldPacket.h deleted file mode 100755 index c27801a8d58..00000000000 --- a/src/server/shared/Packets/WorldPacket.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/> - * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef TRINITYCORE_WORLDPACKET_H -#define TRINITYCORE_WORLDPACKET_H - -#include "Common.h" -#include "ByteBuffer.h" - -class WorldPacket : public ByteBuffer -{ - public: - // just container for later use - WorldPacket() : ByteBuffer(0), m_opcode(0) - { - } - explicit WorldPacket(uint16 opcode, size_t res=200) : ByteBuffer(res), m_opcode(opcode) { } - // copy constructor - WorldPacket(const WorldPacket &packet) : ByteBuffer(packet), m_opcode(packet.m_opcode) - { - } - - void Initialize(uint16 opcode, size_t newres=200) - { - clear(); - _storage.reserve(newres); - m_opcode = opcode; - } - - uint16 GetOpcode() const { return m_opcode; } - void SetOpcode(uint16 opcode) { m_opcode = opcode; } - - protected: - uint16 m_opcode; -}; -#endif - |
