(svn r1803) Move debugging stuff into files of it's own

pull/155/head
tron 20 years ago
parent 8c62a41495
commit 36c9758c94

@ -561,6 +561,7 @@ C_SOURCES += clear_cmd.c
C_SOURCES += command.c
C_SOURCES += console.c
C_SOURCES += console_cmds.c
C_SOURCES += debug.c
C_SOURCES += dedicated.c
C_SOURCES += disaster_cmd.c
C_SOURCES += dock_gui.c

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "map.h"
#include "tile.h"
#include "command.h"

@ -15,6 +15,7 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "tile.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "map.h"
#include "tile.h"
#include "command.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "map.h"
#include "ai.h"
#include "vehicle.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "tile.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "tile.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "map.h"
#include "airport.h"

@ -104,10 +104,6 @@ VARDEF byte _iconsole_color_debug;
VARDEF byte _iconsole_color_commands;
VARDEF _iconsole_modes _iconsole_mode;
// ** ttd.c functions ** //
void SetDebugString(const char* s);
// ** console functions ** //
void IConsoleInit(void);

@ -2,6 +2,7 @@
#include "stdafx.h"
#include "ttd.h"
#include "console.h"
#include "debug.h"
#include "engine.h"
#include "functions.h"
#include "variables.h"

@ -0,0 +1,93 @@
#include <stdarg.h>
#include "stdafx.h"
#include "ttd.h"
#include "console.h"
#include "debug.h"
int _debug_ai_level;
int _debug_grf_level;
int _debug_map_level;
int _debug_misc_level;
int _debug_ms_level;
int _debug_net_level;
int _debug_spritecache_level;
void CDECL debug(const char *s, ...)
{
va_list va;
char buf[1024];
va_start(va, s);
vsnprintf(buf, lengthof(buf), s, va);
va_end(va);
fprintf(stderr, "dbg: %s\n", buf);
IConsoleDebug(buf);
}
void SetDebugString(const char *s)
{
int v;
char *end;
const char *t;
typedef struct DebugLevel {
const char* name;
int* level;
} DebugLevel;
#define DEBUG_LEVEL(x) { #x, &_debug_##x##_level }
static const DebugLevel debug_level[] = {
DEBUG_LEVEL(ai),
DEBUG_LEVEL(grf),
DEBUG_LEVEL(map),
DEBUG_LEVEL(misc),
DEBUG_LEVEL(ms),
DEBUG_LEVEL(net),
DEBUG_LEVEL(spritecache)
};
#undef DEBUG_LEVEL
// global debugging level?
if (*s >= '0' && *s <= '9') {
const DebugLevel *i;
v = strtoul(s, &end, 0);
s = end;
for (i = debug_level; i != endof(debug_level); ++i)
*i->level = v;
}
// individual levels
for(;;) {
const DebugLevel *i;
int *p;
// skip delimiters
while (*s == ' ' || *s == ',' || *s == '\t') s++;
if (*s == '\0') break;
t = s;
while (*s >= 'a' && *s <= 'z') s++;
// check debugging levels
p = NULL;
for (i = debug_level; i != endof(debug_level); ++i)
if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
p = i->level;
break;
}
if (*s == '=') s++;
v = strtoul(s, &end, 0);
s = end;
if (p != NULL)
*p = v;
else {
ShowInfoF("Unknown debug level '%.*s'", s - t, t);
return;
}
}
}

@ -0,0 +1,22 @@
#ifndef DEBUG_H
#define DEBUG_H
#ifdef NO_DEBUG_MESSAGES
#define DEBUG(name, level)
#else
#define DEBUG(name, level) if (level == 0 || _debug_ ## name ## _level >= level) debug
extern int _debug_ai_level;
extern int _debug_grf_level;
extern int _debug_map_level;
extern int _debug_misc_level;
extern int _debug_ms_level;
extern int _debug_net_level;
extern int _debug_spritecache_level;
#endif
void CDECL debug(const char *s, ...);
void SetDebugString(const char *s);
#endif

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "network.h"
#include "hal.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "engine.h"
#include "table/engines.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
//#include "gui.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "functions.h"
#include "map.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "window.h"

@ -1,6 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/namegen.h"
static inline uint32 SeedChance(int shift_by, int max, uint32 seed)

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "debug.h"
#include "map.h"
#include "network_data.h"

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "debug.h"
#include "network_data.h"
#ifdef ENABLE_NETWORK

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "debug.h"
#include "network_data.h"
// Is the network enabled?

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "debug.h"
#include "network_data.h"
#ifdef ENABLE_NETWORK

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "debug.h"
#include "network_data.h"
#ifdef ENABLE_NETWORK

