26 #if defined(ENABLE_NETWORK) 28 SOCKET _debug_socket = INVALID_SOCKET;
33 int _debug_driver_level;
36 int _debug_misc_level;
38 int _debug_sprite_level;
39 int _debug_oldloader_level;
41 int _debug_yapf_level;
42 int _debug_freetype_level;
43 int _debug_script_level;
45 int _debug_gamelog_level;
46 int _debug_desync_level;
47 int _debug_console_level;
49 int _debug_random_level;
59 #define DEBUG_LEVEL(x) { #x, &_debug_##x##_level } 67 DEBUG_LEVEL(oldloader),
70 DEBUG_LEVEL(freetype),
93 buf =
strecpy(buf,
"List of debug facility names:\n", last);
98 buf =
strecpy(buf, i->name, last);
99 length += strlen(i->name);
102 buf =
strecpy(buf,
"\n\n", last);
114 #if defined(ENABLE_NETWORK) 115 if (_debug_socket != INVALID_SOCKET) {
116 char buf2[1024 + 32];
121 send(_debug_socket, buf2, (
int)strlen(buf2), 0);
125 if (strcmp(dbg,
"desync") == 0) {
127 if (f == NULL)
return;
132 }
else if (strcmp(dbg,
"random") == 0) {
134 if (f == NULL)
return;
136 fprintf(f,
"%s\n", buf);
143 TCHAR system_buf[512];
145 _fputts(system_buf, stderr);
147 fputs(buffer, stderr);
149 #ifdef ENABLE_NETWORK 162 void CDECL
debug(
const char *dbg,
const char *format, ...)
167 va_start(va, format);
187 if (*s >=
'0' && *s <=
'9') {
190 v = strtoul(s, &end, 0);
193 for (i = debug_level; i !=
endof(debug_level); ++i) *i->level = v;
202 while (*s ==
' ' || *s ==
',' || *s ==
'\t') s++;
203 if (*s ==
'\0')
break;
206 while (*s >=
'a' && *s <=
'z') s++;
210 for (i = debug_level; i !=
endof(debug_level); ++i) {
211 if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
218 v = strtoul(s, &end, 0);
223 ShowInfoF(
"Unknown debug level '%.*s'", (
int)(s - t), t);
237 static char dbgstr[150];
240 memset(dbgstr, 0,
sizeof(dbgstr));
244 for (i++; i !=
endof(debug_level); i++) {
259 static char _log_prefix[24];
261 time_t cur_time = time(NULL);
262 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.
TCHAR * convert_to_fs(const char *name, TCHAR *system_buf, size_t buflen, bool console_cp)
Convert from OpenTTD's encoding to that of the environment in UNICODE.
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.
#define lengthof(x)
Return the length of an fixed size array.
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
declarations of functions for MS windows systems
Server part of the admin network protocol.