mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[0184] Fix ScriptDev2 Build under Windows.
NOTE: *ByteBuffer.cpp/.h need Sync with mangos/master and Update some for 4.3.4 Signed-off-by: Salja <salja2012@hotmail.de>
This commit is contained in:
parent
f5be9ae4f5
commit
320e38b25b
3 changed files with 51 additions and 82 deletions
|
|
@ -17,95 +17,61 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ByteBuffer.h"
|
#include "ByteBuffer.h"
|
||||||
#include "Log.h"
|
|
||||||
|
|
||||||
void ByteBufferException::PrintPosError() const
|
void BitStream::Clear()
|
||||||
{
|
{
|
||||||
char const* traceStr;
|
_data.clear();
|
||||||
|
_rpos = _wpos = 0;
|
||||||
#ifdef HAVE_ACE_STACK_TRACE_H
|
|
||||||
ACE_Stack_Trace trace;
|
|
||||||
traceStr = trace.c_str();
|
|
||||||
#else
|
|
||||||
traceStr = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sLog.outError(
|
|
||||||
"Attempted to %s in ByteBuffer (pos: " SIZEFMTD " size: " SIZEFMTD ") "
|
|
||||||
"value with size: " SIZEFMTD "%s%s",
|
|
||||||
(add ? "put" : "get"), pos, size, esize,
|
|
||||||
traceStr ? "\n" : "", traceStr ? traceStr : "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ByteBuffer::print_storage() const
|
uint8 BitStream::GetBit(uint32 bit)
|
||||||
{
|
{
|
||||||
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
|
MANGOS_ASSERT(_data.size() > bit);
|
||||||
return;
|
return _data[bit];
|
||||||
|
}
|
||||||
|
|
||||||
std::ostringstream ss;
|
uint8 BitStream::ReadBit()
|
||||||
ss << "STORAGE_SIZE: " << size() << "\n";
|
{
|
||||||
|
MANGOS_ASSERT(_data.size() < _rpos);
|
||||||
|
uint8 b = _data[_rpos];
|
||||||
|
++_rpos;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
if (sLog.IsIncludeTime())
|
void BitStream::WriteBit(uint32 bit)
|
||||||
ss << " ";
|
{
|
||||||
|
_data.push_back(bit ? uint8(1) : uint8(0));
|
||||||
|
++_wpos;
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < size(); ++i)
|
template <typename T> void BitStream::WriteBits(T value, size_t bits)
|
||||||
ss << uint32(read<uint8>(i)) << " - ";
|
{
|
||||||
|
for (int32 i = bits-1; i >= 0; --i)
|
||||||
|
WriteBit((value >> i) & 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BitStream::Empty()
|
||||||
|
{
|
||||||
|
return _data.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitStream::Reverse()
|
||||||
|
{
|
||||||
|
uint32 len = GetLength();
|
||||||
|
std::vector<uint8> b = _data;
|
||||||
|
Clear();
|
||||||
|
|
||||||
|
for(uint32 i = len; i > 0; --i)
|
||||||
|
WriteBit(b[i-1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitStream::Print()
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "BitStream: ";
|
||||||
|
for (uint32 i = 0; i < GetLength(); ++i)
|
||||||
|
ss << uint32(GetBit(i)) << " ";
|
||||||
|
|
||||||
sLog.outDebug(ss.str().c_str());
|
sLog.outDebug(ss.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ByteBuffer::textlike() const
|
|
||||||
{
|
|
||||||
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "STORAGE_SIZE: " << size() << "\n";
|
|
||||||
|
|
||||||
if (sLog.IsIncludeTime())
|
|
||||||
ss << " ";
|
|
||||||
|
|
||||||
for (size_t i = 0; i < size(); ++i)
|
|
||||||
ss << read<uint8>(i);
|
|
||||||
|
|
||||||
sLog.outDebug(ss.str().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ByteBuffer::hexlike() const
|
|
||||||
{
|
|
||||||
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) // optimize disabled debug output
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "STORAGE_SIZE: " << size() << "\n";
|
|
||||||
|
|
||||||
if (sLog.IsIncludeTime())
|
|
||||||
ss << " ";
|
|
||||||
|
|
||||||
size_t j = 1, k = 1;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < size(); ++i)
|
|
||||||
{
|
|
||||||
if ((i == (j * 8)) && ((i != (k * 16))))
|
|
||||||
{
|
|
||||||
ss << "| ";
|
|
||||||
++j;
|
|
||||||
}
|
|
||||||
else if (i == (k * 16))
|
|
||||||
{
|
|
||||||
ss << "\n";
|
|
||||||
|
|
||||||
if (sLog.IsIncludeTime())
|
|
||||||
ss << " ";
|
|
||||||
|
|
||||||
++k;
|
|
||||||
++j;
|
|
||||||
}
|
|
||||||
|
|
||||||
char buf[4];
|
|
||||||
snprintf(buf, 4, "%02X", read<uint8>(i));
|
|
||||||
ss << buf << " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
sLog.outDebug(ss.str().c_str());
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,10 @@ class ByteBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
ByteBuffer(size_t res, bool init = false);
|
ByteBuffer(size_t res): _rpos(0), _wpos(0), _bitpos(8), _curbitval(0)
|
||||||
|
{
|
||||||
|
_storage.reserve(res);
|
||||||
|
}
|
||||||
|
|
||||||
// copy constructor
|
// copy constructor
|
||||||
ByteBuffer(const ByteBuffer &buf) : _rpos(buf._rpos), _wpos(buf._wpos),
|
ByteBuffer(const ByteBuffer &buf) : _rpos(buf._rpos), _wpos(buf._wpos),
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "0183"
|
#define REVISION_NR "0184"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue