diff options
Diffstat (limited to 'src/shared/ByteBuffer.h')
-rw-r--r-- | src/shared/ByteBuffer.h | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h index fb2d7cfc7b9..5f8a584eb0f 100644 --- a/src/shared/ByteBuffer.h +++ b/src/shared/ByteBuffer.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -243,6 +243,32 @@ class ByteBuffer _rpos += len; } + bool readPackGUID(uint64& guid) + { + if(rpos()+1 > size()) + return false; + + guid = 0; + + uint8 guidmark=0; + (*this) >> guidmark; + + for(int i=0;i<8;i++) + { + if(guidmark & (uint8(1) << i)) + { + if(rpos()+1 > size()) + return false; + + uint8 bit; + (*this) >> bit; + guid |= (uint64(bit) << (i*8)); + } + } + + return true; + } + const uint8 *contents() const { return &_storage[0]; } size_t size() const { return _storage.size(); } @@ -339,9 +365,6 @@ class ByteBuffer uint32 j = 1, k = 1; sLog.outDebug("STORAGE_SIZE: %u", size() ); - if(sLog.IsIncludeTime()) - sLog.outDebugInLine(" "); - for(uint32 i = 0; i < size(); i++) { if ((i == (j*8)) && ((i != (k*16)))) @@ -361,16 +384,12 @@ class ByteBuffer if (read<uint8>(i) < 0x0F) { sLog.outDebugInLine("\n"); - if(sLog.IsIncludeTime()) - sLog.outDebugInLine(" "); sLog.outDebugInLine("0%X ", read<uint8>(i) ); } else { sLog.outDebugInLine("\n"); - if(sLog.IsIncludeTime()) - sLog.outDebugInLine(" "); sLog.outDebugInLine("%X ", read<uint8>(i) ); } @@ -478,5 +497,13 @@ template <typename K, typename V> ByteBuffer &operator>>(ByteBuffer &b, std::map } return b; } + +// TODO: Make a ByteBuffer.cpp and move all this inlining to it. +template<> inline std::string ByteBuffer::read<std::string>() +{ + std::string tmp; + *this >> tmp; + return tmp; +} #endif |