@ -1,4 +1,5 @@
#include "stdafx.h"
#include "debug.h"
#include "network_data.h"
#ifdef ENABLE_NETWORK

@ -3,6 +3,7 @@
#include <stdarg.h>
#include "ttd.h"
#include "debug.h"
#include "gfx.h"
#include "fileio.h"
#include "engine.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "npf.h"
#include "aystar.h"
#include "macros.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "pool.h"
/**

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "tile.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "window.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "vehicle.h"
#include "station.h"
#include "town.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "gfx.h"
#include "viewport.h"

@ -2,6 +2,7 @@
#if defined(WITH_SDL)
#include "ttd.h"
#include "debug.h"
#include "gfx.h"
#include "sound.h"
#include "window.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "window.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "gfx.h"
#include "fileio.h"
#include "newgrf.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "tile.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "window.h"
#include "gui.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "town.h"
#include "window.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "window.h"

77
ttd.c

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "table/strings.h"
#include "debug.h"
#include "map.h"
#include "tile.h"
@ -71,17 +72,6 @@ void CDECL error(const char *s, ...) {
exit(1);
}
void CDECL debug(const char *s, ...)
{
va_list va;
char buf[1024];
va_start(va, s);
vsprintf(buf, s, va);
va_end(va);
fprintf(stderr, "dbg: %s\n", buf);
IConsoleDebug(buf);
}
void CDECL ShowInfoF(const char *str, ...)
{
va_list va;
@ -431,71 +421,6 @@ md_continue_here:;
}
}
void SetDebugString(const char *s)
{
int v;
char *end;
const char *t;
typedef struct DebugLevel {
const char* name;
int* level;
} DebugLevel;
#define DEBUG_LEVEL(x) { #x, &_debug_##x##_level }
static const DebugLevel debug_level[] = {
DEBUG_LEVEL(ai),
DEBUG_LEVEL(grf),
DEBUG_LEVEL(map),
DEBUG_LEVEL(misc),
DEBUG_LEVEL(ms),
DEBUG_LEVEL(net),
DEBUG_LEVEL(spritecache)
};
#undef DEBUG_LEVEL
// global debugging level?
if (*s >= '0' && *s <= '9') {
const DebugLevel *i;
v = strtoul(s, &end, 0);
s = end;
for (i = debug_level; i != endof(debug_level); ++i)
*i->level = v;
}
// individual levels
for(;;) {
const DebugLevel *i;
int *p;
// skip delimiters
while (*s == ' ' || *s == ',' || *s == '\t') s++;
if (*s == 0) break;
t = s;
while (*s >= 'a' && *s <= 'z') s++;
// check debugging levels
p = NULL;
for (i = debug_level; i != endof(debug_level); ++i)
if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
p = i->level;
break;
}
if (*s == '=') s++;
v = strtoul(s, &end, 0);
s = end;
if (p != NULL)
*p = v;
else {
ShowInfoF("Unknown debug level '%.*s'", s - t, t);
return;
}
}
}
static void ParseResolution(int res[2], char *s)
{

@ -452,15 +452,6 @@ VARDEF byte _autoreplace_array[256];
VARDEF uint16 _player_num_engines[256];
VARDEF byte _railtype_selected_in_replace_gui;
/* Debugging levels */
VARDEF int _debug_spritecache_level;
VARDEF int _debug_misc_level;
VARDEF int _debug_grf_level;
VARDEF int _debug_ai_level;
VARDEF int _debug_net_level;
VARDEF int _debug_map_level;
VARDEF int _debug_ms_level;
/* Forking stuff */
VARDEF bool _dedicated_forks;
VARDEF bool _dedicated_enabled;
@ -468,11 +459,4 @@ VARDEF bool _dedicated_enabled;
VARDEF pid_t _dedicated_pid;
#endif
void CDECL debug(const char *s, ...);
#ifdef NO_DEBUG_MESSAGES
#define DEBUG(name, level)
#else
#define DEBUG(name, level) if (level == 0 || _debug_ ## name ## _level >= level) debug
#endif
#endif /* VARIABLES_H */

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "vehicle.h"
#include "window.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "table/strings.h"
#include "map.h"
#include "viewport.h"

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "ttd.h"
#include "debug.h"
#include "map.h"
#include "window.h"
#include "gfx.h"

Loading…
Cancel
Save