mirror of
https://git.code.sf.net/p/quake/nuq
synced 2024-11-22 12:11:36 +00:00
first steps to getting zlib support in
This commit is contained in:
parent
dd3b346d4f
commit
279d332373
33 changed files with 498 additions and 301 deletions
2
TODO
2
TODO
|
@ -3,3 +3,5 @@
|
||||||
too slow due to overdraw
|
too slow due to overdraw
|
||||||
areas that should be black are greenish
|
areas that should be black are greenish
|
||||||
o make alsa support more generic for odd hw (eg gus)
|
o make alsa support more generic for odd hw (eg gus)
|
||||||
|
<LordHavoc> you must support skyboxes (in software and GL), transparency (in software and GL), colored lighting (at least in GL, and if you're doing the others, you might as well do it in software as well), two protocols (DarkPlaces for netplay compatibility, and the ancient neh_gl protocol for the movies, which is much simpler than DP protocol and very bloated), the menus (including the map list and all in the server setup)
|
||||||
|
<LordHavoc> here's some stuff you'll find amusing to try to support then: interpolated animations, DP protocol, DP particles (Nehahra uses the same particle engine, albeit an older version), mod music (honestly I skipped this myself, but nehahra uses 2 tunes), dzip support (I skipped this, and mindcrime seems to be in no hurry to actually use it)Z
|
||||||
|
|
|
@ -151,7 +151,7 @@ typedef struct
|
||||||
qboolean demoplayback;
|
qboolean demoplayback;
|
||||||
qboolean timedemo;
|
qboolean timedemo;
|
||||||
int forcetrack; // -1 = use normal cd track
|
int forcetrack; // -1 = use normal cd track
|
||||||
FILE *demofile;
|
QFile *demofile;
|
||||||
int td_lastframe; // to meter out one message a frame
|
int td_lastframe; // to meter out one message a frame
|
||||||
int td_startframe; // host_framecount at start
|
int td_startframe; // host_framecount at start
|
||||||
float td_starttime; // realtime at second frame of timedemo
|
float td_starttime; // realtime at second frame of timedemo
|
||||||
|
|
|
@ -114,7 +114,7 @@ qboolean Cvar_Command (void);
|
||||||
|
|
||||||
// Writes lines containing "set variable value" for all variables
|
// Writes lines containing "set variable value" for all variables
|
||||||
// with the archive flag set to true.
|
// with the archive flag set to true.
|
||||||
void Cvar_WriteVariables (FILE *f);
|
void Cvar_WriteVariables (QFile *f);
|
||||||
|
|
||||||
// Returns a pointer to the Cvar, NULL if not found
|
// Returns a pointer to the Cvar, NULL if not found
|
||||||
cvar_t *Cvar_FindVar (char *var_name);
|
cvar_t *Cvar_FindVar (char *var_name);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
void GIB_Module_Load (char *name, FILE *f);
|
void GIB_Module_Load (char *name, QFile *f);
|
||||||
gib_module_t *GIB_Create_Module (char *name);
|
gib_module_t *GIB_Create_Module (char *name);
|
||||||
gib_sub_t *GIB_Create_Sub (gib_module_t *mod, char *name);
|
gib_sub_t *GIB_Create_Sub (gib_module_t *mod, char *name);
|
||||||
void GIB_Read_Sub (gib_sub_t *sub, FILE *f);
|
void GIB_Read_Sub (gib_sub_t *sub, QFile *f);
|
||||||
gib_module_t *GIB_Find_Module (char *name);
|
gib_module_t *GIB_Find_Module (char *name);
|
||||||
gib_sub_t *GIB_Find_Sub (gib_module_t *mod, char *name);
|
gib_sub_t *GIB_Find_Sub (gib_module_t *mod, char *name);
|
||||||
void GIB_Stats_f (void);
|
void GIB_Stats_f (void);
|
||||||
|
|
|
@ -176,7 +176,7 @@ extern qboolean chat_team;
|
||||||
|
|
||||||
void Key_Event (int key, qboolean down);
|
void Key_Event (int key, qboolean down);
|
||||||
void Key_Init (void);
|
void Key_Init (void);
|
||||||
void Key_WriteBindings (FILE *f);
|
void Key_WriteBindings (QFile *f);
|
||||||
void Key_SetBinding (int keynum, char *binding);
|
void Key_SetBinding (int keynum, char *binding);
|
||||||
void Key_ClearStates (void);
|
void Key_ClearStates (void);
|
||||||
|
|
||||||
|
|
|
@ -93,10 +93,10 @@ char *ED_NewString (char *string);
|
||||||
// returns a copy of the string allocated from the server's string heap
|
// returns a copy of the string allocated from the server's string heap
|
||||||
|
|
||||||
void ED_Print (edict_t *ed);
|
void ED_Print (edict_t *ed);
|
||||||
void ED_Write (FILE *f, edict_t *ed);
|
void ED_Write (QFile *f, edict_t *ed);
|
||||||
char *ED_ParseEdict (char *data, edict_t *ent);
|
char *ED_ParseEdict (char *data, edict_t *ent);
|
||||||
|
|
||||||
void ED_WriteGlobals (FILE *f);
|
void ED_WriteGlobals (QFile *f);
|
||||||
void ED_ParseGlobals (char *data);
|
void ED_ParseGlobals (char *data);
|
||||||
|
|
||||||
void ED_LoadFromFile (char *data);
|
void ED_LoadFromFile (char *data);
|
||||||
|
|
|
@ -49,9 +49,9 @@ extern char com_gamedir[MAX_OSPATH];
|
||||||
extern char gamedirfile[MAX_OSPATH];
|
extern char gamedirfile[MAX_OSPATH];
|
||||||
|
|
||||||
void COM_WriteFile (char *filename, void *data, int len);
|
void COM_WriteFile (char *filename, void *data, int len);
|
||||||
int COM_FOpenFile (char *filename, FILE **gzfile);
|
int COM_FOpenFile (char *filename, QFile **gzfile);
|
||||||
void COM_CloseFile (FILE *h);
|
void COM_CloseFile (QFile *h);
|
||||||
int COM_filelength (FILE *f);
|
int COM_filelength (QFile *f);
|
||||||
void COM_FileBase (char *in, char *out);
|
void COM_FileBase (char *in, char *out);
|
||||||
void COM_DefaultExtension (char *path, char *extension);
|
void COM_DefaultExtension (char *path, char *extension);
|
||||||
char *COM_SkipPath (char *pathname);
|
char *COM_SkipPath (char *pathname);
|
||||||
|
|
|
@ -30,26 +30,41 @@
|
||||||
#ifndef _QUAKEIO_H
|
#ifndef _QUAKEIO_H
|
||||||
#define _QUAKEIO_H
|
#define _QUAKEIO_H
|
||||||
|
|
||||||
#include "gcc_attr.h"
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <stdio.h>
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <config.h>
|
#include <stdio.h>
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
#include <zlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "gcc_attr.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
FILE *file;
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
gzFile *gzfile;
|
||||||
|
#endif
|
||||||
|
} QFile;
|
||||||
|
|
||||||
void Qexpand_squiggle(const char *path, char *dest);
|
void Qexpand_squiggle(const char *path, char *dest);
|
||||||
int Qrename(const char *old, const char *new);
|
int Qrename(const char *old, const char *new);
|
||||||
FILE *Qopen(const char *path, const char *mode);
|
QFile *Qopen(const char *path, const char *mode);
|
||||||
FILE *Qdopen(int fd, const char *mode);
|
QFile *Qdopen(int fd, const char *mode);
|
||||||
void Qclose(FILE *file);
|
void Qclose(QFile *file);
|
||||||
int Qread(FILE *file, void *buf, int count);
|
int Qread(QFile *file, void *buf, int count);
|
||||||
int Qwrite(FILE *file, void *buf, int count);
|
int Qwrite(QFile *file, void *buf, int count);
|
||||||
int Qprintf(FILE *file, const char *fmt, ...) __attribute__((format(printf,2,3)));
|
int Qprintf(QFile *file, const char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||||
char *Qgets(FILE *file, char *buf, int count);
|
char *Qgets(QFile *file, char *buf, int count);
|
||||||
int Qgetc(FILE *file);
|
int Qgetc(QFile *file);
|
||||||
int Qputc(FILE *file, int c);
|
int Qputc(QFile *file, int c);
|
||||||
int Qseek(FILE *file, long offset, int whence);
|
int Qseek(QFile *file, long offset, int whence);
|
||||||
long Qtell(FILE *file);
|
long Qtell(QFile *file);
|
||||||
int Qflush(FILE *file);
|
int Qflush(QFile *file);
|
||||||
int Qeof(FILE *file);
|
int Qeof(QFile *file);
|
||||||
|
|
||||||
|
int Qgetpos(QFile *file, fpos_t *pos);
|
||||||
|
int Qsetpos(QFile *file, fpos_t *pos);
|
||||||
|
|
||||||
#endif /*_QUAKEIO_H*/
|
#endif /*_QUAKEIO_H*/
|
||||||
|
|
|
@ -67,7 +67,7 @@ void CL_StopPlayback (void)
|
||||||
if (!cls.demoplayback)
|
if (!cls.demoplayback)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fclose (cls.demofile);
|
Qclose (cls.demofile);
|
||||||
cls.demoplayback = false;
|
cls.demoplayback = false;
|
||||||
cls.demofile = NULL;
|
cls.demofile = NULL;
|
||||||
cls.state = ca_disconnected;
|
cls.state = ca_disconnected;
|
||||||
|
@ -90,14 +90,14 @@ void CL_WriteDemoMessage (void)
|
||||||
float f;
|
float f;
|
||||||
|
|
||||||
len = LittleLong (net_message.cursize);
|
len = LittleLong (net_message.cursize);
|
||||||
fwrite (&len, 4, 1, cls.demofile);
|
Qwrite (cls.demofile, &len, 4);
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
{
|
{
|
||||||
f = LittleFloat (cl.viewangles[i]);
|
f = LittleFloat (cl.viewangles[i]);
|
||||||
fwrite (&f, 4, 1, cls.demofile);
|
Qwrite (cls.demofile, &f, 4);
|
||||||
}
|
}
|
||||||
fwrite (net_message.data, net_message.cursize, 1, cls.demofile);
|
Qwrite (cls.demofile, net_message.data, net_message.cursize);
|
||||||
fflush (cls.demofile);
|
Qflush (cls.demofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -134,19 +134,19 @@ int CL_GetMessage (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the next message
|
// get the next message
|
||||||
fread (&net_message.cursize, 4, 1, cls.demofile);
|
Qread (cls.demofile, &net_message.cursize, 4);
|
||||||
VectorCopy (cl.mviewangles[0], cl.mviewangles[1]);
|
VectorCopy (cl.mviewangles[0], cl.mviewangles[1]);
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
{
|
{
|
||||||
r = fread (&f, 4, 1, cls.demofile);
|
r = Qread (cls.demofile, &f, 4);
|
||||||
cl.mviewangles[0][i] = LittleFloat (f);
|
cl.mviewangles[0][i] = LittleFloat (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
net_message.cursize = LittleLong (net_message.cursize);
|
net_message.cursize = LittleLong (net_message.cursize);
|
||||||
if (net_message.cursize > MAX_MSGLEN)
|
if (net_message.cursize > MAX_MSGLEN)
|
||||||
Sys_Error ("Demo message > MAX_MSGLEN");
|
Sys_Error ("Demo message > MAX_MSGLEN");
|
||||||
r = fread (net_message.data, net_message.cursize, 1, cls.demofile);
|
r = Qread (cls.demofile, net_message.data, net_message.cursize);
|
||||||
if (r != 1)
|
if (r != net_message.cursize)
|
||||||
{
|
{
|
||||||
CL_StopPlayback ();
|
CL_StopPlayback ();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -200,7 +200,7 @@ void CL_Stop_f (void)
|
||||||
CL_WriteDemoMessage ();
|
CL_WriteDemoMessage ();
|
||||||
|
|
||||||
// finish up
|
// finish up
|
||||||
fclose (cls.demofile);
|
Qclose (cls.demofile);
|
||||||
cls.demofile = NULL;
|
cls.demofile = NULL;
|
||||||
cls.demorecording = false;
|
cls.demorecording = false;
|
||||||
Con_Printf ("Completed demo\n");
|
Con_Printf ("Completed demo\n");
|
||||||
|
@ -264,7 +264,7 @@ void CL_Record_f (void)
|
||||||
COM_DefaultExtension (name, ".dem");
|
COM_DefaultExtension (name, ".dem");
|
||||||
|
|
||||||
Con_Printf ("recording to %s.\n", name);
|
Con_Printf ("recording to %s.\n", name);
|
||||||
cls.demofile = fopen (name, "wb");
|
cls.demofile = Qopen (name, "wb");
|
||||||
if (!cls.demofile)
|
if (!cls.demofile)
|
||||||
{
|
{
|
||||||
Con_Printf ("ERROR: couldn't open.\n");
|
Con_Printf ("ERROR: couldn't open.\n");
|
||||||
|
@ -272,7 +272,7 @@ void CL_Record_f (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.forcetrack = track;
|
cls.forcetrack = track;
|
||||||
fprintf (cls.demofile, "%i\n", cls.forcetrack);
|
Qprintf (cls.demofile, "%i\n", cls.forcetrack);
|
||||||
|
|
||||||
cls.demorecording = true;
|
cls.demorecording = true;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ void CL_PlayDemo_f (void)
|
||||||
cls.state = ca_connected;
|
cls.state = ca_connected;
|
||||||
cls.forcetrack = 0;
|
cls.forcetrack = 0;
|
||||||
|
|
||||||
while ((c = getc(cls.demofile)) != '\n')
|
while ((c = Qgetc(cls.demofile)) != '\n')
|
||||||
if (c == '-')
|
if (c == '-')
|
||||||
neg = true;
|
neg = true;
|
||||||
else
|
else
|
||||||
|
|
|
@ -342,9 +342,9 @@ Cmd_Exec_File (char *path)
|
||||||
int mark;
|
int mark;
|
||||||
int len;
|
int len;
|
||||||
char base[32];
|
char base[32];
|
||||||
FILE *file;
|
QFile *file;
|
||||||
|
|
||||||
if ((file = fopen (path, "r")) != NULL) {
|
if ((file = Qopen (path, "r")) != NULL) {
|
||||||
// extract the filename base name for hunk tag
|
// extract the filename base name for hunk tag
|
||||||
COM_FileBase (path, base);
|
COM_FileBase (path, base);
|
||||||
len = COM_filelength (file);
|
len = COM_filelength (file);
|
||||||
|
@ -352,8 +352,8 @@ Cmd_Exec_File (char *path)
|
||||||
f = (char *)Hunk_AllocName (len+1, base);
|
f = (char *)Hunk_AllocName (len+1, base);
|
||||||
if (f) {
|
if (f) {
|
||||||
f[len] = 0;
|
f[len] = 0;
|
||||||
fread (f, 1, len, file);
|
Qread (file, f, len);
|
||||||
fclose (file);
|
Qclose (file);
|
||||||
Cbuf_InsertText (f);
|
Cbuf_InsertText (f);
|
||||||
}
|
}
|
||||||
Hunk_FreeToLowMark (mark);
|
Hunk_FreeToLowMark (mark);
|
||||||
|
|
|
@ -52,7 +52,7 @@ being registered.
|
||||||
*/
|
*/
|
||||||
void COM_CheckRegistered (void)
|
void COM_CheckRegistered (void)
|
||||||
{
|
{
|
||||||
FILE *h;
|
QFile *h;
|
||||||
unsigned short check[128];
|
unsigned short check[128];
|
||||||
|
|
||||||
COM_FOpenFile("gfx/pop.lmp", &h);
|
COM_FOpenFile("gfx/pop.lmp", &h);
|
||||||
|
@ -60,8 +60,8 @@ void COM_CheckRegistered (void)
|
||||||
|
|
||||||
if (h) {
|
if (h) {
|
||||||
static_registered = 1;
|
static_registered = 1;
|
||||||
fread (check, 1, sizeof(check), h);
|
Qread (h, check, sizeof(check));
|
||||||
fclose (h);
|
Qclose (h);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (static_registered) {
|
if (static_registered) {
|
||||||
|
|
|
@ -289,13 +289,13 @@ Writes lines containing "set variable value" for all variables
|
||||||
with the archive flag set to true.
|
with the archive flag set to true.
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void Cvar_WriteVariables (FILE *f)
|
void Cvar_WriteVariables (QFile *f)
|
||||||
{
|
{
|
||||||
cvar_t *var;
|
cvar_t *var;
|
||||||
|
|
||||||
for (var = cvar_vars ; var ; var = var->next)
|
for (var = cvar_vars ; var ; var = var->next)
|
||||||
if (var->flags&CVAR_ARCHIVE)
|
if (var->flags&CVAR_ARCHIVE)
|
||||||
fprintf (f, "%s \"%s\"\n", var->name, var->string);
|
Qprintf (f, "%s \"%s\"\n", var->name, var->string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cvar_Set_f(void)
|
void Cvar_Set_f(void)
|
||||||
|
|
|
@ -55,14 +55,14 @@ void GIB_Gib_f (void)
|
||||||
void GIB_Load_f (void)
|
void GIB_Load_f (void)
|
||||||
{
|
{
|
||||||
char filename[256];
|
char filename[256];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
sprintf(filename, "%s/%s.gib", com_gamedir, Cmd_Argv(1));
|
sprintf(filename, "%s/%s.gib", com_gamedir, Cmd_Argv(1));
|
||||||
f = fopen(filename, "r");
|
f = Qopen(filename, "r");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
GIB_Module_Load(Cmd_Argv(1), f);
|
GIB_Module_Load(Cmd_Argv(1), f);
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Con_Printf("gibload: File not found.\n");
|
Con_Printf("gibload: File not found.\n");
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
static gib_module_t *gibmodules;
|
static gib_module_t *gibmodules;
|
||||||
|
|
||||||
void GIB_Module_Load (char *name, FILE *f)
|
void GIB_Module_Load (char *name, QFile *f)
|
||||||
{
|
{
|
||||||
char line[1024];
|
char line[1024];
|
||||||
gib_module_t *newmod;
|
gib_module_t *newmod;
|
||||||
|
@ -31,7 +31,7 @@ void GIB_Module_Load (char *name, FILE *f)
|
||||||
|
|
||||||
newmod = GIB_Create_Module(name);
|
newmod = GIB_Create_Module(name);
|
||||||
|
|
||||||
while (fgets(line, 1024, f))
|
while (Qgets(f, line, 1024))
|
||||||
{
|
{
|
||||||
if (strncmp("sub", line, 3) == 0)
|
if (strncmp("sub", line, 3) == 0)
|
||||||
{
|
{
|
||||||
|
@ -78,14 +78,14 @@ gib_sub_t *GIB_Create_Sub(gib_module_t *mod, char *name)
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GIB_Read_Sub(gib_sub_t *sub, FILE *f)
|
void GIB_Read_Sub(gib_sub_t *sub, QFile *f)
|
||||||
{
|
{
|
||||||
char line[1024];
|
char line[1024];
|
||||||
fpos_t begin;
|
fpos_t begin;
|
||||||
int sublen = 0;
|
int sublen = 0;
|
||||||
int insub = 0;
|
int insub = 0;
|
||||||
|
|
||||||
while (fgets(line, 1024, f))
|
while (Qgets(f, line, 1024))
|
||||||
{
|
{
|
||||||
if (strncmp("}}", line, 2) == 0 && insub == 1)
|
if (strncmp("}}", line, 2) == 0 && insub == 1)
|
||||||
{
|
{
|
||||||
|
@ -98,14 +98,14 @@ void GIB_Read_Sub(gib_sub_t *sub, FILE *f)
|
||||||
}
|
}
|
||||||
if (strncmp("{{", line, 2) == 0)
|
if (strncmp("{{", line, 2) == 0)
|
||||||
{
|
{
|
||||||
fgetpos(f, &begin);
|
Qgetpos(f, &begin);
|
||||||
insub = 1;
|
insub = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub->code = malloc(sublen + 1);
|
sub->code = malloc(sublen + 1);
|
||||||
fsetpos(f, &begin);
|
Qsetpos(f, &begin);
|
||||||
fread(sub->code, 1, sublen, f);
|
Qread(f, sub->code, sublen);
|
||||||
sub->code[sublen] = 0;
|
sub->code[sublen] = 0;
|
||||||
Con_Printf("Loaded sub %s\n", sub->name);
|
Con_Printf("Loaded sub %s\n", sub->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,7 +318,7 @@ void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
|
||||||
int *cmds;
|
int *cmds;
|
||||||
trivertx_t *verts;
|
trivertx_t *verts;
|
||||||
char cache[MAX_QPATH], fullpath[MAX_OSPATH];
|
char cache[MAX_QPATH], fullpath[MAX_OSPATH];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
aliasmodel = m;
|
aliasmodel = m;
|
||||||
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);
|
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);
|
||||||
|
@ -333,11 +333,11 @@ void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
|
||||||
COM_FOpenFile (cache, &f);
|
COM_FOpenFile (cache, &f);
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fread (&numcommands, 4, 1, f);
|
Qread (f, &numcommands, 4);
|
||||||
fread (&numorder, 4, 1, f);
|
Qread (f, &numorder, 4);
|
||||||
fread (&commands, numcommands * sizeof(commands[0]), 1, f);
|
Qread (f, &commands, numcommands * sizeof(commands[0]));
|
||||||
fread (&vertexorder, numorder * sizeof(vertexorder[0]), 1, f);
|
Qread (f, &vertexorder, numorder * sizeof(vertexorder[0]));
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -352,22 +352,22 @@ void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr)
|
||||||
// save out the cached version
|
// save out the cached version
|
||||||
//
|
//
|
||||||
snprintf (fullpath, sizeof(fullpath), "%s/%s", com_gamedir, cache);
|
snprintf (fullpath, sizeof(fullpath), "%s/%s", com_gamedir, cache);
|
||||||
f = fopen (fullpath, "wb");
|
f = Qopen (fullpath, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
char gldir[MAX_OSPATH];
|
char gldir[MAX_OSPATH];
|
||||||
|
|
||||||
snprintf (gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
snprintf (gldir, sizeof(gldir), "%s/glquake", com_gamedir);
|
||||||
Sys_mkdir (gldir);
|
Sys_mkdir (gldir);
|
||||||
f = fopen (fullpath, "wb");
|
f = Qopen (fullpath, "wb");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fwrite (&numcommands, 4, 1, f);
|
Qwrite (f, &numcommands, 4);
|
||||||
fwrite (&numorder, 4, 1, f);
|
Qwrite (f, &numorder, 4);
|
||||||
fwrite (&commands, numcommands * sizeof(commands[0]), 1, f);
|
Qwrite (f, &commands, numcommands * sizeof(commands[0]));
|
||||||
fwrite (&vertexorder, numorder * sizeof(vertexorder[0]), 1, f);
|
Qwrite (f, &vertexorder, numorder * sizeof(vertexorder[0]));
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -286,24 +286,24 @@ typedef struct _TargaHeader {
|
||||||
TargaHeader targa_header;
|
TargaHeader targa_header;
|
||||||
byte *targa_rgba;
|
byte *targa_rgba;
|
||||||
|
|
||||||
int fgetLittleShort (FILE *f)
|
int fgetLittleShort (QFile *f)
|
||||||
{
|
{
|
||||||
byte b1, b2;
|
byte b1, b2;
|
||||||
|
|
||||||
b1 = fgetc(f);
|
b1 = Qgetc(f);
|
||||||
b2 = fgetc(f);
|
b2 = Qgetc(f);
|
||||||
|
|
||||||
return (short)(b1 + b2*256);
|
return (short)(b1 + b2*256);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fgetLittleLong (FILE *f)
|
int fgetLittleLong (QFile *f)
|
||||||
{
|
{
|
||||||
byte b1, b2, b3, b4;
|
byte b1, b2, b3, b4;
|
||||||
|
|
||||||
b1 = fgetc(f);
|
b1 = Qgetc(f);
|
||||||
b2 = fgetc(f);
|
b2 = Qgetc(f);
|
||||||
b3 = fgetc(f);
|
b3 = Qgetc(f);
|
||||||
b4 = fgetc(f);
|
b4 = Qgetc(f);
|
||||||
|
|
||||||
return b1 + (b2<<8) + (b3<<16) + (b4<<24);
|
return b1 + (b2<<8) + (b3<<16) + (b4<<24);
|
||||||
}
|
}
|
||||||
|
@ -314,26 +314,26 @@ int fgetLittleLong (FILE *f)
|
||||||
LoadTGA
|
LoadTGA
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void LoadTGA (FILE *fin)
|
void LoadTGA (QFile *fin)
|
||||||
{
|
{
|
||||||
int columns, rows, numPixels;
|
int columns, rows, numPixels;
|
||||||
byte *pixbuf;
|
byte *pixbuf;
|
||||||
int row, column;
|
int row, column;
|
||||||
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
|
unsigned char red = 0, green = 0, blue = 0, alphabyte = 0;
|
||||||
|
|
||||||
targa_header.id_length = fgetc(fin);
|
targa_header.id_length = Qgetc(fin);
|
||||||
targa_header.colormap_type = fgetc(fin);
|
targa_header.colormap_type = Qgetc(fin);
|
||||||
targa_header.image_type = fgetc(fin);
|
targa_header.image_type = Qgetc(fin);
|
||||||
|
|
||||||
targa_header.colormap_index = fgetLittleShort(fin);
|
targa_header.colormap_index = fgetLittleShort(fin);
|
||||||
targa_header.colormap_length = fgetLittleShort(fin);
|
targa_header.colormap_length = fgetLittleShort(fin);
|
||||||
targa_header.colormap_size = fgetc(fin);
|
targa_header.colormap_size = Qgetc(fin);
|
||||||
targa_header.x_origin = fgetLittleShort(fin);
|
targa_header.x_origin = fgetLittleShort(fin);
|
||||||
targa_header.y_origin = fgetLittleShort(fin);
|
targa_header.y_origin = fgetLittleShort(fin);
|
||||||
targa_header.width = fgetLittleShort(fin);
|
targa_header.width = fgetLittleShort(fin);
|
||||||
targa_header.height = fgetLittleShort(fin);
|
targa_header.height = fgetLittleShort(fin);
|
||||||
targa_header.pixel_size = fgetc(fin);
|
targa_header.pixel_size = Qgetc(fin);
|
||||||
targa_header.attributes = fgetc(fin);
|
targa_header.attributes = Qgetc(fin);
|
||||||
|
|
||||||
if (targa_header.image_type!=2
|
if (targa_header.image_type!=2
|
||||||
&& targa_header.image_type!=10)
|
&& targa_header.image_type!=10)
|
||||||
|
@ -350,7 +350,7 @@ void LoadTGA (FILE *fin)
|
||||||
targa_rgba = malloc (numPixels*4);
|
targa_rgba = malloc (numPixels*4);
|
||||||
|
|
||||||
if (targa_header.id_length != 0)
|
if (targa_header.id_length != 0)
|
||||||
fseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
|
Qseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
|
||||||
|
|
||||||
if (targa_header.image_type==2) { // Uncompressed, RGB images
|
if (targa_header.image_type==2) { // Uncompressed, RGB images
|
||||||
for(row=rows-1; row>=0; row--) {
|
for(row=rows-1; row>=0; row--) {
|
||||||
|
@ -359,19 +359,19 @@ void LoadTGA (FILE *fin)
|
||||||
switch (targa_header.pixel_size) {
|
switch (targa_header.pixel_size) {
|
||||||
case 24:
|
case 24:
|
||||||
|
|
||||||
blue = getc(fin);
|
blue = Qgetc(fin);
|
||||||
green = getc(fin);
|
green = Qgetc(fin);
|
||||||
red = getc(fin);
|
red = Qgetc(fin);
|
||||||
*pixbuf++ = red;
|
*pixbuf++ = red;
|
||||||
*pixbuf++ = green;
|
*pixbuf++ = green;
|
||||||
*pixbuf++ = blue;
|
*pixbuf++ = blue;
|
||||||
*pixbuf++ = 255;
|
*pixbuf++ = 255;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
blue = getc(fin);
|
blue = Qgetc(fin);
|
||||||
green = getc(fin);
|
green = Qgetc(fin);
|
||||||
red = getc(fin);
|
red = Qgetc(fin);
|
||||||
alphabyte = getc(fin);
|
alphabyte = Qgetc(fin);
|
||||||
*pixbuf++ = red;
|
*pixbuf++ = red;
|
||||||
*pixbuf++ = green;
|
*pixbuf++ = green;
|
||||||
*pixbuf++ = blue;
|
*pixbuf++ = blue;
|
||||||
|
@ -386,21 +386,21 @@ void LoadTGA (FILE *fin)
|
||||||
for(row=rows-1; row>=0; row--) {
|
for(row=rows-1; row>=0; row--) {
|
||||||
pixbuf = targa_rgba + row*columns*4;
|
pixbuf = targa_rgba + row*columns*4;
|
||||||
for(column=0; column<columns; ) {
|
for(column=0; column<columns; ) {
|
||||||
packetHeader=getc(fin);
|
packetHeader=Qgetc(fin);
|
||||||
packetSize = 1 + (packetHeader & 0x7f);
|
packetSize = 1 + (packetHeader & 0x7f);
|
||||||
if (packetHeader & 0x80) { // run-length packet
|
if (packetHeader & 0x80) { // run-length packet
|
||||||
switch (targa_header.pixel_size) {
|
switch (targa_header.pixel_size) {
|
||||||
case 24:
|
case 24:
|
||||||
blue = getc(fin);
|
blue = Qgetc(fin);
|
||||||
green = getc(fin);
|
green = Qgetc(fin);
|
||||||
red = getc(fin);
|
red = Qgetc(fin);
|
||||||
alphabyte = 255;
|
alphabyte = 255;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
blue = getc(fin);
|
blue = Qgetc(fin);
|
||||||
green = getc(fin);
|
green = Qgetc(fin);
|
||||||
red = getc(fin);
|
red = Qgetc(fin);
|
||||||
alphabyte = getc(fin);
|
alphabyte = Qgetc(fin);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,19 +424,19 @@ void LoadTGA (FILE *fin)
|
||||||
for(j=0;j<packetSize;j++) {
|
for(j=0;j<packetSize;j++) {
|
||||||
switch (targa_header.pixel_size) {
|
switch (targa_header.pixel_size) {
|
||||||
case 24:
|
case 24:
|
||||||
blue = getc(fin);
|
blue = Qgetc(fin);
|
||||||
green = getc(fin);
|
green = Qgetc(fin);
|
||||||
red = getc(fin);
|
red = Qgetc(fin);
|
||||||
*pixbuf++ = red;
|
*pixbuf++ = red;
|
||||||
*pixbuf++ = green;
|
*pixbuf++ = green;
|
||||||
*pixbuf++ = blue;
|
*pixbuf++ = blue;
|
||||||
*pixbuf++ = 255;
|
*pixbuf++ = 255;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
blue = getc(fin);
|
blue = Qgetc(fin);
|
||||||
green = getc(fin);
|
green = Qgetc(fin);
|
||||||
red = getc(fin);
|
red = Qgetc(fin);
|
||||||
alphabyte = getc(fin);
|
alphabyte = Qgetc(fin);
|
||||||
*pixbuf++ = red;
|
*pixbuf++ = red;
|
||||||
*pixbuf++ = green;
|
*pixbuf++ = green;
|
||||||
*pixbuf++ = blue;
|
*pixbuf++ = blue;
|
||||||
|
@ -459,7 +459,7 @@ void LoadTGA (FILE *fin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fin);
|
Qclose(fin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -471,7 +471,7 @@ char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
|
||||||
void R_LoadSkys (char * skyname)
|
void R_LoadSkys (char * skyname)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char name[64];
|
char name[64];
|
||||||
|
|
||||||
if (stricmp (skyname, "none") == 0)
|
if (stricmp (skyname, "none") == 0)
|
||||||
|
|
|
@ -276,13 +276,13 @@ Writes key bindings and archived cvars to config.cfg
|
||||||
*/
|
*/
|
||||||
void Host_WriteConfiguration (void)
|
void Host_WriteConfiguration (void)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
// dedicated servers initialize the host but don't parse and set the
|
// dedicated servers initialize the host but don't parse and set the
|
||||||
// config.cfg cvars
|
// config.cfg cvars
|
||||||
if (host_initialized & !isDedicated)
|
if (host_initialized & !isDedicated)
|
||||||
{
|
{
|
||||||
f = fopen (va("%s/config.cfg",com_gamedir), "w");
|
f = Qopen (va("%s/config.cfg",com_gamedir), "w");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
Con_Printf ("Couldn't write config.cfg.\n");
|
Con_Printf ("Couldn't write config.cfg.\n");
|
||||||
|
@ -292,7 +292,7 @@ void Host_WriteConfiguration (void)
|
||||||
Key_WriteBindings (f);
|
Key_WriteBindings (f);
|
||||||
Cvar_WriteVariables (f);
|
Cvar_WriteVariables (f);
|
||||||
|
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,7 @@ Host_Savegame_f
|
||||||
void Host_Savegame_f (void)
|
void Host_Savegame_f (void)
|
||||||
{
|
{
|
||||||
char name[256];
|
char name[256];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
||||||
|
|
||||||
|
@ -536,30 +536,30 @@ void Host_Savegame_f (void)
|
||||||
COM_DefaultExtension (name, ".sav");
|
COM_DefaultExtension (name, ".sav");
|
||||||
|
|
||||||
Con_Printf ("Saving game to %s...\n", name);
|
Con_Printf ("Saving game to %s...\n", name);
|
||||||
f = fopen (name, "w");
|
f = Qopen (name, "w");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
Con_Printf ("ERROR: couldn't open.\n");
|
Con_Printf ("ERROR: couldn't open.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (f, "%i\n", SAVEGAME_VERSION);
|
Qprintf (f, "%i\n", SAVEGAME_VERSION);
|
||||||
Host_SavegameComment (comment);
|
Host_SavegameComment (comment);
|
||||||
fprintf (f, "%s\n", comment);
|
Qprintf (f, "%s\n", comment);
|
||||||
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||||
fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
||||||
fprintf (f, "%d\n", current_skill);
|
Qprintf (f, "%d\n", current_skill);
|
||||||
fprintf (f, "%s\n", sv.name);
|
Qprintf (f, "%s\n", sv.name);
|
||||||
fprintf (f, "%f\n",sv.time);
|
Qprintf (f, "%f\n",sv.time);
|
||||||
|
|
||||||
// write the light styles
|
// write the light styles
|
||||||
|
|
||||||
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
||||||
{
|
{
|
||||||
if (sv.lightstyles[i])
|
if (sv.lightstyles[i])
|
||||||
fprintf (f, "%s\n", sv.lightstyles[i]);
|
Qprintf (f, "%s\n", sv.lightstyles[i]);
|
||||||
else
|
else
|
||||||
fprintf (f,"m\n");
|
Qprintf (f,"m\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -567,9 +567,9 @@ void Host_Savegame_f (void)
|
||||||
for (i=0 ; i<sv.num_edicts ; i++)
|
for (i=0 ; i<sv.num_edicts ; i++)
|
||||||
{
|
{
|
||||||
ED_Write (f, EDICT_NUM(i));
|
ED_Write (f, EDICT_NUM(i));
|
||||||
fflush (f);
|
Qflush (f);
|
||||||
}
|
}
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
Con_Printf ("done.\n");
|
Con_Printf ("done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ Host_Loadgame_f
|
||||||
void Host_Loadgame_f (void)
|
void Host_Loadgame_f (void)
|
||||||
{
|
{
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char mapname[MAX_QPATH];
|
char mapname[MAX_QPATH];
|
||||||
float time, tfloat;
|
float time, tfloat;
|
||||||
char str[32768], *start;
|
char str[32768], *start;
|
||||||
|
@ -590,7 +590,8 @@ void Host_Loadgame_f (void)
|
||||||
edict_t *ent;
|
edict_t *ent;
|
||||||
int entnum;
|
int entnum;
|
||||||
int version;
|
int version;
|
||||||
float spawn_parms[NUM_SPAWN_PARMS];
|
float spawn_parms[NUM_SPAWN_PARMS];
|
||||||
|
char buf[100];
|
||||||
|
|
||||||
if (cmd_source != src_command)
|
if (cmd_source != src_command)
|
||||||
return;
|
return;
|
||||||
|
@ -611,25 +612,30 @@ void Host_Loadgame_f (void)
|
||||||
// SCR_BeginLoadingPlaque ();
|
// SCR_BeginLoadingPlaque ();
|
||||||
|
|
||||||
Con_Printf ("Loading game from %s...\n", name);
|
Con_Printf ("Loading game from %s...\n", name);
|
||||||
f = fopen (name, "r");
|
f = Qopen (name, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
Con_Printf ("ERROR: couldn't open.\n");
|
Con_Printf ("ERROR: couldn't open.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fscanf (f, "%i\n", &version);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%i\n", &version);
|
||||||
if (version != SAVEGAME_VERSION)
|
if (version != SAVEGAME_VERSION)
|
||||||
{
|
{
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fscanf (f, "%s\n", str);
|
Qgets(f,buf,sizeof(buf));
|
||||||
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
sscanf (buf, "%s\n", str);
|
||||||
fscanf (f, "%f\n", &spawn_parms[i]);
|
for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
|
||||||
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n", &spawn_parms[i]);
|
||||||
|
}
|
||||||
// this silliness is so we can load 1.06 save files, which have float skill values
|
// this silliness is so we can load 1.06 save files, which have float skill values
|
||||||
fscanf (f, "%f\n", &tfloat);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n", &tfloat);
|
||||||
current_skill = (int)(tfloat + 0.1);
|
current_skill = (int)(tfloat + 0.1);
|
||||||
Cvar_SetValue(skill, (float)current_skill);
|
Cvar_SetValue(skill, (float)current_skill);
|
||||||
|
|
||||||
|
@ -639,8 +645,10 @@ void Host_Loadgame_f (void)
|
||||||
Cvar_SetValue(teamplay, 0);
|
Cvar_SetValue(teamplay, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fscanf (f, "%s\n",mapname);
|
Qgets(f,buf,sizeof(buf));
|
||||||
fscanf (f, "%f\n",&time);
|
sscanf (buf, "%s\n",mapname);
|
||||||
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n",&time);
|
||||||
|
|
||||||
CL_Disconnect_f ();
|
CL_Disconnect_f ();
|
||||||
|
|
||||||
|
@ -661,18 +669,19 @@ void Host_Loadgame_f (void)
|
||||||
|
|
||||||
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
||||||
{
|
{
|
||||||
fscanf (f, "%s\n", str);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%s\n", str);
|
||||||
sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
|
sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
|
||||||
strcpy (sv.lightstyles[i], str);
|
strcpy (sv.lightstyles[i], str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the edicts out of the savegame file
|
// load the edicts out of the savegame file
|
||||||
entnum = -1; // -1 is the globals
|
entnum = -1; // -1 is the globals
|
||||||
while (!feof(f))
|
while (!Qeof(f))
|
||||||
{
|
{
|
||||||
for (i=0 ; i<sizeof(str)-1 ; i++)
|
for (i=0 ; i<sizeof(str)-1 ; i++)
|
||||||
{
|
{
|
||||||
r = fgetc (f);
|
r = Qgetc (f);
|
||||||
if (r == EOF || !r)
|
if (r == EOF || !r)
|
||||||
break;
|
break;
|
||||||
str[i] = r;
|
str[i] = r;
|
||||||
|
@ -715,7 +724,7 @@ void Host_Loadgame_f (void)
|
||||||
sv.num_edicts = entnum;
|
sv.num_edicts = entnum;
|
||||||
sv.time = time;
|
sv.time = time;
|
||||||
|
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
|
|
||||||
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||||
svs.clients->spawn_parms[i] = spawn_parms[i];
|
svs.clients->spawn_parms[i] = spawn_parms[i];
|
||||||
|
@ -731,7 +740,7 @@ void Host_Loadgame_f (void)
|
||||||
void SaveGamestate()
|
void SaveGamestate()
|
||||||
{
|
{
|
||||||
char name[256];
|
char name[256];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
||||||
edict_t *ent;
|
edict_t *ent;
|
||||||
|
@ -746,23 +755,23 @@ void SaveGamestate()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (f, "%i\n", SAVEGAME_VERSION);
|
Qprintf (f, "%i\n", SAVEGAME_VERSION);
|
||||||
Host_SavegameComment (comment);
|
Host_SavegameComment (comment);
|
||||||
fprintf (f, "%s\n", comment);
|
Qprintf (f, "%s\n", comment);
|
||||||
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||||
// fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
// Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
||||||
fprintf (f, "%f\n", skill->value);
|
Qprintf (f, "%f\n", skill->value);
|
||||||
fprintf (f, "%s\n", sv.name);
|
Qprintf (f, "%s\n", sv.name);
|
||||||
fprintf (f, "%f\n", sv.time);
|
Qprintf (f, "%f\n", sv.time);
|
||||||
|
|
||||||
// write the light styles
|
// write the light styles
|
||||||
|
|
||||||
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
||||||
{
|
{
|
||||||
if (sv.lightstyles[i])
|
if (sv.lightstyles[i])
|
||||||
fprintf (f, "%s\n", sv.lightstyles[i]);
|
Qprintf (f, "%s\n", sv.lightstyles[i]);
|
||||||
else
|
else
|
||||||
fprintf (f,"m\n");
|
Qprintf (f,"m\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -771,18 +780,18 @@ void SaveGamestate()
|
||||||
ent = EDICT_NUM(i);
|
ent = EDICT_NUM(i);
|
||||||
if ((int)ent->v.flags & FL_ARCHIVE_OVERRIDE)
|
if ((int)ent->v.flags & FL_ARCHIVE_OVERRIDE)
|
||||||
continue;
|
continue;
|
||||||
fprintf (f, "%i\n",i);
|
Qprintf (f, "%i\n",i);
|
||||||
ED_Write (f, ent);
|
ED_Write (f, ent);
|
||||||
fflush (f);
|
Qflush (f);
|
||||||
}
|
}
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
Con_Printf ("done.\n");
|
Con_Printf ("done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadGamestate(char *level, char *startspot)
|
int LoadGamestate(char *level, char *startspot)
|
||||||
{
|
{
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char mapname[MAX_QPATH];
|
char mapname[MAX_QPATH];
|
||||||
float time, sk;
|
float time, sk;
|
||||||
char str[32768], *start;
|
char str[32768], *start;
|
||||||
|
@ -802,21 +811,26 @@ int LoadGamestate(char *level, char *startspot)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fscanf (f, "%i\n", &version);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%i\n", &version);
|
||||||
if (version != SAVEGAME_VERSION)
|
if (version != SAVEGAME_VERSION)
|
||||||
{
|
{
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fscanf (f, "%s\n", str);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%s\n", str);
|
||||||
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||||
// fscanf (f, "%f\n", &spawn_parms[i]);
|
// fscanf (f, "%f\n", &spawn_parms[i]);
|
||||||
fscanf (f, "%f\n", &sk);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n", &sk);
|
||||||
Cvar_SetValue(skill, sk);
|
Cvar_SetValue(skill, sk);
|
||||||
|
|
||||||
fscanf (f, "%s\n",mapname);
|
Qgets(f,buf,sizeof(buf));
|
||||||
fscanf (f, "%f\n",&time);
|
sscanf (buf, "%s\n",mapname);
|
||||||
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%f\n",&time);
|
||||||
|
|
||||||
SV_SpawnServer (mapname, startspot);
|
SV_SpawnServer (mapname, startspot);
|
||||||
|
|
||||||
|
@ -829,7 +843,8 @@ int LoadGamestate(char *level, char *startspot)
|
||||||
// load the light styles
|
// load the light styles
|
||||||
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
||||||
{
|
{
|
||||||
fscanf (f, "%s\n", str);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%s\n", str);
|
||||||
sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
|
sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
|
||||||
strcpy (sv.lightstyles[i], str);
|
strcpy (sv.lightstyles[i], str);
|
||||||
}
|
}
|
||||||
|
@ -837,7 +852,8 @@ int LoadGamestate(char *level, char *startspot)
|
||||||
// load the edicts out of the savegame file
|
// load the edicts out of the savegame file
|
||||||
while (!feof(f))
|
while (!feof(f))
|
||||||
{
|
{
|
||||||
fscanf (f, "%i\n",&entnum);
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%i\n",&entnum);
|
||||||
for (i=0 ; i<sizeof(str)-1 ; i++)
|
for (i=0 ; i<sizeof(str)-1 ; i++)
|
||||||
{
|
{
|
||||||
r = fgetc (f);
|
r = fgetc (f);
|
||||||
|
@ -874,7 +890,7 @@ int LoadGamestate(char *level, char *startspot)
|
||||||
|
|
||||||
// sv.num_edicts = entnum;
|
// sv.num_edicts = entnum;
|
||||||
sv.time = time;
|
sv.time = time;
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
|
|
||||||
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
// for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||||
// svs.clients->spawn_parms[i] = spawn_parms[i];
|
// svs.clients->spawn_parms[i] = spawn_parms[i];
|
||||||
|
|
|
@ -561,14 +561,14 @@ Key_WriteBindings
|
||||||
Writes lines containing "bind key value"
|
Writes lines containing "bind key value"
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void Key_WriteBindings (FILE *f)
|
void Key_WriteBindings (QFile *f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0 ; i<256 ; i++)
|
for (i=0 ; i<256 ; i++)
|
||||||
if (keybindings[i])
|
if (keybindings[i])
|
||||||
if (*keybindings[i])
|
if (*keybindings[i])
|
||||||
fprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString(i), keybindings[i]);
|
Qprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString(i), keybindings[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -473,19 +473,23 @@ void M_ScanSaves (void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int version;
|
int version;
|
||||||
|
char buf[100];
|
||||||
|
|
||||||
for (i=0 ; i<MAX_SAVEGAMES ; i++)
|
for (i=0 ; i<MAX_SAVEGAMES ; i++)
|
||||||
{
|
{
|
||||||
strcpy (m_filenames[i], "--- UNUSED SLOT ---");
|
strcpy (m_filenames[i], "--- UNUSED SLOT ---");
|
||||||
loadable[i] = false;
|
loadable[i] = false;
|
||||||
snprintf (name, sizeof(name), "%s/s%i.sav", com_gamedir, i);
|
snprintf (name, sizeof(name), "%s/s%i.sav", com_gamedir, i);
|
||||||
f = fopen (name, "r");
|
f = Qopen (name, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
continue;
|
continue;
|
||||||
fscanf (f, "%i\n", &version);
|
Qgets(f,buf,sizeof(buf));
|
||||||
fscanf (f, "%79s\n", name);
|
sscanf (buf, "%i\n", &version);
|
||||||
|
Qgets(f,buf,sizeof(buf));
|
||||||
|
sscanf (buf, "%79s\n", name);
|
||||||
|
|
||||||
strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1);
|
strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1);
|
||||||
|
|
||||||
// change _ back to space
|
// change _ back to space
|
||||||
|
@ -493,7 +497,7 @@ void M_ScanSaves (void)
|
||||||
if (m_filenames[i][j] == '_')
|
if (m_filenames[i][j] == '_')
|
||||||
m_filenames[i][j] = ' ';
|
m_filenames[i][j] = ' ';
|
||||||
loadable[i] = true;
|
loadable[i] = true;
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -501,7 +501,7 @@ ED_Write
|
||||||
For savegames
|
For savegames
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void ED_Write (FILE *f, edict_t *ed)
|
void ED_Write (QFile *f, edict_t *ed)
|
||||||
{
|
{
|
||||||
ddef_t *d;
|
ddef_t *d;
|
||||||
int *v;
|
int *v;
|
||||||
|
@ -509,11 +509,11 @@ void ED_Write (FILE *f, edict_t *ed)
|
||||||
char *name;
|
char *name;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
fprintf (f, "{\n");
|
Qprintf (f, "{\n");
|
||||||
|
|
||||||
if (ed->free)
|
if (ed->free)
|
||||||
{
|
{
|
||||||
fprintf (f, "}\n");
|
Qprintf (f, "}\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,11 +534,11 @@ void ED_Write (FILE *f, edict_t *ed)
|
||||||
if (j == type_size[type])
|
if (j == type_size[type])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fprintf (f,"\"%s\" ",name);
|
Qprintf (f,"\"%s\" ",name);
|
||||||
fprintf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v));
|
Qprintf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v));
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (f, "}\n");
|
Qprintf (f, "}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ED_PrintNum (int ent)
|
void ED_PrintNum (int ent)
|
||||||
|
@ -632,14 +632,14 @@ FIXME: need to tag constants, doesn't really work
|
||||||
ED_WriteGlobals
|
ED_WriteGlobals
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void ED_WriteGlobals (FILE *f)
|
void ED_WriteGlobals (QFile *f)
|
||||||
{
|
{
|
||||||
ddef_t *def;
|
ddef_t *def;
|
||||||
int i;
|
int i;
|
||||||
char *name;
|
char *name;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
fprintf (f,"{\n");
|
Qprintf (f,"{\n");
|
||||||
for (i=0 ; i<progs->numglobaldefs ; i++)
|
for (i=0 ; i<progs->numglobaldefs ; i++)
|
||||||
{
|
{
|
||||||
def = &pr_globaldefs[i];
|
def = &pr_globaldefs[i];
|
||||||
|
@ -654,10 +654,10 @@ void ED_WriteGlobals (FILE *f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
name = pr_strings + def->s_name;
|
name = pr_strings + def->s_name;
|
||||||
fprintf (f,"\"%s\" ", name);
|
Qprintf (f,"\"%s\" ", name);
|
||||||
fprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs]));
|
Qprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs]));
|
||||||
}
|
}
|
||||||
fprintf (f,"}\n");
|
Qprintf (f,"}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -127,7 +127,7 @@ typedef struct
|
||||||
typedef struct pack_s
|
typedef struct pack_s
|
||||||
{
|
{
|
||||||
char filename[MAX_OSPATH];
|
char filename[MAX_OSPATH];
|
||||||
FILE *handle;
|
QFile *handle;
|
||||||
int numfiles;
|
int numfiles;
|
||||||
packfile_t *files;
|
packfile_t *files;
|
||||||
} pack_t;
|
} pack_t;
|
||||||
|
@ -192,15 +192,15 @@ COM_FileBase (char *in, char *out)
|
||||||
COM_filelength
|
COM_filelength
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
COM_filelength (FILE *f)
|
COM_filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
pos = ftell (f);
|
pos = Qtell (f);
|
||||||
fseek (f, 0, SEEK_END);
|
Qseek (f, 0, SEEK_END);
|
||||||
end = ftell (f);
|
end = Qtell (f);
|
||||||
fseek (f, pos, SEEK_SET);
|
Qseek (f, pos, SEEK_SET);
|
||||||
|
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
@ -209,11 +209,11 @@ COM_filelength (FILE *f)
|
||||||
COM_FileOpenRead
|
COM_FileOpenRead
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
COM_FileOpenRead (char *path, FILE **hndl)
|
COM_FileOpenRead (char *path, QFile **hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
*hndl = NULL;
|
*hndl = NULL;
|
||||||
|
@ -291,22 +291,22 @@ COM_Maplist_f ( void )
|
||||||
void
|
void
|
||||||
COM_WriteFile ( char *filename, void *data, int len )
|
COM_WriteFile ( char *filename, void *data, int len )
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s/%s", com_gamedir, filename);
|
snprintf(name, sizeof(name), "%s/%s", com_gamedir, filename);
|
||||||
|
|
||||||
f = fopen (name, "wb");
|
f = Qopen (name, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
Sys_mkdir(com_gamedir);
|
Sys_mkdir(com_gamedir);
|
||||||
f = fopen (name, "wb");
|
f = Qopen (name, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
Sys_Error ("Error opening %s", filename);
|
Sys_Error ("Error opening %s", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sys_Printf ("COM_WriteFile: %s\n", name);
|
Sys_Printf ("COM_WriteFile: %s\n", name);
|
||||||
fwrite (data, 1, len, f);
|
Qwrite (f, data, len);
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -344,13 +344,13 @@ COM_CreatePath ( char *path )
|
||||||
void
|
void
|
||||||
COM_CopyFile (char *netpath, char *cachepath)
|
COM_CopyFile (char *netpath, char *cachepath)
|
||||||
{
|
{
|
||||||
FILE *in, *out;
|
QFile *in, *out;
|
||||||
int remaining, count;
|
int remaining, count;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
remaining = COM_FileOpenRead (netpath, &in);
|
remaining = COM_FileOpenRead (netpath, &in);
|
||||||
COM_CreatePath (cachepath); // create directories up to the cache file
|
COM_CreatePath (cachepath); // create directories up to the cache file
|
||||||
out = fopen(cachepath, "wb");
|
out = Qopen(cachepath, "wb");
|
||||||
if (!out)
|
if (!out)
|
||||||
Sys_Error ("Error opening %s", cachepath);
|
Sys_Error ("Error opening %s", cachepath);
|
||||||
|
|
||||||
|
@ -360,19 +360,19 @@ COM_CopyFile (char *netpath, char *cachepath)
|
||||||
count = remaining;
|
count = remaining;
|
||||||
else
|
else
|
||||||
count = sizeof(buf);
|
count = sizeof(buf);
|
||||||
fread (buf, 1, count, in);
|
Qread (in, buf, count);
|
||||||
fwrite (buf, 1, count, out);
|
Qwrite (out, buf, count);
|
||||||
remaining -= count;
|
remaining -= count;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (in);
|
Qclose (in);
|
||||||
fclose (out);
|
Qclose (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
COM_OpenRead
|
COM_OpenRead
|
||||||
*/
|
*/
|
||||||
FILE *
|
QFile *
|
||||||
COM_OpenRead (const char *path, int offs, int len)
|
COM_OpenRead (const char *path, int offs, int len)
|
||||||
{
|
{
|
||||||
int fd=open(path,O_RDONLY);
|
int fd=open(path,O_RDONLY);
|
||||||
|
@ -403,7 +403,7 @@ COM_OpenRead (const char *path, int offs, int len)
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
setmode(fd,O_BINARY);
|
setmode(fd,O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
return fdopen(fd,"rb");
|
return Qdopen(fd,"rb");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ int file_from_pak; // global indicating file came from pack file ZOID
|
||||||
Sets com_filesize and one of handle or file
|
Sets com_filesize and one of handle or file
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
COM_FOpenFile (char *filename, FILE **gzfile)
|
COM_FOpenFile (char *filename, QFile **gzfile)
|
||||||
{
|
{
|
||||||
searchpath_t *search;
|
searchpath_t *search;
|
||||||
char netpath[MAX_OSPATH];
|
char netpath[MAX_OSPATH];
|
||||||
|
@ -492,7 +492,7 @@ int loadsize;
|
||||||
byte *
|
byte *
|
||||||
COM_LoadFile (char *path, int usehunk)
|
COM_LoadFile (char *path, int usehunk)
|
||||||
{
|
{
|
||||||
FILE *h;
|
QFile *h;
|
||||||
byte *buf;
|
byte *buf;
|
||||||
char base[32];
|
char base[32];
|
||||||
int len;
|
int len;
|
||||||
|
@ -532,8 +532,8 @@ COM_LoadFile (char *path, int usehunk)
|
||||||
//if (!is_server) {
|
//if (!is_server) {
|
||||||
Draw_BeginDisc();
|
Draw_BeginDisc();
|
||||||
//}
|
//}
|
||||||
fread (buf, 1, len, h);
|
Qread (h, buf, len);
|
||||||
fclose (h);
|
Qclose (h);
|
||||||
//if (!is_server) {
|
//if (!is_server) {
|
||||||
Draw_EndDisc();
|
Draw_EndDisc();
|
||||||
//}
|
//}
|
||||||
|
@ -589,13 +589,13 @@ COM_LoadPackFile (char *packfile)
|
||||||
packfile_t *newfiles;
|
packfile_t *newfiles;
|
||||||
int numpackfiles;
|
int numpackfiles;
|
||||||
pack_t *pack;
|
pack_t *pack;
|
||||||
FILE *packhandle;
|
QFile *packhandle;
|
||||||
dpackfile_t info[MAX_FILES_IN_PACK];
|
dpackfile_t info[MAX_FILES_IN_PACK];
|
||||||
|
|
||||||
if (COM_FileOpenRead (packfile, &packhandle) == -1)
|
if (COM_FileOpenRead (packfile, &packhandle) == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
fread (&header, 1, sizeof(header), packhandle);
|
Qread (packhandle, &header, sizeof(header));
|
||||||
if (header.id[0] != 'P' || header.id[1] != 'A'
|
if (header.id[0] != 'P' || header.id[1] != 'A'
|
||||||
|| header.id[2] != 'C' || header.id[3] != 'K')
|
|| header.id[2] != 'C' || header.id[3] != 'K')
|
||||||
Sys_Error ("%s is not a packfile", packfile);
|
Sys_Error ("%s is not a packfile", packfile);
|
||||||
|
@ -609,8 +609,8 @@ COM_LoadPackFile (char *packfile)
|
||||||
|
|
||||||
newfiles = calloc (1, numpackfiles * sizeof(packfile_t));
|
newfiles = calloc (1, numpackfiles * sizeof(packfile_t));
|
||||||
|
|
||||||
fseek (packhandle, header.dirofs, SEEK_SET);
|
Qseek (packhandle, header.dirofs, SEEK_SET);
|
||||||
fread (info, 1, header.dirlen, packhandle);
|
Qread (packhandle, info, header.dirlen);
|
||||||
|
|
||||||
|
|
||||||
// parse the directory
|
// parse the directory
|
||||||
|
@ -822,7 +822,7 @@ COM_Gamedir (char *dir)
|
||||||
{
|
{
|
||||||
if (com_searchpaths->pack)
|
if (com_searchpaths->pack)
|
||||||
{
|
{
|
||||||
fclose (com_searchpaths->pack->handle);
|
Qclose (com_searchpaths->pack->handle);
|
||||||
free (com_searchpaths->pack->files);
|
free (com_searchpaths->pack->files);
|
||||||
free (com_searchpaths->pack);
|
free (com_searchpaths->pack);
|
||||||
}
|
}
|
||||||
|
|
223
source/quakeio.c
223
source/quakeio.c
|
@ -91,103 +91,260 @@ Qrename(const char *old, const char *new)
|
||||||
return rename (e_old, e_new);
|
return rename (e_old, e_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
QFile *
|
||||||
Qopen(const char *path, const char *mode)
|
Qopen(const char *path, const char *mode)
|
||||||
{
|
{
|
||||||
FILE *file;
|
QFile *file;
|
||||||
|
char m[80],*p;
|
||||||
|
int zip=0;
|
||||||
char e_path[PATH_MAX];
|
char e_path[PATH_MAX];
|
||||||
|
|
||||||
Qexpand_squiggle (path, e_path);
|
Qexpand_squiggle (path, e_path);
|
||||||
path = e_path;
|
path = e_path;
|
||||||
|
|
||||||
file=fopen(path,mode);
|
for (p=m; *mode && p-m<(sizeof(m)-1); mode++) {
|
||||||
|
if (*mode=='z') {
|
||||||
|
zip=1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*p++=*mode;
|
||||||
|
}
|
||||||
|
*p=0;
|
||||||
|
|
||||||
|
file=calloc(sizeof(*file),1);
|
||||||
|
if (!file)
|
||||||
|
return 0;
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
if (zip) {
|
||||||
|
file->gzfile=gzopen(path,m);
|
||||||
|
if (!file->gzfile) {
|
||||||
|
free(file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
file->file=fopen(path,m);
|
||||||
|
if (!file->file) {
|
||||||
|
free(file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
QFile *
|
||||||
Qdopen(int fd, const char *mode)
|
Qdopen(int fd, const char *mode)
|
||||||
{
|
{
|
||||||
FILE *file;
|
QFile *file;
|
||||||
|
char m[80],*p;
|
||||||
|
int zip=0;
|
||||||
|
|
||||||
file=fdopen(fd,mode);
|
for (p=m; *mode && p-m<(sizeof(m)-1); mode++) {
|
||||||
|
if (*mode=='z') {
|
||||||
|
zip=1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*p++=*mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
*p=0;
|
||||||
|
|
||||||
|
file=calloc(sizeof(*file),1);
|
||||||
|
if (!file)
|
||||||
|
return 0;
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
if (zip) {
|
||||||
|
file->gzfile=gzdopen(fd,m);
|
||||||
|
if (!file->gzfile) {
|
||||||
|
free(file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
file->file=fdopen(fd,m);
|
||||||
|
if (!file->file) {
|
||||||
|
free(file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
setmode(_fileno(file),O_BINARY);
|
setmode(_fileno(file->file),O_BINARY);
|
||||||
# else
|
#else
|
||||||
_setmode(_fileno(file),_O_BINARY);
|
_setmode(_fileno(file->file),_O_BINARY);
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Qclose(FILE *file)
|
Qclose(QFile *file)
|
||||||
{
|
{
|
||||||
fclose(file);
|
if (file->file)
|
||||||
|
fclose(file->file);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
gzclose(file->gzfile);
|
||||||
|
#endif
|
||||||
|
free(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qread(FILE *file, void *buf, int count)
|
Qread(QFile *file, void *buf, int count)
|
||||||
{
|
{
|
||||||
return fread(buf, 1, count, file);
|
if (file->file)
|
||||||
|
return fread(buf, 1, count, file->file);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
return gzread(file->gzfile,buf,count);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qwrite(FILE *file, void *buf, int count)
|
Qwrite (QFile *file, void *buf, int count)
|
||||||
{
|
{
|
||||||
return fwrite(buf, 1, count, file);
|
if (file->file)
|
||||||
|
return fwrite(buf, 1, count, file->file);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
return gzwrite(file->gzfile,buf,count);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qprintf(FILE *file, const char *fmt, ...)
|
Qprintf(QFile *file, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
int ret=-1;
|
int ret=-1;
|
||||||
|
|
||||||
va_start(args,fmt);
|
va_start(args,fmt);
|
||||||
ret=vfprintf(file, fmt, args);
|
if (file->file)
|
||||||
|
ret=vfprintf(file->file, fmt, args);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else {
|
||||||
|
char buf[4096];
|
||||||
|
va_start(args, fmt);
|
||||||
|
#ifdef HAVE_VSNPRINTF
|
||||||
|
(void)vsnprintf(buf, sizeof(buf), fmt, args);
|
||||||
|
#else
|
||||||
|
(void)vsprintf(buf, fmt, args);
|
||||||
|
#endif
|
||||||
|
va_end(args);
|
||||||
|
ret = strlen(buf); /* some *sprintf don't return the nb of bytes written */
|
||||||
|
if (ret>0)
|
||||||
|
ret=gzwrite(file, buf, (unsigned)ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
Qgets(FILE *file, char *buf, int count)
|
Qgets(QFile *file, char *buf, int count)
|
||||||
{
|
{
|
||||||
return fgets(buf, count, file);
|
if (file->file)
|
||||||
|
return fgets(buf, count, file->file);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
return gzgets(file->gzfile,buf,count);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qgetc(FILE *file)
|
Qgetc(QFile *file)
|
||||||
{
|
{
|
||||||
return fgetc(file);
|
if (file->file)
|
||||||
|
return fgetc(file->file);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
return gzgetc(file->gzfile);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qputc(FILE *file, int c)
|
Qputc(QFile *file, int c)
|
||||||
{
|
{
|
||||||
return fputc(c, file);
|
if (file->file)
|
||||||
|
return fputc(c, file->file);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
return gzputc(file->gzfile,c);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qseek(FILE *file, long offset, int whence)
|
Qseek(QFile *file, long offset, int whence)
|
||||||
{
|
{
|
||||||
return fseek(file, offset, whence);
|
if (file->file)
|
||||||
|
return fseek(file->file, offset, whence);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
return gzseek(file->gzfile,offset,whence);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
Qtell(FILE *file)
|
Qtell(QFile *file)
|
||||||
{
|
{
|
||||||
return ftell(file);
|
if (file->file)
|
||||||
|
return ftell(file->file);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
return gztell(file->gzfile);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qflush(FILE *file)
|
Qflush(QFile *file)
|
||||||
{
|
{
|
||||||
return fflush(file);
|
if (file->file)
|
||||||
|
return fflush(file->file);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
return gzflush(file->gzfile,Z_SYNC_FLUSH);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qeof(FILE *file)
|
Qeof(QFile *file)
|
||||||
{
|
{
|
||||||
return feof(file);
|
if (file->file)
|
||||||
|
return feof(file->file);
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
else
|
||||||
|
return gzeof(file->gzfile);
|
||||||
|
#else
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Qgetpos(QFile *file, fpos_t *pos)
|
||||||
|
{
|
||||||
|
*pos = Qtell(file);
|
||||||
|
return *pos==-1?-1:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Qsetpos(QFile *file, fpos_t *pos)
|
||||||
|
{
|
||||||
|
return Qseek(file, *pos, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,12 +211,13 @@ void R_ClearParticles (void)
|
||||||
|
|
||||||
void R_ReadPointFile_f (void)
|
void R_ReadPointFile_f (void)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
vec3_t org;
|
vec3_t org;
|
||||||
int r;
|
int r;
|
||||||
int c;
|
int c;
|
||||||
particle_t *p;
|
particle_t *p;
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
snprintf (name, sizeof(name), "maps/%s.pts", sv.name);
|
snprintf (name, sizeof(name), "maps/%s.pts", sv.name);
|
||||||
|
|
||||||
|
@ -231,7 +232,9 @@ void R_ReadPointFile_f (void)
|
||||||
c = 0;
|
c = 0;
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
r = fscanf (f,"%f %f %f\n", &org[0], &org[1], &org[2]);
|
if (!Qgets(f,buf,sizeof(buf)))
|
||||||
|
break;
|
||||||
|
r = sscanf (buf,"%f %f %f\n", &org[0], &org[1], &org[2]);
|
||||||
if (r != 3)
|
if (r != 3)
|
||||||
break;
|
break;
|
||||||
c++;
|
c++;
|
||||||
|
@ -253,7 +256,7 @@ void R_ReadPointFile_f (void)
|
||||||
VectorCopy (org, p->org);
|
VectorCopy (org, p->org);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
Con_Printf ("%i points read\n", c);
|
Con_Printf ("%i points read\n", c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,9 @@
|
||||||
|
|
||||||
#define INI_STRING_SIZE 0x100
|
#define INI_STRING_SIZE 0x100
|
||||||
|
|
||||||
FILE *ini_fopen(const char *filename, const char *modes);
|
QFile *ini_fopen(const char *filename, const char *modes);
|
||||||
int ini_fclose(FILE *f);
|
int ini_fclose(QFile *f);
|
||||||
void ini_fgets(FILE *f, const char *section, const char *field, char *s);
|
void ini_fgets(QFile *f, const char *section, const char *field, char *s);
|
||||||
|
|
||||||
// Routines for reading from .INI files
|
// Routines for reading from .INI files
|
||||||
// The read routines are fairly efficient.
|
// The read routines are fairly efficient.
|
||||||
|
@ -65,7 +65,7 @@ struct field_buffer
|
||||||
char name[MAX_FIELD_WIDTH+1];
|
char name[MAX_FIELD_WIDTH+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
static FILE *current_file=NULL;
|
static QFile *current_file=NULL;
|
||||||
static int current_section;
|
static int current_section;
|
||||||
|
|
||||||
static int current_section_buffer=0;
|
static int current_section_buffer=0;
|
||||||
|
@ -83,7 +83,7 @@ static char toupper(char c)
|
||||||
return(c);
|
return(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reset_buffer(FILE *f)
|
static void reset_buffer(QFile *f)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ static void add_field(char *instring, int section, long offset)
|
||||||
|
|
||||||
// Identical to fgets except the string is trucated at the first ';',
|
// Identical to fgets except the string is trucated at the first ';',
|
||||||
// carriage return or line feed.
|
// carriage return or line feed.
|
||||||
static char *stripped_fgets(char *s, int n, FILE *f)
|
static char *stripped_fgets(char *s, int n, QFile *f)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
|
@ -340,13 +340,13 @@ static char *stripped_fgets(char *s, int n, FILE *f)
|
||||||
// Externally accessable routines
|
// Externally accessable routines
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Opens an .INI file. Works like fopen
|
// Opens an .INI file. Works like fopen
|
||||||
FILE *ini_fopen(const char *filename, const char *modes)
|
QFile *ini_fopen(const char *filename, const char *modes)
|
||||||
{
|
{
|
||||||
return(fopen(filename,modes));
|
return(fopen(filename,modes));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closes a .INI file. Works like fclose
|
// Closes a .INI file. Works like fclose
|
||||||
int ini_fclose(FILE *f)
|
int ini_fclose(QFile *f)
|
||||||
{
|
{
|
||||||
if (f==current_file)
|
if (f==current_file)
|
||||||
reset_buffer(NULL);
|
reset_buffer(NULL);
|
||||||
|
@ -356,7 +356,7 @@ int ini_fclose(FILE *f)
|
||||||
// Puts "field" from "section" from .ini file "f" into "s".
|
// Puts "field" from "section" from .ini file "f" into "s".
|
||||||
// If "section" does not exist or "field" does not exist in
|
// If "section" does not exist or "field" does not exist in
|
||||||
// section then s="";
|
// section then s="";
|
||||||
void ini_fgets(FILE *f, const char *section, const char *field, char *s)
|
void ini_fgets(QFile *f, const char *section, const char *field, char *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
long start_pos,string_start_pos;
|
long start_pos,string_start_pos;
|
||||||
|
@ -666,7 +666,7 @@ void ClearGf1Ints(void)
|
||||||
static qboolean GUS_GetIWData(void)
|
static qboolean GUS_GetIWData(void)
|
||||||
{
|
{
|
||||||
char *Interwave,s[INI_STRING_SIZE];
|
char *Interwave,s[INI_STRING_SIZE];
|
||||||
FILE *IwFile;
|
QFile *IwFile;
|
||||||
int CodecBase,CodecDma,i;
|
int CodecBase,CodecDma,i;
|
||||||
|
|
||||||
Interwave=getenv("INTERWAVE");
|
Interwave=getenv("INTERWAVE");
|
||||||
|
|
|
@ -35,13 +35,13 @@
|
||||||
/*
|
/*
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|
||||||
FILE IO
|
QFile IO
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_HANDLES 10
|
#define MAX_HANDLES 10
|
||||||
FILE *sys_handles[MAX_HANDLES];
|
QFile *sys_handles[MAX_HANDLES];
|
||||||
|
|
||||||
int findhandle (void)
|
int findhandle (void)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ int findhandle (void)
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -74,7 +74,7 @@ int filelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -93,7 +93,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path)
|
int Sys_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -129,7 +129,7 @@ int Sys_FileWrite (int handle, void *data, int count)
|
||||||
|
|
||||||
int Sys_FileTime (char *path)
|
int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = fopen(path, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
|
|
|
@ -57,7 +57,7 @@ FILE IO
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
FILE *hFile;
|
QFile *hFile;
|
||||||
char *pMap;
|
char *pMap;
|
||||||
int nLen;
|
int nLen;
|
||||||
int nPos;
|
int nPos;
|
||||||
|
@ -81,7 +81,7 @@ int findhandle (void)
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -96,7 +96,7 @@ int filelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -124,7 +124,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path)
|
int Sys_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -183,7 +183,7 @@ int Sys_FileWrite (int handle, void *data, int count)
|
||||||
|
|
||||||
int Sys_FileTime (char *path)
|
int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = fopen(path, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
|
|
|
@ -105,7 +105,7 @@ FILE IO
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_HANDLES 10
|
#define MAX_HANDLES 10
|
||||||
FILE *sys_handles[MAX_HANDLES];
|
QFile *sys_handles[MAX_HANDLES];
|
||||||
|
|
||||||
int findhandle (void)
|
int findhandle (void)
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ int findhandle (void)
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -143,7 +143,7 @@ int filelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i, retval;
|
int i, retval;
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path)
|
int Sys_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ int Sys_FileWrite (int handle, void *data, int count)
|
||||||
|
|
||||||
int Sys_FileTime (char *path)
|
int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int t, retval;
|
int t, retval;
|
||||||
|
|
||||||
t = VID_ForceUnlockedAndReturnState ();
|
t = VID_ForceUnlockedAndReturnState ();
|
||||||
|
|
|
@ -45,7 +45,7 @@ FILE IO
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_HANDLES 10
|
#define MAX_HANDLES 10
|
||||||
FILE *sys_handles[MAX_HANDLES];
|
QFile *sys_handles[MAX_HANDLES];
|
||||||
|
|
||||||
int findhandle (void)
|
int findhandle (void)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ int findhandle (void)
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int filelength (QFile *f)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int end;
|
int end;
|
||||||
|
@ -78,7 +78,7 @@ int filelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileOpenRead (char *path, int *hndl)
|
int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -97,7 +97,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
int Sys_FileOpenWrite (char *path)
|
int Sys_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
@ -133,7 +133,7 @@ int Sys_FileWrite (int handle, void *data, int count)
|
||||||
|
|
||||||
int Sys_FileTime (char *path)
|
int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = fopen(path, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
|
|
|
@ -161,7 +161,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned *table;
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char s[255];
|
char s[255];
|
||||||
//#endif
|
//#endif
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
|
@ -198,8 +198,8 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
|
|
||||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||||
if (f) {
|
if (f) {
|
||||||
fread(d_15to8table, 1<<15, 1, f);
|
Qread(f, d_15to8table, 1<<15);
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
for (i=0; i < (1<<15); i++) {
|
for (i=0; i < (1<<15); i++) {
|
||||||
|
@ -229,8 +229,8 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
Sys_mkdir (s);
|
Sys_mkdir (s);
|
||||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||||
if ((f = fopen(s, "wb")) != NULL) {
|
if ((f = fopen(s, "wb")) != NULL) {
|
||||||
fwrite(d_15to8table, 1<<15, 1, f);
|
Qwrite(f, d_15to8table, 1<<15);
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned *table;
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char s[255];
|
char s[255];
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
static qboolean palflag = false;
|
static qboolean palflag = false;
|
||||||
|
@ -239,8 +239,8 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
|
|
||||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||||
if (f) {
|
if (f) {
|
||||||
fread(d_15to8table, 1<<15, 1, f);
|
Qread(f, d_15to8table, 1<<15);
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
} else {
|
} else {
|
||||||
for (i=0; i < (1<<15); i++) {
|
for (i=0; i < (1<<15); i++) {
|
||||||
/* Maps
|
/* Maps
|
||||||
|
@ -268,9 +268,9 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
||||||
Sys_mkdir (s);
|
Sys_mkdir (s);
|
||||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||||
if ((f = fopen(s, "wb")) != NULL) {
|
if ((f = Qopen(s, "wb")) != NULL) {
|
||||||
fwrite(d_15to8table, 1<<15, 1, f);
|
Qwrite(f, d_15to8table, 1<<15);
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ VID_SetPalette (unsigned char *palette)
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned *table;
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char s[256];
|
char s[256];
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
static qboolean palflag = false;
|
static qboolean palflag = false;
|
||||||
|
@ -191,8 +191,8 @@ VID_SetPalette (unsigned char *palette)
|
||||||
|
|
||||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||||
if (f) {
|
if (f) {
|
||||||
fread(d_15to8table, 1<<15, 1, f);
|
Qread(f, d_15to8table, 1<<15);
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
} else {
|
} else {
|
||||||
for (i=0; i < (1<<15); i++) {
|
for (i=0; i < (1<<15); i++) {
|
||||||
/* Maps
|
/* Maps
|
||||||
|
@ -220,9 +220,9 @@ VID_SetPalette (unsigned char *palette)
|
||||||
snprintf (s, sizeof (s), "%s/glquake", com_gamedir);
|
snprintf (s, sizeof (s), "%s/glquake", com_gamedir);
|
||||||
Sys_mkdir (s);
|
Sys_mkdir (s);
|
||||||
snprintf(s, sizeof (s), "%s/glquake/15to8.pal", com_gamedir);
|
snprintf(s, sizeof (s), "%s/glquake/15to8.pal", com_gamedir);
|
||||||
if ((f = fopen (s, "wb")) != NULL) {
|
if ((f = Qopen (s, "wb")) != NULL) {
|
||||||
fwrite (d_15to8table, 1<<15, 1, f);
|
Qwrite (f, d_15to8table, 1<<15);
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -721,7 +721,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned *table;
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char s[255];
|
char s[255];
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
static qboolean palflag = false;
|
static qboolean palflag = false;
|
||||||
|
@ -755,8 +755,8 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
|
|
||||||
COM_FOpenFile("glquake/15to8.pal", &f);
|
COM_FOpenFile("glquake/15to8.pal", &f);
|
||||||
if (f) {
|
if (f) {
|
||||||
fread(d_15to8table, 1<<15, 1, f);
|
Qread(f, d_15to8table, 1<<15);
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
} else {
|
} else {
|
||||||
for (i=0; i < (1<<15); i++) {
|
for (i=0; i < (1<<15); i++) {
|
||||||
/* Maps
|
/* Maps
|
||||||
|
@ -785,8 +785,8 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
Sys_mkdir (s);
|
Sys_mkdir (s);
|
||||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
||||||
if ((f = fopen(s, "wb")) != NULL) {
|
if ((f = fopen(s, "wb")) != NULL) {
|
||||||
fwrite(d_15to8table, 1<<15, 1, f);
|
Qwrite(f, d_15to8table, 1<<15);
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue