OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
25 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;
53 #define DEBUG_LEVEL(x) { #x, &_debug_##x##_level }
61 DEBUG_LEVEL(oldloader),
64 DEBUG_LEVEL(freetype),
87 buf =
strecpy(buf,
"List of debug facility names:\n", last);
92 buf =
strecpy(buf, i->name, last);
93 length += strlen(i->name);
96 buf =
strecpy(buf,
"\n\n", last);
108 if (_debug_socket != INVALID_SOCKET) {
109 char buf2[1024 + 32];
114 send(_debug_socket, buf2, (
int)strlen(buf2), 0);
117 if (strcmp(dbg,
"desync") == 0) {
119 if (f ==
nullptr)
return;
124 }
else if (strcmp(dbg,
"random") == 0) {
126 if (f ==
nullptr)
return;
128 fprintf(f,
"%s\n", buf);
135 wchar_t system_buf[512];
137 _fputts(system_buf, stderr);
139 fputs(buffer, stderr);
152 void CDECL
debug(
const char *dbg,
const char *format, ...)
157 va_start(va, format);
177 if (*s >=
'0' && *s <=
'9') {
180 v = strtoul(s, &end, 0);
183 for (i = debug_level; i !=
endof(debug_level); ++i) *i->level = v;
192 while (*s ==
' ' || *s ==
',' || *s ==
'\t') s++;
193 if (*s ==
'\0')
break;
196 while (*s >=
'a' && *s <=
'z') s++;
200 for (i = debug_level; i !=
endof(debug_level); ++i) {
201 if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
208 v = strtoul(s, &end, 0);
213 ShowInfoF(
"Unknown debug level '%.*s'", (
int)(s - t), t);
227 static char dbgstr[150];
230 memset(dbgstr, 0,
sizeof(dbgstr));
234 for (i++; i !=
endof(debug_level); i++) {
249 static char _log_prefix[24];
251 time_t cur_time = time(
nullptr);
252 strftime(_log_prefix,
sizeof(_log_prefix),
"[%Y-%m-%d %H:%M:%S] ", localtime(&cur_time));
void SetDebugString(const char *s)
Set debugging levels by parsing the text in s.
@ AUTOSAVE_DIR
Subdirectory of save for autosaves.
ClientSettings _settings_client
The current settings for this game.
void NetworkAdminConsole(const char *origin, const char *string)
Send console to the admin network (if they did opt in for the respective update).
bool show_date_in_logs
whether to show dates in console logs
char * DumpDebugFacilityNames(char *buf, char *last)
Dump the available debug facility names in the help text.
const char * GetLogPrefix()
Get the prefix for logs; if show_date_in_logs is enabled it returns the date, otherwise it returns no...
void CDECL debug(const char *dbg, const char *format,...)
Output a debug line.
FILE * FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
wchar_t * convert_to_fs(const char *name, wchar_t *system_buf, size_t buflen, bool console_cp)
Convert from OpenTTD's encoding to that of the environment in UNICODE.
int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap)
Safer implementation of vsnprintf; same as vsnprintf except:
#define endof(x)
Get the end element of an fixed size array.
const char * GetDebugString()
Print out the current debug-level.
void CDECL ShowInfoF(const char *str,...)
Shows some information on the console/a popup box depending on the OS.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
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...
#define lengthof(x)
Return the length of an fixed size array.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
char * strecat(char *dst, const char *src, const char *last)
Appends characters from one string to another.
#define lastof(x)
Get the last element of an fixed size array.
GUISettings gui
settings related to the GUI
static void debug_print(const char *dbg, const char *buf)
Internal function for outputting the debug line.