- added a directory list function to the file system.

- fixed lookup for resources by ID - it always picked the first candidate from the hash chain without checking the actual ID.
This commit is contained in:
Christoph Oelckers 2019-12-07 09:44:43 +01:00
parent 7d7507d453
commit ddfb2223db
2 changed files with 16 additions and 23 deletions

View file

@ -48,6 +48,7 @@
#include "filesystem.h"
#include "resourcefile.h"
#include "v_text.h"
#include "c_dispatch.h"
//#include "md5.h"
//#include "doomstat.h"
@ -322,6 +323,7 @@ int FileSystem::FindResource (int resid, const char *type, int filenum) const no
for (i = fli[int(resid) % NumEntries]; i != NULL_INDEX; i = nli[i])
{
if (filenum > 0 && FileInfo[i].rfnum != filenum) continue;
if (FileInfo[i].lump->ResourceId != resid) continue;
auto lump = FileInfo[i].lump;
if (lump->LumpName[lookuptype] == lname) return i;
}
@ -1064,28 +1066,18 @@ static void PrintLastError ()
}
#endif
#if 0
void FileSystem::HashDump()
CCMD(printfs)
{
FILE* f = fopen("fs_hash.txt", "wb");
for (int list = 0; list < 5; list++)
{
fprintf(f, "List %d\n------------\n", list);
auto fli = FirstFileIndex[list];
auto nli = NextFileIndex[list];
for (int hash = 0; hash < NumEntries; hash++)
{
if (fli[hash] != NULL_INDEX)
{
fprintf(f, "\tHash %d\n", hash);
for (uint32_t i = fli[hash]; i != NULL_INDEX; i = nli[i])
{
auto lump = FileInfo[i].lump;
fprintf(f, "\t\t%s (%d)\t%d, %d\n", lump->LumpName[list].GetChars(), lump->LumpName[list].GetIndex(), lump->Size(), i);
}
}
}
}
fclose(f);
fileSystem.PrintDirectory();
}
void FileSystem::PrintDirectory()
{
for (int i = 0; i < NumEntries; i++)
{
auto lump = FileInfo[i].lump;
auto f = GetFileContainer(i);
auto n = GetResourceFileFullName(f);
Printf("%5d: %9d %64s %4s %3d %s\n", i, lump->LumpSize, lump->LumpName[0].GetChars(), lump->LumpName[4].GetChars(), lump->ResourceId, n);
}
}
#endif

View file

@ -148,6 +148,7 @@ public:
{
return FileInfo[lump].lump;
}
void PrintDirectory();
protected: