mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- 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:
parent
258822ef3b
commit
dfda74ffe3
7 changed files with 68 additions and 41 deletions
|
@ -387,7 +387,6 @@ int FIWadManager::IdentifyVersion (TArray<FString> &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]));
|
||||
|
|
|
@ -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<FString> 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;
|
||||
|
|
16
src/d_main.h
16
src/d_main.h
|
@ -115,15 +115,13 @@ extern FStartupInfo DoomStartupInfo;
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
struct FIWadManager
|
||||
class FIWadManager
|
||||
{
|
||||
private:
|
||||
TArray<FIWADInfo> mIWads;
|
||||
TArray<FString> mIWadNames;
|
||||
TArray<int> 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<FString> &wadfiles, const char *iwad, const char *zdoom_wad);
|
||||
public:
|
||||
void ParseIWadInfos(const char *fn);
|
||||
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;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -38,11 +38,12 @@
|
|||
#include "configfile.h"
|
||||
|
||||
class DArgs;
|
||||
class FIWadManager;
|
||||
|
||||
class FGameConfigFile : public FConfigFile
|
||||
{
|
||||
public:
|
||||
FGameConfigFile ();
|
||||
FGameConfigFile (FIWadManager *iwad_man);
|
||||
~FGameConfigFile ();
|
||||
|
||||
void DoGlobalSetup ();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue