Files @ r1725:dcb3319784d1
Branch filter:

Location: cpp/openttd-patchpack/source/debug.c - annotation

Darkvater
(svn r2229) - Fix: [ 1188777 ] Non-existing sprite #5125 (presignal). The DOS grf file trgi.grf has 6 less sprites than the windows one. This results in some segfaults for certain sprites. Fixed it by added a dummy grf file consisting ofr 6 sprites and loaded when using DOS gfx at the appropiate place.
r1302:2f26ebcfbebf
r1302:2f26ebcfbebf
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1322:ac830d6af496
r1678:650b403b6981
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1322:ac830d6af496
r1678:650b403b6981
r1678:650b403b6981
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
r1299:07d5483b3f76
#include "stdafx.h"
#include <stdio.h>
#include <stdarg.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;
int _debug_oldloader_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);
}


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),
		DEBUG_LEVEL(oldloader),
		DEBUG_LEVEL(npf)
	};
	#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;
		}
	}
}