aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2013-03-25 13:26:48 +0100
committerSpp <spp@jorge.gr>2013-03-25 13:26:48 +0100
commit1a6a23ec96c7646d2753198f93eaba62d2732a83 (patch)
tree2ef7e8ffd5201bd6e7bf0a4ddfd768a24e263e82 /src/server/shared
parent7c36e3a298ce243631848b94364c185a863d1526 (diff)
Core/Misc: Minor optimizations (+code changes to reduce differences with 4.3.4 branch)
Core/Logging: Create new logger type "Cheat". Will be used to log all cheat attempts
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/CMakeLists.txt3
-rw-r--r--src/server/shared/Containers.h1
-rw-r--r--src/server/shared/Cryptography/Authentication/AuthCrypt.cpp13
-rw-r--r--src/server/shared/Cryptography/Authentication/AuthCrypt.h1
-rw-r--r--src/server/shared/Cryptography/BigNumber.cpp9
-rw-r--r--src/server/shared/Cryptography/HMACSHA1.cpp2
-rw-r--r--src/server/shared/Database/DatabaseWorkerPool.h4
-rw-r--r--src/server/shared/Debugging/Errors.cpp38
-rw-r--r--src/server/shared/Debugging/Errors.h24
-rw-r--r--src/server/shared/Debugging/WheatyExceptionReport.cpp2
-rw-r--r--src/server/shared/Logging/Appender.cpp2
-rw-r--r--src/server/shared/Logging/Appender.h13
-rw-r--r--src/server/shared/Logging/LogOperation.h3
-rw-r--r--src/server/shared/Packets/ByteBuffer.cpp95
-rw-r--r--src/server/shared/Packets/ByteBuffer.h167
15 files changed, 224 insertions, 153 deletions
diff --git a/src/server/shared/CMakeLists.txt b/src/server/shared/CMakeLists.txt
index 01ccf648b31..447819b0431 100644
--- a/src/server/shared/CMakeLists.txt
+++ b/src/server/shared/CMakeLists.txt
@@ -16,6 +16,7 @@ file(GLOB_RECURSE sources_Configuration Configuration/*.cpp Configuration/*.h)
file(GLOB_RECURSE sources_Cryptography Cryptography/*.cpp Cryptography/*.h)
file(GLOB_RECURSE sources_Database Database/*.cpp Database/*.h)
file(GLOB_RECURSE sources_DataStores DataStores/*.cpp DataStores/*.h)
+file(GLOB_RECURSE sources_Debugging Debugging/*.cpp Debugging/*.h)
file(GLOB_RECURSE sources_Dynamic Dynamic/*.cpp Dynamic/*.h)
file(GLOB_RECURSE sources_Logging Logging/*.cpp Logging/*.h)
file(GLOB_RECURSE sources_Packets Packets/*.cpp Packets/*.h)
@@ -39,13 +40,13 @@ set(shared_STAT_SRCS
${sources_Cryptography}
${sources_Database}
${sources_DataStores}
+ ${sources_Debugging}
${sources_Dynamic}
${sources_Logging}
${sources_Packets}
${sources_Threading}
${sources_Utilities}
${sources_localdir}
- Debugging/Errors.h
)
include_directories(
diff --git a/src/server/shared/Containers.h b/src/server/shared/Containers.h
index 83c691a99e2..b33954d7ea4 100644
--- a/src/server/shared/Containers.h
+++ b/src/server/shared/Containers.h
@@ -18,6 +18,7 @@
#ifndef TRINITY_CONTAINERS_H
#define TRINITY_CONTAINERS_H
+#include "Define.h"
#include <list>
//! Because circular includes are bad
diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp b/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
index 0f68fcb6c37..003c09e4589 100644
--- a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
+++ b/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
@@ -20,15 +20,10 @@
#include "Cryptography/HMACSHA1.h"
#include "Cryptography/BigNumber.h"
-AuthCrypt::AuthCrypt() : _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH)
- , _initialized(false)
-{
-}
-
-AuthCrypt::~AuthCrypt()
-{
-
-}
+AuthCrypt::AuthCrypt() :
+ _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH),
+ _initialized(false)
+{ }
void AuthCrypt::Init(BigNumber* K)
{
diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.h b/src/server/shared/Cryptography/Authentication/AuthCrypt.h
index 200681afd08..95e773b586e 100644
--- a/src/server/shared/Cryptography/Authentication/AuthCrypt.h
+++ b/src/server/shared/Cryptography/Authentication/AuthCrypt.h
@@ -27,7 +27,6 @@ class AuthCrypt
{
public:
AuthCrypt();
- ~AuthCrypt();
void Init(BigNumber* K);
void DecryptRecv(uint8 *, size_t);
diff --git a/src/server/shared/Cryptography/BigNumber.cpp b/src/server/shared/Cryptography/BigNumber.cpp
index 37778cceab8..06ea57b662e 100644
--- a/src/server/shared/Cryptography/BigNumber.cpp
+++ b/src/server/shared/Cryptography/BigNumber.cpp
@@ -24,18 +24,15 @@
#include <algorithm>
BigNumber::BigNumber()
- : _bn(BN_new())
- , _array(NULL)
+ : _bn(BN_new()), _array(NULL)
{ }
BigNumber::BigNumber(BigNumber const& bn)
- : _bn(BN_dup(bn._bn))
- , _array(NULL)
+ : _bn(BN_dup(bn._bn)), _array(NULL)
{ }
BigNumber::BigNumber(uint32 val)
- : _bn(BN_new())
- , _array(NULL)
+ : _bn(BN_new()), _array(NULL)
{
BN_set_word(_bn, val);
}
diff --git a/src/server/shared/Cryptography/HMACSHA1.cpp b/src/server/shared/Cryptography/HMACSHA1.cpp
index ab50eb9981a..297b4e90316 100644
--- a/src/server/shared/Cryptography/HMACSHA1.cpp
+++ b/src/server/shared/Cryptography/HMACSHA1.cpp
@@ -40,7 +40,7 @@ void HmacHash::Finalize()
{
uint32 length = 0;
HMAC_Final(&m_ctx, (uint8*)m_digest, &length);
- ASSERT(length == SHA_DIGEST_LENGTH)
+ ASSERT(length == SHA_DIGEST_LENGTH);
}
uint8 *HmacHash::ComputeHash(BigNumber* bn)
diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h
index 524a3de2628..a197610c6b5 100644
--- a/src/server/shared/Database/DatabaseWorkerPool.h
+++ b/src/server/shared/Database/DatabaseWorkerPool.h
@@ -55,8 +55,8 @@ class DatabaseWorkerPool
memset(_connectionCount, 0, sizeof(_connectionCount));
_connections.resize(IDX_SIZE);
- WPFatal (mysql_thread_safe(), "Used MySQL library isn't thread-safe.");
- WPFatal (mysql_get_client_version() >= MIN_MYSQL_CLIENT_VERSION, "TrinityCore does not support MySQL versions below 5.1");
+ WPFatal(mysql_thread_safe(), "Used MySQL library isn't thread-safe.");
+ WPFatal(mysql_get_client_version() >= MIN_MYSQL_CLIENT_VERSION, "TrinityCore does not support MySQL versions below 5.1");
}
~DatabaseWorkerPool()
diff --git a/src/server/shared/Debugging/Errors.cpp b/src/server/shared/Debugging/Errors.cpp
new file mode 100644
index 00000000000..bd299906de0
--- /dev/null
+++ b/src/server/shared/Debugging/Errors.cpp
@@ -0,0 +1,38 @@
+#include "Errors.h"
+#include "Log.h"
+
+#include <ace/Stack_Trace.h>
+#include <ace/OS_NS_unistd.h>
+
+namespace Trinity {
+
+void Assert(char const *file, int line, char const *function, char const *message)
+{
+ ACE_Stack_Trace st;
+ fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n",
+ file, line, function, message, st.c_str());
+ *((volatile int*)NULL) = 0;
+}
+
+void Fatal(char const *file, int line, char const *function, char const *message)
+{
+ sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s FATAL ERROR:\n %s\n",
+ file, line, function, message);
+ ACE_OS::sleep(10);
+ *((volatile int*)NULL) = 0;
+}
+
+void Error(char const *file, int line, char const *function, char const *message)
+{
+ sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s ERROR:\n %s\n",
+ file, line, function, message);
+ *((volatile int*)NULL) = 0;
+}
+
+void Warning(char const *file, int line, char const *function, char const *message)
+{
+ sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s WARNING:\n %s\n",
+ file, line, function, message);
+}
+
+} // namespace Trinity
diff --git a/src/server/shared/Debugging/Errors.h b/src/server/shared/Debugging/Errors.h
index 10e94634e9a..554b20c3648 100644
--- a/src/server/shared/Debugging/Errors.h
+++ b/src/server/shared/Debugging/Errors.h
@@ -19,15 +19,23 @@
#ifndef TRINITYCORE_ERRORS_H
#define TRINITYCORE_ERRORS_H
-#include "Common.h"
-#include "Log.h"
-#include <ace/Stack_Trace.h>
-#include <ace/OS_NS_unistd.h>
+namespace Trinity {
-#define WPAssert(assertion) { if (!(assertion)) { ACE_Stack_Trace st; fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n", __FILE__, __LINE__, __FUNCTION__, #assertion, st.c_str()); *((volatile int*)NULL) = 0; } }
-#define WPError(assertion, errmsg) { if (!(assertion)) { sLog->outError(LOG_FILTER_GENERAL, "%\n%s:%i in %s ERROR:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg); *((volatile int*)NULL) = 0; } }
-#define WPWarning(assertion, errmsg) { if (!(assertion)) { sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s WARNING:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg); } }
-#define WPFatal(assertion, errmsg) { if (!(assertion)) { sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s FATAL ERROR:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg); ACE_OS::sleep(10); *((volatile int*)NULL) = 0; } }
+void Assert(char const *file, int line, char const *function, char const *message);
+
+void Fatal(char const *file, int line, char const *function, char const *message);
+
+void Error(char const *file, int line, char const *function, char const *message);
+
+void Warning(char const *file, int line, char const *function, char const *message);
+
+} // namespace Trinity
+
+#define WPAssert(cond) do { if (!(cond)) Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond); } while(0)
+#define WPFatal(cond, msg) do { if (!(cond)) Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
+#define WPError(cond, msg) do { if (!(cond)) Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
+#define WPWarning(cond, msg) do { if (!(cond)) Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
#define ASSERT WPAssert
+
#endif
diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp
index d07e579ab5d..d4bd630ca25 100644
--- a/src/server/shared/Debugging/WheatyExceptionReport.cpp
+++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp
@@ -3,6 +3,8 @@
// MSDN Magazine, 2002
// FILE: WheatyExceptionReport.CPP
//==========================================
+#include "CompilerDefs.h"
+
#if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__)
#define WIN32_LEAN_AND_MEAN
#pragma warning(disable:4996)
diff --git a/src/server/shared/Logging/Appender.cpp b/src/server/shared/Logging/Appender.cpp
index efb141d1060..cde94fe3a7c 100644
--- a/src/server/shared/Logging/Appender.cpp
+++ b/src/server/shared/Logging/Appender.cpp
@@ -218,6 +218,8 @@ char const* Appender::getLogFilterTypeString(LogFilterType type)
return "SOAP";
case LOG_FILTER_RBAC:
return "RBAC";
+ case LOG_FILTER_CHEAT:
+ return "CHEAT";
default:
break;
}
diff --git a/src/server/shared/Logging/Appender.h b/src/server/shared/Logging/Appender.h
index e11bc40c42f..983f6a5ddbe 100644
--- a/src/server/shared/Logging/Appender.h
+++ b/src/server/shared/Logging/Appender.h
@@ -68,10 +68,11 @@ enum LogFilterType
LOG_FILTER_SERVER_LOADING = 40,
LOG_FILTER_OPCODES = 41,
LOG_FILTER_SOAP = 42,
- LOG_FILTER_RBAC = 43
+ LOG_FILTER_RBAC = 43,
+ LOG_FILTER_CHEAT = 44
};
-const uint8 MaxLogFilter = 43;
+const uint8 MaxLogFilter = 45;
// Values assigned have their equivalent in enum ACE_Log_Priority
enum LogLevel
@@ -108,12 +109,8 @@ enum AppenderFlags
struct LogMessage
{
LogMessage(LogLevel _level, LogFilterType _type, std::string _text)
- : level(_level)
- , type(_type)
- , text(_text)
- {
- mtime = time(NULL);
- }
+ : level(_level), type(_type), text(_text), mtime(time(NULL))
+ { }
static std::string getTimeStr(time_t time);
std::string getTimeStr();
diff --git a/src/server/shared/Logging/LogOperation.h b/src/server/shared/Logging/LogOperation.h
index 0a0dde3bb61..40017cb87f4 100644
--- a/src/server/shared/Logging/LogOperation.h
+++ b/src/server/shared/Logging/LogOperation.h
@@ -25,8 +25,7 @@ class LogOperation
{
public:
LogOperation(Logger* _logger, LogMessage* _msg)
- : logger(_logger)
- , msg(_msg)
+ : logger(_logger), msg(_msg)
{ }
~LogOperation();
diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp
new file mode 100644
index 00000000000..a14cf3477af
--- /dev/null
+++ b/src/server/shared/Packets/ByteBuffer.cpp
@@ -0,0 +1,95 @@
+#include "ByteBuffer.h"
+#include "Log.h"
+
+#include <ace/Stack_Trace.h>
+#include <sstream>
+
+ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos,
+ size_t size, size_t valueSize)
+{
+ std::ostringstream ss;
+ ACE_Stack_Trace trace;
+
+ ss << "Attempted to " << (add ? "put" : "get") << " value with size: "
+ << valueSize << " in ByteBuffer (pos: " << pos << " size: " << size
+ << ")\n\n" << trace.c_str();
+
+ message().assign(ss.str());
+}
+
+ByteBufferSourceException::ByteBufferSourceException(size_t pos, size_t size,
+ size_t valueSize)
+{
+ std::ostringstream ss;
+ ACE_Stack_Trace trace;
+
+ ss << "Attempted to put a "
+ << (valueSize > 0 ? "NULL-pointer" : "zero-sized value")
+ << " in ByteBuffer (pos: " << pos << " size: " << size << ")\n\n"
+ << trace.c_str();
+
+ message().assign(ss.str());
+}
+
+void ByteBuffer::print_storage() const
+{
+ if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled trace output
+ return;
+
+ std::ostringstream o;
+ o << "STORAGE_SIZE: " << size();
+ for (uint32 i = 0; i < size(); ++i)
+ o << read<uint8>(i) << " - ";
+ o << " ";
+
+ sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
+}
+
+void ByteBuffer::textlike() const
+{
+ if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled trace output
+ return;
+
+ std::ostringstream o;
+ o << "STORAGE_SIZE: " << size();
+ for (uint32 i = 0; i < size(); ++i)
+ {
+ char buf[1];
+ snprintf(buf, 1, "%c", read<uint8>(i));
+ o << buf;
+ }
+ o << " ";
+ sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
+}
+
+void ByteBuffer::hexlike() const
+{
+ if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled trace output
+ return;
+
+ uint32 j = 1, k = 1;
+
+ std::ostringstream o;
+ o << "STORAGE_SIZE: " << size();
+
+ for (uint32 i = 0; i < size(); ++i)
+ {
+ char buf[3];
+ snprintf(buf, 1, "%2X ", read<uint8>(i));
+ if ((i == (j * 8)) && ((i != (k * 16))))
+ {
+ o << "| ";
+ ++j;
+ }
+ else if (i == (k * 16))
+ {
+ o << "\n";
+ ++k;
+ ++j;
+ }
+
+ o << buf;
+ }
+ o << " ";
+ sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
+}
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index ceab4ca442e..9b16c2e9c0b 100644
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -19,64 +19,47 @@
#ifndef _BYTEBUFFER_H
#define _BYTEBUFFER_H
-#include "Common.h"
+#include "Define.h"
#include "Debugging/Errors.h"
-#include "Logging/Log.h"
#include "Utilities/ByteConverter.h"
-class ByteBufferException
+#include <exception>
+#include <list>
+#include <map>
+#include <string>
+#include <vector>
+
+#include <cstring>
+
+// Root of ByteBuffer exception hierarchy
+class ByteBufferException : public std::exception
{
- public:
- ByteBufferException(size_t pos, size_t size, size_t valueSize)
- : Pos(pos), Size(size), ValueSize(valueSize)
- {
- }
+public:
+ ~ByteBufferException() throw() { }
- protected:
- size_t Pos;
- size_t Size;
- size_t ValueSize;
+ char const * what() const throw() { return msg_.c_str(); }
+
+protected:
+ std::string & message() throw() { return msg_; }
+
+private:
+ std::string msg_;
};
class ByteBufferPositionException : public ByteBufferException
{
- public:
- ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize)
- : ByteBufferException(pos, size, valueSize), _add(add)
- {
- PrintError();
- }
-
- protected:
- void PrintError() const
- {
- ACE_Stack_Trace trace;
-
- sLog->outError(LOG_FILTER_NETWORKIO, "Attempted to %s value with size: "SIZEFMTD" in ByteBuffer (pos: " SIZEFMTD " size: "SIZEFMTD")\n[Stacktrace: %s]",
- (_add ? "put" : "get"), ValueSize, Pos, Size, trace.c_str());
- }
+public:
+ ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize);
- private:
- bool _add;
+ ~ByteBufferPositionException() throw() { }
};
class ByteBufferSourceException : public ByteBufferException
{
- public:
- ByteBufferSourceException(size_t pos, size_t size, size_t valueSize)
- : ByteBufferException(pos, size, valueSize)
- {
- PrintError();
- }
+public:
+ ByteBufferSourceException(size_t pos, size_t size, size_t valueSize);
- protected:
- void PrintError() const
- {
- ACE_Stack_Trace trace;
-
- sLog->outError(LOG_FILTER_NETWORKIO, "Attempted to put a %s in ByteBuffer (pos: "SIZEFMTD" size: "SIZEFMTD")\n[Stacktrace: %s]",
- (ValueSize > 0 ? "NULL-pointer" : "zero-sized value"), Pos, Size, trace.c_str());
- }
+ ~ByteBufferSourceException() throw() { }
};
class ByteBuffer
@@ -85,19 +68,21 @@ class ByteBuffer
const static size_t DEFAULT_SIZE = 0x1000;
// constructor
- ByteBuffer(): _rpos(0), _wpos(0)
+ ByteBuffer() : _rpos(0), _wpos(0)
{
_storage.reserve(DEFAULT_SIZE);
}
- // constructor
- ByteBuffer(size_t res): _rpos(0), _wpos(0)
+ ByteBuffer(size_t reserve) : _rpos(0), _wpos(0)
{
- _storage.reserve(res);
+ _storage.reserve(reserve);
}
// 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)
+ {
+ }
void clear()
{
@@ -275,9 +260,18 @@ class ByteBuffer
return *this;
}
- uint8 operator[](size_t pos) const
+ uint8& operator[](size_t const pos)
{
- return read<uint8>(pos);
+ if (pos >= size())
+ throw ByteBufferPositionException(false, pos, 1, size());
+ return _storage[pos];
+ }
+
+ uint8 const& operator[](size_t const pos) const
+ {
+ if (pos >= size())
+ throw ByteBufferPositionException(false, pos, 1, size());
+ return _storage[pos];
}
size_t rpos() const { return _rpos; }
@@ -331,7 +325,7 @@ class ByteBuffer
{
if (_rpos + len > size())
throw ByteBufferPositionException(false, _rpos, len, size());
- memcpy(dest, &_storage[_rpos], len);
+ std::memcpy(dest, &_storage[_rpos], len);
_rpos += len;
}
@@ -362,8 +356,7 @@ class ByteBuffer
uint32 ReadPackedTime()
{
uint32 packedDate = read<uint32>();
- tm lt;
- memset(&lt, 0, sizeof(lt));
+ tm lt = tm();
lt.tm_min = packedDate & 0x3F;
lt.tm_hour = (packedDate >> 6) & 0x1F;
@@ -423,7 +416,7 @@ class ByteBuffer
if (_storage.size() < _wpos + cnt)
_storage.resize(_wpos + cnt);
- memcpy(&_storage[_wpos], src, cnt);
+ std::memcpy(&_storage[_wpos], src, cnt);
_wpos += cnt;
}
@@ -476,71 +469,14 @@ class ByteBuffer
if (!src)
throw ByteBufferSourceException(_wpos, size(), cnt);
- memcpy(&_storage[pos], src, cnt);
+ std::memcpy(&_storage[pos], src, cnt);
}
- void print_storage() const
- {
- if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled debug output
- return;
+ void print_storage() const;
- std::ostringstream o;
- o << "STORAGE_SIZE: " << size();
- for (uint32 i = 0; i < size(); ++i)
- o << read<uint8>(i) << " - ";
- o << " ";
+ void textlike() const;
- sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
- }
-
- void textlike() const
- {
- if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled debug output
- return;
-
- std::ostringstream o;
- o << "STORAGE_SIZE: " << size();
- for (uint32 i = 0; i < size(); ++i)
- {
- char buf[1];
- snprintf(buf, 1, "%c", read<uint8>(i));
- o << buf;
- }
- o << " ";
- sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
- }
-
- void hexlike() const
- {
- if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled debug output
- return;
-
- uint32 j = 1, k = 1;
-
- std::ostringstream o;
- o << "STORAGE_SIZE: " << size();
-
- for (uint32 i = 0; i < size(); ++i)
- {
- char buf[3];
- snprintf(buf, 1, "%2X ", read<uint8>(i));
- if ((i == (j * 8)) && ((i != (k * 16))))
- {
- o << "| ";
- ++j;
- }
- else if (i == (k * 16))
- {
- o << "\n";
- ++k;
- ++j;
- }
-
- o << buf;
- }
- o << " ";
- sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
- }
+ void hexlike() const;
protected:
size_t _rpos, _wpos;
@@ -652,5 +588,6 @@ inline void ByteBuffer::read_skip<std::string>()
{
read_skip<char*>();
}
+
#endif