mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
Remove old pre-INI config migration code
- As if any of this matters now. It's not the 90s anymore.
This commit is contained in:
parent
c36222d2ef
commit
b300cfaf62
4 changed files with 16 additions and 78 deletions
|
@ -66,15 +66,13 @@ FConfigFile::FConfigFile ()
|
||||||
//
|
//
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
|
||||||
FConfigFile::FConfigFile (const char *pathname,
|
FConfigFile::FConfigFile (const char *pathname)
|
||||||
void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata),
|
|
||||||
void *userdata)
|
|
||||||
{
|
{
|
||||||
Sections = CurrentSection = NULL;
|
Sections = CurrentSection = NULL;
|
||||||
LastSectionPtr = &Sections;
|
LastSectionPtr = &Sections;
|
||||||
CurrentEntry = NULL;
|
CurrentEntry = NULL;
|
||||||
ChangePathName (pathname);
|
ChangePathName (pathname);
|
||||||
LoadConfigFile (nosechandler, userdata);
|
LoadConfigFile ();
|
||||||
OkayToWrite = true;
|
OkayToWrite = true;
|
||||||
FileExisted = true;
|
FileExisted = true;
|
||||||
}
|
}
|
||||||
|
@ -591,7 +589,7 @@ FConfigFile::FConfigEntry *FConfigFile::NewConfigEntry (
|
||||||
//
|
//
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
|
||||||
void FConfigFile::LoadConfigFile (void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata), void *userdata)
|
void FConfigFile::LoadConfigFile ()
|
||||||
{
|
{
|
||||||
FILE *file = fopen (PathName, "r");
|
FILE *file = fopen (PathName, "r");
|
||||||
bool succ;
|
bool succ;
|
||||||
|
@ -605,14 +603,6 @@ void FConfigFile::LoadConfigFile (void (*nosechandler)(const char *pathname, FCo
|
||||||
succ = ReadConfig (file);
|
succ = ReadConfig (file);
|
||||||
fclose (file);
|
fclose (file);
|
||||||
FileExisted = succ;
|
FileExisted = succ;
|
||||||
|
|
||||||
if (!succ)
|
|
||||||
{ // First valid line did not define a section
|
|
||||||
if (nosechandler != NULL)
|
|
||||||
{
|
|
||||||
nosechandler (PathName, this, userdata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
|
|
@ -41,8 +41,7 @@ class FConfigFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FConfigFile ();
|
FConfigFile ();
|
||||||
FConfigFile (const char *pathname,
|
FConfigFile (const char *pathname);
|
||||||
void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata)=0, void *userdata=NULL);
|
|
||||||
FConfigFile (const FConfigFile &other);
|
FConfigFile (const FConfigFile &other);
|
||||||
virtual ~FConfigFile ();
|
virtual ~FConfigFile ();
|
||||||
|
|
||||||
|
@ -70,7 +69,7 @@ public:
|
||||||
const char *GetPathName () const { return PathName.GetChars(); }
|
const char *GetPathName () const { return PathName.GetChars(); }
|
||||||
void ChangePathName (const char *path);
|
void ChangePathName (const char *path);
|
||||||
|
|
||||||
void LoadConfigFile (void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata), void *userdata);
|
void LoadConfigFile ();
|
||||||
bool WriteConfigFile () const;
|
bool WriteConfigFile () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -83,16 +83,10 @@ FGameConfigFile::FGameConfigFile ()
|
||||||
FString pathname;
|
FString pathname;
|
||||||
|
|
||||||
OkayToWrite = false; // Do not allow saving of the config before DoGameSetup()
|
OkayToWrite = false; // Do not allow saving of the config before DoGameSetup()
|
||||||
bMigrating = false;
|
|
||||||
bModSetup = false;
|
bModSetup = false;
|
||||||
pathname = GetConfigPath (true);
|
pathname = GetConfigPath (true);
|
||||||
ChangePathName (pathname);
|
ChangePathName (pathname);
|
||||||
LoadConfigFile (MigrateStub, NULL);
|
LoadConfigFile ();
|
||||||
|
|
||||||
if (!HaveSections ())
|
|
||||||
{ // Config file not found; try the old one
|
|
||||||
MigrateOldConfig ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If zdoom.ini was read from the program directory, switch
|
// If zdoom.ini was read from the program directory, switch
|
||||||
// to the user directory now. If it was read from the user
|
// to the user directory now. If it was read from the user
|
||||||
|
@ -237,15 +231,6 @@ void FGameConfigFile::WriteCommentHeader (FILE *file) const
|
||||||
fprintf (file, "# This file was generated by " GAMENAME " %s on %s\n", GetVersionString(), myasctime());
|
fprintf (file, "# This file was generated by " GAMENAME " %s on %s\n", GetVersionString(), myasctime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGameConfigFile::MigrateStub (const char *pathname, FConfigFile *config, void *userdata)
|
|
||||||
{
|
|
||||||
static_cast<FGameConfigFile *>(config)->bMigrating = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FGameConfigFile::MigrateOldConfig ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FGameConfigFile::DoGlobalSetup ()
|
void FGameConfigFile::DoGlobalSetup ()
|
||||||
{
|
{
|
||||||
if (SetSection ("GlobalSettings.Unknown"))
|
if (SetSection ("GlobalSettings.Unknown"))
|
||||||
|
@ -358,10 +343,6 @@ void FGameConfigFile::DoGameSetup (const char *gamename)
|
||||||
const char *key;
|
const char *key;
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
if (bMigrating)
|
|
||||||
{
|
|
||||||
MigrateOldConfig ();
|
|
||||||
}
|
|
||||||
sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename);
|
sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename);
|
||||||
subsection = section + countof(section) - sublen - 1;
|
subsection = section + countof(section) - sublen - 1;
|
||||||
section[countof(section) - 1] = '\0';
|
section[countof(section) - 1] = '\0';
|
||||||
|
@ -622,41 +603,20 @@ void FGameConfigFile::AddAutoexec (DArgs *list, const char *game)
|
||||||
|
|
||||||
mysnprintf (section, countof(section), "%s.AutoExec", game);
|
mysnprintf (section, countof(section), "%s.AutoExec", game);
|
||||||
|
|
||||||
if (bMigrating)
|
// If <game>.AutoExec section does not exist, create it
|
||||||
|
// with a default autoexec.cfg file present.
|
||||||
|
CreateStandardAutoExec(section, false);
|
||||||
|
// Run any files listed in the <game>.AutoExec section
|
||||||
|
if (!SectionIsEmpty())
|
||||||
{
|
{
|
||||||
FBaseCVar *autoexec = FindCVar ("autoexec", NULL);
|
while (NextInSection (key, value))
|
||||||
|
|
||||||
if (autoexec != NULL)
|
|
||||||
{
|
{
|
||||||
UCVarValue val;
|
if (stricmp (key, "Path") == 0 && *value != '\0')
|
||||||
char *path;
|
|
||||||
|
|
||||||
val = autoexec->GetGenericRep (CVAR_String);
|
|
||||||
path = copystring (val.String);
|
|
||||||
delete autoexec;
|
|
||||||
SetSection (section, true);
|
|
||||||
SetValueForKey ("Path", path);
|
|
||||||
list->AppendArg (path);
|
|
||||||
delete[] path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If <game>.AutoExec section does not exist, create it
|
|
||||||
// with a default autoexec.cfg file present.
|
|
||||||
CreateStandardAutoExec(section, false);
|
|
||||||
// Run any files listed in the <game>.AutoExec section
|
|
||||||
if (!SectionIsEmpty())
|
|
||||||
{
|
|
||||||
while (NextInSection (key, value))
|
|
||||||
{
|
{
|
||||||
if (stricmp (key, "Path") == 0 && *value != '\0')
|
FString expanded_path = ExpandEnvVars(value);
|
||||||
|
if (FileExists(expanded_path))
|
||||||
{
|
{
|
||||||
FString expanded_path = ExpandEnvVars(value);
|
list->AppendArg (ExpandEnvVars(value));
|
||||||
if (FileExists(expanded_path))
|
|
||||||
{
|
|
||||||
list->AppendArg (ExpandEnvVars(value));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -667,13 +627,6 @@ void FGameConfigFile::SetRavenDefaults (bool isHexen)
|
||||||
{
|
{
|
||||||
UCVarValue val;
|
UCVarValue val;
|
||||||
|
|
||||||
if (bMigrating)
|
|
||||||
{
|
|
||||||
con_centernotify.ResetToDefault ();
|
|
||||||
msg0color.ResetToDefault ();
|
|
||||||
color.ResetToDefault ();
|
|
||||||
}
|
|
||||||
|
|
||||||
val.Bool = false;
|
val.Bool = false;
|
||||||
wi_percents.SetGenericRepDefault (val, CVAR_Bool);
|
wi_percents.SetGenericRepDefault (val, CVAR_Bool);
|
||||||
val.Bool = true;
|
val.Bool = true;
|
||||||
|
|
|
@ -60,13 +60,9 @@ protected:
|
||||||
void CreateStandardAutoExec (const char *section, bool start);
|
void CreateStandardAutoExec (const char *section, bool start);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void MigrateStub (const char *pathname, FConfigFile *config, void *userdata);
|
|
||||||
|
|
||||||
void MigrateOldConfig ();
|
|
||||||
void SetRavenDefaults (bool isHexen);
|
void SetRavenDefaults (bool isHexen);
|
||||||
void ReadCVars (DWORD flags);
|
void ReadCVars (DWORD flags);
|
||||||
|
|
||||||
bool bMigrating;
|
|
||||||
bool bModSetup;
|
bool bModSetup;
|
||||||
|
|
||||||
char section[64];
|
char section[64];
|
||||||
|
|
Loading…
Reference in a new issue