whitespace and headers.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-08-29 02:12:57 +00:00
parent d87b164450
commit 2f5e0cf603
24 changed files with 619 additions and 901 deletions

View file

@ -32,6 +32,7 @@
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/mathlib.h" #include "QF/mathlib.h"
#include "client.h" #include "client.h"
#include "world.h" #include "world.h"
@ -43,11 +44,10 @@ cvar_t *chase_up;
cvar_t *chase_right; cvar_t *chase_right;
cvar_t *chase_active; cvar_t *chase_active;
vec3_t chase_pos;
vec3_t chase_angles; vec3_t chase_angles;
vec3_t chase_dest; vec3_t chase_dest;
vec3_t chase_dest_angles; vec3_t chase_dest_angles;
vec3_t chase_pos;
void void
@ -59,7 +59,6 @@ Chase_Init_Cvars (void)
chase_active = Cvar_Get ("chase_active", "0", CVAR_NONE, NULL, "None"); chase_active = Cvar_Get ("chase_active", "0", CVAR_NONE, NULL, "None");
} }
void void
Chase_Reset (void) Chase_Reset (void)
{ {
@ -67,7 +66,6 @@ Chase_Reset (void)
// start position 12 units behind head // start position 12 units behind head
} }
void void
TraceLine (vec3_t start, vec3_t end, vec3_t impact) TraceLine (vec3_t start, vec3_t end, vec3_t impact)
{ {
@ -79,7 +77,6 @@ TraceLine (vec3_t start, vec3_t end, vec3_t impact)
VectorCopy (trace.endpos, impact); VectorCopy (trace.endpos, impact);
} }
void void
Chase_Update (void) Chase_Update (void)
{ {
@ -88,7 +85,6 @@ Chase_Update (void)
vec3_t forward, up, right; vec3_t forward, up, right;
vec3_t dest, stop; vec3_t dest, stop;
// if can't see player, reset // if can't see player, reset
AngleVectors (cl.viewangles, forward, right, up); AngleVectors (cl.viewangles, forward, right, up);

View file

@ -36,12 +36,14 @@
# include <strings.h> # include <strings.h>
#endif #endif
#include "client.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/sizebuf.h" #include "QF/sizebuf.h"
#include "client.h"
/* /*
Cmd_ForwardToServer Cmd_ForwardToServer
@ -69,18 +71,18 @@ Cmd_ForwardToServer (void)
SZ_Print (&cls.message, "\n"); SZ_Print (&cls.message, "\n");
} }
void void
cl_Cmd_Init (void) cl_Cmd_Init (void)
{ {
// register our commands // register our commands
Cmd_AddCommand ("cmd", Cmd_ForwardToServer, "Send a command to the server.\n" Cmd_AddCommand ("cmd", Cmd_ForwardToServer, "Send a command to the "
"server.\n"
"Commands:\n" "Commands:\n"
"download - Same as the command.\n" "download - Same as the command.\n"
"kill - Same as the command.\n" "kill - Same as the command.\n"
"msg (value) - Same as the command.\n" "msg (value) - Same as the command.\n"
"prespawn (entity) (spot) - Find a spawn spot for the" "prespawn (entity) (spot) - Find a spawn spot for the "
" player entity.\n" "player entity.\n"
"spawn (entity) - Spawn the player entity.\n" "spawn (entity) - Spawn the player entity.\n"
"setinfo - Same as the command.\n" "setinfo - Same as the command.\n"
"serverinfo - Same as the command."); "serverinfo - Same as the command.");

View file

@ -38,13 +38,13 @@
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
#include "compat.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/input.h" #include "QF/input.h"
#include "QF/keys.h" #include "QF/keys.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "client.h" #include "client.h"
#include "compat.h"
#include "host.h" #include "host.h"
/* /*
@ -64,7 +64,6 @@
state bit 2 is edge triggered on the down to up transition state bit 2 is edge triggered on the down to up transition
*/ */
kbutton_t in_mlook, in_klook; kbutton_t in_mlook, in_klook;
kbutton_t in_left, in_right, in_forward, in_back; kbutton_t in_left, in_right, in_forward, in_back;
kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright; kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
@ -77,8 +76,8 @@ int in_impulse;
void void
KeyDown (kbutton_t *b) KeyDown (kbutton_t *b)
{ {
int k;
const char *c; const char *c;
int k;
c = Cmd_Argv (1); c = Cmd_Argv (1);
if (c[0]) if (c[0])
@ -107,8 +106,8 @@ KeyDown (kbutton_t *b)
void void
KeyUp (kbutton_t *b) KeyUp (kbutton_t *b)
{ {
int k;
const char *c; const char *c;
int k;
c = Cmd_Argv (1); c = Cmd_Argv (1);
if (c[0]) if (c[0])
@ -138,28 +137,24 @@ KeyUp (kbutton_t *b)
b->state |= 4; // impulse up b->state |= 4; // impulse up
} }
void void
IN_KLookDown (void) IN_KLookDown (void)
{ {
KeyDown (&in_klook); KeyDown (&in_klook);
} }
void void
IN_KLookUp (void) IN_KLookUp (void)
{ {
KeyUp (&in_klook); KeyUp (&in_klook);
} }
void void
IN_MLookDown (void) IN_MLookDown (void)
{ {
KeyDown (&in_mlook); KeyDown (&in_mlook);
} }
void void
IN_MLookUp (void) IN_MLookUp (void)
{ {
@ -168,49 +163,42 @@ IN_MLookUp (void)
V_StartPitchDrift (); V_StartPitchDrift ();
} }
void void
IN_UpDown (void) IN_UpDown (void)
{ {
KeyDown (&in_up); KeyDown (&in_up);
} }
void void
IN_UpUp (void) IN_UpUp (void)
{ {
KeyUp (&in_up); KeyUp (&in_up);
} }
void void
IN_DownDown (void) IN_DownDown (void)
{ {
KeyDown (&in_down); KeyDown (&in_down);
} }
void void
IN_DownUp (void) IN_DownUp (void)
{ {
KeyUp (&in_down); KeyUp (&in_down);
} }
void void
IN_LeftDown (void) IN_LeftDown (void)
{ {
KeyDown (&in_left); KeyDown (&in_left);
} }
void void
IN_LeftUp (void) IN_LeftUp (void)
{ {
KeyUp (&in_left); KeyUp (&in_left);
} }
void void
IN_RightDown (void) IN_RightDown (void)
{ {
@ -223,168 +211,144 @@ IN_RightUp (void)
KeyUp (&in_right); KeyUp (&in_right);
} }
void void
IN_ForwardDown (void) IN_ForwardDown (void)
{ {
KeyDown (&in_forward); KeyDown (&in_forward);
} }
void void
IN_ForwardUp (void) IN_ForwardUp (void)
{ {
KeyUp (&in_forward); KeyUp (&in_forward);
} }
void void
IN_BackDown (void) IN_BackDown (void)
{ {
KeyDown (&in_back); KeyDown (&in_back);
} }
void void
IN_BackUp (void) IN_BackUp (void)
{ {
KeyUp (&in_back); KeyUp (&in_back);
} }
void void
IN_LookupDown (void) IN_LookupDown (void)
{ {
KeyDown (&in_lookup); KeyDown (&in_lookup);
} }
void void
IN_LookupUp (void) IN_LookupUp (void)
{ {
KeyUp (&in_lookup); KeyUp (&in_lookup);
} }
void void
IN_LookdownDown (void) IN_LookdownDown (void)
{ {
KeyDown (&in_lookdown); KeyDown (&in_lookdown);
} }
void void
IN_LookdownUp (void) IN_LookdownUp (void)
{ {
KeyUp (&in_lookdown); KeyUp (&in_lookdown);
} }
void void
IN_MoveleftDown (void) IN_MoveleftDown (void)
{ {
KeyDown (&in_moveleft); KeyDown (&in_moveleft);
} }
void void
IN_MoveleftUp (void) IN_MoveleftUp (void)
{ {
KeyUp (&in_moveleft); KeyUp (&in_moveleft);
} }
void void
IN_MoverightDown (void) IN_MoverightDown (void)
{ {
KeyDown (&in_moveright); KeyDown (&in_moveright);
} }
void void
IN_MoverightUp (void) IN_MoverightUp (void)
{ {
KeyUp (&in_moveright); KeyUp (&in_moveright);
} }
void void
IN_SpeedDown (void) IN_SpeedDown (void)
{ {
KeyDown (&in_speed); KeyDown (&in_speed);
} }
void void
IN_SpeedUp (void) IN_SpeedUp (void)
{ {
KeyUp (&in_speed); KeyUp (&in_speed);
} }
void void
IN_StrafeDown (void) IN_StrafeDown (void)
{ {
KeyDown (&in_strafe); KeyDown (&in_strafe);
} }
void void
IN_StrafeUp (void) IN_StrafeUp (void)
{ {
KeyUp (&in_strafe); KeyUp (&in_strafe);
} }
void void
IN_AttackDown (void) IN_AttackDown (void)
{ {
KeyDown (&in_attack); KeyDown (&in_attack);
} }
void void
IN_AttackUp (void) IN_AttackUp (void)
{ {
KeyUp (&in_attack); KeyUp (&in_attack);
} }
void void
IN_UseDown (void) IN_UseDown (void)
{ {
KeyDown (&in_use); KeyDown (&in_use);
} }
void void
IN_UseUp (void) IN_UseUp (void)
{ {
KeyUp (&in_use); KeyUp (&in_use);
} }
void void
IN_JumpDown (void) IN_JumpDown (void)
{ {
KeyDown (&in_jump); KeyDown (&in_jump);
} }
void void
IN_JumpUp (void) IN_JumpUp (void)
{ {
KeyUp (&in_jump); KeyUp (&in_jump);
} }
void void
IN_Impulse (void) IN_Impulse (void)
{ {
in_impulse = atoi (Cmd_Argv (1)); in_impulse = atoi (Cmd_Argv (1));
} }
/* /*
CL_KeyState CL_KeyState
@ -434,9 +398,6 @@ CL_KeyState (kbutton_t *key)
return val; return val;
} }
//==========================================================================
cvar_t *cl_anglespeedkey; cvar_t *cl_anglespeedkey;
cvar_t *cl_backspeed; cvar_t *cl_backspeed;
cvar_t *cl_forwardspeed; cvar_t *cl_forwardspeed;
@ -446,7 +407,6 @@ cvar_t *cl_sidespeed;
cvar_t *cl_upspeed; cvar_t *cl_upspeed;
cvar_t *cl_yawspeed; cvar_t *cl_yawspeed;
/* /*
CL_AdjustAngles CL_AdjustAngles
@ -455,8 +415,7 @@ cvar_t *cl_yawspeed;
void void
CL_AdjustAngles (void) CL_AdjustAngles (void)
{ {
float speed; float speed, up, down;
float up, down;
if (in_speed.state & 1) if (in_speed.state & 1)
speed = host_frametime * cl_anglespeedkey->value; speed = host_frametime * cl_anglespeedkey->value;
@ -499,7 +458,6 @@ CL_AdjustAngles (void)
} }
/* /*
CL_BaseMove CL_BaseMove
@ -531,8 +489,7 @@ CL_BaseMove (usercmd_t *cmd)
cmd->forwardmove -= cl_backspeed->value * CL_KeyState (&in_back); cmd->forwardmove -= cl_backspeed->value * CL_KeyState (&in_back);
} }
// adjust for speed key // adjust for speed key
//
if (in_speed.state & 1) { if (in_speed.state & 1) {
cmd->forwardmove *= cl_movespeedkey->value; cmd->forwardmove *= cl_movespeedkey->value;
cmd->sidemove *= cl_movespeedkey->value; cmd->sidemove *= cl_movespeedkey->value;
@ -563,10 +520,9 @@ CL_BaseMove (usercmd_t *cmd)
void void
CL_SendMove (usercmd_t *cmd) CL_SendMove (usercmd_t *cmd)
{ {
int i;
int bits;
sizebuf_t buf;
byte data[128]; byte data[128];
int bits, i;
sizebuf_t buf;
buf.maxsize = 128; buf.maxsize = 128;
buf.cursize = 0; buf.cursize = 0;
@ -574,8 +530,7 @@ CL_SendMove (usercmd_t *cmd)
cl.cmd = *cmd; cl.cmd = *cmd;
// send the movement message // send the movement message
//
MSG_WriteByte (&buf, clc_move); MSG_WriteByte (&buf, clc_move);
MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times
@ -587,8 +542,7 @@ CL_SendMove (usercmd_t *cmd)
MSG_WriteShort (&buf, cmd->sidemove); MSG_WriteShort (&buf, cmd->sidemove);
MSG_WriteShort (&buf, cmd->upmove); MSG_WriteShort (&buf, cmd->upmove);
// send button bits // send button bits
//
bits = 0; bits = 0;
if (in_attack.state & 3) if (in_attack.state & 3)
@ -604,13 +558,12 @@ CL_SendMove (usercmd_t *cmd)
MSG_WriteByte (&buf, in_impulse); MSG_WriteByte (&buf, in_impulse);
in_impulse = 0; in_impulse = 0;
// deliver the message // deliver the message
//
if (cls.demoplayback) if (cls.demoplayback)
return; return;
// always dump the first two message, because it may contain leftover inputs // always dump the first two message, because it may contain leftover
// from the last level // inputs from the last level
if (++cl.movemessages <= 2) if (++cl.movemessages <= 2)
return; return;
@ -620,7 +573,6 @@ CL_SendMove (usercmd_t *cmd)
} }
} }
void void
CL_InitInput (void) CL_InitInput (void)
{ {

View file

@ -97,7 +97,6 @@ CL_Sbar_f (cvar_t *var)
r_lineadj = var->int_val ? sb_lines : 0; r_lineadj = var->int_val ? sb_lines : 0;
} }
void void
CL_InitCvars (void) CL_InitCvars (void)
{ {
@ -113,8 +112,7 @@ CL_InitCvars (void)
"inform when execing a command"); "inform when execing a command");
cl_name = Cvar_Get ("_cl_name", "player", CVAR_ARCHIVE, NULL, cl_name = Cvar_Get ("_cl_name", "player", CVAR_ARCHIVE, NULL,
"Player name"); "Player name");
cl_color = Cvar_Get ("_cl_color", "0", CVAR_ARCHIVE, NULL, cl_color = Cvar_Get ("_cl_color", "0", CVAR_ARCHIVE, NULL, "Player color");
"Player color");
cl_anglespeedkey = Cvar_Get ("cl_anglespeedkey", "1.5", CVAR_NONE, NULL, cl_anglespeedkey = Cvar_Get ("cl_anglespeedkey", "1.5", CVAR_NONE, NULL,
"turn `run' speed multiplier"); "turn `run' speed multiplier");
cl_backspeed = Cvar_Get ("cl_backspeed", "200", CVAR_ARCHIVE, NULL, cl_backspeed = Cvar_Get ("cl_backspeed", "200", CVAR_ARCHIVE, NULL,
@ -157,7 +155,6 @@ CL_InitCvars (void)
"display the current time"); "display the current time");
} }
void void
CL_ClearState (void) CL_ClearState (void)
{ {
@ -192,7 +189,6 @@ CL_ClearState (void)
} }
} }
/* /*
CL_StopCshifts CL_StopCshifts
@ -202,13 +198,13 @@ void
CL_StopCshifts (void) CL_StopCshifts (void)
{ {
int i; int i;
for (i = 0; i < NUM_CSHIFTS; i++) for (i = 0; i < NUM_CSHIFTS; i++)
cl.cshifts[i].percent = 0; cl.cshifts[i].percent = 0;
for (i = 0; i < MAX_CL_STATS; i++) for (i = 0; i < MAX_CL_STATS; i++)
cl.stats[i] = 0; cl.stats[i] = 0;
} }
/* /*
CL_Disconnect CL_Disconnect
@ -250,7 +246,6 @@ CL_Disconnect (void)
cls.signon = 0; cls.signon = 0;
} }
void void
CL_Disconnect_f (void) CL_Disconnect_f (void)
{ {
@ -259,7 +254,6 @@ CL_Disconnect_f (void)
Host_ShutdownServer (false); Host_ShutdownServer (false);
} }
/* /*
CL_EstablishConnection CL_EstablishConnection
@ -289,7 +283,6 @@ CL_EstablishConnection (const char *host)
game_target = IMT_DEFAULT; game_target = IMT_DEFAULT;
} }
/* /*
CL_SignonReply CL_SignonReply
@ -332,7 +325,6 @@ CL_SignonReply (void)
} }
} }
/* /*
CL_NextDemo CL_NextDemo
@ -360,7 +352,6 @@ CL_NextDemo (void)
cls.demonum++; cls.demonum++;
} }
void void
CL_PrintEntities_f (void) CL_PrintEntities_f (void)
{ {
@ -380,7 +371,6 @@ CL_PrintEntities_f (void)
} }
} }
/* /*
SetPal SetPal
@ -390,9 +380,9 @@ void
SetPal (int i) SetPal (int i)
{ {
#if 0 #if 0
static int old;
byte pal[768]; byte pal[768];
int c; int c;
static int old;
if (i == old) if (i == old)
return; return;
@ -418,7 +408,6 @@ SetPal (int i)
#endif #endif
} }
void void
CL_NewDlight (int key, float x, float y, float z, float radius, float time, CL_NewDlight (int key, float x, float y, float z, float radius, float time,
int type) int type)
@ -456,7 +445,6 @@ CL_NewDlight (int key, float x, float y, float z, float radius, float time,
} }
} }
/* /*
CL_LerpPoint CL_LerpPoint
@ -501,17 +489,15 @@ CL_LerpPoint (void)
return frac; return frac;
} }
void void
CL_RelinkEntities (void) CL_RelinkEntities (void)
{ {
entity_t **_ent; entity_t **_ent;
entity_t *ent; entity_t *ent;
int i, j;
float frac, f, d;
vec3_t delta;
float bobjrotate;
dlight_t *dl; dlight_t *dl;
float bobjrotate, frac, f, d;
int i, j;
vec3_t delta;
r_player_entity = &cl_entities[cl.viewentity]; r_player_entity = &cl_entities[cl.viewentity];
@ -654,7 +640,6 @@ CL_RelinkEntities (void)
} }
} }
/* /*
CL_ReadFromServer CL_ReadFromServer
@ -692,7 +677,6 @@ CL_ReadFromServer (void)
return 0; return 0;
} }
void void
CL_SendCmd (void) CL_SendCmd (void)
{ {
@ -728,7 +712,6 @@ CL_SendCmd (void)
SZ_Clear (&cls.message); SZ_Clear (&cls.message);
} }
void void
CL_SetState (cactive_t state) CL_SetState (cactive_t state)
{ {
@ -744,14 +727,12 @@ CL_SetState (cactive_t state)
} }
} }
void void
Force_CenterView_f (void) Force_CenterView_f (void)
{ {
cl.viewangles[PITCH] = 0; cl.viewangles[PITCH] = 0;
} }
void void
CL_Init (void) CL_Init (void)
{ {
@ -769,10 +750,8 @@ CL_Init (void)
Cmd_AddCommand ("playdemo", CL_PlayDemo_f, "No Description"); Cmd_AddCommand ("playdemo", CL_PlayDemo_f, "No Description");
Cmd_AddCommand ("timedemo", CL_TimeDemo_f, "No Description"); Cmd_AddCommand ("timedemo", CL_TimeDemo_f, "No Description");
Cmd_AddCommand ("maplist", COM_Maplist_f, "No Description"); Cmd_AddCommand ("maplist", COM_Maplist_f, "No Description");
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "force the view "
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "force the view to " "to be level");
"be level");
for (i = 0; i < MAX_STATIC_ENTITIES; i++) { for (i = 0; i < MAX_STATIC_ENTITIES; i++) {
cl_static_entities[i].baseline = &cl_static_entity_baselines[i]; cl_static_entities[i].baseline = &cl_static_entity_baselines[i];

View file

@ -119,17 +119,12 @@ CL_EntityNum (int num)
return &cl_entities[num]; return &cl_entities[num];
} }
void void
CL_ParseStartSoundPacket (void) CL_ParseStartSoundPacket (void)
{ {
vec3_t pos;
int channel, ent;
int sound_num;
int volume;
int field_mask;
float attenuation; float attenuation;
int i; int channel, ent, field_mask, sound_num, volume, i;
vec3_t pos;
field_mask = MSG_ReadByte (net_message); field_mask = MSG_ReadByte (net_message);
@ -159,7 +154,6 @@ CL_ParseStartSoundPacket (void)
volume / 255.0, attenuation); volume / 255.0, attenuation);
} }
/* /*
CL_KeepaliveMessage CL_KeepaliveMessage
@ -169,11 +163,11 @@ CL_ParseStartSoundPacket (void)
void void
CL_KeepaliveMessage (void) CL_KeepaliveMessage (void)
{ {
byte olddata[8192];
float time; float time;
static float lastmsg; static float lastmsg;
int ret; int ret;
sizebuf_t old; sizebuf_t old;
byte olddata[8192];
if (sv.active) if (sv.active)
return; // no need if server is local return; // no need if server is local
@ -182,7 +176,8 @@ CL_KeepaliveMessage (void)
// read messages from server, should just be nops // read messages from server, should just be nops
old = *net_message->message; old = *net_message->message;
memcpy (olddata, net_message->message->data, net_message->message->cursize); memcpy (olddata, net_message->message->data,
net_message->message->cursize);
do { do {
ret = CL_GetMessage (); ret = CL_GetMessage ();
@ -202,7 +197,8 @@ CL_KeepaliveMessage (void)
} while (ret); } while (ret);
*net_message->message = old; *net_message->message = old;
memcpy (net_message->message->data, olddata, net_message->message->cursize); memcpy (net_message->message->data, olddata,
net_message->message->cursize);
// check time // check time
time = Sys_DoubleTime (); time = Sys_DoubleTime ();
@ -218,18 +214,15 @@ CL_KeepaliveMessage (void)
SZ_Clear (&cls.message); SZ_Clear (&cls.message);
} }
struct model_s **snd_worldmodel = &cl.worldmodel; struct model_s **snd_worldmodel = &cl.worldmodel;
void void
CL_ParseServerInfo (void) CL_ParseServerInfo (void)
{ {
char *str;
int i;
int nummodels, numsounds;
char model_precache[MAX_MODELS][MAX_QPATH]; char model_precache[MAX_MODELS][MAX_QPATH];
char sound_precache[MAX_SOUNDS][MAX_QPATH]; char sound_precache[MAX_SOUNDS][MAX_QPATH];
char *str;
int nummodels, numsounds, i;
Con_DPrintf ("Serverinfo packet received.\n"); Con_DPrintf ("Serverinfo packet received.\n");
@ -258,12 +251,14 @@ CL_ParseServerInfo (void)
strncpy (cl.levelname, str, sizeof (cl.levelname) - 1); strncpy (cl.levelname, str, sizeof (cl.levelname) - 1);
// seperate the printfs so the server message can have a color // seperate the printfs so the server message can have a color
Con_Printf ("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); Con_Printf ("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
"\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n"
"\n");
Con_Printf ("%c%s\n", 2, str); Con_Printf ("%c%s\n", 2, str);
// first we go through and touch all of the precache data that still // first we go through and touch all of the precache data that still
// happens to be in the cache, so precaching something else doesn't // happens to be in the cache, so precaching something else doesn't
// needlessly purge it // needlessly purge it
// precache models // precache models
memset (cl.model_precache, 0, sizeof (cl.model_precache)); memset (cl.model_precache, 0, sizeof (cl.model_precache));
@ -321,10 +316,8 @@ CL_ParseServerInfo (void)
noclip_anglehack = false; // noclip is turned off at start noclip_anglehack = false; // noclip is turned off at start
} }
int bitcounts[16]; int bitcounts[16];
/* /*
CL_ParseUpdate CL_ParseUpdate
@ -335,13 +328,10 @@ int bitcounts[16];
void void
CL_ParseUpdate (int bits) CL_ParseUpdate (int bits)
{ {
int i;
model_t *model;
int modnum;
qboolean forcelink;
entity_t *ent; entity_t *ent;
int num; int modnum, num, skin, i;
int skin; model_t *model;
qboolean forcelink;
if (cls.signon == SIGNONS - 1) { if (cls.signon == SIGNONS - 1) {
// first update is the final signon stage // first update is the final signon stage
@ -372,7 +362,7 @@ CL_ParseUpdate (int bits)
forcelink = false; forcelink = false;
if (forcelink) { if (forcelink) {
//FIXME do this right (ie, protocol support) // FIXME: do this right (ie, protocol support)
ent->alpha = 1; ent->alpha = 1;
ent->scale = 1; ent->scale = 1;
ent->glow_color = 254; ent->glow_color = 254;
@ -480,7 +470,6 @@ CL_ParseUpdate (int bits)
} }
} }
void void
CL_ParseBaseline (entity_t *ent) CL_ParseBaseline (entity_t *ent)
{ {
@ -503,7 +492,6 @@ CL_ParseBaseline (entity_t *ent)
ent->baseline->colormod = 255; ent->baseline->colormod = 255;
} }
/* /*
CL_ParseClientdata CL_ParseClientdata
@ -608,7 +596,6 @@ CL_ParseClientdata (int bits)
} }
} }
void void
CL_ParseStatic (void) CL_ParseStatic (void)
{ {
@ -641,13 +628,11 @@ CL_ParseStatic (void)
R_AddEfrags (ent); R_AddEfrags (ent);
} }
void void
CL_ParseStaticSound (void) CL_ParseStaticSound (void)
{ {
int sound_num, vol, atten, i;
vec3_t org; vec3_t org;
int sound_num, vol, atten;
int i;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
org[i] = MSG_ReadCoord (net_message); org[i] = MSG_ReadCoord (net_message);
@ -658,17 +643,14 @@ CL_ParseStaticSound (void)
S_StaticSound (cl.sound_precache[sound_num], org, vol, atten); S_StaticSound (cl.sound_precache[sound_num], org, vol, atten);
} }
#define SHOWNET(x) if(cl_shownet->int_val==2)Con_Printf ("%3i:%s\n", net_message->readcount-1, x); #define SHOWNET(x) if(cl_shownet->int_val==2)Con_Printf ("%3i:%s\n", net_message->readcount-1, x);
int snd_viewentity; int snd_viewentity;
void void
CL_ParseServerMessage (void) CL_ParseServerMessage (void)
{ {
int cmd; int cmd, i;
int i;
// if recording demos, copy the message out // if recording demos, copy the message out
if (cl_shownet->int_val == 1) if (cl_shownet->int_val == 1)
@ -703,7 +685,8 @@ CL_ParseServerMessage (void)
// other commands // other commands
switch (cmd) { switch (cmd) {
default: default:
Host_Error ("CL_ParseServerMessage: Illegible server message\n"); Host_Error ("CL_ParseServerMessage: Illegible server "
"message\n");
break; break;
case svc_nop: case svc_nop:
@ -723,9 +706,8 @@ CL_ParseServerMessage (void)
case svc_version: case svc_version:
i = MSG_ReadLong (net_message); i = MSG_ReadLong (net_message);
if (i != PROTOCOL_VERSION) if (i != PROTOCOL_VERSION)
Host_Error Host_Error ("CL_ParseServerMessage: Server is protocol %i "
("CL_ParseServerMessage: Server is protocol %i instead of %i\n", "instead of %i\n", i, PROTOCOL_VERSION);
i, PROTOCOL_VERSION);
break; break;
case svc_disconnect: case svc_disconnect:
@ -783,8 +765,8 @@ CL_ParseServerMessage (void)
Sbar_Changed (); Sbar_Changed ();
i = MSG_ReadByte (net_message); i = MSG_ReadByte (net_message);
if (i >= cl.maxclients) if (i >= cl.maxclients)
Host_Error Host_Error ("CL_ParseServerMessage: svc_updatename > "
("CL_ParseServerMessage: svc_updatename > MAX_SCOREBOARD"); "MAX_SCOREBOARD");
strcpy (cl.scores[i].name, MSG_ReadString (net_message)); strcpy (cl.scores[i].name, MSG_ReadString (net_message));
break; break;
@ -792,8 +774,8 @@ CL_ParseServerMessage (void)
Sbar_Changed (); Sbar_Changed ();
i = MSG_ReadByte (net_message); i = MSG_ReadByte (net_message);
if (i >= cl.maxclients) if (i >= cl.maxclients)
Host_Error Host_Error ("CL_ParseServerMessage: svc_updatefrags > "
("CL_ParseServerMessage: svc_updatefrags > MAX_SCOREBOARD"); "MAX_SCOREBOARD");
cl.scores[i].frags = MSG_ReadShort (net_message); cl.scores[i].frags = MSG_ReadShort (net_message);
break; break;
@ -801,8 +783,8 @@ CL_ParseServerMessage (void)
Sbar_Changed (); Sbar_Changed ();
i = MSG_ReadByte (net_message); i = MSG_ReadByte (net_message);
if (i >= cl.maxclients) if (i >= cl.maxclients)
Host_Error Host_Error ("CL_ParseServerMessage: svc_updatecolors > "
("CL_ParseServerMessage: svc_updatecolors > MAX_SCOREBOARD"); "MAX_SCOREBOARD");
cl.scores[i].colors = MSG_ReadByte (net_message); cl.scores[i].colors = MSG_ReadByte (net_message);
//XXX CL_NewTranslation (i); //XXX CL_NewTranslation (i);
break; break;
@ -842,7 +824,8 @@ CL_ParseServerMessage (void)
case svc_signonnum: case svc_signonnum:
i = MSG_ReadByte (net_message); i = MSG_ReadByte (net_message);
if (i <= cls.signon) if (i <= cls.signon)
Host_Error ("Received signon %i when at %i", i, cls.signon); Host_Error ("Received signon %i when at %i", i,
cls.signon);
cls.signon = i; cls.signon = i;
CL_SignonReply (); CL_SignonReply ();
break; break;

View file

@ -48,6 +48,9 @@
#include "client.h" #include "client.h"
#include "sbar.h" #include "sbar.h"
extern void V_PrepBlend (void);
void void
SCR_DrawNet (int swap) SCR_DrawNet (int swap)
{ {
@ -75,8 +78,6 @@ static SCR_Func scr_funcs[] = {
0 0
}; };
extern void V_PrepBlend (void);
void void
CL_UpdateScreen (double realtime) CL_UpdateScreen (double realtime)
{ {

View file

@ -71,7 +71,6 @@ typedef struct {
explosion_t cl_explosions[MAX_EXPLOSIONS]; explosion_t cl_explosions[MAX_EXPLOSIONS];
sfx_t *cl_sfx_wizhit; sfx_t *cl_sfx_wizhit;
sfx_t *cl_sfx_knighthit; sfx_t *cl_sfx_knighthit;
sfx_t *cl_sfx_tink1; sfx_t *cl_sfx_tink1;
@ -106,6 +105,7 @@ static const particle_effect_t prot_to_rend[]={
PE_UNKNOWN, // TE_BEAM PE_UNKNOWN, // TE_BEAM
}; };
void void
CL_TEnts_Init (void) CL_TEnts_Init (void)
{ {
@ -123,7 +123,6 @@ CL_TEnts_Init (void)
cl_spr_explod = Mod_ForName ("progs/s_explod.spr", true); cl_spr_explod = Mod_ForName ("progs/s_explod.spr", true);
} }
void void
CL_Init_Entity (entity_t *ent) CL_Init_Entity (entity_t *ent)
{ {
@ -138,7 +137,6 @@ CL_Init_Entity (entity_t *ent)
ent->pose1 = ent->pose2 = -1; ent->pose1 = ent->pose2 = -1;
} }
void void
CL_ClearTEnts (void) CL_ClearTEnts (void)
{ {
@ -157,13 +155,11 @@ CL_ClearTEnts (void)
} }
} }
explosion_t * explosion_t *
CL_AllocExplosion (void) CL_AllocExplosion (void)
{ {
int i;
float time; float time;
int index; int index, i;
for (i = 0; i < MAX_EXPLOSIONS; i++) for (i = 0; i < MAX_EXPLOSIONS; i++)
if (!cl_explosions[i].ent.model) if (!cl_explosions[i].ent.model)
@ -180,14 +176,12 @@ CL_AllocExplosion (void)
return &cl_explosions[index]; return &cl_explosions[index];
} }
void void
CL_ParseBeam (model_t *m) CL_ParseBeam (model_t *m)
{ {
int ent;
vec3_t start, end;
beam_t *b; beam_t *b;
int i; int ent, i;
vec3_t start, end;
ent = MSG_ReadShort (net_message); ent = MSG_ReadShort (net_message);
@ -223,17 +217,15 @@ CL_ParseBeam (model_t *m)
Con_Printf ("beam list overflow!\n"); Con_Printf ("beam list overflow!\n");
} }
void void
CL_ParseTEnt (void) CL_ParseTEnt (void)
{ {
byte type; byte type;
vec3_t pos;
dlight_t *dl; dlight_t *dl;
int rnd; int colorStart, colorLength, rnd;
int colorStart, colorLength;
explosion_t *ex;
int cnt = -1; int cnt = -1;
explosion_t *ex;
vec3_t pos;
type = MSG_ReadByte (net_message); type = MSG_ReadByte (net_message);
//XXX FIXME this is to get around an nq/qw protocol colission //XXX FIXME this is to get around an nq/qw protocol colission
@ -404,17 +396,14 @@ CL_ParseTEnt (void)
} }
} }
void void
CL_UpdateBeams (void) CL_UpdateBeams (void)
{ {
int i;
beam_t *b; beam_t *b;
vec3_t dist, org;
float d;
entity_t **ent; entity_t **ent;
float yaw, pitch; float forward, pitch, yaw, d;
float forward; int i;
vec3_t dist, org;
// update lightning // update lightning
for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++) { for (i = 0, b = cl_beams; i < MAX_BEAMS; i++, b++) {
@ -466,14 +455,12 @@ CL_UpdateBeams (void)
} }
} }
void void
CL_UpdateExplosions (void) CL_UpdateExplosions (void)
{ {
int i;
int f;
explosion_t *ex;
entity_t **ent; entity_t **ent;
explosion_t *ex;
int f, i;
for (i = 0, ex = cl_explosions; i < MAX_EXPLOSIONS; i++, ex++) { for (i = 0, ex = cl_explosions; i < MAX_EXPLOSIONS; i++, ex++) {
if (!ex->ent.model) if (!ex->ent.model)
@ -492,7 +479,6 @@ CL_UpdateExplosions (void)
} }
} }
void void
CL_UpdateTEnts (void) CL_UpdateTEnts (void)
{ {
@ -500,7 +486,6 @@ CL_UpdateTEnts (void)
CL_UpdateExplosions (); CL_UpdateExplosions ();
} }
/* /*
CL_ParseParticleEffect CL_ParseParticleEffect
@ -509,8 +494,8 @@ CL_UpdateTEnts (void)
void void
CL_ParseParticleEffect (void) CL_ParseParticleEffect (void)
{ {
vec3_t org, dir;
int i, count, msgcount, color; int i, count, msgcount, color;
vec3_t org, dir;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
org[i] = MSG_ReadCoord (net_message); org[i] = MSG_ReadCoord (net_message);

View file

@ -87,7 +87,6 @@ float v_dmg_time, v_dmg_roll, v_dmg_pitch;
float v_blend[4]; float v_blend[4];
extern cvar_t *vid_gamma; extern cvar_t *vid_gamma;
extern int in_forward, in_forward2, in_back; extern int in_forward, in_forward2, in_back;
cshift_t cshift_empty = { {130, 80, 50}, 0}; cshift_t cshift_empty = { {130, 80, 50}, 0};
@ -100,23 +99,22 @@ cshift_t cshift_bonus = { {215, 186, 60}, 50};
float float
V_CalcBob (void) V_CalcBob (void)
{ {
float bob; float bob, cycle;
float cycle;
cycle = cl.time - (int) (cl.time / cl_bobcycle->value) * cl_bobcycle->value; cycle = cl.time - (int) (cl.time / cl_bobcycle->value) *
cl_bobcycle->value;
cycle /= cl_bobcycle->value; cycle /= cl_bobcycle->value;
if (cycle < cl_bobup->value) if (cycle < cl_bobup->value)
cycle = M_PI * cycle / cl_bobup->value; cycle = M_PI * cycle / cl_bobup->value;
else else
cycle = cycle = M_PI + M_PI * (cycle - cl_bobup->value) / (1.0 -
M_PI + M_PI * (cycle - cl_bobup->value) / (1.0 - cl_bobup->value); cl_bobup->value);
// bob is proportional to velocity in the xy plane // bob is proportional to velocity in the xy plane
// (don't count Z, or jumping messes it up) // (don't count Z, or jumping messes it up)
bob = bob = sqrt (cl.velocity[0] * cl.velocity[0] +
sqrt (cl.velocity[0] * cl.velocity[0] + cl.velocity[1] * cl.velocity[1]) * cl_bob->value;
cl.velocity[1] * cl.velocity[1]) * cl_bob->value;
// Con_Printf ("speed: %5.1f\n", Length(cl.velocity)); // Con_Printf ("speed: %5.1f\n", Length(cl.velocity));
bob = bob * 0.3 + bob * 0.7 * sin (cycle); bob = bob * 0.3 + bob * 0.7 * sin (cycle);
if (bob > 4) if (bob > 4)
@ -124,10 +122,8 @@ V_CalcBob (void)
else if (bob < -7) else if (bob < -7)
bob = -7; bob = -7;
return bob; return bob;
} }
void void
V_StartPitchDrift (void) V_StartPitchDrift (void)
{ {
@ -142,7 +138,6 @@ V_StartPitchDrift (void)
} }
} }
void void
V_StopPitchDrift (void) V_StopPitchDrift (void)
{ {
@ -151,7 +146,6 @@ V_StopPitchDrift (void)
cl.pitchvel = 0; cl.pitchvel = 0;
} }
/* /*
V_DriftPitch V_DriftPitch
@ -215,22 +209,15 @@ V_DriftPitch (void)
} }
} }
/* PALETTE FLASHES */
/*
PALETTE FLASHES
*/
void void
V_ParseDamage (void) V_ParseDamage (void)
{ {
int armor, blood;
vec3_t from;
int i;
vec3_t forward, right, up;
entity_t *ent; entity_t *ent;
float side; float count, side;
float count; int armor, blood, i;
vec3_t from, forward, right, up;
armor = MSG_ReadByte (net_message); armor = MSG_ReadByte (net_message);
blood = MSG_ReadByte (net_message); blood = MSG_ReadByte (net_message);
@ -282,7 +269,6 @@ V_ParseDamage (void)
v_dmg_time = v_kicktime->value; v_dmg_time = v_kicktime->value;
} }
void void
V_cshift_f (void) V_cshift_f (void)
{ {
@ -292,7 +278,6 @@ V_cshift_f (void)
cshift_empty.percent = atoi (Cmd_Argv (4)); cshift_empty.percent = atoi (Cmd_Argv (4));
} }
/* /*
V_BonusFlash_f V_BonusFlash_f
@ -306,7 +291,6 @@ V_BonusFlash_f (void)
cl.cshifts[CSHIFT_BONUS] = cshift_bonus; cl.cshifts[CSHIFT_BONUS] = cshift_bonus;
} }
/* /*
V_SetContentsColor V_SetContentsColor
@ -336,7 +320,6 @@ V_SetContentsColor (int contents)
} }
} }
void void
V_CalcPowerupCshift (void) V_CalcPowerupCshift (void)
{ {
@ -378,7 +361,6 @@ V_CalcPowerupCshift (void)
} }
} }
/* /*
V_CalcBlend V_CalcBlend
@ -388,8 +370,8 @@ V_CalcPowerupCshift (void)
void void
V_CalcBlend (void) V_CalcBlend (void)
{ {
float r = 0, g = 0, b = 0, a = 0;
float a2, a3; float a2, a3;
float r = 0, g = 0, b = 0, a = 0;
int i; int i;
for (i = 0; i < NUM_CSHIFTS; i++) { for (i = 0; i < NUM_CSHIFTS; i++) {
@ -421,7 +403,6 @@ V_CalcBlend (void)
v_blend[3] = bound (0.0, a, 1.0); v_blend[3] = bound (0.0, a, 1.0);
} }
void void
V_PrepBlend (void) V_PrepBlend (void)
{ {
@ -440,7 +421,8 @@ V_PrepBlend (void)
cl.prev_cshifts[i].percent = cl.cshifts[i].percent; cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
} }
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) { if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j])
{
vid.cshift_changed = true; vid.cshift_changed = true;
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j]; cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
} }
@ -463,11 +445,7 @@ V_PrepBlend (void)
V_CalcBlend(); V_CalcBlend();
} }
/* VIEW RENDERING */
/*
VIEW RENDERING
*/
float float
angledelta (float a) angledelta (float a)
@ -478,13 +456,11 @@ angledelta (float a)
return a; return a;
} }
void void
CalcGunAngle (void) CalcGunAngle (void)
{ {
float yaw, pitch, move; float yaw, pitch, move;
static float oldyaw = 0; static float oldpitch = 0, oldyaw = 0;
static float oldpitch = 0;
yaw = r_refdef.viewangles[YAW]; yaw = r_refdef.viewangles[YAW];
pitch = -r_refdef.viewangles[PITCH]; pitch = -r_refdef.viewangles[PITCH];
@ -528,7 +504,6 @@ CalcGunAngle (void)
v_iyaw_level->value; v_iyaw_level->value;
} }
void void
V_BoundOffsets (void) V_BoundOffsets (void)
{ {
@ -536,8 +511,8 @@ V_BoundOffsets (void)
ent = &cl_entities[cl.viewentity]; ent = &cl_entities[cl.viewentity];
// absolutely bound refresh reletive to entity clipping hull // absolutely bound refresh reletive to entity clipping hull
// so the view can never be inside a solid wall // so the view can never be inside a solid wall
if (r_refdef.vieworg[0] < ent->origin[0] - 14) if (r_refdef.vieworg[0] < ent->origin[0] - 14)
r_refdef.vieworg[0] = ent->origin[0] - 14; r_refdef.vieworg[0] = ent->origin[0] - 14;
@ -553,7 +528,6 @@ V_BoundOffsets (void)
r_refdef.vieworg[2] = ent->origin[2] + 30; r_refdef.vieworg[2] = ent->origin[2] + 30;
} }
/* /*
V_AddIdle V_AddIdle
@ -573,7 +547,6 @@ V_AddIdle (void)
v_iyaw_level->value; v_iyaw_level->value;
} }
/* /*
V_CalcViewRoll V_CalcViewRoll
@ -602,7 +575,6 @@ V_CalcViewRoll (void)
} }
void void
V_CalcIntermissionRefdef (void) V_CalcIntermissionRefdef (void)
{ {
@ -626,16 +598,14 @@ V_CalcIntermissionRefdef (void)
Cvar_SetValue (v_idlescale, old); Cvar_SetValue (v_idlescale, old);
} }
void void
V_CalcRefdef (void) V_CalcRefdef (void)
{ {
entity_t *ent, *view; entity_t *ent, *view;
int i;
vec3_t forward, right, up;
vec3_t angles;
float bob; float bob;
static float oldz = 0; static float oldz = 0;
int i;
vec3_t angles, forward, right, up;
V_DriftPitch (); V_DriftPitch ();
@ -644,9 +614,8 @@ V_CalcRefdef (void)
// view is the weapon model (only visible from inside body) // view is the weapon model (only visible from inside body)
view = &cl.viewent; view = &cl.viewent;
// transform the view offset by the model's matrix to get the offset from
// transform the view offset by the model's matrix to get the offset from // model origin for the view
// model origin for the view
ent->angles[YAW] = cl.viewangles[YAW]; // the model should face ent->angles[YAW] = cl.viewangles[YAW]; // the model should face
// the view dir // the view dir
ent->angles[PITCH] = -cl.viewangles[PITCH]; // the model should face ent->angles[PITCH] = -cl.viewangles[PITCH]; // the model should face
@ -659,9 +628,9 @@ V_CalcRefdef (void)
VectorCopy (ent->origin, r_refdef.vieworg); VectorCopy (ent->origin, r_refdef.vieworg);
r_refdef.vieworg[2] += cl.viewheight + bob; r_refdef.vieworg[2] += cl.viewheight + bob;
// never let it sit exactly on a node line, because a water plane can // never let it sit exactly on a node line, because a water plane can
// dissapear when viewed with the eye exactly on it. // dissapear when viewed with the eye exactly on it.
// the server protocol only specifies to 1/16 pixel, so add 1/32 in each axis // server protocol only specifies to 1/16 pixel, so add 1/32 in each axis
r_refdef.vieworg[0] += 1.0 / 32; r_refdef.vieworg[0] += 1.0 / 32;
r_refdef.vieworg[1] += 1.0 / 32; r_refdef.vieworg[1] += 1.0 / 32;
r_refdef.vieworg[2] += 1.0 / 32; r_refdef.vieworg[2] += 1.0 / 32;
@ -696,13 +665,13 @@ V_CalcRefdef (void)
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
view->origin[i] += forward[i] * bob * 0.4; view->origin[i] += forward[i] * bob * 0.4;
// view->origin[i] += right[i]*bob*0.4; // view->origin[i] += right[i]*bob*0.4;
// view->origin[i] += up[i]*bob*0.8; // view->origin[i] += up[i]*bob*0.8;
} }
view->origin[2] += bob; view->origin[2] += bob;
// fudge position around to keep amount of weapon visible // fudge position around to keep amount of weapon visible
// roughly equal with different FOV // roughly equal with different FOV
if (cl_sbar->int_val == 0 && scr_viewsize->int_val >= 100) if (cl_sbar->int_val == 0 && scr_viewsize->int_val >= 100)
; ;
else if (scr_viewsize->int_val == 110) else if (scr_viewsize->int_val == 110)
@ -730,7 +699,7 @@ V_CalcRefdef (void)
steptime = cl.time - cl.oldtime; steptime = cl.time - cl.oldtime;
if (steptime < 0) if (steptime < 0)
//FIXME I_Error ("steptime < 0"); //FIXME I_Error ("steptime < 0");
steptime = 0; steptime = 0;
oldz += steptime * 80; oldz += steptime * 80;
@ -747,7 +716,6 @@ V_CalcRefdef (void)
Chase_Update (); Chase_Update ();
} }
/* /*
V_RenderView V_RenderView
@ -777,61 +745,68 @@ V_RenderView (void)
R_RenderView (); R_RenderView ();
} }
void void
V_Init (void) V_Init (void)
{ {
Cmd_AddCommand ("v_cshift", V_cshift_f, "This adjusts all of the colors currently being displayed.\n" Cmd_AddCommand ("v_cshift", V_cshift_f, "This adjusts all of the colors "
"Used when you are underwater, hit, have the Ring of Shadows, or Quad Damage. (v_cshift r g b intensity)"); "currently being displayed.\n"
"Used when you are underwater, hit, have the Ring of "
Cmd_AddCommand ("bf", V_BonusFlash_f, "Background flash, used when you pick up an item"); "Shadows, or Quad Damage. (v_cshift r g b intensity)");
Cmd_AddCommand ("centerview", V_StartPitchDrift, "Centers the player's view ahead after +lookup or +lookdown \n" Cmd_AddCommand ("bf", V_BonusFlash_f, "Background flash, used when you "
"Will not work while mlook is active or freelook is 1."); "pick up an item");
Cmd_AddCommand ("centerview", V_StartPitchDrift, "Centers the player's "
"view ahead after +lookup or +lookdown\n"
"Will not work while mlook is active or freelook is 1.");
} }
void void
V_Init_Cvars (void) V_Init_Cvars (void)
{ {
v_centermove = Cvar_Get ("v_centermove", "0.15", CVAR_NONE, NULL, v_centermove = Cvar_Get ("v_centermove", "0.15", CVAR_NONE, NULL,
"How far the player must move forward before the view re-centers"); "How far the player must move forward before "
"the view re-centers");
v_centerspeed = Cvar_Get ("v_centerspeed", "500", CVAR_NONE, NULL, v_centerspeed = Cvar_Get ("v_centerspeed", "500", CVAR_NONE, NULL,
"How quickly you return to a center view after a lookup or lookdown"); "How quickly you return to a center view after "
"a lookup or lookdown");
v_iyaw_cycle = Cvar_Get ("v_iyaw_cycle", "2", CVAR_NONE, NULL, v_iyaw_cycle = Cvar_Get ("v_iyaw_cycle", "2", CVAR_NONE, NULL,
"How far you tilt right and left when v_idlescale is enabled"); "How far you tilt right and left when "
"v_idlescale is enabled");
v_iroll_cycle = Cvar_Get ("v_iroll_cycle", "0.5", CVAR_NONE, NULL, v_iroll_cycle = Cvar_Get ("v_iroll_cycle", "0.5", CVAR_NONE, NULL,
"How quickly you tilt right and left when v_idlescale is enabled"); "How quickly you tilt right and left when "
"v_idlescale is enabled");
v_ipitch_cycle = Cvar_Get ("v_ipitch_cycle", "1", CVAR_NONE, NULL, v_ipitch_cycle = Cvar_Get ("v_ipitch_cycle", "1", CVAR_NONE, NULL,
"How quickly you lean forwards and backwards when v_idlescale is enabled"); "How quickly you lean forwards and backwards "
"when v_idlescale is enabled");
v_iyaw_level = Cvar_Get ("v_iyaw_level", "0.3", CVAR_NONE, NULL, v_iyaw_level = Cvar_Get ("v_iyaw_level", "0.3", CVAR_NONE, NULL,
"How far you tilt right and left when v_idlescale is enabled"); "How far you tilt right and left when "
"v_idlescale is enabled");
v_iroll_level = Cvar_Get ("v_iroll_level", "0.1", CVAR_NONE, NULL, v_iroll_level = Cvar_Get ("v_iroll_level", "0.1", CVAR_NONE, NULL,
"How far you tilt right and left when v_idlescale is enabled"); "How far you tilt right and left when "
"v_idlescale is enabled");
v_ipitch_level = Cvar_Get ("v_ipitch_level", "0.3", CVAR_NONE, NULL, v_ipitch_level = Cvar_Get ("v_ipitch_level", "0.3", CVAR_NONE, NULL,
"How far you lean forwards and backwards when v_idlescale is enabled"); "How far you lean forwards and backwards when "
"v_idlescale is enabled");
v_idlescale = Cvar_Get ("v_idlescale", "0", CVAR_NONE, NULL, v_idlescale = Cvar_Get ("v_idlescale", "0", CVAR_NONE, NULL,
"Toggles whether the view remains idle"); "Toggles whether the view remains idle");
scr_ofsx = Cvar_Get ("scr_ofsx", "0", CVAR_NONE, NULL, "None"); scr_ofsx = Cvar_Get ("scr_ofsx", "0", CVAR_NONE, NULL, "None");
scr_ofsy = Cvar_Get ("scr_ofsy", "0", CVAR_NONE, NULL, "None"); scr_ofsy = Cvar_Get ("scr_ofsy", "0", CVAR_NONE, NULL, "None");
scr_ofsz = Cvar_Get ("scr_ofsz", "0", CVAR_NONE, NULL, "None"); scr_ofsz = Cvar_Get ("scr_ofsz", "0", CVAR_NONE, NULL, "None");
cl_rollspeed = Cvar_Get ("cl_rollspeed", "200", CVAR_NONE, NULL, cl_rollspeed = Cvar_Get ("cl_rollspeed", "200", CVAR_NONE, NULL,
"How quickly you straighten out after strafing"); "How quickly you straighten out after strafing");
cl_rollangle = Cvar_Get ("cl_rollangle", "2.0", CVAR_NONE, NULL, cl_rollangle = Cvar_Get ("cl_rollangle", "2.0", CVAR_NONE, NULL,
"How much your screen tilts when strafing"); "How much your screen tilts when strafing");
cl_bob = Cvar_Get ("cl_bob", "0.02", CVAR_NONE, NULL, cl_bob = Cvar_Get ("cl_bob", "0.02", CVAR_NONE, NULL,
"How much your weapon moves up and down when walking"); "How much your weapon moves up and down when walking");
cl_bobcycle = Cvar_Get ("cl_bobcycle", "0.6", CVAR_NONE, NULL, cl_bobcycle = Cvar_Get ("cl_bobcycle", "0.6", CVAR_NONE, NULL,
"How quickly your weapon moves up and down when walking"); "How quickly your weapon moves up and down when "
cl_bobup = Cvar_Get ("cl_bobup", "0.5", CVAR_NONE, NULL, "walking");
"How long your weapon stays up before cycling when walking"); cl_bobup = Cvar_Get ("cl_bobup", "0.5", CVAR_NONE, NULL, "How long your "
"weapon stays up before cycling when walking");
v_kicktime = Cvar_Get ("v_kicktime", "0.5", CVAR_NONE, NULL, v_kicktime = Cvar_Get ("v_kicktime", "0.5", CVAR_NONE, NULL,
"How long the kick from an attack lasts"); "How long the kick from an attack lasts");
v_kickroll = Cvar_Get ("v_kickroll", "0.6", CVAR_NONE, NULL, v_kickroll = Cvar_Get ("v_kickroll", "0.6", CVAR_NONE, NULL,
"How much you lean when hit"); "How much you lean when hit");
v_kickpitch = Cvar_Get ("v_kickpitch", "0.6", CVAR_NONE, NULL, v_kickpitch = Cvar_Get ("v_kickpitch", "0.6", CVAR_NONE, NULL,
"How much you look up when hit"); "How much you look up when hit");
} }

View file

@ -35,6 +35,7 @@
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/vfs.h" #include "QF/vfs.h"
#include "game.h" #include "game.h"
void Cvar_Info (struct cvar_s *var); void Cvar_Info (struct cvar_s *var);
@ -55,8 +56,8 @@ int static_registered = 1;
void void
COM_CheckRegistered (void) COM_CheckRegistered (void)
{ {
VFile *h;
unsigned short check[128]; unsigned short check[128];
VFile *h;
COM_FOpenFile ("gfx/pop.lmp", &h); COM_FOpenFile ("gfx/pop.lmp", &h);
static_registered = 0; static_registered = 0;
@ -73,7 +74,6 @@ COM_CheckRegistered (void)
} }
} }
void void
COM_Init (void) COM_Init (void)
{ {

View file

@ -30,12 +30,14 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <ctype.h> #include <ctype.h>
#include <windows.h> #include <windows.h>
#include "conproc.h"
#include "QF/console.h" #include "QF/console.h"
#include "conproc.h"
HANDLE heventDone; HANDLE heventDone;
HANDLE hfileBuffer; HANDLE hfileBuffer;
HANDLE heventChildSend; HANDLE heventChildSend;
@ -59,7 +61,7 @@ InitConProc (HANDLE hFile, HANDLE heventParent, HANDLE heventChild)
{ {
DWORD dwID; DWORD dwID;
// ignore if we don't have all the events. // ignore if we don't have all the events.
if (!hFile || !heventParent || !heventChild) if (!hFile || !heventParent || !heventChild)
return; return;
@ -67,7 +69,7 @@ InitConProc (HANDLE hFile, HANDLE heventParent, HANDLE heventChild)
heventParentSend = heventParent; heventParentSend = heventParent;
heventChildSend = heventChild; heventChildSend = heventChild;
// so we'll know when to go away. // so we'll know when to go away.
heventDone = CreateEvent (NULL, FALSE, FALSE, NULL); heventDone = CreateEvent (NULL, FALSE, FALSE, NULL);
if (!heventDone) { if (!heventDone) {
@ -81,15 +83,14 @@ InitConProc (HANDLE hFile, HANDLE heventParent, HANDLE heventChild)
Con_Printf ("Couldn't create QHOST thread\n"); Con_Printf ("Couldn't create QHOST thread\n");
return; return;
} }
// save off the input/output handles. // save off the input/output handles.
hStdout = GetStdHandle (STD_OUTPUT_HANDLE); hStdout = GetStdHandle (STD_OUTPUT_HANDLE);
hStdin = GetStdHandle (STD_INPUT_HANDLE); hStdin = GetStdHandle (STD_INPUT_HANDLE);
// force 80 character width, at least 25 character height // force 80 character width, at least 25 character height
SetConsoleCXCY (hStdout, 80, 25); SetConsoleCXCY (hStdout, 80, 25);
} }
void void
DeinitConProc (void) DeinitConProc (void)
{ {
@ -97,14 +98,13 @@ DeinitConProc (void)
SetEvent (heventDone); SetEvent (heventDone);
} }
DWORD DWORD
RequestProc (DWORD dwNichts) RequestProc (DWORD dwNichts)
{ {
int iBeginLine, iEndLine;
int *pBuffer; int *pBuffer;
DWORD dwRet; DWORD dwRet;
HANDLE heventWait[2]; HANDLE heventWait[2];
int iBeginLine, iEndLine;
heventWait[0] = heventParentSend; heventWait[0] = heventParentSend;
heventWait[1] = heventDone; heventWait[1] = heventDone;
@ -157,7 +157,6 @@ RequestProc (DWORD dwNichts)
return 0; return 0;
} }
LPVOID LPVOID
GetMappedBuffer (HANDLE hfileBuffer) GetMappedBuffer (HANDLE hfileBuffer)
{ {
@ -169,14 +168,12 @@ GetMappedBuffer (HANDLE hfileBuffer)
return pBuffer; return pBuffer;
} }
void void
ReleaseMappedBuffer (LPVOID pBuffer) ReleaseMappedBuffer (LPVOID pBuffer)
{ {
UnmapViewOfFile (pBuffer); UnmapViewOfFile (pBuffer);
} }
BOOL BOOL
GetScreenBufferLines (int *piLines) GetScreenBufferLines (int *piLines)
{ {
@ -191,7 +188,6 @@ GetScreenBufferLines (int *piLines)
return bRet; return bRet;
} }
BOOL BOOL
SetScreenBufferLines (int iLines) SetScreenBufferLines (int iLines)
{ {
@ -199,19 +195,17 @@ SetScreenBufferLines (int iLines)
return SetConsoleCXCY (hStdout, 80, iLines); return SetConsoleCXCY (hStdout, 80, iLines);
} }
BOOL BOOL
ReadText (LPTSTR pszText, int iBeginLine, int iEndLine) ReadText (LPTSTR pszText, int iBeginLine, int iEndLine)
{ {
BOOL bRet;
COORD coord; COORD coord;
DWORD dwRead; DWORD dwRead;
BOOL bRet;
coord.X = 0; coord.X = 0;
coord.Y = iBeginLine; coord.Y = iBeginLine;
bRet = ReadConsoleOutputCharacter (hStdout, bRet = ReadConsoleOutputCharacter (hStdout, pszText,
pszText,
80 * (iEndLine - iBeginLine + 1), 80 * (iEndLine - iBeginLine + 1),
coord, &dwRead); coord, &dwRead);
@ -222,13 +216,12 @@ ReadText (LPTSTR pszText, int iBeginLine, int iEndLine)
return bRet; return bRet;
} }
BOOL BOOL
WriteText (LPCTSTR szText) WriteText (LPCTSTR szText)
{ {
char upper, *sz;
DWORD dwWritten; DWORD dwWritten;
INPUT_RECORD rec; INPUT_RECORD rec;
char upper, *sz;
sz = (LPTSTR) szText; sz = (LPTSTR) szText;
@ -260,7 +253,6 @@ WriteText (LPCTSTR szText)
return TRUE; return TRUE;
} }
int int
CharToCode (char c) CharToCode (char c)
{ {
@ -285,7 +277,6 @@ CharToCode (char c)
return c; return c;
} }
BOOL BOOL
SetConsoleCXCY (HANDLE hStdout, int cx, int cy) SetConsoleCXCY (HANDLE hStdout, int cx, int cy)
{ {
@ -303,7 +294,7 @@ SetConsoleCXCY (HANDLE hStdout, int cx, int cy)
if (!GetConsoleScreenBufferInfo (hStdout, &info)) if (!GetConsoleScreenBufferInfo (hStdout, &info))
return FALSE; return FALSE;
// height // height
info.srWindow.Left = 0; info.srWindow.Left = 0;
info.srWindow.Right = info.dwSize.X - 1; info.srWindow.Right = info.dwSize.X - 1;
info.srWindow.Top = 0; info.srWindow.Top = 0;
@ -330,7 +321,7 @@ SetConsoleCXCY (HANDLE hStdout, int cx, int cy)
if (!GetConsoleScreenBufferInfo (hStdout, &info)) if (!GetConsoleScreenBufferInfo (hStdout, &info))
return FALSE; return FALSE;
// width // width
info.srWindow.Left = 0; info.srWindow.Left = 0;
info.srWindow.Right = cx - 1; info.srWindow.Right = cx - 1;
info.srWindow.Top = 0; info.srWindow.Top = 0;

View file

@ -39,7 +39,6 @@
#include <stdarg.h> #include <stdarg.h>
#include "QF/cmd.h" #include "QF/cmd.h"
#include "compat.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/draw.h" #include "QF/draw.h"
@ -51,13 +50,14 @@
#include "QF/va.h" #include "QF/va.h"
#include "client.h" #include "client.h"
#include "compat.h"
int con_ormask;
console_t con_main; console_t con_main;
console_t con_chat; console_t con_chat;
console_t *con; // point to either con_main or con_chat console_t *con; // point to either con_main or con_chat
int con_linewidth; // characters across screen int con_linewidth; // characters across screen
int con_ormask;
int con_totallines; // total lines in console scrollback int con_totallines; // total lines in console scrollback
float con_cursorspeed = 4; float con_cursorspeed = 4;
@ -100,7 +100,6 @@ Con_ToggleConsole_f (void)
Con_ClearNotify (); Con_ClearNotify ();
} }
void void
Con_ToggleChat_f (void) Con_ToggleChat_f (void)
{ {
@ -115,7 +114,6 @@ Con_ToggleChat_f (void)
Con_ClearNotify (); Con_ClearNotify ();
} }
void void
Con_Clear_f (void) Con_Clear_f (void)
{ {
@ -126,7 +124,6 @@ Con_Clear_f (void)
con_main.display = con_main.current; con_main.display = con_main.current;
} }
void void
Con_ClearNotify (void) Con_ClearNotify (void)
{ {
@ -136,7 +133,6 @@ Con_ClearNotify (void)
con_times[i] = 0; con_times[i] = 0;
} }
void void
Con_MessageMode_f (void) Con_MessageMode_f (void)
{ {
@ -146,7 +142,6 @@ Con_MessageMode_f (void)
key_dest = key_message; key_dest = key_message;
} }
void void
Con_MessageMode2_f (void) Con_MessageMode2_f (void)
{ {
@ -156,12 +151,11 @@ Con_MessageMode2_f (void)
key_dest = key_message; key_dest = key_message;
} }
void void
Con_Resize (console_t *con) Con_Resize (console_t *con)
{ {
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
char tbuf[CON_TEXTSIZE]; char tbuf[CON_TEXTSIZE];
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
width = (vid.width >> 3) - 2; width = (vid.width >> 3) - 2;
@ -206,7 +200,6 @@ Con_Resize (console_t *con)
con->display = con->current; con->display = con->current;
} }
/* /*
Con_CheckResize Con_CheckResize
@ -219,7 +212,6 @@ Con_CheckResize (void)
Con_Resize (&con_chat); Con_Resize (&con_chat);
} }
void void
Con_Init (const char *plugin_name) Con_Init (const char *plugin_name)
{ {
@ -244,16 +236,14 @@ Con_Init (const char *plugin_name)
con_initialized = true; con_initialized = true;
} }
void void
Con_Init_Cvars (void) Con_Init_Cvars (void)
{ {
con_notifytime = con_notifytime = Cvar_Get ("con_notifytime", "3", CVAR_NONE, NULL,
Cvar_Get ("con_notifytime", "3", CVAR_NONE, NULL, "How long in seconds messages are displayed "
"How long in seconds messages are displayed on screen"); "on screen");
} }
void void
Con_Linefeed (void) Con_Linefeed (void)
{ {
@ -267,7 +257,6 @@ Con_Linefeed (void)
' ', con_linewidth); ' ', con_linewidth);
} }
/* /*
Con_Print Con_Print
@ -278,10 +267,8 @@ Con_Linefeed (void)
void void
Con_Print (const char *txt) Con_Print (const char *txt)
{ {
int y; int mask, c, l, y;
int c, l;
static int cr; static int cr;
int mask;
// echo to debugging console // echo to debugging console
Sys_Printf ("%s", txt); Sys_Printf ("%s", txt);
@ -316,7 +303,6 @@ Con_Print (const char *txt)
cr = false; cr = false;
} }
if (!con->x) { if (!con->x) {
Con_Linefeed (); Con_Linefeed ();
// mark time for transparent overlay // mark time for transparent overlay
@ -346,11 +332,7 @@ Con_Print (const char *txt)
} }
} }
/* DRAWING */
/*
DRAWING
*/
/* /*
Con_DrawInput Con_DrawInput
@ -360,10 +342,9 @@ Con_Print (const char *txt)
void void
Con_DrawInput (void) Con_DrawInput (void)
{ {
int y;
int i;
char *text;
char temp[MAXCMDLINE]; char temp[MAXCMDLINE];
char *text;
int i, y;
if (key_dest != key_console && cls.state == ca_active) if (key_dest != key_console && cls.state == ca_active)
return; // don't draw anything (always draw if not active) return; // don't draw anything (always draw if not active)
@ -389,7 +370,6 @@ Con_DrawInput (void)
Draw_Character ((i + 1) << 3, con_vislines - 22, text[i]); Draw_Character ((i + 1) << 3, con_vislines - 22, text[i]);
} }
/* /*
Con_DrawNotify Con_DrawNotify
@ -398,12 +378,9 @@ Con_DrawInput (void)
void void
Con_DrawNotify (void) Con_DrawNotify (void)
{ {
int x, v; char *s, *text;
char *text; int skip, i, x, v;
int i;
float time; float time;
char *s;
int skip;
v = 0; v = 0;
for (i = con->current - NUM_CON_TIMES + 1; i <= con->current; i++) { for (i = con->current - NUM_CON_TIMES + 1; i <= con->current; i++) {
@ -455,7 +432,6 @@ Con_DrawNotify (void)
con_notifylines = v; con_notifylines = v;
} }
/* /*
Con_DrawConsole Con_DrawConsole
@ -464,10 +440,8 @@ Con_DrawNotify (void)
void void
Con_DrawConsole (int lines) Con_DrawConsole (int lines)
{ {
int i, x, y;
int rows;
char *text; char *text;
int row; int row, rows, i, x, y;
if (lines <= 0) if (lines <= 0)
return; return;
@ -510,13 +484,12 @@ Con_DrawConsole (int lines)
Con_DrawInput (); Con_DrawInput ();
} }
void void
Con_DrawDownload (int lines) Con_DrawDownload (int lines)
{ {
int i, j, x, y, n;
const char *text;
char dlbar[1024]; char dlbar[1024];
const char *text;
int i, j, x, y, n;
if (!cls.download) if (!cls.download)
return; return;
@ -569,11 +542,10 @@ Con_DrawDownload (int lines)
void void
Con_CompleteCommandLine (void) Con_CompleteCommandLine (void)
{ {
const char *cmd = ""; char *s;
char *s; const char *cmd = "";
int c, v, a, i;
int cmd_len;
const char **list[3] = {0, 0, 0}; const char **list[3] = {0, 0, 0};
int cmd_len, c, v, a, i;
s = key_lines[edit_line] + 1; s = key_lines[edit_line] + 1;
if (*s == '\\' || *s == '/') if (*s == '\\' || *s == '/')
@ -656,4 +628,3 @@ Con_CompleteCommandLine (void)
if (list[i]) if (list[i])
free (list[i]); free (list[i]);
} }

View file

@ -31,20 +31,21 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/vfs.h" #include "QF/vfs.h"
#include "game.h" #include "game.h"
qboolean standard_quake = false; qboolean standard_quake = false;
qboolean hipnotic, rogue, abyss; qboolean hipnotic, rogue, abyss;
/*
Game_Init
*/
void void
Game_Init (void) Game_Init (void)
{ {
int i; int i;
// FIXME: make this dependant on QF metadata in the mission packs // FIXME: make this dependant on QF metadata in the mission packs
standard_quake = true; standard_quake = true;
if ((i = COM_CheckParm ("-hipnotic"))) { if ((i = COM_CheckParm ("-hipnotic"))) {

View file

@ -31,7 +31,6 @@
#endif #endif
#include "QF/cdaudio.h" #include "QF/cdaudio.h"
#include "compat.h"
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -48,6 +47,7 @@
#include "QF/vid.h" #include "QF/vid.h"
#include "chase.h" #include "chase.h"
#include "compat.h"
#include "host.h" #include "host.h"
#include "r_local.h" #include "r_local.h"
#include "sbar.h" #include "sbar.h"
@ -61,31 +61,26 @@ extern void Host_Skin_Init (void);
extern void Host_Skin_Init_Cvars (void); extern void Host_Skin_Init_Cvars (void);
/* /*
A server can always be started, even if the system started out as a client
to a remote system.
A server can always be started, even if the system started out as a client A client can NOT be started if the system started as a dedicated server.
to a remote system.
A client can NOT be started if the system started as a dedicated server.
Memory is cleared / released when a server or client begins, not when they end.
Memory is cleared/released when a server or client begins, not when they end.
*/ */
extern int fps_count;
qboolean msg_suppress_1 = 0; qboolean msg_suppress_1 = 0;
qboolean host_initialized; // true if into command execution
quakeparms_t host_parms; quakeparms_t host_parms;
qboolean host_initialized; // true if into command execution
double host_frametime; double host_frametime;
double host_time; double host_time;
double realtime; // without any filtering or bounding double realtime; // without any filtering or bounding
double oldrealtime; // last frame run double oldrealtime; // last frame run
int host_framecount; int host_framecount;
int host_hunklevel; int host_hunklevel;
int minimum_memory; int minimum_memory;
client_t *host_client; // current client client_t *host_client; // current client
@ -94,8 +89,6 @@ jmp_buf host_abortserver;
byte *vid_basepal; byte *vid_basepal;
extern cvar_t *cl_writecfg;
cvar_t *fs_globalcfg; cvar_t *fs_globalcfg;
cvar_t *fs_usercfg; cvar_t *fs_usercfg;
@ -108,24 +101,26 @@ cvar_t *serverprofile;
cvar_t *fraglimit; cvar_t *fraglimit;
cvar_t *timelimit; cvar_t *timelimit;
cvar_t *teamplay; cvar_t *teamplay;
cvar_t *samelevel;
cvar_t *noexit; cvar_t *noexit;
cvar_t *samelevel;
cvar_t *skill; cvar_t *skill;
cvar_t *deathmatch;
cvar_t *coop; cvar_t *coop;
cvar_t *deathmatch;
cvar_t *pausable; cvar_t *pausable;
cvar_t *temp1; cvar_t *temp1;
extern cvar_t *cl_writecfg;
extern int fps_count;
void void
Host_EndGame (const char *message, ...) Host_EndGame (const char *message, ...)
{ {
va_list argptr;
char string[1024]; char string[1024];
va_list argptr;
va_start (argptr, message); va_start (argptr, message);
vsnprintf (string, sizeof (string), message, argptr); vsnprintf (string, sizeof (string), message, argptr);
@ -154,9 +149,9 @@ Host_EndGame (const char *message, ...)
void void
Host_Error (const char *error, ...) Host_Error (const char *error, ...)
{ {
va_list argptr;
char string[1024]; char string[1024];
static qboolean inerror = false; static qboolean inerror = false;
va_list argptr;
if (inerror) if (inerror)
Sys_Error ("Host_Error: recursively entered"); Sys_Error ("Host_Error: recursively entered");
@ -183,7 +178,6 @@ Host_Error (const char *error, ...)
longjmp (host_abortserver, 1); longjmp (host_abortserver, 1);
} }
void void
Host_FindMaxClients (void) Host_FindMaxClients (void)
{ {
@ -227,7 +221,6 @@ Host_FindMaxClients (void)
Cvar_SetValue (deathmatch, 0.0); Cvar_SetValue (deathmatch, 0.0);
} }
void void
Host_InitLocal (void) Host_InitLocal (void)
{ {
@ -243,17 +236,17 @@ Host_InitLocal (void)
sys_ticrate = Cvar_Get ("sys_ticrate", "0.05", CVAR_NONE, NULL, "None"); sys_ticrate = Cvar_Get ("sys_ticrate", "0.05", CVAR_NONE, NULL, "None");
serverprofile = Cvar_Get ("serverprofile", "0", CVAR_NONE, NULL, "None"); serverprofile = Cvar_Get ("serverprofile", "0", CVAR_NONE, NULL, "None");
fraglimit = Cvar_Get ("fraglimit", "0", CVAR_SERVERINFO, Cvar_Info, "None"); fraglimit = Cvar_Get ("fraglimit", "0", CVAR_SERVERINFO, Cvar_Info,
timelimit = Cvar_Get ("timelimit", "0", CVAR_SERVERINFO, Cvar_Info, "None"); "None");
timelimit = Cvar_Get ("timelimit", "0", CVAR_SERVERINFO, Cvar_Info,
"None");
teamplay = Cvar_Get ("teamplay", "0", CVAR_SERVERINFO, Cvar_Info, "None"); teamplay = Cvar_Get ("teamplay", "0", CVAR_SERVERINFO, Cvar_Info, "None");
samelevel = Cvar_Get ("samelevel", "0", CVAR_NONE, NULL, "None"); samelevel = Cvar_Get ("samelevel", "0", CVAR_NONE, NULL, "None");
noexit = Cvar_Get ("noexit", "0", CVAR_SERVERINFO, Cvar_Info, "None"); noexit = Cvar_Get ("noexit", "0", CVAR_SERVERINFO, Cvar_Info, "None");
skill = Cvar_Get ("skill", "1", CVAR_NONE, NULL, "0 - 3"); skill = Cvar_Get ("skill", "1", CVAR_NONE, NULL, "0 - 3");
deathmatch = Cvar_Get ("deathmatch", "0", CVAR_NONE, NULL, "0, 1, or 2"); deathmatch = Cvar_Get ("deathmatch", "0", CVAR_NONE, NULL, "0, 1, or 2");
coop = Cvar_Get ("coop", "0", CVAR_NONE, NULL, "0 or 1"); coop = Cvar_Get ("coop", "0", CVAR_NONE, NULL, "0 or 1");
pausable = Cvar_Get ("pausable", "1", CVAR_NONE, NULL, "None"); pausable = Cvar_Get ("pausable", "1", CVAR_NONE, NULL, "None");
temp1 = Cvar_Get ("temp1", "0", CVAR_NONE, NULL, "None"); temp1 = Cvar_Get ("temp1", "0", CVAR_NONE, NULL, "None");
Host_FindMaxClients (); Host_FindMaxClients ();
@ -261,7 +254,6 @@ Host_InitLocal (void)
host_time = 1.0; // so a think at time 0 won't get called host_time = 1.0; // so a think at time 0 won't get called
} }
/* /*
Host_WriteConfiguration Host_WriteConfiguration
@ -272,8 +264,8 @@ Host_WriteConfiguration (void)
{ {
VFile *f; VFile *f;
// dedicated servers initialize the host but don't parse and set the // dedicated servers initialize the host but don't parse and set the
// config.cfg cvars // config.cfg cvars
if (cl_writecfg->int_val && (host_initialized & !isDedicated)) { if (cl_writecfg->int_val && (host_initialized & !isDedicated)) {
char *path = va ("%s/config.cfg", com_gamedir); char *path = va ("%s/config.cfg", com_gamedir);
f = Qopen (path, "w"); f = Qopen (path, "w");
@ -289,7 +281,6 @@ Host_WriteConfiguration (void)
} }
} }
/* /*
SV_ClientPrintf SV_ClientPrintf
@ -299,8 +290,8 @@ Host_WriteConfiguration (void)
void void
SV_ClientPrintf (const char *fmt, ...) SV_ClientPrintf (const char *fmt, ...)
{ {
va_list argptr;
char string[1024]; char string[1024];
va_list argptr;
va_start (argptr, fmt); va_start (argptr, fmt);
vsnprintf (string, sizeof (string), fmt, argptr); vsnprintf (string, sizeof (string), fmt, argptr);
@ -310,7 +301,6 @@ SV_ClientPrintf (const char *fmt, ...)
MSG_WriteString (&host_client->message, string); MSG_WriteString (&host_client->message, string);
} }
/* /*
SV_BroadcastPrintf SV_BroadcastPrintf
@ -319,9 +309,9 @@ SV_ClientPrintf (const char *fmt, ...)
void void
SV_BroadcastPrintf (const char *fmt, ...) SV_BroadcastPrintf (const char *fmt, ...)
{ {
va_list argptr;
char string[1024]; char string[1024];
int i; int i;
va_list argptr;
va_start (argptr, fmt); va_start (argptr, fmt);
vsnprintf (string, sizeof (string), fmt, argptr); vsnprintf (string, sizeof (string), fmt, argptr);
@ -334,7 +324,6 @@ SV_BroadcastPrintf (const char *fmt, ...)
} }
} }
/* /*
Host_ClientCommands Host_ClientCommands
@ -343,8 +332,8 @@ SV_BroadcastPrintf (const char *fmt, ...)
void void
Host_ClientCommands (const char *fmt, ...) Host_ClientCommands (const char *fmt, ...)
{ {
va_list argptr;
char string[1024]; char string[1024];
va_list argptr;
va_start (argptr, fmt); va_start (argptr, fmt);
vsnprintf (string, sizeof (string), fmt, argptr); vsnprintf (string, sizeof (string), fmt, argptr);
@ -354,7 +343,6 @@ Host_ClientCommands (const char *fmt, ...)
MSG_WriteString (&host_client->message, string); MSG_WriteString (&host_client->message, string);
} }
/* /*
SV_DropClient SV_DropClient
@ -364,15 +352,15 @@ Host_ClientCommands (const char *fmt, ...)
void void
SV_DropClient (qboolean crash) SV_DropClient (qboolean crash)
{ {
int saveSelf;
int i;
client_t *client; client_t *client;
int saveSelf, i;
if (!crash) { if (!crash) {
// send any final messages (don't check for errors) // send any final messages (don't check for errors)
if (NET_CanSendMessage (host_client->netconnection)) { if (NET_CanSendMessage (host_client->netconnection)) {
MSG_WriteByte (&host_client->message, svc_disconnect); MSG_WriteByte (&host_client->message, svc_disconnect);
NET_SendMessage (host_client->netconnection, &host_client->message); NET_SendMessage (host_client->netconnection,
&host_client->message);
} }
if (host_client->edict && host_client->spawned) { if (host_client->edict && host_client->spawned) {
@ -388,17 +376,17 @@ SV_DropClient (qboolean crash)
Sys_Printf ("Client %s removed\n", host_client->name); Sys_Printf ("Client %s removed\n", host_client->name);
} }
// break the net connection // break the net connection
NET_Close (host_client->netconnection); NET_Close (host_client->netconnection);
host_client->netconnection = NULL; host_client->netconnection = NULL;
// free the client (the body stays around) // free the client (the body stays around)
host_client->active = false; host_client->active = false;
host_client->name[0] = 0; host_client->name[0] = 0;
host_client->old_frags = -999999; host_client->old_frags = -999999;
net_activeconnections--; net_activeconnections--;
// send notification to all clients // send notification to all clients
for (i = 0, client = svs.clients; i < svs.maxclients; i++, client++) { for (i = 0, client = svs.clients; i < svs.maxclients; i++, client++) {
if (!client->active) if (!client->active)
continue; continue;
@ -414,7 +402,6 @@ SV_DropClient (qboolean crash)
} }
} }
/* /*
Host_ShutdownServer Host_ShutdownServer
@ -423,22 +410,21 @@ SV_DropClient (qboolean crash)
void void
Host_ShutdownServer (qboolean crash) Host_ShutdownServer (qboolean crash)
{ {
int i;
int count;
sizebuf_t buf;
char message[4]; char message[4];
double start; double start;
int count, i;
sizebuf_t buf;
if (!sv.active) if (!sv.active)
return; return;
sv.active = false; sv.active = false;
// stop all client sounds immediately // stop all client sounds immediately
if (cls.state == ca_connected) if (cls.state == ca_connected)
CL_Disconnect (); CL_Disconnect ();
// flush any pending messages - like the score!!! // flush any pending messages - like the score!!!
start = Sys_DoubleTime (); start = Sys_DoubleTime ();
do { do {
count = 0; count = 0;
@ -460,7 +446,7 @@ Host_ShutdownServer (qboolean crash)
} }
while (count); while (count);
// make sure all the clients know we're disconnecting // make sure all the clients know we're disconnecting
buf.data = message; buf.data = message;
buf.maxsize = 4; buf.maxsize = 4;
buf.cursize = 0; buf.cursize = 0;
@ -476,14 +462,11 @@ Host_ShutdownServer (qboolean crash)
if (host_client->active) if (host_client->active)
SV_DropClient (crash); SV_DropClient (crash);
// // clear structures
// clear structures
//
memset (&sv, 0, sizeof (sv)); memset (&sv, 0, sizeof (sv));
memset (svs.clients, 0, svs.maxclientslimit * sizeof (client_t)); memset (svs.clients, 0, svs.maxclientslimit * sizeof (client_t));
} }
/* /*
Host_ClearMemory Host_ClearMemory
@ -504,10 +487,6 @@ Host_ClearMemory (void)
memset (&cl, 0, sizeof (cl)); memset (&cl, 0, sizeof (cl));
} }
//============================================================================
/* /*
Host_FilterTime Host_FilterTime
@ -537,7 +516,6 @@ Host_FilterTime (float time)
return true; return true;
} }
/* /*
Host_GetConsoleCommands Host_GetConsoleCommands
@ -556,20 +534,19 @@ Host_GetConsoleCommands (void)
} }
} }
#ifdef FPS_20 #ifdef FPS_20
void void
_Host_ServerFrame (void) _Host_ServerFrame (void)
{ {
// run the world state // run the world state
*sv_globals.frametime = host_frametime; *sv_globals.frametime = host_frametime;
// read client messages // read client messages
SV_RunClients (); SV_RunClients ();
// move things around and think // move things around and think
// always pause in single player if in console or menus // always pause in single player if in console or menus
if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game)) if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game))
SV_Physics (); SV_Physics ();
} }
@ -577,16 +554,15 @@ _Host_ServerFrame (void)
void void
Host_ServerFrame (void) Host_ServerFrame (void)
{ {
float save_host_frametime; float save_host_frametime, temp_host_frametime;
float temp_host_frametime;
// run the world state // run the world state
*sv_globals.frametime = host_frametime; *sv_globals.frametime = host_frametime;
// set the time and clear the general datagram // set the time and clear the general datagram
SV_ClearDatagram (); SV_ClearDatagram ();
// check for new clients // check for new clients
SV_CheckForNewClients (); SV_CheckForNewClients ();
temp_host_frametime = save_host_frametime = host_frametime; temp_host_frametime = save_host_frametime = host_frametime;
@ -600,7 +576,7 @@ Host_ServerFrame (void)
} }
host_frametime = save_host_frametime; host_frametime = save_host_frametime;
// send all messages to the clients // send all messages to the clients
SV_SendClientMessages (); SV_SendClientMessages ();
} }
@ -609,30 +585,29 @@ Host_ServerFrame (void)
void void
Host_ServerFrame (void) Host_ServerFrame (void)
{ {
// run the world state // run the world state
*sv_globals.frametime = host_frametime; *sv_globals.frametime = host_frametime;
// set the time and clear the general datagram // set the time and clear the general datagram
SV_ClearDatagram (); SV_ClearDatagram ();
// check for new clients // check for new clients
SV_CheckForNewClients (); SV_CheckForNewClients ();
// read client messages // read client messages
SV_RunClients (); SV_RunClients ();
// move things around and think // move things around and think
// always pause in single player if in console or menus // always pause in single player if in console or menus
if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game)) if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game))
SV_Physics (); SV_Physics ();
// send all messages to the clients // send all messages to the clients
SV_SendClientMessages (); SV_SendClientMessages ();
} }
#endif #endif
/* /*
Host_Frame Host_Frame
@ -641,22 +616,20 @@ Host_ServerFrame (void)
void void
_Host_Frame (float time) _Host_Frame (float time)
{ {
static double time1 = 0; static double time1 = 0, time2 = 0, time3 = 0;
static double time2 = 0; int pass1, pass2, pass3;
static double time3 = 0;
int pass1, pass2, pass3;
if (setjmp (host_abortserver)) if (setjmp (host_abortserver))
return; // something bad happened, or the return; // something bad happened, or the
// server disconnected // server disconnected
// keep the random time dependent // keep the random time dependent
rand (); rand ();
// decide the simulation time // decide the simulation time
if (!Host_FilterTime (time)) if (!Host_FilterTime (time))
return; // don't run too fast, or packets return; // don't run too fast, or packets
// will flood out // will flood out
if (cls.state != ca_dedicated) { if (cls.state != ca_dedicated) {
// get new key events // get new key events
@ -666,12 +639,12 @@ _Host_Frame (float time)
IN_Commands (); IN_Commands ();
} }
// process console commands // process console commands
Cbuf_Execute (); Cbuf_Execute ();
NET_Poll (); NET_Poll ();
// if running the server locally, make intentions now // if running the server locally, make intentions now
if (sv.active) if (sv.active)
CL_SendCmd (); CL_SendCmd ();
@ -681,7 +654,7 @@ _Host_Frame (float time)
// //
//------------------- //-------------------
// check for commands typed to the host // check for commands typed to the host
Host_GetConsoleCommands (); Host_GetConsoleCommands ();
if (sv.active) if (sv.active)
@ -693,18 +666,18 @@ _Host_Frame (float time)
// //
//------------------- //-------------------
// if running the server remotely, send intentions now after // if running the server remotely, send intentions now after
// the incoming messages have been read // the incoming messages have been read
if (!sv.active) if (!sv.active)
CL_SendCmd (); CL_SendCmd ();
host_time += host_frametime; host_time += host_frametime;
// fetch results from server // fetch results from server
if (cls.state == ca_connected) { if (cls.state == ca_connected) {
CL_ReadFromServer (); CL_ReadFromServer ();
} }
// update video // update video
if (host_speeds->int_val) if (host_speeds->int_val)
time1 = Sys_DoubleTime (); time1 = Sys_DoubleTime ();
@ -722,7 +695,7 @@ _Host_Frame (float time)
if (host_speeds->int_val) if (host_speeds->int_val)
time2 = Sys_DoubleTime (); time2 = Sys_DoubleTime ();
// update audio // update audio
if (cls.signon == SIGNONS) { if (cls.signon == SIGNONS) {
S_Update (r_origin, vpn, vright, vup); S_Update (r_origin, vpn, vright, vup);
R_DecayLights (host_frametime); R_DecayLights (host_frametime);
@ -744,14 +717,13 @@ _Host_Frame (float time)
fps_count++; fps_count++;
} }
void void
Host_Frame (float time) Host_Frame (float time)
{ {
double time1, time2; double time1, time2;
static double timetotal; static double timetotal;
static int timecount; int i, c, m;
int i, c, m; static int timecount;
if (!serverprofile->int_val) { if (!serverprofile->int_val) {
_Host_Frame (time); _Host_Frame (time);
@ -780,20 +752,16 @@ Host_Frame (float time)
Con_Printf ("serverprofile: %2i clients %2i msec\n", c, m); Con_Printf ("serverprofile: %2i clients %2i msec\n", c, m);
} }
//============================================================================
extern VFile *vcrFile; extern VFile *vcrFile;
#define VCR_SIGNATURE 0x56435231 #define VCR_SIGNATURE 0x56435231
// "VCR1" // "VCR1"
void void
Host_InitVCR (quakeparms_t *parms) Host_InitVCR (quakeparms_t *parms)
{ {
int i, len, n;
char *p; char *p;
int i, len, n;
if (COM_CheckParm ("-playback")) { if (COM_CheckParm ("-playback")) {
if (com_argc != 2) if (com_argc != 2)
@ -850,13 +818,12 @@ Host_InitVCR (quakeparms_t *parms)
} }
static int static int
check_quakerc (void) check_quakerc (void)
{ {
VFile *f;
const char *l, *p; const char *l, *p;
int ret = 1; int ret = 1;
VFile *f;
COM_FOpenFile ("quake.rc", &f); COM_FOpenFile ("quake.rc", &f);
if (!f) if (!f)
@ -873,11 +840,9 @@ check_quakerc (void)
return ret; return ret;
} }
void void
Host_Init (quakeparms_t *parms) Host_Init (quakeparms_t *parms)
{ {
if (standard_quake) if (standard_quake)
minimum_memory = MINIMUM_MEMORY; minimum_memory = MINIMUM_MEMORY;
else else
@ -1017,7 +982,6 @@ Host_Init (quakeparms_t *parms)
CL_UpdateScreen (cl.time); CL_UpdateScreen (cl.time);
} }
/* /*
Host_Shutdown Host_Shutdown
@ -1035,7 +999,7 @@ Host_Shutdown (void)
} }
isdown = true; isdown = true;
// keep Con_Printf from trying to update the screen // keep Con_Printf from trying to update the screen
scr_disabled_for_loading = true; scr_disabled_for_loading = true;
Host_WriteConfiguration (); Host_WriteConfiguration ();

View file

@ -40,10 +40,9 @@
cvar_t *registered; cvar_t *registered;
qboolean com_modified; // set true if using non-id files
int static_registered = 1; // only for startup check, then set int static_registered = 1; // only for startup check, then set
qboolean com_modified; // set true if using non-id files
qboolean msg_suppress_1 = 0; qboolean msg_suppress_1 = 0;
void COM_Path_f (void); void COM_Path_f (void);
@ -60,8 +59,8 @@ void COM_Path_f (void);
void void
COM_CheckRegistered (void) COM_CheckRegistered (void)
{ {
VFile *h;
unsigned short check[128]; unsigned short check[128];
VFile *h;
COM_FOpenFile ("gfx/pop.lmp", &h); COM_FOpenFile ("gfx/pop.lmp", &h);
static_registered = 0; static_registered = 0;
@ -78,7 +77,6 @@ COM_CheckRegistered (void)
} }
} }
void void
COM_Init (void) COM_Init (void)
{ {

View file

@ -39,7 +39,6 @@
#include <stdarg.h> #include <stdarg.h>
#include "QF/cmd.h" #include "QF/cmd.h"
#include "compat.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/draw.h" #include "QF/draw.h"
@ -51,27 +50,27 @@
#include "QF/va.h" #include "QF/va.h"
#include "client.h" #include "client.h"
#include "compat.h"
int con_ormask;
console_t con_main; console_t con_main;
console_t con_chat; console_t con_chat;
console_t *con; // point to either con_main or con_chat console_t *con; // point to either con_main or con_chat
int con_ormask;
int con_linewidth; // characters across screen int con_linewidth; // characters across screen
int con_totallines; // total lines in console scrollback int con_totallines; // total lines in console scrollback
int con_notifylines; // scan lines to clear for notify lines
float con_cursorspeed = 4; int con_vislines;
cvar_t *con_notifytime; // seconds cvar_t *con_notifytime; // seconds
#define NUM_CON_TIMES 4 #define NUM_CON_TIMES 4
float con_cursorspeed = 4;
float con_times[NUM_CON_TIMES]; // realtime time the line was generated float con_times[NUM_CON_TIMES]; // realtime time the line was generated
// for transparent notify lines // for transparent notify lines
int con_vislines;
int con_notifylines; // scan lines to clear for notify lines
qboolean con_debuglog; qboolean con_debuglog;
qboolean con_initialized;
#define MAXCMDLINE 256 #define MAXCMDLINE 256
@ -79,8 +78,6 @@ extern char key_lines[32][MAXCMDLINE];
extern int edit_line; extern int edit_line;
extern int key_linepos; extern int key_linepos;
qboolean con_initialized;
void void
Con_ToggleConsole_f (void) Con_ToggleConsole_f (void)
@ -100,7 +97,6 @@ Con_ToggleConsole_f (void)
Con_ClearNotify (); Con_ClearNotify ();
} }
void void
Con_ToggleChat_f (void) Con_ToggleChat_f (void)
{ {
@ -119,7 +115,6 @@ Con_ToggleChat_f (void)
Con_ClearNotify (); Con_ClearNotify ();
} }
void void
Con_Clear_f (void) Con_Clear_f (void)
{ {
@ -130,7 +125,6 @@ Con_Clear_f (void)
con_main.display = con_main.current; con_main.display = con_main.current;
} }
void void
Con_ClearNotify (void) Con_ClearNotify (void)
{ {
@ -140,7 +134,6 @@ Con_ClearNotify (void)
con_times[i] = 0; con_times[i] = 0;
} }
void void
Con_MessageMode_f (void) Con_MessageMode_f (void)
{ {
@ -150,7 +143,6 @@ Con_MessageMode_f (void)
key_dest = key_message; key_dest = key_message;
} }
void void
Con_MessageMode2_f (void) Con_MessageMode2_f (void)
{ {
@ -160,12 +152,11 @@ Con_MessageMode2_f (void)
key_dest = key_message; key_dest = key_message;
} }
void void
Con_Resize (console_t *con) Con_Resize (console_t *con)
{ {
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
char tbuf[CON_TEXTSIZE]; char tbuf[CON_TEXTSIZE];
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
width = (vid.width >> 3) - 2; width = (vid.width >> 3) - 2;
@ -210,7 +201,6 @@ Con_Resize (console_t *con)
con->display = con->current; con->display = con->current;
} }
/* /*
Con_CheckResize Con_CheckResize
@ -223,7 +213,6 @@ Con_CheckResize (void)
Con_Resize (&con_chat); Con_Resize (&con_chat);
} }
void void
Con_Init (const char *plugin_name) Con_Init (const char *plugin_name)
{ {
@ -248,16 +237,14 @@ Con_Init (const char *plugin_name)
con_initialized = true; con_initialized = true;
} }
void void
Con_Init_Cvars (void) Con_Init_Cvars (void)
{ {
con_notifytime = con_notifytime = Cvar_Get ("con_notifytime", "3", CVAR_NONE, NULL,
Cvar_Get ("con_notifytime", "3", CVAR_NONE, NULL, "How long in seconds messages are displayed on "
"How long in seconds messages are displayed on screen"); "screen");
} }
void void
Con_Linefeed (void) Con_Linefeed (void)
{ {
@ -271,7 +258,6 @@ Con_Linefeed (void)
' ', con_linewidth); ' ', con_linewidth);
} }
/* /*
Con_Print Con_Print
@ -282,10 +268,8 @@ Con_Linefeed (void)
void void
Con_Print (const char *txt) Con_Print (const char *txt)
{ {
int y; int mask, c, l, y;
int c, l;
static int cr; static int cr;
int mask;
// echo to debugging console // echo to debugging console
Sys_Printf ("%s", txt); Sys_Printf ("%s", txt);
@ -350,11 +334,7 @@ Con_Print (const char *txt)
} }
} }
/* DRAWING */
/*
DRAWING
*/
/* /*
Con_DrawInput Con_DrawInput
@ -364,10 +344,9 @@ Con_Print (const char *txt)
void void
Con_DrawInput (void) Con_DrawInput (void)
{ {
int y;
int i;
char *text;
char temp[MAXCMDLINE]; char temp[MAXCMDLINE];
char *text;
int i, y;
if (key_dest != key_console && cls.state == ca_active) if (key_dest != key_console && cls.state == ca_active)
return; // don't draw anything (always draw if not active) return; // don't draw anything (always draw if not active)
@ -393,7 +372,6 @@ Con_DrawInput (void)
Draw_Character ((i + 1) << 3, con_vislines - 22, text[i]); Draw_Character ((i + 1) << 3, con_vislines - 22, text[i]);
} }
/* /*
Con_DrawNotify Con_DrawNotify
@ -402,12 +380,9 @@ Con_DrawInput (void)
void void
Con_DrawNotify (void) Con_DrawNotify (void)
{ {
int x, v; char *s, *text;
char *text;
int i;
float time; float time;
char *s; int skip, i, x, v;
int skip;
v = 0; v = 0;
for (i = con->current - NUM_CON_TIMES + 1; i <= con->current; i++) { for (i = con->current - NUM_CON_TIMES + 1; i <= con->current; i++) {
@ -459,7 +434,6 @@ Con_DrawNotify (void)
con_notifylines = v; con_notifylines = v;
} }
/* /*
Con_DrawConsole Con_DrawConsole
@ -468,10 +442,8 @@ Con_DrawNotify (void)
void void
Con_DrawConsole (int lines) Con_DrawConsole (int lines)
{ {
int i, x, y;
int rows;
char *text; char *text;
int row; int row, rows, i, x, y;
if (lines <= 0) if (lines <= 0)
return; return;
@ -514,13 +486,12 @@ Con_DrawConsole (int lines)
Con_DrawInput (); Con_DrawInput ();
} }
void void
Con_DrawDownload (int lines) Con_DrawDownload (int lines)
{ {
int i, j, x, y, n;
const char *text;
char dlbar[1024]; char dlbar[1024];
const char *text;
int i, j, x, y, n;
if (!cls.download) if (!cls.download)
return; return;
@ -573,10 +544,9 @@ Con_DrawDownload (int lines)
void void
Con_CompleteCommandLine (void) Con_CompleteCommandLine (void)
{ {
const char *cmd = ""; char *s;
char *s; const char *cmd = "";
int c, v, a, i; int cmd_len, c, v, a, i;
int cmd_len;
const char **list[3] = {0, 0, 0}; const char **list[3] = {0, 0, 0};
s = key_lines[edit_line] + 1; s = key_lines[edit_line] + 1;
@ -660,4 +630,3 @@ Con_CompleteCommandLine (void)
if (list[i]) if (list[i])
free (list[i]); free (list[i]);
} }

View file

@ -38,21 +38,23 @@
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H
# include <ctype.h> # include <ctype.h>
#endif #endif
#include <dirent.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h>
#include "compat.h" #include "QF/console.h"
#include "QF/sys.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/vfs.h" #include "QF/vfs.h"
#include "QF/zone.h" #include "QF/zone.h"
#include "QF/sys.h"
#include "QF/console.h"
#include "compat.h"
#include "crudefile.h" #include "crudefile.h"
int cf_maxsize; // max combined file size (eg quota) int cf_maxsize; // max combined file size (eg quota)
int cf_cursize; // current combined file size int cf_cursize; // current combined file size
typedef struct cf_file_s { typedef struct cf_file_s {
VFile *file; VFile *file;
char *path; char *path;
@ -61,15 +63,17 @@ typedef struct cf_file_s {
int writtento; int writtento;
char mode; // 'r' for read, 'w' for write char mode; // 'r' for read, 'w' for write
} cf_file_t; } cf_file_t;
cf_file_t * cf_filep;
int cf_filepcount; // elements in array cf_file_t *cf_filep;
int cf_openfiles; // used elements cvar_t *crudefile_quota;
cvar_t *crudefile_quota; int cf_filepcount; // elements in array
int cf_openfiles; // used elements
#define CF_DIR "cf/" #define CF_DIR "cf/"
#define CF_MAXFILES 100 #define CF_MAXFILES 100
#define CF_BUFFERSIZE 256 #define CF_BUFFERSIZE 256
/* /*
CF_ValidDesc CF_ValidDesc
@ -93,12 +97,14 @@ int
CF_AlreadyOpen (const char * path, char mode) CF_AlreadyOpen (const char * path, char mode)
{ {
int i; int i;
for (i = 0; i < cf_filepcount; i++) { for (i = 0; i < cf_filepcount; i++) {
if (!cf_filep[i].file) if (!cf_filep[i].file)
continue; continue;
if (mode == 'r' && cf_filep[i].mode == 'w' && strequal(path, cf_filep[i].path)) if (mode == 'r' && cf_filep[i].mode == 'w' &&
strequal (path, cf_filep[i].path))
return 1; return 1;
if (mode == 'w' && strequal(path, cf_filep[i].path)) if (mode == 'w' && strequal (path, cf_filep[i].path))
return 1; return 1;
} }
return 0; return 0;
@ -128,12 +134,12 @@ CF_GetFileSize (const char *path)
void void
CF_BuildQuota () CF_BuildQuota ()
{ {
DIR *dir; char *file, *path;
struct dirent *i; struct dirent *i;
char *path; DIR *dir;
char *file;
path = Hunk_TempAlloc (strlen (com_gamedir) + 1 + strlen (CF_DIR) + 256 + 1); path = Hunk_TempAlloc (strlen (com_gamedir) + 1 + strlen (CF_DIR) + 256 +
1);
if (!path) if (!path)
return; return;
@ -164,7 +170,9 @@ void
CF_Init () CF_Init ()
{ {
CF_BuildQuota(); CF_BuildQuota();
crudefile_quota = Cvar_Get ("crudefile_quota", "-1", CVAR_ROM, NULL, "Maximum space available to the Crude File system, -1 to totally disable file writing"); crudefile_quota = Cvar_Get ("crudefile_quota", "-1", CVAR_ROM, NULL,
"Maximum space available to the Crude File "
"system, -1 to totally disable file writing");
cf_maxsize = crudefile_quota->int_val; cf_maxsize = crudefile_quota->int_val;
} }
@ -177,9 +185,11 @@ void
CF_CloseAllFiles () CF_CloseAllFiles ()
{ {
int i; int i;
for (i = 0; i < cf_filepcount; i++) for (i = 0; i < cf_filepcount; i++)
if (cf_filep[i].file) { if (cf_filep[i].file) {
Con_DPrintf ("Warning: closing Crude File %d left over from last map\n", i); Con_DPrintf ("Warning: closing Crude File %d left over from last "
"map\n", i);
CF_Close(i); CF_Close(i);
} }
} }
@ -194,12 +204,9 @@ CF_CloseAllFiles ()
int int
CF_Open (const char *path, const char *mode) CF_Open (const char *path, const char *mode)
{ {
char *fullpath; char *fullpath, *j;
int desc, oldsize, i;
VFile *file; VFile *file;
int desc;
int i;
char *j;
int oldsize;
if (cf_openfiles >= CF_MAXFILES) { if (cf_openfiles >= CF_MAXFILES) {
return -1; return -1;
@ -222,7 +229,8 @@ CF_Open (const char *path, const char *mode)
return -1; return -1;
} }
fullpath = malloc(strlen(com_gamedir) + 1 + strlen(CF_DIR) + strlen(path) + 1); fullpath = malloc(strlen(com_gamedir) + 1 + strlen(CF_DIR) + strlen(path) +
1);
if (!fullpath) { if (!fullpath) {
return -1; return -1;
} }
@ -320,7 +328,8 @@ CF_Read (int desc)
do { do {
int foo; int foo;
if (cf_filep[desc].size <= len) { if (cf_filep[desc].size <= len) {
char *t = realloc (cf_filep[desc].buf, cf_filep[desc].size + CF_BUFFERSIZE); char *t = realloc (cf_filep[desc].buf, cf_filep[desc].size +
CF_BUFFERSIZE);
if (!t) { if (!t) {
Sys_Error ("CF_Read: memory allocation error!"); Sys_Error ("CF_Read: memory allocation error!");
} }
@ -350,7 +359,8 @@ CF_Write (int desc, const char *buf) // should be const char *, but Qwrite isn't
{ {
int len; int len;
if (!CF_ValidDesc(desc) || cf_filep[desc].mode != 'w' || cf_cursize >= cf_maxsize) { if (!CF_ValidDesc(desc) || cf_filep[desc].mode != 'w' || cf_cursize >=
cf_maxsize) {
return 0; return 0;
} }

View file

@ -44,17 +44,18 @@
#include "QF/info.h" #include "QF/info.h"
#include "QF/qargs.h" #include "QF/qargs.h"
#include "QF/vfs.h" #include "QF/vfs.h"
#include "game.h" #include "game.h"
#include "server.h" #include "server.h"
extern qboolean is_server; extern qboolean is_server;
/* /*
SV_Gamedir_f SV_Gamedir_f
Sets the gamedir and path to a different directory. Sets the gamedir and path to a different directory.
*/ */
void void
SV_Gamedir_f (void) SV_Gamedir_f (void)
{ {
@ -86,9 +87,6 @@ SV_Gamedir_f (void)
} }
} }
/*
Game_Init
*/
void void
Game_Init (void) Game_Init (void)
{ {

View file

@ -38,7 +38,6 @@
#include <limits.h> #include <limits.h>
#include "compat.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/locs.h" #include "QF/locs.h"
#include "QF/qtypes.h" #include "QF/qtypes.h"
@ -46,25 +45,27 @@
#include "QF/vfs.h" #include "QF/vfs.h"
#include "client.h" #include "client.h"
#include "compat.h"
#define LOCATION_BLOCK 128 // 128 locations per block. #define LOCATION_BLOCK 128 // 128 locations per block.
location_t **locations = NULL; location_t **locations = NULL;
int locations_alloced = 0; int locations_alloced = 0;
int locations_count = 0; int locations_count = 0;
int location_blocks = 0; int location_blocks = 0;
void locs_add (vec3_t location, const char *name); void locs_add (vec3_t location, const char *name);
void locs_load (const char *filename); void locs_load (const char *filename);
void locs_free (void); void locs_free (void);
void locs_more (void); void locs_more (void);
int int
locs_nearest (vec3_t loc) locs_nearest (vec3_t loc)
{ {
location_t *cur;
float best_distance = 9999999, distance; float best_distance = 9999999, distance;
int i, j = -1; int i, j = -1;
location_t *cur;
for (i = 0; i < locations_count; i++) { for (i = 0; i < locations_count; i++) {
cur = locations[i]; cur = locations[i];
@ -81,6 +82,7 @@ location_t *
locs_find (vec3_t target) locs_find (vec3_t target)
{ {
int i; int i;
i = locs_nearest(target); i = locs_nearest(target);
if (i == -1) if (i == -1)
return NULL; return NULL;
@ -111,13 +113,12 @@ locs_add (vec3_t location, const char *name)
void void
locs_load (const char *filename) locs_load (const char *filename)
{ {
VFile *file; char tmp[PATH_MAX], foundname[MAX_OSPATH];
const char *line;
char *t1, *t2; char *t1, *t2;
vec3_t loc; const char *line;
char tmp[PATH_MAX];
char foundname[MAX_OSPATH];
int templength = 0; int templength = 0;
vec3_t loc;
VFile *file;
snprintf(tmp,sizeof(tmp), "maps/%s",filename); snprintf(tmp,sizeof(tmp), "maps/%s",filename);
templength = _COM_FOpenFile (tmp, &file, foundname, 1); templength = _COM_FOpenFile (tmp, &file, foundname, 1);
@ -190,9 +191,9 @@ locs_more (void)
void void
locs_save (const char *filename, qboolean gz) locs_save (const char *filename, qboolean gz)
{ {
VFile *locfd;
int i;
char locfile[MAX_OSPATH]; char locfile[MAX_OSPATH];
int i;
VFile *locfd;
if (gz) { if (gz) {
if (strncmp(filename + strlen(filename) - 3,".gz",3) != 0) if (strncmp(filename + strlen(filename) - 3,".gz",3) != 0)
@ -224,14 +225,15 @@ locs_mark (vec3_t loc, const char *desc)
/* /*
locs_edit locs_edit
call with description to modify location description call with description to modify location description
call with NULL description to modify location vectors call with NULL description to modify location vectors
*/ */
void void
locs_edit (vec3_t loc, const char *desc) locs_edit (vec3_t loc, const char *desc)
{ {
int i; int i;
if (locations_count) { if (locations_count) {
i = locs_nearest (loc); i = locs_nearest (loc);
if (!desc) { if (!desc) {
@ -252,6 +254,7 @@ void
locs_del (vec3_t loc) locs_del (vec3_t loc)
{ {
int i; int i;
if (locations_count) { if (locations_count) {
i = locs_nearest (loc); i = locs_nearest (loc);
Con_Printf ("Removing location marker for %s\n", Con_Printf ("Removing location marker for %s\n",

View file

@ -37,21 +37,21 @@
#endif #endif
#include "QF/msg.h" #include "QF/msg.h"
#include "net.h"
#include "protocol.h"
#include "QF/qendian.h" #include "QF/qendian.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "net.h"
#include "protocol.h"
struct usercmd_s nullcmd; struct usercmd_s nullcmd;
void void
MSG_WriteDeltaUsercmd (sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd) MSG_WriteDeltaUsercmd (sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
{ {
int bits; int bits;
// // send the movement message
// send the movement message
//
bits = 0; bits = 0;
if (cmd->angles[0] != from->angles[0]) if (cmd->angles[0] != from->angles[0])
bits |= CM_ANGLE1; bits |= CM_ANGLE1;
@ -102,7 +102,7 @@ MSG_ReadDeltaUsercmd (usercmd_t *from, usercmd_t *move)
bits = MSG_ReadByte (net_message); bits = MSG_ReadByte (net_message);
// read current angles // read current angles
if (bits & CM_ANGLE1) if (bits & CM_ANGLE1)
move->angles[0] = MSG_ReadAngle16 (net_message); move->angles[0] = MSG_ReadAngle16 (net_message);
if (bits & CM_ANGLE2) if (bits & CM_ANGLE2)
@ -110,7 +110,7 @@ MSG_ReadDeltaUsercmd (usercmd_t *from, usercmd_t *move)
if (bits & CM_ANGLE3) if (bits & CM_ANGLE3)
move->angles[2] = MSG_ReadAngle16 (net_message); move->angles[2] = MSG_ReadAngle16 (net_message);
// read movement // read movement
if (bits & CM_FORWARD) if (bits & CM_FORWARD)
move->forwardmove = MSG_ReadShort (net_message); move->forwardmove = MSG_ReadShort (net_message);
if (bits & CM_SIDE) if (bits & CM_SIDE)
@ -118,13 +118,13 @@ MSG_ReadDeltaUsercmd (usercmd_t *from, usercmd_t *move)
if (bits & CM_UP) if (bits & CM_UP)
move->upmove = MSG_ReadShort (net_message); move->upmove = MSG_ReadShort (net_message);
// read buttons // read buttons
if (bits & CM_BUTTONS) if (bits & CM_BUTTONS)
move->buttons = MSG_ReadByte (net_message); move->buttons = MSG_ReadByte (net_message);
if (bits & CM_IMPULSE) if (bits & CM_IMPULSE)
move->impulse = MSG_ReadByte (net_message); move->impulse = MSG_ReadByte (net_message);
// read time to run command // read time to run command
move->msec = MSG_ReadByte (net_message); move->msec = MSG_ReadByte (net_message);
} }

View file

@ -30,7 +30,9 @@
# include "config.h" # include "config.h"
#endif #endif
#ifndef _WIN32 #ifndef _WIN32
# include <unistd.h> # ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
#else #else
# include <windows.h> # include <windows.h>
#endif #endif
@ -41,76 +43,72 @@
# include <strings.h> # include <strings.h>
#endif #endif
#include <time.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h>
#include "client.h"
#include "compat.h"
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "client.h"
#include "compat.h"
#include "net.h" #include "net.h"
#define PACKET_HEADER 8 #define PACKET_HEADER 8
/* /*
packet header
-------------
31 sequence
1 does this message contain a reliable payload
31 acknowledge sequence
1 acknowledge receipt of even/odd message
16 qport
packet header The remote connection never knows if it missed a reliable message, the
------------- local side detects that it has been dropped by seeing a sequence acknowledge
31 sequence higher thatn the last reliable sequence, but without the correct evon/odd
1 does this message contain a reliable payload bit for the reliable set.
31 acknowledge sequence
1 acknowledge receipt of even/odd message
16 qport
The remote connection never knows if it missed a reliable message, the If the sender notices that a reliable message has been dropped, it will be
local side detects that it has been dropped by seeing a sequence acknowledge retransmitted. It will not be retransmitted again until a message after the
higher thatn the last reliable sequence, but without the correct evon/odd retransmit has been acknowledged and the reliable still failed to get there.
bit for the reliable set.
If the sender notices that a reliable message has been dropped, it will be if the sequence number is -1, the packet should be handled without a netcon
retransmitted. It will not be retransmitted again until a message after
the retransmit has been acknowledged and the reliable still failed to get there.
if the sequence number is -1, the packet should be handled without a netcon The reliable message can be added to at any time by doing
MSG_Write* (&netchan->message, <data>).
The reliable message can be added to at any time by doing If the message buffer is overflowed, either by a single message, or by
MSG_Write* (&netchan->message, <data>). multiple frames worth piling up while the last reliable transmit goes
unacknowledged, the netchan signals a fatal error.
If the message buffer is overflowed, either by a single message, or by Reliable messages are always placed first in a packet, then the unreliable
multiple frames worth piling up while the last reliable transmit goes message is included if there is sufficient room.
unacknowledged, the netchan signals a fatal error.
Reliable messages are always placed first in a packet, then the unreliable To the receiver, there is no distinction between the reliable and unreliable
message is included if there is sufficient room. parts of the message, they are just processed out as a single larger message.
To the receiver, there is no distinction between the reliable and unreliable Illogical packet sequence numbers cause the packet to be dropped, but do
parts of the message, they are just processed out as a single larger message. not kill the connection. This, combined with the tight window of valid
reliable acknowledgement numbers provides protection against malicious
Illogical packet sequence numbers cause the packet to be dropped, but do address spoofing.
not kill the connection. This, combined with the tight window of valid
reliable acknowledgement numbers provides protection against malicious
address spoofing.
The qport field is a workaround for bad address translating routers that
sometimes remap the client's source port on a packet during gameplay.
If the base part of the net address matches and the qport matches, then the
channel matches even if the IP port differs. The IP port should be updated
to the new value before sending out any replies.
The qport field is a workaround for bad address translating routers that
sometimes remap the client's source port on a packet during gameplay.
If the base part of the net address matches and the qport matches, then the
channel matches even if the IP port differs. The IP port should be updated
to the new value before sending out any replies.
*/ */
int net_drop; int net_drop;
cvar_t *showpackets; cvar_t *showpackets;
cvar_t *showdrop; cvar_t *showdrop;
cvar_t *qport; cvar_t *qport;
extern qboolean is_server; extern qboolean is_server;
/*
Netchan_Init
*/
void void
Netchan_Init (void) Netchan_Init (void)
{ {
@ -130,12 +128,14 @@ void
Netchan_Init_Cvars (void) Netchan_Init_Cvars (void)
{ {
showpackets = Cvar_Get ("showpackets", "0", CVAR_NONE, NULL, showpackets = Cvar_Get ("showpackets", "0", CVAR_NONE, NULL,
"Show all network packets"); "Show all network packets");
showdrop = Cvar_Get ("showdrop", "0", CVAR_NONE, NULL, showdrop = Cvar_Get ("showdrop", "0", CVAR_NONE, NULL, "Toggle the "
"Toggle the display of how many packets you are dropping"); "display of how many packets you are dropping");
qport = Cvar_Get ("qport", "0", CVAR_NONE, NULL, qport = Cvar_Get ("qport", "0", CVAR_NONE, NULL, "The internal port "
"The internal port number for the game networking code." "number for the game networking code. Useful for "
"Useful for clients who use multiple connections through one IP address (NAT/IP-MASQ) because default port is random."); "clients who use multiple connections through one "
"IP address (NAT/IP-MASQ) because default port is "
"random.");
} }
/* /*
@ -146,10 +146,10 @@ Netchan_Init_Cvars (void)
void void
Netchan_OutOfBand (netadr_t adr, int length, byte * data) Netchan_OutOfBand (netadr_t adr, int length, byte * data)
{ {
sizebuf_t send;
byte send_buf[MAX_MSGLEN + PACKET_HEADER]; byte send_buf[MAX_MSGLEN + PACKET_HEADER];
sizebuf_t send;
// write the packet header // write the packet header
send.data = send_buf; send.data = send_buf;
send.maxsize = sizeof (send_buf); send.maxsize = sizeof (send_buf);
send.cursize = 0; send.cursize = 0;
@ -157,7 +157,7 @@ Netchan_OutOfBand (netadr_t adr, int length, byte * data)
MSG_WriteLong (&send, -1); // -1 sequence means out of band MSG_WriteLong (&send, -1); // -1 sequence means out of band
SZ_Write (&send, data, length); SZ_Write (&send, data, length);
// send the datagram // send the datagram
// zoid, no input in demo playback mode // zoid, no input in demo playback mode
if (!is_server) { if (!is_server) {
if (!cls.demoplayback) if (!cls.demoplayback)
@ -175,8 +175,8 @@ Netchan_OutOfBand (netadr_t adr, int length, byte * data)
void void
Netchan_OutOfBandPrint (netadr_t adr, const char *format, ...) Netchan_OutOfBandPrint (netadr_t adr, const char *format, ...)
{ {
va_list argptr;
static char string[8192]; // ?? why static? static char string[8192]; // ?? why static?
va_list argptr;
va_start (argptr, format); va_start (argptr, format);
vsnprintf (string, sizeof (string), format, argptr); vsnprintf (string, sizeof (string), format, argptr);
@ -186,7 +186,6 @@ Netchan_OutOfBandPrint (netadr_t adr, const char *format, ...)
Netchan_OutOfBand (adr, strlen (string), (byte *) string); Netchan_OutOfBand (adr, strlen (string), (byte *) string);
} }
/* /*
Netchan_Setup Netchan_Setup
@ -209,13 +208,13 @@ Netchan_Setup (netchan_t *chan, netadr_t adr, int qport)
chan->rate = 1.0 / 2500; chan->rate = 1.0 / 2500;
} }
#define MAX_BACKUP 200
/* /*
Netchan_CanPacket Netchan_CanPacket
Returns true if the bandwidth choke isn't active Returns true if the bandwidth choke isn't active
*/ */
#define MAX_BACKUP 200
qboolean qboolean
Netchan_CanPacket (netchan_t *chan) Netchan_CanPacket (netchan_t *chan)
{ {
@ -224,7 +223,6 @@ Netchan_CanPacket (netchan_t *chan)
return false; return false;
} }
/* /*
Netchan_CanReliable Netchan_CanReliable
@ -246,32 +244,32 @@ qboolean ServerPaused (void);
tries to send an unreliable message to a connection, and handles the tries to send an unreliable message to a connection, and handles the
transmition / retransmition of the reliable messages. transmition / retransmition of the reliable messages.
A 0 length will still generate a packet and deal with the reliable messages. 0 length will still generate a packet and deal with the reliable messages.
*/ */
void void
Netchan_Transmit (netchan_t *chan, int length, byte * data) Netchan_Transmit (netchan_t *chan, int length, byte * data)
{ {
sizebuf_t send;
byte send_buf[MAX_MSGLEN + PACKET_HEADER]; byte send_buf[MAX_MSGLEN + PACKET_HEADER];
qboolean send_reliable;
unsigned int w1, w2;
int i; int i;
unsigned int w1, w2;
qboolean send_reliable;
sizebuf_t send;
// check for message overflow // check for message overflow
if (chan->message.overflowed) { if (chan->message.overflowed) {
chan->fatal_error = true; chan->fatal_error = true;
Con_Printf ("%s:Outgoing message overflow\n", Con_Printf ("%s:Outgoing message overflow\n",
NET_AdrToString (chan->remote_address)); NET_AdrToString (chan->remote_address));
return; return;
} }
// if the remote side dropped the last reliable message, resend it // if the remote side dropped the last reliable message, resend it
send_reliable = false; send_reliable = false;
if (chan->incoming_acknowledged > chan->last_reliable_sequence if (chan->incoming_acknowledged > chan->last_reliable_sequence
&& chan->incoming_reliable_acknowledged != chan->reliable_sequence) && chan->incoming_reliable_acknowledged != chan->reliable_sequence)
send_reliable = true; send_reliable = true;
// if the reliable transmit buffer is empty, copy the current message out // if the reliable transmit buffer is empty, copy the current message out
if (!chan->reliable_length && chan->message.cursize) { if (!chan->reliable_length && chan->message.cursize) {
memcpy (chan->reliable_buf, chan->message_buf, chan->message.cursize); memcpy (chan->reliable_buf, chan->message_buf, chan->message.cursize);
chan->reliable_length = chan->message.cursize; chan->reliable_length = chan->message.cursize;
@ -279,7 +277,7 @@ Netchan_Transmit (netchan_t *chan, int length, byte * data)
chan->reliable_sequence ^= 1; chan->reliable_sequence ^= 1;
send_reliable = true; send_reliable = true;
} }
// write the packet header // write the packet header
send.data = send_buf; send.data = send_buf;
send.maxsize = sizeof (send_buf); send.maxsize = sizeof (send_buf);
send.cursize = 0; send.cursize = 0;
@ -296,16 +294,16 @@ Netchan_Transmit (netchan_t *chan, int length, byte * data)
if (!is_server) if (!is_server)
MSG_WriteShort (&send, cls.qport); MSG_WriteShort (&send, cls.qport);
// copy the reliable message to the packet first // copy the reliable message to the packet first
if (send_reliable) { if (send_reliable) {
SZ_Write (&send, chan->reliable_buf, chan->reliable_length); SZ_Write (&send, chan->reliable_buf, chan->reliable_length);
chan->last_reliable_sequence = chan->outgoing_sequence; chan->last_reliable_sequence = chan->outgoing_sequence;
} }
// add the unreliable part if space is available // add the unreliable part if space is available
if (send.maxsize - send.cursize >= length) if (send.maxsize - send.cursize >= length)
SZ_Write (&send, data, length); SZ_Write (&send, data, length);
// send the datagram // send the datagram
i = chan->outgoing_sequence & (MAX_LATENT - 1); i = chan->outgoing_sequence & (MAX_LATENT - 1);
chan->outgoing_size[i] = send.cursize; chan->outgoing_size[i] = send.cursize;
chan->outgoing_time[i] = realtime; chan->outgoing_time[i] = realtime;
@ -328,7 +326,6 @@ Netchan_Transmit (netchan_t *chan, int length, byte * data)
Con_Printf ("--> s=%i(%i) a=%i(%i) %i\n", chan->outgoing_sequence, Con_Printf ("--> s=%i(%i) a=%i(%i) %i\n", chan->outgoing_sequence,
send_reliable, chan->incoming_sequence, send_reliable, chan->incoming_sequence,
chan->incoming_reliable_sequence, send.cursize); chan->incoming_reliable_sequence, send.cursize);
} }
/* /*
@ -340,9 +337,8 @@ Netchan_Transmit (netchan_t *chan, int length, byte * data)
qboolean qboolean
Netchan_Process (netchan_t *chan) Netchan_Process (netchan_t *chan)
{ {
unsigned int sequence, sequence_ack; int qport;
unsigned int reliable_ack, reliable_message; unsigned int reliable_ack, reliable_message, sequence, sequence_ack;
int qport;
if (is_server) { if (is_server) {
if (!NET_CompareAdr (net_from, chan->remote_address)) if (!NET_CompareAdr (net_from, chan->remote_address))
@ -352,7 +348,7 @@ Netchan_Process (netchan_t *chan)
!NET_CompareAdr (net_from, chan->remote_address)) return false; !NET_CompareAdr (net_from, chan->remote_address)) return false;
} }
// get sequence numbers // get sequence numbers
MSG_BeginReading (net_message); MSG_BeginReading (net_message);
sequence = MSG_ReadLong (net_message); sequence = MSG_ReadLong (net_message);
sequence_ack = MSG_ReadLong (net_message); sequence_ack = MSG_ReadLong (net_message);
@ -371,7 +367,7 @@ Netchan_Process (netchan_t *chan)
Con_Printf ("<-- s=%i(%i) a=%i(%i) %i\n", sequence, reliable_message, Con_Printf ("<-- s=%i(%i) a=%i(%i) %i\n", sequence, reliable_message,
sequence_ack, reliable_ack, net_message->message->cursize); sequence_ack, reliable_ack, net_message->message->cursize);
// get a rate estimation // get a rate estimation
#if 0 #if 0
if (chan->outgoing_sequence - sequence_ack < MAX_LATENT) { if (chan->outgoing_sequence - sequence_ack < MAX_LATENT) {
int i; int i;
@ -398,9 +394,7 @@ Netchan_Process (netchan_t *chan)
} }
#endif #endif
// // discard stale or duplicated packets
// discard stale or duplicated packets
//
if (sequence <= (unsigned int) chan->incoming_sequence) { if (sequence <= (unsigned int) chan->incoming_sequence) {
if (showdrop->int_val) if (showdrop->int_val)
Con_Printf ("%s:Out of order packet %i at %i\n", Con_Printf ("%s:Out of order packet %i at %i\n",
@ -408,9 +402,8 @@ Netchan_Process (netchan_t *chan)
chan->incoming_sequence); chan->incoming_sequence);
return false; return false;
} }
//
// dropped packets don't keep the message from being used // dropped packets don't keep the message from being used
//
net_drop = sequence - (chan->incoming_sequence + 1); net_drop = sequence - (chan->incoming_sequence + 1);
if (net_drop > 0) { if (net_drop > 0) {
chan->drop_count += 1; chan->drop_count += 1;
@ -421,26 +414,22 @@ Netchan_Process (netchan_t *chan)
sequence - (chan->incoming_sequence + 1) sequence - (chan->incoming_sequence + 1)
, sequence); , sequence);
} }
//
// if the current outgoing reliable message has been acknowledged // if the current outgoing reliable message has been acknowledged
// clear the buffer to make way for the next // clear the buffer to make way for the next
//
if (reliable_ack == (unsigned int) chan->reliable_sequence) if (reliable_ack == (unsigned int) chan->reliable_sequence)
chan->reliable_length = 0; // it has been received chan->reliable_length = 0; // it has been received
// // if this message contains a reliable message, bump
// if this message contains a reliable message, bump incoming_reliable_sequence // incoming_reliable_sequence
//
chan->incoming_sequence = sequence; chan->incoming_sequence = sequence;
chan->incoming_acknowledged = sequence_ack; chan->incoming_acknowledged = sequence_ack;
chan->incoming_reliable_acknowledged = reliable_ack; chan->incoming_reliable_acknowledged = reliable_ack;
if (reliable_message) if (reliable_message)
chan->incoming_reliable_sequence ^= 1; chan->incoming_reliable_sequence ^= 1;
// // the message can now be read from the current message pointer
// the message can now be read from the current message pointer // update statistics counters
// update statistics counters
//
chan->frame_latency = chan->frame_latency * OLD_AVG chan->frame_latency = chan->frame_latency * OLD_AVG
+ (chan->outgoing_sequence - sequence_ack) * (1.0 - OLD_AVG); + (chan->outgoing_sequence - sequence_ack) * (1.0 - OLD_AVG);
chan->frame_rate = chan->frame_rate * OLD_AVG chan->frame_rate = chan->frame_rate * OLD_AVG

View file

@ -31,12 +31,18 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#ifdef HAVE_IO_H
# include <io.h>
#endif
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H
# include <string.h> # include <string.h>
#endif #endif
#ifdef HAVE_STRINGS_H #ifdef HAVE_STRINGS_H
# include <strings.h> # include <strings.h>
#endif #endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
// FIXME: we did support Quake1 protocol too... // FIXME: we did support Quake1 protocol too...
@ -44,12 +50,6 @@
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
#include "QF/cmd.h" #include "QF/cmd.h"
#include "QF/cvar.h" #include "QF/cvar.h"
@ -68,14 +68,13 @@ cvar_t *net_loglevel;
//extern server_t sv; //extern server_t sv;
extern qboolean is_server; extern qboolean is_server;
void Analyze_Server_Packet (const byte * data, int len);
void Analyze_Client_Packet (const byte * data, int len);
void Parse_Server_Packet (void);
void Parse_Client_Packet (void);
int Net_LogStart (const char *fname); int Net_LogStart (const char *fname);
void Net_LogStop (void);
void Analyze_Server_Packet (const byte * data, int len);
void Analyze_Client_Packet (const byte * data, int len);
void Parse_Server_Packet (void);
void Parse_Client_Packet (void);
void Net_LogStop (void);
// note: this is SUPPOSED to be duplicate, like many others // note: this is SUPPOSED to be duplicate, like many others
const char *svc_string[] = { const char *svc_string[] = {
@ -93,7 +92,6 @@ const char *svc_string[] = {
// should be \n terminated // should be \n terminated
"svc_setangle", // [vec3] set the view angle to this "svc_setangle", // [vec3] set the view angle to this
// absolute value // absolute value
"svc_serverdata", // [long] version ... "svc_serverdata", // [long] version ...
"svc_lightstyle", // [byte] [string] "svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string] "svc_updatename", // [byte] [string]
@ -104,11 +102,9 @@ const char *svc_string[] = {
"svc_particle", // [vec3] <variable> "svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3] "svc_damage", // [byte] impact [byte] blood [vec3]
// from // from
"svc_spawnstatic", "svc_spawnstatic",
"svc_spawnbinary", "svc_spawnbinary",
"svc_spawnbaseline", "svc_spawnbaseline",
"svc_temp_entity", // <variable> "svc_temp_entity", // <variable>
"svc_setpause", "svc_setpause",
"svc_signonnum", "svc_signonnum",
@ -120,13 +116,10 @@ const char *svc_string[] = {
"svc_finale", // [string] music [string] text "svc_finale", // [string] music [string] text
"svc_cdtrack", // [byte] track [byte] looptrack "svc_cdtrack", // [byte] track [byte] looptrack
"svc_sellscreen", "svc_sellscreen",
"svc_smallkick", // Quake svc_cutscene "svc_smallkick", // Quake svc_cutscene
"svc_bigkick", "svc_bigkick",
"svc_updateping", "svc_updateping",
"svc_updateentertime", "svc_updateentertime",
"svc_updatestatlong", "svc_updatestatlong",
"svc_muzzleflash", "svc_muzzleflash",
"svc_updateuserinfo", "svc_updateuserinfo",
@ -140,7 +133,6 @@ const char *svc_string[] = {
"svc_deltapacketentities", "svc_deltapacketentities",
"svc_maxspeed", "svc_maxspeed",
"svc_entgravity", "svc_entgravity",
"svc_setinfo", "svc_setinfo",
"svc_serverinfo", "svc_serverinfo",
"svc_updatepl", "svc_updatepl",
@ -171,7 +163,7 @@ const char *clc_string[] = {
}; };
#ifndef svc_spawnbinary #ifndef svc_spawnbinary
#define svc_spawnbinary 21 # define svc_spawnbinary 21
#endif #endif
// Quake1, obsolete for QW // Quake1, obsolete for QW
@ -189,17 +181,17 @@ static const char **Net_sound_precache;
static sizebuf_t _packet; static sizebuf_t _packet;
static msg_t packet = {0, 0, &_packet}; static msg_t packet = {0, 0, &_packet};
/* /*
NET_LogPrintf NET_LogPrintf
Prints packet to logfile, adds time stamp etc. Prints packet to logfile, adds time stamp etc.
*/ */
void void
Net_LogPrintf (char *fmt, ...) Net_LogPrintf (char *fmt, ...)
{ {
va_list argptr;
char text[2048]; char text[2048];
va_list argptr;
va_start (argptr, fmt); va_start (argptr, fmt);
vsnprintf (text, sizeof (text), fmt, argptr); vsnprintf (text, sizeof (text), fmt, argptr);
@ -277,17 +269,15 @@ Log_Incoming_Packet (const char *p, int len)
return; return;
if (is_server) { if (is_server) {
Net_LogPrintf Net_LogPrintf ("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: "
("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: <<<<<<<<<<<<<<<<<<<<<<<<\n", "<<<<<<<<<<<<<<<<<<<<<<<<\n", len);
len);
if (net_loglevel->int_val != 3) if (net_loglevel->int_val != 3)
hex_dump_buf ((unsigned char *) p, len); hex_dump_buf ((unsigned char *) p, len);
if (net_loglevel->int_val > 1) if (net_loglevel->int_val > 1)
Analyze_Client_Packet (p, len); Analyze_Client_Packet (p, len);
} else { } else {
Net_LogPrintf Net_LogPrintf ("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: "
("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: >>>>>>>>>>>>>>>>>>>>>>>>\n", ">>>>>>>>>>>>>>>>>>>>>>>>\n", len);
len);
if (net_loglevel->int_val != 3) if (net_loglevel->int_val != 3)
hex_dump_buf ((unsigned char *) p, len);; hex_dump_buf ((unsigned char *) p, len);;
if (net_loglevel->int_val > 1) if (net_loglevel->int_val > 1)
@ -303,17 +293,15 @@ Log_Outgoing_Packet (const char *p, int len)
return; return;
if (is_server) { if (is_server) {
Net_LogPrintf Net_LogPrintf ("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: "
("\n>>>>>>>>>>>>>>>>>>>>> server to client %d bytes: >>>>>>>>>>>>>>>>>>>>>>>>\n", ">>>>>>>>>>>>>>>>>>>>>>>>\n", len);
len);
if (net_loglevel->int_val != 3) if (net_loglevel->int_val != 3)
hex_dump_buf ((unsigned char *) p, len);; hex_dump_buf ((unsigned char *) p, len);;
if (net_loglevel->int_val > 1) if (net_loglevel->int_val > 1)
Analyze_Server_Packet (p, len); Analyze_Server_Packet (p, len);
} else { } else {
Net_LogPrintf Net_LogPrintf ("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: "
("\n<<<<<<<<<<<<<<<<<<<<< client to server %d bytes: <<<<<<<<<<<<<<<<<<<<<<<<\n", "<<<<<<<<<<<<<<<<<<<<<<<<\n", len);
len);
if (net_loglevel->int_val != 3) if (net_loglevel->int_val != 3)
hex_dump_buf ((unsigned char *) p, len);; hex_dump_buf ((unsigned char *) p, len);;
if (net_loglevel->int_val > 1) if (net_loglevel->int_val > 1)
@ -325,10 +313,10 @@ Log_Outgoing_Packet (const char *p, int len)
void void
Log_Delta(int bits) Log_Delta(int bits)
{ {
entity_state_t to; entity_state_t to;
int i; int i;
Net_LogPrintf ("\n\t"); Net_LogPrintf ("\n\t");
// set everything to the state we are delta'ing from // set everything to the state we are delta'ing from
@ -426,9 +414,9 @@ Analyze_Server_Packet (const byte * data, int len)
void void
Parse_Server_Packet () Parse_Server_Packet ()
{ {
long seq1, seq2;
int c, i, ii, iii, mask1, mask2;
char *s; char *s;
int c, i, ii, iii, mask1, mask2;
long seq1, seq2;
seq1 = MSG_ReadLong (&packet); seq1 = MSG_ReadLong (&packet);
if (packet.badread) if (packet.badread)
@ -455,12 +443,12 @@ Parse_Server_Packet ()
c = MSG_ReadByte (&packet); c = MSG_ReadByte (&packet);
if (c == -1) if (c == -1)
break; break;
// Net_LogPrintf("\n<%ld,%ld> ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF); // Net_LogPrintf("\n<%ld,%ld> ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF);
Net_LogPrintf ("<%06x> [0x%02x] ", MSG_GetReadCount (&packet), c); Net_LogPrintf ("<%06x> [0x%02x] ", MSG_GetReadCount (&packet), c);
if (c < 53) if (c < 53)
Net_LogPrintf ("%s: ", svc_string[c]); Net_LogPrintf ("%s: ", svc_string[c]);
// else Net_LogPrintf("(UNK: %d): ",c); // else Net_LogPrintf("(UNK: %d): ",c);
if (MSG_GetReadCount (&packet) > packet.message->cursize) if (MSG_GetReadCount (&packet) > packet.message->cursize)
return; return;
@ -476,7 +464,8 @@ Parse_Server_Packet ()
break; break;
case svc_updatestat: case svc_updatestat:
i = MSG_ReadByte (&packet); i = MSG_ReadByte (&packet);
Net_LogPrintf (" index: %d value: %d", i, MSG_ReadByte (&packet)); Net_LogPrintf (" index: %d value: %d", i, MSG_ReadByte
(&packet));
break; break;
case svc_version: case svc_version:
#ifdef QUAKEWORLD #ifdef QUAKEWORLD
@ -552,7 +541,8 @@ Parse_Server_Packet ()
#endif #endif
break; break;
case svc_updatefrags: case svc_updatefrags:
Net_LogPrintf ("player: %d frags: %d", MSG_ReadByte (&packet), Net_LogPrintf ("player: %d frags: %d", MSG_ReadByte
(&packet),
MSG_ReadShort (&packet)); MSG_ReadShort (&packet));
break; break;
case svc_clientdata: case svc_clientdata:
@ -568,7 +558,8 @@ Parse_Server_Packet ()
#ifdef QUAKEWORLD #ifdef QUAKEWORLD
Net_LogPrintf ("**QW OBSOLETE**"); Net_LogPrintf ("**QW OBSOLETE**");
#else #else
Net_LogPrintf ("%d %d", MSG_ReadByte (&packet), MSG_ReadByte ()); Net_LogPrintf ("%d %d", MSG_ReadByte (&packet),
MSG_ReadByte ());
#endif #endif
break; break;
case svc_particle: case svc_particle:
@ -586,19 +577,20 @@ Parse_Server_Packet ()
case svc_damage: case svc_damage:
// FIXME: parse damage // FIXME: parse damage
Net_LogPrintf ("armor: %d health: %d", MSG_ReadByte (&packet), Net_LogPrintf ("armor: %d health: %d", MSG_ReadByte
MSG_ReadByte (&packet)); (&packet), MSG_ReadByte (&packet));
Net_LogPrintf (" from %f,%f,%f", MSG_ReadCoord (&packet), Net_LogPrintf (" from %f,%f,%f", MSG_ReadCoord (&packet),
MSG_ReadCoord (&packet), MSG_ReadCoord (&packet)); MSG_ReadCoord (&packet), MSG_ReadCoord
(&packet));
break; break;
case svc_spawnstatic: case svc_spawnstatic:
Net_LogPrintf ("Model: %d", MSG_ReadByte (&packet)); Net_LogPrintf ("Model: %d", MSG_ReadByte (&packet));
Net_LogPrintf (" Frame: %d Color: %d Skin: %", Net_LogPrintf (" Frame: %d Color: %d Skin: %",
MSG_ReadByte (&packet), MSG_ReadByte (&packet), MSG_ReadByte (&packet), MSG_ReadByte
MSG_ReadByte (&packet)); (&packet), MSG_ReadByte (&packet));
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
Net_LogPrintf ("%d: %f %f", i + 1, MSG_ReadCoord (&packet), Net_LogPrintf ("%d: %f %f", i + 1, MSG_ReadCoord
MSG_ReadAngle (&packet)); (&packet), MSG_ReadAngle (&packet));
break; break;
case svc_spawnbinary: case svc_spawnbinary:
Net_LogPrintf ("**OBSOLETE**"); Net_LogPrintf ("**OBSOLETE**");
@ -626,25 +618,30 @@ Parse_Server_Packet ()
case 10: case 10:
case 11: case 11:
case 13: case 13:
Net_LogPrintf (" origin %f %f %f", MSG_ReadCoord (&packet), Net_LogPrintf (" origin %f %f %f", MSG_ReadCoord
MSG_ReadCoord (&packet), MSG_ReadCoord (&packet)); (&packet), MSG_ReadCoord (&packet),
MSG_ReadCoord (&packet));
break; break;
case 5: case 5:
case 6: case 6:
case 9: case 9:
Net_LogPrintf (" created by %d", MSG_ReadShort (&packet)); Net_LogPrintf (" created by %d", MSG_ReadShort
Net_LogPrintf (" origin: %f,%f,%f", (&packet));
MSG_ReadCoord (&packet), MSG_ReadCoord (&packet), Net_LogPrintf (" origin: %f,%f,%f", MSG_ReadCoord
(&packet), MSG_ReadCoord (&packet),
MSG_ReadCoord (&packet)); MSG_ReadCoord (&packet));
Net_LogPrintf (" trace endpos: %f,%f,%f", Net_LogPrintf (" trace endpos: %f,%f,%f",
MSG_ReadCoord (&packet), MSG_ReadCoord (&packet), MSG_ReadCoord (&packet),
MSG_ReadCoord (&packet),
MSG_ReadCoord (&packet)); MSG_ReadCoord (&packet));
break; break;
case 2: case 2:
case 12: case 12:
Net_LogPrintf (" count: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" count: %d", MSG_ReadByte
printf (" origin: %f,%f,%f", MSG_ReadCoord (&packet), (&packet));
MSG_ReadCoord (&packet), MSG_ReadCoord (&packet)); printf (" origin: %f,%f,%f", MSG_ReadCoord
(&packet), MSG_ReadCoord (&packet),
MSG_ReadCoord (&packet));
break; break;
default: default:
Net_LogPrintf (" unknown value %d for tempentity", Net_LogPrintf (" unknown value %d for tempentity",
@ -672,8 +669,10 @@ Parse_Server_Packet ()
break; break;
case svc_spawnstaticsound: case svc_spawnstaticsound:
Net_LogPrintf ("pos %f,%f,%f", MSG_ReadCoord (&packet), Net_LogPrintf ("pos %f,%f,%f", MSG_ReadCoord (&packet),
MSG_ReadCoord (&packet), MSG_ReadCoord (&packet)); MSG_ReadCoord (&packet), MSG_ReadCoord
Net_LogPrintf ("%d %d %d", MSG_ReadByte (&packet), MSG_ReadByte (&packet), (&packet));
Net_LogPrintf ("%d %d %d", MSG_ReadByte (&packet),
MSG_ReadByte (&packet),
MSG_ReadByte (&packet)); MSG_ReadByte (&packet));
break; break;
case svc_intermission: case svc_intermission:
@ -720,7 +719,8 @@ Parse_Server_Packet ()
break; break;
case svc_download: case svc_download:
ii = MSG_ReadShort (&packet); ii = MSG_ReadShort (&packet);
Net_LogPrintf ("%d bytes at %d", ii, MSG_ReadByte (&packet)); Net_LogPrintf ("%d bytes at %d", ii, MSG_ReadByte
(&packet));
for (i = 0; i < ii; i++) for (i = 0; i < ii; i++)
MSG_ReadByte (&packet); MSG_ReadByte (&packet);
break; break;
@ -728,8 +728,9 @@ Parse_Server_Packet ()
Net_LogPrintf ("\n\tPlayer: %d", MSG_ReadByte (&packet)); Net_LogPrintf ("\n\tPlayer: %d", MSG_ReadByte (&packet));
mask1 = MSG_ReadShort (&packet); mask1 = MSG_ReadShort (&packet);
Net_LogPrintf (" Mask1: %d", mask1); Net_LogPrintf (" Mask1: %d", mask1);
Net_LogPrintf (" Origin: %f,%f,%f", MSG_ReadCoord (&packet), Net_LogPrintf (" Origin: %f,%f,%f", MSG_ReadCoord
MSG_ReadCoord (&packet), MSG_ReadCoord (&packet)); (&packet), MSG_ReadCoord (&packet),
MSG_ReadCoord (&packet));
Net_LogPrintf (" Frame: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" Frame: %d", MSG_ReadByte (&packet));
if (mask1 & PF_MSEC) if (mask1 & PF_MSEC)
@ -738,21 +739,29 @@ Parse_Server_Packet ()
if (mask1 & PF_COMMAND) { if (mask1 & PF_COMMAND) {
mask2 = MSG_ReadByte (&packet); // command mask2 = MSG_ReadByte (&packet); // command
if (mask2 & 0x01) if (mask2 & 0x01)
Net_LogPrintf (" Pitch: %f", MSG_ReadAngle16 (&packet)); Net_LogPrintf (" Pitch: %f", MSG_ReadAngle16
(&packet));
if (mask2 & 0x80) if (mask2 & 0x80)
Net_LogPrintf (" Yaw: %f", MSG_ReadAngle16 (&packet)); Net_LogPrintf (" Yaw: %f", MSG_ReadAngle16
(&packet));
if (mask2 & 0x02) if (mask2 & 0x02)
Net_LogPrintf (" Roll: %f", MSG_ReadAngle16 (&packet)); Net_LogPrintf (" Roll: %f", MSG_ReadAngle16
(&packet));
if (mask2 & 0x04) if (mask2 & 0x04)
Net_LogPrintf (" Speed1: %d", MSG_ReadShort (&packet)); Net_LogPrintf (" Speed1: %d", MSG_ReadShort
(&packet));
if (mask2 & 0x08) if (mask2 & 0x08)
Net_LogPrintf (" Speed2: %d", MSG_ReadShort (&packet)); Net_LogPrintf (" Speed2: %d", MSG_ReadShort
(&packet));
if (mask2 & 0x10) if (mask2 & 0x10)
Net_LogPrintf (" Speed3: %d", MSG_ReadShort (&packet)); Net_LogPrintf (" Speed3: %d", MSG_ReadShort
(&packet));
if (mask2 & 0x20) if (mask2 & 0x20)
Net_LogPrintf (" Flag: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" Flag: %d", MSG_ReadByte
(&packet));
if (mask2 & 0x40) if (mask2 & 0x40)
Net_LogPrintf (" Impulse: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" Impulse: %d", MSG_ReadByte
(&packet));
Net_LogPrintf (" Msec: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" Msec: %d", MSG_ReadByte (&packet));
} }
if (mask1 & PF_VELOCITY1) if (mask1 & PF_VELOCITY1)
@ -769,7 +778,8 @@ Parse_Server_Packet ()
Net_LogPrintf (" Effects: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" Effects: %d", MSG_ReadByte (&packet));
if (mask1 & PF_WEAPONFRAME) if (mask1 & PF_WEAPONFRAME)
Net_LogPrintf (" Weapon frame: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" Weapon frame: %d", MSG_ReadByte
(&packet));
break; break;
case svc_nails: case svc_nails:
ii = MSG_ReadByte (&packet); ii = MSG_ReadByte (&packet);
@ -822,22 +832,21 @@ Parse_Server_Packet ()
Net_LogPrintf ("\n\t*End of sound list*"); Net_LogPrintf ("\n\t*End of sound list*");
break; break;
case svc_packetentities: case svc_packetentities:
while (1) {
while (1) { mask1 = (unsigned short) MSG_ReadShort(&packet);
mask1 = (unsigned short) MSG_ReadShort(&packet); if (packet.badread) {
if (packet.badread) { Net_LogPrintf ("Badread\n");
Net_LogPrintf ("Badread\n"); return;
return; }
} if (!mask1) break;
if (!mask1) break;
if (mask1 & U_REMOVE) Net_LogPrintf("UREMOVE "); if (mask1 & U_REMOVE) Net_LogPrintf("UREMOVE ");
Log_Delta(mask1); Log_Delta(mask1);
} }
break; break;
case svc_deltapacketentities: case svc_deltapacketentities:
Net_LogPrintf ("idx: %d", MSG_ReadByte (&packet)); Net_LogPrintf ("idx: %d", MSG_ReadByte (&packet));
return; return;
break; break;
case svc_maxspeed: case svc_maxspeed:
Net_LogPrintf ("%f", MSG_ReadFloat (&packet)); Net_LogPrintf ("%f", MSG_ReadFloat (&packet));
break; break;
@ -850,12 +859,12 @@ Parse_Server_Packet ()
Net_LogPrintf ("Value: %s", MSG_ReadString (&packet)); Net_LogPrintf ("Value: %s", MSG_ReadString (&packet));
break; break;
case svc_serverinfo: case svc_serverinfo:
Net_LogPrintf ("Name: %s Value: %s", MSG_ReadString (&packet), Net_LogPrintf ("Name: %s Value: %s", MSG_ReadString
MSG_ReadString (&packet)); (&packet), MSG_ReadString (&packet));
break; break;
case svc_updatepl: case svc_updatepl:
Net_LogPrintf ("Player: %d Ploss: %d", MSG_ReadByte (&packet), Net_LogPrintf ("Player: %d Ploss: %d", MSG_ReadByte
MSG_ReadByte (&packet)); (&packet), MSG_ReadByte (&packet));
break; break;
default: default:
Net_LogPrintf ("**UNKNOWN**: [%d]", c); Net_LogPrintf ("**UNKNOWN**: [%d]", c);
@ -882,9 +891,8 @@ Analyze_Client_Packet (const byte * data, int len)
void void
Parse_Client_Packet (void) Parse_Client_Packet (void)
{ {
int i, c, ii; int mask, i, c, ii;
long seq1, seq2; long seq1, seq2;
int mask;
seq1 = MSG_ReadLong (&packet); seq1 = MSG_ReadLong (&packet);
if (seq1 == -1) { if (seq1 == -1) {
@ -909,8 +917,9 @@ Parse_Client_Packet (void)
c = MSG_ReadByte (&packet); c = MSG_ReadByte (&packet);
if (c == -1) if (c == -1)
break; break;
// Net_LogPrintf("<%ld,%ld> ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF); // Net_LogPrintf("<%ld,%ld> ",seq1 & 0x7FFFFFFF,seq2 & 0x7FFFFFFF);
Net_LogPrintf ("\n<%06x> [0x%02x] ", MSG_GetReadCount (&packet), c); Net_LogPrintf ("\n<%06x> [0x%02x] ", MSG_GetReadCount (&packet),
c);
if (c < 8) if (c < 8)
Net_LogPrintf ("%s: ", clc_string[c]); Net_LogPrintf ("%s: ", clc_string[c]);
@ -928,21 +937,29 @@ Parse_Client_Packet (void)
mask = MSG_ReadByte (&packet); mask = MSG_ReadByte (&packet);
Net_LogPrintf ("\n\t(%d) mask = %02x", i, mask); Net_LogPrintf ("\n\t(%d) mask = %02x", i, mask);
if (mask & 0x01) if (mask & 0x01)
Net_LogPrintf (" Tilt: %f", MSG_ReadAngle16 (&packet)); Net_LogPrintf (" Tilt: %f", MSG_ReadAngle16
(&packet));
if (mask & 0x80) if (mask & 0x80)
Net_LogPrintf (" Yaw: %f", MSG_ReadAngle16 (&packet)); Net_LogPrintf (" Yaw: %f", MSG_ReadAngle16
(&packet));
if (mask & 0x02) if (mask & 0x02)
Net_LogPrintf (" Roll: %f", MSG_ReadAngle16 (&packet)); Net_LogPrintf (" Roll: %f", MSG_ReadAngle16
(&packet));
if (mask & 0x04) if (mask & 0x04)
Net_LogPrintf (" Fwd: %d", MSG_ReadShort (&packet)); Net_LogPrintf (" Fwd: %d", MSG_ReadShort
(&packet));
if (mask & 0x08) if (mask & 0x08)
Net_LogPrintf (" Right: %d", MSG_ReadShort (&packet)); Net_LogPrintf (" Right: %d", MSG_ReadShort
(&packet));
if (mask & 0x10) if (mask & 0x10)
Net_LogPrintf (" Up: %d", MSG_ReadShort (&packet)); Net_LogPrintf (" Up: %d", MSG_ReadShort
(&packet));
if (mask & 0x20) if (mask & 0x20)
Net_LogPrintf (" Flags: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" Flags: %d", MSG_ReadByte
(&packet));
if (mask & 0x40) if (mask & 0x40)
Net_LogPrintf (" Impulse: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" Impulse: %d", MSG_ReadByte
(&packet));
Net_LogPrintf (" Msec: %d", MSG_ReadByte (&packet)); Net_LogPrintf (" Msec: %d", MSG_ReadByte (&packet));
} }
break; break;
@ -955,7 +972,8 @@ Parse_Client_Packet (void)
break; break;
case clc_upload: case clc_upload:
ii = MSG_ReadShort (&packet); ii = MSG_ReadShort (&packet);
Net_LogPrintf ("%d bytes at %d", ii, MSG_ReadByte (&packet)); Net_LogPrintf ("%d bytes at %d", ii, MSG_ReadByte
(&packet));
for (i = 0; i < ii; i++) for (i = 0; i < ii; i++)
MSG_ReadByte (&packet); MSG_ReadByte (&packet);
break; break;
@ -965,7 +983,6 @@ Parse_Client_Packet (void)
} }
Net_LogPrintf ("\n"); Net_LogPrintf ("\n");
} }
} }
} }
@ -1011,9 +1028,8 @@ Net_Log_Init (const char **sound_precache)
// 3 = just parse // 3 = just parse
// 4 = parse/hexdump, skip movement/empty messages // 4 = parse/hexdump, skip movement/empty messages
net_loglevel = net_loglevel = Cvar_Get ("net_loglevel", "2", CVAR_NONE, NULL,
Cvar_Get ("net_loglevel", "2", CVAR_NONE, NULL, "Packet logging/parsing");
"Packet logging/parsing");
Cmd_AddCommand ("net_packetlog_zap", Net_PacketLog_Zap_f, Cmd_AddCommand ("net_packetlog_zap", Net_PacketLog_Zap_f,
"clear the packet log file"); "clear the packet log file");

View file

@ -30,18 +30,9 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#endif #endif
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
# include <sys/param.h> # include <sys/param.h>
#endif #endif
@ -63,11 +54,16 @@
#ifdef HAVE_SYS_FILIO_H #ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h> # include <sys/filio.h>
#endif #endif
#ifdef NeXT #ifdef NeXT
# include <libc.h> # include <libc.h>
#endif #endif
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/msg.h" #include "QF/msg.h"
@ -95,19 +91,14 @@
# endif # endif
#endif #endif
extern cvar_t *net_packetlog;
netadr_t net_local_adr;
netadr_t net_from;
int net_socket; int net_socket;
netadr_t net_local_adr;
netadr_t net_from;
static sizebuf_t _net_message_message; static sizebuf_t _net_message_message;
static msg_t _net_message = {0, 0, &_net_message_message}; static msg_t _net_message = {0, 0, &_net_message_message};
msg_t *net_message = &_net_message; msg_t *net_message = &_net_message;
extern qboolean is_server;
#define MAX_UDP_PACKET (MAX_MSGLEN*2) #define MAX_UDP_PACKET (MAX_MSGLEN*2)
byte net_message_buffer[MAX_UDP_PACKET]; byte net_message_buffer[MAX_UDP_PACKET];
@ -115,7 +106,9 @@ byte net_message_buffer[MAX_UDP_PACKET];
WSADATA winsockdata; WSADATA winsockdata;
#endif #endif
//============================================================================= extern cvar_t *net_packetlog;
extern qboolean is_server;
void void
NetadrToSockadr (netadr_t *a, struct sockaddr_in *s) NetadrToSockadr (netadr_t *a, struct sockaddr_in *s)
@ -143,7 +136,6 @@ NET_CompareBaseAdr (netadr_t a, netadr_t b)
return false; return false;
} }
qboolean qboolean
NET_CompareAdr (netadr_t a, netadr_t b) NET_CompareAdr (netadr_t a, netadr_t b)
{ {
@ -185,11 +177,10 @@ NET_BaseAdrToString (netadr_t a)
qboolean qboolean
NET_StringToAdr (const char *s, netadr_t *a) NET_StringToAdr (const char *s, netadr_t *a)
{ {
char copy[128];
char *colon;
struct hostent *h; struct hostent *h;
struct sockaddr_in sadr; struct sockaddr_in sadr;
char *colon;
char copy[128];
memset (&sadr, 0, sizeof (sadr)); memset (&sadr, 0, sizeof (sadr));
sadr.sin_family = AF_INET; sadr.sin_family = AF_INET;
@ -223,8 +214,8 @@ qboolean
NET_IsClientLegal (netadr_t *adr) NET_IsClientLegal (netadr_t *adr)
{ {
#if 0 #if 0
struct sockaddr_in sadr;
int newsocket; int newsocket;
struct sockaddr_in sadr;
if (adr->ip[0] == 127) if (adr->ip[0] == 127)
return false; // no local connections period return false; // no local connections period
@ -248,15 +239,12 @@ NET_IsClientLegal (netadr_t *adr)
#endif #endif
} }
//=============================================================================
qboolean qboolean
NET_GetPacket (void) NET_GetPacket (void)
{ {
int ret; int ret;
struct sockaddr_in from;
socklen_t fromlen; socklen_t fromlen;
struct sockaddr_in from;
fromlen = sizeof (from); fromlen = sizeof (from);
ret = ret =
@ -292,15 +280,15 @@ NET_GetPacket (void)
return false; return false;
} }
// Check for malformed packets // Check for malformed packets
if (is_server && ntohs(net_from.port)<1024) { if (is_server && ntohs(net_from.port)<1024) {
Con_Printf ("Warning: Packet from %s dropped: Bad port\n", Con_Printf ("Warning: Packet from %s dropped: Bad port\n",
NET_AdrToString (net_from)); NET_AdrToString (net_from));
return false; return false;
} }
if (from.sin_addr.s_addr==INADDR_ANY || from.sin_addr.s_addr==INADDR_BROADCAST) { if (from.sin_addr.s_addr==INADDR_ANY || from.sin_addr.s_addr ==
INADDR_BROADCAST) {
Con_Printf ("Warning: Packet dropped - bad address\n"); Con_Printf ("Warning: Packet dropped - bad address\n");
return false; return false;
} }
@ -316,8 +304,6 @@ NET_GetPacket (void)
return ret; return ret;
} }
//=============================================================================
void void
NET_SendPacket (int length, void *data, netadr_t to) NET_SendPacket (int length, void *data, netadr_t to)
{ {
@ -355,12 +341,10 @@ NET_SendPacket (int length, void *data, netadr_t to)
} }
} }
//=============================================================================
int int
UDP_OpenSocket (int port) UDP_OpenSocket (int port)
{ {
int newsocket; int newsocket, i;
struct sockaddr_in address; struct sockaddr_in address;
#ifdef _WIN32 #ifdef _WIN32
@ -369,7 +353,6 @@ UDP_OpenSocket (int port)
#else #else
int _true = 1; int _true = 1;
#endif #endif
int i;
memset (&address, 0, sizeof(address)); memset (&address, 0, sizeof(address));
@ -378,7 +361,7 @@ UDP_OpenSocket (int port)
if (ioctl (newsocket, FIONBIO, &_true) == -1) if (ioctl (newsocket, FIONBIO, &_true) == -1)
Sys_Error ("UDP_OpenSocket: ioctl FIONBIO:%s", strerror (errno)); Sys_Error ("UDP_OpenSocket: ioctl FIONBIO:%s", strerror (errno));
address.sin_family = AF_INET; address.sin_family = AF_INET;
//ZOID -- check for interface binding option // ZOID -- check for interface binding option
if ((i = COM_CheckParm ("-ip")) != 0 && i < com_argc) { if ((i = COM_CheckParm ("-ip")) != 0 && i < com_argc) {
address.sin_addr.s_addr = inet_addr (com_argv[i + 1]); address.sin_addr.s_addr = inet_addr (com_argv[i + 1]);
Con_Printf ("Binding to IP Interface Address of %s\n", Con_Printf ("Binding to IP Interface Address of %s\n",
@ -399,8 +382,8 @@ void
NET_GetLocalAddress (void) NET_GetLocalAddress (void)
{ {
char buff[MAXHOSTNAMELEN]; char buff[MAXHOSTNAMELEN];
struct sockaddr_in address;
socklen_t namelen; socklen_t namelen;
struct sockaddr_in address;
gethostname (buff, MAXHOSTNAMELEN); gethostname (buff, MAXHOSTNAMELEN);
buff[MAXHOSTNAMELEN - 1] = 0; buff[MAXHOSTNAMELEN - 1] = 0;
@ -415,15 +398,12 @@ NET_GetLocalAddress (void)
Con_Printf ("IP address %s\n", NET_AdrToString (net_local_adr)); Con_Printf ("IP address %s\n", NET_AdrToString (net_local_adr));
} }
/*
NET_Init
*/
void void
NET_Init (int port) NET_Init (int port)
{ {
#ifdef _WIN32 #ifdef _WIN32
WORD wVersionRequested;
int r; int r;
WORD wVersionRequested;
wVersionRequested = MAKEWORD (1, 1); wVersionRequested = MAKEWORD (1, 1);
@ -431,28 +411,19 @@ NET_Init (int port)
if (r) if (r)
Sys_Error ("Winsock initialization failed."); Sys_Error ("Winsock initialization failed.");
#endif /* _WIN32 */ #endif /* _WIN32 */
//
// open the single socket to be used for all communications // open the single socket to be used for all communications
//
net_socket = UDP_OpenSocket (port); net_socket = UDP_OpenSocket (port);
//
// init the message buffer // init the message buffer
//
_net_message_message.maxsize = sizeof (net_message_buffer); _net_message_message.maxsize = sizeof (net_message_buffer);
_net_message_message.data = net_message_buffer; _net_message_message.data = net_message_buffer;
//
// determine my name & address // determine my name & address
//
NET_GetLocalAddress (); NET_GetLocalAddress ();
Con_Printf ("UDP Initialized\n"); Con_Printf ("UDP Initialized\n");
} }
/*
NET_Shutdown
*/
void void
NET_Shutdown (void) NET_Shutdown (void)
{ {

View file

@ -29,17 +29,47 @@
$Id$ $Id$
*/ */
/* Sun's model_t in sys/model.h conflicts w/ Quake's model_t */
#define model_t quakeforgemodel_t
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h>
#endif
#ifdef NeXT
# include <libc.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
# include <windows.h> # include <windows.h>
# undef EWOULDBLOCK # undef EWOULDBLOCK
# define EWOULDBLOCK WSAEWOULDBLOCK # define EWOULDBLOCK WSAEWOULDBLOCK
#endif
#ifdef _WIN32
# ifdef HAVE_IPV6 # ifdef HAVE_IPV6
# include <winsock2.h> # include <winsock2.h>
# define _DEF_BYTE_ # define _DEF_BYTE_
@ -65,47 +95,10 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
/* Sun's model_t in sys/model.h conflicts w/ Quake's model_t */
#define model_t quakeforgemodel_t
#ifndef _WIN32
# include <unistd.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h>
#endif
#undef model_t #undef model_t
#ifdef NeXT
# include <libc.h>
#endif
#include "QF/console.h" #include "QF/console.h"
#include "QF/msg.h" #include "QF/msg.h"
#include "QF/qargs.h" #include "QF/qargs.h"
@ -125,9 +118,8 @@
# endif # endif
#endif #endif
netadr_t net_local_adr;
netadr_t net_from; netadr_t net_from;
netadr_t net_local_adr;
int net_socket; int net_socket;
static sizebuf_t _net_message_message; static sizebuf_t _net_message_message;
@ -141,7 +133,6 @@ byte net_message_buffer[MAX_UDP_PACKET];
WSADATA winsockdata; WSADATA winsockdata;
#endif #endif
//=============================================================================
void void
NetadrToSockadr (netadr_t *a, struct sockaddr_in6 *s) NetadrToSockadr (netadr_t *a, struct sockaddr_in6 *s)
@ -185,7 +176,6 @@ NET_CompareBaseAdr (netadr_t a, netadr_t b)
return false; return false;
} }
qboolean qboolean
NET_CompareAdr (netadr_t a, netadr_t b) NET_CompareAdr (netadr_t a, netadr_t b)
{ {
@ -256,14 +246,12 @@ NET_BaseAdrToString (netadr_t a)
qboolean qboolean
NET_StringToAdr (const char *s, netadr_t *a) NET_StringToAdr (const char *s, netadr_t *a)
{ {
char copy[128];
char *addrs, *space;
char *ports = NULL;
int err;
struct addrinfo hints; struct addrinfo hints;
struct addrinfo *resultp; struct addrinfo *resultp;
char *space;
char *ports = NULL;
char copy[128];
char *addrs;
int err;
struct sockaddr_storage ss; struct sockaddr_storage ss;
struct sockaddr_in6 *ss6; struct sockaddr_in6 *ss6;
struct sockaddr_in *ss4; struct sockaddr_in *ss4;
@ -291,11 +279,12 @@ NET_StringToAdr (const char *s, netadr_t *a)
} }
} }
// Con_Printf ("NET_StringToAdr: addrs %s ports %s\n",addrs, ports); // Con_Printf ("NET_StringToAdr: addrs %s ports %s\n",addrs, ports);
if ((err = getaddrinfo (addrs, ports, &hints, &resultp))) { if ((err = getaddrinfo (addrs, ports, &hints, &resultp))) {
// Error // Error
Con_Printf ("NET_StringToAdr: string %s:\n%s\n", s, gai_strerror (err)); Con_Printf ("NET_StringToAdr: string %s:\n%s\n", s, gai_strerror
(err));
return 0; return 0;
} }
@ -335,8 +324,8 @@ qboolean
NET_IsClientLegal (netadr_t *adr) NET_IsClientLegal (netadr_t *adr)
{ {
#if 0 #if 0
struct sockaddr_in sadr;
int newsocket; int newsocket;
struct sockaddr_in sadr;
if (adr->ip[0] == 127) if (adr->ip[0] == 127)
return false; // no local connections period return false; // no local connections period
@ -360,15 +349,12 @@ NET_IsClientLegal (netadr_t *adr)
#endif #endif
} }
//=============================================================================
qboolean qboolean
NET_GetPacket (void) NET_GetPacket (void)
{ {
int ret; int ret;
struct sockaddr_in6 from;
unsigned int fromlen; unsigned int fromlen;
struct sockaddr_in6 from;
fromlen = sizeof (from); fromlen = sizeof (from);
ret = ret =
@ -407,8 +393,6 @@ NET_GetPacket (void)
return ret; return ret;
} }
//=============================================================================
void void
NET_SendPacket (int length, void *data, netadr_t to) NET_SendPacket (int length, void *data, netadr_t to)
{ {
@ -441,16 +425,13 @@ NET_SendPacket (int length, void *data, netadr_t to)
} }
} }
//=============================================================================
int int
UDP_OpenSocket (int port) UDP_OpenSocket (int port)
{ {
int newsocket; char Buf[BUFSIZ], *Host, *Service;
int newsocket, Error;
struct sockaddr_in6 address; struct sockaddr_in6 address;
struct addrinfo hints, *res; struct addrinfo hints, *res;
int Error;
char Buf[BUFSIZ], *Host, *Service;
#ifdef IPV6_BINDV6ONLY #ifdef IPV6_BINDV6ONLY
int dummy; int dummy;
@ -469,7 +450,7 @@ UDP_OpenSocket (int port)
Sys_Error ("UDP_OpenSocket: ioctl FIONBIO: %s", strerror (errno)); Sys_Error ("UDP_OpenSocket: ioctl FIONBIO: %s", strerror (errno));
memset (&address, 0, sizeof (address)); memset (&address, 0, sizeof (address));
address.sin6_family = AF_INET6; address.sin6_family = AF_INET6;
//ZOID -- check for interface binding option // ZOID -- check for interface binding option
memset (&hints, 0, sizeof (hints)); memset (&hints, 0, sizeof (hints));
hints.ai_family = PF_UNSPEC; hints.ai_family = PF_UNSPEC;
@ -525,8 +506,8 @@ void
NET_GetLocalAddress (void) NET_GetLocalAddress (void)
{ {
char buff[MAXHOSTNAMELEN]; char buff[MAXHOSTNAMELEN];
struct sockaddr_in6 address;
unsigned int namelen; unsigned int namelen;
struct sockaddr_in6 address;
if (gethostname (buff, MAXHOSTNAMELEN) == -1) if (gethostname (buff, MAXHOSTNAMELEN) == -1)
Sys_Error ("Net_GetLocalAddress: gethostname: %s", strerror (errno)); Sys_Error ("Net_GetLocalAddress: gethostname: %s", strerror (errno));
@ -542,15 +523,12 @@ NET_GetLocalAddress (void)
Con_Printf ("IP address %s\n", NET_AdrToString (net_local_adr)); Con_Printf ("IP address %s\n", NET_AdrToString (net_local_adr));
} }
/*
NET_Init
*/
void void
NET_Init (int port) NET_Init (int port)
{ {
#ifdef _WIN32 #ifdef _WIN32
WORD wVersionRequested;
int r; int r;
WORD wVersionRequested;
wVersionRequested = MAKEWORD (1, 1); wVersionRequested = MAKEWORD (1, 1);
@ -559,28 +537,19 @@ NET_Init (int port)
Sys_Error ("Winsock initialization failed."); Sys_Error ("Winsock initialization failed.");
#endif /* _WIN32 */ #endif /* _WIN32 */
//
// open the single socket to be used for all communications // open the single socket to be used for all communications
//
net_socket = UDP_OpenSocket (port); net_socket = UDP_OpenSocket (port);
//
// init the message buffer // init the message buffer
//
_net_message_message.maxsize = sizeof (net_message_buffer); _net_message_message.maxsize = sizeof (net_message_buffer);
_net_message_message.data = net_message_buffer; _net_message_message.data = net_message_buffer;
//
// determine my name & address // determine my name & address
//
NET_GetLocalAddress (); NET_GetLocalAddress ();
Con_Printf ("UDP Initialized\n"); Con_Printf ("UDP Initialized\n");
} }
/*
NET_Shutdown
*/
void void
NET_Shutdown (void) NET_Shutdown (void)
{ {

View file

@ -51,7 +51,6 @@ int watertype;
float frametime; float frametime;
vec3_t forward, right, up; vec3_t forward, right, up;
vec3_t player_mins = { -16, -16, -24 }; vec3_t player_mins = { -16, -16, -24 };
vec3_t player_maxs = { 16, 16, 32 }; vec3_t player_maxs = { 16, 16, 32 };
@ -115,12 +114,11 @@ PM_ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce)
int int
PM_FlyMove (void) PM_FlyMove (void)
{ {
int blocked, bumpcount, numbumps, numplanes, i, j;
vec3_t dir;
float time_left, d; float time_left, d;
int blocked, bumpcount, numbumps, numplanes, i, j;
pmtrace_t trace; pmtrace_t trace;
vec3_t dir, end, primal_velocity, original_velocity;
vec3_t planes[MAX_CLIP_PLANES]; vec3_t planes[MAX_CLIP_PLANES];
vec3_t end, primal_velocity, original_velocity;
numbumps = 4; numbumps = 4;
@ -343,8 +341,8 @@ PM_GroundMove (void)
void void
PM_Friction (void) PM_Friction (void)
{ {
float *vel;
float drop, friction, speed, newspeed; float drop, friction, speed, newspeed;
float *vel;
pmtrace_t trace; pmtrace_t trace;
vec3_t start, stop; vec3_t start, stop;
@ -494,9 +492,9 @@ PM_WaterMove (void)
void void
PM_AirMove (void) PM_AirMove (void)
{ {
float fmove, smove, wishspeed;
int i; int i;
vec3_t original, wishdir, wishvel; vec3_t original, wishdir, wishvel;
float fmove, smove, wishspeed;
fmove = pmove.cmd.forwardmove; fmove = pmove.cmd.forwardmove;
smove = pmove.cmd.sidemove; smove = pmove.cmd.sidemove;
@ -562,8 +560,7 @@ PM_CategorizePosition (void)
pmtrace_t tr; pmtrace_t tr;
vec3_t point; vec3_t point;
// if the player hull point one unit down is solid, the player // if the player hull point one unit down is solid, the player is on ground
// is on ground
// see if standing on something solid // see if standing on something solid
point[0] = pmove.origin[0]; point[0] = pmove.origin[0];
@ -615,8 +612,7 @@ void
JumpButton (void) JumpButton (void)
{ {
if (pmove.dead) { if (pmove.dead) {
pmove.oldbuttons |= BUTTON_JUMP; // don't jump again until pmove.oldbuttons |= BUTTON_JUMP; // don't jump again until released
// released
return; return;
} }
@ -736,8 +732,7 @@ SpectatorMove (void)
float control, drop, friction, fmove, smove, speed, newspeed; float control, drop, friction, fmove, smove, speed, newspeed;
float currentspeed, addspeed, accelspeed, wishspeed; float currentspeed, addspeed, accelspeed, wishspeed;
int i; int i;
vec3_t wishvel; vec3_t wishdir, wishvel;
vec3_t wishdir;
// friction // friction
speed = Length (pmove.velocity); speed = Length (pmove.velocity);