From 3114a26bc8aa7984b92db3da9ac311cd8e7b0567 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 6 Apr 2015 11:21:28 +0200 Subject: [PATCH] - allow renaming of config sections and added migration code to rename the old autoload sections to the more flexible naming system that's planned. --- src/configfile.cpp | 16 ++++++++++++++++ src/configfile.h | 1 + src/gameconfigfile.cpp | 20 ++++++++++++++++++++ src/version.h | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/configfile.cpp b/src/configfile.cpp index 9a1f7bd4dd..e64005fc46 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -513,6 +513,22 @@ FConfigFile::FConfigSection *FConfigFile::FindSection (const char *name) const return section; } +//==================================================================== +// +// FConfigFile :: RenameSection +// +//==================================================================== + +void FConfigFile::RenameSection (const char *oldname, const char *newname) const +{ + FConfigSection *section = FindSection(oldname); + + if (section != NULL) + { + section->SectionName = newname; + } +} + //==================================================================== // // FConfigFile :: FindEntry diff --git a/src/configfile.h b/src/configfile.h index 31943ccb66..e125351dcf 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -78,6 +78,7 @@ protected: virtual char *ReadLine (char *string, int n, void *file) const; bool ReadConfig (void *file); static const char *GenerateEndTag(const char *value); + void RenameSection(const char *oldname, const char *newname) const; bool OkayToWrite; bool FileExisted; diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index 7e0ddc6a19..9121e79d6b 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -334,6 +334,26 @@ void FGameConfigFile::DoGlobalSetup () SetValueForKey ("5", "use ArtiInvulnerability2"); } } + if (last < 211) + { + //RenameSection("Hacx2.Autoload", "hacx.2_0.Autoload"); + //RenameSection("Hacx12.Autoload", "hacx.1_2.Autoload"); + //RenameSection("Hexen1.Autoload", "hexen.hexen.Autoload"); + RenameSection("Chex3.Autoload", "chex.3.Autoload"); + RenameSection("Chex1.Autoload", "chex.1.Autoload"); + RenameSection("HexenDK.Autoload", "hexen.deathkings.Autoload"); + RenameSection("HereticSR.Autoload", "heretic.shadow.Autoload"); + RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload"); + RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload"); + RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload"); + RenameSection("DoomBFG.Autoload", "doom.doom1.bfg.Autoload"); + RenameSection("DoomU.Autoload", "doom.doom1.ultimate.Autoload"); + RenameSection("Doom1.Autoload", "doom.doom1.registered.Autoload"); + RenameSection("TNT.Autoload", "doom.doom2.tnt.Autoload"); + RenameSection("Plutonia.Autoload", "doom.doom2.plutonia.Autoload"); + RenameSection("Doom2BFG.Autoload", "doom.doom2.bfg.Autoload"); + RenameSection("Doom2.Autoload", "doom.doom2.commercial.Autoload"); + } } } } diff --git a/src/version.h b/src/version.h index cbbb8bd214..f45f58b2fc 100644 --- a/src/version.h +++ b/src/version.h @@ -56,7 +56,7 @@ const char *GetVersionString(); // Version stored in the ini's [LastRun] section. // Bump it if you made some configuration change that you want to // be able to migrate in FGameConfigFile::DoGlobalSetup(). -#define LASTRUNVERSION "210" +#define LASTRUNVERSION "211" // Protocol version used in demos. // Bump it if you change existing DEM_ commands or add new ones.