summaryrefslogtreecommitdiff
path: root/src/debug.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-06-03 18:35:58 +0000
committersmatz <smatz@openttd.org>2008-06-03 18:35:58 +0000
commitc7a9637834a96722be5a524c4c1e8932a45e3461 (patch)
tree72b7d141fd63dcb880f610a334390bf9c41f97b1 /src/debug.cpp
parentd58f0558761079552c4c607707dd131a2c5e5397 (diff)
downloadopenttd-c7a9637834a96722be5a524c4c1e8932a45e3461.tar.xz
(svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
Diffstat (limited to 'src/debug.cpp')
-rw-r--r--src/debug.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/debug.cpp b/src/debug.cpp
index 6584b9e7f..fb1e28a49 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -30,6 +30,7 @@ int _debug_yapf_level;
int _debug_freetype_level;
int _debug_sl_level;
int _debug_station_level;
+int _debug_gamelog_level;
struct DebugLevel {
@@ -54,24 +55,17 @@ struct DebugLevel {
DEBUG_LEVEL(freetype),
DEBUG_LEVEL(sl),
DEBUG_LEVEL(station),
+ DEBUG_LEVEL(gamelog),
};
#undef DEBUG_LEVEL
#if !defined(NO_DEBUG_MESSAGES)
-void CDECL debug(const char *dbg, ...)
+void CDECL debug_print(const char *dbg, const char *buf)
{
- va_list va;
- va_start(va, dbg);
- const char *s;
- char buf[1024];
-
- s = va_arg(va, const char*);
- vsnprintf(buf, lengthof(buf), s, va);
- va_end(va);
#if defined(ENABLE_NETWORK)
if (_debug_socket != INVALID_SOCKET) {
- char buf2[lengthof(buf) + 32];
+ char buf2[1024 + 32];
snprintf(buf2, lengthof(buf2), "dbg: [%s] %s\n", dbg, buf);
send(_debug_socket, buf2, (int)strlen(buf2), 0);
@@ -89,6 +83,20 @@ void CDECL debug(const char *dbg, ...)
IConsoleDebug(dbg, buf);
}
}
+
+void CDECL debug(const char *dbg, ...)
+{
+ va_list va;
+ va_start(va, dbg);
+ const char *s;
+ char buf[1024];
+
+ s = va_arg(va, const char*);
+ vsnprintf(buf, lengthof(buf), s, va);
+ va_end(va);
+
+ debug_print(dbg, buf);
+}
#endif /* NO_DEBUG_MESSAGES */
void SetDebugString(const char *s)