diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index e09baa26d..7574347bc 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -387,7 +387,6 @@ int FIWadManager::IdentifyVersion (TArray &wadfiles, const char *iwad, bool iwadparmfound = false; FString custwad; - ParseIWadInfos(zdoom_wad); wads.Resize(mIWadNames.Size()); foundwads.Resize(mIWads.Size()); memset(&foundwads[0], 0, foundwads.Size() * sizeof(foundwads[0])); diff --git a/src/d_main.cpp b/src/d_main.cpp index 78d12e651..5f4f09d4d 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1978,10 +1978,6 @@ static void D_DoomInit() } FRandom::StaticClearRandom (); - - Printf ("M_LoadDefaults: Load system defaults.\n"); - M_LoadDefaults (); // load before initing other systems - } //========================================================================== @@ -2203,7 +2199,8 @@ void D_DoomMain (void) DArgs *execFiles; TArray pwads; FString *args; - int argcount; + int argcount; + FIWadManager *iwad_man; // +logfile gets checked too late to catch the full startup log in the logfile so do some extra check for it here. FString logfile = Args->TakeValue("+logfile"); @@ -2233,8 +2230,6 @@ void D_DoomMain (void) } D_DoomInit(); - PClass::StaticInit (); - atterm(FinalGC); // [RH] Make sure zdoom.pk3 is always loaded, // as it contains magic stuff we need. @@ -2246,6 +2241,14 @@ void D_DoomMain (void) } FString basewad = wad; + iwad_man = new FIWadManager; + iwad_man->ParseIWadInfos(basewad); + + Printf ("M_LoadDefaults: Load system defaults.\n"); + M_LoadDefaults (iwad_man); // load before initing other systems + + PClass::StaticInit (); + atterm(FinalGC); // reinit from here @@ -2267,7 +2270,11 @@ void D_DoomMain (void) // restart is initiated without a defined IWAD assume for now that it's not going to change. if (iwad.IsEmpty()) iwad = lastIWAD; - FIWadManager *iwad_man = new FIWadManager; + if (iwad_man == NULL) + { + iwad_man = new FIWadManager; + iwad_man->ParseIWadInfos(basewad); + } const FIWADInfo *iwad_info = iwad_man->FindIWAD(allwads, iwad, basewad); gameinfo.gametype = iwad_info->gametype; gameinfo.flags = iwad_info->flags; @@ -2486,6 +2493,7 @@ void D_DoomMain (void) FBaseCVar::EnableNoSet (); delete iwad_man; // now we won't need this anymore + iwad_man = NULL; // [RH] Run any saved commands from the command line or autoexec.cfg now. gamestate = GS_FULLCONSOLE; diff --git a/src/d_main.h b/src/d_main.h index e4641c41d..afca8bc3b 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -115,15 +115,13 @@ extern FStartupInfo DoomStartupInfo; // //========================================================================== -struct FIWadManager +class FIWadManager { -private: TArray mIWads; TArray mIWadNames; TArray mLumpsFound; void ParseIWadInfo(const char *fn, const char *data, int datasize); - void ParseIWadInfos(const char *fn); void ClearChecks(); void CheckLumpName(const char *name); int GetIWadInfo(); @@ -131,7 +129,19 @@ private: int CheckIWAD (const char *doomwaddir, WadStuff *wads); int IdentifyVersion (TArray &wadfiles, const char *iwad, const char *zdoom_wad); public: + void ParseIWadInfos(const char *fn); const FIWADInfo *FindIWAD(TArray &wadfiles, const char *iwad, const char *basewad); + const FString *GetAutoname(unsigned int num) const + { + if (num < mIWads.Size()) return &mIWads[num].Autoname; + else return NULL; + } + int GetIWadFlags(unsigned int num) const + { + if (num < mIWads.Size()) return mIWads[num].flags; + else return false; + } + }; diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index e17a3e127..112bcbe1b 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -61,6 +61,7 @@ extern HWND Window; #include "doomstat.h" #include "i_system.h" #include "gi.h" +#include "d_main.h" EXTERN_CVAR (Bool, con_centernotify) EXTERN_CVAR (Int, msg0color) @@ -75,7 +76,7 @@ EXTERN_CVAR (Color, am_cdwallcolor) EXTERN_CVAR (Float, spc_amp) EXTERN_CVAR (Bool, wi_percents) -FGameConfigFile::FGameConfigFile () +FGameConfigFile::FGameConfigFile (FIWadManager *iwad_man) { #ifdef __APPLE__ FString user_docs, user_app_support, local_app_support; @@ -163,30 +164,36 @@ FGameConfigFile::FGameConfigFile () // Create auto-load sections, so users know what's available. // Note that this totem pole is the reverse of the order that // they will appear in the file. -#if 0 - CreateSectionAtStart("Harmony.Autoload"); - CreateSectionAtStart("UrbanBrawl.Autoload"); - CreateSectionAtStart("Chex3.Autoload"); - CreateSectionAtStart("Chex1.Autoload"); - CreateSectionAtStart("Chex.Autoload"); - CreateSectionAtStart("Strife.Autoload"); - CreateSectionAtStart("HexenDK.Autoload"); - CreateSectionAtStart("Hexen.Autoload"); - CreateSectionAtStart("HereticSR.Autoload"); - CreateSectionAtStart("Heretic.Autoload"); - CreateSectionAtStart("FreeDM.Autoload"); - CreateSectionAtStart("Freedoom2.Autoload"); - CreateSectionAtStart("Freedoom1.Autoload"); - CreateSectionAtStart("Freedoom.Autoload"); - CreateSectionAtStart("Plutonia.Autoload"); - CreateSectionAtStart("TNT.Autoload"); - CreateSectionAtStart("Doom2BFG.Autoload"); - CreateSectionAtStart("Doom2.Autoload"); - CreateSectionAtStart("DoomBFG.Autoload"); - CreateSectionAtStart("DoomU.Autoload"); - CreateSectionAtStart("Doom1.Autoload"); - CreateSectionAtStart("Doom.Autoload"); -#endif + + double last = 0; + if (SetSection ("LastRun")) + { + const char *lastver = GetValueForKey ("Version"); + if (lastver != NULL) last = atof(lastver); + } + + // don't create the autoload section if we are about to migrate an old config because it'd mess up the upcoming migration step. + // This will be taken care of once the game runs again with the migrated config file. + if (last >= 211) + { + const FString *pAuto; + for (int num = 0; (pAuto = iwad_man->GetAutoname(num)) != NULL; num++) + { + if (!(iwad_man->GetIWadFlags(num) & GI_SHAREWARE)) // we do not want autoload sections for shareware IWADs (which may have an autoname for resource filtering) + { + FString workname = *pAuto; + + while (workname.IsNotEmpty()) + { + FString section = workname + ".Autoload"; + CreateSectionAtStart(section.GetChars()); + long dotpos = workname.LastIndexOf('.'); + if (dotpos < 0) break; + workname.Truncate(dotpos); + } + } + } + } CreateSectionAtStart("Global.Autoload"); // The same goes for auto-exec files. @@ -345,6 +352,7 @@ void FGameConfigFile::DoGlobalSetup () RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload"); RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload"); RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload"); + RenameSection("Freedoom.Autoload", "doom.freedoom.Autoload"); RenameSection("DoomBFG.Autoload", "doom.doom1.bfg.Autoload"); RenameSection("DoomU.Autoload", "doom.doom1.ultimate.Autoload"); RenameSection("Doom1.Autoload", "doom.doom1.registered.Autoload"); diff --git a/src/gameconfigfile.h b/src/gameconfigfile.h index 57956f7cd..5862bb79e 100644 --- a/src/gameconfigfile.h +++ b/src/gameconfigfile.h @@ -38,11 +38,12 @@ #include "configfile.h" class DArgs; +class FIWadManager; class FGameConfigFile : public FConfigFile { public: - FGameConfigFile (); + FGameConfigFile (FIWadManager *iwad_man); ~FGameConfigFile (); void DoGlobalSetup (); diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 7f4fa482d..1369bdb52 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -410,9 +410,9 @@ CCMD (writeini) // M_LoadDefaults // -void M_LoadDefaults () +void M_LoadDefaults (FIWadManager *iwad_man) { - GameConfig = new FGameConfigFile; + GameConfig = new FGameConfigFile(iwad_man); GameConfig->DoGlobalSetup (); atterm (M_SaveDefaultsFinal); } diff --git a/src/m_misc.h b/src/m_misc.h index 9599306de..ea146c690 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -28,6 +28,7 @@ class FConfigFile; class FGameConfigFile; +class FIWadManager; extern FGameConfigFile *GameConfig; @@ -40,7 +41,7 @@ void M_FindResponseFile (void); // Pass a NULL to get the original behavior. void M_ScreenShot (const char *filename); -void M_LoadDefaults (); +void M_LoadDefaults (FIWadManager *iwad_man); bool M_SaveDefaults (const char *filename); void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection, size_t sublen);