diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 7f9bc60fedf..3ad6ed00486 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -111,6 +111,12 @@ void FIWadManager::ParseIWadInfo(const char *fn, const char *data, int datasize, iwad->prio = sc.Number; } } + else if (sc.Compare("SupportWAD")) + { + sc.MustGetStringName("="); + sc.MustGetString(); + iwad->SupportWAD = sc.String; + } else if (sc.Compare("Config")) { sc.MustGetStringName("="); @@ -562,6 +568,18 @@ void FIWadManager::ValidateIWADs() static bool havepicked = false; + +FString FIWadManager::IWADPathFileSearch(const FString &file) +{ + for(const FString &path : mSearchPaths) + { + FString f = path + "/" + file; + if(FileExists(f)) return f; + } + + return ""; +} + int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char *iwad, const char *zdoom_wad, const char *optional_wad) { const char *iwadparm = Args->CheckValue ("-iwad"); @@ -802,11 +820,11 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char D_AddFile (wadfiles, zdoom_wad, true, -1, GameConfig); // [SP] Load non-free assets if available. This must be done before the IWAD. - int iwadnum; + int iwadnum = 1; if (D_AddFile(wadfiles, optional_wad, true, -1, GameConfig)) - iwadnum = 2; - else - iwadnum = 1; + { + iwadnum++; + } fileSystem.SetIwadNum(iwadnum); if (picks[pick].mRequiredPath.IsNotEmpty()) @@ -818,6 +836,17 @@ int FIWadManager::IdentifyVersion (std::vector&wadfiles, const char fileSystem.SetMaxIwadNum(iwadnum); auto info = mIWadInfos[picks[pick].mInfoIndex]; + + if(info.SupportWAD.IsNotEmpty()) + { + FString supportWAD = IWADPathFileSearch(info.SupportWAD); + + if(supportWAD.IsNotEmpty()) + { + D_AddFile(wadfiles, supportWAD.GetChars(), true, -1, GameConfig); + } + } + // Load additional resources from the same directory as the IWAD itself. for (unsigned i=0; i < info.Load.Size(); i++) { diff --git a/src/d_main.h b/src/d_main.h index 49e9846be1a..0d4a33079cd 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -76,6 +76,7 @@ struct FIWADInfo FString Name; // Title banner text for this IWAD FString Autoname; // Name of autoload ini section for this IWAD FString IWadname; // Default name this game would use - this is for IWAD detection in GAMEINFO. + FString SupportWAD; // Optional support WAD, load if present (initially implemented for id24) int prio = 0; // selection priority for given IWAD name. FString Configname; // Name of config section for this IWAD FString Required; // Requires another IWAD @@ -133,7 +134,9 @@ class FIWadManager void CollectSearchPaths(); void AddIWADCandidates(const char *dir); void ValidateIWADs(); + FString IWADPathFileSearch(const FString &file); public: + FIWadManager(const char *fn, const char *fnopt); const FIWADInfo *FindIWAD(std::vector& wadfiles, const char *iwad, const char *basewad, const char *optionalwad); const FString *GetAutoname(unsigned int num) const diff --git a/wadsrc_extra/static/iwadinfo.txt b/wadsrc_extra/static/iwadinfo.txt index 8eb7f1522cb..985df8b5d36 100644 --- a/wadsrc_extra/static/iwadinfo.txt +++ b/wadsrc_extra/static/iwadinfo.txt @@ -338,6 +338,7 @@ IWad "DMENUPIC", "M_ACPT", "M_CAN", "M_EXITO", "M_CHG" BannerColors = "54 54 54", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -356,6 +357,7 @@ IWad Load = "extras.wad" BannerColors = "00 7c 00", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -374,6 +376,7 @@ IWad Load = "extras.wad", "soundtrack" BannerColors = "00 7c 00", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -388,6 +391,7 @@ IWad MustContain = "SMOOSHED", "ANIMDEFS", "LANGUAGE", "MAPINFO", "ENDOOM", "M_DOOM", "TITLEPIC", "TEXTURES" BannerColors = "a8 00 00", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -404,6 +408,7 @@ IWad "DPHOOF","BFGGA0","HEADA1","CYBRA1","SPIDA1D1", "E4M2", "E1M10", "SEWERS" BannerColors = "18 18 18", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -420,6 +425,7 @@ IWad "DPHOOF","BFGGA0","HEADA1","CYBRA1","SPIDA1D1", "E4M2" BannerColors = "54 54 54", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -436,6 +442,7 @@ IWad "DPHOOF","BFGGA0","HEADA1","CYBRA1","SPIDA1D1" BannerColors = "54 54 54", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -449,6 +456,7 @@ IWad MustContain = "E1M1" BannerColors = "54 54 54", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -463,6 +471,7 @@ IWad MustContain = "MAP01", "REDTNT2", "DMAPINFO" BannerColors = "00 7c 00", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -478,6 +487,7 @@ IWad BannerColors = "a8 00 00", "a8 a8 a8" Load = "extras.wad" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -492,6 +502,7 @@ IWad MustContain = "MAP01", "REDTNT2" BannerColors = "a8 00 00", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -506,6 +517,7 @@ IWad MustContain = "MAP01", "CAMO1", "DMAPINFO" BannerColors = "00 7c 00", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -521,6 +533,7 @@ IWad BannerColors = "a8 00 00", "a8 a8 a8" Load = "extras.wad" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -535,6 +548,7 @@ IWad MustContain = "MAP01", "CAMO1" BannerColors = "a8 00 00", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -550,6 +564,7 @@ IWad BannerColors = "a8 00 00", "a8 a8 a8" Load = "nerve.wad" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" } IWad @@ -565,6 +580,7 @@ IWad BannerColors = "00 7c 00", "a8 a8 a8" IgnoreTitlePatches = 1 Load = "extras.wad" + SupportWAD = "id24res.wad" } IWad @@ -580,6 +596,7 @@ IWad BannerColors = "00 7c 00", "a8 a8 a8" IgnoreTitlePatches = 1 Load = "nerveunity.wad", "extras.wad", "soundtrack" + SupportWAD = "id24res.wad" } IWad @@ -596,6 +613,7 @@ IWad IgnoreTitlePatches = 1 Load = "nerve.wad" DeleteLumps = "M_EPI1", "M_EPI2", "M_EPISOD" + SupportWAD = "id24res.wad" } IWad @@ -609,6 +627,7 @@ IWad Compatibility = "Shorttex", "nosectionmerge" MustContain = "MAP01", "WIOBJ" BannerColors = "ff ff ff", "a8 00 00" + SupportWAD = "id24res.wad" } // Doom 2 must be last to be checked because MAP01 is its only requirement @@ -624,6 +643,7 @@ IWad MustContain = "MAP01" BannerColors = "a8 00 00", "a8 a8 a8" IgnoreTitlePatches = 1 + SupportWAD = "id24res.wad" }