mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-29 15:23:02 +00:00
zlib support (gzipped pack contents). if you have a probelm with gzgets, you
have 3 choices: remove /usr/X11R6/lib/libz.a, --diable-zlib, or fix configure. I do intend on fixing it myself.
This commit is contained in:
parent
7c12c9b4c7
commit
86f87122c0
39 changed files with 537 additions and 328 deletions
|
@ -82,6 +82,9 @@
|
||||||
/* Define if you have the dlopen function. */
|
/* Define if you have the dlopen function. */
|
||||||
#undef HAVE_DLOPEN
|
#undef HAVE_DLOPEN
|
||||||
|
|
||||||
|
/* Define if you have zlib */
|
||||||
|
#undef HAS_ZLIB
|
||||||
|
|
||||||
/* Define if you have pthread support. */
|
/* Define if you have pthread support. */
|
||||||
#undef HAVE_LIBPTHREAD
|
#undef HAVE_LIBPTHREAD
|
||||||
|
|
||||||
|
|
20
configure.in
20
configure.in
|
@ -182,6 +182,26 @@ fi
|
||||||
dnl Checks for working -lm
|
dnl Checks for working -lm
|
||||||
AC_CHECK_LIB(m, pow,, AC_MSG_ERROR([math library (-lm) appears broken]))
|
AC_CHECK_LIB(m, pow,, AC_MSG_ERROR([math library (-lm) appears broken]))
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(zlib,
|
||||||
|
[ --disable-zlib disable zlib support],
|
||||||
|
)
|
||||||
|
|
||||||
|
if test "x$enable_zlib" != "xno"; then
|
||||||
|
dnl Check for working -lz
|
||||||
|
dnl Note - must have gztell *and* gzgets in -lz *and* zlib.h
|
||||||
|
AC_CHECK_LIB(z, gztell, HAS_ZLIB=yes, HAS_ZLIB=no, [$LIBS])
|
||||||
|
if test "x$HAS_ZLIB" = "xyes"; then
|
||||||
|
AC_CHECK_LIB(z, gzgets, HAS_ZLIB=yes, HAS_ZLIB=no, [$LIBS])
|
||||||
|
if test "x$HAS_ZLIB" = "xyes"; then
|
||||||
|
AC_CHECK_HEADER(zlib.h, HAS_ZLIB=yes, HAS_ZLIB=no)
|
||||||
|
if test "x$HAS_ZLIB" = "xyes"; then
|
||||||
|
LIBS="-lz $LIBS"
|
||||||
|
AC_DEFINE(HAS_ZLIB)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
dnl Checks for MGL support
|
dnl Checks for MGL support
|
||||||
AC_ARG_WITH(mgl,
|
AC_ARG_WITH(mgl,
|
||||||
[ --with-mgl[=DIR] use MGL found in DIR],
|
[ --with-mgl[=DIR] use MGL found in DIR],
|
||||||
|
|
|
@ -49,8 +49,8 @@ void SL_Swap(server_entry_t *swap1, server_entry_t *swap2);
|
||||||
server_entry_t *SL_Get_By_Num(server_entry_t *start, int n);
|
server_entry_t *SL_Get_By_Num(server_entry_t *start, int n);
|
||||||
int SL_Len(server_entry_t *start);
|
int SL_Len(server_entry_t *start);
|
||||||
|
|
||||||
server_entry_t *SL_LoadF(FILE *f, server_entry_t *start);
|
server_entry_t *SL_LoadF(QFile *f, server_entry_t *start);
|
||||||
void SL_SaveF(FILE *f, server_entry_t *start);
|
void SL_SaveF(QFile *f, server_entry_t *start);
|
||||||
|
|
||||||
void SL_Del_All(server_entry_t *start);
|
void SL_Del_All(server_entry_t *start);
|
||||||
void SL_Shutdown(server_entry_t *start);
|
void SL_Shutdown(server_entry_t *start);
|
||||||
|
|
|
@ -199,7 +199,7 @@ typedef struct
|
||||||
|
|
||||||
int qport;
|
int qport;
|
||||||
|
|
||||||
FILE *download; // file transfer from server
|
QFile *download; // file transfer from server
|
||||||
char downloadtempname[MAX_OSPATH];
|
char downloadtempname[MAX_OSPATH];
|
||||||
char downloadname[MAX_OSPATH];
|
char downloadname[MAX_OSPATH];
|
||||||
int downloadnumber;
|
int downloadnumber;
|
||||||
|
@ -215,7 +215,7 @@ typedef struct
|
||||||
qboolean demorecording;
|
qboolean demorecording;
|
||||||
qboolean demoplayback;
|
qboolean demoplayback;
|
||||||
qboolean timedemo;
|
qboolean timedemo;
|
||||||
FILE *demofile;
|
QFile *demofile;
|
||||||
float td_lastframe; // to meter out one message a frame
|
float 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
|
||||||
|
|
|
@ -113,7 +113,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);
|
||||||
|
|
|
@ -175,7 +175,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);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "pr_comp.h" // defs shared with qcc
|
#include "pr_comp.h" // defs shared with qcc
|
||||||
#include "progdefs.h" // generated by program cdefs
|
#include "progdefs.h" // generated by program cdefs
|
||||||
#include "link.h"
|
#include "link.h"
|
||||||
|
#include "quakeio.h"
|
||||||
|
|
||||||
typedef union eval_s
|
typedef union eval_s
|
||||||
{
|
{
|
||||||
|
@ -91,10 +92,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,39 @@
|
||||||
#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);
|
||||||
|
|
||||||
|
|
||||||
#endif /*_QUAKEIO_H*/
|
#endif /*_QUAKEIO_H*/
|
||||||
|
|
|
@ -191,7 +191,7 @@ typedef struct client_s
|
||||||
|
|
||||||
client_frame_t frames[UPDATE_BACKUP]; // updates can be deltad from here
|
client_frame_t frames[UPDATE_BACKUP]; // updates can be deltad from here
|
||||||
|
|
||||||
FILE *download; // file being downloaded
|
QFile *download; // file being downloaded
|
||||||
int downloadsize; // total bytes
|
int downloadsize; // total bytes
|
||||||
int downloadcount; // bytes sent
|
int downloadcount; // bytes sent
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ typedef struct client_s
|
||||||
|
|
||||||
qboolean upgradewarn; // did we warn him?
|
qboolean upgradewarn; // did we warn him?
|
||||||
|
|
||||||
FILE *upload;
|
QFile *upload;
|
||||||
char uploadfn[MAX_QPATH];
|
char uploadfn[MAX_QPATH];
|
||||||
netadr_t snap_from;
|
netadr_t snap_from;
|
||||||
qboolean remote_snap;
|
qboolean remote_snap;
|
||||||
|
@ -391,8 +391,8 @@ extern char localmodels[MAX_MODELS][5]; // inline model names for precache
|
||||||
extern char localinfo[MAX_LOCALINFO_STRING+1];
|
extern char localinfo[MAX_LOCALINFO_STRING+1];
|
||||||
|
|
||||||
extern int host_hunklevel;
|
extern int host_hunklevel;
|
||||||
extern FILE *sv_logfile;
|
extern QFile *sv_logfile;
|
||||||
extern FILE *sv_fraglogfile;
|
extern QFile *sv_fraglogfile;
|
||||||
|
|
||||||
extern double sv_frametime;
|
extern double sv_frametime;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
/* Version strings */
|
/* Version strings */
|
||||||
#define PACKAGE "quakeforge"
|
#define PACKAGE "quakeforge"
|
||||||
#define PROGRAM "QuakeForge"
|
#define PROGRAM "QuakeForge"
|
||||||
#define VERSION "0.1.99pre2"
|
#define VERSION "0.2.99beta1"
|
||||||
#define QW_VERSION "2.40"
|
#define QW_VERSION "2.40"
|
||||||
#define QSG_VERSION "2.0"
|
#define QSG_VERSION "2.0"
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ void CL_StopPlayback (void)
|
||||||
if (!cls.demoplayback)
|
if (!cls.demoplayback)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fclose (cls.demofile);
|
Qclose (cls.demofile);
|
||||||
cls.demofile = NULL;
|
cls.demofile = NULL;
|
||||||
cls.state = ca_disconnected;
|
cls.state = ca_disconnected;
|
||||||
cls.demoplayback = 0;
|
cls.demoplayback = 0;
|
||||||
|
@ -99,10 +99,10 @@ void CL_WriteDemoCmd (usercmd_t *pcmd)
|
||||||
//Con_Printf("write: %ld bytes, %4.4f\n", msg->cursize, realtime);
|
//Con_Printf("write: %ld bytes, %4.4f\n", msg->cursize, realtime);
|
||||||
|
|
||||||
fl = LittleFloat((float)realtime);
|
fl = LittleFloat((float)realtime);
|
||||||
fwrite (&fl, sizeof(fl), 1, cls.demofile);
|
Qwrite (cls.demofile, &fl, sizeof(fl));
|
||||||
|
|
||||||
c = dem_cmd;
|
c = dem_cmd;
|
||||||
fwrite (&c, sizeof(c), 1, cls.demofile);
|
Qwrite (cls.demofile, &c, sizeof(c));
|
||||||
|
|
||||||
// correct for byte order, bytes don't matter
|
// correct for byte order, bytes don't matter
|
||||||
cmd = *pcmd;
|
cmd = *pcmd;
|
||||||
|
@ -113,15 +113,15 @@ void CL_WriteDemoCmd (usercmd_t *pcmd)
|
||||||
cmd.sidemove = LittleShort(cmd.sidemove);
|
cmd.sidemove = LittleShort(cmd.sidemove);
|
||||||
cmd.upmove = LittleShort(cmd.upmove);
|
cmd.upmove = LittleShort(cmd.upmove);
|
||||||
|
|
||||||
fwrite(&cmd, sizeof(cmd), 1, cls.demofile);
|
Qwrite(cls.demofile, &cmd, sizeof(cmd));
|
||||||
|
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
{
|
{
|
||||||
fl = LittleFloat (cl.viewangles[i]);
|
fl = LittleFloat (cl.viewangles[i]);
|
||||||
fwrite (&fl, 4, 1, cls.demofile);
|
Qwrite (cls.demofile, &fl, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush (cls.demofile);
|
Qflush (cls.demofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -143,16 +143,16 @@ void CL_WriteDemoMessage (sizebuf_t *msg)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fl = LittleFloat((float)realtime);
|
fl = LittleFloat((float)realtime);
|
||||||
fwrite (&fl, sizeof(fl), 1, cls.demofile);
|
Qwrite (cls.demofile, &fl, sizeof(fl));
|
||||||
|
|
||||||
c = dem_read;
|
c = dem_read;
|
||||||
fwrite (&c, sizeof(c), 1, cls.demofile);
|
Qwrite (cls.demofile, &c, sizeof(c));
|
||||||
|
|
||||||
len = LittleLong (msg->cursize);
|
len = LittleLong (msg->cursize);
|
||||||
fwrite (&len, 4, 1, cls.demofile);
|
Qwrite (cls.demofile, &len, 4);
|
||||||
fwrite (msg->data, msg->cursize, 1, cls.demofile);
|
Qwrite (cls.demofile, msg->data, msg->cursize);
|
||||||
|
|
||||||
fflush (cls.demofile);
|
Qflush (cls.demofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -171,7 +171,7 @@ qboolean CL_GetDemoMessage (void)
|
||||||
usercmd_t *pcmd;
|
usercmd_t *pcmd;
|
||||||
|
|
||||||
// read the time from the packet
|
// read the time from the packet
|
||||||
fread(&demotime, sizeof(demotime), 1, cls.demofile);
|
Qread(cls.demofile, &demotime, sizeof(demotime));
|
||||||
demotime = LittleFloat(demotime);
|
demotime = LittleFloat(demotime);
|
||||||
|
|
||||||
// decide if it is time to grab the next message
|
// decide if it is time to grab the next message
|
||||||
|
@ -181,7 +181,7 @@ qboolean CL_GetDemoMessage (void)
|
||||||
else if (demotime > cls.td_lastframe) {
|
else if (demotime > cls.td_lastframe) {
|
||||||
cls.td_lastframe = demotime;
|
cls.td_lastframe = demotime;
|
||||||
// rewind back to time
|
// rewind back to time
|
||||||
fseek(cls.demofile, ftell(cls.demofile) - sizeof(demotime),
|
Qseek(cls.demofile, Qtell(cls.demofile) - sizeof(demotime),
|
||||||
SEEK_SET);
|
SEEK_SET);
|
||||||
return 0; // allready read this frame's message
|
return 0; // allready read this frame's message
|
||||||
}
|
}
|
||||||
|
@ -195,12 +195,12 @@ qboolean CL_GetDemoMessage (void)
|
||||||
// too far back
|
// too far back
|
||||||
realtime = demotime - 1.0;
|
realtime = demotime - 1.0;
|
||||||
// rewind back to time
|
// rewind back to time
|
||||||
fseek(cls.demofile, ftell(cls.demofile) - sizeof(demotime),
|
Qseek(cls.demofile, Qtell(cls.demofile) - sizeof(demotime),
|
||||||
SEEK_SET);
|
SEEK_SET);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (realtime < demotime) {
|
} else if (realtime < demotime) {
|
||||||
// rewind back to time
|
// rewind back to time
|
||||||
fseek(cls.demofile, ftell(cls.demofile) - sizeof(demotime),
|
Qseek(cls.demofile, Qtell(cls.demofile) - sizeof(demotime),
|
||||||
SEEK_SET);
|
SEEK_SET);
|
||||||
return 0; // don't need another message yet
|
return 0; // don't need another message yet
|
||||||
}
|
}
|
||||||
|
@ -211,15 +211,15 @@ qboolean CL_GetDemoMessage (void)
|
||||||
Host_Error ("CL_GetDemoMessage: cls.state != ca_active");
|
Host_Error ("CL_GetDemoMessage: cls.state != ca_active");
|
||||||
|
|
||||||
// get the msg type
|
// get the msg type
|
||||||
fread (&c, sizeof(c), 1, cls.demofile);
|
Qread (cls.demofile, &c, sizeof(c));
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case dem_cmd :
|
case dem_cmd :
|
||||||
// user sent input
|
// user sent input
|
||||||
i = cls.netchan.outgoing_sequence & UPDATE_MASK;
|
i = cls.netchan.outgoing_sequence & UPDATE_MASK;
|
||||||
pcmd = &cl.frames[i].cmd;
|
pcmd = &cl.frames[i].cmd;
|
||||||
r = fread (pcmd, sizeof(*pcmd), 1, cls.demofile);
|
r = Qread (cls.demofile, pcmd, sizeof(*pcmd));
|
||||||
if (r != 1)
|
if (r != sizeof(*pcmd))
|
||||||
{
|
{
|
||||||
CL_StopPlayback ();
|
CL_StopPlayback ();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -235,21 +235,21 @@ qboolean CL_GetDemoMessage (void)
|
||||||
cls.netchan.outgoing_sequence++;
|
cls.netchan.outgoing_sequence++;
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
{
|
{
|
||||||
r = fread (&f, 4, 1, cls.demofile);
|
Qread (cls.demofile, &f, 4);
|
||||||
cl.viewangles[i] = LittleFloat (f);
|
cl.viewangles[i] = LittleFloat (f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case dem_read:
|
case dem_read:
|
||||||
// get the next message
|
// get the next message
|
||||||
fread (&net_message.cursize, 4, 1, cls.demofile);
|
Qread (cls.demofile, &net_message.cursize, 4);
|
||||||
net_message.cursize = LittleLong (net_message.cursize);
|
net_message.cursize = LittleLong (net_message.cursize);
|
||||||
//Con_Printf("read: %ld bytes\n", net_message.cursize);
|
//Con_Printf("read: %ld bytes\n", 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");
|
||||||
Host_EndGame ("Demo message > MAX_MSGLEN");
|
Host_EndGame ("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;
|
||||||
|
@ -257,9 +257,9 @@ qboolean CL_GetDemoMessage (void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case dem_set :
|
case dem_set :
|
||||||
fread (&i, 4, 1, cls.demofile);
|
Qread (cls.demofile, &i, 4);
|
||||||
cls.netchan.outgoing_sequence = LittleLong(i);
|
cls.netchan.outgoing_sequence = LittleLong(i);
|
||||||
fread (&i, 4, 1, cls.demofile);
|
Qread (cls.demofile, &i, 4);
|
||||||
cls.netchan.incoming_sequence = LittleLong(i);
|
cls.netchan.incoming_sequence = LittleLong(i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ void CL_Stop_f (void)
|
||||||
CL_WriteDemoMessage (&net_message);
|
CL_WriteDemoMessage (&net_message);
|
||||||
|
|
||||||
// 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");
|
||||||
|
@ -343,21 +343,21 @@ void CL_WriteRecordDemoMessage (sizebuf_t *msg, int seq)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fl = LittleFloat((float)realtime);
|
fl = LittleFloat((float)realtime);
|
||||||
fwrite (&fl, sizeof(fl), 1, cls.demofile);
|
Qwrite (cls.demofile, &fl, sizeof(fl));
|
||||||
|
|
||||||
c = dem_read;
|
c = dem_read;
|
||||||
fwrite (&c, sizeof(c), 1, cls.demofile);
|
Qwrite (cls.demofile, &c, sizeof(c));
|
||||||
|
|
||||||
len = LittleLong (msg->cursize + 8);
|
len = LittleLong (msg->cursize + 8);
|
||||||
fwrite (&len, 4, 1, cls.demofile);
|
Qwrite (cls.demofile, &len, 4);
|
||||||
|
|
||||||
i = LittleLong(seq);
|
i = LittleLong(seq);
|
||||||
fwrite (&i, 4, 1, cls.demofile);
|
Qwrite (cls.demofile, &i, 4);
|
||||||
fwrite (&i, 4, 1, cls.demofile);
|
Qwrite (cls.demofile, &i, 4);
|
||||||
|
|
||||||
fwrite (msg->data, msg->cursize, 1, cls.demofile);
|
Qwrite (cls.demofile, msg->data, msg->cursize);
|
||||||
|
|
||||||
fflush (cls.demofile);
|
Qflush (cls.demofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -373,17 +373,17 @@ void CL_WriteSetDemoMessage (void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fl = LittleFloat((float)realtime);
|
fl = LittleFloat((float)realtime);
|
||||||
fwrite (&fl, sizeof(fl), 1, cls.demofile);
|
Qwrite (cls.demofile, &fl, sizeof(fl));
|
||||||
|
|
||||||
c = dem_set;
|
c = dem_set;
|
||||||
fwrite (&c, sizeof(c), 1, cls.demofile);
|
Qwrite (cls.demofile, &c, sizeof(c));
|
||||||
|
|
||||||
len = LittleLong(cls.netchan.outgoing_sequence);
|
len = LittleLong(cls.netchan.outgoing_sequence);
|
||||||
fwrite (&len, 4, 1, cls.demofile);
|
Qwrite (cls.demofile, &len, 4);
|
||||||
len = LittleLong(cls.netchan.incoming_sequence);
|
len = LittleLong(cls.netchan.incoming_sequence);
|
||||||
fwrite (&len, 4, 1, cls.demofile);
|
Qwrite (cls.demofile, &len, 4);
|
||||||
|
|
||||||
fflush (cls.demofile);
|
Qflush (cls.demofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ void CL_Record_f (void)
|
||||||
//
|
//
|
||||||
COM_DefaultExtension (name, ".qwd");
|
COM_DefaultExtension (name, ".qwd");
|
||||||
|
|
||||||
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");
|
||||||
|
@ -718,7 +718,7 @@ void CL_ReRecord_f (void)
|
||||||
//
|
//
|
||||||
COM_DefaultExtension (name, ".qwd");
|
COM_DefaultExtension (name, ".qwd");
|
||||||
|
|
||||||
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");
|
||||||
|
|
|
@ -493,7 +493,7 @@ void CL_Disconnect (void)
|
||||||
Cam_Reset();
|
Cam_Reset();
|
||||||
|
|
||||||
if (cls.download) {
|
if (cls.download) {
|
||||||
fclose(cls.download);
|
Qclose(cls.download);
|
||||||
cls.download = NULL;
|
cls.download = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,7 +1099,7 @@ void CL_Download_f (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy (cls.downloadtempname, cls.downloadname, sizeof(cls.downloadtempname));
|
strncpy (cls.downloadtempname, cls.downloadname, sizeof(cls.downloadtempname));
|
||||||
cls.download = fopen (cls.downloadname, "wb");
|
cls.download = Qopen (cls.downloadname, "wb");
|
||||||
cls.downloadtype = dl_single;
|
cls.downloadtype = dl_single;
|
||||||
|
|
||||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||||
|
@ -1128,7 +1128,7 @@ CL_Init
|
||||||
*/
|
*/
|
||||||
void CL_Init (void)
|
void CL_Init (void)
|
||||||
{
|
{
|
||||||
FILE *servlist;
|
QFile *servlist;
|
||||||
char st[80];
|
char st[80];
|
||||||
char e_path[MAX_OSPATH];
|
char e_path[MAX_OSPATH];
|
||||||
|
|
||||||
|
@ -1151,9 +1151,9 @@ void CL_Init (void)
|
||||||
Pmove_Init ();
|
Pmove_Init ();
|
||||||
|
|
||||||
Qexpand_squiggle(fs_userpath->string, e_path);
|
Qexpand_squiggle(fs_userpath->string, e_path);
|
||||||
if ((servlist = fopen(va("%s/servers.txt", e_path), "r"))) {
|
if ((servlist = Qopen(va("%s/servers.txt", e_path), "r"))) {
|
||||||
slist = SL_LoadF(servlist,slist);
|
slist = SL_LoadF(servlist,slist);
|
||||||
fclose(servlist);
|
Qclose(servlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1342,11 +1342,11 @@ Writes key bindings and archived cvars to config.cfg
|
||||||
*/
|
*/
|
||||||
void Host_WriteConfiguration (void)
|
void Host_WriteConfiguration (void)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
if (host_initialized)
|
if (host_initialized)
|
||||||
{
|
{
|
||||||
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");
|
||||||
|
@ -1356,7 +1356,7 @@ void Host_WriteConfiguration (void)
|
||||||
Key_WriteBindings (f);
|
Key_WriteBindings (f);
|
||||||
Cvar_WriteVariables (f);
|
Cvar_WriteVariables (f);
|
||||||
|
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ to start a download from the server.
|
||||||
*/
|
*/
|
||||||
qboolean CL_CheckOrDownloadFile (char *filename)
|
qboolean CL_CheckOrDownloadFile (char *filename)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
if (strstr (filename, ".."))
|
if (strstr (filename, ".."))
|
||||||
{
|
{
|
||||||
|
@ -193,7 +193,7 @@ qboolean CL_CheckOrDownloadFile (char *filename)
|
||||||
COM_FOpenFile (filename, &f);
|
COM_FOpenFile (filename, &f);
|
||||||
if (f)
|
if (f)
|
||||||
{ // it exists, no need to download
|
{ // it exists, no need to download
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ void CL_ParseDownload (void)
|
||||||
if (cls.download)
|
if (cls.download)
|
||||||
{
|
{
|
||||||
Con_Printf ("cls.download shouldn't have been set\n");
|
Con_Printf ("cls.download shouldn't have been set\n");
|
||||||
fclose (cls.download);
|
Qclose (cls.download);
|
||||||
cls.download = NULL;
|
cls.download = NULL;
|
||||||
}
|
}
|
||||||
CL_RequestNextDownload ();
|
CL_RequestNextDownload ();
|
||||||
|
@ -400,7 +400,7 @@ void CL_ParseDownload (void)
|
||||||
|
|
||||||
COM_CreatePath (name);
|
COM_CreatePath (name);
|
||||||
|
|
||||||
cls.download = fopen (name, "wb");
|
cls.download = Qopen (name, "wb");
|
||||||
if (!cls.download)
|
if (!cls.download)
|
||||||
{
|
{
|
||||||
msg_readcount += size;
|
msg_readcount += size;
|
||||||
|
@ -410,7 +410,7 @@ void CL_ParseDownload (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite (net_message.data + msg_readcount, 1, size, cls.download);
|
Qwrite (cls.download, net_message.data + msg_readcount, size);
|
||||||
msg_readcount += size;
|
msg_readcount += size;
|
||||||
|
|
||||||
if (percent != 100)
|
if (percent != 100)
|
||||||
|
@ -439,7 +439,7 @@ void CL_ParseDownload (void)
|
||||||
Con_Printf ("100%%\n");
|
Con_Printf ("100%%\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fclose (cls.download);
|
Qclose (cls.download);
|
||||||
|
|
||||||
// rename the temp file to it's final name
|
// rename the temp file to it's final name
|
||||||
if (strcmp(cls.downloadtempname, cls.downloadname)) {
|
if (strcmp(cls.downloadtempname, cls.downloadname)) {
|
||||||
|
@ -557,7 +557,7 @@ CL_ParseServerData
|
||||||
void CL_ParseServerData (void)
|
void CL_ParseServerData (void)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char fn[MAX_OSPATH];
|
char fn[MAX_OSPATH];
|
||||||
qboolean cflag = false;
|
qboolean cflag = false;
|
||||||
extern char gamedirfile[MAX_OSPATH];
|
extern char gamedirfile[MAX_OSPATH];
|
||||||
|
@ -595,21 +595,21 @@ void CL_ParseServerData (void)
|
||||||
if (cflag) {
|
if (cflag) {
|
||||||
int cl_warncmd_val = cl_warncmd->value;
|
int cl_warncmd_val = cl_warncmd->value;
|
||||||
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "config.cfg");
|
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "config.cfg");
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = Qopen(fn, "r")) != NULL) {
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
Cbuf_AddText ("cl_warncmd 0\n");
|
Cbuf_AddText ("cl_warncmd 0\n");
|
||||||
Cbuf_AddText ("exec config.cfg\n");
|
Cbuf_AddText ("exec config.cfg\n");
|
||||||
}
|
}
|
||||||
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "frontend.cfg");
|
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "frontend.cfg");
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = Qopen(fn, "r")) != NULL) {
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
Cbuf_AddText ("cl_warncmd 0\n");
|
Cbuf_AddText ("cl_warncmd 0\n");
|
||||||
Cbuf_AddText ("exec frontend.cfg\n");
|
Cbuf_AddText ("exec frontend.cfg\n");
|
||||||
}
|
}
|
||||||
if (cl_autoexec->value) {
|
if (cl_autoexec->value) {
|
||||||
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "autoexec.cfg");
|
snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "autoexec.cfg");
|
||||||
if ((f = fopen(fn, "r")) != NULL) {
|
if ((f = Qopen(fn, "r")) != NULL) {
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
Cbuf_AddText ("cl_warncmd 0\n");
|
Cbuf_AddText ("cl_warncmd 0\n");
|
||||||
Cbuf_AddText ("exec autoexec.cfg\n");
|
Cbuf_AddText ("exec autoexec.cfg\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ int SL_Len (server_entry_t *start) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
server_entry_t *SL_LoadF (FILE *f,server_entry_t *start) { // This could get messy
|
server_entry_t *SL_LoadF (QFile *f,server_entry_t *start) { // This could get messy
|
||||||
char line[256]; /* Long lines get truncated. */
|
char line[256]; /* Long lines get truncated. */
|
||||||
int c = ' '; /* int so it can be compared to EOF properly*/
|
int c = ' '; /* int so it can be compared to EOF properly*/
|
||||||
int len;
|
int len;
|
||||||
|
@ -150,7 +150,7 @@ server_entry_t *SL_LoadF (FILE *f,server_entry_t *start) { // This could get mes
|
||||||
i = 0;
|
i = 0;
|
||||||
c = ' ';
|
c = ' ';
|
||||||
while (c != '\n' && c != EOF) {
|
while (c != '\n' && c != EOF) {
|
||||||
c = getc(f);
|
c = Qgetc(f);
|
||||||
if (i < 255) {
|
if (i < 255) {
|
||||||
line[i] = c;
|
line[i] = c;
|
||||||
i++;
|
i++;
|
||||||
|
@ -174,23 +174,23 @@ server_entry_t *SL_LoadF (FILE *f,server_entry_t *start) { // This could get mes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SL_SaveF (FILE *f,server_entry_t *start) {
|
void SL_SaveF (QFile *f,server_entry_t *start) {
|
||||||
do {
|
do {
|
||||||
fprintf(f,"%s %s\n",start->server,start->desc);
|
Qprintf(f,"%s %s\n",start->server,start->desc);
|
||||||
start = start->next;
|
start = start->next;
|
||||||
|
|
||||||
} while (start);
|
} while (start);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SL_Shutdown (server_entry_t *start) {
|
void SL_Shutdown (server_entry_t *start) {
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char e_path[MAX_OSPATH];
|
char e_path[MAX_OSPATH];
|
||||||
|
|
||||||
if (start) {
|
if (start) {
|
||||||
Qexpand_squiggle(fs_userpath->string, e_path);
|
Qexpand_squiggle(fs_userpath->string, e_path);
|
||||||
if ((f = fopen(va("%s/servers.txt", e_path),"w"))) {
|
if ((f = Qopen(va("%s/servers.txt", e_path),"w"))) {
|
||||||
SL_SaveF(f,start);
|
SL_SaveF(f,start);
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
}
|
}
|
||||||
SL_Del_All (start);
|
SL_Del_All (start);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,14 +100,14 @@ FILE IO
|
||||||
|
|
||||||
int Sys_FileTime (char *path)
|
int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
int t, retval;
|
int t, retval;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -100,15 +100,15 @@ FILE IO
|
||||||
wfilelength
|
wfilelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int wfilelength (FILE *f)
|
int wfilelength (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;
|
||||||
}
|
}
|
||||||
|
@ -116,16 +116,16 @@ int wfilelength (FILE *f)
|
||||||
|
|
||||||
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 ();
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -360,9 +360,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);
|
||||||
|
@ -370,8 +370,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);
|
||||||
|
|
|
@ -62,7 +62,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);
|
||||||
|
@ -70,8 +70,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) {
|
||||||
|
|
|
@ -282,13 +282,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)
|
||||||
|
|
|
@ -319,7 +319,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);
|
||||||
|
@ -334,11 +334,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
|
||||||
{
|
{
|
||||||
|
@ -353,22 +353,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ 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;
|
||||||
|
@ -143,7 +143,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]);
|
char buf[64];
|
||||||
|
Qgets (f, buf, sizeof(buf));
|
||||||
|
r = sscanf (buf,"%f %f %f\n", &org[0], &org[1], &org[2]);
|
||||||
if (r != 3)
|
if (r != 3)
|
||||||
break;
|
break;
|
||||||
c++;
|
c++;
|
||||||
|
@ -165,7 +167,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,7 @@ byte *pcx_rgb;
|
||||||
LoadPCX
|
LoadPCX
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void LoadPCX (FILE *f)
|
void LoadPCX (QFile *f)
|
||||||
{
|
{
|
||||||
pcx_t *pcx, pcxbuf;
|
pcx_t *pcx, pcxbuf;
|
||||||
byte palette[768];
|
byte palette[768];
|
||||||
|
@ -292,7 +292,7 @@ void LoadPCX (FILE *f)
|
||||||
//
|
//
|
||||||
// parse the PCX file
|
// parse the PCX file
|
||||||
//
|
//
|
||||||
fread (&pcxbuf, 1, sizeof(pcxbuf), f);
|
Qread (f, &pcxbuf, sizeof(pcxbuf));
|
||||||
|
|
||||||
pcx = &pcxbuf;
|
pcx = &pcxbuf;
|
||||||
|
|
||||||
|
@ -308,10 +308,10 @@ void LoadPCX (FILE *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
// seek to palette
|
// seek to palette
|
||||||
fseek (f, -768, SEEK_END);
|
Qseek (f, -768, SEEK_END);
|
||||||
fread (palette, 1, 768, f);
|
Qread (f, palette, 768);
|
||||||
|
|
||||||
fseek (f, sizeof(pcxbuf) - 4, SEEK_SET);
|
Qseek (f, sizeof(pcxbuf) - 4, SEEK_SET);
|
||||||
|
|
||||||
count = (pcx->xmax+1) * (pcx->ymax+1);
|
count = (pcx->xmax+1) * (pcx->ymax+1);
|
||||||
pcx_rgb = malloc( count * 4);
|
pcx_rgb = malloc( count * 4);
|
||||||
|
@ -321,12 +321,12 @@ void LoadPCX (FILE *f)
|
||||||
pix = pcx_rgb + 4*y*(pcx->xmax+1);
|
pix = pcx_rgb + 4*y*(pcx->xmax+1);
|
||||||
for (x=0 ; x<=pcx->ymax ; )
|
for (x=0 ; x<=pcx->ymax ; )
|
||||||
{
|
{
|
||||||
dataByte = fgetc(f);
|
dataByte = Qgetc(f);
|
||||||
|
|
||||||
if((dataByte & 0xC0) == 0xC0)
|
if((dataByte & 0xC0) == 0xC0)
|
||||||
{
|
{
|
||||||
runLength = dataByte & 0x3F;
|
runLength = dataByte & 0x3F;
|
||||||
dataByte = fgetc(f);
|
dataByte = Qgetc(f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
runLength = 1;
|
runLength = 1;
|
||||||
|
@ -364,24 +364,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);
|
||||||
}
|
}
|
||||||
|
@ -392,26 +392,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)
|
||||||
|
@ -428,7 +428,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--) {
|
||||||
|
@ -437,19 +437,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;
|
||||||
|
@ -464,21 +464,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,19 +502,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;
|
||||||
|
@ -537,7 +537,7 @@ void LoadTGA (FILE *fin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fin);
|
Qclose(fin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -549,7 +549,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)
|
||||||
|
|
|
@ -676,13 +676,13 @@ Writes lines containing "bind key value"
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Key_WriteBindings ( FILE *f )
|
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])
|
||||||
fprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString(i), keybindings[i]); // 1999-12-26 bound keys not saved in quotes fix by Maddes
|
Qprintf (f, "bind \"%s\" \"%s\"\n", Key_KeynumToString(i), keybindings[i]); // 1999-12-26 bound keys not saved in quotes fix by Maddes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1590,8 +1590,8 @@ void PF_logfrag (void)
|
||||||
|
|
||||||
SZ_Print (&svs.log[svs.logsequence&1], s);
|
SZ_Print (&svs.log[svs.logsequence&1], s);
|
||||||
if (sv_fraglogfile) {
|
if (sv_fraglogfile) {
|
||||||
fprintf (sv_fraglogfile, s);
|
Qprintf (sv_fraglogfile, s);
|
||||||
fflush (sv_fraglogfile);
|
Qflush (sv_fraglogfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -507,7 +507,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;
|
||||||
|
@ -515,11 +515,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,11 +540,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)
|
||||||
|
@ -637,14 +637,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];
|
||||||
|
@ -659,10 +659,10 @@ void ED_WriteGlobals (FILE *f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
name = PR_GetString(def->s_name);
|
name = PR_GetString(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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -124,7 +124,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;
|
||||||
|
@ -189,15 +189,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;
|
||||||
}
|
}
|
||||||
|
@ -206,11 +206,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, "rbz");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
*hndl = NULL;
|
*hndl = NULL;
|
||||||
|
@ -288,22 +288,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -341,13 +341,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);
|
||||||
|
|
||||||
|
@ -357,19 +357,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);
|
||||||
|
@ -385,6 +385,7 @@ COM_OpenRead (const char *path, int offs, int len)
|
||||||
len=lseek(fd,0,SEEK_END);
|
len=lseek(fd,0,SEEK_END);
|
||||||
lseek(fd,0,SEEK_SET);
|
lseek(fd,0,SEEK_SET);
|
||||||
}
|
}
|
||||||
|
lseek(fd,offs,SEEK_SET);
|
||||||
read(fd,id,2);
|
read(fd,id,2);
|
||||||
if (id[0]==0x1f && id[1]==0x8b) {
|
if (id[0]==0x1f && id[1]==0x8b) {
|
||||||
lseek(fd,offs+len-4,SEEK_SET);
|
lseek(fd,offs+len-4,SEEK_SET);
|
||||||
|
@ -400,7 +401,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,"rbz");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,13 +414,21 @@ 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];
|
||||||
pack_t *pak;
|
pack_t *pak;
|
||||||
int i;
|
int i;
|
||||||
int findtime;
|
int findtime;
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
char gzfilename[MAX_OSPATH];
|
||||||
|
int filenamelen;;
|
||||||
|
|
||||||
|
filenamelen = strlen(filename);
|
||||||
|
strncpy(gzfilename,filename,sizeof(gzfilename));
|
||||||
|
strncat(gzfilename,".gz",sizeof(gzfilename));
|
||||||
|
#endif
|
||||||
|
|
||||||
file_from_pak = 0;
|
file_from_pak = 0;
|
||||||
|
|
||||||
|
@ -435,11 +444,20 @@ COM_FOpenFile (char *filename, FILE **gzfile)
|
||||||
pak = search->pack;
|
pak = search->pack;
|
||||||
for (i=0 ; i<pak->numfiles ; i++) {
|
for (i=0 ; i<pak->numfiles ; i++) {
|
||||||
char *fn=0;
|
char *fn=0;
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
if (!strncmp(pak->files[i].name, filename, filenamelen)) {
|
||||||
|
if (!pak->files[i].name[filenamelen])
|
||||||
|
fn=filename;
|
||||||
|
else if (!strcmp (pak->files[i].name, gzfilename))
|
||||||
|
fn=gzfilename;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (!strcmp (pak->files[i].name, filename))
|
if (!strcmp (pak->files[i].name, filename))
|
||||||
fn=filename;
|
fn=filename;
|
||||||
|
#endif
|
||||||
if (fn)
|
if (fn)
|
||||||
{ // found it!
|
{ // found it!
|
||||||
if (developer->value)
|
if (developer->int_val)
|
||||||
Sys_Printf ("PackFile: %s : %s\n",pak->filename, fn);
|
Sys_Printf ("PackFile: %s : %s\n",pak->filename, fn);
|
||||||
// open a new file on the pakfile
|
// open a new file on the pakfile
|
||||||
*gzfile=COM_OpenRead(pak->filename,pak->files[i].filepos,
|
*gzfile=COM_OpenRead(pak->filename,pak->files[i].filepos,
|
||||||
|
@ -457,10 +475,16 @@ COM_FOpenFile (char *filename, FILE **gzfile)
|
||||||
|
|
||||||
findtime = Sys_FileTime (netpath);
|
findtime = Sys_FileTime (netpath);
|
||||||
if (findtime == -1) {
|
if (findtime == -1) {
|
||||||
|
#ifdef HAS_ZLIB
|
||||||
|
snprintf(netpath, sizeof(netpath), "%s/%s",search->filename,
|
||||||
|
gzfilename);
|
||||||
|
findtime = Sys_FileTime (netpath);
|
||||||
|
if (findtime == -1)
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(developer->value)
|
if(developer->int_val)
|
||||||
Sys_Printf ("FindFile: %s\n",netpath);
|
Sys_Printf ("FindFile: %s\n",netpath);
|
||||||
|
|
||||||
*gzfile=COM_OpenRead(netpath,-1,-1);
|
*gzfile=COM_OpenRead(netpath,-1,-1);
|
||||||
|
@ -489,7 +513,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;
|
||||||
|
@ -529,8 +553,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();
|
||||||
}
|
}
|
||||||
|
@ -586,13 +610,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);
|
||||||
|
@ -606,8 +630,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
|
||||||
|
@ -819,7 +843,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);
|
||||||
}
|
}
|
||||||
|
|
210
source/quakeio.c
210
source/quakeio.c
|
@ -91,103 +91,247 @@ 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ 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;
|
||||||
|
@ -121,7 +121,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]);
|
char buf[64];
|
||||||
|
Qgets(f, buf, sizeof(buf));
|
||||||
|
r = sscanf (buf,"%f %f %f\n", &org[0], &org[1], &org[2]);
|
||||||
if (r != 3)
|
if (r != 3)
|
||||||
break;
|
break;
|
||||||
c++;
|
c++;
|
||||||
|
@ -143,7 +145,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,14 +128,14 @@ void SV_Logfile_f (void)
|
||||||
if (sv_logfile)
|
if (sv_logfile)
|
||||||
{
|
{
|
||||||
Con_Printf ("File logging off.\n");
|
Con_Printf ("File logging off.\n");
|
||||||
fclose (sv_logfile);
|
Qclose (sv_logfile);
|
||||||
sv_logfile = NULL;
|
sv_logfile = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (name, sizeof(name), "%s/qconsole.log", com_gamedir);
|
snprintf (name, sizeof(name), "%s/qconsole.log", com_gamedir);
|
||||||
Con_Printf ("Logging text to %s.\n", name);
|
Con_Printf ("Logging text to %s.\n", name);
|
||||||
sv_logfile = fopen (name, "w");
|
sv_logfile = Qopen (name, "w");
|
||||||
if (!sv_logfile)
|
if (!sv_logfile)
|
||||||
Con_Printf ("failed.\n");
|
Con_Printf ("failed.\n");
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ void SV_Fraglogfile_f (void)
|
||||||
if (sv_fraglogfile)
|
if (sv_fraglogfile)
|
||||||
{
|
{
|
||||||
Con_Printf ("Frag file logging off.\n");
|
Con_Printf ("Frag file logging off.\n");
|
||||||
fclose (sv_fraglogfile);
|
Qclose (sv_fraglogfile);
|
||||||
sv_fraglogfile = NULL;
|
sv_fraglogfile = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -163,15 +163,15 @@ void SV_Fraglogfile_f (void)
|
||||||
for (i=0 ; i<1000 ; i++)
|
for (i=0 ; i<1000 ; i++)
|
||||||
{
|
{
|
||||||
snprintf (name, sizeof(name), "%s/frag_%i.log", com_gamedir, i);
|
snprintf (name, sizeof(name), "%s/frag_%i.log", com_gamedir, i);
|
||||||
sv_fraglogfile = fopen (name, "r");
|
sv_fraglogfile = Qopen (name, "r");
|
||||||
if (!sv_fraglogfile)
|
if (!sv_fraglogfile)
|
||||||
{ // can't read it, so create this one
|
{ // can't read it, so create this one
|
||||||
sv_fraglogfile = fopen (name, "w");
|
sv_fraglogfile = Qopen (name, "w");
|
||||||
if (!sv_fraglogfile)
|
if (!sv_fraglogfile)
|
||||||
i=1000; // give error
|
i=1000; // give error
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fclose (sv_fraglogfile);
|
Qclose (sv_fraglogfile);
|
||||||
}
|
}
|
||||||
if (i==1000)
|
if (i==1000)
|
||||||
{
|
{
|
||||||
|
@ -333,7 +333,7 @@ void SV_Map_f (void)
|
||||||
{
|
{
|
||||||
char level[MAX_QPATH];
|
char level[MAX_QPATH];
|
||||||
char expanded[MAX_QPATH];
|
char expanded[MAX_QPATH];
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
if (Cmd_Argc() != 2)
|
if (Cmd_Argc() != 2)
|
||||||
{
|
{
|
||||||
|
@ -355,7 +355,7 @@ void SV_Map_f (void)
|
||||||
Cbuf_AddText (va("map %s", curlevel));
|
Cbuf_AddText (va("map %s", curlevel));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
|
|
||||||
SV_BroadcastCommand ("changing\n");
|
SV_BroadcastCommand ("changing\n");
|
||||||
SV_SendMessagesToAll ();
|
SV_SendMessagesToAll ();
|
||||||
|
|
|
@ -124,8 +124,8 @@ cvar_t *watervis;
|
||||||
|
|
||||||
cvar_t *hostname;
|
cvar_t *hostname;
|
||||||
|
|
||||||
FILE *sv_logfile;
|
QFile *sv_logfile;
|
||||||
FILE *sv_fraglogfile;
|
QFile *sv_fraglogfile;
|
||||||
|
|
||||||
void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
|
void SV_AcceptClient (netadr_t adr, int userid, char *userinfo);
|
||||||
void Master_Shutdown (void);
|
void Master_Shutdown (void);
|
||||||
|
@ -149,12 +149,12 @@ void SV_Shutdown (void)
|
||||||
Master_Shutdown ();
|
Master_Shutdown ();
|
||||||
if (sv_logfile)
|
if (sv_logfile)
|
||||||
{
|
{
|
||||||
fclose (sv_logfile);
|
Qclose (sv_logfile);
|
||||||
sv_logfile = NULL;
|
sv_logfile = NULL;
|
||||||
}
|
}
|
||||||
if (sv_fraglogfile)
|
if (sv_fraglogfile)
|
||||||
{
|
{
|
||||||
fclose (sv_fraglogfile);
|
Qclose (sv_fraglogfile);
|
||||||
sv_logfile = NULL;
|
sv_logfile = NULL;
|
||||||
}
|
}
|
||||||
NET_Shutdown ();
|
NET_Shutdown ();
|
||||||
|
@ -259,12 +259,12 @@ void SV_DropClient (client_t *drop)
|
||||||
|
|
||||||
if (drop->download)
|
if (drop->download)
|
||||||
{
|
{
|
||||||
fclose (drop->download);
|
Qclose (drop->download);
|
||||||
drop->download = NULL;
|
drop->download = NULL;
|
||||||
}
|
}
|
||||||
if (drop->upload)
|
if (drop->upload)
|
||||||
{
|
{
|
||||||
fclose (drop->upload);
|
Qclose (drop->upload);
|
||||||
drop->upload = NULL;
|
drop->upload = NULL;
|
||||||
}
|
}
|
||||||
*drop->uploadfn = 0;
|
*drop->uploadfn = 0;
|
||||||
|
@ -1142,7 +1142,7 @@ SV_WriteIP_f
|
||||||
*/
|
*/
|
||||||
void SV_WriteIP_f (void)
|
void SV_WriteIP_f (void)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
byte b[4];
|
byte b[4];
|
||||||
int i;
|
int i;
|
||||||
|
@ -1151,7 +1151,7 @@ void SV_WriteIP_f (void)
|
||||||
|
|
||||||
Con_Printf ("Writing %s.\n", name);
|
Con_Printf ("Writing %s.\n", name);
|
||||||
|
|
||||||
f = fopen (name, "wb");
|
f = Qopen (name, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
Con_Printf ("Couldn't open %s\n", name);
|
Con_Printf ("Couldn't open %s\n", name);
|
||||||
|
@ -1161,10 +1161,10 @@ void SV_WriteIP_f (void)
|
||||||
for (i=0 ; i<numipfilters ; i++)
|
for (i=0 ; i<numipfilters ; i++)
|
||||||
{
|
{
|
||||||
*(unsigned int *)b = ipfilters[i].compare;
|
*(unsigned int *)b = ipfilters[i].compare;
|
||||||
fprintf (f, "addip %i.%i.%i.%i\n", b[0], b[1], b[2], b[3]);
|
Qprintf (f, "addip %i.%i.%i.%i\n", b[0], b[1], b[2], b[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (f);
|
Qclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -152,7 +152,7 @@ void Con_Printf (char *fmt, ...)
|
||||||
if (msgcount>0) {
|
if (msgcount>0) {
|
||||||
Sys_Printf ("Last message repeated %d times\n", msgcount);
|
Sys_Printf ("Last message repeated %d times\n", msgcount);
|
||||||
if (sv_logfile)
|
if (sv_logfile)
|
||||||
fprintf (sv_logfile, "Last message repeated %d times\n", msgcount);
|
Qprintf (sv_logfile, "Last message repeated %d times\n", msgcount);
|
||||||
msgcount=0;
|
msgcount=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ void Con_Printf (char *fmt, ...)
|
||||||
|
|
||||||
Sys_Printf ("%s", msg2); // also echo to debugging console
|
Sys_Printf ("%s", msg2); // also echo to debugging console
|
||||||
if (sv_logfile)
|
if (sv_logfile)
|
||||||
fprintf (sv_logfile, "%s", msg2);
|
Qprintf (sv_logfile, "%s", msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -54,12 +54,12 @@ Sys_FileTime
|
||||||
*/
|
*/
|
||||||
int Sys_FileTime (char *path)
|
int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -573,7 +573,7 @@ void SV_NextDownload_f (void)
|
||||||
r = host_client->downloadsize - host_client->downloadcount;
|
r = host_client->downloadsize - host_client->downloadcount;
|
||||||
if (r > 768)
|
if (r > 768)
|
||||||
r = 768;
|
r = 768;
|
||||||
r = fread (buffer, 1, r, host_client->download);
|
r = Qread (host_client->download, buffer, r);
|
||||||
ClientReliableWrite_Begin (host_client, svc_download, 6+r);
|
ClientReliableWrite_Begin (host_client, svc_download, 6+r);
|
||||||
ClientReliableWrite_Short (host_client, r);
|
ClientReliableWrite_Short (host_client, r);
|
||||||
|
|
||||||
|
@ -588,7 +588,7 @@ void SV_NextDownload_f (void)
|
||||||
if (host_client->downloadcount != host_client->downloadsize)
|
if (host_client->downloadcount != host_client->downloadsize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fclose (host_client->download);
|
Qclose (host_client->download);
|
||||||
host_client->download = NULL;
|
host_client->download = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,7 @@ void SV_NextUpload (void)
|
||||||
|
|
||||||
if (!host_client->upload)
|
if (!host_client->upload)
|
||||||
{
|
{
|
||||||
host_client->upload = fopen(host_client->uploadfn, "wb");
|
host_client->upload = Qopen(host_client->uploadfn, "wb");
|
||||||
if (!host_client->upload) {
|
if (!host_client->upload) {
|
||||||
Sys_Printf("Can't create %s\n", host_client->uploadfn);
|
Sys_Printf("Can't create %s\n", host_client->uploadfn);
|
||||||
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
|
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
|
||||||
|
@ -649,7 +649,7 @@ void SV_NextUpload (void)
|
||||||
OutofBandPrintf(host_client->snap_from, "Server receiving %s from %d...\n", host_client->uploadfn, host_client->userid);
|
OutofBandPrintf(host_client->snap_from, "Server receiving %s from %d...\n", host_client->uploadfn, host_client->userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite (net_message.data + msg_readcount, 1, size, host_client->upload);
|
Qwrite (host_client->upload, net_message.data + msg_readcount, size);
|
||||||
msg_readcount += size;
|
msg_readcount += size;
|
||||||
|
|
||||||
Con_DPrintf ("UPLOAD: %d received\n", size);
|
Con_DPrintf ("UPLOAD: %d received\n", size);
|
||||||
|
@ -658,7 +658,7 @@ Con_DPrintf ("UPLOAD: %d received\n", size);
|
||||||
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
|
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
|
||||||
ClientReliableWrite_String (host_client, "nextul\n");
|
ClientReliableWrite_String (host_client, "nextul\n");
|
||||||
} else {
|
} else {
|
||||||
fclose (host_client->upload);
|
Qclose (host_client->upload);
|
||||||
host_client->upload = NULL;
|
host_client->upload = NULL;
|
||||||
|
|
||||||
Sys_Printf("%s upload completed.\n", host_client->uploadfn);
|
Sys_Printf("%s upload completed.\n", host_client->uploadfn);
|
||||||
|
@ -718,7 +718,7 @@ void SV_BeginDownload_f(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host_client->download) {
|
if (host_client->download) {
|
||||||
fclose (host_client->download);
|
Qclose (host_client->download);
|
||||||
host_client->download = NULL;
|
host_client->download = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ void SV_BeginDownload_f(void)
|
||||||
|| (strncmp(name, "maps/", 5) == 0 && file_from_pak))
|
|| (strncmp(name, "maps/", 5) == 0 && file_from_pak))
|
||||||
{
|
{
|
||||||
if (host_client->download) {
|
if (host_client->download) {
|
||||||
fclose(host_client->download);
|
Qclose(host_client->download);
|
||||||
host_client->download = NULL;
|
host_client->download = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,15 +38,15 @@
|
||||||
filelength
|
filelength
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int filelength (FILE *f)
|
int 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;
|
||||||
}
|
}
|
||||||
|
@ -54,12 +54,12 @@ int filelength (FILE *f)
|
||||||
|
|
||||||
int Sys_FileTime (char *path)
|
int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned int *table;
|
unsigned int *table;
|
||||||
FILE *f;
|
QFile *f;
|
||||||
char s[255];
|
char s[255];
|
||||||
//#endif
|
//#endif
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
|
@ -196,8 +196,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++) {
|
||||||
|
@ -226,9 +226,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned int *table;
|
unsigned int *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;
|
||||||
|
@ -240,8 +240,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
|
||||||
|
@ -269,9 +269,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ VID_SetPalette (unsigned char *palette)
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned int *table;
|
unsigned int *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;
|
||||||
|
@ -187,8 +187,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
|
||||||
|
@ -216,9 +216,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 int *table;
|
unsigned int *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
|
||||||
|
@ -784,9 +784,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue