mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
- fixed compilation of file system code.
This commit is contained in:
parent
8ef40c5083
commit
d7e183d46d
6 changed files with 48 additions and 38 deletions
|
@ -60,6 +60,7 @@ struct RFFLump
|
|||
uint8_t Flags;
|
||||
char Extension[3];
|
||||
char Name[8];
|
||||
uint32_t ResourceId;
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
@ -71,7 +72,7 @@ struct RFFLump
|
|||
struct FRFFLump : public FUncompressedLump
|
||||
{
|
||||
virtual FileReader *GetReader();
|
||||
int ValidataCache() override;
|
||||
int ValidateCache() override;
|
||||
|
||||
uint32_t IndexNum;
|
||||
};
|
||||
|
@ -205,7 +206,7 @@ int FRFFLump::ValidateCache()
|
|||
{
|
||||
int res = FUncompressedLump::ValidateCache();
|
||||
|
||||
if (res && )(Flags & LUMPF_BLOODCRYPT))
|
||||
if (res && (Flags & LUMPF_BLOODCRYPT))
|
||||
{
|
||||
int cryptlen = std::min<int> (LumpSize, 256);
|
||||
uint8_t *data = Cache.Data();
|
||||
|
|
|
@ -356,7 +356,7 @@ FileReader *FZipLump::GetReader()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FZipLump::ValidataCache()
|
||||
int FZipLump::ValidateCache()
|
||||
{
|
||||
if (Flags & LUMPFZIP_NEEDFILESTART) SetLumpAddress();
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ int FileSystem::FindResource (int resid, const char *type, int filenum) const no
|
|||
FName lname(type, true);
|
||||
if (lname == NAME_None) return -1;
|
||||
|
||||
const int lookuptype = (int)ELookupMode::IdWithType
|
||||
const int lookuptype = (int)ELookupMode::IdWithType;
|
||||
uint32_t* fli = FirstFileIndex[lookuptype];
|
||||
uint32_t* nli = NextFileIndex[lookuptype];
|
||||
|
||||
|
@ -337,7 +337,7 @@ int FileSystem::GetResource (int resid, const char *type, int filenum) const
|
|||
{
|
||||
int i;
|
||||
|
||||
i = FindResource (resid, type, lookupmode, filenum);
|
||||
i = FindResource (resid, type, filenum);
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
|
@ -450,7 +450,7 @@ void FileSystem::AddLump(FResourceLump *lump)
|
|||
hash = int(lump->ResourceId) % NumEntries;
|
||||
}
|
||||
NextFileIndex[l][hash] = FirstFileIndex[l][hash];
|
||||
FirstFileIndex[l][hash] = i;
|
||||
FirstFileIndex[l][hash] = FileInfo.Size() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ unsigned FileSystem::GetFilesInFolder(const char *inpath, TArray<FolderEntry> &r
|
|||
TArray<uint8_t> FileSystem::GetFileData(int lump, int pad)
|
||||
{
|
||||
if ((size_t)lump >= FileInfo.Size())
|
||||
return TArray<<uint8_t>();
|
||||
return TArray<uint8_t>();
|
||||
|
||||
auto lumpr = OpenFileReader(lump);
|
||||
auto size = lumpr.GetLength();
|
||||
|
@ -656,22 +656,22 @@ TArray<uint8_t> FileSystem::GetFileData(int lump, int pad)
|
|||
const void *FileSystem::Lock(int lump)
|
||||
{
|
||||
if ((size_t)lump >= FileInfo.Size()) return nullptr;
|
||||
auto lump = FileInfo[lump].lump;
|
||||
return lump->Lock();
|
||||
auto lumpp = FileInfo[lump].lump;
|
||||
return lumpp->Lock();
|
||||
}
|
||||
|
||||
void FileSystem::Unlock(bool mayfree)
|
||||
void FileSystem::Unlock(int lump, bool mayfree)
|
||||
{
|
||||
if ((size_t)lump >= FileInfo.Size()) return;
|
||||
auto lump = FileInfo[lump].lump;
|
||||
lump->Unlock(maxfree);
|
||||
auto lumpp = FileInfo[lump].lump;
|
||||
lumpp->Unlock(mayfree);
|
||||
}
|
||||
|
||||
const void *FileSystem::Get(int lump)
|
||||
{
|
||||
if ((size_t)lump >= FileInfo.Size()) return nullptr;
|
||||
auto lump = FileInfo[lump].lump;
|
||||
return lump->Get();
|
||||
auto lumpp = FileInfo[lump].lump;
|
||||
return lumpp->Get();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -680,9 +680,10 @@ const void *FileSystem::Get(int lump)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void *FileSystem::Lock(FResourceLump *lump)
|
||||
const void *FileSystem::Lock(FResourceLump *lump)
|
||||
{
|
||||
if (lump) return lump->Lock();
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
void FileSystem::Unlock(FResourceLump *lump)
|
||||
|
@ -690,9 +691,10 @@ void FileSystem::Unlock(FResourceLump *lump)
|
|||
if (lump) return lump->Unlock();
|
||||
}
|
||||
|
||||
void FileSystem::Load(FResourceLump *lump)
|
||||
const void *FileSystem::Load(FResourceLump *lump)
|
||||
{
|
||||
if (lump) return lump->Get();
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -890,13 +892,14 @@ FResourceLump *FileSystem::Lookup(const char *name, const char *type)
|
|||
FStringf fname("%s.%s", name, type);
|
||||
auto lump = FindFile(fname);
|
||||
if (lump >= 0) return FileInfo[lump].lump;
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
FResourceLump *FileSystem::Lookup(unsigned int id, const char *type)
|
||||
{
|
||||
auto lump = FindResource(id, type);
|
||||
auto lump = FindFile(fname);
|
||||
if (lump >= 0) return FileInfo[lump].lump;
|
||||
else return nullptr;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
#include "tarray.h"
|
||||
#include "zstring.h"
|
||||
|
||||
#ifdef FindResource
|
||||
#undef FindResource
|
||||
#endif
|
||||
|
||||
// We do not want to expose the resource file interface here.
|
||||
class FResourceFile;
|
||||
struct FResourceLump;
|
||||
|
@ -107,13 +111,13 @@ public:
|
|||
FileData ReadFile (const char *name) { return ReadFile (GetFile (name)); }
|
||||
|
||||
const void *Lock(int lump);
|
||||
void Unlock(bool mayfree = false);
|
||||
void *Get(int lump);
|
||||
void Unlock(int lump, bool mayfree = false);
|
||||
const void *Get(int lump);
|
||||
|
||||
// These are designed to be stand-ins for Blood's resource class.
|
||||
static void *Lock(FResourceLump *lump);
|
||||
static const void *Lock(FResourceLump *lump);
|
||||
static void Unlock(FResourceLump *lump);
|
||||
static void *Load(FResourceLump *lump);
|
||||
static const void *Load(FResourceLump *lump);
|
||||
static void Read(FResourceLump *lump) { Load(lump); }
|
||||
static void Read(FResourceLump *n, void *p);
|
||||
FResourceLump *Lookup(const char *name, const char *type);
|
||||
|
@ -158,6 +162,7 @@ protected:
|
|||
uint32_t NumEntries; // Hash modulus. Can be smaller than NumFiles if things get added at run time.
|
||||
|
||||
void InitHashChains (); // [RH] Set up the lumpinfo hashing
|
||||
void AddLump(FResourceLump* lump);
|
||||
|
||||
private:
|
||||
void DeleteAll();
|
||||
|
|
|
@ -54,13 +54,13 @@ public:
|
|||
FLumpReader(FResourceLump *src)
|
||||
: MemoryReader(NULL, src->LumpSize), source(src)
|
||||
{
|
||||
src->CacheLump();
|
||||
bufptr = (const char*)src->Cache.Data();
|
||||
bufptr = (const char*)src->Lock();
|
||||
src->Cache.Data();
|
||||
}
|
||||
|
||||
~FLumpReader()
|
||||
{
|
||||
source->ReleaseCache();
|
||||
source->Unlock(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -154,7 +154,7 @@ void *FResourceLump::Lock()
|
|||
}
|
||||
else if (LumpSize > 0)
|
||||
{
|
||||
ValidateCache()
|
||||
ValidateCache();
|
||||
RefCount++;
|
||||
}
|
||||
return Cache.Data();
|
||||
|
@ -170,7 +170,7 @@ void *FResourceLump::Get()
|
|||
{
|
||||
if (Cache.Size() == 0)
|
||||
{
|
||||
ValidateCache()
|
||||
ValidateCache();
|
||||
}
|
||||
return Cache.Data();
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ void *FResourceLump::Get()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FResourceLump::Unlock(bool mayfree)
|
||||
void FResourceLump::Unlock(bool mayfree)
|
||||
{
|
||||
if (LumpSize > 0 && RefCount > 0)
|
||||
{
|
||||
|
@ -190,7 +190,6 @@ int FResourceLump::Unlock(bool mayfree)
|
|||
if (mayfree) Cache.Reset();
|
||||
}
|
||||
}
|
||||
return RefCount;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <stdint.h>
|
||||
#include "files.h"
|
||||
#include "zstring.h"
|
||||
#include "name.h"
|
||||
|
||||
class FResourceFile;
|
||||
class FTexture;
|
||||
|
@ -56,6 +57,7 @@ struct FResourceLump
|
|||
};
|
||||
|
||||
friend class FResourceFile;
|
||||
friend struct FClonedLump;
|
||||
|
||||
unsigned LumpSize = 0;
|
||||
int RefCount = 0;
|
||||
|
@ -81,9 +83,9 @@ struct FResourceLump
|
|||
// Wrappers for emulating Blood's resource system
|
||||
unsigned Size() const{ return LumpSize; }
|
||||
int LockCount() const { return RefCount; }
|
||||
const char *ResName() const { return LumpName[BaseNameNoExtType]; } needed
|
||||
const char *ResName() const { return LumpName[BaseNameNoExtType]; }
|
||||
const char *ResType() { return LumpName[ExtensionType]; }
|
||||
const char *FullName() const { return LumpName[FullNameType]; } needed
|
||||
const char *FullName() const { return LumpName[FullNameType]; }
|
||||
|
||||
protected:
|
||||
virtual int ValidateCache() { return -1; }
|
||||
|
@ -167,7 +169,7 @@ struct FExternalLump : public FResourceLump
|
|||
|
||||
struct FMemoryLump : public FResourceLump
|
||||
{
|
||||
FMemoryLump(const void *data, int length)
|
||||
FMemoryLump(const void* data, int length)
|
||||
{
|
||||
Cache.Resize(length);
|
||||
memcpy(Cache.Data(), data, length);
|
||||
|
@ -177,20 +179,20 @@ struct FMemoryLump : public FResourceLump
|
|||
RefCount = INT_MAX / 2; // Make sure it never counts down to 0 by resetting it to something high each time it is used.
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct FClonedLump : public FResourceLump
|
||||
{
|
||||
FResourceLump *parent;
|
||||
FClonedLump(FResourceLump *lump)
|
||||
FResourceLump* parent;
|
||||
FClonedLump(FResourceLump* lump)
|
||||
{
|
||||
parent = lump;
|
||||
}
|
||||
void *Lock() { return parent->Lock(); }
|
||||
void* Lock() { return parent->Lock(); }
|
||||
void Unlock(bool mayfree) override { parent->Unlock(mayfree); }
|
||||
void *Get() { return parent->Get(); }
|
||||
void ValidateCache() override { parent->ValidateCache(); }
|
||||
}
|
||||
void* Get() { return parent->Get(); }
|
||||
int ValidateCache() override { return parent->ValidateCache(); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue