2009-04-23 22:49:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef __RESFILE_H
|
|
|
|
#define __RESFILE_H
|
|
|
|
|
|
|
|
#include "files.h"
|
|
|
|
|
|
|
|
class FResourceFile;
|
2014-05-13 18:51:16 +00:00
|
|
|
class FTexture;
|
2009-04-23 22:49:38 +00:00
|
|
|
|
|
|
|
struct FResourceLump
|
|
|
|
{
|
|
|
|
friend class FResourceFile;
|
|
|
|
|
|
|
|
int LumpSize;
|
2015-04-04 00:59:42 +00:00
|
|
|
FString FullName; // only valid for files loaded from a non-wad archive
|
2009-08-02 03:38:57 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
char Name[9];
|
|
|
|
|
|
|
|
DWORD dwName; // These are for accessing the first 4 or 8 chars of
|
|
|
|
QWORD qwName; // Name as a unit without breaking strict aliasing rules
|
|
|
|
};
|
2009-04-23 22:49:38 +00:00
|
|
|
BYTE Flags;
|
2009-04-26 18:12:40 +00:00
|
|
|
SBYTE RefCount;
|
2009-04-23 22:49:38 +00:00
|
|
|
char * Cache;
|
|
|
|
FResourceFile * Owner;
|
2014-05-13 18:51:16 +00:00
|
|
|
FTexture * LinkedTexture;
|
2009-04-23 22:49:38 +00:00
|
|
|
int Namespace;
|
|
|
|
|
|
|
|
FResourceLump()
|
|
|
|
{
|
|
|
|
Cache = NULL;
|
|
|
|
Owner = NULL;
|
|
|
|
Flags = 0;
|
|
|
|
RefCount = 0;
|
|
|
|
Namespace = 0; // ns_global
|
|
|
|
*Name = 0;
|
2014-05-13 18:51:16 +00:00
|
|
|
LinkedTexture = NULL;
|
2009-04-23 22:49:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~FResourceLump();
|
|
|
|
virtual FileReader *GetReader();
|
|
|
|
virtual FileReader *NewReader();
|
|
|
|
virtual int GetFileOffset() { return -1; }
|
2010-03-18 05:01:10 +00:00
|
|
|
virtual int GetIndexNum() const { return 0; }
|
2009-05-31 10:49:47 +00:00
|
|
|
void LumpNameSetup(const char *iname);
|
2009-04-23 22:49:38 +00:00
|
|
|
void CheckEmbedded();
|
|
|
|
|
|
|
|
void *CacheLump();
|
|
|
|
int ReleaseCache();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual int FillCache() = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class FResourceFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FileReader *Reader;
|
|
|
|
const char *Filename;
|
|
|
|
protected:
|
|
|
|
DWORD NumLumps;
|
|
|
|
|
|
|
|
FResourceFile(const char *filename, FileReader *r);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DWORD FirstLump;
|
|
|
|
|
|
|
|
public:
|
2009-05-30 09:53:38 +00:00
|
|
|
static FResourceFile *OpenResourceFile(const char *filename, FileReader *file, bool quiet = false);
|
2010-01-01 15:31:00 +00:00
|
|
|
static FResourceFile *OpenDirectory(const char *filename, bool quiet = false);
|
2009-04-23 22:49:38 +00:00
|
|
|
virtual ~FResourceFile();
|
|
|
|
FileReader *GetReader() const { return Reader; }
|
|
|
|
DWORD LumpCount() const { return NumLumps; }
|
|
|
|
DWORD GetFirstLump() const { return FirstLump; }
|
|
|
|
void SetFirstLump(DWORD f) { FirstLump = f; }
|
2015-04-04 01:22:18 +00:00
|
|
|
void PostProcessArchive(void *lumps, size_t lumpsize); // for archives that can contain directories
|
2009-04-23 22:49:38 +00:00
|
|
|
|
|
|
|
virtual void FindStrifeTeaserVoices ();
|
2009-05-30 09:53:38 +00:00
|
|
|
virtual bool Open(bool quiet) = 0;
|
2009-04-23 22:49:38 +00:00
|
|
|
virtual FResourceLump *GetLump(int no) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FUncompressedLump : public FResourceLump
|
|
|
|
{
|
|
|
|
int Position;
|
|
|
|
|
|
|
|
virtual FileReader *GetReader();
|
|
|
|
virtual int FillCache();
|
|
|
|
virtual int GetFileOffset() { return Position; }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Base class for uncompressed resource files (WAD, GRP, PAK and single lumps)
|
|
|
|
class FUncompressedFile : public FResourceFile
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
FUncompressedLump * Lumps;
|
|
|
|
|
|
|
|
|
|
|
|
FUncompressedFile(const char *filename, FileReader *r);
|
|
|
|
virtual ~FUncompressedFile();
|
|
|
|
virtual FResourceLump *GetLump(int no) { return ((unsigned)no < NumLumps)? &Lumps[no] : NULL; }
|
|
|
|
|
|
|
|
public:
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct FExternalLump : public FResourceLump
|
|
|
|
{
|
|
|
|
const char *filename; // the actual file name. This is not necessarily the same as the lump name!
|
|
|
|
|
|
|
|
FExternalLump(const char *_filename, int filesize = -1);
|
|
|
|
~FExternalLump();
|
|
|
|
virtual int FillCache();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|