mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-09 01:01:07 +00:00
Try to make use of win32/posix LFS for larger pk3s. Use a couple of other unsigned types for larger bsps too, now that we're supposedly able to exceed the 2gb limit on file sizes.
This commit is contained in:
parent
7bc708c607
commit
3ac910c32d
16 changed files with 69 additions and 55 deletions
|
@ -103,6 +103,8 @@ endif
|
|||
ifeq ($(USE_SDL2),1)
|
||||
CFLAGS += -DUSE_SDL2
|
||||
endif
|
||||
#make use of LFS on 32bit even on systems.
|
||||
CFLAGS += -D_FILE_OFFSET_BITS=64
|
||||
|
||||
ifeq ($(USE_SDL2),1)
|
||||
SDL_CONFIG ?= sdl2-config
|
||||
|
|
|
@ -70,7 +70,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int fileofs, filelen;
|
||||
unsigned int fileofs, filelen;
|
||||
} lump_t;
|
||||
|
||||
#define LUMP_ENTITIES 0
|
||||
|
|
|
@ -1896,7 +1896,7 @@ QUAKE FILESYSTEM
|
|||
=============================================================================
|
||||
*/
|
||||
|
||||
int com_filesize;
|
||||
qofs_t com_filesize;
|
||||
|
||||
|
||||
//
|
||||
|
@ -1905,14 +1905,14 @@ int com_filesize;
|
|||
typedef struct
|
||||
{
|
||||
char name[56];
|
||||
int filepos, filelen;
|
||||
unsigned int filepos, filelen;
|
||||
} dpackfile_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char id[4];
|
||||
int dirofs;
|
||||
int dirlen;
|
||||
unsigned int dirofs;
|
||||
unsigned int dirlen;
|
||||
} dpackheader_t;
|
||||
|
||||
#define MAX_FILES_IN_PACK 4096
|
||||
|
|
|
@ -222,11 +222,24 @@ char *va (const char *format, ...) FUNC_PRINTF(1,2);
|
|||
//============================================================================
|
||||
|
||||
// QUAKEFS
|
||||
#ifdef _WIN32
|
||||
#define qofs_t __int64 //LLP64 sucks and needs clumsy workarounds.
|
||||
#define fseek _fseeki64
|
||||
#define ftell _ftelli64
|
||||
#elif _POSIX_C_SOURCE >= 200112L
|
||||
#define qofs_t off_t //posix has its own LFS support for 32bit systems.
|
||||
#define fseek fseeko
|
||||
#define ftell ftello
|
||||
#else
|
||||
#define qofs_t long //LP64 just makes more sense. everything just works.
|
||||
#endif
|
||||
#define qofs_Make(low,high) ((unsigned int)(low) | ((qofs_t)(high)<<32))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
int filepos, filelen;
|
||||
int deflatedsize;
|
||||
qofs_t filepos, filelen;
|
||||
qofs_t deflatedsize;
|
||||
} packfile_t;
|
||||
|
||||
typedef struct pack_s
|
||||
|
@ -252,7 +265,7 @@ typedef struct searchpath_s
|
|||
extern searchpath_t *com_searchpaths;
|
||||
extern searchpath_t *com_base_searchpaths;
|
||||
|
||||
extern int com_filesize;
|
||||
extern qofs_t com_filesize;
|
||||
struct cache_user_s;
|
||||
|
||||
extern char com_basedir[MAX_OSPATH];
|
||||
|
@ -264,7 +277,7 @@ const char *COM_GetGameNames(qboolean full);
|
|||
qboolean COM_GameDirMatches(const char *tdirs);
|
||||
|
||||
pack_t *FSZIP_LoadArchive (const char *packfile);
|
||||
FILE *FSZIP_Deflate(FILE *src, int srcsize, int outsize);
|
||||
FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize);
|
||||
|
||||
void COM_WriteFile (const char *filename, const void *data, int len);
|
||||
int COM_OpenFile (const char *filename, int *handle, unsigned int *path_id);
|
||||
|
|
|
@ -82,7 +82,7 @@ unsigned short CRC_Value(unsigned short crcvalue)
|
|||
}
|
||||
|
||||
//johnfitz -- texture crc
|
||||
unsigned short CRC_Block (const byte *start, int count)
|
||||
unsigned short CRC_Block (const byte *start, size_t count)
|
||||
{
|
||||
unsigned short crc;
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
void CRC_Init(unsigned short *crcvalue);
|
||||
void CRC_ProcessByte(unsigned short *crcvalue, byte data);
|
||||
unsigned short CRC_Value(unsigned short crcvalue);
|
||||
unsigned short CRC_Block (const byte *start, int count); //johnfitz -- texture crc
|
||||
unsigned short CRC_Block (const byte *start, size_t count); //johnfitz -- texture crc
|
||||
|
||||
//additional hash functions...
|
||||
unsigned Com_BlockChecksum (void *buffer, int length);
|
||||
void Com_BlockFullChecksum (void *buffer, int len, unsigned char *outbuf);
|
||||
unsigned Com_BlockChecksum (void *buffer, size_t length);
|
||||
void Com_BlockFullChecksum (void *buffer, size_t len, unsigned char *outbuf);
|
||||
|
||||
#endif /* _QUAKE_CRC_H */
|
||||
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
//infozip utf-8 name override.
|
||||
//other 'extra' fields.
|
||||
|
||||
#define qofs_t long long
|
||||
#define qofs_Make(low,high) ((unsigned int)(low) | ((qofs_t)(high)<<32))
|
||||
|
||||
struct zipinfo
|
||||
{
|
||||
unsigned int thisdisk; //this disk number
|
||||
|
@ -747,7 +744,7 @@ pack_t *FSZIP_LoadArchive (const char *packfile)
|
|||
return pack;
|
||||
}
|
||||
|
||||
FILE *FSZIP_Deflate(FILE *src, int srcsize, int outsize)
|
||||
FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize)
|
||||
{
|
||||
#ifdef USE_ZLIB
|
||||
byte inbuffer[65536];
|
||||
|
|
|
@ -974,7 +974,7 @@ void Mod_LoadLighting (lump_t *l)
|
|||
return;
|
||||
}
|
||||
Hunk_FreeToLowMark(mark);
|
||||
Con_Printf("Outdated .lit file (%s should be %u bytes, not %u)\n", litfilename, 8+l->filelen*3, com_filesize);
|
||||
Con_Printf("Outdated .lit file (%s should be %u bytes, not %u)\n", litfilename, 8+l->filelen*3, (unsigned)com_filesize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -53,9 +53,9 @@ struct mdfour {
|
|||
};
|
||||
|
||||
static void mdfour_begin(struct mdfour *md); // old: MD4Init
|
||||
static void mdfour_update(struct mdfour *md, unsigned char *in, int n); //old: MD4Update
|
||||
static void mdfour_update(struct mdfour *md, unsigned char *in, size_t n); //old: MD4Update
|
||||
static void mdfour_result(struct mdfour *md, unsigned char *out); // old: MD4Final
|
||||
static void mdfour(unsigned char *out, unsigned char *in, int n);
|
||||
static void mdfour(unsigned char *out, unsigned char *in, size_t n);
|
||||
|
||||
#endif // _MDFOUR_H
|
||||
|
||||
|
@ -160,7 +160,7 @@ static void mdfour_begin(struct mdfour *md)
|
|||
}
|
||||
|
||||
|
||||
static void mdfour_tail(struct mdfour *m, unsigned char *in, int n)
|
||||
static void mdfour_tail(struct mdfour *m, unsigned char *in, size_t n)
|
||||
{
|
||||
unsigned char buf[128];
|
||||
uint32 M[16];
|
||||
|
@ -190,7 +190,7 @@ static void mdfour_tail(struct mdfour *m, unsigned char *in, int n)
|
|||
}
|
||||
}
|
||||
|
||||
static void mdfour_update(struct mdfour *m, unsigned char *in, int n)
|
||||
static void mdfour_update(struct mdfour *m, unsigned char *in, size_t n)
|
||||
{
|
||||
uint32 M[16];
|
||||
|
||||
|
@ -218,7 +218,7 @@ static void mdfour_result(struct mdfour *m, unsigned char *out)
|
|||
}
|
||||
|
||||
|
||||
static void mdfour(unsigned char *out, unsigned char *in, int n)
|
||||
static void mdfour(unsigned char *out, unsigned char *in, size_t n)
|
||||
{
|
||||
struct mdfour md;
|
||||
mdfour_begin(&md);
|
||||
|
@ -234,7 +234,7 @@ static void mdfour(unsigned char *out, unsigned char *in, int n)
|
|||
// Author: Jeff Teunissen <d2deek@pmail.net>
|
||||
// Date: 01 Jan 2000
|
||||
|
||||
unsigned Com_BlockChecksum (void *buffer, int length)
|
||||
unsigned Com_BlockChecksum (void *buffer, size_t length)
|
||||
{
|
||||
int digest[4];
|
||||
unsigned val;
|
||||
|
@ -246,7 +246,7 @@ unsigned Com_BlockChecksum (void *buffer, int length)
|
|||
return val;
|
||||
}
|
||||
|
||||
void Com_BlockFullChecksum (void *buffer, int len, unsigned char *outbuf)
|
||||
void Com_BlockFullChecksum (void *buffer, size_t len, unsigned char *outbuf)
|
||||
{
|
||||
mdfour ( outbuf, (unsigned char *) buffer, len );
|
||||
}
|
||||
|
|
|
@ -1300,7 +1300,7 @@ qboolean PR_LoadProgs (const char *filename, qboolean fatal, unsigned int needcr
|
|||
return false;
|
||||
}
|
||||
}
|
||||
Con_DPrintf ("%s occupies %iK.\n", filename, com_filesize/1024);
|
||||
Con_DPrintf ("%s occupies %uK.\n", filename, (unsigned)(com_filesize/1024u));
|
||||
|
||||
qcvm->functions = (dfunction_t *)((byte *)qcvm->progs + qcvm->progs->ofs_functions);
|
||||
qcvm->strings = (char *)qcvm->progs + qcvm->progs->ofs_strings;
|
||||
|
|
|
@ -3478,7 +3478,7 @@ void SV_SpawnServer (const char *server)
|
|||
if (csprogs)
|
||||
{
|
||||
Info_SetKey(svs.serverinfo, sizeof(svs.serverinfo), "*csprogs", va("%#x", Com_BlockChecksum(csprogs, com_filesize)));
|
||||
Info_SetKey(svs.serverinfo, sizeof(svs.serverinfo), "*csprogssize", va("%#x", com_filesize));
|
||||
Info_SetKey(svs.serverinfo, sizeof(svs.serverinfo), "*csprogssize", va("%#x", (unsigned)com_filesize));
|
||||
free(csprogs);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -32,12 +32,12 @@ void Sys_Init (void);
|
|||
|
||||
// returns the file size or -1 if file is not present.
|
||||
// the file should be in BINARY mode for stupid OSs that care
|
||||
int Sys_FileOpenRead (const char *path, int *hndl);
|
||||
qofs_t Sys_FileOpenRead (const char *path, int *hndl);
|
||||
int Sys_FileOpenWrite (const char *path);
|
||||
int Sys_FileOpenStdio (FILE *file);
|
||||
|
||||
void Sys_FileClose (int handle);
|
||||
void Sys_FileSeek (int handle, int position);
|
||||
void Sys_FileSeek (int handle, qofs_t position);
|
||||
int Sys_FileRead (int handle, void *dest, int count);
|
||||
int Sys_FileWrite (int handle,const void *data, int count);
|
||||
int Sys_FileTime (const char *path);
|
||||
|
|
|
@ -72,7 +72,7 @@ static int findhandle (void)
|
|||
return i;
|
||||
}
|
||||
|
||||
long Sys_filelength (FILE *f)
|
||||
qofs_t Sys_filelength (FILE *f)
|
||||
{
|
||||
long pos, end;
|
||||
|
||||
|
@ -84,10 +84,11 @@ long Sys_filelength (FILE *f)
|
|||
return end;
|
||||
}
|
||||
|
||||
int Sys_FileOpenRead (const char *path, int *hndl)
|
||||
qofs_t Sys_FileOpenRead (const char *path, int *hndl)
|
||||
{
|
||||
FILE *f;
|
||||
int i, retval;
|
||||
int i;
|
||||
qofs_t retval;
|
||||
|
||||
i = findhandle ();
|
||||
f = fopen(path, "rb");
|
||||
|
@ -136,7 +137,7 @@ void Sys_FileClose (int handle)
|
|||
sys_handles[handle] = NULL;
|
||||
}
|
||||
|
||||
void Sys_FileSeek (int handle, int position)
|
||||
void Sys_FileSeek (int handle, qofs_t position)
|
||||
{
|
||||
fseek (sys_handles[handle], position, SEEK_SET);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ static int findhandle (void)
|
|||
return i;
|
||||
}
|
||||
|
||||
long Sys_filelength (FILE *f)
|
||||
qofs_t Sys_filelength (FILE *f)
|
||||
{
|
||||
long pos, end;
|
||||
|
||||
|
@ -83,10 +83,11 @@ long Sys_filelength (FILE *f)
|
|||
return end;
|
||||
}
|
||||
|
||||
int Sys_FileOpenRead (const char *path, int *hndl)
|
||||
qofs_t Sys_FileOpenRead (const char *path, int *hndl)
|
||||
{
|
||||
FILE *f;
|
||||
int i, retval;
|
||||
int i;
|
||||
qofs_t retval;
|
||||
|
||||
i = findhandle ();
|
||||
f = fopen(path, "rb");
|
||||
|
@ -135,7 +136,7 @@ void Sys_FileClose (int handle)
|
|||
sys_handles[handle] = NULL;
|
||||
}
|
||||
|
||||
void Sys_FileSeek (int handle, int position)
|
||||
void Sys_FileSeek (int handle, qofs_t position)
|
||||
{
|
||||
fseek (sys_handles[handle], position, SEEK_SET);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
int wad_numlumps;
|
||||
unsigned int wad_numlumps;
|
||||
lumpinfo_t *wad_lumps;
|
||||
byte *wad_base = NULL;
|
||||
|
||||
|
@ -116,13 +116,13 @@ void W_LoadWadFile (void) //johnfitz -- filename is now hard-coded for honesty
|
|||
{
|
||||
if (lump_p->filepos > com_filesize || lump_p->size < 0)
|
||||
{
|
||||
Con_Printf ("Wad file %s lump \"%.16s\" begins %u bytes beyond end of wad\n",filename, lump_p->name, lump_p->filepos - com_filesize);
|
||||
Con_Printf ("Wad file %s lump \"%.16s\" begins %u bytes beyond end of wad\n",filename, lump_p->name, (unsigned)(lump_p->filepos - com_filesize));
|
||||
lump_p->filepos = 0;
|
||||
lump_p->size = q_max(0, lump_p->size-lump_p->filepos);
|
||||
}
|
||||
else
|
||||
{
|
||||
Con_Printf ("Wad file %s lump \"%.16s\" extends %u bytes beyond end of wad (lump size: %u)\n",filename, lump_p->name, (lump_p->filepos + lump_p->size) - com_filesize, lump_p->size);
|
||||
Con_Printf ("Wad file %s lump \"%.16s\" extends %u bytes beyond end of wad (lump size: %u)\n",filename, lump_p->name, (unsigned)((lump_p->filepos + lump_p->size) - com_filesize), lump_p->size);
|
||||
lump_p->size = q_max(0, lump_p->size-lump_p->filepos);
|
||||
}
|
||||
}
|
||||
|
|
30
Quake/wad.h
30
Quake/wad.h
|
@ -44,31 +44,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int width, height;
|
||||
byte data[4]; // variably sized
|
||||
unsigned int width, height;
|
||||
byte data[4]; // variably sized
|
||||
} qpic_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char identification[4]; // should be WAD2 or 2DAW
|
||||
int numlumps;
|
||||
int infotableofs;
|
||||
char identification[4]; // should be WAD2 or 2DAW
|
||||
unsigned int numlumps;
|
||||
unsigned int infotableofs;
|
||||
} wadinfo_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int filepos;
|
||||
int disksize;
|
||||
int size; // uncompressed
|
||||
char type;
|
||||
char compression;
|
||||
char pad1, pad2;
|
||||
char name[16]; // must be null terminated
|
||||
unsigned int filepos;
|
||||
unsigned int disksize;
|
||||
unsigned int size; // uncompressed
|
||||
char type;
|
||||
char compression;
|
||||
char pad1, pad2;
|
||||
char name[16]; // must be null terminated
|
||||
} lumpinfo_t;
|
||||
|
||||
extern int wad_numlumps;
|
||||
extern lumpinfo_t *wad_lumps;
|
||||
extern byte *wad_base;
|
||||
extern unsigned int wad_numlumps;
|
||||
extern lumpinfo_t *wad_lumps;
|
||||
extern byte *wad_base;
|
||||
|
||||
void W_LoadWadFile (void); //johnfitz -- filename is now hard-coded for honesty
|
||||
void *W_GetLumpName (const char *name, lumpinfo_t **out_info);
|
||||
|
|
Loading…
Reference in a new issue