27 SOCKET _debug_socket = INVALID_SOCKET;
31 int _debug_driver_level;
34 int _debug_misc_level;
36 int _debug_sprite_level;
37 int _debug_oldloader_level;
39 int _debug_yapf_level;
40 int _debug_freetype_level;
41 int _debug_script_level;
43 int _debug_gamelog_level;
44 int _debug_desync_level;
45 int _debug_console_level;
47 int _debug_random_level;
57 #define DEBUG_LEVEL(x) { #x, &_debug_##x##_level } 65 DEBUG_LEVEL(oldloader),
68 DEBUG_LEVEL(freetype),
91 buf =
strecpy(buf,
"List of debug facility names:\n", last);
96 buf =
strecpy(buf, i->name, last);
97 length += strlen(i->name);
100 buf =
strecpy(buf,
"\n\n", last);
112 if (_debug_socket != INVALID_SOCKET) {
113 char buf2[1024 + 32];
118 send(_debug_socket, buf2, (
int)strlen(buf2), 0);
121 if (strcmp(dbg,
"desync") == 0) {
123 if (f ==
nullptr)
return;
128 }
else if (strcmp(dbg,
"random") == 0) {
130 if (f ==
nullptr)
return;
132 fprintf(f,
"%s\n", buf);
139 TCHAR system_buf[512];
141 _fputts(system_buf, stderr);
143 fputs(buffer, stderr);
156 void CDECL
debug(
const char *dbg,
const char *format, ...)
161 va_start(va, format);
181 if (*s >=
'0' && *s <=
'9') {
184 v = strtoul(s, &end, 0);
187 for (i = debug_level; i !=
endof(debug_level); ++i) *i->level = v;
196 while (*s ==
' ' || *s ==
',' || *s ==
'\t') s++;
197 if (*s ==
'\0')
break;
200 while (*s >=
'a' && *s <=
'z') s++;
204 for (i = debug_level; i !=
endof(debug_level); ++i) {
205 if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
212 v = strtoul(s, &end, 0);
217 ShowInfoF(
"Unknown debug level '%.*s'", (
int)(s - t), t);
231 static char dbgstr[150];
234 memset(dbgstr, 0,
sizeof(dbgstr));
238 for (i++; i !=
endof(debug_level); i++) {
253 static char _log_prefix[24];
255 time_t cur_time = time(
nullptr);
256 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.