- 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.
This commit is contained in:
Christoph Oelckers 2020-02-01 21:12:09 +01:00
parent ca593f7dda
commit 5d55f768e0
4 changed files with 46 additions and 11 deletions

View file

@ -127,6 +127,7 @@ struct GrpInfo
size_t size = 0;
int flags = 0;
bool loaddirectory = false;
bool isAddon = false;
TArray<FString> mustcontain;
TArray<FString> tobedeleted;
TArray<FString> loadfiles;

View file

@ -486,19 +486,20 @@ void InitFileSystem(TArray<GrpEntry>& 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;

View file

@ -403,10 +403,11 @@ static TArray<GrpInfo> ParseGrpInfo(const char *fn, FileReader &fr, TMap<FString
CRCMap.Insert(key, (uint32_t)sc.BigNumber);
}
}
else if (sc.Compare("grpinfo"))
else if (sc.Compare("grpinfo") || sc.Compare("addon"))
{
groups.Reserve(1);
auto& grp = groups.Last();
grp.isAddon = sc.Compare("addon");
sc.MustGetToken('{');
while (!sc.CheckToken('}'))
{
@ -645,6 +646,25 @@ GrpInfo *IdentifyGroup(FileEntry *entry, TArray<GrpInfo *> &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<GrpEntry> GrpScan()
{
TArray<GrpEntry> foundGames;
@ -652,6 +672,7 @@ TArray<GrpEntry> GrpScan()
TArray<FileEntry*> sortedFileList;
TArray<GrpInfo*> sortedGroupList;
TArray<GrpInfo*> contentGroupList;
TArray<GrpInfo*> addonList;
auto allFiles = CollectAllFilesInSearchPath();
auto allGroups = ParseAllGrpInfos(allFiles);
@ -667,7 +688,9 @@ TArray<GrpEntry> 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<GrpEntry> 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)
{

View file

@ -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"