22 #if defined(ENABLE_NETWORK) 24 SOCKET _debug_socket = INVALID_SOCKET;
29 int _debug_driver_level;
32 int _debug_misc_level;
34 int _debug_sprite_level;
35 int _debug_oldloader_level;
37 int _debug_yapf_level;
38 int _debug_freetype_level;
39 int _debug_script_level;
41 int _debug_gamelog_level;
42 int _debug_desync_level;
43 int _debug_console_level;
45 int _debug_random_level;
55 #define DEBUG_LEVEL(x) { #x, &_debug_##x##_level } 63 DEBUG_LEVEL(oldloader),
66 DEBUG_LEVEL(freetype),
89 buf =
strecpy(buf,
"List of debug facility names:\n", last);
94 buf =
strecpy(buf, i->name, last);
95 length += strlen(i->name);
98 buf =
strecpy(buf,
"\n\n", last);
103 #if !defined(NO_DEBUG_MESSAGES) 112 #if defined(ENABLE_NETWORK) 113 if (_debug_socket != INVALID_SOCKET) {
114 char buf2[1024 + 32];
119 send(_debug_socket, buf2, (
int)strlen(buf2), 0);
123 if (strcmp(dbg,
"desync") == 0) {
125 if (f == NULL)
return;
130 }
else if (strcmp(dbg,
"random") == 0) {
132 if (f == NULL)
return;
134 fprintf(f,
"%s\n", buf);
142 #elif defined(WIN32) || defined(WIN64) 143 _fputts(
OTTD2FS(buffer,
true), stderr);
145 fputs(buffer, stderr);
147 #ifdef ENABLE_NETWORK 160 void CDECL
debug(
const char *dbg,
const char *format, ...)
165 va_start(va, format);
186 if (*s >=
'0' && *s <=
'9') {
189 v = strtoul(s, &end, 0);
192 for (i = debug_level; i !=
endof(debug_level); ++i) *i->level = v;
201 while (*s ==
' ' || *s ==
',' || *s ==
'\t') s++;
202 if (*s ==
'\0')
break;
205 while (*s >=
'a' && *s <=
'z') s++;
209 for (i = debug_level; i !=
endof(debug_level); ++i) {
210 if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
217 v = strtoul(s, &end, 0);
222 ShowInfoF(
"Unknown debug level '%.*s'", (
int)(s - t), t);
236 static char dbgstr[150];
239 memset(dbgstr, 0,
sizeof(dbgstr));
243 for (i++; i !=
endof(debug_level); i++) {
258 static char _log_prefix[24];
260 time_t cur_time = time(NULL);
261 strftime(_log_prefix,
sizeof(_log_prefix),
"[%Y-%m-%d %H:%M:%S] ", localtime(&cur_time));
static void debug_print(const char *dbg, const char *buf)
Internal function for outputting the debug line.
uint32 _realtime_tick
The real time in the game.
static char * strecat(char *dst, const char *src, const char *last)
Appends characters from one string to another.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Functions related to debugging.
int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap)
Safer implementation of vsnprintf; same as vsnprintf except:
Functions for Standard In/Out file operations.
#define lastof(x)
Get the last element of an fixed size array.
void CDECL debug(const char *dbg, const char *format,...)
Output a debug line.
void IConsoleDebug(const char *dbg, const char *string)
It is possible to print debugging information to the console, which is achieved by using this functio...
void CDECL ShowInfoF(const char *str,...)
Shows some information on the console/a popup box depending on the OS.
const char * GetLogPrefix()
Get the prefix for logs; if show_date_in_logs is enabled it returns the date, otherwise it returns no...
void NetworkAdminConsole(const char *origin, const char *string)
Send console to the admin network (if they did opt in for the respective update). ...
Functions related to low-level strings.
ClientSettings _settings_client
The current settings for this game.
Types related to global configuration settings.
FILE * FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
Subdirectory of save for autosaves.
Console functions used outside of the console code.
char * DumpDebugFacilityNames(char *buf, char *last)
Dump the available debug facility names in the help text.
const char * GetDebugString()
Print out the current debug-level.
const TCHAR * OTTD2FS(const char *name, bool console_cp)
Convert from OpenTTD's encoding to that of the local environment.
GUISettings gui
settings related to the GUI
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
#define endof(x)
Get the end element of an fixed size array.
void SetDebugString(const char *s)
Set debugging levels by parsing the text in s.
bool show_date_in_logs
whether to show dates in console logs
Server part of the admin network protocol.