summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/debug.cpp2
-rw-r--r--src/debug.h1
-rw-r--r--src/gamelog.cpp16
-rw-r--r--src/gamelog.h2
-rw-r--r--src/openttd.cpp2
5 files changed, 16 insertions, 7 deletions
diff --git a/src/debug.cpp b/src/debug.cpp
index fb1e28a49..44e160700 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -61,7 +61,7 @@ struct DebugLevel {
#if !defined(NO_DEBUG_MESSAGES)
-void CDECL debug_print(const char *dbg, const char *buf)
+static void debug_print(const char *dbg, const char *buf)
{
#if defined(ENABLE_NETWORK)
if (_debug_socket != INVALID_SOCKET) {
diff --git a/src/debug.h b/src/debug.h
index 4048c16c0..8cf27f1ea 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -50,7 +50,6 @@
extern int _debug_gamelog_level;
void CDECL debug(const char *dbg, ...);
- void CDECL debug_print(const char *dbg, const char *buf);
#endif /* NO_DEBUG_MESSAGES */
void SetDebugString(const char *s);
diff --git a/src/gamelog.cpp b/src/gamelog.cpp
index 11b651851..f612f8951 100644
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -114,10 +114,12 @@ void GamelogStopAction()
{
assert(_gamelog_action_type != GLAT_NONE); // nobody should try to stop if there is no action in progress
+ bool print = _current_action != NULL;
+
_current_action = NULL;
_gamelog_action_type = GLAT_NONE;
- if (_debug_gamelog_level > 4) GamelogPrintDebug();
+ if (print) GamelogPrintDebug(5);
}
/** Resets and frees all memory allocated - used before loading or starting a new game
@@ -318,14 +320,22 @@ void GamelogPrintConsole()
GamelogPrint(&GamelogPrintConsoleProc);
}
+static int _gamelog_print_level = 0; ///< gamelog debug level we need to print stuff
static void GamelogPrintDebugProc(const char *s)
{
- debug_print("gamelog", s);
+ DEBUG(gamelog, _gamelog_print_level, s);
}
-void GamelogPrintDebug()
+
+/** Prints gamelog to debug output. Code is executed even when
+ * there will be no output. It is called very seldom, so it
+ * doesn't matter that much. At least it gives more uniform code...
+ * @param level debug level we need to print stuff
+ */
+void GamelogPrintDebug(int level)
{
+ _gamelog_print_level = level;
GamelogPrint(&GamelogPrintDebugProc);
}
diff --git a/src/gamelog.h b/src/gamelog.h
index 418ec1ee4..acf97c7ea 100644
--- a/src/gamelog.h
+++ b/src/gamelog.h
@@ -25,7 +25,7 @@ void GamelogReset();
typedef void GamelogPrintProc(const char *s);
void GamelogPrint(GamelogPrintProc *proc); // needed for WIN32 / WINCE crash.log
-void GamelogPrintDebug();
+void GamelogPrintDebug(int level);
void GamelogPrintConsole();
void GamelogRevision();
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 540fdb0cf..9e0b7387c 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -2455,7 +2455,7 @@ bool AfterLoadGame()
}
}
- if (_debug_gamelog_level > 0) GamelogPrintDebug();
+ GamelogPrintDebug(1);
return InitializeWindowsAndCaches();
}