From 1a6a23ec96c7646d2753198f93eaba62d2732a83 Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 25 Mar 2013 13:26:48 +0100 Subject: 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 --- src/server/shared/Debugging/Errors.cpp | 38 ++++++++++++++++++++++ src/server/shared/Debugging/Errors.h | 24 +++++++++----- .../shared/Debugging/WheatyExceptionReport.cpp | 2 ++ 3 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 src/server/shared/Debugging/Errors.cpp (limited to 'src/server/shared/Debugging') 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 +#include + +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 -#include +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) -- cgit v1.2.3