- do not load subdirectories of the game directory. They cannot contain anything useful because the original assets never used subdirectories.

- fixed RRRA game flags.
This commit is contained in:
Christoph Oelckers 2019-11-02 19:12:01 +01:00
parent c5838df0c8
commit 4cf62fca77
7 changed files with 26 additions and 18 deletions

View file

@ -72,12 +72,13 @@ struct FDirectoryLump : public FResourceLump
class FDirectory : public FResourceFile
{
TArray<FDirectoryLump> Lumps;
const bool nosubdir;
int AddDirectory(const char *dirpath);
void AddEntry(const char *fullpath, int size);
public:
FDirectory(const char * dirname);
FDirectory(const char * dirname, bool nosubdirflag);
bool Open(bool quiet);
virtual FResourceLump *GetLump(int no) { return ((unsigned)no < NumLumps)? &Lumps[no] : NULL; }
};
@ -90,8 +91,8 @@ public:
//
//==========================================================================
FDirectory::FDirectory(const char * directory)
: FResourceFile(NULL)
FDirectory::FDirectory(const char * directory, bool nosubdirflag)
: FResourceFile(NULL), nosubdir(nosubdirflag)
{
FString dirname;
@ -144,11 +145,11 @@ int FDirectory::AddDirectory(const char *dirpath)
if (fileinfo.attrib & _A_SUBDIR)
{
if (fi[0] == '.' &&
if (nosubdir || (fi[0] == '.' &&
(fi[1] == '\0' ||
(fi[1] == '.' && fi[2] == '\0')))
(fi[1] == '.' && fi[2] == '\0'))))
{
// Do not record . and .. directories.
// Skip if requested and do not record . and .. directories.
continue;
}
FString newdir = dirpath;
@ -320,9 +321,9 @@ int FDirectoryLump::ValidateCache()
//
//==========================================================================
FResourceFile *CheckDir(const char *filename, bool quiet)
FResourceFile *CheckDir(const char *filename, bool quiet, bool nosubdirflag)
{
FResourceFile *rf = new FDirectory(filename);
FResourceFile *rf = new FDirectory(filename, nosubdirflag);
if (rf->Open(quiet)) return rf;
delete rf;
return NULL;

View file

@ -111,7 +111,14 @@ int FileSystem::InitMultipleFiles (TArray<FString> &filenames, const TArray<FStr
for(unsigned i=0;i<filenames.Size(); i++)
{
int baselump = NumEntries;
AddFile (filenames[i]);
bool nosubdirflag = false;
const char* fn = filenames[i];
if (*fn == '*')
{
fn++;
nosubdirflag = true;
}
AddFile (filenames[i], nullptr, nosubdirflag);
}
NumEntries = FileInfo.Size();
@ -139,7 +146,7 @@ int FileSystem::InitMultipleFiles (TArray<FString> &filenames, const TArray<FStr
//
//==========================================================================
void FileSystem::AddFile (const char *filename, FileReader *filer)
void FileSystem::AddFile (const char *filename, FileReader *filer, bool nosubdirflag)
{
int startlump;
bool isdir = false;
@ -175,7 +182,7 @@ void FileSystem::AddFile (const char *filename, FileReader *filer)
if (!isdir)
resfile = FResourceFile::OpenResourceFile(filename, fr);
else
resfile = FResourceFile::OpenDirectory(filename);
resfile = FResourceFile::OpenDirectory(filename, false, nosubdirflag);
if (resfile != NULL)
{

View file

@ -82,7 +82,7 @@ public:
~FileSystem ();
int InitMultipleFiles (TArray<FString> &filenames, const TArray<FString> &todelete);
void AddFile (const char *filename, FileReader *wadinfo = NULL);
void AddFile (const char *filename, FileReader *wadinfo = NULL, bool nosubdirflag = false);
void AddAdditionalFile(const char* filename, FileReader* wadinfo = NULL) {}
int CheckIfResourceFileLoaded (const char *name) noexcept;

View file

@ -209,7 +209,7 @@ FResourceFile *CheckPak(const char *filename, FileReader &file, bool quiet);
FResourceFile *CheckZip(const char *filename, FileReader &file, bool quiet);
FResourceFile *Check7Z(const char *filename, FileReader &file, bool quiet);
FResourceFile *CheckLump(const char *filename,FileReader &file, bool quiet);
FResourceFile *CheckDir(const char *filename, bool quiet);
FResourceFile *CheckDir(const char *filename, bool quiet, bool nosubdirflag);
static CheckFunc funcs[] = { CheckGRP, CheckRFF, CheckZip, Check7Z, CheckPak, CheckLump };
@ -244,9 +244,9 @@ FResourceFile *FResourceFile::OpenResourceFileFromLump(int lumpnum, bool quiet,
}
*/
FResourceFile *FResourceFile::OpenDirectory(const char *filename, bool quiet)
FResourceFile *FResourceFile::OpenDirectory(const char *filename, bool quiet, bool nosubdirflag)
{
return CheckDir(filename, quiet);
return CheckDir(filename, quiet, nosubdirflag);
}
//==========================================================================

View file

@ -120,7 +120,7 @@ private:
public:
static FResourceFile *OpenResourceFile(const char *filename, FileReader &file, bool quiet = false, bool containeronly = false);
static FResourceFile *OpenResourceFile(const char *filename, bool quiet = false, bool containeronly = false);
static FResourceFile *OpenDirectory(const char *filename, bool quiet = false);
static FResourceFile* OpenDirectory(const char* filename, bool quiet = false, bool nosubdirs = false);
virtual ~FResourceFile();
// If this FResourceFile represents a directory, the Reader object is not usable so don't return it.
FileReader *GetReader() { return Reader.isOpen()? &Reader : nullptr; }

View file

@ -329,7 +329,7 @@ void InitFileSystem(TArray<GrpEntry>& groups)
// Do this only if explicitly requested because this severely limits the usability of GRP files.
if (insertdirectoriesafter) for (auto& file : *userConfig.AddFilesPre)
{
D_AddFile(Files, file);
D_AddFile(Files, '*' + file); // The * tells the file system not to pull in all subdirectories.
}
D_AddFile(Files, fn);

View file

@ -321,7 +321,7 @@ grpinfo
size 191798609
crc RRRA_CRC
defname "rrra.def"
flags GAMEFLAG_RRRA
flags GAMEFLAG_RRRA|GAMEFLAG_RR
dependency 0
gamefilter "Redneck.RidesAgain"
}