- 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)
This commit is contained in:
Randy Heit 2012-07-06 02:22:58 +00:00
parent df6f494329
commit ca2cfb803f
3 changed files with 12 additions and 3 deletions

View File

@ -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;
}

View File

@ -80,6 +80,7 @@ protected:
bool ReadConfig (void *file);
bool OkayToWrite;
bool FileExisted;
private:
struct FConfigEntry

View File

@ -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