From 749eda32c5f3463a45a7f7172e7cf56f2ae314ef Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 7 Dec 2019 10:14:51 +0100 Subject: [PATCH] - moved kopenfilereader into the FileSystem class. --- source/blood/src/barf.cpp | 2 +- source/blood/src/credits.cpp | 4 ++-- source/blood/src/inifile.cpp | 2 +- source/blood/src/sound.cpp | 2 +- source/blood/src/tile.cpp | 6 +++--- source/build/include/cache1d.h | 9 --------- source/build/src/defs.cpp | 6 +++--- source/build/src/engine.cpp | 6 +++--- source/build/src/mdsprite.cpp | 2 +- source/build/src/palette.cpp | 2 +- source/build/src/scriptfile.cpp | 2 +- source/build/src/voxmodel.cpp | 6 +++--- source/common/filesystem/filesystem.cpp | 7 +++++++ source/common/filesystem/filesystem.h | 1 + source/common/fonts/v_font.cpp | 2 +- source/common/openaudio.cpp | 6 +++--- source/common/rts.cpp | 2 +- source/common/textures/buildtiles.cpp | 4 ++-- source/common/textures/formats/arttexture.cpp | 4 ++-- source/common/textures/formats/ddstexture.cpp | 4 ++-- source/common/textures/formats/jpegtexture.cpp | 4 ++-- source/common/textures/formats/pcxtexture.cpp | 4 ++-- source/common/textures/formats/pngtexture.cpp | 4 ++-- source/common/textures/formats/stbtexture.cpp | 2 +- source/common/textures/formats/tgatexture.cpp | 4 ++-- source/common/textures/image.cpp | 2 +- source/common/utility/sc_man.cpp | 2 +- source/duke3d/src/anim.cpp | 6 +++--- source/duke3d/src/common.cpp | 2 +- source/duke3d/src/gamedef.cpp | 4 ++-- source/glbackend/glbackend.cpp | 2 +- source/libsmackerdec/src/FileStream.cpp | 2 +- source/rr/src/anim.cpp | 6 +++--- source/rr/src/common.cpp | 2 +- source/rr/src/gamedef.cpp | 4 ++-- source/sw/src/anim.cpp | 2 +- source/sw/src/demo.h | 2 +- source/sw/src/scrip2.cpp | 2 +- source/sw/src/sounds.cpp | 6 +++--- 39 files changed, 70 insertions(+), 71 deletions(-) diff --git a/source/blood/src/barf.cpp b/source/blood/src/barf.cpp index 839f59766..84cfbd697 100644 --- a/source/blood/src/barf.cpp +++ b/source/blood/src/barf.cpp @@ -166,7 +166,7 @@ int RFS::Open(const char *fileName) { strcpy(_fileName, fileName); - auto hFile = kopenFileReader(fileName, 0); + auto hFile = fileSystem.OpenFileReader(fileName, 0); if (!hFile.isOpen()) { initprintf("BARF: Error opening file %s", _fileName); return 1; diff --git a/source/blood/src/credits.cpp b/source/blood/src/credits.cpp index bc579f1ce..f6f1dbc23 100644 --- a/source/blood/src/credits.cpp +++ b/source/blood/src/credits.cpp @@ -160,14 +160,14 @@ FileReader credKOpen4Load(char *&pzFile) if (pzFile[i] == '\\') pzFile[i] = '/'; } - auto nHandle = kopenFileReader(pzFile, 0); + auto nHandle = fileSystem.OpenFileReader(pzFile, 0); if (!nHandle.isOpen()) { // Hack if (nLen >= 3 && isalpha(pzFile[0]) && pzFile[1] == ':' && pzFile[2] == '/') { pzFile += 3; - nHandle = kopenFileReader(pzFile, 0); + nHandle = fileSystem.OpenFileReader(pzFile, 0); } } return nHandle; diff --git a/source/blood/src/inifile.cpp b/source/blood/src/inifile.cpp index b9263efe6..78fd149ec 100644 --- a/source/blood/src/inifile.cpp +++ b/source/blood/src/inifile.cpp @@ -130,7 +130,7 @@ void IniFile::Load() curNode = &head; - auto fp = kopenFileReader(fileName, 0); + auto fp = fileSystem.OpenFileReader(fileName, 0); if (fp.isOpen()) { int nSize = fp.GetLength(); diff --git a/source/blood/src/sound.cpp b/source/blood/src/sound.cpp index 235b0e495..dc1f87dcc 100644 --- a/source/blood/src/sound.cpp +++ b/source/blood/src/sound.cpp @@ -216,7 +216,7 @@ void sndStartWavDisk(const char *pzFile, int nVolume, int nChannel) pChannel = &Channel[nChannel]; if (pChannel->at0 > 0) sndKillSound(pChannel); - auto hFile = kopenFileReader(pzFile, 0); + auto hFile = fileSystem.OpenFileReader(pzFile, 0); if (!hFile.isOpen()) return; int nLength = hFile.GetLength(); diff --git a/source/blood/src/tile.cpp b/source/blood/src/tile.cpp index c700fbb76..cfb857af2 100644 --- a/source/blood/src/tile.cpp +++ b/source/blood/src/tile.cpp @@ -86,12 +86,12 @@ int tileInit(char a1, const char *a2) for (int i = 0; i < kMaxTiles; i++) voxelIndex[i] = 0; - auto hFile = kopenFileReader("SURFACE.DAT", 0); + auto hFile = fileSystem.OpenFileReader("SURFACE.DAT", 0); if (hFile.isOpen()) { hFile.Read(surfType, sizeof(surfType)); } - hFile = kopenFileReader("VOXEL.DAT", 0); + hFile = fileSystem.OpenFileReader("VOXEL.DAT", 0); if (hFile.isOpen()) { hFile.Read(voxelIndex, sizeof(voxelIndex)); @@ -100,7 +100,7 @@ int tileInit(char a1, const char *a2) voxelIndex[i] = B_LITTLE16(voxelIndex[i]); #endif } - hFile = kopenFileReader("SHADE.DAT", 0); + hFile = fileSystem.OpenFileReader("SHADE.DAT", 0); if (hFile.isOpen()) { hFile.Read(tileShade, sizeof(tileShade)); diff --git a/source/build/include/cache1d.h b/source/build/include/cache1d.h index 0468fe660..161425025 100644 --- a/source/build/include/cache1d.h +++ b/source/build/include/cache1d.h @@ -18,15 +18,6 @@ extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (e #include "filesystem/filesystem.h" -// Wrappers for the handle based API to get rid of the direct calls without any actual changes to the implementation. -// These are now getting redirected to the file system so that the implementation here can be gutted without making changes to the calling code. -inline FileReader kopenFileReader(const char* name, int where) -{ - auto lump = fileSystem.FindFile(name); - if (lump < 0) return FileReader(); - else return fileSystem.OpenFileReader(lump); -} - // This is only here to mark a file as not being part of the game assets (e.g. savegames) // These should be handled differently (e.g read from a userdata directory or similar things.) inline FileReader fopenFileReader(const char* name, int where) diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 872e2c299..7495fd5fd 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -2596,7 +2596,7 @@ static int32_t defsparser(scriptfile *script) break; } - FileReader fil = kopenFileReader(fn, 0); + FileReader fil = fileSystem.OpenFileReader(fn, 0); if (!fil.isOpen()) { initprintf("Error: basepalette: Failed opening \"%s\" on line %s:%d\n", fn, @@ -2770,7 +2770,7 @@ static int32_t defsparser(scriptfile *script) break; } - FileReader fil = kopenFileReader(fn, 0); + FileReader fil = fileSystem.OpenFileReader(fn, 0); if (!fil.isOpen()) { initprintf("Error: palookup: Failed opening \"%s\" on line %s:%d\n", fn, @@ -3063,7 +3063,7 @@ static int32_t defsparser(scriptfile *script) break; } - FileReader fil = kopenFileReader(fn, 0); + FileReader fil = fileSystem.OpenFileReader(fn, 0); if (!fil.isOpen()) { initprintf("Error: blendtable: Failed opening \"%s\" on line %s:%d\n", fn, diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 07f048c70..08d8cc25e 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -9447,7 +9447,7 @@ int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t flags &= 3; - FileReader fr = kopenFileReader(filename, 0); + FileReader fr = fileSystem.OpenFileReader(filename, 0); if (!fr.isOpen()) { mapversion = 7; return -1; } @@ -9639,7 +9639,7 @@ int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos, struct walltypev6 v6wall; struct spritetypev6 v6spr; - FileReader fr = kopenFileReader(filename, fromwhere); + FileReader fr = fileSystem.OpenFileReader(filename, fromwhere); if (!fr.isOpen()) { mapversion = 5L; return -1; } @@ -10109,7 +10109,7 @@ void videoNextPage(void) int32_t qloadkvx(int32_t voxindex, const char *filename) { - auto fil = kopenFileReader(filename, 0); + auto fil = fileSystem.OpenFileReader(filename, 0); if (!fil.isOpen()) return -1; diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 5fd32bd5d..a7d1191e0 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -1862,7 +1862,7 @@ mdmodel_t *mdload(const char *filnam) vm = (mdmodel_t *)voxload(filnam); if (vm) return vm; - auto fil = kopenFileReader(filnam,0); + auto fil = fileSystem.OpenFileReader(filnam,0); if (!fil.isOpen()) return NULL; diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp index bc0c09090..cf4c07e0e 100644 --- a/source/build/src/palette.cpp +++ b/source/build/src/palette.cpp @@ -179,7 +179,7 @@ void paletteLoadFromDisk(void) return; } - auto fil = kopenFileReader("palette.dat", 0); + auto fil = fileSystem.OpenFileReader("palette.dat", 0); if (!fil.isOpen()) return; diff --git a/source/build/src/scriptfile.cpp b/source/build/src/scriptfile.cpp index dd1fa5f88..5b7e02475 100644 --- a/source/build/src/scriptfile.cpp +++ b/source/build/src/scriptfile.cpp @@ -299,7 +299,7 @@ void scriptfile_preparse(scriptfile *sf, char *tx, int32_t flen) scriptfile *scriptfile_fromfile(const char *fn) { - auto fr = kopenFileReader(fn, 0); + auto fr = fileSystem.OpenFileReader(fn, 0); if (!fr.isOpen()) return nullptr; uint32_t flen = fr.GetLength(); diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 7bb7f7650..112f1d1c8 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -607,7 +607,7 @@ static void read_pal(FileReader &fil, int32_t pal[256]) static int32_t loadvox(const char *filnam) { - auto fil = kopenFileReader(filnam, 0); + auto fil = fileSystem.OpenFileReader(filnam, 0); if (!fil.isOpen()) return -1; @@ -683,7 +683,7 @@ static int32_t loadkvx(const char *filnam) { int32_t i, mip1leng; - auto fil = kopenFileReader(filnam, 0); + auto fil = fileSystem.OpenFileReader(filnam, 0); if (!fil.isOpen()) return -1; @@ -767,7 +767,7 @@ static int32_t loadkv6(const char *filnam) { int32_t i; - auto fil = kopenFileReader(filnam, 0); + auto fil = fileSystem.OpenFileReader(filnam, 0); if (!fil.isOpen()) return -1; diff --git a/source/common/filesystem/filesystem.cpp b/source/common/filesystem/filesystem.cpp index 05f022ad4..b7bbee4e1 100644 --- a/source/common/filesystem/filesystem.cpp +++ b/source/common/filesystem/filesystem.cpp @@ -770,6 +770,13 @@ FileReader FileSystem::ReopenFileReader(int lump, bool alwayscache) return rl->NewReader(); // This always gets a reader to the cache } +FileReader FileSystem::OpenFileReader(const char* name, int where) +{ + auto lump = FindFile(name); + if (lump < 0) return FileReader(); + else return OpenFileReader(lump); +} + //========================================================================== // // GetAllFilesOfType diff --git a/source/common/filesystem/filesystem.h b/source/common/filesystem/filesystem.h index 03d406728..9bce7a0be 100644 --- a/source/common/filesystem/filesystem.h +++ b/source/common/filesystem/filesystem.h @@ -127,6 +127,7 @@ public: FileReader OpenFileReader(int file); // opens a reader that redirects to the containing file's one. FileReader ReopenFileReader(int file, bool alwayscache = false); // opens an independent reader. + FileReader OpenFileReader(const char* name, int where); int Iterate (const char *name, int *lastfile, ELookupMode lookupmode = ELookupMode::FullName); // [RH] Find files with duplication diff --git a/source/common/fonts/v_font.cpp b/source/common/fonts/v_font.cpp index 0a1334513..a11beba66 100644 --- a/source/common/fonts/v_font.cpp +++ b/source/common/fonts/v_font.cpp @@ -93,7 +93,7 @@ FFont *V_GetFont(const char *name, const char *fontlumpname) FFont *font = FFont::FindFont (name); if (font == nullptr) { - auto lumpy = kopenFileReader(fontlumpname, 0); + auto lumpy = fileSystem.OpenFileReader(fontlumpname, 0); if (!lumpy.isOpen()) return nullptr; uint32_t head; lumpy.Read (&head, 4); diff --git a/source/common/openaudio.cpp b/source/common/openaudio.cpp index f57869096..423a17525 100644 --- a/source/common/openaudio.cpp +++ b/source/common/openaudio.cpp @@ -13,7 +13,7 @@ static FileReader S_TryFormats(char * const testfn, char * const fn_suffix, char #ifdef HAVE_FLAC { Bstrcpy(fn_suffix, ".flac"); - auto fp = kopenFileReader(testfn, searchfirst); + auto fp = fileSystem.OpenFileReader(testfn, searchfirst); if (fp.isOpen()) return fp; } @@ -22,7 +22,7 @@ static FileReader S_TryFormats(char * const testfn, char * const fn_suffix, char #ifdef HAVE_VORBIS { Bstrcpy(fn_suffix, ".ogg"); - auto fp = kopenFileReader(testfn, searchfirst); + auto fp = fileSystem.OpenFileReader(testfn, searchfirst); if (fp.isOpen()) return fp; } @@ -64,7 +64,7 @@ static FileReader S_TryExtensionReplacements(char * const testfn, char const sea FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t const ismusic) { - auto origfp = kopenFileReader(fn, searchfirst); + auto origfp = fileSystem.OpenFileReader(fn, searchfirst); if (!snd_tryformats) return origfp; return origfp; #if 0 // this needs to be redone diff --git a/source/common/rts.cpp b/source/common/rts.cpp index f0cb6a9f1..526826520 100644 --- a/source/common/rts.cpp +++ b/source/common/rts.cpp @@ -80,7 +80,7 @@ bool RTS_IsInitialized() { if (LumpInfo.Size() > 0) return true; if (RTSName.IsEmpty()) return false; - auto fr = kopenFileReader(RTSName, 0); + auto fr = fileSystem.OpenFileReader(RTSName, 0); RTSName = ""; // don't try ever again. if (!fr.isOpen()) return false; RTSFile = fr.Read(); diff --git a/source/common/textures/buildtiles.cpp b/source/common/textures/buildtiles.cpp index af0bb7f3e..bd21fafe7 100644 --- a/source/common/textures/buildtiles.cpp +++ b/source/common/textures/buildtiles.cpp @@ -287,7 +287,7 @@ int BuildTiles::LoadArtFile(const char *fn, bool mapart, int firsttile) auto old = FindFile(fn); if (old >= ArtFiles.Size()) // Do not process if already loaded. { - FileReader fr = kopenFileReader(fn, 0); + FileReader fr = fileSystem.OpenFileReader(fn, 0); if (fr.isOpen()) { auto artdata = fr.Read(); @@ -565,7 +565,7 @@ void artSetupMapArt(const char* filename) artClearMapArt(); FStringf firstname("%s_00.art", filename); - auto fr = kopenFileReader(firstname, 0); + auto fr = fileSystem.OpenFileReader(firstname, 0); if (!fr.isOpen()) return; for (bssize_t i = 0; i < MAXARTFILES_TOTAL - MAXARTFILES_BASE; i++) diff --git a/source/common/textures/formats/arttexture.cpp b/source/common/textures/formats/arttexture.cpp index 2f0d75ab7..b5c1157fd 100644 --- a/source/common/textures/formats/arttexture.cpp +++ b/source/common/textures/formats/arttexture.cpp @@ -118,7 +118,7 @@ FArtTexture::FArtTexture(int width, int height, int p) void FArtTexture::CreatePalettedPixels(uint8_t* buffer) { - FileReader fr = kopenFileReader(Name, 0); + FileReader fr = fileSystem.OpenFileReader(Name, 0); if (!fr.isOpen()) return; int numpixels = Width * Height; fr.Read(buffer, numpixels); @@ -139,7 +139,7 @@ int FArtTexture::CopyPixels(FBitmap *bmp, int conversion) // Both Src and Dst are ordered the same with no padding. int numpixels = Width * Height; bool hasalpha = false; - FileReader fr = kopenFileReader(Name, 0); + FileReader fr = fileSystem.OpenFileReader(Name, 0); if (!fr.isOpen()) return 0; TArray source(numpixels, true); fr.Read(source.Data(), numpixels); diff --git a/source/common/textures/formats/ddstexture.cpp b/source/common/textures/formats/ddstexture.cpp index f8160ba94..2d8a581b1 100644 --- a/source/common/textures/formats/ddstexture.cpp +++ b/source/common/textures/formats/ddstexture.cpp @@ -374,7 +374,7 @@ void FDDSTexture::CalcBitShift (uint32_t mask, uint8_t *lshiftp, uint8_t *rshift void FDDSTexture::CreatePalettedPixels(uint8_t *buffer) { - auto lump = kopenFileReader(Name, 0); + auto lump = fileSystem.OpenFileReader(Name, 0); if (!lump.isOpen()) return; // Just leave the texture blank. lump.Seek (sizeof(DDSURFACEDESC2) + 4, FileReader::SeekSet); @@ -781,7 +781,7 @@ void FDDSTexture::DecompressDXT5 (FileReader &lump, bool premultiplied, uint8_t int FDDSTexture::CopyPixels(FBitmap *bmp, int conversion) { - auto lump = kopenFileReader(Name, 0); + auto lump = fileSystem.OpenFileReader(Name, 0); if (!lump.isOpen()) return -1; // Just leave the texture blank. uint8_t *TexBuffer = bmp->GetPixels(); diff --git a/source/common/textures/formats/jpegtexture.cpp b/source/common/textures/formats/jpegtexture.cpp index 19404fd79..1adaaeebf 100644 --- a/source/common/textures/formats/jpegtexture.cpp +++ b/source/common/textures/formats/jpegtexture.cpp @@ -262,7 +262,7 @@ FJPEGTexture::FJPEGTexture (int width, int height) void FJPEGTexture::CreatePalettedPixels(uint8_t *buffer) { - auto lump = kopenFileReader(Name, 0); + auto lump = fileSystem.OpenFileReader(Name, 0); if (!lump.isOpen()) return; // Just leave the texture blank. JSAMPLE *buff = NULL; @@ -385,7 +385,7 @@ int FJPEGTexture::CopyPixels(FBitmap *bmp, int conversion) { PalEntry pe[256]; - auto lump = kopenFileReader(Name, 0); + auto lump = fileSystem.OpenFileReader(Name, 0); if (!lump.isOpen()) return -1; // Just leave the texture blank. jpeg_decompress_struct cinfo; diff --git a/source/common/textures/formats/pcxtexture.cpp b/source/common/textures/formats/pcxtexture.cpp index 807c1560f..69110bf0d 100644 --- a/source/common/textures/formats/pcxtexture.cpp +++ b/source/common/textures/formats/pcxtexture.cpp @@ -350,7 +350,7 @@ void FPCXTexture::CreatePalettedPixels(uint8_t *buffer) PCXHeader header; int bitcount; - auto lump = kopenFileReader(Name, 0); + auto lump = fileSystem.OpenFileReader(Name, 0); if (!lump.isOpen()) return; // Just leave the texture blank. lump.Read(&header, sizeof(header)); @@ -436,7 +436,7 @@ int FPCXTexture::CopyPixels(FBitmap *bmp, int conversion) int bitcount; TArray Pixels; - auto lump = kopenFileReader(Name, 0); + auto lump = fileSystem.OpenFileReader(Name, 0); if (!lump.isOpen()) return -1; // Just leave the texture blank. lump.Read(&header, sizeof(header)); diff --git a/source/common/textures/formats/pngtexture.cpp b/source/common/textures/formats/pngtexture.cpp index 21660c8d9..30dabba12 100644 --- a/source/common/textures/formats/pngtexture.cpp +++ b/source/common/textures/formats/pngtexture.cpp @@ -291,7 +291,7 @@ void FPNGTexture::CreatePalettedPixels(uint8_t *buffer) FileReader *lump; FileReader lfr; - lfr = kopenFileReader(Name, 0); + lfr = fileSystem.OpenFileReader(Name, 0); if (!lfr.isOpen()) return; lump = 𝔩 @@ -408,7 +408,7 @@ int FPNGTexture::CopyPixels(FBitmap *bmp, int conversion) FileReader *lump; FileReader lfr; - lfr = kopenFileReader(Name, 0); + lfr = fileSystem.OpenFileReader(Name, 0); if (!lfr.isOpen()) return -1; // Just leave the texture blank. lump = 𝔩 diff --git a/source/common/textures/formats/stbtexture.cpp b/source/common/textures/formats/stbtexture.cpp index e0dd82f63..78d6857fb 100644 --- a/source/common/textures/formats/stbtexture.cpp +++ b/source/common/textures/formats/stbtexture.cpp @@ -154,7 +154,7 @@ void FStbTexture::CreatePalettedPixels(uint8_t *buffer) int FStbTexture::CopyPixels(FBitmap *bmp, int conversion) { - auto lump = kopenFileReader(Name, 0); + auto lump = fileSystem.OpenFileReader(Name, 0); if (!lump.isOpen()) return -1; // Just leave the texture blank. int x, y, chan; auto image = stbi_load_from_callbacks(&callbacks, &lump, &x, &y, &chan, STBI_rgb_alpha); diff --git a/source/common/textures/formats/tgatexture.cpp b/source/common/textures/formats/tgatexture.cpp index 6a8596e72..323ad165f 100644 --- a/source/common/textures/formats/tgatexture.cpp +++ b/source/common/textures/formats/tgatexture.cpp @@ -179,7 +179,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe void FTGATexture::CreatePalettedPixels(uint8_t *buffer) { uint8_t PaletteMap[256]; - auto lump = kopenFileReader(Name, 0); + auto lump = fileSystem.OpenFileReader(Name, 0); if (!lump.isOpen()) return; TGAHeader hdr; uint16_t w; @@ -385,7 +385,7 @@ void FTGATexture::CreatePalettedPixels(uint8_t *buffer) int FTGATexture::CopyPixels(FBitmap *bmp, int conversion) { PalEntry pe[256]; - auto lump = kopenFileReader(Name, 0); + auto lump = fileSystem.OpenFileReader(Name, 0); if (!lump.isOpen()) return -1; TGAHeader hdr; uint16_t w; diff --git a/source/common/textures/image.cpp b/source/common/textures/image.cpp index 5fd7759e7..0e1154ba7 100644 --- a/source/common/textures/image.cpp +++ b/source/common/textures/image.cpp @@ -79,7 +79,7 @@ FImageSource * FImageSource::GetImage(const char *name) { nullptr } }; - auto data = kopenFileReader(name, 0); + auto data = fileSystem.OpenFileReader(name, 0); if (!data.isOpen()) return nullptr; for (size_t i = 0; CreateInfo[i].TryCreate; i++) diff --git a/source/common/utility/sc_man.cpp b/source/common/utility/sc_man.cpp index 0f09f1a36..8e848fa64 100644 --- a/source/common/utility/sc_man.cpp +++ b/source/common/utility/sc_man.cpp @@ -143,7 +143,7 @@ FScanner &FScanner::operator=(const FScanner &other) void FScanner::Open (const char *name) { - auto fr = kopenFileReader(name, 0); + auto fr = fileSystem.OpenFileReader(name, 0); if (!fr.isOpen()) { I_Error("Could not find script lump '%s'\n", name); diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index a0a0e2e02..3af7e8d8d 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -253,7 +253,7 @@ int32_t Anim_Play(const char *fn) FileReader handle; if (!Bstrcmp(dot, ".ivf")) { - handle = kopenFileReader(fn, 0); + handle = fileSystem.OpenFileReader(fn, 0); if (!handle.isOpen()) break; } @@ -272,7 +272,7 @@ int32_t Anim_Play(const char *fn) vpxfndot[3] = 'f'; vpxfndot[4] = '\0'; - handle = kopenFileReader(vpxfn, 0); + handle = fileSystem.OpenFileReader(vpxfn, 0); if (!handle.isOpen()) break; @@ -420,7 +420,7 @@ int32_t Anim_Play(const char *fn) int32_t ogltexfiltermode = hw_texfilter; #endif TArray buffer; - auto fr = kopenFileReader(fn, 0); + auto fr = fileSystem.OpenFileReader(fn, 0); if (!fr.isOpen()) goto end_anim; diff --git a/source/duke3d/src/common.cpp b/source/duke3d/src/common.cpp index 74f0e56ad..ff6be1845 100644 --- a/source/duke3d/src/common.cpp +++ b/source/duke3d/src/common.cpp @@ -106,7 +106,7 @@ void G_LoadLookups(void) { int32_t j; - auto fr = kopenFileReader("lookup.dat", 0); + auto fr = fileSystem.OpenFileReader("lookup.dat", 0); if (!fr.isOpen()) return; diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index ff5a202a2..a60d046af 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -1908,7 +1908,7 @@ static int C_CountCaseStatements() static void C_Include(const char *confile) { - auto fp = kopenFileReader(confile,0); + auto fp = fileSystem.OpenFileReader(confile,0); if (!fp.isOpen()) { @@ -5922,7 +5922,7 @@ void C_Compile(const char *fileName) Gv_Init(); C_InitProjectiles(); - auto kFile = kopenFileReader(fileName,0); + auto kFile = fileSystem.OpenFileReader(fileName,0); if (!kFile.isOpen()) { diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 4b222a273..a424567d8 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -49,7 +49,7 @@ extern int ydim; FileReader GetResource(const char* fn) { - auto fr = kopenFileReader(fn, 0); + auto fr = fileSystem.OpenFileReader(fn, 0); if (!fr.isOpen()) { I_Error("Fatal: '%s' not found", fn); diff --git a/source/libsmackerdec/src/FileStream.cpp b/source/libsmackerdec/src/FileStream.cpp index a14428392..cdb1eff0f 100644 --- a/source/libsmackerdec/src/FileStream.cpp +++ b/source/libsmackerdec/src/FileStream.cpp @@ -25,7 +25,7 @@ namespace SmackerCommon { bool FileStream::Open(const std::string &fileName) { - file = kopenFileReader(fileName.c_str(), 0); + file = fileSystem.OpenFileReader(fileName.c_str(), 0); if (!file.isOpen()) { // log error diff --git a/source/rr/src/anim.cpp b/source/rr/src/anim.cpp index 2eb9b20eb..9496492cb 100644 --- a/source/rr/src/anim.cpp +++ b/source/rr/src/anim.cpp @@ -289,7 +289,7 @@ int32_t Anim_Play(const char *fn) FileReader handle; if (!Bstrcmp(dot, ".ivf")) { - handle = kopenFileReader(fn, 0); + handle = fileSystem.OpenFileReader(fn, 0); if (!handle.isOpen()) break; } @@ -308,7 +308,7 @@ int32_t Anim_Play(const char *fn) vpxfndot[3] = 'f'; vpxfndot[4] = '\0'; - handle = kopenFileReader(vpxfn, 0); + handle = fileSystem.OpenFileReader(vpxfn, 0); if (!handle.isOpen()) break; @@ -451,7 +451,7 @@ int32_t Anim_Play(const char *fn) #ifdef USE_OPENGL int32_t ogltexfiltermode = hw_texfilter; #endif - auto fr = kopenFileReader(fn, 0); + auto fr = fileSystem.OpenFileReader(fn, 0); if (!fr.isOpen()) return 0; diff --git a/source/rr/src/common.cpp b/source/rr/src/common.cpp index 67af9e974..4ad9d1f6c 100644 --- a/source/rr/src/common.cpp +++ b/source/rr/src/common.cpp @@ -105,7 +105,7 @@ void G_LoadLookups(void) { int32_t j; - auto fr = kopenFileReader("lookup.dat", 0); + auto fr = fileSystem.OpenFileReader("lookup.dat", 0); if (!fr.isOpen()) return; diff --git a/source/rr/src/gamedef.cpp b/source/rr/src/gamedef.cpp index 15352437a..6941e90a9 100644 --- a/source/rr/src/gamedef.cpp +++ b/source/rr/src/gamedef.cpp @@ -780,7 +780,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr) static void C_Include(const char *confile) { - auto fp = kopenFileReader(confile,0); + auto fp = fileSystem.OpenFileReader(confile,0); if (!fp.isOpen()) { @@ -2220,7 +2220,7 @@ void C_Compile(const char *fileName) C_InitHashes(); - auto kFile = kopenFileReader(fileName,0); + auto kFile = fileSystem.OpenFileReader(fileName,0); if (!kFile.isOpen()) { diff --git a/source/sw/src/anim.cpp b/source/sw/src/anim.cpp index aec81d051..f602fc08c 100644 --- a/source/sw/src/anim.cpp +++ b/source/sw/src/anim.cpp @@ -243,7 +243,7 @@ unsigned char *LoadAnm(short anim_num) if (anm_ptr[anim_num] == 0) { - auto handle = kopenFileReader(ANIMname[ANIMnum], 0); + auto handle = fileSystem.OpenFileReader(ANIMname[ANIMnum], 0); if (!handle.isOpen()) return NULL; length = handle.GetLength(); diff --git a/source/sw/src/demo.h b/source/sw/src/demo.h index 0be471f6a..e0324923f 100644 --- a/source/sw/src/demo.h +++ b/source/sw/src/demo.h @@ -55,7 +55,7 @@ extern int DemoRecCnt; // Can only record 1-player game #if DEMO_FILE_TYPE == DEMO_FILE_GROUP typedef FileReader DFILE; #define DREAD(ptr, size, num, handle) (handle).Read((ptr),(size)*(num)) -#define DOPEN_READ(name) kopenFileReader(name,0) +#define DOPEN_READ(name) fileSystem.OpenFileReader(name,0) #define DCLOSE(handle) ((handle).Close()) #define DF_ERR(f) (!(f).isOpen()) #else diff --git a/source/sw/src/scrip2.cpp b/source/sw/src/scrip2.cpp index 10a95f557..ba19d1e30 100644 --- a/source/sw/src/scrip2.cpp +++ b/source/sw/src/scrip2.cpp @@ -81,7 +81,7 @@ SWBOOL LoadScriptFile(const char *filename) - if (!(fp = kopenFileReader(filename, 0)).isOpen()) + if (!(fp = fileSystem.OpenFileReader(filename, 0)).isOpen()) { // If there's no script file, forget it. return FALSE; diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index a8c1fb861..b668bd075 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -1055,7 +1055,7 @@ void PlaySoundRTS(int rts_num) SWBOOL OpenSound(VOC_INFOp vp, FileReader &handle, int *length) { - handle = kopenFileReader(vp->name, 0); + handle = fileSystem.OpenFileReader(vp->name, 0); if (!handle.isOpen()) { @@ -1085,7 +1085,7 @@ ReadSound(FileReader &handle, VOC_INFOp vp, int length) SWBOOL LoadSong(const char *filename) { - auto fr = kopenFileReader(filename, 0); + auto fr = fileSystem.OpenFileReader(filename, 0); if (!fr.isOpen()) { return FALSE; @@ -1170,7 +1170,7 @@ SoundShutdown(void) void MusicStartup(void) { #if 0 - auto fil = kopenFileReader("swtimbr.tmb", 0); + auto fil = fileSystem.OpenFileReader("swtimbr.tmb", 0); if (fil.isOpen()) {