diff options
author | truelight <truelight@openttd.org> | 2007-02-08 12:27:53 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2007-02-08 12:27:53 +0000 |
commit | c46a1cc2f685b4351b429b382a28a468fbf2c623 (patch) | |
tree | 18108e9e6f3d116f39e99f84eb6540da848e01cf /src/debug.cpp | |
parent | 2a7682be799ed35b6a63373be232332657b262da (diff) | |
download | openttd-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.cpp | 19 |
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 */ |