summaryrefslogtreecommitdiff
path: root/src/debug.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-01-26 17:24:56 +0000
committerrubidium <rubidium@openttd.org>2012-01-26 17:24:56 +0000
commita48e3cb891af580dc03e3fe1ae8d4978fad575fe (patch)
treec81648ce0840f55aacdfd3e1e61a66b09d4b6cb4 /src/debug.cpp
parentd99eb6aac2c8f772632291d71e5334f13f4d534f (diff)
downloadopenttd-a48e3cb891af580dc03e3fe1ae8d4978fad575fe.tar.xz
(svn r23854) -Codechange: make it easier to put random debug stuff into the random log
Diffstat (limited to 'src/debug.cpp')
-rw-r--r--src/debug.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/debug.cpp b/src/debug.cpp
index f7d31b89a..fe5b0d3fd 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -39,6 +39,9 @@ int _debug_sl_level;
int _debug_gamelog_level;
int _debug_desync_level;
int _debug_console_level;
+#ifdef RANDOM_DEBUG
+int _debug_random_level;
+#endif
uint32 _realtime_tick = 0;
@@ -64,6 +67,9 @@ struct DebugLevel {
DEBUG_LEVEL(gamelog),
DEBUG_LEVEL(desync),
DEBUG_LEVEL(console),
+#ifdef RANDOM_DEBUG
+ DEBUG_LEVEL(random),
+#endif
};
#undef DEBUG_LEVEL
@@ -85,7 +91,21 @@ static void debug_print(const char *dbg, const char *buf)
return;
}
#endif /* ENABLE_NETWORK */
- if (strcmp(dbg, "desync") != 0) {
+ if (strcmp(dbg, "desync") == 0) {
+ static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR);
+ if (f == NULL) return;
+
+ fprintf(f, "%s%s\n", GetLogPrefix(), buf);
+ fflush(f);
+#ifdef RANDOM_DEBUG
+ } else if (strcmp(dbg, "random") == 0) {
+ static FILE *f = FioFOpenFile("random-out.log", "wb", AUTOSAVE_DIR);
+ if (f == NULL) return;
+
+ fprintf(f, "%s\n", buf);
+ fflush(f);
+#endif
+ } else {
#if defined(WINCE)
/* We need to do OTTD2FS twice, but as it uses a static buffer, we need to store one temporary */
TCHAR tbuf[512];
@@ -98,12 +118,6 @@ static void debug_print(const char *dbg, const char *buf)
NetworkAdminConsole(dbg, buf);
#endif /* ENABLE_NETWORK */
IConsoleDebug(dbg, buf);
- } else {
- static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR);
- if (f == NULL) return;
-
- fprintf(f, "%s%s\n", GetLogPrefix(), buf);
- fflush(f);
}
}