Add gzip support, add -Werror to gcc CFLAGS, clean up misc warnings.

NOTE: demos are broken for gzipped demo files (possibly normal ones too, not
yet tested).
This commit is contained in:
Bill Currie 2000-02-03 00:34:12 +00:00
parent 02dab8f828
commit e9a2a3fab5
20 changed files with 155 additions and 90 deletions

View file

@ -551,11 +551,14 @@ Draws the console with the solid background
*/
void Con_DrawConsole (int lines)
{
int i, j, x, y, n;
int i, x, y;
int rows;
char *text;
int row;
#ifdef QUAKEWORLD
int j, n;
char dlbar[1024];
#endif
if (lines <= 0)
return;

View file

@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "console.h"
#include "menu.h"
#include "screen.h"
#include "sys.h"
#ifdef _WIN32
#include <windows.h>

View file

@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <protocol.h>
#include <cmd.h>
#include <sys.h>
#include <console.h>
#define RETURN_EDICT(e) (((int *)pr_globals)[OFS_RETURN] = EDICT_TO_PROG(e))
#define RETURN_STRING(s) (((int *)pr_globals)[OFS_RETURN] = PR_SetString(s))

View file

@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <cmd.h>
#include <crc.h>
#include <cvar.h>
#include <console.h>
dprograms_t *progs;
dfunction_t *pr_functions;

View file

@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
#include <sys.h>
#include <console.h>
typedef struct
{
@ -371,9 +372,9 @@ PR_ExecuteProgram
*/
void PR_ExecuteProgram (func_t fnum)
{
eval_t *a, *b, *c;
eval_t *a=0, *b=0, *c=0;
int s;
dstatement_t *st;
dstatement_t *st=0;
dfunction_t *f, *newf;
int runaway;
int i;

View file

@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
#include <qtypes.h>
#include <quakefs.h>
#include <sys.h>
@ -260,6 +262,36 @@ void COM_CopyFile (char *netpath, char *cachepath)
fclose (out);
}
gzFile *COM_gzOpenRead(const char *path, int offs, int len)
{
int fd=open(path,O_RDONLY);
unsigned char id[2];
unsigned char len_bytes[4];
if (fd==-1) {
Sys_Error ("Couldn't open %s", path);
return 0;
}
if (offs<0 || len<0) {
// normal file
offs=0;
len=lseek(fd,0,SEEK_END);
lseek(fd,0,SEEK_SET);
}
read(fd,id,2);
if (id[0]==0x1f && id[1]==0x8b) {
lseek(fd,offs+len-4,SEEK_SET);
read(fd,len_bytes,4);
len=((len_bytes[3]<<24)
|(len_bytes[2]<<16)
|(len_bytes[1]<<8)
|(len_bytes[0]));
}
lseek(fd,offs,SEEK_SET);
com_filesize=len;
return gzdopen(fd,"rb");
}
/*
===========
COM_FindFile
@ -270,7 +302,7 @@ Sets com_filesize and one of handle or file
*/
int file_from_pak; // global indicating file came from pack file ZOID
int COM_FOpenFile (char *filename, FILE **file)
int COM_FOpenFile (char *filename, gzFile **gzfile)
{
searchpath_t *search;
char netpath[MAX_OSPATH];
@ -305,11 +337,13 @@ int COM_FOpenFile (char *filename, FILE **file)
if(developer.value)
Sys_Printf ("PackFile: %s : %s\n",pak->filename, fn);
// open a new file on the pakfile
*file = fopen (pak->filename, "rb");
if (!*file)
Sys_Error ("Couldn't reopen %s", pak->filename);
fseek (*file, pak->files[i].filepos, SEEK_SET);
com_filesize = pak->files[i].filelen;
//*file = fopen (pak->filename, "rb");
//if (!*file)
// Sys_Error ("Couldn't reopen %s", pak->filename);
//fseek (*file, pak->files[i].filepos, SEEK_SET);
//com_filesize = pak->files[i].filelen;
*gzfile=COM_gzOpenRead(pak->filename,pak->files[i].filepos,
pak->files[i].filelen);
file_from_pak = 1;
return com_filesize;
}
@ -333,15 +367,17 @@ int COM_FOpenFile (char *filename, FILE **file)
if(developer.value)
Sys_Printf ("FindFile: %s\n",netpath);
*file = fopen (netpath, "rb");
return COM_filelength (*file);
//*file = fopen (netpath, "rb");
//return COM_filelength (*file);
*gzfile=COM_gzOpenRead(netpath,-1,-1);
return com_filesize;
}
}
Sys_Printf ("FindFile: can't find %s\n", filename);
*file = NULL;
*gzfile = NULL;
com_filesize = -1;
return -1;
}
@ -359,7 +395,7 @@ byte *loadbuf;
int loadsize;
byte *COM_LoadFile (char *path, int usehunk)
{
FILE *h;
gzFile *h;
byte *buf;
char base[32];
int len;
@ -399,8 +435,8 @@ byte *COM_LoadFile (char *path, int usehunk)
#ifndef SERVERONLY
Draw_BeginDisc ();
#endif
fread (buf, 1, len, h);
fclose (h);
gzread (h, buf, len);
gzclose (h);
#ifndef SERVERONLY
Draw_EndDisc ();
#endif

View file

@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _QUAKEFS_H
#define _QUAKEFS_H
#include <zlib.h>
//============================================================================
@ -35,7 +36,7 @@ struct cache_user_s;
extern char com_gamedir[MAX_OSPATH];
void COM_WriteFile (char *filename, void *data, int len);
int COM_FOpenFile (char *filename, FILE **file);
int COM_FOpenFile (char *filename, gzFile **file);
void COM_CloseFile (FILE *h);
byte *COM_LoadStackFile (char *path, void *buffer, int bufsize);

View file

@ -44,7 +44,7 @@ cvar_t registered = {"registered", "0"};
void
register_check ( void ) {
FILE *h;
gzFile *h;
Cvar_RegisterVariable (&registered);
@ -52,6 +52,6 @@ register_check ( void ) {
if (h) {
Cvar_Set ("registered", "1");
fclose (h);
gzclose (h);
}
}

View file

@ -33,6 +33,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "cmd.h"
#include <protocol.h>
extern void M_DrawPic (int x, int y, qpic_t *pic);
int sb_updates; // if >= vid.numpages, no update needed
#define STAT_MINUS 10 // num frame for '-' stats digit
@ -655,7 +657,6 @@ void Sbar_SoloScoreboard (void)
{
char str[80];
int minutes, seconds, tens, units;
int l;
#ifdef QUAKEWORLD
Sbar_DrawPic (0, 0, sb_scorebar);
@ -676,9 +677,11 @@ void Sbar_SoloScoreboard (void)
Sbar_DrawString (184, 4, str);
#ifdef UQUAKE
// draw level name
l = strlen (cl.levelname);
Sbar_DrawString (232 - l*4, 12, cl.levelname);
{
// draw level name
int l = strlen (cl.levelname);
Sbar_DrawString (232 - l*4, 12, cl.levelname);
}
#endif // QUAKEWORLD
}
@ -1194,7 +1197,9 @@ Sbar_Draw
void Sbar_Draw (void)
{
qboolean headsup;
#ifdef QUAKEWORLD
char st[512];
#endif
headsup = !(cl_sbar.value || scr_viewsize.value<100);
if ((sb_updates >= vid.numpages) && !headsup)

View file

@ -113,6 +113,10 @@ fi
dnl Checks for working -lm
AC_CHECK_LIB(m, pow,, AC_MSG_ERROR([math library (-lm) appears broken]))
dnl Check for working -lz
AC_CHECK_LIB(z, gzopen, LIBS="$LIBS -lz"
HAS_ZLIB=yes, HAS_ZLIB=no, [$LIBS])
dnl Checks for X11 support
dnl (XoXus: Since vid_x.c relies on XShm being there, this now disables
@ -435,7 +439,7 @@ dnl CFLAGS for release and devel versions
if test "x$RELEASE" = xyes; then
if test "x$GCC" = xyes; then
AC_MSG_CHECKING(for special release compiler settings)
BASE_RELEASE_CFLAGS="-Wall -O6 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations"
BASE_RELEASE_CFLAGS="-Wall -Werror -O6 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations"
case "${target}" in
changequote(,)dnl
i?86-*-*)
@ -478,7 +482,7 @@ fi
dnl We want warnings, lots of warnings...
if test "x$GCC" = xyes; then
CFLAGS="$CFLAGS -Wall"
CFLAGS="$CFLAGS -Wall -Werror"
fi
# CFLAGS="$CFLAGS -Wall -pedantic"

View file

@ -54,7 +54,7 @@ void CL_StopPlayback (void)
if (!cls.demoplayback)
return;
fclose (cls.demofile);
gzclose (cls.demofile);
cls.demofile = NULL;
cls.state = ca_disconnected;
cls.demoplayback = 0;
@ -84,10 +84,10 @@ void CL_WriteDemoCmd (usercmd_t *pcmd)
//Con_Printf("write: %ld bytes, %4.4f\n", msg->cursize, realtime);
fl = LittleFloat((float)realtime);
fwrite (&fl, sizeof(fl), 1, cls.demofile);
gzwrite (cls.demofile, &fl, sizeof(fl));
c = dem_cmd;
fwrite (&c, sizeof(c), 1, cls.demofile);
gzwrite (cls.demofile, &c, sizeof(c));
// correct for byte order, bytes don't matter
cmd = *pcmd;
@ -98,15 +98,15 @@ void CL_WriteDemoCmd (usercmd_t *pcmd)
cmd.sidemove = LittleShort(cmd.sidemove);
cmd.upmove = LittleShort(cmd.upmove);
fwrite(&cmd, sizeof(cmd), 1, cls.demofile);
gzwrite(cls.demofile, &cmd, sizeof(cmd));
for (i=0 ; i<3 ; i++)
{
fl = LittleFloat (cl.viewangles[i]);
fwrite (&fl, 4, 1, cls.demofile);
gzwrite (cls.demofile, &fl, 4);
}
fflush (cls.demofile);
gzflush (cls.demofile, Z_SYNC_FLUSH);
}
/*
@ -128,16 +128,16 @@ void CL_WriteDemoMessage (sizebuf_t *msg)
return;
fl = LittleFloat((float)realtime);
fwrite (&fl, sizeof(fl), 1, cls.demofile);
gzwrite (cls.demofile, &fl, sizeof(fl));
c = dem_read;
fwrite (&c, sizeof(c), 1, cls.demofile);
gzwrite (cls.demofile, &c, sizeof(c));
len = LittleLong (msg->cursize);
fwrite (&len, 4, 1, cls.demofile);
fwrite (msg->data, msg->cursize, 1, cls.demofile);
gzwrite (cls.demofile, &len, 4);
gzwrite (cls.demofile, msg->data, msg->cursize);
fflush (cls.demofile);
gzflush (cls.demofile, Z_SYNC_FLUSH);
}
/*
@ -156,7 +156,7 @@ qboolean CL_GetDemoMessage (void)
usercmd_t *pcmd;
// read the time from the packet
fread(&demotime, sizeof(demotime), 1, cls.demofile);
gzread(cls.demofile, &demotime, sizeof(demotime));
demotime = LittleFloat(demotime);
// decide if it is time to grab the next message
@ -166,7 +166,7 @@ qboolean CL_GetDemoMessage (void)
else if (demotime > cls.td_lastframe) {
cls.td_lastframe = demotime;
// rewind back to time
fseek(cls.demofile, ftell(cls.demofile) - sizeof(demotime),
gzseek(cls.demofile, gztell(cls.demofile) - sizeof(demotime),
SEEK_SET);
return 0; // allready read this frame's message
}
@ -180,12 +180,12 @@ qboolean CL_GetDemoMessage (void)
// too far back
realtime = demotime - 1.0;
// rewind back to time
fseek(cls.demofile, ftell(cls.demofile) - sizeof(demotime),
gzseek(cls.demofile, gztell(cls.demofile) - sizeof(demotime),
SEEK_SET);
return 0;
} else if (realtime < demotime) {
// rewind back to time
fseek(cls.demofile, ftell(cls.demofile) - sizeof(demotime),
gzseek(cls.demofile, gztell(cls.demofile) - sizeof(demotime),
SEEK_SET);
return 0; // don't need another message yet
}
@ -196,14 +196,14 @@ qboolean CL_GetDemoMessage (void)
Host_Error ("CL_GetDemoMessage: cls.state != ca_active");
// get the msg type
fread (&c, sizeof(c), 1, cls.demofile);
gzread (cls.demofile, &c, sizeof(c));
switch (c) {
case dem_cmd :
// user sent input
i = cls.netchan.outgoing_sequence & UPDATE_MASK;
pcmd = &cl.frames[i].cmd;
r = fread (pcmd, sizeof(*pcmd), 1, cls.demofile);
r = gzread (cls.demofile, pcmd, sizeof(*pcmd));
if (r != 1)
{
CL_StopPlayback ();
@ -220,19 +220,19 @@ qboolean CL_GetDemoMessage (void)
cls.netchan.outgoing_sequence++;
for (i=0 ; i<3 ; i++)
{
r = fread (&f, 4, 1, cls.demofile);
r = gzread (cls.demofile, &f, 4);
cl.viewangles[i] = LittleFloat (f);
}
break;
case dem_read:
// get the next message
fread (&net_message.cursize, 4, 1, cls.demofile);
gzread (cls.demofile, &net_message.cursize, 4);
net_message.cursize = LittleLong (net_message.cursize);
//Con_Printf("read: %ld bytes\n", net_message.cursize);
if (net_message.cursize > MAX_MSGLEN)
Sys_Error ("Demo message > MAX_MSGLEN");
r = fread (net_message.data, net_message.cursize, 1, cls.demofile);
r = gzread (cls.demofile, net_message.data, net_message.cursize);
if (r != 1)
{
CL_StopPlayback ();
@ -241,9 +241,9 @@ qboolean CL_GetDemoMessage (void)
break;
case dem_set :
fread (&i, 4, 1, cls.demofile);
gzread (cls.demofile, &i, 4);
cls.netchan.outgoing_sequence = LittleLong(i);
fread (&i, 4, 1, cls.demofile);
gzread (cls.demofile, &i, 4);
cls.netchan.incoming_sequence = LittleLong(i);
break;
@ -300,7 +300,7 @@ void CL_Stop_f (void)
CL_WriteDemoMessage (&net_message);
// finish up
fclose (cls.demofile);
gzclose (cls.demofile);
cls.demofile = NULL;
cls.demorecording = false;
Con_Printf ("Completed demo\n");
@ -327,21 +327,21 @@ void CL_WriteRecordDemoMessage (sizebuf_t *msg, int seq)
return;
fl = LittleFloat((float)realtime);
fwrite (&fl, sizeof(fl), 1, cls.demofile);
gzwrite (cls.demofile, &fl, sizeof(fl));
c = dem_read;
fwrite (&c, sizeof(c), 1, cls.demofile);
gzwrite (cls.demofile, &c, sizeof(c));
len = LittleLong (msg->cursize + 8);
fwrite (&len, 4, 1, cls.demofile);
gzwrite (cls.demofile, &len, 4);
i = LittleLong(seq);
fwrite (&i, 4, 1, cls.demofile);
fwrite (&i, 4, 1, cls.demofile);
gzwrite (cls.demofile, &i, 4);
gzwrite (cls.demofile, &i, 4);
fwrite (msg->data, msg->cursize, 1, cls.demofile);
gzwrite (cls.demofile, msg->data, msg->cursize);
fflush (cls.demofile);
gzflush (cls.demofile, Z_SYNC_FLUSH);
}
@ -357,17 +357,17 @@ void CL_WriteSetDemoMessage (void)
return;
fl = LittleFloat((float)realtime);
fwrite (&fl, sizeof(fl), 1, cls.demofile);
gzwrite (cls.demofile, &fl, sizeof(fl));
c = dem_set;
fwrite (&c, sizeof(c), 1, cls.demofile);
gzwrite (cls.demofile, &c, sizeof(c));
len = LittleLong(cls.netchan.outgoing_sequence);
fwrite (&len, 4, 1, cls.demofile);
gzwrite (cls.demofile, &len, 4);
len = LittleLong(cls.netchan.incoming_sequence);
fwrite (&len, 4, 1, cls.demofile);
gzwrite (cls.demofile, &len, 4);
fflush (cls.demofile);
gzflush (cls.demofile, Z_SYNC_FLUSH);
}
@ -416,7 +416,7 @@ void CL_Record_f (void)
//
COM_DefaultExtension (name, ".qwd");
cls.demofile = fopen (name, "wb");
cls.demofile = gzopen (name, "wb");
if (!cls.demofile)
{
Con_Printf ("ERROR: couldn't open.\n");
@ -702,7 +702,7 @@ void CL_ReRecord_f (void)
//
COM_DefaultExtension (name, ".qwd");
cls.demofile = fopen (name, "wb");
cls.demofile = gzopen (name, "wb");
if (!cls.demofile)
{
Con_Printf ("ERROR: couldn't open.\n");

View file

@ -167,7 +167,7 @@ to start a download from the server.
*/
qboolean CL_CheckOrDownloadFile (char *filename)
{
FILE *f;
gzFile *f;
if (strstr (filename, ".."))
{
@ -178,7 +178,7 @@ qboolean CL_CheckOrDownloadFile (char *filename)
COM_FOpenFile (filename, &f);
if (f)
{ // it exists, no need to download
fclose (f);
gzclose (f);
return true;
}

View file

@ -93,12 +93,13 @@ void R_ClearParticles (void)
void R_ReadPointFile_f (void)
{
FILE *f;
gzFile *f;
vec3_t org;
int r;
int c;
particle_t *p;
char name[MAX_OSPATH];
char buf[256];
// FIXME snprintf(name, sizeof(name),"maps/%s.pts", sv.name);
@ -113,7 +114,9 @@ void R_ReadPointFile_f (void)
c = 0;
for ( ;; )
{
r = fscanf (f,"%f %f %f\n", &org[0], &org[1], &org[2]);
if (!gzgets(f,buf,sizeof(buf)))
break;
r = sscanf (buf,"%f %f %f\n", &org[0], &org[1], &org[2]);
if (r != 3)
break;
c++;
@ -135,7 +138,7 @@ void R_ReadPointFile_f (void)
VectorCopy (org, p->org);
}
fclose (f);
gzclose (f);
Con_Printf ("%i points read\n", c);
}

View file

@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _CLIENT_H
#define _CLIENT_H
#include <zlib.h>
#include "qtypes.h"
#include "zone.h"
#include "protocol.h"
@ -195,7 +197,7 @@ typedef struct
qboolean demorecording;
qboolean demoplayback;
qboolean timedemo;
FILE *demofile;
gzFile *demofile;
float td_lastframe; // to meter out one message a frame
int td_startframe; // host_framecount at start
float td_starttime; // realtime at second frame of timedemo

View file

@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _SERVER_H
#define _SERVER_H
#include <zlib.h>
#include <progs.h>
#define QW_SERVER
@ -175,7 +177,7 @@ typedef struct client_s
client_frame_t frames[UPDATE_BACKUP]; // updates can be deltad from here
FILE *download; // file being downloaded
gzFile *download; // file being downloaded
int downloadsize; // total bytes
int downloadcount; // bytes sent

View file

@ -306,7 +306,7 @@ void SV_Map_f (void)
{
char level[MAX_QPATH];
char expanded[MAX_QPATH];
FILE *f;
gzFile *f;
if (Cmd_Argc() != 2)
{
@ -331,7 +331,7 @@ void SV_Map_f (void)
Con_Printf ("Can't find %s\n", expanded);
return;
}
fclose (f);
gzclose (f);
SV_BroadcastCommand ("changing\n");
SV_SendMessagesToAll ();

View file

@ -533,7 +533,7 @@ void SV_NextDownload_f (void)
r = host_client->downloadsize - host_client->downloadcount;
if (r > 768)
r = 768;
r = fread (buffer, 1, r, host_client->download);
r = gzread (host_client->download, buffer, r);
ClientReliableWrite_Begin (host_client, svc_download, 6+r);
ClientReliableWrite_Short (host_client, r);
@ -548,7 +548,7 @@ void SV_NextDownload_f (void)
if (host_client->downloadcount != host_client->downloadsize)
return;
fclose (host_client->download);
gzclose (host_client->download);
host_client->download = NULL;
}
@ -678,7 +678,7 @@ void SV_BeginDownload_f(void)
}
if (host_client->download) {
fclose (host_client->download);
gzclose (host_client->download);
host_client->download = NULL;
}
@ -700,7 +700,7 @@ void SV_BeginDownload_f(void)
|| (strncmp(name, "maps/", 5) == 0 && file_from_pak))
{
if (host_client->download) {
fclose(host_client->download);
gzclose(host_client->download);
host_client->download = NULL;
}

View file

@ -55,7 +55,7 @@ void CL_StopPlayback (void)
if (!cls.demoplayback)
return;
fclose (cls.demofile);
gzclose (cls.demofile);
cls.demoplayback = false;
cls.demofile = NULL;
cls.state = ca_disconnected;
@ -78,14 +78,14 @@ void CL_WriteDemoMessage (void)
float f;
len = LittleLong (net_message.cursize);
fwrite (&len, 4, 1, cls.demofile);
gzwrite (cls.demofile, &len, 4);
for (i=0 ; i<3 ; i++)
{
f = LittleFloat (cl.viewangles[i]);
fwrite (&f, 4, 1, cls.demofile);
gzwrite (cls.demofile, &f, 4);
}
fwrite (net_message.data, net_message.cursize, 1, cls.demofile);
fflush (cls.demofile);
gzwrite (cls.demofile, net_message.data, net_message.cursize);
gzflush (cls.demofile, Z_SYNC_FLUSH);
}
/*
@ -122,18 +122,18 @@ int CL_GetMessage (void)
}
// get the next message
fread (&net_message.cursize, 4, 1, cls.demofile);
gzread (cls.demofile, &net_message.cursize, 4);
VectorCopy (cl.mviewangles[0], cl.mviewangles[1]);
for (i=0 ; i<3 ; i++)
{
r = fread (&f, 4, 1, cls.demofile);
r = gzread (cls.demofile, &f, 4);
cl.mviewangles[0][i] = LittleFloat (f);
}
net_message.cursize = LittleLong (net_message.cursize);
if (net_message.cursize > MAX_MSGLEN)
Sys_Error ("Demo message > MAX_MSGLEN");
r = fread (net_message.data, net_message.cursize, 1, cls.demofile);
r = gzread (cls.demofile, net_message.data, net_message.cursize);
if (r != 1)
{
CL_StopPlayback ();
@ -188,7 +188,7 @@ void CL_Stop_f (void)
CL_WriteDemoMessage ();
// finish up
fclose (cls.demofile);
gzclose (cls.demofile);
cls.demofile = NULL;
cls.demorecording = false;
Con_Printf ("Completed demo\n");
@ -252,7 +252,7 @@ void CL_Record_f (void)
COM_DefaultExtension (name, ".dem");
Con_Printf ("recording to %s.\n", name);
cls.demofile = fopen (name, "wb");
cls.demofile = gzopen (name, "wb");
if (!cls.demofile)
{
Con_Printf ("ERROR: couldn't open.\n");
@ -260,7 +260,7 @@ void CL_Record_f (void)
}
cls.forcetrack = track;
fprintf (cls.demofile, "%i\n", cls.forcetrack);
gzprintf (cls.demofile, "%i\n", cls.forcetrack);
cls.demorecording = true;
}
@ -312,7 +312,7 @@ void CL_PlayDemo_f (void)
cls.state = ca_connected;
cls.forcetrack = 0;
while ((c = getc(cls.demofile)) != '\n')
while ((c = gzgetc(cls.demofile)) != '\n')
if (c == '-')
neg = true;
else

View file

@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _CLIENT_H
#define _CLIENT_H
#include <zlib.h>
#include <qtypes.h>
#include <common.h>
#include <quakefs.h>
@ -129,7 +131,7 @@ typedef struct
qboolean demoplayback;
qboolean timedemo;
int forcetrack; // -1 = use normal cd track
FILE *demofile;
gzFile *demofile;
int td_lastframe; // to meter out one message a frame
int td_startframe; // host_framecount at start
float td_starttime; // realtime at second frame of timedemo

View file

@ -199,12 +199,13 @@ void R_ClearParticles (void)
void R_ReadPointFile_f (void)
{
FILE *f;
gzFile *f;
vec3_t org;
int r;
int c;
particle_t *p;
char name[MAX_OSPATH];
char buf[256];
snprintf(name, sizeof(name),"maps/%s.pts", sv.name);
@ -219,7 +220,9 @@ void R_ReadPointFile_f (void)
c = 0;
for ( ;; )
{
r = fscanf (f,"%f %f %f\n", &org[0], &org[1], &org[2]);
if (!gzgets(f,buf,sizeof(buf)))
break;
r = sscanf (buf,"%f %f %f\n", &org[0], &org[1], &org[2]);
if (r != 3)
break;
c++;
@ -241,7 +244,7 @@ void R_ReadPointFile_f (void)
VectorCopy (org, p->org);
}
fclose (f);
gzclose (f);
Con_Printf ("%i points read\n", c);
}