diff --git a/source/blood/src/demo.cpp b/source/blood/src/demo.cpp index b00b89a5e..f83043659 100644 --- a/source/blood/src/demo.cpp +++ b/source/blood/src/demo.cpp @@ -212,16 +212,14 @@ bool CDemo::SetupPlayback(const char *pzFile) at1 = 0; if (pzFile) { - hPFile = fopenFileReader(pzFile, 0); - if (!hPFile.isOpen()) + if (!hPFile.OpenFile(pzFile)) return false; } else { if (!pCurrentDemo) return false; - hPFile = fopenFileReader(pCurrentDemo->zName, 0); - if (hPFile.isOpen()) + if (!hPFile.OpenFile(pCurrentDemo->zName)) return false; } hPFile.Read(&atf, sizeof(DEMOHEADER)); @@ -412,8 +410,8 @@ void CDemo::LoadDemoInfo(void) D_AddWildFile(demos, zFN); for (auto &filename : demos) { - auto hFile = fopenFileReader(filename, 0); - if (!hFile.isOpen()) + FileReader hFile; + if (!hFile.OpenFile(filename)) ThrowError("Error loading demo file header."); hFile.Read(&atf, sizeof(atf)); #if B_BIG_ENDIAN == 1 diff --git a/source/build/include/cache1d.h b/source/build/include/cache1d.h index 3d7dc8691..4e6983879 100644 --- a/source/build/include/cache1d.h +++ b/source/build/include/cache1d.h @@ -9,23 +9,7 @@ #ifndef cache1d_h_ #define cache1d_h_ -#include "compat.h" -#include "files.h" - void cacheAllocateBlock(intptr_t *newhandle, int32_t newbytes, uint8_t *newlockptr); -extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode) - -#include "filesystem/filesystem.h" - -// 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) -{ - FileReader fr; - fr.OpenFile(name); - return fr; -} - #endif // cache1d_h_ diff --git a/source/build/include/palette.h b/source/build/include/palette.h index 8bf75b49b..d8b6f0c21 100644 --- a/source/build/include/palette.h +++ b/source/build/include/palette.h @@ -11,7 +11,7 @@ #ifndef palette_h_ #define palette_h_ -#include "cache1d.h" +#include "filesystem/filesystem.h" #define MAXBASEPALS 256 #define MAXPALOOKUPS 256 diff --git a/source/build/src/common.cpp b/source/build/src/common.cpp index 4333aab95..5531f8d81 100644 --- a/source/build/src/common.cpp +++ b/source/build/src/common.cpp @@ -292,7 +292,8 @@ static char* KeyValues_FindKeyValue(char **vdfbuf, char * const vdfbufend, const void Paths_ParseSteamKeyValuesForPaths(const char *vdf, SteamPathParseFunc func) { - FileReader fr = fopenFileReader(vdf, 0); + FileReader fr; + if (!fr.OpenFile(vdf)) return; auto size = fr.GetLength(); char *vdfbuf, *vdfbufend; diff --git a/source/build/src/scriptfile.cpp b/source/build/src/scriptfile.cpp index 5b7e02475..e6103e68e 100644 --- a/source/build/src/scriptfile.cpp +++ b/source/build/src/scriptfile.cpp @@ -9,7 +9,7 @@ #include "scriptfile.h" #include "baselayer.h" #include "compat.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" #define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n')) diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 7bb988b39..112bd5193 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -667,8 +667,8 @@ static SDL_GameController *controller = NULL; static void LoadSDLControllerDB() { - auto fh = fopenFileReader("gamecontrollerdb.txt", 0); - if (!fh.isOpen()) + FileReader fh; + if (!fh.OpenFile("gamecontrollerdb.txt")) return; int flen = fh.GetLength(); diff --git a/source/common/fonts/fontchars.cpp b/source/common/fonts/fontchars.cpp index 7e8d0a26c..caa5a874d 100644 --- a/source/common/fonts/fontchars.cpp +++ b/source/common/fonts/fontchars.cpp @@ -34,7 +34,7 @@ ** */ -#include "cache1d.h" +#include "filesystem/filesystem.h" #include "bitmap.h" #include "image.h" #include "imagehelpers.h" diff --git a/source/common/fonts/singlelumpfont.cpp b/source/common/fonts/singlelumpfont.cpp index 5b80a01e9..47282ac97 100644 --- a/source/common/fonts/singlelumpfont.cpp +++ b/source/common/fonts/singlelumpfont.cpp @@ -40,7 +40,7 @@ #include "fontchars.h" #include "printf.h" #include "imagehelpers.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" #include "fontinternals.h" diff --git a/source/common/openaudio.h b/source/common/openaudio.h index e9fee2288..ac3a6c2de 100644 --- a/source/common/openaudio.h +++ b/source/common/openaudio.h @@ -1,4 +1,6 @@ #pragma once +#include "filesystem/filesystem.h" + // This really, really needs to be redone in its entirety, the audio lookup code is hideous. extern FileReader S_OpenAudio(const char *fn, char searchfirst, uint8_t ismusic); diff --git a/source/common/rts.cpp b/source/common/rts.cpp index 526826520..372d12805 100644 --- a/source/common/rts.cpp +++ b/source/common/rts.cpp @@ -35,7 +35,7 @@ #include #include "zstring.h" #include "tarray.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" #include "rts.h" #include "m_swap.h" diff --git a/source/common/secrets.cpp b/source/common/secrets.cpp index 2e2b32a78..d06700ca0 100644 --- a/source/common/secrets.cpp +++ b/source/common/secrets.cpp @@ -1,5 +1,5 @@ #include "c_dispatch.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" #include "printf.h" #include "v_text.h" #include "tarray.h" diff --git a/source/common/textures/formats/ddstexture.cpp b/source/common/textures/formats/ddstexture.cpp index 2d8a581b1..7527c4359 100644 --- a/source/common/textures/formats/ddstexture.cpp +++ b/source/common/textures/formats/ddstexture.cpp @@ -55,7 +55,7 @@ #include "imagehelpers.h" #include "image.h" #include "m_png.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" // Since we want this to compile under Linux too, we need to define this // stuff ourselves instead of including a DirectX header. diff --git a/source/common/textures/formats/jpegtexture.cpp b/source/common/textures/formats/jpegtexture.cpp index 1adaaeebf..5f3b0e2ad 100644 --- a/source/common/textures/formats/jpegtexture.cpp +++ b/source/common/textures/formats/jpegtexture.cpp @@ -40,7 +40,7 @@ #include "printf.h" #include "bitmap.h" #include "image.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" #include "imagehelpers.h" #include "v_text.h" diff --git a/source/common/textures/formats/pcxtexture.cpp b/source/common/textures/formats/pcxtexture.cpp index 69110bf0d..9a0c3d348 100644 --- a/source/common/textures/formats/pcxtexture.cpp +++ b/source/common/textures/formats/pcxtexture.cpp @@ -39,7 +39,7 @@ #include "bitmap.h" #include "imagehelpers.h" #include "image.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" //========================================================================== // diff --git a/source/common/textures/formats/pngtexture.cpp b/source/common/textures/formats/pngtexture.cpp index 30dabba12..1ed4dcf5d 100644 --- a/source/common/textures/formats/pngtexture.cpp +++ b/source/common/textures/formats/pngtexture.cpp @@ -41,7 +41,7 @@ #include "imagehelpers.h" #include "image.h" #include "printf.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" //========================================================================== // diff --git a/source/common/textures/formats/stbtexture.cpp b/source/common/textures/formats/stbtexture.cpp index 78d6857fb..d9bf916f2 100644 --- a/source/common/textures/formats/stbtexture.cpp +++ b/source/common/textures/formats/stbtexture.cpp @@ -49,7 +49,7 @@ #include "bitmap.h" #include "imagehelpers.h" #include "image.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" //========================================================================== // diff --git a/source/common/textures/formats/tgatexture.cpp b/source/common/textures/formats/tgatexture.cpp index 323ad165f..d920160e7 100644 --- a/source/common/textures/formats/tgatexture.cpp +++ b/source/common/textures/formats/tgatexture.cpp @@ -37,7 +37,7 @@ #include "templates.h" #include "bitmap.h" #include "image.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" #include "imagehelpers.h" diff --git a/source/common/textures/image.cpp b/source/common/textures/image.cpp index 0e1154ba7..39ee8018d 100644 --- a/source/common/textures/image.cpp +++ b/source/common/textures/image.cpp @@ -38,7 +38,7 @@ #include "bitmap.h" #include "image.h" #include "files.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" #include "imagehelpers.h" int FImageSource::NextID; diff --git a/source/common/utility/sc_man.cpp b/source/common/utility/sc_man.cpp index 8e848fa64..6cd7ff42a 100644 --- a/source/common/utility/sc_man.cpp +++ b/source/common/utility/sc_man.cpp @@ -20,7 +20,8 @@ #include "printf.h" #include "name.h" #include "v_text.h" -#include "cache1d.h" +#include "templates.h" +#include "filesystem/filesystem.h" // MACROS ------------------------------------------------------------------ @@ -544,13 +545,13 @@ bool FScanner::GetToken () { TokenType = TK_UIntConst; BigNumber = (int64_t)strtoull(String, &stopper, 0); - Number = (int)clamp(BigNumber, 0, UINT_MAX); + Number = (int)clamp(BigNumber, 0, UINT_MAX); Float = (unsigned)Number; } else { BigNumber = strtoll(String, &stopper, 0); - Number = (int)clamp(BigNumber, INT_MIN, INT_MAX); + Number = (int)clamp(BigNumber, INT_MIN, INT_MAX); Float = Number; } } @@ -652,7 +653,7 @@ bool FScanner::GetNumber () else { BigNumber = strtoll(String, &stopper, 0); - Number = (int)clamp(BigNumber, INT_MIN, INT_MAX); + Number = (int)clamp(BigNumber, INT_MIN, INT_MAX); if (*stopper != 0) { ScriptError ("SC_GetNumber: Bad numeric constant \"%s\".", String); @@ -709,7 +710,7 @@ bool FScanner::CheckNumber () else { BigNumber = strtoll (String, &stopper, 0); - Number = (int)clamp(BigNumber, INT_MIN, INT_MAX); + Number = (int)clamp(BigNumber, INT_MIN, INT_MAX); if (*stopper != 0) { UnGet(); diff --git a/source/duke3d/src/demo.cpp b/source/duke3d/src/demo.cpp index b06aa304b..0a2b00ddf 100644 --- a/source/duke3d/src/demo.cpp +++ b/source/duke3d/src/demo.cpp @@ -95,8 +95,7 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine demofnptr = demofn; } - g_demo_recFilePtr = fopenFileReader(demofnptr, g_loadFromGroupOnly); - if (!g_demo_recFilePtr.isOpen()) + if (!g_demo_recFilePtr.OpenFile(demofnptr)) return 0; Bassert(g_whichDemo >= 1); diff --git a/source/duke3d/src/demo.h b/source/duke3d/src/demo.h index d01128835..f27b0f9dd 100644 --- a/source/duke3d/src/demo.h +++ b/source/duke3d/src/demo.h @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define demo_h_ #include "compat.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" BEGIN_DUKE_NS diff --git a/source/duke3d/src/gamevars.h b/source/duke3d/src/gamevars.h index 66d0b8e22..9cc9717fd 100644 --- a/source/duke3d/src/gamevars.h +++ b/source/duke3d/src/gamevars.h @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "fix16.hpp" #include "gamedef.h" +#include "filesystem/filesystem.h" BEGIN_DUKE_NS diff --git a/source/libsmackerdec/src/FileStream.cpp b/source/libsmackerdec/src/FileStream.cpp index cdb1eff0f..5fd112fc1 100644 --- a/source/libsmackerdec/src/FileStream.cpp +++ b/source/libsmackerdec/src/FileStream.cpp @@ -18,7 +18,7 @@ */ #include "FileStream.h" -#include "cache1d.h" +#include "filesystem/filesystem.h" #include namespace SmackerCommon { diff --git a/source/rr/src/demo.cpp b/source/rr/src/demo.cpp index e459bc519..dd3917168 100644 --- a/source/rr/src/demo.cpp +++ b/source/rr/src/demo.cpp @@ -95,8 +95,7 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine demofnptr = demofn; } - g_demo_recFilePtr = fopenFileReader(demofnptr, g_loadFromGroupOnly); - if (!g_demo_recFilePtr.isOpen()) + if (!g_demo_recFilePtr.OpenFile(demofnptr)) return 0; Bassert(g_whichDemo >= 1);