merge FileData and ResourceData.

This commit is contained in:
Christoph Oelckers 2023-12-10 22:30:54 +01:00
parent d2cb44b1bf
commit fe106d9bfe
38 changed files with 77 additions and 118 deletions

View file

@ -182,8 +182,8 @@ static void SetupGenMidi()
} }
auto genmidi = fileSystem.ReadFile(lump); auto genmidi = fileSystem.ReadFile(lump);
if (genmidi.GetSize() < 8 + 175 * 36 || memcmp(genmidi.GetMem(), "#OPL_II#", 8)) return; if (genmidi.size() < 8 + 175 * 36 || memcmp(genmidi.data(), "#OPL_II#", 8)) return;
ZMusic_SetGenMidi(genmidi.GetBytes() + 8); ZMusic_SetGenMidi(genmidi.bytes() + 8);
} }
static void SetupWgOpn() static void SetupWgOpn()
@ -194,7 +194,7 @@ static void SetupWgOpn()
return; return;
} }
auto data = fileSystem.ReadFile(lump); auto data = fileSystem.ReadFile(lump);
ZMusic_SetWgOpn(data.GetMem(), (uint32_t)data.GetSize()); ZMusic_SetWgOpn(data.data(), (uint32_t)data.size());
} }
static void SetupDMXGUS() static void SetupDMXGUS()
@ -206,7 +206,7 @@ static void SetupDMXGUS()
return; return;
} }
auto data = fileSystem.ReadFile(lump); auto data = fileSystem.ReadFile(lump);
ZMusic_SetDmxGus(data.GetMem(), (uint32_t)data.GetSize()); ZMusic_SetDmxGus(data.data(), (uint32_t)data.size());
} }
#endif #endif

View file

