src/console.cpp
changeset 5860 7fdc9b423ba1
parent 5838 9c3129cb019b
child 6144 5a0ffbf27ced
equal deleted inserted replaced
5859:158718283d16 5860:7fdc9b423ba1
   222 #endif
   222 #endif
   223 
   223 
   224 	memset(_iconsole_history, 0, sizeof(_iconsole_history));
   224 	memset(_iconsole_history, 0, sizeof(_iconsole_history));
   225 	memset(_iconsole_buffer, 0, sizeof(_iconsole_buffer));
   225 	memset(_iconsole_buffer, 0, sizeof(_iconsole_buffer));
   226 	memset(_iconsole_cbuffer, 0, sizeof(_iconsole_cbuffer));
   226 	memset(_iconsole_cbuffer, 0, sizeof(_iconsole_cbuffer));
   227 	CallocT(&_iconsole_cmdline.buf, ICON_CMDLN_SIZE); // create buffer and zero it
   227 	_iconsole_cmdline.buf = CallocT<char>(ICON_CMDLN_SIZE); // create buffer and zero it
   228 	_iconsole_cmdline.maxlength = ICON_CMDLN_SIZE;
   228 	_iconsole_cmdline.maxlength = ICON_CMDLN_SIZE;
   229 
   229 
   230 	IConsolePrintF(13, "OpenTTD Game Console Revision 7 - %s", _openttd_revision);
   230 	IConsolePrintF(13, "OpenTTD Game Console Revision 7 - %s", _openttd_revision);
   231 	IConsolePrint(12,  "------------------------------------");
   231 	IConsolePrint(12,  "------------------------------------");
   232 	IConsolePrint(12,  "use \"help\" for more information");
   232 	IConsolePrint(12,  "use \"help\" for more information");
   611  * @param proc function that will be called upon execution of command
   611  * @param proc function that will be called upon execution of command
   612  */
   612  */
   613 void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc)
   613 void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc)
   614 {
   614 {
   615 	char *new_cmd = strdup(name);
   615 	char *new_cmd = strdup(name);
   616 	IConsoleCmd *item_new;
   616 	IConsoleCmd *item_new = MallocT<IConsoleCmd>(1);
   617 	MallocT(&item_new, 1);
       
   618 
   617 
   619 	item_new->next = NULL;
   618 	item_new->next = NULL;
   620 	item_new->proc = proc;
   619 	item_new->proc = proc;
   621 	item_new->name = new_cmd;
   620 	item_new->name = new_cmd;
   622 
   621 
   649  */
   648  */
   650 void IConsoleAliasRegister(const char *name, const char *cmd)
   649 void IConsoleAliasRegister(const char *name, const char *cmd)
   651 {
   650 {
   652 	char *new_alias = strdup(name);
   651 	char *new_alias = strdup(name);
   653 	char *cmd_aliased = strdup(cmd);
   652 	char *cmd_aliased = strdup(cmd);
   654 	IConsoleAlias *item_new;
   653 	IConsoleAlias *item_new = MallocT<IConsoleAlias>(1);
   655 	MallocT(&item_new, 1);
       
   656 
   654 
   657 	item_new->next = NULL;
   655 	item_new->next = NULL;
   658 	item_new->cmdline = cmd_aliased;
   656 	item_new->cmdline = cmd_aliased;
   659 	item_new->name = new_alias;
   657 	item_new->name = new_alias;
   660 
   658 
   785  * @param type the type of the variable (simple atomic) so we know which values it can get
   783  * @param type the type of the variable (simple atomic) so we know which values it can get
   786  */
   784  */
   787 void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help)
   785 void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help)
   788 {
   786 {
   789 	char *new_cmd = strdup(name);
   787 	char *new_cmd = strdup(name);
   790 	IConsoleVar *item_new;
   788 	IConsoleVar *item_new = MallocT<IConsoleVar>(1);
   791 	MallocT(&item_new, 1);
       
   792 
   789 
   793 	item_new->help = (help != NULL) ? strdup(help) : NULL;
   790 	item_new->help = (help != NULL) ? strdup(help) : NULL;
   794 
   791 
   795 	item_new->next = NULL;
   792 	item_new->next = NULL;
   796 	item_new->name = new_cmd;
   793 	item_new->name = new_cmd;