summaryrefslogtreecommitdiff
path: root/debug.c
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-01-02 19:19:48 +0000
committerrubidium <rubidium@openttd.org>2007-01-02 19:19:48 +0000
commit66bbf336c6af7353ef0aeed58002c46543b30635 (patch)
treead4a63860df2626b22f77e7dac712e958bea54cb /debug.c
parentccc0a3f4dbf58c005b22341ac8874252924690cd (diff)
downloadopenttd-66bbf336c6af7353ef0aeed58002c46543b30635.tar.xz
(svn r7759) -Merge: makefile rewrite. This merge features:
- A proper ./configure, so everything needs to be configured only once, not for every make. - Usage of makedepend when available. This greatly reduces the time needed for generating the dependencies. - A generator for all project files. There is a single file with sources, which is used to generate Makefiles and the project files for MSVC. - Proper support for OSX universal binaries. - Object files for non-MSVC compiles are also placed in separate directories, making is faster to switch between debug and release compiles and it does not touch the directory with the source files. - Functionality to make a bundle of all needed files for for example a nightly or distribution of a binary with all needed GRFs and language files. Note: as this merge moves almost all files, it is recommended to make a backup of your working copy before updating your working copy.
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c153
1 files changed, 0 insertions, 153 deletions
diff --git a/debug.c b/debug.c
deleted file mode 100644
index 536d21c6a..000000000
--- a/debug.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/* $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_sprite_level;
-int _debug_oldloader_level;
-int _debug_ntp_level;
-int _debug_npf_level;
-int _debug_yapf_level;
-int _debug_freetype_level;
-int _debug_sl_level;
-
-
-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(sprite),
- DEBUG_LEVEL(oldloader),
- DEBUG_LEVEL(ntp),
- DEBUG_LEVEL(npf),
- DEBUG_LEVEL(yapf),
- DEBUG_LEVEL(freetype),
- DEBUG_LEVEL(sl),
- };
-#undef DEBUG_LEVEL
-
-#if !defined(NO_DEBUG_MESSAGES)
-
-/** Functionized DEBUG macro for compilers that don't support
- * variadic macros (__VA_ARGS__) such as...yes MSVC2003 and lower */
-#if defined(NO_VARARG_MACRO)
-void CDECL DEBUG(int name, int level, ...)
-{
- va_list va;
- const char *dbg;
- const DebugLevel *dl = &debug_level[name];
-
- if (level != 0 && *dl->level < level) return;
- dbg = dl->name;
- va_start(va, level);
-#else
-void CDECL debug(const char *dbg, ...)
-{
- va_list va;
- va_start(va, dbg);
-#endif /* NO_VARARG_MACRO */
- {
- const char *s;
- char buf[1024];
-
- s = va_arg(va, const char*);
- vsnprintf(buf, lengthof(buf), s, va);
- va_end(va);
- fprintf(stderr, "dbg: [%s] %s\n", dbg, buf);
- IConsoleDebug(dbg, buf);
- }
-}
-#endif /* NO_DEBUG_MESSAGES */
-
-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;
-}