diff src/debug.cpp @ 9457:267a95510fdf draft

(svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
author smatz <smatz@openttd.org>
date Tue, 03 Jun 2008 18:35:58 +0000
parents 45c874394355
children 8cff5d45a15f
line wrap: on
line diff
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -30,6 +30,7 @@
 int _debug_freetype_level;
 int _debug_sl_level;
 int _debug_station_level;
+int _debug_gamelog_level;
 
 
 struct DebugLevel {
@@ -54,24 +55,17 @@
 	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 @@
 		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)