(svn r13727) -Fix (r13375): compilation with NO_DEBUG_MESSAGES was broken
authorsmatz
Fri, 18 Jul 2008 12:11:46 +0000
changeset 11169 60cbac6bc442
parent 11163 7034daa18792
child 11170 3646f7f4fcfc
(svn r13727) -Fix (r13375): compilation with NO_DEBUG_MESSAGES was broken
src/debug.cpp
src/debug.h
src/gamelog.cpp
src/gamelog.h
src/openttd.cpp
--- a/src/debug.cpp	Thu Jul 17 23:43:47 2008 +0000
+++ b/src/debug.cpp	Fri Jul 18 12:11:46 2008 +0000
@@ -61,7 +61,7 @@
 
 #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) {
--- a/src/debug.h	Thu Jul 17 23:43:47 2008 +0000
+++ b/src/debug.h	Fri Jul 18 12:11:46 2008 +0000
@@ -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);
--- a/src/gamelog.cpp	Thu Jul 17 23:43:47 2008 +0000
+++ b/src/gamelog.cpp	Fri Jul 18 12:11:46 2008 +0000
@@ -114,10 +114,12 @@
 {
 	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 @@
 	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);
 }
 
--- a/src/gamelog.h	Thu Jul 17 23:43:47 2008 +0000
+++ b/src/gamelog.h	Fri Jul 18 12:11:46 2008 +0000
@@ -25,7 +25,7 @@
 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();
--- a/src/openttd.cpp	Thu Jul 17 23:43:47 2008 +0000
+++ b/src/openttd.cpp	Fri Jul 18 12:11:46 2008 +0000
@@ -2455,7 +2455,7 @@
 		}
 	}
 
-	if (_debug_gamelog_level > 0) GamelogPrintDebug();
+	GamelogPrintDebug(1);
 
 	return InitializeWindowsAndCaches();
 }