Reworked check for embedded WADs put inside directory within archive

Any WAD from directory named the same as archive are treated as embedded
Fixed the issue with archive filename that wasn't taken into account
This commit is contained in:
alexey.lysiuk 2015-01-12 11:28:40 +02:00
parent 7ae3678abc
commit 9df56216b3

View file

@ -150,22 +150,28 @@ void FResourceLump::LumpNameSetup(const char *iname)
// //
//========================================================================== //==========================================================================
static bool IsWadInFolder(const char* const fullName) static bool IsWadInFolder(const FResourceFile* const archive, const char* const resPath)
{ {
// Checks a special case when <myfile.wad> was put in // Checks a special case when <somefile.wad> was put in
// <myfile> directory inside <myfile.zip> // <myproject> directory inside <myproject.zip>
const FString baseName = ExtractFileBase(fullName); if (NULL == archive)
const FString fileName = baseName + '/' + baseName + ".wad"; {
return false;
}
return 0 == fileName.CompareNoCase(fullName); const FString dirName = ExtractFileBase(archive->Filename);
const FString fileName = ExtractFileBase(resPath, true);
const FString filePath = dirName + '/' + fileName;
return 0 == filePath.CompareNoCase(resPath);
} }
void FResourceLump::CheckEmbedded() void FResourceLump::CheckEmbedded()
{ {
// Checks for embedded archives // Checks for embedded archives
const char *c = strstr(FullName, ".wad"); const char *c = strstr(FullName, ".wad");
if (c && strlen(c) == 4 && (!strchr(FullName, '/') || IsWadInFolder(FullName))) if (c && strlen(c) == 4 && (!strchr(FullName, '/') || IsWadInFolder(Owner, FullName)))
{ {
// Mark all embedded WADs // Mark all embedded WADs
Flags |= LUMPF_EMBEDDED; Flags |= LUMPF_EMBEDDED;