From 9b95c134a766995dbb90a38fcad618384c3170df Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 9 Apr 2015 09:14:53 +0200 Subject: [PATCH] - fixed: Lumps from a directory need to store the full file path so that they still can be accessed when the internal path is changed due to a filter directory. --- src/resourcefiles/file_directory.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/resourcefiles/file_directory.cpp b/src/resourcefiles/file_directory.cpp index f6adf0723..2be8da1b1 100644 --- a/src/resourcefiles/file_directory.cpp +++ b/src/resourcefiles/file_directory.cpp @@ -72,7 +72,7 @@ struct FDirectoryLump : public FResourceLump virtual FileReader *NewReader(); virtual int FillCache(); -private: + FString mFullPath; }; @@ -300,6 +300,8 @@ void FDirectory::AddEntry(const char *fullpath, int size) { FDirectoryLump *lump_p = &Lumps[Lumps.Reserve(1)]; + // Store the full path here so that we can access the file later, even if it is from a filter directory. + lump_p->mFullPath = fullpath; // The lump's name is only the part relative to the main directory lump_p->LumpNameSetup(fullpath + strlen(Filename)); lump_p->LumpSize = size; @@ -319,9 +321,7 @@ FileReader *FDirectoryLump::NewReader() { try { - FString fullpath = Owner->Filename; - fullpath += FullName; - return new FileReader(fullpath); + return new FileReader(mFullPath); } catch (CRecoverableError &) { @@ -339,6 +339,11 @@ int FDirectoryLump::FillCache() { Cache = new char[LumpSize]; FileReader *reader = NewReader(); + if (reader == NULL) + { + memset(Cache, 0, sizeof(Cache)); + return 0; + } reader->Read(Cache, LumpSize); delete reader; RefCount = 1;