From ca2cfb803f9742203cf1cbc65596c065f0d163b5 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 6 Jul 2012 02:22:58 +0000 Subject: [PATCH] - Do do not disable config writing before DoGameSetup() (introduced in r3653) if the config file does not already exist. This way, we can create a default config file without removing anything from an existing config file if things go wrong early during setup. SVN r3737 (trunk) --- src/configfile.cpp | 12 ++++++++++-- src/configfile.h | 1 + src/d_iwad.cpp | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/configfile.cpp b/src/configfile.cpp index b379bcf2a..fcbed42c3 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -54,6 +54,7 @@ FConfigFile::FConfigFile () CurrentEntry = NULL; PathName = ""; OkayToWrite = true; + FileExisted = true; } //==================================================================== @@ -72,6 +73,7 @@ FConfigFile::FConfigFile (const char *pathname, ChangePathName (pathname); LoadConfigFile (nosechandler, userdata); OkayToWrite = true; + FileExisted = true; } //==================================================================== @@ -88,6 +90,7 @@ FConfigFile::FConfigFile (const FConfigFile &other) ChangePathName (other.PathName); *this = other; OkayToWrite = other.OkayToWrite; + FileExisted = other.FileExisted; } //==================================================================== @@ -590,11 +593,15 @@ void FConfigFile::LoadConfigFile (void (*nosechandler)(const char *pathname, FCo FILE *file = fopen (PathName, "r"); bool succ; + FileExisted = false; if (file == NULL) + { return; + } succ = ReadConfig (file); fclose (file); + FileExisted = succ; if (!succ) { // First valid line did not define a section @@ -698,9 +705,10 @@ char *FConfigFile::ReadLine (char *string, int n, void *file) const bool FConfigFile::WriteConfigFile () const { - if (!OkayToWrite) + if (!OkayToWrite && FileExisted) { // Pretend it was written anyway so that the user doesn't get - // any "config not written" notifications. + // any "config not written" notifications, but only if the file + // already existed. Otherwise, let it write out a default one. return true; } diff --git a/src/configfile.h b/src/configfile.h index 173d6fede..b704dd359 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -80,6 +80,7 @@ protected: bool ReadConfig (void *file); bool OkayToWrite; + bool FileExisted; private: struct FConfigEntry diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 0bad0c3ed..be4e5873e 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -326,7 +326,7 @@ int FIWadManager::CheckIWAD (const char *doomwaddir, WadStuff *wads) int numfound; numfound = 0; - +return 0; slash = (doomwaddir[0] && doomwaddir[strlen (doomwaddir)-1] != '/') ? "/" : ""; // Search for a pre-defined IWAD