From fe106d9bfe4c76e97d50ce5cb5a2ce2e8f09b621 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 10 Dec 2023 22:30:54 +0100 Subject: [PATCH] merge FileData and ResourceData. --- src/common/audio/music/i_music.cpp | 8 ++--- src/common/cutscenes/movieplayer.cpp | 2 +- src/common/engine/stringtable.cpp | 6 ++-- src/common/filesystem/include/fs_files.h | 24 ++++++------- src/common/filesystem/include/fs_filesystem.h | 36 ------------------- src/common/filesystem/include/resourcefile.h | 2 +- src/common/filesystem/source/files.cpp | 4 +-- src/common/filesystem/source/filesystem.cpp | 7 +--- src/common/fonts/singlelumpfont.cpp | 4 +-- src/common/models/model.cpp | 2 +- src/common/models/models_iqm.cpp | 2 +- src/common/models/models_md2.cpp | 4 +-- src/common/models/models_md3.cpp | 2 +- src/common/models/models_ue1.cpp | 4 +-- src/common/models/voxels.cpp | 4 +-- src/common/textures/formats/anmtexture.cpp | 4 +-- .../textures/formats/automaptexture.cpp | 2 +- src/common/textures/formats/imgztexture.cpp | 2 +- src/common/textures/formats/patchtexture.cpp | 4 +-- src/common/textures/formats/qoitexture.cpp | 6 ++-- .../textures/formats/rawpagetexture.cpp | 6 ++-- .../textures/formats/startuptexture.cpp | 12 +++---- src/common/textures/formats/webptexture.cpp | 2 +- .../textures/multipatchtexturebuilder.cpp | 4 +-- src/common/utility/cmdlib.cpp | 2 +- src/common/utility/palette.cpp | 12 +++---- src/d_iwad.cpp | 4 +-- src/d_main.cpp | 2 +- src/gamedata/g_mapinfo.cpp | 2 +- src/gamedata/keysections.cpp | 4 +-- src/gamedata/textures/anim_switches.cpp | 2 +- src/gamedata/textures/animations.cpp | 2 +- src/gamedata/textures/buildloader.cpp | 2 +- src/m_misc.cpp | 2 +- src/playsim/p_user.cpp | 2 +- src/r_data/r_translate.cpp | 2 +- src/r_data/sprites.cpp | 2 +- src/r_data/v_palette.cpp | 2 +- 38 files changed, 77 insertions(+), 118 deletions(-) diff --git a/src/common/audio/music/i_music.cpp b/src/common/audio/music/i_music.cpp index 1f17cf884b..d190537d45 100644 --- a/src/common/audio/music/i_music.cpp +++ b/src/common/audio/music/i_music.cpp @@ -182,8 +182,8 @@ static void SetupGenMidi() } auto genmidi = fileSystem.ReadFile(lump); - if (genmidi.GetSize() < 8 + 175 * 36 || memcmp(genmidi.GetMem(), "#OPL_II#", 8)) return; - ZMusic_SetGenMidi(genmidi.GetBytes() + 8); + if (genmidi.size() < 8 + 175 * 36 || memcmp(genmidi.data(), "#OPL_II#", 8)) return; + ZMusic_SetGenMidi(genmidi.bytes() + 8); } static void SetupWgOpn() @@ -194,7 +194,7 @@ static void SetupWgOpn() return; } auto data = fileSystem.ReadFile(lump); - ZMusic_SetWgOpn(data.GetMem(), (uint32_t)data.GetSize()); + ZMusic_SetWgOpn(data.data(), (uint32_t)data.size()); } static void SetupDMXGUS() @@ -206,7 +206,7 @@ static void SetupDMXGUS() return; } auto data = fileSystem.ReadFile(lump); - ZMusic_SetDmxGus(data.GetMem(), (uint32_t)data.GetSize()); + ZMusic_SetDmxGus(data.data(), (uint32_t)data.size()); } #endif diff --git a/src/common/cutscenes/movieplayer.cpp b/src/common/cutscenes/movieplayer.cpp index ef49346f58..dfb7d3a4c7 100644 --- a/src/common/cutscenes/movieplayer.cpp +++ b/src/common/cutscenes/movieplayer.cpp @@ -153,7 +153,7 @@ class AnmPlayer : public MoviePlayer { // This doesn't need its own class type anim_t anim; - FileSys::ResourceData buffer; + FileSys::FileData buffer; int numframes = 0; int curframe = 1; int frametime = 0; diff --git a/src/common/engine/stringtable.cpp b/src/common/engine/stringtable.cpp index d507b281cb..6bfbe12804 100644 --- a/src/common/engine/stringtable.cpp +++ b/src/common/engine/stringtable.cpp @@ -63,8 +63,8 @@ void FStringTable::LoadStrings (const char *language) { auto lumpdata = fileSystem.ReadFile(lump); - if (!ParseLanguageCSV(lump, lumpdata.GetString(), lumpdata.GetSize())) - LoadLanguage (lump, lumpdata.GetString(), lumpdata.GetSize()); + if (!ParseLanguageCSV(lump, lumpdata.string(), lumpdata.size())) + LoadLanguage (lump, lumpdata.string(), lumpdata.size()); } UpdateLanguage(language); allMacros.Clear(); @@ -160,7 +160,7 @@ TArray> FStringTable::parseCSV(const char* buffer, size_t size) bool FStringTable::readMacros(int 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++) { diff --git a/src/common/filesystem/include/fs_files.h b/src/common/filesystem/include/fs_files.h index 7a2871a71c..a3f71f159d 100644 --- a/src/common/filesystem/include/fs_files.h +++ b/src/common/filesystem/include/fs_files.h @@ -91,7 +91,7 @@ enum class FileReader; // 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; size_t length; @@ -99,13 +99,13 @@ class ResourceData public: 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; } size_t size() const { return length; } const char* string() const { return (const char*)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); length = copy.length; @@ -119,7 +119,7 @@ public: return *this; } - ResourceData& operator = (ResourceData&& copy) noexcept + FileData& operator = (FileData&& copy) noexcept { if (owned && memory) free(memory); length = copy.length; @@ -131,13 +131,13 @@ public: return *this; } - ResourceData(const ResourceData& copy) + FileData(const FileData& copy) { memory = nullptr; *this = copy; } - ~ResourceData() + ~FileData() { if (owned && memory) free(memory); } @@ -254,7 +254,7 @@ public: 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(std::vector& 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&)> 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. @@ -273,9 +273,9 @@ public: return mReader->Read(buffer, len); } - ResourceData Read(size_t len) + FileData Read(size_t len) { - ResourceData buffer; + FileData buffer; if (len > 0) { Size length = mReader->Read(buffer.allocate(len), len); @@ -284,15 +284,15 @@ public: return buffer; } - ResourceData Read() + FileData Read() { return Read(GetLength()); } - ResourceData ReadPadded(size_t padding) + FileData ReadPadded(size_t padding) { auto len = GetLength(); - ResourceData buffer; + FileData buffer; if (len > 0) { diff --git a/src/common/filesystem/include/fs_filesystem.h b/src/common/filesystem/include/fs_filesystem.h index 1b5249cbc5..d0e44194f1 100644 --- a/src/common/filesystem/include/fs_filesystem.h +++ b/src/common/filesystem/include/fs_filesystem.h @@ -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 { const char *name; diff --git a/src/common/filesystem/include/resourcefile.h b/src/common/filesystem/include/resourcefile.h index 5776963d79..180bed9313 100644 --- a/src/common/filesystem/include/resourcefile.h +++ b/src/common/filesystem/include/resourcefile.h @@ -249,7 +249,7 @@ public: return l ? l->GetIndexNum() : 0; } - ResourceData Read(int entry) + FileData Read(int entry) { auto fr = GetEntryReader(entry, false); return fr.Read(); diff --git a/src/common/filesystem/source/files.cpp b/src/common/filesystem/source/files.cpp index 7bf0130600..87eee970d0 100644 --- a/src/common/filesystem/source/files.cpp +++ b/src/common/filesystem/source/files.cpp @@ -406,10 +406,10 @@ bool FileReader::OpenMemoryArray(std::vector& data) return true; } -bool FileReader::OpenMemoryArray(ResourceData& data) +bool FileReader::OpenMemoryArray(FileData& data) { Close(); - if (data.size() > 0) mReader = new MemoryArrayReader(data); + if (data.size() > 0) mReader = new MemoryArrayReader(data); return true; } diff --git a/src/common/filesystem/source/filesystem.cpp b/src/common/filesystem/source/filesystem.cpp index ab7d96a58a..8be2f3556d 100644 --- a/src/common/filesystem/source/filesystem.cpp +++ b/src/common/filesystem/source/filesystem.cpp @@ -306,7 +306,6 @@ int FileSystem::AddFromBuffer(const char* name, char* data, int size, int id, in if (rf) { Files.push_back(rf); - FResourceLump* lump = rf->GetLump(0); FileInfo.resize(FileInfo.size() + 1); FileSystem::LumpRecord* lump_p = &FileInfo.back(); 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); for (int i = 0; i < resfile->EntryCount(); i++) { - FResourceLump* lump = resfile->GetLump(i); FileInfo.resize(FileInfo.size() + 1); FileSystem::LumpRecord* lump_p = &FileInfo.back(); 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); } - - auto file = FileInfo[lump].resfile; - auto lumpp = file->GetLump(FileInfo[lump].resindex); - return FileData(lumpp); + return FileInfo[lump].resfile->Read(FileInfo[lump].resindex); } //========================================================================== diff --git a/src/common/fonts/singlelumpfont.cpp b/src/common/fonts/singlelumpfont.cpp index 0a8a099e44..0d58394016 100644 --- a/src/common/fonts/singlelumpfont.cpp +++ b/src/common/fonts/singlelumpfont.cpp @@ -125,7 +125,7 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump) FontName = name; 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) { @@ -475,7 +475,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) void FSingleLumpFont::CheckFON1Chars() { auto memLump = fileSystem.ReadFile(Lump); - auto data = memLump.GetBytes(); + auto data = memLump.bytes(); const uint8_t* data_p; data_p = data + 8; diff --git a/src/common/models/model.cpp b/src/common/models/model.cpp index 4b9ab0b00d..ce61bfe54f 100644 --- a/src/common/models/model.cpp +++ b/src/common/models/model.cpp @@ -165,7 +165,7 @@ unsigned FindModel(const char * path, const char * modelfile, bool silent) int len = fileSystem.FileLength(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 ) { diff --git a/src/common/models/models_iqm.cpp b/src/common/models/models_iqm.cpp index d22c0d9d55..1184a9390b 100644 --- a/src/common/models/models_iqm.cpp +++ b/src/common/models/models_iqm.cpp @@ -274,7 +274,7 @@ void IQMModel::LoadGeometry() try { auto lumpdata = fileSystem.ReadFile(mLumpNum); - IQMFileReader reader(lumpdata.GetMem(), (int)lumpdata.GetSize()); + IQMFileReader reader(lumpdata.data(), (int)lumpdata.size()); Vertices.Resize(NumVertices); for (IQMVertexArray& vertexArray : VertexArrays) diff --git a/src/common/models/models_md2.cpp b/src/common/models/models_md2.cpp index 3ba364c033..280c4d265f 100644 --- a/src/common/models/models_md2.cpp +++ b/src/common/models/models_md2.cpp @@ -178,7 +178,7 @@ void FDMDModel::LoadGeometry() { static int axis[3] = { VX, VY, VZ }; auto lumpdata = fileSystem.ReadFile(mLumpNum); - auto buffer = lumpdata.GetString(); + auto buffer = lumpdata.string(); texCoords = new FTexCoord[info.numTexCoords]; memcpy(texCoords, buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); @@ -502,7 +502,7 @@ void FMD2Model::LoadGeometry() static int axis[3] = { VX, VY, VZ }; uint8_t *md2_frames; auto lumpdata = fileSystem.ReadFile(mLumpNum); - auto buffer = lumpdata.GetString(); + auto buffer = lumpdata.string(); texCoords = new FTexCoord[info.numTexCoords]; memcpy(texCoords, (uint8_t*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); diff --git a/src/common/models/models_md3.cpp b/src/common/models/models_md3.cpp index 5330611fca..327cbff88a 100644 --- a/src/common/models/models_md3.cpp +++ b/src/common/models/models_md3.cpp @@ -190,7 +190,7 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le void FMD3Model::LoadGeometry() { auto lumpdata = fileSystem.ReadFile(mLumpNum); - auto buffer = lumpdata.GetString(); + auto buffer = lumpdata.string(); md3_header_t * hdr = (md3_header_t *)buffer; md3_surface_t * surf = (md3_surface_t*)(buffer + LittleLong(hdr->Ofs_Surfaces)); diff --git a/src/common/models/models_ue1.cpp b/src/common/models/models_ue1.cpp index c2f6929eb2..8106592617 100644 --- a/src/common/models/models_ue1.cpp +++ b/src/common/models/models_ue1.cpp @@ -71,9 +71,9 @@ void FUE1Model::LoadGeometry() { const char *buffer, *buffer2; auto lump = fileSystem.ReadFile(mDataLump); - buffer = lump.GetString(); + buffer = lump.string(); auto lump2 = fileSystem.ReadFile(mAnivLump); - buffer2 = lump2.GetString(); + buffer2 = lump2.string(); // map structures dhead = (const d3dhead*)(buffer); dpolys = (const d3dpoly*)(buffer+sizeof(d3dhead)); diff --git a/src/common/models/voxels.cpp b/src/common/models/voxels.cpp index e5b61bcb60..a2e371582c 100644 --- a/src/common/models/voxels.cpp +++ b/src/common/models/voxels.cpp @@ -162,8 +162,8 @@ FVoxel *R_LoadKVX(int lumpnum) int i, j, n; auto lump = fileSystem.ReadFile(lumpnum); // FileData adds an extra 0 byte to the end. - auto rawvoxel = lump.GetBytes(); - int voxelsize = (int)(lump.GetSize()); + auto rawvoxel = lump.bytes(); + int voxelsize = (int)(lump.size()); // 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 diff --git a/src/common/textures/formats/anmtexture.cpp b/src/common/textures/formats/anmtexture.cpp index dbc51bae57..1eb7f49492 100644 --- a/src/common/textures/formats/anmtexture.cpp +++ b/src/common/textures/formats/anmtexture.cpp @@ -106,10 +106,10 @@ FAnmTexture::FAnmTexture (int lumpnum, int w, int h) void FAnmTexture::ReadFrame(uint8_t *pixels, uint8_t *palette) { auto lump = fileSystem.ReadFile (SourceLump); - auto source = lump.GetBytes(); + auto source = lump.bytes(); std::unique_ptr anim = std::make_unique(); // 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()); if (numframes >= 1) diff --git a/src/common/textures/formats/automaptexture.cpp b/src/common/textures/formats/automaptexture.cpp index a3b16c720e..2ebdc4d536 100644 --- a/src/common/textures/formats/automaptexture.cpp +++ b/src/common/textures/formats/automaptexture.cpp @@ -93,7 +93,7 @@ PalettedPixels FAutomapTexture::CreatePalettedPixels(int conversion, int frame) { int x, y; auto data = fileSystem.ReadFile (SourceLump); - auto indata = data.GetBytes(); + auto indata = data.bytes(); PalettedPixels Pixels(Width * Height); diff --git a/src/common/textures/formats/imgztexture.cpp b/src/common/textures/formats/imgztexture.cpp index 831733a2b7..9419c64a66 100644 --- a/src/common/textures/formats/imgztexture.cpp +++ b/src/common/textures/formats/imgztexture.cpp @@ -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) { 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]; uint8_t *dest_p; diff --git a/src/common/textures/formats/patchtexture.cpp b/src/common/textures/formats/patchtexture.cpp index 0b6266a588..d7e8f3fca6 100644 --- a/src/common/textures/formats/patchtexture.cpp +++ b/src/common/textures/formats/patchtexture.cpp @@ -186,7 +186,7 @@ PalettedPixels FPatchTexture::CreatePalettedPixels(int conversion, int frame) int x; 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); @@ -296,7 +296,7 @@ void FPatchTexture::DetectBadPatches () // It must be 256 pixels tall, and all its columns must have exactly // one post, where each post has a supposed length of 0. 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; int x, x2 = LittleShort(realpatch->width); diff --git a/src/common/textures/formats/qoitexture.cpp b/src/common/textures/formats/qoitexture.cpp index 2df6517568..07511aaf9a 100644 --- a/src/common/textures/formats/qoitexture.cpp +++ b/src/common/textures/formats/qoitexture.cpp @@ -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); }; auto lump = fileSystem.ReadFile(SourceLump); - if (lump.GetSize() < 22) return 0; // error + if (lump.size() < 22) return 0; // error PalEntry index[64] = {}; PalEntry pe = 0xff000000; size_t p = 14, run = 0; - size_t chunks_len = lump.GetSize() - 8; - auto bytes = lump.GetBytes(); + size_t chunks_len = lump.size() - 8; + auto bytes = lump.bytes(); for (int h = 0; h < Height; h++) { diff --git a/src/common/textures/formats/rawpagetexture.cpp b/src/common/textures/formats/rawpagetexture.cpp index cca68dd074..52b3f3c535 100644 --- a/src/common/textures/formats/rawpagetexture.cpp +++ b/src/common/textures/formats/rawpagetexture.cpp @@ -183,7 +183,7 @@ FRawPageTexture::FRawPageTexture (int lumpnum) PalettedPixels FRawPageTexture::CreatePalettedPixels(int conversion, int frame) { auto lump = fileSystem.ReadFile (SourceLump); - auto source = lump.GetBytes(); + auto source = lump.bytes(); const uint8_t *source_p = source; uint8_t *dest_p; @@ -216,8 +216,8 @@ int FRawPageTexture::CopyPixels(FBitmap *bmp, int conversion, int frame) { auto lump = fileSystem.ReadFile(SourceLump); auto plump = fileSystem.ReadFile(mPaletteLump); - auto source = lump.GetBytes(); - auto psource = plump.GetBytes(); + auto source = lump.bytes(); + auto psource = plump.bytes(); PalEntry paldata[256]; for (auto & pe : paldata) { diff --git a/src/common/textures/formats/startuptexture.cpp b/src/common/textures/formats/startuptexture.cpp index 510061f7c9..c062251d8c 100644 --- a/src/common/textures/formats/startuptexture.cpp +++ b/src/common/textures/formats/startuptexture.cpp @@ -165,7 +165,7 @@ FStartupTexture::FStartupTexture (int lumpnum) bUseGamePalette = false; auto lump = fileSystem.ReadFile (SourceLump); - auto source = lump.GetBytes(); + auto source = lump.bytes(); // Initialize the bitmap palette. // 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) { auto lump = fileSystem.ReadFile (SourceLump); - auto source = lump.GetBytes(); + auto source = lump.bytes(); 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) { auto lump = fileSystem.ReadFile (SourceLump); - auto source = lump.GetBytes(); + auto source = lump.bytes(); PlanarToChunky((uint32_t*)bmp->GetPixels(), source + 48, startuppalette32, Width, Height); return 0; } @@ -282,7 +282,7 @@ FNotchTexture::FNotchTexture (int lumpnum, int width, int height) PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion, int frame) { auto lump = fileSystem.ReadFile (SourceLump); - auto source = lump.GetBytes(); + auto source = lump.bytes(); const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); TArray Work(Width*Height, true); @@ -305,7 +305,7 @@ PalettedPixels FNotchTexture::CreatePalettedPixels(int conversion, int frame) int FNotchTexture::CopyPixels(FBitmap *bmp, int conversion, int frame) { auto lump = fileSystem.ReadFile (SourceLump); - auto source = lump.GetBytes(); + auto source = lump.bytes(); auto Work = (uint32_t*)bmp->GetPixels(); 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) { auto lump = fileSystem.ReadFile (SourceLump); - auto source = lump.GetBytes(); + auto source = lump.bytes(); PalettedPixels Pixels(Width*Height); const uint8_t *remap = ImageHelpers::GetRemap(conversion == luminance); ImageHelpers::FlipNonSquareBlockRemap(Pixels.Data(), source, Width, Height, Width, remap); diff --git a/src/common/textures/formats/webptexture.cpp b/src/common/textures/formats/webptexture.cpp index e86ed4a11f..2df7596451 100644 --- a/src/common/textures/formats/webptexture.cpp +++ b/src/common/textures/formats/webptexture.cpp @@ -142,7 +142,7 @@ int FWebPTexture::CopyPixels(FBitmap *bmp, int conversion, int frame) config.output.u.RGBA.stride = bmp->GetPitch(); config.output.is_external_memory = 1; - (void)WebPDecode(bytes.GetBytes(), bytes.GetSize(), &config); + (void)WebPDecode(bytes.bytes(), bytes.size(), &config); return 0; } diff --git a/src/common/textures/multipatchtexturebuilder.cpp b/src/common/textures/multipatchtexturebuilder.cpp index 7f94437d2f..f57b1f65b9 100644 --- a/src/common/textures/multipatchtexturebuilder.cpp +++ b/src/common/textures/multipatchtexturebuilder.cpp @@ -398,12 +398,12 @@ void FMultipatchTextureBuilder::AddTexturesLumps(int lump1, int lump2, int patch if (lump1 >= 0) { 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) { 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); } } diff --git a/src/common/utility/cmdlib.cpp b/src/common/utility/cmdlib.cpp index 9bb06fb38d..5933a91d55 100644 --- a/src/common/utility/cmdlib.cpp +++ b/src/common/utility/cmdlib.cpp @@ -1045,7 +1045,7 @@ void uppercopy(char* to, const char* from) FString GetStringFromLump(int lump, bool zerotruncate) { 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. return ScriptBuffer; } diff --git a/src/common/utility/palette.cpp b/src/common/utility/palette.cpp index c0fcd9f5d8..ea046a2209 100644 --- a/src/common/utility/palette.cpp +++ b/src/common/utility/palette.cpp @@ -681,8 +681,8 @@ FString V_GetColorStringByName(const char* name, FScriptPosition* sc) } auto rgbNames = fileSystem.ReadFile(rgblump); - rgb = rgbNames.GetString(); - rgbEnd = rgb + rgbNames.GetSize(); + rgb = rgbNames.string(); + rgbEnd = rgb + rgbNames.size(); step = 0; namelen = strlen(name); @@ -930,11 +930,11 @@ int ReadPalette(int lumpnum, uint8_t* buffer) return 0; } auto lump = fileSystem.ReadFile(lumpnum); - auto lumpmem = lump.GetBytes(); + auto lumpmem = lump.bytes(); memset(buffer, 0, 768); FileReader fr; - fr.OpenMemory(lumpmem, lump.GetSize()); + fr.OpenMemory(lumpmem, lump.size()); auto png = M_VerifyPNG(fr); if (png) { @@ -964,7 +964,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer) { 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.MustGetNumber(); // version - ignore sc.MustGetNumber(); @@ -982,7 +982,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer) } else { - memcpy(buffer, lumpmem, min(768, lump.GetSize())); + memcpy(buffer, lumpmem, min(768, lump.size())); return 256; } } diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 6cbde02f78..a252104bdf 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -315,7 +315,7 @@ FIWadManager::FIWadManager(const char *firstfn, const char *optfn) if (num >= 0) { 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; 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) { diff --git a/src/d_main.cpp b/src/d_main.cpp index 22771119c5..6e7155840d 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1940,7 +1940,7 @@ static FString CheckGameInfo(std::vector & pwads) // Found one! auto data = check.ReadFile(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 ""; diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index 18fc4e1d30..1b5b287847 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -2599,7 +2599,7 @@ void G_ParseMapInfo (FString basemapinfo) if (comp >= 0) { auto complvl = fileSystem.ReadFile(comp); - auto data = complvl.GetString(); + auto data = complvl.string(); int length = fileSystem.FileLength(comp); if (length == 7 && !strnicmp("vanilla", data, 7)) { diff --git a/src/gamedata/keysections.cpp b/src/gamedata/keysections.cpp index 5a218638f3..b1d3354ca2 100644 --- a/src/gamedata/keysections.cpp +++ b/src/gamedata/keysections.cpp @@ -166,8 +166,8 @@ void D_LoadWadSettings () while ((lump = fileSystem.FindLump ("KEYCONF", &lastlump)) != -1) { auto data = fileSystem.ReadFile (lump); - const char* conf = data.GetString(); - const char *eof = conf + data.GetSize(); + const char* conf = data.string(); + const char *eof = conf + data.size(); while (conf < eof) { diff --git a/src/gamedata/textures/anim_switches.cpp b/src/gamedata/textures/anim_switches.cpp index c0485714b4..ce7166ba95 100644 --- a/src/gamedata/textures/anim_switches.cpp +++ b/src/gamedata/textures/anim_switches.cpp @@ -67,7 +67,7 @@ void FTextureAnimator::InitSwitchList () if (lump != -1) { auto lumpdata = fileSystem.ReadFile (lump); - auto alphSwitchList = lumpdata.GetString(); + auto alphSwitchList = lumpdata.string(); const char *list_p; FSwitchDef *def1, *def2; diff --git a/src/gamedata/textures/animations.cpp b/src/gamedata/textures/animations.cpp index c2f903e306..249544317a 100644 --- a/src/gamedata/textures/animations.cpp +++ b/src/gamedata/textures/animations.cpp @@ -205,7 +205,7 @@ void FTextureAnimator::InitAnimated (void) { auto animatedlump = fileSystem.ReadFile (lumpnum); int animatedlen = fileSystem.FileLength(lumpnum); - auto animdefs = animatedlump.GetBytes(); + auto animdefs = animatedlump.bytes(); const uint8_t *anim_p; FTextureID pic1, pic2; int animtype; diff --git a/src/gamedata/textures/buildloader.cpp b/src/gamedata/textures/buildloader.cpp index a3955d6d86..83c547b501 100644 --- a/src/gamedata/textures/buildloader.cpp +++ b/src/gamedata/textures/buildloader.cpp @@ -85,7 +85,7 @@ static int BuildPaletteTranslation(int lump) } auto data = fileSystem.ReadFile(lump); - auto ipal = data.GetBytes(); + auto ipal = data.bytes(); FRemapTable opal; bool blood = false; diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 6e850f3d12..d415d6c475 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -98,7 +98,7 @@ void M_FindResponseFile (void) else { char **argv; - FileSys::ResourceData file; + FileSys::FileData file; int argc = 0; size_t argsize = 0; int index; diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index f7372d0d17..1ce3e3445a 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -403,7 +403,7 @@ void player_t::SetLogNumber (int num) } auto lump = fileSystem.ReadFile(lumpnum); - SetLogText (lump.GetString()); + SetLogText (lump.string()); } } diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index 799b2c32ed..8b197cda7d 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -494,7 +494,7 @@ static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerC else { auto translump = fileSystem.ReadFile(colorset->Lump); - auto trans = translump.GetBytes(); + auto trans = translump.bytes(); for (i = start; i <= end; ++i) { table->Remap[i] = GPalette.Remap[trans[i]]; diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 63314f23e9..0a7be96a12 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -947,7 +947,7 @@ CCMD (skins) static void R_CreateSkinTranslation (const char *palname) { auto lump = fileSystem.ReadFile (palname); - auto otherPal = lump.GetBytes(); + auto otherPal = lump.bytes(); for (int i = 0; i < 256; ++i) { diff --git a/src/r_data/v_palette.cpp b/src/r_data/v_palette.cpp index cc63955498..8af454445d 100644 --- a/src/r_data/v_palette.cpp +++ b/src/r_data/v_palette.cpp @@ -65,7 +65,7 @@ void InitPalette () if (lump != -1) { FileData cmap = fileSystem.ReadFile(lump); - auto cmapdata = cmap.GetBytes(); + auto cmapdata = cmap.bytes(); GPalette.GenerateGlobalBrightmapFromColormap(cmapdata, 32); MakeGoodRemap((uint32_t*)GPalette.BaseColors, GPalette.Remap, cmapdata + 7936); // last entry in colormap }