- 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.

This commit is contained in:
Christoph Oelckers 2015-04-09 09:14:53 +02:00
parent 6428b399d6
commit 9b95c134a7

View file

@ -72,7 +72,7 @@ struct FDirectoryLump : public FResourceLump
virtual FileReader *NewReader(); virtual FileReader *NewReader();
virtual int FillCache(); 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)]; 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 // The lump's name is only the part relative to the main directory
lump_p->LumpNameSetup(fullpath + strlen(Filename)); lump_p->LumpNameSetup(fullpath + strlen(Filename));
lump_p->LumpSize = size; lump_p->LumpSize = size;
@ -319,9 +321,7 @@ FileReader *FDirectoryLump::NewReader()
{ {
try try
{ {
FString fullpath = Owner->Filename; return new FileReader(mFullPath);
fullpath += FullName;
return new FileReader(fullpath);
} }
catch (CRecoverableError &) catch (CRecoverableError &)
{ {
@ -339,6 +339,11 @@ int FDirectoryLump::FillCache()
{ {
Cache = new char[LumpSize]; Cache = new char[LumpSize];
FileReader *reader = NewReader(); FileReader *reader = NewReader();
if (reader == NULL)
{
memset(Cache, 0, sizeof(Cache));
return 0;
}
reader->Read(Cache, LumpSize); reader->Read(Cache, LumpSize);
delete reader; delete reader;
RefCount = 1; RefCount = 1;