diff --git a/source/build/include/build.h b/source/build/include/build.h index 9421b59bd..e523bde57 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -628,7 +628,7 @@ int32_t md_definehud (int32_t modelid, int32_t tilex, vec3f_t add, int32_t md_undefinetile(int32_t tile); int32_t md_undefinemodel(int32_t modelid); -int32_t loaddefinitionsfile(const char *fn, bool loadadds = false); +int32_t loaddefinitionsfile(const char *fn, bool loadadds = false, bool cumulative = false); #ifdef USE_OPENGL # include "polymost.h" diff --git a/source/build/include/scriptfile.h b/source/build/include/scriptfile.h index c7aaf4fa8..5b742cd29 100644 --- a/source/build/include/scriptfile.h +++ b/source/build/include/scriptfile.h @@ -113,12 +113,6 @@ inline void scriptfile_close(scriptfile *sf) delete sf; } -inline int32_t scriptfile_addsymbolvalue(scriptfile *sf, char const *name, int32_t val) -{ - sf->AddSymbol(name, val); - return 1; -} - typedef struct { const char *text; diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 9b7993666..91c2eac86 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -2917,7 +2917,7 @@ static int32_t defsparser(scriptfile *script) break; FStringf name("%s.%s", resName.GetChars(), resType.GetChars()); - fileSystem.CreatePathlessCopy(resName, resID, 0); + fileSystem.CreatePathlessCopy(name, resID, 0); } break; @@ -2930,34 +2930,44 @@ static int32_t defsparser(scriptfile *script) return 0; } - -int32_t loaddefinitionsfile(const char *fn, bool loadadds) +int32_t loaddefinitionsfile(const char *fn, bool loadadds, bool cumulative) { - scriptfile *script; - - script = scriptfile_fromfile(fn); - - if (script) + bool done = false; + auto parseit = [&](int lump) { - Printf(PRINT_NONOTIFY, "Loading \"%s\"\n",fn); + FScanner sc; + sc.OpenLumpNum(lump); + sc.SetNoOctals(true); + sc.SetNoFatalErrors(true); + defsparser(&sc); + done = true; + Printf(PRINT_NONOTIFY, "\n"); + }; - defsparser(script); + if (!cumulative) + { + int lump = fileSystem.FindFile(fn); + if (lump >= 0) + { + Printf(PRINT_NONOTIFY, "Loading \"%s\"\n", fn); + parseit(lump); + } + } + else + { + int lump, lastlump = 0; + while ((lump = fileSystem.FindLumpFullName(fn, &lastlump)) >= 0) + { + Printf(PRINT_NONOTIFY, "Loading \"%s\"\n", fileSystem.GetFileFullPath(lump).GetChars()); + parseit(lump); + } } if (userConfig.AddDefs && loadadds) for (auto& m : *userConfig.AddDefs) { Printf("Loading module \"%s\"\n",m.GetChars()); - defsparser_include(m, NULL, NULL); // Q: should we let the external script see our symbol table? + defsparser_include(m, nullptr, nullptr); // Q: should we let the external script see our symbol table? + Printf(PRINT_NONOTIFY, "\n"); } - - if (script) - scriptfile_close(script); - - if (!script) return -1; - - Printf(PRINT_NONOTIFY, "\n"); - return 0; } - -// vim:ts=4: diff --git a/source/common/filesystem/filesystem.cpp b/source/common/filesystem/filesystem.cpp index 0ea4ac7a6..dae98edf5 100644 --- a/source/common/filesystem/filesystem.cpp +++ b/source/common/filesystem/filesystem.cpp @@ -76,14 +76,14 @@ struct FileSystem::LumpRecord shortName.String[8] = 0; longName = ""; Namespace = lump->GetNamespace(); - resourceId = 0; + resourceId = -1; } else if ((lump->Flags & LUMPF_EMBEDDED) || !lump->getName() || !*lump->getName()) { shortName.qword = 0; longName = ""; Namespace = ns_hidden; - resourceId = 0; + resourceId = -1; } else { diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index e5e5410f5..e8736bf98 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -361,7 +361,7 @@ void UserConfig::ProcessOptions() static const char* defs[] = { "-def", "-h", nullptr }; Args->CollectFiles("-def", defs, ".def"); - DefaultDef = Args->CheckValue("-def"); + UserDef = Args->CheckValue("-def"); if (DefaultCon.IsEmpty()) { @@ -1323,27 +1323,50 @@ void DrawCrosshair(int deftile, int health, double xdelta, double ydelta, double void LoadDefinitions() { - loaddefinitionsfile("engine/engine.def"); // Internal stuff that is required. - - const char* defsfile = G_DefFile(); - cycle_t deftimer; deftimer.Reset(); deftimer.Clock(); - if (!loaddefinitionsfile(defsfile, true)) + 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. + + // check what we have. + // user .defs override the default ones and are not cumulative. + // if we fine even one Raze-specific file, all of those will be loaded cumulatively. + // otherwise the default rules inherited from older ports apply. + if (userConfig.UserDef.IsNotEmpty()) + { + if (!loaddefinitionsfile(userConfig.UserDef, true, false)) loaded = userConfig.UserDef; + } + else + { + if (fileSystem.FileExists(razedefsfile)) + { + if (!loaddefinitionsfile(razedefsfile, true, true)) loaded = razedefsfile; + } + else + { + if (!loaddefinitionsfile(defsfile, true, false)) loaded = defsfile; + } + } + + if (loaded) { deftimer.Unclock(); - Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %.3f ms.\n", defsfile, deftimer.TimeMS()); + DPrintf(DMSG_SPAMMY, "Definitions file \"%s\" loaded, %f ms.\n", loaded, deftimer.TimeMS()); } userConfig.AddDefs.reset(); - // load the widescreen replacements last so that they do not clobber the CRC for the original items so that mod-side replacement are picked up. + // 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")) { loaddefinitionsfile("engine/widescreen.def"); } - - + fileSystem.InitHashChains(); // make sure that any resources that got added can be found again. } bool M_Active() diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 4a3d684b2..d91275260 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -65,6 +65,7 @@ struct UserConfig { FString gamegrp; FString CommandMap; + FString UserDef; FString DefaultDef; FString DefaultCon; FString CommandDemo; diff --git a/source/core/parsefuncs.h b/source/core/parsefuncs.h index b6f71f8f1..61459d10a 100644 --- a/source/core/parsefuncs.h +++ b/source/core/parsefuncs.h @@ -51,6 +51,20 @@ void parseSkip(FScanner& sc, FScriptPosition& pos) for (int i = 0; i < cnt; i++) if (!sc.GetNumber(true)) return; } +void parseDefine(FScanner& sc, FScriptPosition& pos) +{ + FString name; + if (!sc.GetString(name)) return; + if (!sc.GetNumber()) return; + sc.AddSymbol(name, sc.Number); +} + +//=========================================================================== +// +// +// +//=========================================================================== + void parseDefineTexture(FScanner& sc, FScriptPosition& pos) { int tile, palette; @@ -178,3 +192,54 @@ void parseAnimTileRange(FScanner& sc, FScriptPosition& pos) processSetAnim("animtilerange", pos, set); } +//=========================================================================== +// +// +// +//=========================================================================== + +void parseAlphahack(FScanner& sc, FScriptPosition& pos) +{ + int tile; + + if (!sc.GetNumber(tile, true)) return; + if (!sc.GetFloat(true)) return; + if ((unsigned)tile < MAXTILES) TileFiles.tiledata[tile].texture->alphaThreshold = (float)sc.Float; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void parseAlphahackRange(FScanner& sc, FScriptPosition& pos) +{ + int tilestart, tileend; + + if (!sc.GetNumber(tilestart, true)) return; + if (!sc.GetNumber(tileend, true)) return; + if (!sc.GetFloat(true)) return; + if (!ValidateTileRange("alphahackrange", tilestart, tileend, pos)) return; + + for (int i = tilestart; i <= tileend; i++) + TileFiles.tiledata[i].texture->alphaThreshold = (float)sc.Number; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void parseDefineTint(FScanner& sc, FScriptPosition& pos) +{ + int pal, r, g, b, f; + + if (!sc.GetNumber(pal, true)) return; + if (!sc.GetNumber(r)) return; + if (!sc.GetNumber(g)) return; + if (!sc.GetNumber(b)) return; + if (!sc.GetNumber(f)) return; + lookups.setPaletteTint(pal, r, g, b, 0, 0, 0, f); +} diff --git a/source/games/blood/src/barf.cpp b/source/games/blood/src/barf.cpp index f5f6f6381..ad218159c 100644 --- a/source/games/blood/src/barf.cpp +++ b/source/games/blood/src/barf.cpp @@ -656,7 +656,7 @@ void ParseScript(int lumpnum) if (dword_44CE0[gParseLevel] == 0) { // In the RFS files I have seen the outermost directory is not part of what goes into the file system. - auto inp1 = strchr(inp, '\\'); + auto inp1 = strpbrk(inp, "/\\"); if (!inp1 || !fileSystem.CreatePathlessCopy(inp1 + 1, ID, nFlags)) { // I'll activate this when I find evidence that it is needed. Otherwise the risk of picking up unwanted data is too high. diff --git a/wadsrc/static/filter/exhumed/engine/engine.def b/wadsrc/static/filter/exhumed/engine/engine.def deleted file mode 100644 index eaa696b26..000000000 --- a/wadsrc/static/filter/exhumed/engine/engine.def +++ /dev/null @@ -1 +0,0 @@ -tilefromtexture 3463 { file "tiles/options.png" } \ No newline at end of file diff --git a/wadsrc/static/filter/exhumed/tiles/options.png b/wadsrc/static/filter/exhumed/tiles/options.png deleted file mode 100644 index a035cbae2..000000000 Binary files a/wadsrc/static/filter/exhumed/tiles/options.png and /dev/null differ diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 675a6b08b..907b26f2d 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1490,6 +1490,14 @@ OptionValue GPUSwitch 2.0, "$OPTVAL_INTEGRATED" } +OptionValue PreferBackend +{ + 0, "$OPTVAL_OPENGL" + 1, "$OPTVAL_VULKAN" + // Enable when HAVE_SOFTPOLY will be defined + //2, "$OPTVAL_SOFTPOLY" +} + OptionMenu VideoModeMenu protected { Title "$VIDMNU_TITLE"