From b300cfaf62e60aef1b48548c406f46bbb4edaecd Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 5 Apr 2015 21:56:00 -0500 Subject: [PATCH] Remove old pre-INI config migration code - As if any of this matters now. It's not the 90s anymore. --- src/configfile.cpp | 16 ++-------- src/configfile.h | 5 ++- src/gameconfigfile.cpp | 69 +++++++----------------------------------- src/gameconfigfile.h | 4 --- 4 files changed, 16 insertions(+), 78 deletions(-) diff --git a/src/configfile.cpp b/src/configfile.cpp index 177c019fb5..8792175f47 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -66,15 +66,13 @@ FConfigFile::FConfigFile () // //==================================================================== -FConfigFile::FConfigFile (const char *pathname, - void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata), - void *userdata) +FConfigFile::FConfigFile (const char *pathname) { Sections = CurrentSection = NULL; LastSectionPtr = &Sections; CurrentEntry = NULL; ChangePathName (pathname); - LoadConfigFile (nosechandler, userdata); + LoadConfigFile (); OkayToWrite = 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"); bool succ; @@ -605,14 +603,6 @@ void FConfigFile::LoadConfigFile (void (*nosechandler)(const char *pathname, FCo succ = ReadConfig (file); fclose (file); FileExisted = succ; - - if (!succ) - { // First valid line did not define a section - if (nosechandler != NULL) - { - nosechandler (PathName, this, userdata); - } - } } //==================================================================== diff --git a/src/configfile.h b/src/configfile.h index 25c366f010..34ab9d56b4 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -41,8 +41,7 @@ class FConfigFile { public: FConfigFile (); - FConfigFile (const char *pathname, - void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata)=0, void *userdata=NULL); + FConfigFile (const char *pathname); FConfigFile (const FConfigFile &other); virtual ~FConfigFile (); @@ -70,7 +69,7 @@ public: const char *GetPathName () const { return PathName.GetChars(); } void ChangePathName (const char *path); - void LoadConfigFile (void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata), void *userdata); + void LoadConfigFile (); bool WriteConfigFile () const; protected: diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 6cfd6456be..7e0ddc6a19 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -83,16 +83,10 @@ FGameConfigFile::FGameConfigFile () FString pathname; OkayToWrite = false; // Do not allow saving of the config before DoGameSetup() - bMigrating = false; bModSetup = false; pathname = GetConfigPath (true); ChangePathName (pathname); - LoadConfigFile (MigrateStub, NULL); - - if (!HaveSections ()) - { // Config file not found; try the old one - MigrateOldConfig (); - } + LoadConfigFile (); // If zdoom.ini was read from the program directory, switch // 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()); } -void FGameConfigFile::MigrateStub (const char *pathname, FConfigFile *config, void *userdata) -{ - static_cast(config)->bMigrating = true; -} - -void FGameConfigFile::MigrateOldConfig () -{ -} - void FGameConfigFile::DoGlobalSetup () { if (SetSection ("GlobalSettings.Unknown")) @@ -358,10 +343,6 @@ void FGameConfigFile::DoGameSetup (const char *gamename) const char *key; const char *value; - if (bMigrating) - { - MigrateOldConfig (); - } sublen = countof(section) - 1 - mysnprintf (section, countof(section), "%s.", gamename); subsection = section + countof(section) - sublen - 1; section[countof(section) - 1] = '\0'; @@ -622,41 +603,20 @@ void FGameConfigFile::AddAutoexec (DArgs *list, const char *game) mysnprintf (section, countof(section), "%s.AutoExec", game); - if (bMigrating) + // If .AutoExec section does not exist, create it + // with a default autoexec.cfg file present. + CreateStandardAutoExec(section, false); + // Run any files listed in the .AutoExec section + if (!SectionIsEmpty()) { - FBaseCVar *autoexec = FindCVar ("autoexec", NULL); - - if (autoexec != NULL) + while (NextInSection (key, value)) { - UCVarValue val; - 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 .AutoExec section does not exist, create it - // with a default autoexec.cfg file present. - CreateStandardAutoExec(section, false); - // Run any files listed in the .AutoExec section - if (!SectionIsEmpty()) - { - while (NextInSection (key, value)) + if (stricmp (key, "Path") == 0 && *value != '\0') { - if (stricmp (key, "Path") == 0 && *value != '\0') + FString expanded_path = ExpandEnvVars(value); + if (FileExists(expanded_path)) { - FString expanded_path = ExpandEnvVars(value); - if (FileExists(expanded_path)) - { - list->AppendArg (ExpandEnvVars(value)); - } + list->AppendArg (ExpandEnvVars(value)); } } } @@ -667,13 +627,6 @@ void FGameConfigFile::SetRavenDefaults (bool isHexen) { UCVarValue val; - if (bMigrating) - { - con_centernotify.ResetToDefault (); - msg0color.ResetToDefault (); - color.ResetToDefault (); - } - val.Bool = false; wi_percents.SetGenericRepDefault (val, CVAR_Bool); val.Bool = true; diff --git a/src/gameconfigfile.h b/src/gameconfigfile.h index 55867eaf8b..57956f7cdd 100644 --- a/src/gameconfigfile.h +++ b/src/gameconfigfile.h @@ -60,13 +60,9 @@ protected: void CreateStandardAutoExec (const char *section, bool start); private: - static void MigrateStub (const char *pathname, FConfigFile *config, void *userdata); - - void MigrateOldConfig (); void SetRavenDefaults (bool isHexen); void ReadCVars (DWORD flags); - bool bMigrating; bool bModSetup; char section[64];