From 9df56216b32617509d79c212ddfce8df290d74c7 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 12 Jan 2015 11:28:40 +0200 Subject: [PATCH] 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 --- src/resourcefiles/resourcefile.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index 24b3ad3d68..15a4337b1d 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -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 was put in - // directory inside + // Checks a special case when was put in + // directory inside - const FString baseName = ExtractFileBase(fullName); - const FString fileName = baseName + '/' + baseName + ".wad"; + if (NULL == archive) + { + 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() { // Checks for embedded archives 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 Flags |= LUMPF_EMBEDDED;