- automatically create autoload section based on IWADINFO.

This has an important implication:
Previously the config was loaded before IWADINFO so in order to allow the config to access the data this had to be switched around.
This means that zdoom.pk3 will not be looked for in the global IWAD search paths anymore, but since it shouldn't be there to begin with it should be an acceptable compromise.
This commit is contained in:
Christoph Oelckers 2015-04-06 13:52:08 +02:00
parent 258822ef3b
commit dfda74ffe3
7 changed files with 68 additions and 41 deletions

View file

@ -387,7 +387,6 @@ int FIWadManager::IdentifyVersion (TArray<FString> &wadfiles, const char *iwad,
bool iwadparmfound = false; bool iwadparmfound = false;
FString custwad; FString custwad;
ParseIWadInfos(zdoom_wad);
wads.Resize(mIWadNames.Size()); wads.Resize(mIWadNames.Size());
foundwads.Resize(mIWads.Size()); foundwads.Resize(mIWads.Size());
memset(&foundwads[0], 0, foundwads.Size() * sizeof(foundwads[0])); memset(&foundwads[0], 0, foundwads.Size() * sizeof(foundwads[0]));

View file

@ -1978,10 +1978,6 @@ static void D_DoomInit()
} }
FRandom::StaticClearRandom (); FRandom::StaticClearRandom ();
Printf ("M_LoadDefaults: Load system defaults.\n");
M_LoadDefaults (); // load before initing other systems
} }
//========================================================================== //==========================================================================
@ -2204,6 +2200,7 @@ void D_DoomMain (void)
TArray<FString> pwads; TArray<FString> pwads;
FString *args; 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. // +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"); FString logfile = Args->TakeValue("+logfile");
@ -2233,8 +2230,6 @@ void D_DoomMain (void)
} }
D_DoomInit(); D_DoomInit();
PClass::StaticInit ();
atterm(FinalGC);
// [RH] Make sure zdoom.pk3 is always loaded, // [RH] Make sure zdoom.pk3 is always loaded,
// as it contains magic stuff we need. // as it contains magic stuff we need.
@ -2246,6 +2241,14 @@ void D_DoomMain (void)
} }
FString basewad = wad; 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 // 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. // restart is initiated without a defined IWAD assume for now that it's not going to change.
if (iwad.IsEmpty()) iwad = lastIWAD; 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); const FIWADInfo *iwad_info = iwad_man->FindIWAD(allwads, iwad, basewad);
gameinfo.gametype = iwad_info->gametype; gameinfo.gametype = iwad_info->gametype;
gameinfo.flags = iwad_info->flags; gameinfo.flags = iwad_info->flags;
@ -2486,6 +2493,7 @@ void D_DoomMain (void)
FBaseCVar::EnableNoSet (); FBaseCVar::EnableNoSet ();
delete iwad_man; // now we won't need this anymore 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. // [RH] Run any saved commands from the command line or autoexec.cfg now.
gamestate = GS_FULLCONSOLE; gamestate = GS_FULLCONSOLE;

View file

@ -115,15 +115,13 @@ extern FStartupInfo DoomStartupInfo;
// //
//========================================================================== //==========================================================================
struct FIWadManager class FIWadManager
{ {
private:
TArray<FIWADInfo> mIWads; TArray<FIWADInfo> mIWads;
TArray<FString> mIWadNames; TArray<FString> mIWadNames;
TArray<int> mLumpsFound; TArray<int> mLumpsFound;
void ParseIWadInfo(const char *fn, const char *data, int datasize); void ParseIWadInfo(const char *fn, const char *data, int datasize);
void ParseIWadInfos(const char *fn);
void ClearChecks(); void ClearChecks();
void CheckLumpName(const char *name); void CheckLumpName(const char *name);
int GetIWadInfo(); int GetIWadInfo();
@ -131,7 +129,19 @@ private:
int CheckIWAD (const char *doomwaddir, WadStuff *wads); int CheckIWAD (const char *doomwaddir, WadStuff *wads);
int IdentifyVersion (TArray<FString> &wadfiles, const char *iwad, const char *zdoom_wad); int IdentifyVersion (TArray<FString> &wadfiles, const char *iwad, const char *zdoom_wad);
public: public:
void ParseIWadInfos(const char *fn);
const FIWADInfo *FindIWAD(TArray<FString> &wadfiles, const char *iwad, const char *basewad); const FIWADInfo *FindIWAD(TArray<FString> &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;
}
}; };

View file

