File diff r221:56c7ed3a0581 → r222:4409829eb08f
console_cmds.c
Show inline comments
 
@@ -18,56 +18,58 @@
 
static int32 GetArgumentInteger(byte *arg)
 
{
 
	int32 result;
 
	sscanf((char *)arg, "%u", &result);
 
 
	if (result == 0 && arg[0] == '0' && arg[1] == 'x')
 
		sscanf((char *)arg, "%x", &result);
 
 
	return result;
 
}
 
 
/* **************************** */
 
/* variable and command hooks   */
 
/* **************************** */
 
 
DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetwork)
 
{
 
	if (_networking) {
 
		IConsoleError("this command is forbidden in multiplayer");
 
		return false;
 
		}
 
	return true;
 
}
 
 
#if 0 /* Not used atm */
 
DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetwork)
 
{
 
	if (_networking) {
 
		IConsoleError("this variable is forbidden in multiplayer");
 
		return false;
 
		}
 
	return true;
 
}
 
#endif
 
 
DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetClient)
 
{
 
	if (!_networking_server) {
 
		IConsoleError("this variable only makes sense for a network server");
 
		return false;
 
		}
 
	return true;
 
}
 
 
/* **************************** */
 
/* reset commands               */
 
/* **************************** */
 
 
DEF_CONSOLE_CMD(ConResetEngines)
 
{
 
	StartupEngines();
 
	return 0;
 
}
 
 
DEF_CONSOLE_CMD(ConResetTile)
 
{
 
	if (argc == 2) {
 
		TileIndex tile = (TileIndex)GetArgumentInteger(argv[1]);
 
@@ -254,119 +256,121 @@ DEF_CONSOLE_CMD(ConListCommands)
 
					IConsolePrintF(_iconsole_color_default,"%s",item->name);
 
 
			} else {
 
 
			IConsolePrintF(_iconsole_color_default,"%s",item->name);
 
 
			}
 
		item = item->_next;
 
		}
 
 
	return NULL;
 
}
 
 
DEF_CONSOLE_CMD(ConListVariables) 
 
{
 
	_iconsole_var * item;
 
	int l = 0;
 
 
	if (argv[1]!=NULL) l = strlen((char *) argv[1]);
 
 
	item = _iconsole_vars;
 
	while (item != NULL) {
 
		if (argv[1]!=NULL) {
 
 
			if (memcmp((void *) item->name, (void *) argv[1],l)==0)
 
			if (memcmp(item->name, argv[1],l)==0)
 
					IConsolePrintF(_iconsole_color_default,"%s",item->name);
 
 
			} else {
 
 
			IConsolePrintF(_iconsole_color_default,"%s",item->name);
 
 
			}
 
		item = item->_next;
 
		}
 
 
	return NULL;
 
}
 
 
DEF_CONSOLE_CMD(ConListDumpVariables)
 
{
 
	_iconsole_var * item;
 
	int l = 0;
 
 
	if (argv[1]!=NULL) l = strlen((char *) argv[1]);
 
 
	item = _iconsole_vars;
 
	while (item != NULL) {
 
		if (argv[1]!=NULL) {
 
 
			if (memcmp((void *) item->name, (void *) argv[1],l)==0)
 
			if (memcmp(item->name, argv[1],l)==0)
 
					IConsoleVarDump(item,NULL);
 
 
			} else {
 
 
			IConsoleVarDump(item,NULL);
 
 
			}
 
		item = item->_next;
 
		}
 
 
	return NULL;
 
}
 
 
#ifdef _DEBUG
 
/* ****************************************** */
 
/*  debug commands and variables */
 
/* ****************************************** */
 
 
void IConsoleDebugLibRegister() 
 
{
 
	IConsoleVarMemRegister("temp_bool",ICONSOLE_VAR_BOOLEAN);
 
	IConsoleVarMemRegister("temp_int16",ICONSOLE_VAR_INT16);
 
	IConsoleVarMemRegister("temp_int32",ICONSOLE_VAR_INT32);
 
	IConsoleVarMemRegister("temp_pointer",ICONSOLE_VAR_POINTER);
 
	IConsoleVarMemRegister("temp_uint16",ICONSOLE_VAR_UINT16);
 
	IConsoleVarMemRegister("temp_uint16_2",ICONSOLE_VAR_UINT16);
 
	IConsoleVarMemRegister("temp_uint32",ICONSOLE_VAR_UINT32);
 
	IConsoleVarMemRegister("temp_string",ICONSOLE_VAR_STRING);
 
	IConsoleVarMemRegister("temp_string2",ICONSOLE_VAR_STRING);
 
	IConsoleCmdRegister("resettile",ConResetTile);
 
}
 
#endif
 
 
/* ****************************************** */
 
/*  console command and variable registration */
 
/* ****************************************** */
 
 
void IConsoleStdLibRegister()
 
{
 
	// stdlib
 
	extern byte _stdlib_developer;
 
	extern bool _stdlib_con_developer;
 
 
#ifdef _DEBUG
 
	IConsoleDebugLibRegister();
 
#else
 
	(void)ConResetTile; // Silence warning, this is only used in _DEBUG
 
#endif
 
 
	// functions [please add them alphabeticaly]
 
#ifdef ENABLE_NETWORK
 
	IConsoleCmdRegister("connect",ConNetworkConnect);
 
	IConsoleCmdHook("connect",ICONSOLE_HOOK_ACCESS,ConCmdHookNoNetwork);
 
#endif
 
	IConsoleCmdRegister("debug_level",ConDebugLevel);
 
	IConsoleCmdRegister("dump_vars",ConListDumpVariables);
 
	IConsoleCmdRegister("echo",ConEcho);
 
	IConsoleCmdRegister("echoc",ConEchoC);
 
	IConsoleCmdRegister("exit",ConExit);
 
	IConsoleCmdRegister("help",ConHelp);
 
	IConsoleCmdRegister("printf",ConPrintF);
 
	IConsoleCmdRegister("printfc",ConPrintFC);
 
	IConsoleCmdRegister("quit",ConExit);
 
	IConsoleCmdRegister("random",ConRandom);
 
	IConsoleCmdRegister("list_cmds",ConListCommands);
 
	IConsoleCmdRegister("list_vars",ConListVariables);
 
	IConsoleCmdRegister("resetengines",ConResetEngines);
 
	IConsoleCmdHook("resetengines",ICONSOLE_HOOK_ACCESS,ConCmdHookNoNetwork);
 
	IConsoleCmdRegister("screenshot",ConScreenShot);
 
	IConsoleCmdRegister("scrollto",ConScrollToTile);
 
	IConsoleCmdRegister("varinfo",ConVarInfo);