- cleaned out the remaining wrappers from cache1d.h and use the file system directly instead.

This commit is contained in:
Christoph Oelckers 2019-12-07 10:49:23 +01:00
parent 30cbcb54b1
commit 0342b96335
24 changed files with 34 additions and 49 deletions

View file

@ -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

View file

@ -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_

View file

@ -11,7 +11,7 @@
#ifndef palette_h_
#define palette_h_
#include "cache1d.h"
#include "filesystem/filesystem.h"
#define MAXBASEPALS 256
#define MAXPALOOKUPS 256

View file

@ -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;

View file

@ -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'))

View file

@ -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();

View file

@ -34,7 +34,7 @@
**
*/
#include "cache1d.h"
#include "filesystem/filesystem.h"
#include "bitmap.h"
#include "image.h"
#include "imagehelpers.h"

View file

@ -40,7 +40,7 @@
#include "fontchars.h"
#include "printf.h"
#include "imagehelpers.h"
#include "cache1d.h"
#include "filesystem/filesystem.h"
#include "fontinternals.h"

View file

@ -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);

View file

@ -35,7 +35,7 @@
#include <stdint.h>
#include "zstring.h"
#include "tarray.h"
#include "cache1d.h"
#include "filesystem/filesystem.h"
#include "rts.h"
#include "m_swap.h"

View file

@ -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"

View file

@ -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.

View file

@ -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"

View file

@ -39,7 +39,7 @@
#include "bitmap.h"
#include "imagehelpers.h"
#include "image.h"
#include "cache1d.h"
#include "filesystem/filesystem.h"
//==========================================================================
//

View file

@ -41,7 +41,7 @@
#include "imagehelpers.h"
#include "image.h"
#include "printf.h"
#include "cache1d.h"
#include "filesystem/filesystem.h"
//==========================================================================
//

View file

@ -49,7 +49,7 @@
#include "bitmap.h"
#include "imagehelpers.h"
#include "image.h"
#include "cache1d.h"
#include "filesystem/filesystem.h"
//==========================================================================
//

View file

@ -37,7 +37,7 @@
#include "templates.h"
#include "bitmap.h"
#include "image.h"
#include "cache1d.h"
#include "filesystem/filesystem.h"
#include "imagehelpers.h"

View file

@ -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;

View file

@ -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<int64_t>(BigNumber, 0, UINT_MAX);
Float = (unsigned)Number;
}
else
{
BigNumber = strtoll(String, &stopper, 0);
Number = (int)clamp(BigNumber, INT_MIN, INT_MAX);
Number = (int)clamp<int64_t>(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<int64_t>(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<int64_t>(BigNumber, INT_MIN, INT_MAX);
if (*stopper != 0)
{
UnGet();

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -18,7 +18,7 @@
*/
#include "FileStream.h"
#include "cache1d.h"
#include "filesystem/filesystem.h"
#include <stdlib.h>
namespace SmackerCommon {

View file

@ -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);