From 5d55f768e092be8f7f51d7e21db3929ee4f2aaf4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 1 Feb 2020 21:12:09 +0100 Subject: [PATCH] - added autodetection for Cryptic Passage and Route 66 add-ons in their originally (messed up) form. Cryptic Passage will also be detected in a Fresh Supply installation now. --- source/common/gamecontrol.h | 1 + source/common/initfs.cpp | 11 +++++---- source/common/searchpaths.cpp | 41 ++++++++++++++++++++++++++++---- wadsrc/static/engine/grpinfo.txt | 4 ++-- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/source/common/gamecontrol.h b/source/common/gamecontrol.h index b9b662b22..7bec34c46 100644 --- a/source/common/gamecontrol.h +++ b/source/common/gamecontrol.h @@ -127,6 +127,7 @@ struct GrpInfo size_t size = 0; int flags = 0; bool loaddirectory = false; + bool isAddon = false; TArray mustcontain; TArray tobedeleted; TArray loadfiles; diff --git a/source/common/initfs.cpp b/source/common/initfs.cpp index 8d9315817..d4a210148 100644 --- a/source/common/initfs.cpp +++ b/source/common/initfs.cpp @@ -486,19 +486,20 @@ void InitFileSystem(TArray& groups) bool insertdirectoriesafter = Args->CheckParm("-insertdirafter"); int i = groups.Size()-1; + FString fn; for (auto &grp : groups) { // Add all dependencies, plus the directory of the base dependency. // Directories of addon content are not added if they differ from the main directory. // Also, the directory is inserted after the base dependency, allowing the addons to override directory content. // This can be overridden via command line switch if needed. - if (!grp.FileInfo.loaddirectory) + if (!grp.FileInfo.loaddirectory && grp.FileName.IsNotEmpty()) + { D_AddFile(Files, grp.FileName); + fn = ExtractFilePath(grp.FileName); + if (fn.Len() > 0 && fn.Back() != '/') fn += '/'; + } - auto fn = grp.FileName; - fn.Substitute("\\", "/"); - auto index = fn.LastIndexOf("/"); - fn.Truncate(index+1); // right after the last slash. for (auto& fname : grp.FileInfo.loadfiles) { FString newname = fn + fname; diff --git a/source/common/searchpaths.cpp b/source/common/searchpaths.cpp index 0f06bc10d..818643b52 100644 --- a/source/common/searchpaths.cpp +++ b/source/common/searchpaths.cpp @@ -403,10 +403,11 @@ static TArray ParseGrpInfo(const char *fn, FileReader &fr, TMap &groups) // //========================================================================== +static bool CheckAddon(GrpInfo* addon, GrpInfo* main, const char* filename) +{ + if (addon->dependencyCRC != main->CRC) return false; + FString path = ExtractFilePath(filename); + if (path.Len() > 0 && path.Back() != '/') path += '/'; + for (auto& fn : addon->mustcontain) + { + FString check = path + fn; + if (!FileExists(check)) return false; + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + TArray GrpScan() { TArray foundGames; @@ -652,6 +672,7 @@ TArray GrpScan() TArray sortedFileList; TArray sortedGroupList; TArray contentGroupList; + TArray addonList; auto allFiles = CollectAllFilesInSearchPath(); auto allGroups = ParseAllGrpInfos(allFiles); @@ -667,7 +688,9 @@ TArray GrpScan() for (auto& f : allFiles) sortedFileList.Push(&f); for (auto& g : allGroups) { - if (g.CRC == 0 && g.mustcontain.Size() > 0) + if (g.isAddon) + addonList.Push(&g); + else if (g.CRC == 0 && g.mustcontain.Size() > 0) contentGroupList.Push(&g); else sortedGroupList.Push(&g); @@ -761,6 +784,16 @@ TArray GrpScan() fg.FileInfo = *grp; fg.FileName = entry->FileName; fg.FileIndex = entry->Index; + for (auto addon : addonList) + { + if (CheckAddon(addon, grp, entry->FileName)) + { + foundGames.Reserve(1); + auto& fga = foundGames.Last(); + fga.FileInfo = *addon; + fga.FileIndex = entry->Index; + } + } } } @@ -875,8 +908,8 @@ const char* G_DefaultConFile(void) if (fileSystem.FindFile("ww2gi.con") >= 0) return "ww2gi.con"; } - if (g_gameType & GAMEFLAG_SW) - return nullptr; // SW has no scripts of any kind. + if (g_gameType & (GAMEFLAG_SW|GAMEFLAG_PSEXHUMED)) + return nullptr; // Exhumed and SW have no scripts of any kind. if (g_gameType & GAMEFLAG_NAM) { diff --git a/wadsrc/static/engine/grpinfo.txt b/wadsrc/static/engine/grpinfo.txt index e774f41c7..7bc51f1cf 100644 --- a/wadsrc/static/engine/grpinfo.txt +++ b/wadsrc/static/engine/grpinfo.txt @@ -419,7 +419,7 @@ addon name "BLOOD: Cryptic Passage" scriptname "CRYPTIC.INI" mustcontain "cryptic/CRYPTIC.INI", "cryptic/CP01.MAP", "cryptic/CP02.MAP" - addresource "cryptic" + loadgrp "cryptic" flags GAMEFLAG_BLOOD|GAMEFLAG_ADDON dependency BLOOD_CRC loadart "CPART07.AR_", "CPART15.AR_" @@ -432,7 +432,7 @@ addon name "BLOOD: Cryptic Passage" scriptname "CRYPTIC.INI" mustcontain "addons/Cryptic Passage/CRYPTIC.INI", "addons/Cryptic Passage/CP01.MAP", "addons/Cryptic Passage/CP02.MAP" - addresource "addons/Cryptic Passage" + loadgrp "addons/Cryptic Passage" flags GAMEFLAG_BLOOD|GAMEFLAG_ADDON dependency BLOOD_CRC gamefilter "Blood.Cryptic"