Merge remote-tracking branch 'gzdoom/master' into big_beautiful_merge

This commit is contained in:
Magnus Norddahl 2025-08-06 21:06:53 +02:00
commit 3fdd22ef91
1433 changed files with 484787 additions and 9566 deletions

View file

@ -121,6 +121,7 @@ public:
static uint32_t LumpNameHash (const char *name); // [RH] Create hash key from an 8-char name
ptrdiff_t FileLength (int lump) const;
uint32_t FileHash (int lump) const;
int GetFileFlags (int lump); // Return the flags for this lump
const char* GetFileShortName(int lump) const;
const char *GetFileFullName (int lump, bool returnshort = true) const; // [RH] Returns the lump's full name

View file

@ -169,6 +169,11 @@ public:
return (entry < NumLumps) ? Entries[entry].Position : 0;
}
size_t GetEntryHash(uint32_t entry)
{
return (entry < NumLumps) ? Entries[entry].CRC32 : 0;
}
// default is the safest reader type.
virtual FileReader GetEntryReader(uint32_t entry, int readertype = READER_NEW, int flags = READERFLAG_SEEKABLE);

View file

@ -337,7 +337,7 @@ FileData F7ZFile::Read(uint32_t entry)
FileReader F7ZFile::GetEntryReader(uint32_t entry, int, int)
{
FileReader fr;
if (entry < 0 || entry >= NumLumps) return fr;
if (entry >= NumLumps) return fr;
auto buffer = Read(entry);
if (buffer.size() > 0)
fr.OpenMemoryArray(buffer);

View file

@ -759,6 +759,24 @@ ptrdiff_t FileSystem::FileLength (int lump) const
return (int)lump_p.resfile->Length(lump_p.resindex);
}
//==========================================================================
//
// FileHash
//
// Returns the file hash.
//
//==========================================================================
uint32_t FileSystem::FileHash (int lump) const
{
if ((size_t)lump >= NumEntries)
{
return -1;
}
const auto &lump_p = FileInfo[lump];
return lump_p.resfile->GetEntryHash(lump_p.resindex);
}
//==========================================================================
//
//
@ -1264,13 +1282,16 @@ void FileSystem::ReadFile (int lump, void *dest)
{
std::unique_lock lock(Mutex);
auto lumpr = OpenFileReader (lump);
auto size = lumpr.GetLength ();
auto numread = lumpr.Read (dest, size);
if (numread != size)
if (lumpr.mReader != nullptr)
{
throw FileSystemException("W_ReadFile: only read %td of %td on '%s'\n",
numread, size, FileInfo[lump].LongName);
auto size = lumpr.GetLength ();
auto numread = lumpr.Read (dest, size);
if (numread != size)
{
throw FileSystemException("W_ReadFile: only read %td of %td on '%s'\n",
numread, size, FileInfo[lump].LongName);
}
}
}