diff --git a/config-file.cpp b/config-file.cpp index c753f8dadd4..d7e77bcb8bd 100644 --- a/config-file.cpp +++ b/config-file.cpp @@ -155,7 +155,7 @@ void hashconfig::merge(const hashconfig * h) // The config-class itself. Config::Config(const char *cfg, const char *d) - : filename(Scumm::Strdup(cfg)), domain(d ? Scumm::Strdup(d) : 0), hash(0), ndomains(0) + : filename(Scumm::Strdup(cfg)), domain(d ? Scumm::Strdup(d) : 0), hash(0), ndomains(0), willwrite(false) { FILE *cfg_file; char t[MAXLINELEN]; @@ -302,6 +302,9 @@ void Config::flush() const { FILE *cfg_file; int i; + + if (!willwrite) + return; if (!(cfg_file = fopen(filename, "w"))) { debug(1, "Unable to write configuration file: %s.\n", filename); @@ -377,3 +380,7 @@ void Config::merge_config(const Config * c) } } } + +void Config::set_writing(bool w) { + willwrite = w; +} diff --git a/config-file.h b/config-file.h index 922724cce41..2e2f20477b6 100644 --- a/config-file.h +++ b/config-file.h @@ -38,10 +38,12 @@ class Config { void delete_domain(const char *); void change_filename(const char *); void merge_config(const Config *); + void set_writing(bool); private: char * filename, * domain; hashconfig ** hash; int ndomains; + bool willwrite; }; // The global config object diff --git a/gameDetector.cpp b/gameDetector.cpp index 3b7651720a7..bad009effb7 100644 --- a/gameDetector.cpp +++ b/gameDetector.cpp @@ -230,6 +230,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) exit(1); case 'w': _saveconfig = true; + scummcfg->set_writing(true); HANDLE_OPT_OPTION(); if (option != NULL) scummcfg->change_filename(option); @@ -258,7 +259,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) } } - if (_saveconfig) + if (_exe_name) scummcfg->flush(); return;