mirror of https://github.com/ZDoom/gzdoom-gles.git
- 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:
parent
df6f494329
commit
ca2cfb803f
|
@ -54,6 +54,7 @@ FConfigFile::FConfigFile ()
|
||||||
CurrentEntry = NULL;
|
CurrentEntry = NULL;
|
||||||
PathName = "";
|
PathName = "";
|
||||||
OkayToWrite = true;
|
OkayToWrite = true;
|
||||||
|
FileExisted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
@ -72,6 +73,7 @@ FConfigFile::FConfigFile (const char *pathname,
|
||||||
ChangePathName (pathname);
|
ChangePathName (pathname);
|
||||||
LoadConfigFile (nosechandler, userdata);
|
LoadConfigFile (nosechandler, userdata);
|
||||||
OkayToWrite = true;
|
OkayToWrite = true;
|
||||||
|
FileExisted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
@ -88,6 +90,7 @@ FConfigFile::FConfigFile (const FConfigFile &other)
|
||||||
ChangePathName (other.PathName);
|
ChangePathName (other.PathName);
|
||||||
*this = other;
|
*this = other;
|
||||||
OkayToWrite = other.OkayToWrite;
|
OkayToWrite = other.OkayToWrite;
|
||||||
|
FileExisted = other.FileExisted;
|
||||||
}
|
}
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
@ -590,11 +593,15 @@ void FConfigFile::LoadConfigFile (void (*nosechandler)(const char *pathname, FCo
|
||||||
FILE *file = fopen (PathName, "r");
|
FILE *file = fopen (PathName, "r");
|
||||||
bool succ;
|
bool succ;
|
||||||
|
|
||||||
|
FileExisted = false;
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
succ = ReadConfig (file);
|
succ = ReadConfig (file);
|
||||||
fclose (file);
|
fclose (file);
|
||||||
|
FileExisted = succ;
|
||||||
|
|
||||||
if (!succ)
|
if (!succ)
|
||||||
{ // First valid line did not define a section
|
{ // 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
|
bool FConfigFile::WriteConfigFile () const
|
||||||
{
|
{
|
||||||
if (!OkayToWrite)
|
if (!OkayToWrite && FileExisted)
|
||||||
{ // Pretend it was written anyway so that the user doesn't get
|
{ // 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ protected:
|
||||||
bool ReadConfig (void *file);
|
bool ReadConfig (void *file);
|
||||||
|
|
||||||
bool OkayToWrite;
|
bool OkayToWrite;
|
||||||
|
bool FileExisted;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct FConfigEntry
|
struct FConfigEntry
|
||||||
|
|
|
@ -326,7 +326,7 @@ int FIWadManager::CheckIWAD (const char *doomwaddir, WadStuff *wads)
|
||||||
int numfound;
|
int numfound;
|
||||||
|
|
||||||
numfound = 0;
|
numfound = 0;
|
||||||
|
return 0;
|
||||||
slash = (doomwaddir[0] && doomwaddir[strlen (doomwaddir)-1] != '/') ? "/" : "";
|
slash = (doomwaddir[0] && doomwaddir[strlen (doomwaddir)-1] != '/') ? "/" : "";
|
||||||
|
|
||||||
// Search for a pre-defined IWAD
|
// Search for a pre-defined IWAD
|
||||||
|
|
Loading…
Reference in New Issue