mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-21 18:31:10 +00:00
use the FResourceFile interface in favor of FResourceLump's where possible.
This commit is contained in:
parent
5c04185d5a
commit
749d4e3acb
4 changed files with 19 additions and 25 deletions
|
@ -174,7 +174,6 @@ public:
|
|||
int AddFromBuffer(const char* name, const char* type, char* data, int size, int id, int flags);
|
||||
FileReader* GetFileReader(int wadnum); // Gets a FileReader object to the entire WAD
|
||||
void InitHashChains();
|
||||
FResourceLump* GetFileAt(int no);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -226,7 +226,12 @@ public:
|
|||
{
|
||||
auto l = GetLump(entry);
|
||||
return l ? l->NewReader() : FileReader();
|
||||
}
|
||||
|
||||
int GetEntryFlags(int entry)
|
||||
{
|
||||
auto l = GetLump(entry);
|
||||
return l ? l->Flags : 0;
|
||||
}
|
||||
|
||||
ResourceData Read(int entry)
|
||||
|
|
|
@ -421,13 +421,13 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf
|
|||
|
||||
for (uint32_t i=0; i < resfile->EntryCount(); i++)
|
||||
{
|
||||
FResourceLump *lump = resfile->GetLump(i);
|
||||
if (lump->Flags & LUMPF_EMBEDDED)
|
||||
int flags = resfile->GetEntryFlags(i);
|
||||
if (flags & LUMPF_EMBEDDED)
|
||||
{
|
||||
std::string path = filename;
|
||||
path += ':';
|
||||
path += lump->getName();
|
||||
auto embedded = lump->NewReader();
|
||||
path += resfile->getName(i);
|
||||
auto embedded = resfile->GetEntryReader(i, true);
|
||||
AddFile(path.c_str(), &embedded, filter, Printf, hashfile);
|
||||
}
|
||||
}
|
||||
|
@ -456,11 +456,10 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf
|
|||
|
||||
for (uint32_t i = 0; i < resfile->EntryCount(); i++)
|
||||
{
|
||||
FResourceLump *lump = resfile->GetLump(i);
|
||||
|
||||
if (!(lump->Flags & LUMPF_EMBEDDED))
|
||||
int flags = resfile->GetEntryFlags(i);
|
||||
if (!(flags & LUMPF_EMBEDDED))
|
||||
{
|
||||
auto reader = lump->NewReader();
|
||||
auto reader = resfile->GetEntryReader(i, true);
|
||||
md5Hash(filereader, cksum);
|
||||
|
||||
for (size_t j = 0; j < sizeof(cksum); ++j)
|
||||
|
@ -468,7 +467,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf
|
|||
snprintf(cksumout + (j * 2), 3, "%02X", cksum[j]);
|
||||
}
|
||||
|
||||
fprintf(hashfile, "file: %s, lump: %s, hash: %s, size: %d\n", filename, lump->getName(), cksumout, lump->LumpSize);
|
||||
fprintf(hashfile, "file: %s, lump: %s, hash: %s, size: %llu\n", filename, resfile->getName(i), cksumout, (uint64_t)resfile->Length(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1592,15 +1591,5 @@ static void PrintLastError (FileSystemMessageFunc Printf)
|
|||
}
|
||||
#endif
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// NBlood style lookup functions
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FResourceLump* FileSystem::GetFileAt(int no)
|
||||
{
|
||||
return FileInfo[no].lump;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -360,13 +360,13 @@ int lumpcmp(const void * a, const void * b)
|
|||
//
|
||||
// Generates a hash identifier for use in file identification.
|
||||
// Potential uses are mod-wide compatibility settings or localization add-ons.
|
||||
// This only hashes the lump directory but not the actual content
|
||||
// This only hashes the directory but not the actual content
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FResourceFile::GenerateHash()
|
||||
{
|
||||
// hash the lump directory after sorting
|
||||
// hash the directory after sorting
|
||||
using namespace FileSys::md5;
|
||||
|
||||
auto n = snprintf(Hash, 48, "%08X-%04X-", (unsigned)Reader.GetLength(), NumLumps);
|
||||
|
@ -377,9 +377,10 @@ void FResourceFile::GenerateHash()
|
|||
uint8_t digest[16];
|
||||
for(uint32_t i = 0; i < NumLumps; i++)
|
||||
{
|
||||
auto lump = GetLump(i);
|
||||
md5_append(&state, (const uint8_t*)lump->FullName, (unsigned)strlen(lump->FullName) + 1);
|
||||
md5_append(&state, (const uint8_t*)&lump->LumpSize, 4);
|
||||
auto name = getName(i);
|
||||
auto size = Length(i);
|
||||
md5_append(&state, (const uint8_t*)name, (unsigned)strlen(name) + 1);
|
||||
md5_append(&state, (const uint8_t*)&size, sizeof(size));
|
||||
}
|
||||
md5_finish(&state, digest);
|
||||
for (auto c : digest)
|
||||
|
|
Loading…
Reference in a new issue