1
0
Fork 0

(svn r7801) -Feature: add command line option to prevent saving of highscore and configuration on exit and a console command to manually initiate a configuration save (Aloysha).

release/0.6
rubidium 2007-01-03 18:06:50 +00:00
parent dd048e8c31
commit 2676142ca9
2 changed files with 23 additions and 3 deletions

View File

@ -201,6 +201,19 @@ DEF_CONSOLE_CMD(ConSave)
return false; return false;
} }
/* Explicitly save the configuration */
DEF_CONSOLE_CMD(ConSaveConfig)
{
if (argc == 0) {
IConsoleHelp("Saves the current config, typically to 'openttd.cfg'.");
return true;
}
SaveToConfig();
IConsolePrint(_icolour_def, "Saved config.");
return true;
}
static const FiosItem* GetFiosItem(const char* file) static const FiosItem* GetFiosItem(const char* file)
{ {
int i; int i;
@ -1475,6 +1488,7 @@ void IConsoleStdLibRegister(void)
IConsoleCmdRegister("load", ConLoad); IConsoleCmdRegister("load", ConLoad);
IConsoleCmdRegister("rm", ConRemove); IConsoleCmdRegister("rm", ConRemove);
IConsoleCmdRegister("save", ConSave); IConsoleCmdRegister("save", ConSave);
IConsoleCmdRegister("saveconfig", ConSaveConfig);
IConsoleCmdRegister("ls", ConListFiles); IConsoleCmdRegister("ls", ConListFiles);
IConsoleCmdRegister("cd", ConChangeDirectory); IConsoleCmdRegister("cd", ConChangeDirectory);
IConsoleCmdRegister("pwd", ConPrintWorkingDirectory); IConsoleCmdRegister("pwd", ConPrintWorkingDirectory);

View File

@ -165,6 +165,7 @@ static void showhelp(void)
" -i = Force to use the DOS palette\n" " -i = Force to use the DOS palette\n"
" (use this if you see a lot of pink)\n" " (use this if you see a lot of pink)\n"
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n" " -c config_file = Use 'config_file' instead of 'openttd.cfg'\n"
" -x = Do not automatically save to config file on exit\n"
"\n", "\n",
lastof(buf) lastof(buf)
); );
@ -333,6 +334,7 @@ int ttd_main(int argc, char *argv[])
uint generation_seed = GENERATE_NEW_SEED; uint generation_seed = GENERATE_NEW_SEED;
bool dedicated = false; bool dedicated = false;
bool network = false; bool network = false;
bool save_config = true;
char *network_conn = NULL; char *network_conn = NULL;
musicdriver[0] = sounddriver[0] = videodriver[0] = 0; musicdriver[0] = sounddriver[0] = videodriver[0] = 0;
@ -347,7 +349,7 @@ int ttd_main(int argc, char *argv[])
// a letter means: it accepts that param (e.g.: -h) // a letter means: it accepts that param (e.g.: -h)
// a ':' behind it means: it need a param (e.g.: -m<driver>) // a ':' behind it means: it need a param (e.g.: -m<driver>)
// a '::' behind it means: it can optional have a param (e.g.: -d<debug>) // a '::' behind it means: it can optional have a param (e.g.: -d<debug>)
optformat = "m:s:v:hDn::eit:d::r:g::G:c:" optformat = "m:s:v:hDn::eit:d::r:g::G:c:x"
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32) #if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
"f" "f"
#endif #endif
@ -390,6 +392,7 @@ int ttd_main(int argc, char *argv[])
break; break;
case 'G': generation_seed = atoi(mgo.opt); break; case 'G': generation_seed = atoi(mgo.opt); break;
case 'c': _config_file = strdup(mgo.opt); break; case 'c': _config_file = strdup(mgo.opt); break;
case 'x': save_config = false; break;
case -2: case -2:
case 'h': case 'h':
showhelp(); showhelp();
@ -523,8 +526,11 @@ int ttd_main(int argc, char *argv[])
_music_driver->stop(); _music_driver->stop();
_sound_driver->stop(); _sound_driver->stop();
SaveToConfig(); /* only save config if we have to */
SaveToHighScore(); if (save_config) {
SaveToConfig();
SaveToHighScore();
}
// uninitialize airport state machines // uninitialize airport state machines
UnInitializeAirports(); UnInitializeAirports();