mirror of https://github.com/OpenTTD/OpenTTD
(svn r1420) -Fix: Console alias, load_game functionality and load fix (sign_de)
parent
2da54df9df
commit
b11f7c7817
|
@ -625,9 +625,10 @@ void IConsoleAliasExec(const char* cmdline, char* tokens[20], byte tokentypes[20
|
||||||
x += l2+1;
|
x += l2+1;
|
||||||
t++;
|
t++;
|
||||||
}
|
}
|
||||||
|
linestream--;
|
||||||
*linestream = '"';
|
*linestream = '"';
|
||||||
linestream++;
|
linestream++;
|
||||||
x += 2;
|
x += 1;
|
||||||
} else {
|
} else {
|
||||||
// one specific parameter: %A = [param 1] %B = [param 2] ...
|
// one specific parameter: %A = [param 1] %B = [param 2] ...
|
||||||
int l2;
|
int l2;
|
||||||
|
|
|
@ -153,16 +153,18 @@ static void LoadMap(uint no)
|
||||||
if (no != 0 && no <= (uint)_fios_num) {
|
if (no != 0 && no <= (uint)_fios_num) {
|
||||||
const FiosItem *item = &_fios_list[no - 1];
|
const FiosItem *item = &_fios_list[no - 1];
|
||||||
|
|
||||||
/* Load the file */
|
if (item->type == FIOS_TYPE_FILE) {
|
||||||
_switch_mode = SM_LOAD;
|
/* Load the file */
|
||||||
SetFiosType(item->type);
|
_switch_mode = SM_LOAD;
|
||||||
strcpy(_file_to_saveload.name, FiosBrowseTo(item));
|
SetFiosType(item->type);
|
||||||
|
strcpy(_file_to_saveload.name, FiosBrowseTo(item));
|
||||||
|
|
||||||
IConsolePrint(_iconsole_color_default, "Loading map...");
|
IConsolePrint(_iconsole_color_default, "Loading map...");
|
||||||
} else {
|
} else
|
||||||
/* Show usages */
|
IConsolePrint(_iconsole_color_error, "That is not a map.");
|
||||||
IConsolePrint(_iconsole_color_default, "Unknown map. Use 'list_files' and 'goto_dir' to find the numbers of the savegame.");
|
|
||||||
}
|
} else /* Show usages */
|
||||||
|
IConsolePrint(_iconsole_color_error, "Unknown map. Use 'list_files' and 'goto_dir' to find the numbers of the savegame.");
|
||||||
|
|
||||||
/* Free the file-list */
|
/* Free the file-list */
|
||||||
FiosFreeSavegameList();
|
FiosFreeSavegameList();
|
||||||
|
@ -206,6 +208,54 @@ DEF_CONSOLE_CMD(ConListFiles)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get an Specific file */
|
||||||
|
DEF_CONSOLE_CMD(ConScanFiles)
|
||||||
|
{
|
||||||
|
const FiosItem *item;
|
||||||
|
int pos = 0;
|
||||||
|
_iconsole_var* result;
|
||||||
|
|
||||||
|
|
||||||
|
result = IConsoleVarAlloc(ICONSOLE_VAR_STRING);
|
||||||
|
|
||||||
|
if (argc <= 1) {
|
||||||
|
IConsoleVarSetString(result, "0");
|
||||||
|
return result; // return an zero
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build the file-list */
|
||||||
|
BuildFileList();
|
||||||
|
|
||||||
|
/* As long as we have files */
|
||||||
|
while (pos < _fios_num) {
|
||||||
|
item = _fios_list + pos;
|
||||||
|
pos++;
|
||||||
|
if (strcmp(argv[1], "..") == 0) {
|
||||||
|
if (item->type == FIOS_TYPE_PARENT) {
|
||||||
|
// huh we are searching for the parent directory
|
||||||
|
char buffer[10];
|
||||||
|
itoa(pos,buffer,10);
|
||||||
|
IConsoleVarSetString(result, buffer);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
// file records ?
|
||||||
|
if (item->type == FIOS_TYPE_FILE) {
|
||||||
|
if (strcmp(argv[1], item->name) == 0) {
|
||||||
|
char buffer[10];
|
||||||
|
itoa(pos,buffer,10);
|
||||||
|
IConsoleVarSetString(result, buffer);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Destroy the file list */
|
||||||
|
FiosFreeSavegameList();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Change the dir via console */
|
/* Change the dir via console */
|
||||||
DEF_CONSOLE_CMD(ConGotoDir)
|
DEF_CONSOLE_CMD(ConGotoDir)
|
||||||
{
|
{
|
||||||
|
@ -1089,15 +1139,8 @@ void IConsoleDebugLibRegister()
|
||||||
extern bool _stdlib_con_developer; /* XXX extern in .c */
|
extern bool _stdlib_con_developer; /* XXX extern in .c */
|
||||||
|
|
||||||
IConsoleVarRegister("con_developer", &_stdlib_con_developer, ICONSOLE_VAR_BOOLEAN);
|
IConsoleVarRegister("con_developer", &_stdlib_con_developer, ICONSOLE_VAR_BOOLEAN);
|
||||||
IConsoleVarMemRegister("temp_string", ICONSOLE_VAR_STRING);
|
|
||||||
IConsoleVarMemRegister("temp_string2", ICONSOLE_VAR_STRING);
|
IConsoleVarMemRegister("temp_string2", ICONSOLE_VAR_STRING);
|
||||||
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_uint16_2", ICONSOLE_VAR_UINT16);
|
||||||
IConsoleVarMemRegister("temp_uint32", ICONSOLE_VAR_UINT32);
|
|
||||||
IConsoleCmdRegister("resettile", ConResetTile);
|
IConsoleCmdRegister("resettile", ConResetTile);
|
||||||
IConsoleAliasRegister("dbg_echo","echo %A; echo %B");
|
IConsoleAliasRegister("dbg_echo","echo %A; echo %B");
|
||||||
IConsoleAliasRegister("dbg_echo2","echo %+");
|
IConsoleAliasRegister("dbg_echo2","echo %+");
|
||||||
|
@ -1140,13 +1183,25 @@ void IConsoleStdLibRegister(void)
|
||||||
IConsoleCmdRegister("alias", ConAlias);
|
IConsoleCmdRegister("alias", ConAlias);
|
||||||
IConsoleCmdRegister("load", ConLoad);
|
IConsoleCmdRegister("load", ConLoad);
|
||||||
IConsoleCmdRegister("list_files", ConListFiles);
|
IConsoleCmdRegister("list_files", ConListFiles);
|
||||||
|
IConsoleCmdRegister("scan_files", ConScanFiles);
|
||||||
IConsoleCmdRegister("goto_dir", ConGotoDir);
|
IConsoleCmdRegister("goto_dir", ConGotoDir);
|
||||||
IConsoleAliasRegister("new_game", "newgame");
|
IConsoleAliasRegister("new_game", "newgame");
|
||||||
IConsoleAliasRegister("newmap", "newgame");
|
IConsoleAliasRegister("newmap", "newgame");
|
||||||
IConsoleAliasRegister("new_map", "newgame");
|
IConsoleAliasRegister("new_map", "newgame");
|
||||||
|
IConsoleAliasRegister("load_game", "temp_string << scan_files %!;load temp_string");
|
||||||
|
|
||||||
IConsoleVarRegister("developer", &_stdlib_developer, ICONSOLE_VAR_BYTE);
|
IConsoleVarRegister("developer", &_stdlib_developer, ICONSOLE_VAR_BYTE);
|
||||||
|
|
||||||
|
// temporary data containers for alias scripting
|
||||||
|
IConsoleVarMemRegister("temp_string", ICONSOLE_VAR_STRING);
|
||||||
|
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_uint32", ICONSOLE_VAR_UINT32);
|
||||||
|
|
||||||
|
|
||||||
// networking variables and functions
|
// networking variables and functions
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
IConsoleCmdRegister("say", ConSay);
|
IConsoleCmdRegister("say", ConSay);
|
||||||
|
|
Loading…
Reference in New Issue