mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r295) -Fix: Rewrite and fix of console stuff, including marking (XXX) of areas that require further investigation (Tron)
-Note: booby trapped some suspicous assignments (Tron)
This commit is contained in:
parent
089a2a7847
commit
e2c1370d60
142
console.h
142
console.h
|
@ -1,17 +1,10 @@
|
|||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
// ** console ** //
|
||||
|
||||
enum {
|
||||
ICONSOLE_OPENED=0,
|
||||
ICONSOLE_CLOSED,
|
||||
} _iconsole_modes;
|
||||
|
||||
// ** console parser ** //
|
||||
|
||||
enum {
|
||||
ICONSOLE_VAR_NONE=0,
|
||||
typedef enum _iconsole_var_types {
|
||||
ICONSOLE_VAR_NONE,
|
||||
ICONSOLE_VAR_BOOLEAN,
|
||||
ICONSOLE_VAR_BYTE,
|
||||
ICONSOLE_VAR_UINT16,
|
||||
|
@ -21,47 +14,65 @@ enum {
|
|||
ICONSOLE_VAR_STRING,
|
||||
ICONSOLE_VAR_POINTER,
|
||||
ICONSOLE_VAR_REFERENCE,
|
||||
ICONSOLE_VAR_UNKNOWN,
|
||||
ICONSOLE_VAR_UNKNOWN
|
||||
} _iconsole_var_types;
|
||||
|
||||
enum {
|
||||
typedef enum _iconsole_hook_types {
|
||||
ICONSOLE_HOOK_ACCESS,
|
||||
ICONSOLE_HOOK_BEFORE_CHANGE,
|
||||
ICONSOLE_HOOK_BEFORE_EXEC,
|
||||
ICONSOLE_HOOK_AFTER_CHANGE,
|
||||
ICONSOLE_HOOK_AFTER_EXEC,
|
||||
ICONSOLE_HOOK_AFTER_EXEC
|
||||
} _iconsole_hook_types;
|
||||
|
||||
typedef struct {
|
||||
// -------------- //
|
||||
void * addr;
|
||||
byte * name;
|
||||
// -------------- //
|
||||
void * hook_access;
|
||||
void * hook_before_exec;
|
||||
void * hook_after_exec;
|
||||
// -------------- //
|
||||
void * _next;
|
||||
} _iconsole_cmd;
|
||||
struct _iconsole_var;
|
||||
typedef bool (*iconsole_var_hook)(struct _iconsole_var* hook_var);
|
||||
|
||||
typedef struct {
|
||||
typedef struct _iconsole_var {
|
||||
// --------------- //
|
||||
void * addr;
|
||||
const byte * name;
|
||||
byte type;
|
||||
union {
|
||||
void* addr;
|
||||
bool* bool_;
|
||||
byte* byte_;
|
||||
uint16* uint16_;
|
||||
uint32* uint32_;
|
||||
int16* int16_;
|
||||
int32* int32_;
|
||||
char* string_;
|
||||
struct _iconsole_var* reference_;
|
||||
} data;
|
||||
char* name;
|
||||
_iconsole_var_types type;
|
||||
// -------------- //
|
||||
void * hook_access;
|
||||
void * hook_before_change;
|
||||
void * hook_after_change;
|
||||
iconsole_var_hook hook_access;
|
||||
iconsole_var_hook hook_before_change;
|
||||
iconsole_var_hook hook_after_change;
|
||||
// -------------- //
|
||||
void * _next;
|
||||
struct _iconsole_var* _next;
|
||||
bool _malloc;
|
||||
} _iconsole_var;
|
||||
} _iconsole_var;
|
||||
|
||||
struct _iconsole_cmd;
|
||||
typedef bool (*iconsole_cmd_hook)(struct _iconsole_cmd* hook_cmd);
|
||||
|
||||
typedef _iconsole_var* (*_iconsole_cmd_addr)(byte argc, char* argv[], byte argt[]);
|
||||
|
||||
typedef struct _iconsole_cmd {
|
||||
// -------------- //
|
||||
_iconsole_cmd_addr addr;
|
||||
char* name;
|
||||
// -------------- //
|
||||
iconsole_cmd_hook hook_access;
|
||||
iconsole_cmd_hook hook_before_exec;
|
||||
iconsole_cmd_hook hook_after_exec;
|
||||
// -------------- //
|
||||
void* _next;
|
||||
} _iconsole_cmd;
|
||||
|
||||
// ** console parser ** //
|
||||
|
||||
_iconsole_cmd * _iconsole_cmds; // list of registred commands
|
||||
_iconsole_var * _iconsole_vars; // list of registred vars
|
||||
_iconsole_cmd* _iconsole_cmds; // list of registred commands
|
||||
_iconsole_var* _iconsole_vars; // list of registred vars
|
||||
|
||||
// ** console colors ** //
|
||||
VARDEF byte _iconsole_color_default;
|
||||
|
@ -72,58 +83,57 @@ VARDEF byte _iconsole_color_commands;
|
|||
|
||||
// ** ttd.c functions ** //
|
||||
|
||||
void SetDebugString(const char *s);
|
||||
void SetDebugString(const char* s);
|
||||
|
||||
// ** console functions ** //
|
||||
|
||||
void IConsoleClearCommand();
|
||||
void IConsoleInit();
|
||||
void IConsoleClear();
|
||||
void IConsoleFree();
|
||||
void IConsoleResize();
|
||||
void IConsoleSwitch();
|
||||
void IConsoleClose();
|
||||
void IConsoleOpen();
|
||||
void IConsoleInit(void);
|
||||
void IConsoleClear(void);
|
||||
void IConsoleFree(void);
|
||||
void IConsoleResize(void);
|
||||
void IConsoleSwitch(void);
|
||||
void IConsoleClose(void);
|
||||
void IConsoleOpen(void);
|
||||
|
||||
// ** console cmd buffer ** //
|
||||
void IConsoleCmdBufferAdd(const byte *cmd);
|
||||
void IConsoleCmdBufferAdd(const char* cmd);
|
||||
void IConsoleCmdBufferNavigate(signed char direction);
|
||||
|
||||
// ** console output ** //
|
||||
void IConsolePrint(byte color_code, const byte* string);
|
||||
void CDECL IConsolePrintF(byte color_code, const char *s, ...);
|
||||
void IConsoleDebug(byte* string);
|
||||
void IConsoleError(const byte* string);
|
||||
void IConsoleWarning(const byte* string);
|
||||
void IConsolePrint(byte color_code, const char* string);
|
||||
void CDECL IConsolePrintF(byte color_code, const char* s, ...);
|
||||
void IConsoleDebug(const char* string);
|
||||
void IConsoleError(const char* string);
|
||||
void IConsoleWarning(const char* string);
|
||||
|
||||
// *** Commands *** //
|
||||
|
||||
void IConsoleCmdRegister(const byte * name, void * addr);
|
||||
_iconsole_cmd * IConsoleCmdGet(const byte * name);
|
||||
void IConsoleCmdRegister(const char* name, _iconsole_cmd_addr addr);
|
||||
_iconsole_cmd* IConsoleCmdGet(const char* name);
|
||||
|
||||
// *** Variables *** //
|
||||
|
||||
void IConsoleVarRegister(const byte * name, void * addr, byte type);
|
||||
void IConsoleVarMemRegister(const byte * name, byte type);
|
||||
void IConsoleVarInsert(_iconsole_var * var, const byte * name);
|
||||
_iconsole_var * IConsoleVarGet(const byte * name);
|
||||
_iconsole_var * IConsoleVarAlloc(byte type);
|
||||
void IConsoleVarFree(_iconsole_var * var);
|
||||
void IConsoleVarSetString(_iconsole_var * var, const byte * string);
|
||||
void IConsoleVarSetValue(_iconsole_var * var, int value);
|
||||
void IConsoleVarDump(_iconsole_var * var, const byte * dump_desc);
|
||||
void IConsoleVarRegister(const char* name, void* addr, _iconsole_var_types type);
|
||||
void IConsoleVarMemRegister(const char* name, _iconsole_var_types type);
|
||||
void IConsoleVarInsert(_iconsole_var* var, const char* name);
|
||||
_iconsole_var* IConsoleVarGet(const char* name);
|
||||
_iconsole_var* IConsoleVarAlloc(_iconsole_var_types type);
|
||||
void IConsoleVarFree(_iconsole_var* var);
|
||||
void IConsoleVarSetString(_iconsole_var* var, const char* string);
|
||||
void IConsoleVarSetValue(_iconsole_var* var, int value);
|
||||
void IConsoleVarDump(const _iconsole_var* var, const char* dump_desc);
|
||||
|
||||
// *** Parser *** //
|
||||
|
||||
void IConsoleCmdExec(const byte* cmdstr);
|
||||
void IConsoleCmdExec(const char* cmdstr);
|
||||
|
||||
// ** console std lib ** //
|
||||
void IConsoleStdLibRegister();
|
||||
void IConsoleStdLibRegister(void);
|
||||
|
||||
// ** hook code ** //
|
||||
void IConsoleVarHook(const byte * name, byte type, void * proc);
|
||||
void IConsoleCmdHook(const byte * name, byte type, void * proc);
|
||||
bool IConsoleVarHookHandle(_iconsole_var * hook_var, byte type);
|
||||
bool IConsoleCmdHookHandle(_iconsole_cmd * hook_cmd, byte type);
|
||||
void IConsoleVarHook(const char* name, _iconsole_hook_types type, iconsole_var_hook proc);
|
||||
void IConsoleCmdHook(const char* name, _iconsole_hook_types type, iconsole_cmd_hook proc);
|
||||
bool IConsoleVarHookHandle(_iconsole_var* hook_var, _iconsole_hook_types type);
|
||||
bool IConsoleCmdHookHandle(_iconsole_cmd* hook_cmd, _iconsole_hook_types type);
|
||||
|
||||
#endif /* CONSOLE_H */
|
||||
|
|
307
console_cmds.c
307
console_cmds.c
|
@ -7,7 +7,7 @@
|
|||
#include "variables.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
# define ENABLE_NETWORK
|
||||
# define ENABLE_NETWORK
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -17,20 +17,20 @@ static bool _script_running;
|
|||
|
||||
// ** console command / variable defines ** //
|
||||
|
||||
#define DEF_CONSOLE_CMD(yyyy) static _iconsole_var * yyyy(byte argc, byte* argv[], byte argt[])
|
||||
#define DEF_CONSOLE_CMD(yyyy) static _iconsole_var * yyyy(byte argc, char* argv[], byte argt[])
|
||||
#define DEF_CONSOLE_CMD_HOOK(yyyy) static bool yyyy(_iconsole_cmd * hookcmd)
|
||||
#define DEF_CONSOLE_VAR_HOOK(yyyy) static bool yyyy(_iconsole_var * hookvar)
|
||||
|
||||
|
||||
// ** supporting functions ** //
|
||||
|
||||
static int32 GetArgumentInteger(byte *arg)
|
||||
static uint32 GetArgumentInteger(const char* arg)
|
||||
{
|
||||
int32 result;
|
||||
sscanf((char *)arg, "%u", &result);
|
||||
uint32 result;
|
||||
sscanf(arg, "%u", &result);
|
||||
|
||||
if (result == 0 && arg[0] == '0' && arg[1] == 'x')
|
||||
sscanf((char *)arg, "%x", &result);
|
||||
sscanf(arg, "%x", &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetwork)
|
|||
if (_networking) {
|
||||
IConsoleError("this command is forbidden in multiplayer");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetwork)
|
|||
if (_networking) {
|
||||
IConsoleError("this variable is forbidden in multiplayer");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -64,7 +64,7 @@ DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetClient)
|
|||
if (!_networking_server) {
|
||||
IConsoleError("this variable only makes sense for a network server");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,7 @@ DEF_CONSOLE_CMD(ConResetEngines)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
DEF_CONSOLE_CMD(ConResetTile)
|
||||
{
|
||||
if (argc == 2) {
|
||||
|
@ -87,6 +88,7 @@ DEF_CONSOLE_CMD(ConResetTile)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
DEF_CONSOLE_CMD(ConScrollToTile)
|
||||
{
|
||||
|
@ -105,9 +107,9 @@ DEF_CONSOLE_CMD(ConScrollToTile)
|
|||
|
||||
DEF_CONSOLE_CMD(ConNetworkConnect)
|
||||
{
|
||||
byte * ip;
|
||||
const byte *port = NULL;
|
||||
const byte *player = NULL;
|
||||
char* ip;
|
||||
const char *port = NULL;
|
||||
const char *player = NULL;
|
||||
uint16 rport;
|
||||
|
||||
if (argc<2) return NULL;
|
||||
|
@ -117,14 +119,14 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
|
|||
|
||||
ParseConnectionString(&player, &port, ip);
|
||||
|
||||
IConsolePrintF(_iconsole_color_default,"Connecting to %s...", ip);
|
||||
IConsolePrintF(_iconsole_color_default, "Connecting to %s...", ip);
|
||||
if (player!=NULL) {
|
||||
_network_playas = atoi(player);
|
||||
IConsolePrintF(_iconsole_color_default," player-no: %s", player);
|
||||
IConsolePrintF(_iconsole_color_default, " player-no: %s", player);
|
||||
}
|
||||
if (port!=NULL) {
|
||||
rport = atoi(port);
|
||||
IConsolePrintF(_iconsole_color_default," port: %s", port);
|
||||
IConsolePrintF(_iconsole_color_default, " port: %s", port);
|
||||
}
|
||||
|
||||
NetworkCoreConnectGame(ip, rport);
|
||||
|
@ -146,7 +148,7 @@ DEF_CONSOLE_CMD(ConExec)
|
|||
if (argc<2) return NULL;
|
||||
|
||||
doerror = true;
|
||||
_script_file = fopen(argv[1],"rb");
|
||||
_script_file = fopen(argv[1], "rb");
|
||||
|
||||
if (_script_file == NULL) {
|
||||
if (argc>2) if (atoi(argv[2])==0) doerror=false;
|
||||
|
@ -157,11 +159,8 @@ DEF_CONSOLE_CMD(ConExec)
|
|||
_script_running = true;
|
||||
|
||||
while (!feof(_script_file) && _script_running) {
|
||||
|
||||
fgets((char *)&cmd, 1024, _script_file);
|
||||
|
||||
IConsoleCmdExec((byte *) &cmd);
|
||||
|
||||
fgets(cmd, sizeof(cmd), _script_file);
|
||||
IConsoleCmdExec(cmd);
|
||||
}
|
||||
|
||||
_script_running = false;
|
||||
|
@ -182,13 +181,14 @@ DEF_CONSOLE_CMD(ConReturn)
|
|||
DEF_CONSOLE_CMD(ConScript)
|
||||
{
|
||||
extern FILE* _iconsole_output_file;
|
||||
if (_iconsole_output_file!=NULL) {
|
||||
IConsolePrintF(_iconsole_color_default,"file output complete");
|
||||
if (_iconsole_output_file != NULL) {
|
||||
IConsolePrintF(_iconsole_color_default, "file output complete");
|
||||
fclose(_iconsole_output_file);
|
||||
} else {
|
||||
if (argc<2) return NULL;
|
||||
IConsolePrintF(_iconsole_color_default,"file output started to: %s",argv[1]);
|
||||
_iconsole_output_file = fopen(argv[1],"ab");
|
||||
if (argc < 2) return NULL;
|
||||
IConsolePrintF(_iconsole_color_default, "file output started to: %s",
|
||||
argv[1]);
|
||||
_iconsole_output_file = fopen(argv[1], "ab");
|
||||
if (_iconsole_output_file == NULL) IConsoleError("could not open file");
|
||||
}
|
||||
return NULL;
|
||||
|
@ -197,93 +197,94 @@ DEF_CONSOLE_CMD(ConScript)
|
|||
|
||||
DEF_CONSOLE_CMD(ConEcho)
|
||||
{
|
||||
if (argc<2) return NULL;
|
||||
if (argc < 2) return NULL;
|
||||
IConsolePrint(_iconsole_color_default, argv[1]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConEchoC)
|
||||
{
|
||||
if (argc<3) return NULL;
|
||||
if (argc < 3) return NULL;
|
||||
IConsolePrint(atoi(argv[1]), argv[2]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConPrintF)
|
||||
{
|
||||
if (argc<3) return NULL;
|
||||
IConsolePrintF(_iconsole_color_default, argv[1] ,argv[2],argv[3],argv[4],argv[5],argv[6],argv[7],argv[8],argv[9],argv[10],argv[11],argv[12],argv[13],argv[14],argv[15],argv[16],argv[17],argv[18],argv[19]);
|
||||
if (argc < 3) return NULL;
|
||||
IConsolePrintF(_iconsole_color_default, argv[1] , argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11], argv[12], argv[13], argv[14], argv[15], argv[16], argv[17], argv[18], argv[19]); /* XXX ugh... */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConPrintFC)
|
||||
{
|
||||
if (argc<3) return NULL;
|
||||
IConsolePrintF(atoi(argv[1]), argv[2] ,argv[3],argv[4],argv[5],argv[6],argv[7],argv[8],argv[9],argv[10],argv[11],argv[12],argv[13],argv[14],argv[15],argv[16],argv[17],argv[18],argv[19]);
|
||||
if (argc < 3) return NULL;
|
||||
IConsolePrintF(atoi(argv[1]), argv[2] , argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11], argv[12], argv[13], argv[14], argv[15], argv[16], argv[17], argv[18], argv[19]); /* XXX ugh... */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConScreenShot)
|
||||
{
|
||||
if (argc<2) {
|
||||
_make_screenshot=1;
|
||||
if (argc < 2) {
|
||||
_make_screenshot = 1;
|
||||
} else {
|
||||
if (strcmp(argv[1],"big")==0) {
|
||||
if (strcmp(argv[1], "big") == 0)
|
||||
_make_screenshot=2;
|
||||
}
|
||||
if (strcmp(argv[1],"no_con")==0) {
|
||||
if (strcmp(argv[1], "no_con") == 0) {
|
||||
IConsoleClose();
|
||||
_make_screenshot=1;
|
||||
}
|
||||
_make_screenshot = 1;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConInfoVar)
|
||||
{
|
||||
if (argc<2) return NULL;
|
||||
if (argt[1]!=ICONSOLE_VAR_REFERENCE) {
|
||||
if (argc < 2) return NULL;
|
||||
if (argt[1] != ICONSOLE_VAR_REFERENCE) {
|
||||
IConsoleError("first argument has to be a variable reference");
|
||||
} else {
|
||||
_iconsole_var * item;
|
||||
item = (_iconsole_var *) argv[1];
|
||||
IConsolePrintF(_iconsole_color_default,"var_name: %s",item->name);
|
||||
IConsolePrintF(_iconsole_color_default,"var_type: %i",item->type);
|
||||
IConsolePrintF(_iconsole_color_default,"var_addr: %i",item->addr);
|
||||
if (item->_malloc) IConsolePrintF(_iconsole_color_default,"var_malloc: internal");
|
||||
else IConsolePrintF(_iconsole_color_default, "var_malloc: external");
|
||||
} else {
|
||||
_iconsole_var* item;
|
||||
item = (_iconsole_var*)argv[1];
|
||||
IConsolePrintF(_iconsole_color_default, "var_name: %s", item->name);
|
||||
IConsolePrintF(_iconsole_color_default, "var_type: %i", item->type);
|
||||
IConsolePrintF(_iconsole_color_default, "var_addr: %i", item->data.addr);
|
||||
if (item->_malloc)
|
||||
IConsolePrintF(_iconsole_color_default, "var_malloc: internal");
|
||||
else
|
||||
IConsolePrintF(_iconsole_color_default, "var_malloc: external");
|
||||
if (item->hook_access) IConsoleWarning("var_access hooked");
|
||||
if (item->hook_before_change) IConsoleWarning("var_before_change hooked");
|
||||
if (item->hook_after_change) IConsoleWarning("var_after_change hooked");
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
DEF_CONSOLE_CMD(ConInfoCmd)
|
||||
{
|
||||
if (argc<2) return NULL;
|
||||
if (argt[1]!=ICONSOLE_VAR_UNKNOWN) {
|
||||
if (argc < 2) return NULL;
|
||||
if (argt[1] != ICONSOLE_VAR_UNKNOWN) {
|
||||
IConsoleError("first argument has to be a command name");
|
||||
} else {
|
||||
_iconsole_cmd * item;
|
||||
} else {
|
||||
_iconsole_cmd* item;
|
||||
item = IConsoleCmdGet(argv[1]);
|
||||
if (item==NULL) {
|
||||
if (item == NULL) {
|
||||
IConsoleError("the given command was not found");
|
||||
return NULL;
|
||||
}
|
||||
IConsolePrintF(_iconsole_color_default,"cmd_name: %s",item->name);
|
||||
IConsolePrintF(_iconsole_color_default,"cmd_addr: %i",item->addr);
|
||||
IConsolePrintF(_iconsole_color_default, "cmd_name: %s", item->name);
|
||||
IConsolePrintF(_iconsole_color_default, "cmd_addr: %i", item->addr);
|
||||
if (item->hook_access) IConsoleWarning("cmd_access hooked");
|
||||
if (item->hook_before_exec) IConsoleWarning("cmd_before_exec hooked");
|
||||
if (item->hook_after_exec) IConsoleWarning("cmd_after_exec hooked");
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConDebugLevel)
|
||||
{
|
||||
if (argc<2) return NULL;
|
||||
if (argc < 2) return NULL;
|
||||
SetDebugString(argv[1]);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -296,100 +297,68 @@ DEF_CONSOLE_CMD(ConExit)
|
|||
|
||||
DEF_CONSOLE_CMD(ConHelp)
|
||||
{
|
||||
IConsolePrint(13 ," -- console help -- ");
|
||||
IConsolePrint(1 ," variables: [command to list them: list_vars]");
|
||||
IConsolePrint(1 ," *temp_string = \"my little \"");
|
||||
IConsolePrint(1 ,"");
|
||||
IConsolePrint(1 ," commands: [command to list them: list_cmds]");
|
||||
IConsolePrint(1 ," [command] [\"string argument with spaces\"] [argument 2] ...");
|
||||
IConsolePrint(1 ," printf \"%s world\" *temp_string");
|
||||
IConsolePrint(1 ,"");
|
||||
IConsolePrint(1 ," command/variable returning a value into an variable:");
|
||||
IConsolePrint(1 ," *temp_uint16 << random");
|
||||
IConsolePrint(1 ," *temp_uint16 << *temp_uint16_2");
|
||||
IConsolePrint(1 ,"");
|
||||
IConsolePrint(13, " -- console help -- ");
|
||||
IConsolePrint( 1, " variables: [command to list them: list_vars]");
|
||||
IConsolePrint( 1, " *temp_string = \"my little \"");
|
||||
IConsolePrint( 1, "");
|
||||
IConsolePrint( 1, " commands: [command to list them: list_cmds]");
|
||||
IConsolePrint( 1, " [command] [\"string argument with spaces\"] [argument 2] ...");
|
||||
IConsolePrint( 1, " printf \"%s world\" *temp_string");
|
||||
IConsolePrint( 1, "");
|
||||
IConsolePrint( 1, " command/variable returning a value into an variable:");
|
||||
IConsolePrint( 1, " *temp_uint16 << random");
|
||||
IConsolePrint( 1, " *temp_uint16 << *temp_uint16_2");
|
||||
IConsolePrint( 1, "");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConRandom)
|
||||
{
|
||||
_iconsole_var * result;
|
||||
/* XXX memory leak */
|
||||
_iconsole_var* result;
|
||||
result = IConsoleVarAlloc(ICONSOLE_VAR_UINT16);
|
||||
IConsoleVarSetValue(result,rand());
|
||||
IConsoleVarSetValue(result, rand());
|
||||
return result;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConListCommands)
|
||||
{
|
||||
_iconsole_cmd * item;
|
||||
int l = 0;
|
||||
const _iconsole_cmd* item;
|
||||
size_t l = 0;
|
||||
|
||||
if (argv[1]!=NULL) l = strlen((char *) argv[1]);
|
||||
if (argv[1] != NULL) l = strlen(argv[1]);
|
||||
|
||||
item = _iconsole_cmds;
|
||||
while (item != NULL) {
|
||||
if (argv[1]!=NULL) {
|
||||
|
||||
if (memcmp((void *) item->name, (void *) argv[1],l)==0)
|
||||
IConsolePrintF(_iconsole_color_default,"%s",item->name);
|
||||
|
||||
} else {
|
||||
|
||||
IConsolePrintF(_iconsole_color_default,"%s",item->name);
|
||||
|
||||
}
|
||||
item = item->_next;
|
||||
}
|
||||
for (item = _iconsole_cmds; item != NULL; item = item->_next)
|
||||
if (argv[1] == NULL || strncmp(item->name, argv[1], l) == 0)
|
||||
IConsolePrintF(_iconsole_color_default, "%s", item->name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConListVariables)
|
||||
{
|
||||
_iconsole_var * item;
|
||||
int l = 0;
|
||||
const _iconsole_var* item;
|
||||
size_t l = 0;
|
||||
|
||||
if (argv[1]!=NULL) l = strlen((char *) argv[1]);
|
||||
if (argv[1] != NULL) l = strlen(argv[1]);
|
||||
|
||||
item = _iconsole_vars;
|
||||
while (item != NULL) {
|
||||
if (argv[1]!=NULL) {
|
||||
|
||||
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;
|
||||
}
|
||||
for (item = _iconsole_vars; item != NULL; item = item->_next)
|
||||
if (argv[1] == NULL || strncmp(item->name, argv[1], l) == 0)
|
||||
IConsolePrintF(_iconsole_color_default, "%s", item->name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_CMD(ConListDumpVariables)
|
||||
{
|
||||
_iconsole_var * item;
|
||||
int l = 0;
|
||||
const _iconsole_var* item;
|
||||
size_t l = 0;
|
||||
|
||||
if (argv[1]!=NULL) l = strlen((char *) argv[1]);
|
||||
if (argv[1] != NULL) l = strlen(argv[1]);
|
||||
|
||||
item = _iconsole_vars;
|
||||
while (item != NULL) {
|
||||
if (argv[1]!=NULL) {
|
||||
|
||||
if (memcmp(item->name, argv[1],l)==0)
|
||||
IConsoleVarDump(item,NULL);
|
||||
|
||||
} else {
|
||||
|
||||
IConsoleVarDump(item,NULL);
|
||||
|
||||
}
|
||||
item = item->_next;
|
||||
}
|
||||
for (item = _iconsole_vars; item != NULL; item = item->_next)
|
||||
if (argv[1] == NULL || strncmp(item->name, argv[1], l) == 0)
|
||||
IConsoleVarDump(item, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -402,19 +371,19 @@ DEF_CONSOLE_CMD(ConListDumpVariables)
|
|||
void IConsoleDebugLibRegister()
|
||||
{
|
||||
// stdlib
|
||||
extern bool _stdlib_con_developer;
|
||||
extern bool _stdlib_con_developer; /* XXX extern in .c */
|
||||
|
||||
IConsoleVarRegister("con_developer",(void *) &_stdlib_con_developer,ICONSOLE_VAR_BOOLEAN);
|
||||
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);
|
||||
IConsoleVarRegister("con_developer", &_stdlib_con_developer, ICONSOLE_VAR_BOOLEAN);
|
||||
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
|
||||
|
||||
|
@ -425,51 +394,49 @@ void IConsoleDebugLibRegister()
|
|||
void IConsoleStdLibRegister()
|
||||
{
|
||||
// stdlib
|
||||
extern byte _stdlib_developer;
|
||||
extern byte _stdlib_developer; /* XXX extern in .c */
|
||||
|
||||
#ifdef _DEBUG
|
||||
IConsoleDebugLibRegister();
|
||||
#else
|
||||
(void)ConResetTile; // Silence warning, this is only used in _DEBUG
|
||||
#endif
|
||||
|
||||
// functions [please add them alphabeticaly]
|
||||
// functions [please add them alphabetically]
|
||||
#ifdef ENABLE_NETWORK
|
||||
IConsoleCmdRegister("connect",ConNetworkConnect);
|
||||
IConsoleCmdHook("connect",ICONSOLE_HOOK_ACCESS,ConCmdHookNoNetwork);
|
||||
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("exec",ConExec);
|
||||
IConsoleCmdRegister("exit",ConExit);
|
||||
IConsoleCmdRegister("help",ConHelp);
|
||||
IConsoleCmdRegister("info_cmd",ConInfoCmd);
|
||||
IConsoleCmdRegister("info_var",ConInfoVar);
|
||||
IConsoleCmdRegister("list_cmds",ConListCommands);
|
||||
IConsoleCmdRegister("list_vars",ConListVariables);
|
||||
IConsoleCmdRegister("printf",ConPrintF);
|
||||
IConsoleCmdRegister("printfc",ConPrintFC);
|
||||
IConsoleCmdRegister("quit",ConExit);
|
||||
IConsoleCmdRegister("random",ConRandom);
|
||||
IConsoleCmdRegister("resetengines",ConResetEngines);
|
||||
IConsoleCmdHook("resetengines",ICONSOLE_HOOK_ACCESS,ConCmdHookNoNetwork);
|
||||
IConsoleCmdRegister("return",ConReturn);
|
||||
IConsoleCmdRegister("screenshot",ConScreenShot);
|
||||
IConsoleCmdRegister("script",ConScript);
|
||||
IConsoleCmdRegister("scrollto",ConScrollToTile);
|
||||
IConsoleCmdRegister("debug_level", ConDebugLevel);
|
||||
IConsoleCmdRegister("dump_vars", ConListDumpVariables);
|
||||
IConsoleCmdRegister("echo", ConEcho);
|
||||
IConsoleCmdRegister("echoc", ConEchoC);
|
||||
IConsoleCmdRegister("exec", ConExec);
|
||||
IConsoleCmdRegister("exit", ConExit);
|
||||
IConsoleCmdRegister("help", ConHelp);
|
||||
IConsoleCmdRegister("info_cmd", ConInfoCmd);
|
||||
IConsoleCmdRegister("info_var", ConInfoVar);
|
||||
IConsoleCmdRegister("list_cmds", ConListCommands);
|
||||
IConsoleCmdRegister("list_vars", ConListVariables);
|
||||
IConsoleCmdRegister("printf", ConPrintF);
|
||||
IConsoleCmdRegister("printfc", ConPrintFC);
|
||||
IConsoleCmdRegister("quit", ConExit);
|
||||
IConsoleCmdRegister("random", ConRandom);
|
||||
IConsoleCmdRegister("resetengines", ConResetEngines);
|
||||
IConsoleCmdHook("resetengines", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetwork);
|
||||
IConsoleCmdRegister("return", ConReturn);
|
||||
IConsoleCmdRegister("screenshot", ConScreenShot);
|
||||
IConsoleCmdRegister("script", ConScript);
|
||||
IConsoleCmdRegister("scrollto", ConScrollToTile);
|
||||
|
||||
// variables [please add them alphabeticaly]
|
||||
IConsoleVarRegister("developer",(void *) &_stdlib_developer,ICONSOLE_VAR_BYTE);
|
||||
IConsoleVarRegister("developer", &_stdlib_developer, ICONSOLE_VAR_BYTE);
|
||||
#ifdef ENABLE_NETWORK
|
||||
IConsoleVarRegister("net_client_timeout",&_network_client_timeout,ICONSOLE_VAR_UINT16);
|
||||
IConsoleVarHook("*net_client_timeout",ICONSOLE_HOOK_ACCESS,ConVarHookNoNetClient);
|
||||
IConsoleVarRegister("net_ready_ahead",&_network_ready_ahead,ICONSOLE_VAR_UINT16);
|
||||
IConsoleVarRegister("net_sync_freq",&_network_sync_freq,ICONSOLE_VAR_UINT16);
|
||||
IConsoleVarHook("*net_sync_freq",ICONSOLE_HOOK_ACCESS,ConVarHookNoNetClient);
|
||||
IConsoleVarRegister("net_client_timeout", &_network_client_timeout, ICONSOLE_VAR_UINT16);
|
||||
IConsoleVarHook("*net_client_timeout", ICONSOLE_HOOK_ACCESS, ConVarHookNoNetClient);
|
||||
IConsoleVarRegister("net_ready_ahead", &_network_ready_ahead, ICONSOLE_VAR_UINT16);
|
||||
IConsoleVarRegister("net_sync_freq", &_network_sync_freq, ICONSOLE_VAR_UINT16);
|
||||
IConsoleVarHook("*net_sync_freq", ICONSOLE_HOOK_ACCESS, ConVarHookNoNetClient);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
/* -------------------- dont cross this line --------------------- */
|
||||
/* -------------------- don't cross this line --------------------- */
|
||||
|
|
Loading…
Reference in New Issue