diff --git a/source/core/defparser.cpp b/source/core/defparser.cpp index 5a601f15c..93fcca3aa 100644 --- a/source/core/defparser.cpp +++ b/source/core/defparser.cpp @@ -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); - } - } } diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index f976fdacc..55b46a034 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -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. } diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index a3565c470..20a5d7ad7 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -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);