mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-21 21:49:10 +00:00
ai
data
docs
lang
makefiledir
media
music
openttd.xcode
os
scenario
scripts
sound
strgen
table
video
COPYING
Doxyfile
Makefile
StdAfx.c
aircraft_cmd.c
aircraft_gui.c
airport.c
airport.h
airport_gui.c
airport_movement.h
aystar.c
aystar.h
bridge.h
bridge_gui.c
bridge_map.c
bridge_map.h
callback_table.c
callback_table.h
changelog.txt
clear_cmd.c
clear_map.h
command.c
command.h
configure
console.c
console.h
console_cmds.c
currency.c
currency.h
debug.c
debug.h
dedicated.c
depot.c
depot.h
direction.h
disaster_cmd.c
dock_gui.c
driver.c
driver.h
dummy_land.c
economy.c
economy.h
endian_check.c
engine.c
engine.h
engine_gui.c
fileio.c
fileio.h
functions.h
gfx.c
gfx.h
gfxinit.c
gfxinit.h
graph_gui.c
gui.h
hal.h
industry.h
industry_cmd.c
industry_gui.c
industry_map.h
intro_gui.c
known-bugs.txt
landscape.c
langs.dsp
langs.vcproj
lzoconf.h
macros.h
main_gui.c
mainicon.ico
map.c
map.h
md5.c
md5.h
mersenne.c
minilzo.c
minilzo.h
misc.c
misc_cmd.c
misc_gui.c
mixer.c
mixer.h
music_gui.c
namegen.c
namegen.h
network.c
network.h
network_client.c
network_client.h
network_core.h
network_data.c
network_data.h
network_gamelist.c
network_gamelist.h
network_gui.c
network_server.c
network_server.h
network_udp.c
network_udp.h
newgrf.c
newgrf.h
newgrf_callbacks.h
newgrf_engine.c
newgrf_engine.h
newgrf_station.c
newgrf_station.h
news.h
news_gui.c
npf.c
npf.h
oldloader.c
openttd.c
openttd.dsp
openttd.dsw
openttd.h
openttd.ico
openttd.sln
openttd.tgt
openttd.vcproj
order.h
order_cmd.c
order_gui.c
os2.c
ottdres.rc
pathfind.c
pathfind.h
player.h
player_gui.c
players.c
pool.c
pool.h
queue.c
queue.h
rail.c
rail.h
rail_cmd.c
rail_gui.c
rail_map.h
railtypes.h
readme.txt
resource.h
road_cmd.c
road_gui.c
road_map.c
road_map.h
roadveh_cmd.c
roadveh_gui.c
saveload.c
saveload.h
screenshot.c
screenshot.h
sdl.c
sdl.h
settings.c
settings.h
settings_gui.c
ship_cmd.c
ship_gui.c
signs.c
signs.h
smallmap_gui.c
sound.c
sound.h
sprite.c
sprite.h
spritecache.c
spritecache.h
station.h
station_cmd.c
station_gui.c
station_map.c
station_map.h
stdafx.h
string.c
string.h
strings.c
strings.h
subsidy_gui.c
svnup.sh
terraform_gui.c
texteff.c
thread.c
thread.h
tile.c
tile.h
town.h
town_cmd.c
town_gui.c
town_map.h
train.h
train_cmd.c
train_gui.c
tree_cmd.c
tree_map.h
tunnel_map.c
tunnel_map.h
tunnelbridge_cmd.c
unix.c
unmovable_cmd.c
unmovable_map.h
variables.h
vehicle.c
vehicle.h
vehicle_gui.c
vehicle_gui.h
viewport.c
viewport.h
void_map.h
water_cmd.c
water_map.h
waypoint.c
waypoint.h
widget.c
win32.c
win32.h
win64.asm
window.c
window.h
- The only change is that the nsignalsw.grf file is kept and that existing nightlies with PBS signals get those signals converted to combo-signals.
127 lines
2.4 KiB
C
127 lines
2.4 KiB
C
/* $Id$ */
|
|
|
|
#include "stdafx.h"
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include "openttd.h"
|
|
#include "console.h"
|
|
#include "debug.h"
|
|
#include "functions.h"
|
|
#include "string.h"
|
|
|
|
int _debug_ai_level;
|
|
int _debug_driver_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;
|
|
int _debug_oldloader_level;
|
|
int _debug_ntp_level;
|
|
int _debug_npf_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);
|
|
}
|
|
|
|
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(driver),
|
|
DEBUG_LEVEL(grf),
|
|
DEBUG_LEVEL(map),
|
|
DEBUG_LEVEL(misc),
|
|
DEBUG_LEVEL(ms),
|
|
DEBUG_LEVEL(net),
|
|
DEBUG_LEVEL(spritecache),
|
|
DEBUG_LEVEL(oldloader),
|
|
DEBUG_LEVEL(ntp),
|
|
DEBUG_LEVEL(npf)
|
|
};
|
|
#undef DEBUG_LEVEL
|
|
|
|
void SetDebugString(const char *s)
|
|
{
|
|
int v;
|
|
char *end;
|
|
const char *t;
|
|
|
|
// 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;
|
|
}
|
|
}
|
|
}
|
|
|
|
/** Print out the current debug-level
|
|
* Just return a string with the values of all the debug categorites
|
|
* @return string with debug-levels
|
|
*/
|
|
const char *GetDebugString(void)
|
|
{
|
|
const DebugLevel *i;
|
|
static char dbgstr[100];
|
|
char dbgval[20];
|
|
|
|
memset(dbgstr, 0, sizeof(dbgstr));
|
|
i = debug_level;
|
|
snprintf(dbgstr, sizeof(dbgstr), "%s=%d", i->name, *i->level);
|
|
|
|
for (i++; i != endof(debug_level); i++) {
|
|
snprintf(dbgval, sizeof(dbgval), ", %s=%d", i->name, *i->level);
|
|
ttd_strlcat(dbgstr, dbgval, sizeof(dbgstr));
|
|
}
|
|
|
|
return dbgstr;
|
|
}
|