- used the newly added game ID as reference for GAMEINFO to autoselect which game to start a mod with.

While in GZDoom this uses the IWAD name, the same approach is a lot more problematic here because of name duplications with far more incompatible content.
So this allows targeting a group of base games instead of one specific version.
This commit is contained in:
Christoph Oelckers 2021-04-13 17:05:53 +02:00
parent 6ad3ac8ef9
commit 4fe3c50c7c
3 changed files with 26 additions and 14 deletions

View file

@ -123,7 +123,7 @@ FMemArena dump; // this is for memory blocks than cannot be deallocated without
InputState inputState;
int ShowStartupWindow(TArray<GrpEntry> &);
FString GetGameFronUserFiles();
TArray<FString> GetGameFronUserFiles();
void InitFileSystem(TArray<GrpEntry>&);
void I_SetWindowTitle(const char* caption);
void S_ParseSndInfo();
@ -643,14 +643,25 @@ static TArray<GrpEntry> SetupGame()
int groupno = -1;
// If the user has specified a file name, let's see if we know it.
//
FString game = GetGameFronUserFiles();
auto game = GetGameFronUserFiles();
if (userConfig.gamegrp.IsEmpty())
{
userConfig.gamegrp = game;
for (auto& str : game)
{
for (auto& grp : groups)
{
if (grp.FileInfo.gameid.CompareNoCase(str) == 0)
{
userConfig.gamegrp = grp.FileName;
goto foundit;
}
}
}
}
foundit:
// If the user has specified a file name, let's see if we know it.
//
if (userConfig.gamegrp.Len())
{
FString gamegrplower = "/" + userConfig.gamegrp.MakeLower();

View file

@ -139,6 +139,7 @@ struct GrpInfo
FString defname;
FString rtsname;
FString gamefilter;
FString gameid;
uint32_t CRC = 0;
uint32_t dependencyCRC = 0;
size_t size = 0;

View file

@ -60,10 +60,10 @@ static const char* validexts[] = { "*.grp", "*.zip", "*.pk3", "*.pk4", "*.7z", "
//
//==========================================================================
static FString ParseGameInfo(TArray<FString>& pwads, const char* fn, const char* data, int size)
static TArray<FString> ParseGameInfo(TArray<FString>& pwads, const char* fn, const char* data, int size)
{
FScanner sc;
FString iwad;
TArray<FString> bases;
int pos = 0;
const char* lastSlash = strrchr(fn, '/');
@ -78,7 +78,7 @@ static FString ParseGameInfo(TArray<FString>& pwads, const char* fn, const char*
if (!nextKey.CompareNoCase("GAME"))
{
sc.MustGetString();
iwad = sc.String;
bases.Push(sc.String);
}
else if (!nextKey.CompareNoCase("LOAD"))
{
@ -136,7 +136,7 @@ static FString ParseGameInfo(TArray<FString>& pwads, const char* fn, const char*
} while (sc.CheckToken(','));
}
}
return iwad;
return bases;
}
//==========================================================================
//
@ -144,7 +144,7 @@ static FString ParseGameInfo(TArray<FString>& pwads, const char* fn, const char*
//
//==========================================================================
static FString CheckGameInfo(TArray<FString>& pwads)
static TArray<FString> CheckGameInfo(TArray<FString>& pwads)
{
// scan the list of WADs backwards to find the last one that contains a GAMEINFO lump
for (int i = pwads.Size() - 1; i >= 0; i--)
@ -184,15 +184,15 @@ static FString CheckGameInfo(TArray<FString>& pwads)
if (FName(lmp->getName(), true) == gameinfo)
{
// Found one!
FString iwad = ParseGameInfo(pwads, resfile->FileName, (const char*)lmp->Lock(), lmp->LumpSize);
auto bases = ParseGameInfo(pwads, resfile->FileName, (const char*)lmp->Lock(), lmp->LumpSize);
delete resfile;
return iwad;
return bases;
}
}
delete resfile;
}
}
return "";
return TArray<FString>();
}
//==========================================================================
@ -201,7 +201,7 @@ static FString CheckGameInfo(TArray<FString>& pwads)
//
//==========================================================================
FString GetGameFronUserFiles()
TArray<FString> GetGameFronUserFiles()
{
TArray<FString> Files;