summaryrefslogtreecommitdiff
path: root/src/debug.cpp
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-02-08 12:27:53 +0000
committertruelight <truelight@openttd.org>2007-02-08 12:27:53 +0000
commitc46a1cc2f685b4351b429b382a28a468fbf2c623 (patch)
tree18108e9e6f3d116f39e99f84eb6540da848e01cf /src/debug.cpp
parent2a7682be799ed35b6a63373be232332657b262da (diff)
downloadopenttd-c46a1cc2f685b4351b429b382a28a468fbf2c623.tar.xz
(svn r8631) -Add: added parameter -l ip[:port] to ./openttd, which redirects DEBUG() to a remote connection over TCP
For example, launch on 192.168.0.1 with, say, netcat a listener: netcat -l -p 3982 Launch OpenTTD on a remote host (say, PSP): ./openttd -l 192.168.0.1 -d9 And you get all debug information on 192.168.0.1. Very useful for debugging Portable systems.
Diffstat (limited to 'src/debug.cpp')
-rw-r--r--src/debug.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/debug.cpp b/src/debug.cpp
index 4040c9cea..d21580665 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -8,6 +8,11 @@
#include "debug.h"
#include "functions.h"
#include "string.h"
+#include "network/core/core.h"
+
+#if defined(ENABLE_NETWORK)
+SOCKET _debug_socket = INVALID_SOCKET;
+#endif /* ENABLE_NETWORK */
int _debug_ai_level;
int _debug_driver_level;
@@ -78,8 +83,18 @@ void CDECL debug(const char *dbg, ...)
s = va_arg(va, const char*);
vsnprintf(buf, lengthof(buf), s, va);
va_end(va);
- fprintf(stderr, "dbg: [%s] %s\n", dbg, buf);
- IConsoleDebug(dbg, buf);
+#if defined(ENABLE_NETWORK)
+ if (_debug_socket != INVALID_SOCKET) {
+ char buf2[lengthof(buf) + 32];
+
+ snprintf(buf2, lengthof(buf2), "dbg: [%s] %s\n", dbg, buf);
+ send(_debug_socket, buf2, strlen(buf2), 0);
+ } else
+#endif /* ENABLE_NETWORK */
+ {
+ fprintf(stderr, "dbg: [%s] %s\n", dbg, buf);
+ IConsoleDebug(dbg, buf);
+ }
}
}
#endif /* NO_DEBUG_MESSAGES */