Changeset - r14498:ba88afbc611b
[Not reviewed]
master
0 4 0
smatz - 14 years ago 2010-02-10 16:10:05
smatz@openttd.org
(svn r19079) -Codechange: use _debug_console_level instead of _stdlib_con_developer
4 files changed with 7 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/console.cpp
Show inline comments
 
@@ -30,13 +30,12 @@
 
IConsoleCmd   *_iconsole_cmds;    ///< list of registred commands
 
IConsoleVar   *_iconsole_vars;    ///< list of registred vars
 
IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
 

	
 
/* ** stdlib ** */
 
byte _stdlib_developer = 1;
 
bool _stdlib_con_developer = false;
 
FILE *_iconsole_output_file;
 

	
 
void IConsoleInit()
 
{
 
	_iconsole_output_file = NULL;
 
#ifdef ENABLE_NETWORK /* Initialize network only variables */
 
@@ -413,14 +412,13 @@ static void IConsoleAliasExec(const ICon
 
	uint i;
 
	uint a_index, astream_i;
 

	
 
	memset(&aliases, 0, sizeof(aliases));
 
	memset(&aliasstream, 0, sizeof(aliasstream));
 

	
 
	if (_stdlib_con_developer)
 
		IConsolePrintF(CC_DEBUG, "condbg: requested command is an alias; parsing...");
 
	DEBUG(console, 6, "condbg: requested command is an alias; parsing...");
 

	
 
	aliases[0] = aliasstream;
 
	for (cmdptr = alias->cmdline, a_index = 0, astream_i = 0; *cmdptr != '\0'; cmdptr++) {
 
		if (a_index >= lengthof(aliases) || astream_i >= lengthof(aliasstream)) break;
 

	
 
		switch (*cmdptr) {
 
@@ -693,14 +691,13 @@ void IConsoleVarPrintGetValue(const ICon
 
static void IConsoleVarExec(const IConsoleVar *var, byte tokencount, char *token[ICON_TOKEN_COUNT])
 
{
 
	const char *tokenptr = token[0];
 
	byte t_index = tokencount;
 
	uint32 value;
 

	
 
	if (_stdlib_con_developer)
 
		IConsolePrintF(CC_DEBUG, "condbg: requested command is a variable");
 
	DEBUG(console, 6, "Requested command is a variable");
 

	
 
	if (tokencount == 0) { // Just print out value
 
		IConsoleVarPrintGetValue(var);
 
		return;
 
	}
 

	
 
@@ -776,14 +773,13 @@ void IConsoleCmdExec(const char *cmdstr)
 
			IConsoleError("command contains malformed characters, aborting");
 
			IConsolePrintF(CC_ERROR, "ERROR: command was: '%s'", cmdstr);
 
			return;
 
		}
 
	}
 

	
 
	if (_stdlib_con_developer)
 
		IConsolePrintF(CC_DEBUG, "condbg: executing cmdline: '%s'", cmdstr);
 
	DEBUG(console, 4, "Executing cmdline: '%s'", cmdstr);
 

	
 
	memset(&tokens, 0, sizeof(tokens));
 
	memset(&tokenstream, 0, sizeof(tokenstream));
 

	
 
	/* 1. Split up commandline into tokens, seperated by spaces, commands
 
	 * enclosed in "" are taken as one token. We can only go as far as the amount
 
@@ -821,18 +817,14 @@ void IConsoleCmdExec(const char *cmdstr)
 
				foundtoken = true;
 
			}
 
			break;
 
		}
 
	}
 

	
 
	if (_stdlib_con_developer) {
 
		uint i;
 

	
 
		for (i = 0; tokens[i] != NULL; i++) {
 
			IConsolePrintF(CC_DEBUG, "condbg: token %d is: '%s'", i, tokens[i]);
 
		}
 
	for (uint i = 0; tokens[i] != NULL; i++) {
 
		DEBUG(console, 8, "condbg: token %d is: '%s'", i, tokens[i]);
 
	}
 

	
 
	if (tokens[0] == '\0') return; // don't execute empty commands
 
	/* 2. Determine type of command (cmd, alias or variable) and execute
 
	 * First try commands, then aliases, and finally variables. Execute
 
	 * the found action taking into account its hooking code
src/console_cmds.cpp
Show inline comments
 
@@ -1763,16 +1763,12 @@ DEF_CONSOLE_CMD(ConGamelogPrint)
 
/*******************************************
 
 *  debug commands and variables
 
 ********************************************/
 

	
 
static void IConsoleDebugLibRegister()
 
{
 
	/* debugging variables and functions */
 
	extern bool _stdlib_con_developer; // XXX extern in .cpp
 

	
 
	IConsoleVarRegister("con_developer",    &_stdlib_con_developer, ICONSOLE_VAR_BOOLEAN, "Enable/disable console debugging information (internal)");
 
	IConsoleCmdRegister("resettile",        ConResetTile);
 
	IConsoleCmdRegister("stopall",          ConStopAllVehicles);
 
	IConsoleAliasRegister("dbg_echo",       "echo %A; echo %B");
 
	IConsoleAliasRegister("dbg_echo2",      "echo %!");
 
}
 
#endif
src/debug.cpp
Show inline comments
 
@@ -37,12 +37,13 @@ int _debug_ntp_level;
 
int _debug_npf_level;
 
int _debug_yapf_level;
 
int _debug_freetype_level;
 
int _debug_sl_level;
 
int _debug_gamelog_level;
 
int _debug_desync_level;
 
int _debug_console_level;
 

	
 

	
 
struct DebugLevel {
 
	const char *name;
 
	int *level;
 
};
src/debug.h
Show inline comments
 
@@ -43,12 +43,13 @@
 
	extern int _debug_npf_level;
 
	extern int _debug_yapf_level;
 
	extern int _debug_freetype_level;
 
	extern int _debug_sl_level;
 
	extern int _debug_gamelog_level;
 
	extern int _debug_desync_level;
 
	extern int _debug_console_level;
 

	
 
	void CDECL debug(const char *dbg, const char *format, ...) WARN_FORMAT(2, 3);
 
#endif /* NO_DEBUG_MESSAGES */
 

	
 
void SetDebugString(const char *s);
 
const char *GetDebugString();
0 comments (0 inline, 0 general)