@ -61,6 +61,7 @@ extern HWND Window;
#include "doomstat.h" #include "doomstat.h"
#include "i_system.h" #include "i_system.h"
#include "gi.h" #include "gi.h"
#include "d_main.h"
EXTERN_CVAR (Bool, con_centernotify) EXTERN_CVAR (Bool, con_centernotify)
EXTERN_CVAR (Int, msg0color) EXTERN_CVAR (Int, msg0color)
@ -75,7 +76,7 @@ EXTERN_CVAR (Color, am_cdwallcolor)
EXTERN_CVAR (Float, spc_amp) EXTERN_CVAR (Float, spc_amp)
EXTERN_CVAR (Bool, wi_percents) EXTERN_CVAR (Bool, wi_percents)
FGameConfigFile::FGameConfigFile () FGameConfigFile::FGameConfigFile (FIWadManager *iwad_man)
{ {
#ifdef __APPLE__ #ifdef __APPLE__
FString user_docs, user_app_support, local_app_support; 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. // Create auto-load sections, so users know what's available.
// Note that this totem pole is the reverse of the order that // Note that this totem pole is the reverse of the order that
// they will appear in the file. // they will appear in the file.
#if 0
CreateSectionAtStart("Harmony.Autoload"); double last = 0;
CreateSectionAtStart("UrbanBrawl.Autoload"); if (SetSection ("LastRun"))
CreateSectionAtStart("Chex3.Autoload"); {
CreateSectionAtStart("Chex1.Autoload"); const char *lastver = GetValueForKey ("Version");
CreateSectionAtStart("Chex.Autoload"); if (lastver != NULL) last = atof(lastver);
CreateSectionAtStart("Strife.Autoload"); }
CreateSectionAtStart("HexenDK.Autoload");
CreateSectionAtStart("Hexen.Autoload"); // don't create the autoload section if we are about to migrate an old config because it'd mess up the upcoming migration step.
CreateSectionAtStart("HereticSR.Autoload"); // This will be taken care of once the game runs again with the migrated config file.
CreateSectionAtStart("Heretic.Autoload"); if (last >= 211)
CreateSectionAtStart("FreeDM.Autoload"); {
CreateSectionAtStart("Freedoom2.Autoload"); const FString *pAuto;
CreateSectionAtStart("Freedoom1.Autoload"); for (int num = 0; (pAuto = iwad_man->GetAutoname(num)) != NULL; num++)
CreateSectionAtStart("Freedoom.Autoload"); {
CreateSectionAtStart("Plutonia.Autoload"); if (!(iwad_man->GetIWadFlags(num) & GI_SHAREWARE)) // we do not want autoload sections for shareware IWADs (which may have an autoname for resource filtering)
CreateSectionAtStart("TNT.Autoload"); {
CreateSectionAtStart("Doom2BFG.Autoload"); FString workname = *pAuto;
CreateSectionAtStart("Doom2.Autoload");
CreateSectionAtStart("DoomBFG.Autoload"); while (workname.IsNotEmpty())
CreateSectionAtStart("DoomU.Autoload"); {
CreateSectionAtStart("Doom1.Autoload"); FString section = workname + ".Autoload";
CreateSectionAtStart("Doom.Autoload"); CreateSectionAtStart(section.GetChars());
#endif long dotpos = workname.LastIndexOf('.');
if (dotpos < 0) break;
workname.Truncate(dotpos);
}
}
}
}
CreateSectionAtStart("Global.Autoload"); CreateSectionAtStart("Global.Autoload");
// The same goes for auto-exec files. // The same goes for auto-exec files.
@ -345,6 +352,7 @@ void FGameConfigFile::DoGlobalSetup ()
RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload"); RenameSection("FreeDM.Autoload", "doom.freedoom.freedm.Autoload");
RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload"); RenameSection("Freedoom2.Autoload", "doom.freedoom.phase2.Autoload");
RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload"); RenameSection("Freedoom1.Autoload", "doom.freedoom.phase1.Autoload");
RenameSection("Freedoom.Autoload", "doom.freedoom.Autoload");
RenameSection("DoomBFG.Autoload", "doom.doom1.bfg.Autoload"); RenameSection("DoomBFG.Autoload", "doom.doom1.bfg.Autoload");
RenameSection("DoomU.Autoload", "doom.doom1.ultimate.Autoload"); RenameSection("DoomU.Autoload", "doom.doom1.ultimate.Autoload");
RenameSection("Doom1.Autoload", "doom.doom1.registered.Autoload"); RenameSection("Doom1.Autoload", "doom.doom1.registered.Autoload");

View file

@ -38,11 +38,12 @@
#include "configfile.h" #include "configfile.h"
class DArgs; class DArgs;
class FIWadManager;
class FGameConfigFile : public FConfigFile class FGameConfigFile : public FConfigFile
{ {
public: public:
FGameConfigFile (); FGameConfigFile (FIWadManager *iwad_man);
~FGameConfigFile (); ~FGameConfigFile ();
void DoGlobalSetup (); void DoGlobalSetup ();

View file

@ -410,9 +410,9 @@ CCMD (writeini)
// M_LoadDefaults // M_LoadDefaults
// //
void M_LoadDefaults () void M_LoadDefaults (FIWadManager *iwad_man)
{ {
GameConfig = new FGameConfigFile; GameConfig = new FGameConfigFile(iwad_man);
GameConfig->DoGlobalSetup (); GameConfig->DoGlobalSetup ();
atterm (M_SaveDefaultsFinal); atterm (M_SaveDefaultsFinal);
} }

View file

@ -28,6 +28,7 @@
class FConfigFile; class FConfigFile;
class FGameConfigFile; class FGameConfigFile;
class FIWadManager;
extern FGameConfigFile *GameConfig; extern FGameConfigFile *GameConfig;
@ -40,7 +41,7 @@ void M_FindResponseFile (void);
// Pass a NULL to get the original behavior. // Pass a NULL to get the original behavior.
void M_ScreenShot (const char *filename); void M_ScreenShot (const char *filename);
void M_LoadDefaults (); void M_LoadDefaults (FIWadManager *iwad_man);
bool M_SaveDefaults (const char *filename); bool M_SaveDefaults (const char *filename);
void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection, size_t sublen); void M_SaveCustomKeys (FConfigFile *config, char *section, char *subsection, size_t sublen);