@ -153,7 +153,7 @@ class AnmPlayer : public MoviePlayer
{ {
// This doesn't need its own class type // This doesn't need its own class type
anim_t anim; anim_t anim;
FileSys::ResourceData buffer; FileSys::FileData buffer;
int numframes = 0; int numframes = 0;
int curframe = 1; int curframe = 1;
int frametime = 0; int frametime = 0;

View file

@ -63,8 +63,8 @@ void FStringTable::LoadStrings (const char *language)
{ {
auto lumpdata = fileSystem.ReadFile(lump); auto lumpdata = fileSystem.ReadFile(lump);
if (!ParseLanguageCSV(lump, lumpdata.GetString(), lumpdata.GetSize())) if (!ParseLanguageCSV(lump, lumpdata.string(), lumpdata.size()))
LoadLanguage (lump, lumpdata.GetString(), lumpdata.GetSize()); LoadLanguage (lump, lumpdata.string(), lumpdata.size());
} }
UpdateLanguage(language); UpdateLanguage(language);
allMacros.Clear(); allMacros.Clear();
@ -160,7 +160,7 @@ TArray<TArray<FString>> FStringTable::parseCSV(const char* buffer, size_t size)
bool FStringTable::readMacros(int lumpnum) bool FStringTable::readMacros(int lumpnum)
{ {
auto lumpdata = fileSystem.ReadFile(lumpnum); auto lumpdata = fileSystem.ReadFile(lumpnum);
auto data = parseCSV(lumpdata.GetString(), lumpdata.GetSize()); auto data = parseCSV(lumpdata.string(), lumpdata.size());
for (unsigned i = 1; i < data.Size(); i++) for (unsigned i = 1; i < data.Size(); i++)
{ {

View file

@ -91,7 +91,7 @@ enum
class FileReader; class FileReader;
// an opaque memory buffer to the file's content. Can either own the memory or just point to an external buffer. // an opaque memory buffer to the file's content. Can either own the memory or just point to an external buffer.
class ResourceData class FileData
{ {
void* memory; void* memory;
size_t length; size_t length;
@ -99,13 +99,13 @@ class ResourceData
public: public:
using value_type = uint8_t; using value_type = uint8_t;
ResourceData() { memory = nullptr; length = 0; owned = true; } FileData() { memory = nullptr; length = 0; owned = true; }
const void* data() const { return memory; } const void* data() const { return memory; }
size_t size() const { return length; } size_t size() const { return length; }
const char* string() const { return (const char*)memory; } const char* string() const { return (const char*)memory; }
const uint8_t* bytes() const { return (const uint8_t*)memory; } const uint8_t* bytes() const { return (const uint8_t*)memory; }
ResourceData& operator = (const ResourceData& copy) FileData& operator = (const FileData& copy)
{ {
if (owned && memory) free(memory); if (owned && memory) free(memory);
length = copy.length; length = copy.length;
@ -119,7 +119,7 @@ public:
return *this; return *this;
} }
ResourceData& operator = (ResourceData&& copy) noexcept FileData& operator = (FileData&& copy) noexcept
{ {
if (owned && memory) free(memory); if (owned && memory) free(memory);
length = copy.length; length = copy.length;
@ -131,13 +131,13 @@ public:
return *this; return *this;
} }
ResourceData(const ResourceData& copy) FileData(const FileData& copy)
{ {
memory = nullptr; memory = nullptr;
*this = copy; *this = copy;
} }
~ResourceData() ~FileData()
{ {
if (owned && memory) free(memory); if (owned && memory) free(memory);
} }
@ -254,7 +254,7 @@ public:
bool OpenMemory(const void *mem, Size length); // read directly from the buffer bool OpenMemory(const void *mem, Size length); // read directly from the buffer
bool OpenMemoryArray(const void *mem, Size length); // read from a copy of the buffer. bool OpenMemoryArray(const void *mem, Size length); // read from a copy of the buffer.
bool OpenMemoryArray(std::vector<uint8_t>& data); // take the given array bool OpenMemoryArray(std::vector<uint8_t>& data); // take the given array
bool OpenMemoryArray(ResourceData& data); // take the given array bool OpenMemoryArray(FileData& data); // take the given array
bool OpenMemoryArray(std::function<bool(std::vector<uint8_t>&)> getter); // read contents to a buffer and return a reader to it bool OpenMemoryArray(std::function<bool(std::vector<uint8_t>&)> getter); // read contents to a buffer and return a reader to it
bool OpenDecompressor(FileReader &parent, Size length, int method, bool seekable, bool exceptions = false); // creates a decompressor stream. 'seekable' uses a buffered version so that the Seek and Tell methods can be used. bool OpenDecompressor(FileReader &parent, Size length, int method, bool seekable, bool exceptions = false); // creates a decompressor stream. 'seekable' uses a buffered version so that the Seek and Tell methods can be used.
@ -273,9 +273,9 @@ public:
return mReader->Read(buffer, len); return mReader->Read(buffer, len);
} }
ResourceData Read(size_t len) FileData Read(size_t len)
{ {
ResourceData buffer; FileData buffer;
if (len > 0) if (len > 0)
{ {
Size length = mReader->Read(buffer.allocate(len), len); Size length = mReader->Read(buffer.allocate(len), len);
@ -284,15 +284,15 @@ public:
return buffer; return buffer;
} }
ResourceData Read() FileData Read()
{ {
return Read(GetLength()); return Read(GetLength());
} }
ResourceData ReadPadded(size_t padding) FileData ReadPadded(size_t padding)
{ {
auto len = GetLength(); auto len = GetLength();
ResourceData buffer; FileData buffer;
if (len > 0) if (len > 0)
{ {

View file

@ -22,42 +22,6 @@ union LumpShortName
}; };
// A lump in memory.
class FileData
{
public:
FileData() { lump = nullptr; }
const void *GetMem () { return lump->Cache; }
size_t GetSize () { return lump->LumpSize; }
const char* GetString () const { return (const char*)lump->Cache; }
const uint8_t* GetBytes() const { return (const uint8_t*)lump->Cache; }
FileData& operator = (const FileData& copy) = delete;
FileData(const FileData& copy)
{
lump = copy.lump;
lump->Lock();
}
~FileData()
{
if (lump) lump->Unlock();
}
private:
FileData(FResourceLump* nlump)
{
lump = nlump;
if (lump) lump->Lock();
}
FResourceLump* lump;
friend class FileSystem;
};
struct FolderEntry struct FolderEntry
{ {
const char *name; const char *name;

View file

@ -249,7 +249,7 @@ public:
return l ? l->GetIndexNum() : 0; return l ? l->GetIndexNum() : 0;
} }
ResourceData Read(int entry) FileData Read(int entry)
{ {
auto fr = GetEntryReader(entry, false); auto fr = GetEntryReader(entry, false);
return fr.Read(); return fr.Read();

View file

@ -406,10 +406,10 @@ bool FileReader::OpenMemoryArray(std::vector<uint8_t>& data)
return true; return true;
} }
bool FileReader::OpenMemoryArray(ResourceData& data) bool FileReader::OpenMemoryArray(FileData& data)
{ {
Close(); Close();
if (data.size() > 0) mReader = new MemoryArrayReader<ResourceData>(data); if (data.size() > 0) mReader = new MemoryArrayReader<FileData>(data);
return true; return true;
} }

View file

@ -306,7 +306,6 @@ int FileSystem::AddFromBuffer(const char* name, char* data, int size, int id, in
if (rf) if (rf)
{ {
Files.push_back(rf); Files.push_back(rf);
FResourceLump* lump = rf->GetLump(0);
FileInfo.resize(FileInfo.size() + 1); FileInfo.resize(FileInfo.size() + 1);
FileSystem::LumpRecord* lump_p = &FileInfo.back(); FileSystem::LumpRecord* lump_p = &FileInfo.back();
lump_p->SetFromLump(rf, 0, (int)Files.size() - 1, stringpool); lump_p->SetFromLump(rf, 0, (int)Files.size() - 1, stringpool);
@ -379,7 +378,6 @@ void FileSystem::AddFile (const char *filename, FileReader *filer, LumpFilterInf
Files.push_back(resfile); Files.push_back(resfile);
for (int i = 0; i < resfile->EntryCount(); i++) for (int i = 0; i < resfile->EntryCount(); i++)
{ {
FResourceLump* lump = resfile->GetLump(i);
FileInfo.resize(FileInfo.size() + 1); FileInfo.resize(FileInfo.size() + 1);
FileSystem::LumpRecord* lump_p = &FileInfo.back(); FileSystem::LumpRecord* lump_p = &FileInfo.back();
lump_p->SetFromLump(resfile, i, (int)Files.size() - 1, stringpool); lump_p->SetFromLump(resfile, i, (int)Files.size() - 1, stringpool);
@ -1312,10 +1310,7 @@ FileData FileSystem::ReadFile (int lump)
{ {
throw FileSystemException("ReadFile: %u >= NumEntries", lump); throw FileSystemException("ReadFile: %u >= NumEntries", lump);
} }
return FileInfo[lump].resfile->Read(FileInfo[lump].resindex);
auto file = FileInfo[lump].resfile;
auto lumpp = file->GetLump(FileInfo[lump].resindex);
return FileData(lumpp);
} }
//========================================================================== //==========================================================================

View file

@ -125,7 +125,7 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump)
FontName = name; FontName = name;
auto data1 = fileSystem.ReadFile (lump); auto data1 = fileSystem.ReadFile (lump);
auto data = data1.GetBytes(); auto data = data1.bytes();
if (data[0] == 0xE1 && data[1] == 0xE6 && data[2] == 0xD5 && data[3] == 0x1A) if (data[0] == 0xE1 && data[1] == 0xE6 && data[2] == 0xD5 && data[3] == 0x1A)
{ {
@ -475,7 +475,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data)
void FSingleLumpFont::CheckFON1Chars() void FSingleLumpFont::CheckFON1Chars()
{ {
auto memLump = fileSystem.ReadFile(Lump); auto memLump = fileSystem.ReadFile(Lump);
auto data = memLump.GetBytes(); auto data = memLump.bytes();
const uint8_t* data_p; const uint8_t* data_p;
data_p = data + 8; data_p = data + 8;

View file

@ -165,7 +165,7 @@ unsigned FindModel(const char * path, const char * modelfile, bool silent)
int len = fileSystem.FileLength(lump); int len = fileSystem.FileLength(lump);
auto lumpd = fileSystem.ReadFile(lump); auto lumpd = fileSystem.ReadFile(lump);
const char * buffer = lumpd.GetString(); const char * buffer = lumpd.string();
if ( (size_t)fullname.LastIndexOf("_d.3d") == fullname.Len()-5 ) if ( (size_t)fullname.LastIndexOf("_d.3d") == fullname.Len()-5 )
{ {

View file

@ -274,7 +274,7 @@ void IQMModel::LoadGeometry()
try try
{ {
auto lumpdata = fileSystem.ReadFile(mLumpNum); auto lumpdata = fileSystem.ReadFile(mLumpNum);
IQMFileReader reader(lumpdata.GetMem(), (int)lumpdata.GetSize()); IQMFileReader reader(lumpdata.data(), (int)lumpdata.size());
Vertices.Resize(NumVertices); Vertices.Resize(NumVertices);
for (IQMVertexArray& vertexArray : VertexArrays) for (IQMVertexArray& vertexArray : VertexArrays)

View file

@ -178,7 +178,7 @@ void FDMDModel::LoadGeometry()
{ {
static int axis[3] = { VX, VY, VZ }; static int axis[3] = { VX, VY, VZ };
auto lumpdata = fileSystem.ReadFile(mLumpNum); auto lumpdata = fileSystem.ReadFile(mLumpNum);
auto buffer = lumpdata.GetString(); auto buffer = lumpdata.string();
texCoords = new FTexCoord[info.numTexCoords]; texCoords = new FTexCoord[info.numTexCoords];
memcpy(texCoords, buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); memcpy(texCoords, buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord));
@ -502,7 +502,7 @@ void FMD2Model::LoadGeometry()
static int axis[3] = { VX, VY, VZ }; static int axis[3] = { VX, VY, VZ };
uint8_t *md2_frames; uint8_t *md2_frames;
auto lumpdata = fileSystem.ReadFile(mLumpNum); auto lumpdata = fileSystem.ReadFile(mLumpNum);
auto buffer = lumpdata.GetString(); auto buffer = lumpdata.string();
texCoords = new FTexCoord[info.numTexCoords]; texCoords = new FTexCoord[info.numTexCoords];
memcpy(texCoords, (uint8_t*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); memcpy(texCoords, (uint8_t*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord));

View file

@ -190,7 +190,7 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le
void FMD3Model::LoadGeometry() void FMD3Model::LoadGeometry()
{ {
auto lumpdata = fileSystem.ReadFile(mLumpNum); auto lumpdata = fileSystem.ReadFile(mLumpNum);
auto buffer = lumpdata.GetString(); auto buffer = lumpdata.string();
md3_header_t * hdr = (md3_header_t *)buffer; md3_header_t * hdr = (md3_header_t *)buffer;
md3_surface_t * surf = (md3_surface_t*)(buffer + LittleLong(hdr->Ofs_Surfaces)); md3_surface_t * surf = (md3_surface_t*)(buffer + LittleLong(hdr->Ofs_Surfaces));

View file

@ -71,9 +71,9 @@ void FUE1Model::LoadGeometry()
{ {
const char *buffer, *buffer2; const char *buffer, *buffer2;
auto lump = fileSystem.ReadFile(mDataLump); auto lump = fileSystem.ReadFile(mDataLump);
buffer = lump.GetString(); buffer = lump.string();
auto lump2 = fileSystem.ReadFile(mAnivLump); auto lump2 = fileSystem.ReadFile(mAnivLump);
buffer2 = lump2.GetString(); buffer2 = lump2.string();
// map structures // map structures
dhead = (const d3dhead*)(buffer); dhead = (const d3dhead*)(buffer);
dpolys = (const d3dpoly*)(buffer+sizeof(d3dhead)); dpolys = (const d3dpoly*)(buffer+sizeof(d3dhead));

View file

@ -162,8 +162,8 @@ FVoxel *R_LoadKVX(int lumpnum)
int i, j, n; int i, j, n;
auto lump = fileSystem.ReadFile(lumpnum); // FileData adds an extra 0 byte to the end. auto lump = fileSystem.ReadFile(lumpnum); // FileData adds an extra 0 byte to the end.
auto rawvoxel = lump.GetBytes(); auto rawvoxel = lump.bytes();
int voxelsize = (int)(lump.GetSize()); int voxelsize = (int)(lump.size());
// Oh, KVX, why couldn't you have a proper header? We'll just go through // Oh, KVX, why couldn't you have a proper header? We'll just go through
// and collect each MIP level, doing lots of range checking, and if the // and collect each MIP level, doing lots of range checking, and if the

View file

@ -106,10 +106,10 @@ FAnmTexture::FAnmTexture (int lumpnum, int w, int h)
void FAnmTexture::ReadFrame(uint8_t *pixels, uint8_t *palette) void FAnmTexture::ReadFrame(uint8_t *pixels, uint8_t *palette)
{ {
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
auto source = lump.GetBytes(); auto source = lump.bytes();
std::unique_ptr<anim_t> anim = std::make_unique<anim_t>(); // note that this struct is very large and should not go onto the stack! std::unique_ptr<anim_t> anim = std::make_unique<anim_t>(); // note that this struct is very large and should not go onto the stack!
if (ANIM_LoadAnim(anim.get(), source, (int)lump.GetSize()) >= 0) if (ANIM_LoadAnim(anim.get(), source, (int)lump.size()) >= 0)
{ {
int numframes = ANIM_NumFrames(anim.get()); int numframes = ANIM_NumFrames(anim.get());
if (numframes >= 1) if (numframes >= 1)

View file

@ -93,7 +93,7 @@ PalettedPixels FAutomapTexture::CreatePalettedPixels(int conversion, int frame)
{ {
int x, y; int x, y;
auto data = fileSystem.ReadFile (SourceLump); auto data = fileSystem.ReadFile (SourceLump);
auto indata = data.GetBytes(); auto indata = data.bytes();
PalettedPixels Pixels(Width * Height); PalettedPixels Pixels(Width * Height);

View file

@ -121,7 +121,7 @@ FIMGZTexture::FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int1
PalettedPixels FIMGZTexture::CreatePalettedPixels(int conversion, int frame) PalettedPixels FIMGZTexture::CreatePalettedPixels(int conversion, int frame)
{ {
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
auto imgz = (const ImageHeader *)lump.GetMem(); auto imgz = (const ImageHeader *)lump.data();
const uint8_t *data = (const uint8_t *)&imgz[1]; const uint8_t *data = (const uint8_t *)&imgz[1];
uint8_t *dest_p; uint8_t *dest_p;

View file

@ -186,7 +186,7 @@ PalettedPixels FPatchTexture::CreatePalettedPixels(int conversion, int frame)
int x; int x;
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
const patch_t *patch = (const patch_t *)lump.GetMem(); const patch_t *patch = (const patch_t *)lump.data();
maxcol = (const column_t *)((const uint8_t *)patch + fileSystem.FileLength (SourceLump) - 3); maxcol = (const column_t *)((const uint8_t *)patch + fileSystem.FileLength (SourceLump) - 3);
@ -296,7 +296,7 @@ void FPatchTexture::DetectBadPatches ()
// It must be 256 pixels tall, and all its columns must have exactly // It must be 256 pixels tall, and all its columns must have exactly
// one post, where each post has a supposed length of 0. // one post, where each post has a supposed length of 0.
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
const patch_t *realpatch = (patch_t *)lump.GetMem(); const patch_t *realpatch = (patch_t *)lump.data();
const uint32_t *cofs = realpatch->columnofs; const uint32_t *cofs = realpatch->columnofs;
int x, x2 = LittleShort(realpatch->width); int x, x2 = LittleShort(realpatch->width);

View file

@ -141,14 +141,14 @@ int FQOITexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
constexpr auto QOI_COLOR_HASH = [](PalEntry C) { return (C.r * 3 + C.g * 5 + C.b * 7 + C.a * 11); }; constexpr auto QOI_COLOR_HASH = [](PalEntry C) { return (C.r * 3 + C.g * 5 + C.b * 7 + C.a * 11); };
auto lump = fileSystem.ReadFile(SourceLump); auto lump = fileSystem.ReadFile(SourceLump);
if (lump.GetSize() < 22) return 0; // error if (lump.size() < 22) return 0; // error
PalEntry index[64] = {}; PalEntry index[64] = {};
PalEntry pe = 0xff000000; PalEntry pe = 0xff000000;
size_t p = 14, run = 0; size_t p = 14, run = 0;
size_t chunks_len = lump.GetSize() - 8; size_t chunks_len = lump.size() - 8;
auto bytes = lump.GetBytes(); auto bytes = lump.bytes();
for (int h = 0; h < Height; h++) for (int h = 0; h < Height; h++)
{ {

View file

@ -183,7 +183,7 @@ FRawPageTexture::FRawPageTexture (int lumpnum)
PalettedPixels FRawPageTexture::CreatePalettedPixels(int conversion, int frame) PalettedPixels FRawPageTexture::CreatePalettedPixels(int conversion, int frame)
{ {
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
auto source = lump.GetBytes(); auto source = lump.bytes();
const uint8_t *source_p = source; const uint8_t *source_p = source;
uint8_t *dest_p; uint8_t *dest_p;
@ -216,8 +216,8 @@ int FRawPageTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
{ {
auto lump = fileSystem.ReadFile(SourceLump); auto lump = fileSystem.ReadFile(SourceLump);
auto plump = fileSystem.ReadFile(mPaletteLump); auto plump = fileSystem.ReadFile(mPaletteLump);
auto source = lump.GetBytes(); auto source = lump.bytes();
auto psource = plump.GetBytes(); auto psource = plump.bytes();
PalEntry paldata[256]; PalEntry paldata[256];
for (auto & pe : paldata) for (auto & pe : paldata)
{ {

View file

@ -165,7 +165,7 @@ FStartupTexture::FStartupTexture (int lumpnum)
bUseGamePalette = false; bUseGamePalette = false;
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
auto source = lump.GetBytes(); auto source = lump.bytes();
// Initialize the bitmap palette. // Initialize the bitmap palette.
// the palette is static so that the notches can share it. // the palette is static so that the notches can share it.
@ -234,7 +234,7 @@ void PlanarToChunky(T* dest, const uint8_t* src, const T* remap, int width, int
PalettedPixels FStartupTexture::CreatePalettedPixels(int conversion, int frame) PalettedPixels FStartupTexture::CreatePalettedPixels(int conversion, int frame)
{ {
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
auto source = lump.GetBytes(); auto source = lump.bytes();
const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance);
@ -254,7 +254,7 @@ PalettedPixels FStartupTexture::CreatePalettedPixels(int conversion, int frame)
int FStartupTexture::CopyPixels(FBitmap *bmp, int conversion, int frame) int FStartupTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
{ {
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
auto source = lump.GetBytes(); auto source = lump.bytes();
PlanarToChunky((uint32_t*)bmp->GetPixels(), source + 48, startuppalette32, Width, Height); PlanarToChunky((uint32_t*)bmp->GetPixels(), source + 48, startuppalette32, Width, Height);
return 0; return 0;
} }
@ -282,7 +282,7 @@ FNotchTexture::FNotchTexture (int lumpnum, int width, int height)
PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion, int frame) PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion, int frame)
{ {
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
auto source = lump.GetBytes(); auto source = lump.bytes();
const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance);
TArray<uint8_t> Work(Width*Height, true); TArray<uint8_t> Work(Width*Height, true);
@ -305,7 +305,7 @@ PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion, int frame)
int FNotchTexture::CopyPixels(FBitmap *bmp, int conversion, int frame) int FNotchTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
{ {
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
auto source = lump.GetBytes(); auto source = lump.bytes();
auto Work = (uint32_t*)bmp->GetPixels(); auto Work = (uint32_t*)bmp->GetPixels();
for(int i = 0; i < Width * Height / 2; i++) for(int i = 0; i < Width * Height / 2; i++)
@ -339,7 +339,7 @@ FStrifeStartupTexture::FStrifeStartupTexture (int lumpnum, int w, int h)
PalettedPixels FStrifeStartupTexture::CreatePalettedPixels(int conversion, int frame) PalettedPixels FStrifeStartupTexture::CreatePalettedPixels(int conversion, int frame)
{ {
auto lump = fileSystem.ReadFile (SourceLump); auto lump = fileSystem.ReadFile (SourceLump);
auto source = lump.GetBytes(); auto source = lump.bytes();
PalettedPixels Pixels(Width*Height); PalettedPixels Pixels(Width*Height);
const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance);
ImageHelpers::FlipNonSquareBlockRemap(Pixels.Data(), source, Width, Height, Width, remap); ImageHelpers::FlipNonSquareBlockRemap(Pixels.Data(), source, Width, Height, Width, remap);

View file

@ -142,7 +142,7 @@ int FWebPTexture::CopyPixels(FBitmap *bmp, int conversion, int frame)
config.output.u.RGBA.stride = bmp->GetPitch(); config.output.u.RGBA.stride = bmp->GetPitch();
config.output.is_external_memory = 1; config.output.is_external_memory = 1;
(void)WebPDecode(bytes.GetBytes(), bytes.GetSize(), &config); (void)WebPDecode(bytes.bytes(), bytes.size(), &config);
return 0; return 0;
} }

View file

@ -398,12 +398,12 @@ void FMultipatchTextureBuilder::AddTexturesLumps(int lump1, int lump2, int patch
if (lump1 >= 0) if (lump1 >= 0)
{ {
auto texdir = fileSystem.ReadFile(lump1); auto texdir = fileSystem.ReadFile(lump1);
AddTexturesLump(texdir.GetMem(), fileSystem.FileLength(lump1), lump1, patcheslump, firstdup, true); AddTexturesLump(texdir.data(), fileSystem.FileLength(lump1), lump1, patcheslump, firstdup, true);
} }
if (lump2 >= 0) if (lump2 >= 0)
{ {
auto texdir = fileSystem.ReadFile(lump2); auto texdir = fileSystem.ReadFile(lump2);
AddTexturesLump(texdir.GetMem(), fileSystem.FileLength(lump2), lump2, patcheslump, firstdup, false); AddTexturesLump(texdir.data(), fileSystem.FileLength(lump2), lump2, patcheslump, firstdup, false);
} }
} }

View file

@ -1045,7 +1045,7 @@ void uppercopy(char* to, const char* from)
FString GetStringFromLump(int lump, bool zerotruncate) FString GetStringFromLump(int lump, bool zerotruncate)
{ {
auto fd = fileSystem.ReadFile(lump); auto fd = fileSystem.ReadFile(lump);
FString ScriptBuffer(fd.GetString(), fd.GetSize()); FString ScriptBuffer(fd.string(), fd.size());
if (zerotruncate) ScriptBuffer.Truncate(strlen(ScriptBuffer.GetChars())); // this is necessary to properly truncate the generated string to not contain 0 bytes. if (zerotruncate) ScriptBuffer.Truncate(strlen(ScriptBuffer.GetChars())); // this is necessary to properly truncate the generated string to not contain 0 bytes.
return ScriptBuffer; return ScriptBuffer;
} }

View file

@ -681,8 +681,8 @@ FString V_GetColorStringByName(const char* name, FScriptPosition* sc)
} }
auto rgbNames = fileSystem.ReadFile(rgblump); auto rgbNames = fileSystem.ReadFile(rgblump);
rgb = rgbNames.GetString(); rgb = rgbNames.string();
rgbEnd = rgb + rgbNames.GetSize(); rgbEnd = rgb + rgbNames.size();
step = 0; step = 0;
namelen = strlen(name); namelen = strlen(name);
@ -930,11 +930,11 @@ int ReadPalette(int lumpnum, uint8_t* buffer)
return 0; return 0;
} }
auto lump = fileSystem.ReadFile(lumpnum); auto lump = fileSystem.ReadFile(lumpnum);
auto lumpmem = lump.GetBytes(); auto lumpmem = lump.bytes();
memset(buffer, 0, 768); memset(buffer, 0, 768);
FileReader fr; FileReader fr;
fr.OpenMemory(lumpmem, lump.GetSize()); fr.OpenMemory(lumpmem, lump.size());
auto png = M_VerifyPNG(fr); auto png = M_VerifyPNG(fr);
if (png) if (png)
{ {
@ -964,7 +964,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer)
{ {
FScanner sc; FScanner sc;
sc.OpenMem(fileSystem.GetFileFullName(lumpnum), (char*)lumpmem, int(lump.GetSize())); sc.OpenMem(fileSystem.GetFileFullName(lumpnum), (char*)lumpmem, int(lump.size()));
sc.MustGetString(); sc.MustGetString();
sc.MustGetNumber(); // version - ignore sc.MustGetNumber(); // version - ignore
sc.MustGetNumber(); sc.MustGetNumber();
@ -982,7 +982,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer)
} }
else else
{ {
memcpy(buffer, lumpmem, min<size_t>(768, lump.GetSize())); memcpy(buffer, lumpmem, min<size_t>(768, lump.size()));
return 256; return 256;
} }
} }

View file

@ -315,7 +315,7 @@ FIWadManager::FIWadManager(const char *firstfn, const char *optfn)
if (num >= 0) if (num >= 0)
{ {
auto data = check.ReadFile(num); auto data = check.ReadFile(num);
ParseIWadInfo("IWADINFO", data.GetString(), (int)data.GetSize()); ParseIWadInfo("IWADINFO", data.string(), (int)data.size());
} }
} }
} }
@ -399,7 +399,7 @@ int FIWadManager::CheckIWADInfo(const char* fn)
FIWADInfo result; FIWADInfo result;
auto data = check.ReadFile(num); auto data = check.ReadFile(num);
ParseIWadInfo(fn, data.GetString(), (int)data.GetSize(), &result); ParseIWadInfo(fn, data.string(), (int)data.size(), &result);
for (unsigned i = 0, count = mIWadInfos.Size(); i < count; ++i) for (unsigned i = 0, count = mIWadInfos.Size(); i < count; ++i)
{ {

View file

@ -1940,7 +1940,7 @@ static FString CheckGameInfo(std::vector<std::string> & pwads)
// Found one! // Found one!
auto data = check.ReadFile(num); auto data = check.ReadFile(num);
auto wadname = check.GetResourceFileName(check.GetFileContainer(num)); auto wadname = check.GetResourceFileName(check.GetFileContainer(num));
return ParseGameInfo(pwads, wadname, data.GetString(), (int)data.GetSize()); return ParseGameInfo(pwads, wadname, data.string(), (int)data.size());
} }
} }
return ""; return "";

View file

@ -2599,7 +2599,7 @@ void G_ParseMapInfo (FString basemapinfo)
if (comp >= 0) if (comp >= 0)
{ {
auto complvl = fileSystem.ReadFile(comp); auto complvl = fileSystem.ReadFile(comp);
auto data = complvl.GetString(); auto data = complvl.string();
int length = fileSystem.FileLength(comp); int length = fileSystem.FileLength(comp);
if (length == 7 && !strnicmp("vanilla", data, 7)) if (length == 7 && !strnicmp("vanilla", data, 7))
{ {

View file

@ -166,8 +166,8 @@ void D_LoadWadSettings ()
while ((lump = fileSystem.FindLump ("KEYCONF", &lastlump)) != -1) while ((lump = fileSystem.FindLump ("KEYCONF", &lastlump)) != -1)
{ {
auto data = fileSystem.ReadFile (lump); auto data = fileSystem.ReadFile (lump);
const char* conf = data.GetString(); const char* conf = data.string();
const char *eof = conf + data.GetSize(); const char *eof = conf + data.size();
while (conf < eof) while (conf < eof)
{ {

View file

@ -67,7 +67,7 @@ void FTextureAnimator::InitSwitchList ()
if (lump != -1) if (lump != -1)
{ {
auto lumpdata = fileSystem.ReadFile (lump); auto lumpdata = fileSystem.ReadFile (lump);
auto alphSwitchList = lumpdata.GetString(); auto alphSwitchList = lumpdata.string();
const char *list_p; const char *list_p;
FSwitchDef *def1, *def2; FSwitchDef *def1, *def2;

View file

@ -205,7 +205,7 @@ void FTextureAnimator::InitAnimated (void)
{ {
auto animatedlump = fileSystem.ReadFile (lumpnum); auto animatedlump = fileSystem.ReadFile (lumpnum);
int animatedlen = fileSystem.FileLength(lumpnum); int animatedlen = fileSystem.FileLength(lumpnum);
auto animdefs = animatedlump.GetBytes(); auto animdefs = animatedlump.bytes();
const uint8_t *anim_p; const uint8_t *anim_p;
FTextureID pic1, pic2; FTextureID pic1, pic2;
int animtype; int animtype;

View file

@ -85,7 +85,7 @@ static int BuildPaletteTranslation(int lump)
} }
auto data = fileSystem.ReadFile(lump); auto data = fileSystem.ReadFile(lump);
auto ipal = data.GetBytes(); auto ipal = data.bytes();
FRemapTable opal; FRemapTable opal;
bool blood = false; bool blood = false;

View file

@ -98,7 +98,7 @@ void M_FindResponseFile (void)
else else
{ {
char **argv; char **argv;
FileSys::ResourceData file; FileSys::FileData file;
int argc = 0; int argc = 0;
size_t argsize = 0; size_t argsize = 0;
int index; int index;

View file

@ -403,7 +403,7 @@ void player_t::SetLogNumber (int num)
} }
auto lump = fileSystem.ReadFile(lumpnum); auto lump = fileSystem.ReadFile(lumpnum);
SetLogText (lump.GetString()); SetLogText (lump.string());
} }
} }

View file

@ -494,7 +494,7 @@ static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerC
else else
{ {
auto translump = fileSystem.ReadFile(colorset->Lump); auto translump = fileSystem.ReadFile(colorset->Lump);
auto trans = translump.GetBytes(); auto trans = translump.bytes();
for (i = start; i <= end; ++i) for (i = start; i <= end; ++i)
{ {
table->Remap[i] = GPalette.Remap[trans[i]]; table->Remap[i] = GPalette.Remap[trans[i]];

View file

@ -947,7 +947,7 @@ CCMD (skins)
static void R_CreateSkinTranslation (const char *palname) static void R_CreateSkinTranslation (const char *palname)
{ {
auto lump = fileSystem.ReadFile (palname); auto lump = fileSystem.ReadFile (palname);
auto otherPal = lump.GetBytes(); auto otherPal = lump.bytes();
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
{ {

View file

@ -65,7 +65,7 @@ void InitPalette ()
if (lump != -1) if (lump != -1)
{ {
FileData cmap = fileSystem.ReadFile(lump); FileData cmap = fileSystem.ReadFile(lump);
auto cmapdata = cmap.GetBytes(); auto cmapdata = cmap.bytes();
GPalette.GenerateGlobalBrightmapFromColormap(cmapdata, 32); GPalette.GenerateGlobalBrightmapFromColormap(cmapdata, 32);
MakeGoodRemap((uint32_t*)GPalette.BaseColors, GPalette.Remap, cmapdata + 7936); // last entry in colormap MakeGoodRemap((uint32_t*)GPalette.BaseColors, GPalette.Remap, cmapdata + 7936); // last entry in colormap
} }