diff --git a/src/resourcefiles/resourcefile.h b/src/resourcefiles/resourcefile.h index 0f51d8d10b..9b39b09082 100644 --- a/src/resourcefiles/resourcefile.h +++ b/src/resourcefiles/resourcefile.h @@ -106,7 +106,8 @@ public: static FResourceFile *OpenResourceFile(const char *filename, bool quiet = false, bool containeronly = false); static FResourceFile *OpenDirectory(const char *filename, bool quiet = false); virtual ~FResourceFile(); - FileReader *GetReader() { return &Reader; } + // If this FResourceFile represents a directory, the Reader object is not usable so don't return it. + FileReader *GetReader() { return Reader.isOpen()? &Reader : nullptr; } uint32_t LumpCount() const { return NumLumps; } uint32_t GetFirstLump() const { return FirstLump; } void SetFirstLump(uint32_t f) { FirstLump = f; } diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 18bf2aa390..e084d4c749 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -1364,9 +1364,7 @@ FileReader *FWadCollection::GetFileReader(int wadnum) return NULL; } - // Return reader for real files only and nullptr otherwise - FileReader* const reader = Files[wadnum]->GetReader(); - return reader->isOpen() ? reader : nullptr; + return Files[wadnum]->GetReader(); } //==========================================================================