mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
Added ability to load any IWAD without extension
Previously, only .wad files can specified without file extension for -iwad command line option For example, -iwad square1 will load square1.pk3 as IWAD
This commit is contained in:
parent
17bc9c3f69
commit
ca0e39cd0c
1 changed files with 27 additions and 16 deletions
|
@ -519,28 +519,39 @@ int FIWadManager::IdentifyVersion (TArray<FString> &wadfiles, const char *iwad,
|
||||||
|
|
||||||
if (iwadparm)
|
if (iwadparm)
|
||||||
{
|
{
|
||||||
// Check if the given IWAD has an absolute path, in which case the search path will be ignored.
|
const char* const extensions[] = { ".wad", ".pk3", ".iwad", ".ipk3", ".ipk7" };
|
||||||
custwad = iwadparm;
|
|
||||||
FixPathSeperator(custwad);
|
for (auto ext : extensions)
|
||||||
DefaultExtension(custwad, ".wad");
|
{
|
||||||
bool isAbsolute = (custwad[0] == '/');
|
// Check if the given IWAD has an absolute path, in which case the search path will be ignored.
|
||||||
|
custwad = iwadparm;
|
||||||
|
FixPathSeperator(custwad);
|
||||||
|
DefaultExtension(custwad, ext);
|
||||||
|
bool isAbsolute = (custwad[0] == '/');
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
isAbsolute |= (custwad.Len() >= 2 && custwad[1] == ':');
|
isAbsolute |= (custwad.Len() >= 2 && custwad[1] == ':');
|
||||||
#endif
|
#endif
|
||||||
if (isAbsolute)
|
if (isAbsolute)
|
||||||
{
|
|
||||||
if (FileExists(custwad)) mFoundWads.Push({ custwad, "", -1 });
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (auto &dir : mSearchPaths)
|
|
||||||
{
|
{
|
||||||
FStringf fullpath("%s/%s", dir.GetChars(), custwad.GetChars());
|
if (FileExists(custwad)) mFoundWads.Push({ custwad, "", -1 });
|
||||||
if (FileExists(fullpath))
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto &dir : mSearchPaths)
|
||||||
{
|
{
|
||||||
mFoundWads.Push({ fullpath, "", -1 });
|
FStringf fullpath("%s/%s", dir.GetChars(), custwad.GetChars());
|
||||||
|
if (FileExists(fullpath))
|
||||||
|
{
|
||||||
|
mFoundWads.Push({ fullpath, "", -1 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mFoundWads.Size() != numFoundWads)
|
||||||
|
{
|
||||||
|
// Found IWAD with guessed extension
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// -iwad not found or not specified. Revert back to standard behavior.
|
// -iwad not found or not specified. Revert back to standard behavior.
|
||||||
|
|
Loading…
Reference in a new issue