mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2024-11-22 03:41:27 +00:00
merge qw_client/cl_main.c and uquake/cl_main.c into common/cl_main.c
For the rest, convert all refs to FILE and gzFile to QFile, and similar for file functions (eg fprintf, fgets, fread, etc)
This commit is contained in:
parent
bc28568890
commit
edbb589045
26 changed files with 1404 additions and 1567 deletions
File diff suppressed because it is too large
Load diff
|
@ -205,7 +205,7 @@ typedef struct
|
|||
int qport;
|
||||
|
||||
// download stuff
|
||||
FILE *download; // file transfer from server
|
||||
QFile *download; // file transfer from server
|
||||
char downloadtempname[MAX_OSPATH];
|
||||
char downloadname[MAX_OSPATH];
|
||||
int downloadnumber;
|
||||
|
@ -229,7 +229,7 @@ typedef struct
|
|||
qboolean demoplayback;
|
||||
qboolean timedemo;
|
||||
int forcetrack;
|
||||
gzFile *demofile;
|
||||
QFile *demofile;
|
||||
float td_lastframe;
|
||||
int td_startframe;
|
||||
float td_starttime;
|
||||
|
@ -446,14 +446,14 @@ void CL_BeginServerConnect(void);
|
|||
#define MAX_VISEDICTS 256
|
||||
|
||||
extern int cl_numvisedicts, cl_oldnumvisedicts;
|
||||
#ifdef QUAKEWORLD
|
||||
//#ifdef QUAKEWORLD
|
||||
extern entity_t *cl_visedicts, *cl_oldvisedicts;
|
||||
extern entity_t cl_visedicts_list[2][MAX_VISEDICTS];
|
||||
extern char emodel_name[], pmodel_name[], prespawn_name[],
|
||||
modellist_name[], soundlist_name[];
|
||||
#elif UQUAKE
|
||||
extern entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
#endif // QUAKEWORLD else UQUAKE
|
||||
//#elif UQUAKE
|
||||
//extern entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
//#endif // QUAKEWORLD else UQUAKE
|
||||
|
||||
|
||||
//
|
||||
|
@ -497,8 +497,9 @@ void CL_StopPlayback (void);
|
|||
#ifdef QUAKEWORLD
|
||||
qboolean CL_GetMessage (void);
|
||||
void CL_WriteDemoCmd (usercmd_t *pcmd);
|
||||
#elif UQUAKE
|
||||
#elif defined(UQUAKE)
|
||||
int CL_GetMessage (void);
|
||||
void CL_SignonReply (void);
|
||||
#endif // QUAKEWORLD else UQUAKE
|
||||
|
||||
void CL_Stop_f (void);
|
||||
|
|
|
@ -278,12 +278,12 @@ Writes lines containing "set variable value" for all variables
|
|||
with the archive flag set to true.
|
||||
============
|
||||
*/
|
||||
void Cvar_WriteVariables (FILE *f)
|
||||
void Cvar_WriteVariables (QFile *f)
|
||||
{
|
||||
cvar_t *var;
|
||||
|
||||
for (var = cvar_vars ; var ; var = var->next)
|
||||
if (var->archive)
|
||||
fprintf (f, "%s \"%s\"\n", var->name, var->string);
|
||||
Qprintf (f, "%s \"%s\"\n", var->name, var->string);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define _CVAR_H
|
||||
|
||||
#include <qtypes.h>
|
||||
#include <quakeio.h>
|
||||
/*
|
||||
|
||||
cvar_t variables are used to hold scalar or string variables that can be changed or displayed at the console or prog code as well as accessed directly
|
||||
|
@ -95,7 +96,7 @@ qboolean Cvar_Command (void);
|
|||
// command. Returns true if the command was a variable reference that
|
||||
// was handled. (print or change)
|
||||
|
||||
void Cvar_WriteVariables (FILE *f);
|
||||
void Cvar_WriteVariables (QFile *f);
|
||||
// Writes lines containing "set variable value" for all variables
|
||||
// with the archive flag set to true.
|
||||
|
||||
|
|
|
@ -628,13 +628,13 @@ Key_WriteBindings
|
|||
Writes lines containing "bind key value"
|
||||
============
|
||||
*/
|
||||
void Key_WriteBindings (FILE *f)
|
||||
void Key_WriteBindings (QFile *f)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<256 ; i++)
|
||||
if (keybindings[i])
|
||||
fprintf (f, "bind %s \"%s\"\n", Key_KeynumToString(i), keybindings[i]);
|
||||
Qprintf (f, "bind %s \"%s\"\n", Key_KeynumToString(i), keybindings[i]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define KEYS_H
|
||||
|
||||
#include "qtypes.h"
|
||||
#include "quakeio.h"
|
||||
|
||||
//
|
||||
// these are the key numbers that should be passed to Key_Event
|
||||
|
@ -166,7 +167,7 @@ extern qboolean chat_team;
|
|||
|
||||
void Key_Event (int key, qboolean down);
|
||||
void Key_Init (void);
|
||||
void Key_WriteBindings (FILE *f);
|
||||
void Key_WriteBindings (QFile *f);
|
||||
void Key_SetBinding (int keynum, char *binding);
|
||||
void Key_ClearStates (void);
|
||||
|
||||
|
|
|
@ -527,7 +527,7 @@ ED_Write
|
|||
For savegames
|
||||
=============
|
||||
*/
|
||||
void ED_Write (FILE *f, edict_t *ed)
|
||||
void ED_Write (QFile *f, edict_t *ed)
|
||||
{
|
||||
ddef_t *d;
|
||||
int *v;
|
||||
|
@ -535,11 +535,11 @@ void ED_Write (FILE *f, edict_t *ed)
|
|||
char *name;
|
||||
int type;
|
||||
|
||||
fprintf (f, "{\n");
|
||||
Qprintf (f, "{\n");
|
||||
|
||||
if (ed->free)
|
||||
{
|
||||
fprintf (f, "}\n");
|
||||
Qprintf (f, "}\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -560,11 +560,11 @@ void ED_Write (FILE *f, edict_t *ed)
|
|||
if (j == type_size[type])
|
||||
continue;
|
||||
|
||||
fprintf (f,"\"%s\" ",name);
|
||||
fprintf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v));
|
||||
Qprintf (f,"\"%s\" ",name);
|
||||
Qprintf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v));
|
||||
}
|
||||
|
||||
fprintf (f, "}\n");
|
||||
Qprintf (f, "}\n");
|
||||
}
|
||||
|
||||
void ED_PrintNum (int ent)
|
||||
|
@ -665,14 +665,14 @@ FIXME: need to tag constants, doesn't really work
|
|||
ED_WriteGlobals
|
||||
=============
|
||||
*/
|
||||
void ED_WriteGlobals (FILE *f)
|
||||
void ED_WriteGlobals (QFile *f)
|
||||
{
|
||||
ddef_t *def;
|
||||
int i;
|
||||
char *name;
|
||||
int type;
|
||||
|
||||
fprintf (f,"{\n");
|
||||
Qprintf (f,"{\n");
|
||||
for (i=0 ; i<progs->numglobaldefs ; i++)
|
||||
{
|
||||
def = &pr_globaldefs[i];
|
||||
|
@ -687,10 +687,10 @@ void ED_WriteGlobals (FILE *f)
|
|||
continue;
|
||||
|
||||
name = PR_GetString(def->s_name);
|
||||
fprintf (f,"\"%s\" ", name);
|
||||
fprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs]));
|
||||
Qprintf (f,"\"%s\" ", name);
|
||||
Qprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs]));
|
||||
}
|
||||
fprintf (f,"}\n");
|
||||
Qprintf (f,"}\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -82,10 +82,10 @@ char *ED_NewString (char *string);
|
|||
// returns a copy of the string allocated from the server's string heap
|
||||
|
||||
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);
|
||||
|
||||
void ED_WriteGlobals (FILE *f);
|
||||
void ED_WriteGlobals (QFile *f);
|
||||
void ED_ParseGlobals (char *data);
|
||||
|
||||
void ED_LoadFromFile (char *data);
|
||||
|
|
|
@ -264,9 +264,9 @@ void COM_CopyFile (char *netpath, char *cachepath)
|
|||
}
|
||||
|
||||
|
||||
gzFile *COM_gzOpenRead(const char *path, int offs, int len)
|
||||
QFile *COM_gzOpenRead(const char *path, int offs, int len)
|
||||
{
|
||||
int fd=open(path,O_RDONLY);
|
||||
/* int fd=open(path,O_RDONLY);
|
||||
unsigned char id[2];
|
||||
unsigned char len_bytes[4];
|
||||
if (fd==-1) {
|
||||
|
@ -290,7 +290,8 @@ gzFile *COM_gzOpenRead(const char *path, int offs, int len)
|
|||
}
|
||||
lseek(fd,offs,SEEK_SET);
|
||||
com_filesize=len;
|
||||
return gzdopen(fd,"rb");
|
||||
return gzdopen(fd,"rb");*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -303,7 +304,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, gzFile **gzfile)
|
||||
int COM_FOpenFile (char *filename, QFile **gzfile)
|
||||
{
|
||||
searchpath_t *search;
|
||||
char netpath[MAX_OSPATH];
|
||||
|
@ -402,7 +403,7 @@ byte *loadbuf;
|
|||
int loadsize;
|
||||
byte *COM_LoadFile (char *path, int usehunk)
|
||||
{
|
||||
gzFile *h;
|
||||
QFile *h;
|
||||
byte *buf;
|
||||
char base[32];
|
||||
int len;
|
||||
|
@ -442,8 +443,8 @@ byte *COM_LoadFile (char *path, int usehunk)
|
|||
#ifndef SERVERONLY
|
||||
Draw_BeginDisc ();
|
||||
#endif
|
||||
gzread (h, buf, len);
|
||||
gzclose (h);
|
||||
Qread (h, buf, len);
|
||||
Qclose (h);
|
||||
#ifndef SERVERONLY
|
||||
Draw_EndDisc ();
|
||||
#endif
|
||||
|
|
|
@ -25,11 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define _QUAKEFS_H
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAS_ZLIB
|
||||
#include <zlib.h>
|
||||
#else
|
||||
#include "nozip.h"
|
||||
#endif
|
||||
#include "quakeio.h"
|
||||
|
||||
//============================================================================
|
||||
|
||||
|
@ -41,8 +37,8 @@ struct cache_user_s;
|
|||
extern char com_gamedir[MAX_OSPATH];
|
||||
|
||||
void COM_WriteFile (char *filename, void *data, int len);
|
||||
int COM_FOpenFile (char *filename, gzFile **file);
|
||||
void COM_CloseFile (FILE *h);
|
||||
int COM_FOpenFile (char *filename, QFile **file);
|
||||
void COM_CloseFile (QFile *h);
|
||||
|
||||
byte *COM_LoadStackFile (char *path, void *buffer, int bufsize);
|
||||
byte *COM_LoadTempFile (char *path);
|
||||
|
|
|
@ -267,11 +267,7 @@ void R_StoreEfrags (efrag_t **ppefrag)
|
|||
if ((pent->visframe != r_framecount) &&
|
||||
(cl_numvisedicts < MAX_VISEDICTS))
|
||||
{
|
||||
#ifdef QUAKEWORLD
|
||||
cl_visedicts[cl_numvisedicts++] = *pent;
|
||||
#else
|
||||
cl_visedicts[cl_numvisedicts++] = pent;
|
||||
#endif
|
||||
|
||||
// mark that we've recorded this entity for this frame
|
||||
pent->visframe = r_framecount;
|
||||
|
|
|
@ -597,11 +597,8 @@ void R_DrawEntitiesOnList (void)
|
|||
|
||||
for (i=0 ; i<cl_numvisedicts ; i++)
|
||||
{
|
||||
#ifdef QUAKEWORLD
|
||||
currententity = &cl_visedicts[i];
|
||||
#else
|
||||
currententity = cl_visedicts[i];
|
||||
|
||||
#ifdef UQUAKE
|
||||
if (currententity == &cl_entities[cl.playernum + 1])
|
||||
continue; // don't draw the player
|
||||
#endif // QUAKEWORLD
|
||||
|
@ -827,11 +824,7 @@ void R_DrawBEntitiesOnList (void)
|
|||
|
||||
for (i=0 ; i<cl_numvisedicts ; i++)
|
||||
{
|
||||
#ifdef QUAKEWORLD
|
||||
currententity = &cl_visedicts[i];
|
||||
#else
|
||||
currententity = cl_visedicts[i];
|
||||
#endif // QUAKEWORLD
|
||||
|
||||
switch (currententity->model->type)
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ cvar_t registered = {"registered", "0"};
|
|||
void
|
||||
register_check ( void ) {
|
||||
|
||||
gzFile *h;
|
||||
QFile *h;
|
||||
|
||||
Cvar_RegisterVariable (®istered);
|
||||
|
||||
|
@ -52,6 +52,6 @@ register_check ( void ) {
|
|||
|
||||
if (h) {
|
||||
Cvar_Set ("registered", "1");
|
||||
gzclose (h);
|
||||
Qclose (h);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,8 @@ QW_NET_SRC = net_udp.c net_com.c mdfour.c
|
|||
# Common source files
|
||||
|
||||
MISC_SRC = common.c crc.c cvar.c cmd.c mathlib.c register_check.c \
|
||||
wad.c zone.c cvars.c qendian.c lib_replace.c quakefs.c qargs.c
|
||||
wad.c zone.c cvars.c qendian.c lib_replace.c quakefs.c \
|
||||
quakeio.c qargs.c
|
||||
|
||||
# GL renderer source
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ void CL_StopPlayback (void)
|
|||
if (!cls.demoplayback)
|
||||
return;
|
||||
|
||||
gzclose (cls.demofile);
|
||||
Qclose (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);
|
||||
gzwrite (cls.demofile, &fl, sizeof(fl));
|
||||
Qwrite (cls.demofile, &fl, sizeof(fl));
|
||||
|
||||
c = dem_cmd;
|
||||
gzwrite (cls.demofile, &c, sizeof(c));
|
||||
Qwrite (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);
|
||||
|
||||
gzwrite(cls.demofile, &cmd, sizeof(cmd));
|
||||
Qwrite(cls.demofile, &cmd, sizeof(cmd));
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
fl = LittleFloat (cl.viewangles[i]);
|
||||
gzwrite (cls.demofile, &fl, 4);
|
||||
Qwrite (cls.demofile, &fl, 4);
|
||||
}
|
||||
|
||||
gzflush (cls.demofile, Z_SYNC_FLUSH);
|
||||
Qflush (cls.demofile);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -128,16 +128,16 @@ void CL_WriteDemoMessage (sizebuf_t *msg)
|
|||
return;
|
||||
|
||||
fl = LittleFloat((float)realtime);
|
||||
gzwrite (cls.demofile, &fl, sizeof(fl));
|
||||
Qwrite (cls.demofile, &fl, sizeof(fl));
|
||||
|
||||
c = dem_read;
|
||||
gzwrite (cls.demofile, &c, sizeof(c));
|
||||
Qwrite (cls.demofile, &c, sizeof(c));
|
||||
|
||||
len = LittleLong (msg->cursize);
|
||||
gzwrite (cls.demofile, &len, 4);
|
||||
gzwrite (cls.demofile, msg->data, msg->cursize);
|
||||
Qwrite (cls.demofile, &len, 4);
|
||||
Qwrite (cls.demofile, msg->data, msg->cursize);
|
||||
|
||||
gzflush (cls.demofile, Z_SYNC_FLUSH);
|
||||
Qflush (cls.demofile);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -156,7 +156,7 @@ qboolean CL_GetDemoMessage (void)
|
|||
usercmd_t *pcmd;
|
||||
|
||||
// read the time from the packet
|
||||
gzread(cls.demofile, &demotime, sizeof(demotime));
|
||||
Qread(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
|
||||
gzseek(cls.demofile, gztell(cls.demofile) - sizeof(demotime),
|
||||
Qseek(cls.demofile, Qtell(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
|
||||
gzseek(cls.demofile, gztell(cls.demofile) - sizeof(demotime),
|
||||
Qseek(cls.demofile, Qtell(cls.demofile) - sizeof(demotime),
|
||||
SEEK_SET);
|
||||
return 0;
|
||||
} else if (realtime < demotime) {
|
||||
// rewind back to time
|
||||
gzseek(cls.demofile, gztell(cls.demofile) - sizeof(demotime),
|
||||
Qseek(cls.demofile, Qtell(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
|
||||
gzread (cls.demofile, &c, sizeof(c));
|
||||
Qread (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 = gzread (cls.demofile, pcmd, sizeof(*pcmd));
|
||||
r = Qread (cls.demofile, pcmd, sizeof(*pcmd));
|
||||
if (r != sizeof(*pcmd))
|
||||
{
|
||||
CL_StopPlayback ();
|
||||
|
@ -220,19 +220,19 @@ qboolean CL_GetDemoMessage (void)
|
|||
cls.netchan.outgoing_sequence++;
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
r = gzread (cls.demofile, &f, 4);
|
||||
r = Qread (cls.demofile, &f, 4);
|
||||
cl.viewangles[i] = LittleFloat (f);
|
||||
}
|
||||
break;
|
||||
|
||||
case dem_read:
|
||||
// get the next message
|
||||
gzread (cls.demofile, &net_message.cursize, 4);
|
||||
Qread (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 = gzread (cls.demofile, net_message.data, net_message.cursize);
|
||||
r = Qread (cls.demofile, net_message.data, net_message.cursize);
|
||||
if (r != net_message.cursize)
|
||||
{
|
||||
CL_StopPlayback ();
|
||||
|
@ -241,9 +241,9 @@ qboolean CL_GetDemoMessage (void)
|
|||
break;
|
||||
|
||||
case dem_set :
|
||||
gzread (cls.demofile, &i, 4);
|
||||
Qread (cls.demofile, &i, 4);
|
||||
cls.netchan.outgoing_sequence = LittleLong(i);
|
||||
gzread (cls.demofile, &i, 4);
|
||||
Qread (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
|
||||
gzclose (cls.demofile);
|
||||
Qclose (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);
|
||||
gzwrite (cls.demofile, &fl, sizeof(fl));
|
||||
Qwrite (cls.demofile, &fl, sizeof(fl));
|
||||
|
||||
c = dem_read;
|
||||
gzwrite (cls.demofile, &c, sizeof(c));
|
||||
Qwrite (cls.demofile, &c, sizeof(c));
|
||||
|
||||
len = LittleLong (msg->cursize + 8);
|
||||
gzwrite (cls.demofile, &len, 4);
|
||||
Qwrite (cls.demofile, &len, 4);
|
||||
|
||||
i = LittleLong(seq);
|
||||
gzwrite (cls.demofile, &i, 4);
|
||||
gzwrite (cls.demofile, &i, 4);
|
||||
Qwrite (cls.demofile, &i, 4);
|
||||
Qwrite (cls.demofile, &i, 4);
|
||||
|
||||
gzwrite (cls.demofile, msg->data, msg->cursize);
|
||||
Qwrite (cls.demofile, msg->data, msg->cursize);
|
||||
|
||||
gzflush (cls.demofile, Z_SYNC_FLUSH);
|
||||
Qflush (cls.demofile);
|
||||
}
|
||||
|
||||
|
||||
|
@ -357,17 +357,17 @@ void CL_WriteSetDemoMessage (void)
|
|||
return;
|
||||
|
||||
fl = LittleFloat((float)realtime);
|
||||
gzwrite (cls.demofile, &fl, sizeof(fl));
|
||||
Qwrite (cls.demofile, &fl, sizeof(fl));
|
||||
|
||||
c = dem_set;
|
||||
gzwrite (cls.demofile, &c, sizeof(c));
|
||||
Qwrite (cls.demofile, &c, sizeof(c));
|
||||
|
||||
len = LittleLong(cls.netchan.outgoing_sequence);
|
||||
gzwrite (cls.demofile, &len, 4);
|
||||
Qwrite (cls.demofile, &len, 4);
|
||||
len = LittleLong(cls.netchan.incoming_sequence);
|
||||
gzwrite (cls.demofile, &len, 4);
|
||||
Qwrite (cls.demofile, &len, 4);
|
||||
|
||||
gzflush (cls.demofile, Z_SYNC_FLUSH);
|
||||
Qflush (cls.demofile);
|
||||
}
|
||||
|
||||
|
||||
|
@ -416,7 +416,7 @@ void CL_Record_f (void)
|
|||
//
|
||||
COM_DefaultExtension (name, ".qwd");
|
||||
|
||||
cls.demofile = gzopen (name, "wb");
|
||||
cls.demofile = Qopen (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 = gzopen (name, "wb");
|
||||
cls.demofile = Qopen (name, "wb");
|
||||
if (!cls.demofile)
|
||||
{
|
||||
Con_Printf ("ERROR: couldn't open.\n");
|
||||
|
|
|
@ -168,7 +168,7 @@ to start a download from the server.
|
|||
*/
|
||||
qboolean CL_CheckOrDownloadFile (char *filename)
|
||||
{
|
||||
gzFile *f;
|
||||
QFile *f;
|
||||
|
||||
if (strstr (filename, ".."))
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ qboolean CL_CheckOrDownloadFile (char *filename)
|
|||
COM_FOpenFile (filename, &f);
|
||||
if (f)
|
||||
{ // it exists, no need to download
|
||||
gzclose (f);
|
||||
Qclose (f);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ void CL_ParseDownload (void)
|
|||
if (cls.download)
|
||||
{
|
||||
Con_Printf ("cls.download shouldn't have been set\n");
|
||||
fclose (cls.download);
|
||||
Qclose (cls.download);
|
||||
cls.download = NULL;
|
||||
}
|
||||
CL_RequestNextDownload ();
|
||||
|
@ -384,7 +384,7 @@ void CL_ParseDownload (void)
|
|||
|
||||
COM_CreatePath (name);
|
||||
|
||||
cls.download = fopen (name, "wb");
|
||||
cls.download = Qopen (name, "wb");
|
||||
if (!cls.download)
|
||||
{
|
||||
msg_readcount += size;
|
||||
|
@ -394,7 +394,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;
|
||||
|
||||
if (percent != 100)
|
||||
|
@ -423,7 +423,7 @@ void CL_ParseDownload (void)
|
|||
Con_Printf ("100%%\n");
|
||||
#endif
|
||||
|
||||
fclose (cls.download);
|
||||
Qclose (cls.download);
|
||||
|
||||
// rename the temp file to it's final name
|
||||
if (strcmp(cls.downloadtempname, cls.downloadname)) {
|
||||
|
|
|
@ -93,7 +93,7 @@ void R_ClearParticles (void)
|
|||
|
||||
void R_ReadPointFile_f (void)
|
||||
{
|
||||
gzFile *f;
|
||||
QFile *f;
|
||||
vec3_t org;
|
||||
int r;
|
||||
int c;
|
||||
|
@ -114,7 +114,7 @@ void R_ReadPointFile_f (void)
|
|||
c = 0;
|
||||
for ( ;; )
|
||||
{
|
||||
if (!gzgets(f,buf,sizeof(buf)))
|
||||
if (!Qgets(f,buf,sizeof(buf)))
|
||||
break;
|
||||
r = sscanf (buf,"%f %f %f\n", &org[0], &org[1], &org[2]);
|
||||
if (r != 3)
|
||||
|
@ -138,7 +138,7 @@ void R_ReadPointFile_f (void)
|
|||
VectorCopy (org, p->org);
|
||||
}
|
||||
|
||||
gzclose (f);
|
||||
Qclose (f);
|
||||
Con_Printf ("%i points read\n", c);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,8 @@ targets = $(SRVQUAKE)
|
|||
GENERAL_SRC = common.c crc.c cvar.c cmd.c mathlib.c wad.c zone.c \
|
||||
$(QW_NET_SRC) net_chan.c $(SRV_SRC) $(QW_SRV_SRC) \
|
||||
$(SRV_PR_SRC) $(QW_SRV_SYS_SRC) $(QW_GENERAL_SRC) \
|
||||
register_check.c qendian.c qargs.c quakefs.c lib_replace.c
|
||||
register_check.c qendian.c qargs.c quakefs.c quakeio.c \
|
||||
lib_replace.c
|
||||
ALL_QW_SRV_SRC = $(GENERAL_SRC) model.c
|
||||
# FIXME: add dos/win specifc source
|
||||
|
||||
|
|
|
@ -26,12 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAS_ZLIB
|
||||
#include <zlib.h>
|
||||
#else
|
||||
#include "nozip.h"
|
||||
#endif
|
||||
|
||||
#include <progs.h>
|
||||
|
||||
#define QW_SERVER
|
||||
|
@ -183,7 +177,7 @@ typedef struct client_s
|
|||
|
||||
client_frame_t frames[UPDATE_BACKUP]; // updates can be deltad from here
|
||||
|
||||
gzFile *download; // file being downloaded
|
||||
QFile *download; // file being downloaded
|
||||
int downloadsize; // total bytes
|
||||
int downloadcount; // bytes sent
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ void SV_Map_f (void)
|
|||
{
|
||||
char level[MAX_QPATH];
|
||||
char expanded[MAX_QPATH];
|
||||
gzFile *f;
|
||||
QFile *f;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
|
|
|
@ -156,7 +156,8 @@ UQ_NET_SRC = net_dgrm.c net_loop.c net_main.c net_vcr.c $(NET_SRC)
|
|||
# Common source files
|
||||
|
||||
MISC_SRC = common.c crc.c cvar.c cmd.c mathlib.c register_check.c \
|
||||
wad.c zone.c cvars.c lib_replace.c qendian.c quakefs.c
|
||||
wad.c zone.c cvars.c lib_replace.c qendian.c quakefs.c \
|
||||
quakeio.c
|
||||
|
||||
# GL renderer source
|
||||
|
||||
|
|
783
uquake/cl_main.c
783
uquake/cl_main.c
|
@ -1,783 +0,0 @@
|
|||
/*
|
||||
cl_main.c - client main loop
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
Portions Copyright (C) 1999,2000 Nelson Rush.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <quakedef.h>
|
||||
#include <qtypes.h>
|
||||
#include <qstructs.h>
|
||||
#include <client.h>
|
||||
#include <sound.h>
|
||||
#include <common.h>
|
||||
#include <net.h>
|
||||
#include <console.h>
|
||||
#include <screen.h>
|
||||
#include <mathlib.h>
|
||||
#include <cmd.h>
|
||||
#include <protocol.h>
|
||||
#include <cvar.h>
|
||||
#include <input.h>
|
||||
#include <zone.h>
|
||||
#include <client.h>
|
||||
#include <server.h>
|
||||
|
||||
// we need to declare some mouse variables here, because the menu system
|
||||
// references them even when on a unix system.
|
||||
|
||||
// these two are not intended to be set directly
|
||||
cvar_t cl_name = {"_cl_name", "player", true};
|
||||
cvar_t cl_color = {"_cl_color", "0", true};
|
||||
|
||||
cvar_t cl_shownet = {"cl_shownet","0"}; // can be 0, 1, or 2
|
||||
cvar_t cl_nolerp = {"cl_nolerp","0"};
|
||||
|
||||
cvar_t cl_sbar = {"cl_sbar", "1", true};
|
||||
cvar_t cl_hudswap = {"cl_hudswap", "1", true};
|
||||
|
||||
cvar_t lookspring = {"lookspring","0", true};
|
||||
cvar_t lookstrafe = {"lookstrafe","0", true};
|
||||
cvar_t sensitivity = {"sensitivity","3", true};
|
||||
|
||||
cvar_t m_pitch = {"m_pitch","0.022", true};
|
||||
cvar_t m_yaw = {"m_yaw","0.022", true};
|
||||
cvar_t m_forward = {"m_forward","1", true};
|
||||
cvar_t m_side = {"m_side","0.8", true};
|
||||
|
||||
|
||||
client_static_t cls;
|
||||
client_state_t cl;
|
||||
// FIXME: put these on hunk?
|
||||
efrag_t cl_efrags[MAX_EFRAGS];
|
||||
entity_t cl_entities[MAX_EDICTS];
|
||||
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
||||
lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
||||
dlight_t cl_dlights[MAX_DLIGHTS];
|
||||
|
||||
int cl_numvisedicts;
|
||||
entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_ClearState
|
||||
|
||||
=====================
|
||||
*/
|
||||
void CL_ClearState (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!sv.active)
|
||||
Host_ClearMemory ();
|
||||
|
||||
// wipe the entire cl structure
|
||||
memset (&cl, 0, sizeof(cl));
|
||||
|
||||
SZ_Clear (&cls.netchan.message);
|
||||
|
||||
// clear other arrays
|
||||
memset (cl_efrags, 0, sizeof(cl_efrags));
|
||||
memset (cl_entities, 0, sizeof(cl_entities));
|
||||
memset (cl_dlights, 0, sizeof(cl_dlights));
|
||||
memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
|
||||
memset (cl_temp_entities, 0, sizeof(cl_temp_entities));
|
||||
CL_ClearTEnts ();
|
||||
|
||||
//
|
||||
// allocate the efrags and chain together into a free list
|
||||
//
|
||||
cl.free_efrags = cl_efrags;
|
||||
for (i=0 ; i<MAX_EFRAGS-1 ; i++)
|
||||
cl.free_efrags[i].entnext = &cl.free_efrags[i+1];
|
||||
cl.free_efrags[i].entnext = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_Disconnect
|
||||
|
||||
Sends a disconnect message to the server
|
||||
This is also called on Host_Error, so it shouldn't cause any errors
|
||||
=====================
|
||||
*/
|
||||
void CL_Disconnect (void)
|
||||
{
|
||||
// stop sounds (especially looping!)
|
||||
S_StopAllSounds (true);
|
||||
|
||||
// bring the console down and fade the colors back to normal
|
||||
// SCR_BringDownConsole ();
|
||||
|
||||
// if running a local server, shut it down
|
||||
if (cls.demoplayback)
|
||||
CL_StopPlayback ();
|
||||
else if (cls.state >= ca_connected)
|
||||
{
|
||||
if (cls.demorecording)
|
||||
CL_Stop_f ();
|
||||
|
||||
Con_DPrintf ("Sending clc_disconnect\n");
|
||||
SZ_Clear (&cls.netchan.message);
|
||||
MSG_WriteByte (&cls.netchan.message, clc_disconnect);
|
||||
NET_SendUnreliableMessage (cls.netcon, &cls.netchan.message);
|
||||
SZ_Clear (&cls.netchan.message);
|
||||
NET_Close (cls.netcon);
|
||||
|
||||
cls.state = ca_disconnected;
|
||||
if (sv.active)
|
||||
Host_ShutdownServer(false);
|
||||
}
|
||||
|
||||
cls.demoplayback = cls.timedemo = false;
|
||||
cls.signon = 0;
|
||||
}
|
||||
|
||||
void CL_Disconnect_f (void)
|
||||
{
|
||||
CL_Disconnect ();
|
||||
if (sv.active)
|
||||
Host_ShutdownServer (false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_EstablishConnection
|
||||
|
||||
Host should be either "local" or a net address to be passed on
|
||||
=====================
|
||||
*/
|
||||
void CL_EstablishConnection (char *host)
|
||||
{
|
||||
if (cls.state == ca_dedicated)
|
||||
return;
|
||||
|
||||
if (cls.demoplayback)
|
||||
return;
|
||||
|
||||
CL_Disconnect ();
|
||||
|
||||
cls.netcon = NET_Connect (host);
|
||||
if (!cls.netcon)
|
||||
Host_Error ("CL_Connect: connect failed\n");
|
||||
Con_DPrintf ("CL_EstablishConnection: connected to %s\n", host);
|
||||
|
||||
cls.demonum = -1; // not in the demo loop now
|
||||
cls.state = ca_connected;
|
||||
cls.signon = 0; // need all the signon messages before playing
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_SignonReply
|
||||
|
||||
An svc_signonnum has been received, perform a client side setup
|
||||
=====================
|
||||
*/
|
||||
void CL_SignonReply (void)
|
||||
{
|
||||
char str[8192];
|
||||
|
||||
Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
|
||||
|
||||
switch (cls.signon)
|
||||
{
|
||||
case 1:
|
||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.netchan.message, "prespawn");
|
||||
cls.state = ca_onserver;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.netchan.message, va("name \"%s\"\n", cl_name.string));
|
||||
|
||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.netchan.message, va("color %i %i\n", ((int)cl_color.value)>>4, ((int)cl_color.value)&15));
|
||||
|
||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||
snprintf(str, sizeof(str), "spawn %s", cls.spawnparms);
|
||||
MSG_WriteString (&cls.netchan.message, str);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
||||
MSG_WriteString (&cls.netchan.message, "begin");
|
||||
Cache_Report (); // print remaining memory
|
||||
break;
|
||||
|
||||
case 4:
|
||||
SCR_EndLoadingPlaque (); // allow normal screen updates
|
||||
cls.state = ca_active;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_NextDemo
|
||||
|
||||
Called to play the next demo in the demo loop
|
||||
=====================
|
||||
*/
|
||||
void CL_NextDemo (void)
|
||||
{
|
||||
char str[1024];
|
||||
|
||||
if (cls.demonum == -1)
|
||||
return; // don't play demos
|
||||
|
||||
SCR_BeginLoadingPlaque ();
|
||||
|
||||
if (!cls.demos[cls.demonum][0] || cls.demonum == MAX_DEMOS)
|
||||
{
|
||||
cls.demonum = 0;
|
||||
if (!cls.demos[cls.demonum][0])
|
||||
{
|
||||
Con_Printf ("No demos listed with startdemos\n");
|
||||
cls.demonum = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(str, sizeof(str),"playdemo %s\n", cls.demos[cls.demonum]);
|
||||
Cbuf_InsertText (str);
|
||||
cls.demonum++;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
CL_PrintEntities_f
|
||||
==============
|
||||
*/
|
||||
void CL_PrintEntities_f (void)
|
||||
{
|
||||
entity_t *ent;
|
||||
int i;
|
||||
|
||||
for (i=0,ent=cl_entities ; i<cl.num_entities ; i++,ent++)
|
||||
{
|
||||
Con_Printf ("%3i:",i);
|
||||
if (!ent->model)
|
||||
{
|
||||
Con_Printf ("EMPTY\n");
|
||||
continue;
|
||||
}
|
||||
Con_Printf ("%s:%2i (%5.1f,%5.1f,%5.1f) [%5.1f %5.1f %5.1f]\n"
|
||||
,ent->model->name,ent->frame, ent->origin[0], ent->origin[1], ent->origin[2], ent->angles[0], ent->angles[1], ent->angles[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
SetPal
|
||||
|
||||
Debugging tool, just flashes the screen
|
||||
===============
|
||||
*/
|
||||
void SetPal (int i)
|
||||
{
|
||||
#if 0
|
||||
static int old;
|
||||
byte pal[768];
|
||||
int c;
|
||||
|
||||
if (i == old)
|
||||
return;
|
||||
old = i;
|
||||
|
||||
if (i==0)
|
||||
VID_SetPalette (host_basepal);
|
||||
else if (i==1)
|
||||
{
|
||||
for (c=0 ; c<768 ; c+=3)
|
||||
{
|
||||
pal[c] = 0;
|
||||
pal[c+1] = 255;
|
||||
pal[c+2] = 0;
|
||||
}
|
||||
VID_SetPalette (pal);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (c=0 ; c<768 ; c+=3)
|
||||
{
|
||||
pal[c] = 0;
|
||||
pal[c+1] = 0;
|
||||
pal[c+2] = 255;
|
||||
}
|
||||
VID_SetPalette (pal);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_AllocDlight
|
||||
|
||||
===============
|
||||
*/
|
||||
dlight_t *CL_AllocDlight (int key)
|
||||
{
|
||||
int i;
|
||||
dlight_t *dl;
|
||||
|
||||
// first look for an exact key match
|
||||
if (key)
|
||||
{
|
||||
dl = cl_dlights;
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
|
||||
{
|
||||
if (dl->key == key)
|
||||
{
|
||||
memset (dl, 0, sizeof(*dl));
|
||||
dl->key = key;
|
||||
return dl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// then look for anything else
|
||||
dl = cl_dlights;
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
|
||||
{
|
||||
if (dl->die < cl.time)
|
||||
{
|
||||
memset (dl, 0, sizeof(*dl));
|
||||
dl->key = key;
|
||||
return dl;
|
||||
}
|
||||
}
|
||||
|
||||
dl = &cl_dlights[0];
|
||||
memset (dl, 0, sizeof(*dl));
|
||||
dl->key = key;
|
||||
return dl;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_DecayLights
|
||||
|
||||
===============
|
||||
*/
|
||||
void CL_DecayLights (void)
|
||||
{
|
||||
int i;
|
||||
dlight_t *dl;
|
||||
float time;
|
||||
|
||||
time = cl.time - cl.oldtime;
|
||||
|
||||
dl = cl_dlights;
|
||||
for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
|
||||
{
|
||||
if (dl->die < cl.time || !dl->radius)
|
||||
continue;
|
||||
|
||||
dl->radius -= time*dl->decay;
|
||||
if (dl->radius < 0)
|
||||
dl->radius = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_LerpPoint
|
||||
|
||||
Determines the fraction between the last two messages that the objects
|
||||
should be put at.
|
||||
===============
|
||||
*/
|
||||
float CL_LerpPoint (void)
|
||||
{
|
||||
float f, frac;
|
||||
|
||||
f = cl.mtime[0] - cl.mtime[1];
|
||||
|
||||
if (!f || cl_nolerp.value || cls.timedemo || sv.active)
|
||||
{
|
||||
cl.time = cl.mtime[0];
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (f > 0.1)
|
||||
{ // dropped packet, or start of demo
|
||||
cl.mtime[1] = cl.mtime[0] - 0.1;
|
||||
f = 0.1;
|
||||
}
|
||||
frac = (cl.time - cl.mtime[1]) / f;
|
||||
//Con_Printf ("frac: %f\n",frac);
|
||||
if (frac < 0)
|
||||
{
|
||||
if (frac < -0.01)
|
||||
{
|
||||
SetPal(1);
|
||||
cl.time = cl.mtime[1];
|
||||
// Con_Printf ("low frac\n");
|
||||
}
|
||||
frac = 0;
|
||||
}
|
||||
else if (frac > 1)
|
||||
{
|
||||
if (frac > 1.01)
|
||||
{
|
||||
SetPal(2);
|
||||
cl.time = cl.mtime[0];
|
||||
// Con_Printf ("high frac\n");
|
||||
}
|
||||
frac = 1;
|
||||
}
|
||||
else
|
||||
SetPal(0);
|
||||
|
||||
return frac;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_RelinkEntities
|
||||
===============
|
||||
*/
|
||||
void CL_RelinkEntities (void)
|
||||
{
|
||||
entity_t *ent;
|
||||
int i, j;
|
||||
float frac, f, d;
|
||||
vec3_t delta;
|
||||
float bobjrotate;
|
||||
vec3_t oldorg;
|
||||
dlight_t *dl;
|
||||
|
||||
// determine partial update time
|
||||
frac = CL_LerpPoint ();
|
||||
|
||||
cl_numvisedicts = 0;
|
||||
|
||||
//
|
||||
// interpolate player info
|
||||
//
|
||||
for (i=0 ; i<3 ; i++)
|
||||
cl.velocity[i] = cl.mvelocity[1][i] +
|
||||
frac * (cl.mvelocity[0][i] - cl.mvelocity[1][i]);
|
||||
|
||||
if (cls.demoplayback)
|
||||
{
|
||||
// interpolate the angles
|
||||
for (j=0 ; j<3 ; j++)
|
||||
{
|
||||
d = cl.mviewangles[0][j] - cl.mviewangles[1][j];
|
||||
if (d > 180)
|
||||
d -= 360;
|
||||
else if (d < -180)
|
||||
d += 360;
|
||||
cl.viewangles[j] = cl.mviewangles[1][j] + frac*d;
|
||||
}
|
||||
}
|
||||
|
||||
bobjrotate = anglemod(100*cl.time);
|
||||
|
||||
// start on the entity after the world
|
||||
for (i=1,ent=cl_entities+1 ; i<cl.num_entities ; i++,ent++)
|
||||
{
|
||||
if (!ent->model)
|
||||
{ // empty slot
|
||||
if (ent->forcelink)
|
||||
R_RemoveEfrags (ent); // just became empty
|
||||
continue;
|
||||
}
|
||||
|
||||
// if the object wasn't included in the last packet, remove it
|
||||
if (ent->msgtime != cl.mtime[0])
|
||||
{
|
||||
ent->model = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
VectorCopy (ent->origin, oldorg);
|
||||
|
||||
if (ent->forcelink)
|
||||
{ // the entity was not updated in the last message
|
||||
// so move to the final spot
|
||||
VectorCopy (ent->msg_origins[0], ent->origin);
|
||||
VectorCopy (ent->msg_angles[0], ent->angles);
|
||||
}
|
||||
else
|
||||
{ // if the delta is large, assume a teleport and don't lerp
|
||||
f = frac;
|
||||
for (j=0 ; j<3 ; j++)
|
||||
{
|
||||
delta[j] = ent->msg_origins[0][j] - ent->msg_origins[1][j];
|
||||
if (delta[j] > 100 || delta[j] < -100)
|
||||
f = 1; // assume a teleportation, not a motion
|
||||
}
|
||||
|
||||
// interpolate the origin and angles
|
||||
for (j=0 ; j<3 ; j++)
|
||||
{
|
||||
ent->origin[j] = ent->msg_origins[1][j] + f*delta[j];
|
||||
|
||||
d = ent->msg_angles[0][j] - ent->msg_angles[1][j];
|
||||
if (d > 180)
|
||||
d -= 360;
|
||||
else if (d < -180)
|
||||
d += 360;
|
||||
ent->angles[j] = ent->msg_angles[1][j] + f*d;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// rotate binary objects locally
|
||||
if (ent->model->flags & EF_ROTATE)
|
||||
ent->angles[1] = bobjrotate;
|
||||
|
||||
if (ent->effects & EF_BRIGHTFIELD)
|
||||
R_EntityParticles (ent);
|
||||
#ifdef QUAKE2
|
||||
if (ent->effects & EF_DARKFIELD)
|
||||
R_DarkFieldParticles (ent);
|
||||
#endif
|
||||
if (ent->effects & EF_MUZZLEFLASH)
|
||||
{
|
||||
vec3_t fv, rv, uv;
|
||||
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
dl->origin[2] += 16;
|
||||
AngleVectors (ent->angles, fv, rv, uv);
|
||||
|
||||
VectorMA (dl->origin, 18, fv, dl->origin);
|
||||
dl->radius = 200 + (rand()&31);
|
||||
dl->minlight = 32;
|
||||
dl->die = cl.time + 0.1;
|
||||
}
|
||||
if (ent->effects & EF_BRIGHTLIGHT)
|
||||
{
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
dl->origin[2] += 16;
|
||||
dl->radius = 400 + (rand()&31);
|
||||
dl->die = cl.time + 0.001;
|
||||
}
|
||||
if (ent->effects & EF_DIMLIGHT)
|
||||
{
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
dl->radius = 200 + (rand()&31);
|
||||
dl->die = cl.time + 0.001;
|
||||
}
|
||||
#ifdef QUAKE2
|
||||
if (ent->effects & EF_DARKLIGHT)
|
||||
{
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
dl->radius = 200.0 + (rand()&31);
|
||||
dl->die = cl.time + 0.001;
|
||||
dl->dark = true;
|
||||
}
|
||||
if (ent->effects & EF_LIGHT)
|
||||
{
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
dl->radius = 200;
|
||||
dl->die = cl.time + 0.001;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ent->model->flags & EF_GIB)
|
||||
R_RocketTrail (oldorg, ent->origin, 2);
|
||||
else if (ent->model->flags & EF_ZOMGIB)
|
||||
R_RocketTrail (oldorg, ent->origin, 4);
|
||||
else if (ent->model->flags & EF_TRACER)
|
||||
R_RocketTrail (oldorg, ent->origin, 3);
|
||||
else if (ent->model->flags & EF_TRACER2)
|
||||
R_RocketTrail (oldorg, ent->origin, 5);
|
||||
else if (ent->model->flags & EF_ROCKET)
|
||||
{
|
||||
R_RocketTrail (oldorg, ent->origin, 0);
|
||||
dl = CL_AllocDlight (i);
|
||||
VectorCopy (ent->origin, dl->origin);
|
||||
dl->radius = 200;
|
||||
dl->die = cl.time + 0.01;
|
||||
}
|
||||
else if (ent->model->flags & EF_GRENADE)
|
||||
R_RocketTrail (oldorg, ent->origin, 1);
|
||||
else if (ent->model->flags & EF_TRACER3)
|
||||
R_RocketTrail (oldorg, ent->origin, 6);
|
||||
|
||||
ent->forcelink = false;
|
||||
|
||||
if (i == cl.playernum + 1 && !cl_chasecam.value)
|
||||
continue;
|
||||
|
||||
#ifdef QUAKE2
|
||||
if ( ent->effects & EF_NODRAW )
|
||||
continue;
|
||||
#endif
|
||||
if (cl_numvisedicts < MAX_VISEDICTS)
|
||||
{
|
||||
cl_visedicts[cl_numvisedicts] = ent;
|
||||
cl_numvisedicts++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_ReadFromServer
|
||||
|
||||
Read all incoming data from the server
|
||||
===============
|
||||
*/
|
||||
int CL_ReadFromServer (void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
cl.oldtime = cl.time;
|
||||
cl.time += host_frametime;
|
||||
|
||||
do
|
||||
{
|
||||
ret = CL_GetMessage ();
|
||||
if (ret == -1)
|
||||
Host_Error ("CL_ReadFromServer: lost server connection");
|
||||
if (!ret)
|
||||
break;
|
||||
|
||||
cl.last_received_message = realtime;
|
||||
CL_ParseServerMessage ();
|
||||
} while (ret && cls.state >= ca_connected);
|
||||
|
||||
if (cl_shownet.value)
|
||||
Con_Printf ("\n");
|
||||
|
||||
CL_RelinkEntities ();
|
||||
CL_UpdateTEnts ();
|
||||
|
||||
//
|
||||
// bring the links up to date
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_SendCmd
|
||||
=================
|
||||
*/
|
||||
void CL_SendCmd (void)
|
||||
{
|
||||
usercmd_t cmd;
|
||||
|
||||
if (cls.state < ca_connected)
|
||||
return;
|
||||
|
||||
if (cls.signon == SIGNONS)
|
||||
{
|
||||
// get basic movement from keyboard
|
||||
CL_BaseMove (&cmd);
|
||||
|
||||
// allow mice or other external controllers to add to the move
|
||||
IN_Move (&cmd);
|
||||
|
||||
// send the unreliable message
|
||||
CL_SendMove (&cmd);
|
||||
|
||||
}
|
||||
|
||||
if (cls.demoplayback)
|
||||
{
|
||||
SZ_Clear (&cls.netchan.message);
|
||||
return;
|
||||
}
|
||||
|
||||
// send the reliable message
|
||||
if (!cls.netchan.message.cursize)
|
||||
return; // no message at all
|
||||
|
||||
if (!NET_CanSendMessage (cls.netcon))
|
||||
{
|
||||
Con_DPrintf ("CL_WriteToServer: can't send\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (NET_SendMessage (cls.netcon, &cls.netchan.message) == -1)
|
||||
Host_Error ("CL_WriteToServer: lost server connection");
|
||||
|
||||
SZ_Clear (&cls.netchan.message);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_Init
|
||||
=================
|
||||
*/
|
||||
void CL_Init (void)
|
||||
{
|
||||
SZ_Alloc (&cls.netchan.message, 1024);
|
||||
|
||||
CL_InitInput ();
|
||||
CL_InitTEnts ();
|
||||
|
||||
//
|
||||
// register our commands
|
||||
//
|
||||
Cvar_RegisterVariable (&cl_name);
|
||||
Cvar_RegisterVariable (&cl_color);
|
||||
Cvar_RegisterVariable (&cl_upspeed);
|
||||
Cvar_RegisterVariable (&cl_forwardspeed);
|
||||
Cvar_RegisterVariable (&cl_backspeed);
|
||||
Cvar_RegisterVariable (&cl_sidespeed);
|
||||
Cvar_RegisterVariable (&cl_movespeedkey);
|
||||
Cvar_RegisterVariable (&cl_yawspeed);
|
||||
Cvar_RegisterVariable (&cl_pitchspeed);
|
||||
Cvar_RegisterVariable (&cl_anglespeedkey);
|
||||
Cvar_RegisterVariable (&cl_shownet);
|
||||
Cvar_RegisterVariable (&cl_nolerp);
|
||||
|
||||
Cvar_RegisterVariable (&cl_sbar);
|
||||
Cvar_RegisterVariable (&cl_hudswap);
|
||||
|
||||
Cvar_RegisterVariable (&lookspring);
|
||||
Cvar_RegisterVariable (&lookstrafe);
|
||||
Cvar_RegisterVariable (&sensitivity);
|
||||
|
||||
Cvar_RegisterVariable (&m_pitch);
|
||||
Cvar_RegisterVariable (&m_yaw);
|
||||
Cvar_RegisterVariable (&m_forward);
|
||||
Cvar_RegisterVariable (&m_side);
|
||||
|
||||
// Cvar_RegisterVariable (&cl_autofire);
|
||||
|
||||
Cmd_AddCommand ("entities", CL_PrintEntities_f);
|
||||
Cmd_AddCommand ("disconnect", CL_Disconnect_f);
|
||||
Cmd_AddCommand ("record", CL_Record_f);
|
||||
Cmd_AddCommand ("stop", CL_Stop_f);
|
||||
Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
|
||||
Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
|
||||
}
|
||||
|
|
@ -277,13 +277,13 @@ Writes key bindings and archived cvars to config.cfg
|
|||
*/
|
||||
void Host_WriteConfiguration (void)
|
||||
{
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
|
||||
// dedicated servers initialize the host but don't parse and set the
|
||||
// config.cfg cvars
|
||||
if (host_initialized & !isDedicated)
|
||||
{
|
||||
f = fopen (va("%s/config.cfg",com_gamedir), "w");
|
||||
f = Qopen (va("%s/config.cfg",com_gamedir), "w");
|
||||
if (!f)
|
||||
{
|
||||
Con_Printf ("Couldn't write config.cfg.\n");
|
||||
|
@ -293,7 +293,7 @@ void Host_WriteConfiguration (void)
|
|||
Key_WriteBindings (f);
|
||||
Cvar_WriteVariables (f);
|
||||
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -483,7 +483,7 @@ Host_Savegame_f
|
|||
void Host_Savegame_f (void)
|
||||
{
|
||||
char name[256];
|
||||
FILE *f;
|
||||
QFile *f;
|
||||
int i;
|
||||
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
||||
|
||||
|
@ -533,30 +533,30 @@ void Host_Savegame_f (void)
|
|||
COM_DefaultExtension (name, ".sav");
|
||||
|
||||
Con_Printf ("Saving game to %s...\n", name);
|
||||
f = fopen (name, "w");
|
||||
f = Qopen (name, "w");
|
||||
if (!f)
|
||||
{
|
||||
Con_Printf ("ERROR: couldn't open.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf (f, "%i\n", SAVEGAME_VERSION);
|
||||
Qprintf (f, "%i\n", SAVEGAME_VERSION);
|
||||
Host_SavegameComment (comment);
|
||||
fprintf (f, "%s\n", comment);
|
||||
Qprintf (f, "%s\n", comment);
|
||||
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
|
||||
fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
||||
fprintf (f, "%d\n", current_skill);
|
||||
fprintf (f, "%s\n", sv.name);
|
||||
fprintf (f, "%f\n",sv.time);
|
||||
Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
|
||||
Qprintf (f, "%d\n", current_skill);
|
||||
Qprintf (f, "%s\n", sv.name);
|
||||
Qprintf (f, "%f\n",sv.time);
|
||||
|
||||
// write the light styles
|
||||
|
||||
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
|
||||
{
|
||||
if (sv.lightstyles[i])
|
||||
fprintf (f, "%s\n", sv.lightstyles[i]);
|
||||
Qprintf (f, "%s\n", sv.lightstyles[i]);
|
||||
else
|
||||
fprintf (f,"m\n");
|
||||
Qprintf (f,"m\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -564,9 +564,9 @@ void Host_Savegame_f (void)
|
|||
for (i=0 ; i<sv.num_edicts ; i++)
|
||||
{
|
||||
ED_Write (f, EDICT_NUM(i));
|
||||
fflush (f);
|
||||
Qflush (f);
|
||||
}
|
||||
fclose (f);
|
||||
Qclose (f);
|
||||
Con_Printf ("done.\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ void R_ClearParticles (void)
|
|||
|
||||
void R_ReadPointFile_f (void)
|
||||
{
|
||||
gzFile *f;
|
||||
QFile *f;
|
||||
vec3_t org;
|
||||
int r;
|
||||
int c;
|
||||
|
@ -221,7 +221,7 @@ void R_ReadPointFile_f (void)
|
|||
c = 0;
|
||||
for ( ;; )
|
||||
{
|
||||
if (!gzgets(f,buf,sizeof(buf)))
|
||||
if (!Qgets(f,buf,sizeof(buf)))
|
||||
break;
|
||||
r = sscanf (buf,"%f %f %f\n", &org[0], &org[1], &org[2]);
|
||||
if (r != 3)
|
||||
|
@ -245,7 +245,7 @@ void R_ReadPointFile_f (void)
|
|||
VectorCopy (org, p->org);
|
||||
}
|
||||
|
||||
gzclose (f);
|
||||
Qclose (f);
|
||||
Con_Printf ("%i points read\n", c);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <sys.h>
|
||||
#include <client.h>
|
||||
#include <server.h>
|
||||
#include <model.h>
|
||||
|
||||
entity_t *CL_EntityNum (int num);
|
||||
|
||||
|
|
Loading…
Reference in a new issue