- Move for (auto& m : *userConfig.AddDefs) loop from loaddefinitionsfile() into LoadDefinitions() and rework debug timer code to accommodate.

* Change also reverts 5af7be42a2.
This commit is contained in:
Mitchell Richters 2021-04-22 16:33:45 +10:00
parent c0e5599478
commit 27767f61ae
3 changed files with 42 additions and 31 deletions

View file

@ -2112,7 +2112,7 @@ static void defsparser(FScanner& sc)
}
}
void loaddefinitionsfile(const char* fn, bool loadadds, bool cumulative)
void loaddefinitionsfile(const char* fn, bool cumulative)
{
bool done = false;
auto parseit = [&](int lump)
@ -2142,14 +2142,4 @@ void loaddefinitionsfile(const char* fn, bool loadadds, bool cumulative)
parseit(lump);
}
}
if (userConfig.AddDefs && loadadds) for (auto& m : *userConfig.AddDefs)
{
int lump = fileSystem.FindFile(m);
if (lump >= 0)
{
Printf(PRINT_NONOTIFY, "Loading \"%s\"\n", m.GetChars());
parseit(lump);
}
}
}

View file

@ -1341,15 +1341,25 @@ void DrawCrosshair(int deftile, int health, double xdelta, double ydelta, double
void LoadDefinitions()
{
cycle_t deftimer;
deftimer.Reset();
deftimer.Clock();
const char* loaded = nullptr;
const char* defsfile = G_DefFile();
FString razedefsfile = defsfile;
razedefsfile.Substitute(".def", "-raze.def");
loaddefinitionsfile("engine/engine.def", false); // Internal stuff that is required.
auto starttimer = [&]()
{
deftimer.Reset();
deftimer.Clock();
};
auto printtimer = [&](const char* fn)
{
deftimer.Unclock();
DPrintf(DMSG_SPAMMY, "Definitions file \"%s\" loaded, %f ms.\n", fn, deftimer.TimeMS());
};
starttimer();
loaddefinitionsfile("engine/engine.def"); // Internal stuff that is required.
printtimer("engine/engine.def");
// check what we have.
// user .defs override the default ones and are not cumulative.
@ -1357,39 +1367,50 @@ void LoadDefinitions()
// otherwise the default rules inherited from older ports apply.
if (userConfig.UserDef.IsNotEmpty())
{
loaddefinitionsfile(userConfig.UserDef, true, false);
loaded = userConfig.UserDef;
starttimer();
loaddefinitionsfile(userConfig.UserDef, false);
printtimer(userConfig.UserDef);
}
else
{
if (fileSystem.FileExists(razedefsfile))
{
loaddefinitionsfile(razedefsfile, true, true);
loaded = razedefsfile;
starttimer();
loaddefinitionsfile(razedefsfile, true);
printtimer(razedefsfile);
}
else
else if (fileSystem.FileExists(defsfile))
{
loaddefinitionsfile(defsfile, true, false);
loaded = defsfile;
starttimer();
loaddefinitionsfile(defsfile, false);
printtimer(defsfile);
}
}
if (userConfig.AddDefs)
{
for (auto& m : *userConfig.AddDefs)
{
starttimer();
loaddefinitionsfile(m, false);
printtimer(m);
}
userConfig.AddDefs.reset();
}
if (GameStartupInfo.def.IsNotEmpty())
{
loaddefinitionsfile(GameStartupInfo.def, false); // Stuff from gameinfo.
starttimer();
loaddefinitionsfile(GameStartupInfo.def); // Stuff from gameinfo.
printtimer(GameStartupInfo.def);
}
if (loaded)
{
deftimer.Unclock();
DPrintf(DMSG_SPAMMY, "Definitions file \"%s\" loaded, %f ms.\n", loaded, deftimer.TimeMS());
}
userConfig.AddDefs.reset();
// load the widescreen replacements last. This ensures that mods still get the correct CRCs for their own tile replacements.
if (fileSystem.FindFile("engine/widescreen.def") >= 0 && !Args->CheckParm("-nowidescreen"))
{
starttimer();
loaddefinitionsfile("engine/widescreen.def");
printtimer("engine/widescreen.def");
}
fileSystem.InitHashChains(); // make sure that any resources that got added can be found again.
}

View file

@ -6,7 +6,7 @@
extern int cameradist, cameraclock;
void loaddefinitionsfile(const char* fn, bool loadadds = false, bool cumulative = false);
void loaddefinitionsfile(const char* fn, bool cumulative = false);
bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, short *psectnum, binangle ang, fixedhoriz horiz, double const smoothratio);
void PlanesAtPoint(const sectortype* sec, float dax, float day, float* ceilz, float* florz);