Skip to content

Commit

Permalink
add missing check for embedded WADs.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Dec 16, 2023
1 parent cffa49d commit 7ce63ab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
39 changes: 27 additions & 12 deletions src/common/filesystem/source/resourcefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ void FResourceFile::PostProcessArchive(LumpFilterInfo *filter)
}

JunkLeftoverFilters(max);

for (uint32_t i = 0; i < NumLumps; i++)
{
CheckEmbedded(i, filter);
}

}

//==========================================================================
Expand Down Expand Up @@ -663,21 +669,30 @@ FileReader FResourceFile::GetEntryReader(uint32_t entry, int readertype, int rea
}
if (!(Entries[entry].Flags & RESFF_COMPRESSED))
{
if (readertype == READER_SHARED && mainThread)
readertype = READER_NEW;
if (readertype == READER_SHARED)
{
fr.OpenFilePart(Reader, Entries[entry].Position, Entries[entry].Length);
}
else if (readertype == READER_NEW)
auto buf = Reader.GetBuffer();
// if this is backed by a memory buffer, create a new reader directly referencing it.
if (buf != nullptr)
{
fr.OpenFile(FileName, Entries[entry].Position, Entries[entry].Length);
fr.OpenMemory(buf + Entries[entry].Position, Entries[entry].Length);
}
else if (readertype == READER_CACHED)
else
{
Reader.Seek(Entries[entry].Position, FileReader::SeekSet);
auto data = Reader.Read(Entries[entry].Length);
fr.OpenMemoryArray(data);
if (readertype == READER_SHARED && !mainThread)
readertype = READER_NEW;
if (readertype == READER_SHARED)
{
fr.OpenFilePart(Reader, Entries[entry].Position, Entries[entry].Length);
}
else if (readertype == READER_NEW)
{
fr.OpenFile(FileName, Entries[entry].Position, Entries[entry].Length);
}
else if (readertype == READER_CACHED)
{
Reader.Seek(Entries[entry].Position, FileReader::SeekSet);
auto data = Reader.Read(Entries[entry].Length);
fr.OpenMemoryArray(data);
}
}
}
else
Expand Down
4 changes: 3 additions & 1 deletion src/d_iwad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,10 @@ FIWadManager::FIWadManager(const char *firstfn, const char *optfn)
std::vector<std::string> fns;
fns.push_back(firstfn);
if (optfn) fns.push_back(optfn);
FileSys::LumpFilterInfo lfi;
GetReserved(lfi);

if (check.InitMultipleFiles(fns, nullptr, nullptr))
if (check.InitMultipleFiles(fns, &lfi, nullptr))
{
int num = check.CheckNumForName("IWADINFO");
if (num >= 0)
Expand Down

0 comments on commit 7ce63ab

Please sign in to comment.