Lots of whitespace in sv_user.c, plus fix sv_timekick help strings, and up sv_timekick_fuzz from 15 to 30 ms.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2002-08-22 23:04:44 +00:00
parent 0715464bb1
commit 0085cd698f
2 changed files with 146 additions and 222 deletions

View File

@ -2034,10 +2034,11 @@ SV_InitLocal (void)
"Sets the value for auto-aiming leniency"); "Sets the value for auto-aiming leniency");
sv_timekick = Cvar_Get ("sv_timekick", "3", CVAR_SERVERINFO, Cvar_Info, sv_timekick = Cvar_Get ("sv_timekick", "3", CVAR_SERVERINFO, Cvar_Info,
"Time cheat protection"); "Time cheat protection");
sv_timekick_fuzz = Cvar_Get ("sv_timekick_fuzz", "15", CVAR_NONE, NULL, sv_timekick_fuzz = Cvar_Get ("sv_timekick_fuzz", "30", CVAR_NONE, NULL,
"Time cheat \"fuzz factor\""); "Time cheat \"fuzz factor\" in milliseconds");
sv_timekick_interval = Cvar_Get ("sv_timekick_interval", "30", CVAR_NONE, sv_timekick_interval = Cvar_Get ("sv_timekick_interval", "30", CVAR_NONE,
NULL, "Time cheat check interval"); NULL, "Time cheat check interval in "
"seconds");
sv_minqfversion = Cvar_Get ("sv_minqfversion", "0", CVAR_SERVERINFO, sv_minqfversion = Cvar_Get ("sv_minqfversion", "0", CVAR_SERVERINFO,
Cvar_Info, "Minimum QF version on client"); Cvar_Info, "Minimum QF version on client");
sv_maxrate = Cvar_Get ("sv_maxrate", "10000", CVAR_SERVERINFO, Cvar_Info, sv_maxrate = Cvar_Get ("sv_maxrate", "10000", CVAR_SERVERINFO, Cvar_Info,

View File

@ -55,8 +55,8 @@ static const char rcsid[] =
#include "QF/va.h" #include "QF/va.h"
#include "QF/vfs.h" #include "QF/vfs.h"
#include "compat.h"
#include "bothdefs.h" #include "bothdefs.h"
#include "compat.h"
#include "msg_ucmd.h" #include "msg_ucmd.h"
#include "pmove.h" #include "pmove.h"
#include "server.h" #include "server.h"
@ -80,24 +80,18 @@ cvar_t *cl_rollspeed;
cvar_t *cl_rollangle; cvar_t *cl_rollangle;
cvar_t *sv_spectalk; cvar_t *sv_spectalk;
cvar_t *sv_kickfake;
cvar_t *sv_mapcheck; cvar_t *sv_mapcheck;
cvar_t *sv_timekick; cvar_t *sv_timekick;
cvar_t *sv_timekick_fuzz; cvar_t *sv_timekick_fuzz;
cvar_t *sv_timekick_interval; cvar_t *sv_timekick_interval;
cvar_t *sv_kickfake; void SV_FullClientUpdateToClient (client_t *client, client_t *cl);
// USER STRINGCMD EXECUTION host_client and sv_player will be valid.
void SV_FullClientUpdateToClient (client_t *client, client_t *cl);
/*
USER STRINGCMD EXECUTION
host_client and sv_player will be valid.
*/
/* /*
SV_New_f SV_New_f
@ -118,15 +112,15 @@ SV_New_f (ucmd_t *cmd)
host_client->connection_started = realtime; host_client->connection_started = realtime;
// send the info about the new client to all connected clients // send the info about the new client to all connected clients
// SV_FullClientUpdate (host_client, &sv.reliable_datagram); // SV_FullClientUpdate (host_client, &sv.reliable_datagram);
// host_client->sendinfo = true; // host_client->sendinfo = true;
gamedir = Info_ValueForKey (svs.info, "*gamedir"); gamedir = Info_ValueForKey (svs.info, "*gamedir");
if (!gamedir[0]) if (!gamedir[0])
gamedir = "qw"; gamedir = "qw";
//NOTE: This doesn't go through ClientReliableWrite since it's before the user // NOTE: This doesn't go through ClientReliableWrite since it's before the
//spawns. These functions are written to not overflow // user spawns. These functions are written to not overflow
if (host_client->num_backbuf) { if (host_client->num_backbuf) {
SV_Printf ("WARNING %s: [SV_New] Back buffered (%d0, clearing\n", SV_Printf ("WARNING %s: [SV_New] Back buffered (%d0, clearing\n",
host_client->name, host_client->netchan.message.cursize); host_client->name, host_client->netchan.message.cursize);
@ -146,7 +140,8 @@ SV_New_f (ucmd_t *cmd)
// send full levelname // send full levelname
MSG_WriteString (&host_client->netchan.message, MSG_WriteString (&host_client->netchan.message,
PR_GetString (&sv_pr_state, SVstring (sv.edicts, message))); PR_GetString (&sv_pr_state,
SVstring (sv.edicts, message)));
// send the movevars // send the movevars
MSG_WriteFloat (&host_client->netchan.message, movevars.gravity); MSG_WriteFloat (&host_client->netchan.message, movevars.gravity);
@ -171,9 +166,6 @@ SV_New_f (ucmd_t *cmd)
Info_MakeString (svs.info, 0))); Info_MakeString (svs.info, 0)));
} }
/*
SV_Soundlist_f
*/
void void
SV_Soundlist_f (ucmd_t *cmd) SV_Soundlist_f (ucmd_t *cmd)
{ {
@ -197,8 +189,8 @@ SV_Soundlist_f (ucmd_t *cmd)
SV_New_f (0); SV_New_f (0);
return; return;
} }
//NOTE: This doesn't go through ClientReliableWrite since it's before the user // NOTE: This doesn't go through ClientReliableWrite since it's before the
//spawns. These functions are written to not overflow // user spawns. These functions are written to not overflow
if (host_client->num_backbuf) { if (host_client->num_backbuf) {
SV_Printf ("WARNING %s: [SV_Soundlist] Back buffered (%d0, clearing", SV_Printf ("WARNING %s: [SV_Soundlist] Back buffered (%d0, clearing",
host_client->name, host_client->netchan.message.cursize); host_client->name, host_client->netchan.message.cursize);
@ -221,9 +213,6 @@ SV_Soundlist_f (ucmd_t *cmd)
MSG_WriteByte (&host_client->netchan.message, 0); MSG_WriteByte (&host_client->netchan.message, 0);
} }
/*
SV_Modellist_f
*/
void void
SV_Modellist_f (ucmd_t *cmd) SV_Modellist_f (ucmd_t *cmd)
{ {
@ -247,8 +236,8 @@ SV_Modellist_f (ucmd_t *cmd)
SV_New_f (0); SV_New_f (0);
return; return;
} }
//NOTE: This doesn't go through ClientReliableWrite since it's before the user // NOTE: This doesn't go through ClientReliableWrite since it's before the
//spawns. These functions are written to not overflow // user spawns. These functions are written to not overflow
if (host_client->num_backbuf) { if (host_client->num_backbuf) {
SV_Printf ("WARNING %s: [SV_Modellist] Back buffered (%d0, clearing", SV_Printf ("WARNING %s: [SV_Modellist] Back buffered (%d0, clearing",
host_client->name, host_client->netchan.message.cursize); host_client->name, host_client->netchan.message.cursize);
@ -270,17 +259,13 @@ SV_Modellist_f (ucmd_t *cmd)
MSG_WriteByte (&host_client->netchan.message, 0); MSG_WriteByte (&host_client->netchan.message, 0);
} }
/*
SV_PreSpawn_f
*/
void void
SV_PreSpawn_f (ucmd_t *cmd) SV_PreSpawn_f (ucmd_t *cmd)
{ {
unsigned int buf;
unsigned int check;
sizebuf_t *msg;
char *command; char *command;
int size; int size;
unsigned int buf, check;
sizebuf_t *msg;
if (host_client->state != cs_connected) { if (host_client->state != cs_connected) {
SV_Printf ("prespawn not valid -- already spawned\n"); SV_Printf ("prespawn not valid -- already spawned\n");
@ -305,9 +290,10 @@ SV_PreSpawn_f (ucmd_t *cmd)
if (sv_mapcheck->int_val && check != sv.worldmodel->checksum && if (sv_mapcheck->int_val && check != sv.worldmodel->checksum &&
check != sv.worldmodel->checksum2) { check != sv.worldmodel->checksum2) {
SV_ClientPrintf (host_client, PRINT_HIGH, SV_ClientPrintf (host_client, PRINT_HIGH, "Map model file does "
"Map model file does not match (%s), %i != %i/%i.\n" "not match (%s), %i != %i/%i.\n"
"You may need a new version of the map, or the proper install files.\n", "You may need a new version of the map, or the "
"proper install files.\n",
sv.modelname, check, sv.worldmodel->checksum, sv.modelname, check, sv.worldmodel->checksum,
sv.worldmodel->checksum2); sv.worldmodel->checksum2);
SV_DropClient (host_client); SV_DropClient (host_client);
@ -337,16 +323,12 @@ SV_PreSpawn_f (ucmd_t *cmd)
MSG_WriteString (msg, command); MSG_WriteString (msg, command);
} }
/*
SV_Spawn_f
*/
void void
SV_Spawn_f (ucmd_t *cmd) SV_Spawn_f (ucmd_t *cmd)
{ {
int i; int i, n;
client_t *client; client_t *client;
edict_t *ent; edict_t *ent;
int n;
if (host_client->state != cs_connected) { if (host_client->state != cs_connected) {
SV_Printf ("Spawn not valid -- already spawned\n"); SV_Printf ("Spawn not valid -- already spawned\n");
@ -360,9 +342,8 @@ SV_Spawn_f (ucmd_t *cmd)
} }
// make sure they're not trying to cheat by spawning without prespawning // make sure they're not trying to cheat by spawning without prespawning
if (host_client->prespawned == false) { if (host_client->prespawned == false) {
SV_BroadcastPrintf (PRINT_HIGH, SV_BroadcastPrintf (PRINT_HIGH, "%s has been kicked for trying to "
"%s has been kicked for trying to spawn before prespawning!\n", "spawn before prespawning!\n", host_client->name);
host_client->name);
SV_DropClient (host_client); SV_DropClient (host_client);
return; return;
} }
@ -391,11 +372,8 @@ SV_Spawn_f (ucmd_t *cmd)
// send all current light styles // send all current light styles
for (i = 0; i < MAX_LIGHTSTYLES; i++) { for (i = 0; i < MAX_LIGHTSTYLES; i++) {
ClientReliableWrite_Begin (host_client, svc_lightstyle, ClientReliableWrite_Begin (host_client, svc_lightstyle,
3 + 3 + (sv.lightstyles[i] ?
(sv. strlen (sv.lightstyles[i]) : 1));
lightstyles[i] ? strlen (sv.
lightstyles[i]) :
1));
ClientReliableWrite_Byte (host_client, (char) i); ClientReliableWrite_Byte (host_client, (char) i);
ClientReliableWrite_String (host_client, sv.lightstyles[i]); ClientReliableWrite_String (host_client, sv.lightstyles[i]);
} }
@ -405,7 +383,7 @@ SV_Spawn_f (ucmd_t *cmd)
memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4); memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4);
SVfloat (ent, colormap) = NUM_FOR_EDICT (&sv_pr_state, ent); SVfloat (ent, colormap) = NUM_FOR_EDICT (&sv_pr_state, ent);
SVfloat (ent, team) = 0; // FIXME SVfloat (ent, team) = 0; // FIXME
SVstring (ent, netname) = PR_SetString (&sv_pr_state, host_client->name); SVstring (ent, netname) = PR_SetString (&sv_pr_state, host_client->name);
host_client->entgravity = 1.0; host_client->entgravity = 1.0;
@ -442,9 +420,6 @@ SV_Spawn_f (ucmd_t *cmd)
ClientReliableWrite_String (host_client, "skins\n"); ClientReliableWrite_String (host_client, "skins\n");
} }
/*
SV_SpawnSpectator
*/
void void
SV_SpawnSpectator (void) SV_SpawnSpectator (void)
{ {
@ -458,7 +433,8 @@ SV_SpawnSpectator (void)
// search for an info_playerstart to spawn the spectator at // search for an info_playerstart to spawn the spectator at
for (i = MAX_CLIENTS - 1; i < sv.num_edicts; i++) { for (i = MAX_CLIENTS - 1; i < sv.num_edicts; i++) {
e = EDICT_NUM (&sv_pr_state, i); e = EDICT_NUM (&sv_pr_state, i);
if (!strcmp (PR_GetString (&sv_pr_state, SVstring (e, classname)), "info_player_start")) { if (!strcmp (PR_GetString (&sv_pr_state, SVstring (e, classname)),
"info_player_start")) {
VectorCopy (SVvector (e, origin), SVvector (sv_player, origin)); VectorCopy (SVvector (e, origin), SVvector (sv_player, origin));
return; return;
} }
@ -466,14 +442,11 @@ SV_SpawnSpectator (void)
} }
/*
SV_Begin_f
*/
void void
SV_Begin_f (ucmd_t *cmd) SV_Begin_f (ucmd_t *cmd)
{ {
unsigned int pmodel = 0, emodel = 0; unsigned int pmodel = 0, emodel = 0;
int i; int i;
if (host_client->state == cs_spawned) if (host_client->state == cs_spawned)
return; // don't begin again return; // don't begin again
@ -489,10 +462,10 @@ SV_Begin_f (ucmd_t *cmd)
// make sure they're not trying to cheat by beginning without spawning // make sure they're not trying to cheat by beginning without spawning
if (host_client->spawned == false) { if (host_client->spawned == false) {
SV_BroadcastPrintf (PRINT_HIGH, SV_BroadcastPrintf (PRINT_HIGH, "%s has been kicked for trying to "
"%s has been kicked for trying to begin before spawning!\n" "begin before spawning!\n"
"Have a nice day!\n", // 1 string! "Have a nice day!\n", // 1 string!
host_client->name); host_client->name);
SV_DropClient (host_client); SV_DropClient (host_client);
return; return;
} }
@ -537,10 +510,10 @@ SV_Begin_f (ucmd_t *cmd)
pmodel = atoi (Info_ValueForKey (host_client->userinfo, "pmodel")); pmodel = atoi (Info_ValueForKey (host_client->userinfo, "pmodel"));
emodel = atoi (Info_ValueForKey (host_client->userinfo, "emodel")); emodel = atoi (Info_ValueForKey (host_client->userinfo, "emodel"));
if (pmodel != sv.model_player_checksum || emodel != sv.eyes_player_checksum) if (pmodel != sv.model_player_checksum || emodel
SV_BroadcastPrintf (PRINT_HIGH, != sv.eyes_player_checksum)
"%s WARNING: non standard player/eyes model detected\n", SV_BroadcastPrintf (PRINT_HIGH, "%s WARNING: non standard "
host_client->name); "player/eyes model detected\n", host_client->name);
// if we are paused, tell the client // if we are paused, tell the client
if (sv.paused) { if (sv.paused) {
@ -549,7 +522,6 @@ SV_Begin_f (ucmd_t *cmd)
SV_ClientPrintf (host_client, PRINT_HIGH, "Server is paused.\n"); SV_ClientPrintf (host_client, PRINT_HIGH, "Server is paused.\n");
} }
#if 0 #if 0
//
// send a fixangle over the reliable channel to make sure it gets there // send a fixangle over the reliable channel to make sure it gets there
// Never send a roll angle, because savegames can catch the server // Never send a roll angle, because savegames can catch the server
// in a state where it is expecting the client to correct the angle // in a state where it is expecting the client to correct the angle
@ -566,16 +538,11 @@ SV_Begin_f (ucmd_t *cmd)
//============================================================================= //=============================================================================
/*
SV_NextDownload_f
*/
void void
SV_NextDownload_f (ucmd_t *cmd) SV_NextDownload_f (ucmd_t *cmd)
{ {
byte buffer[1024]; byte buffer[1024];
int r; int percent, size, r;
int percent;
int size;
if (!host_client->download) if (!host_client->download)
return; return;
@ -606,8 +573,8 @@ SV_NextDownload_f (ucmd_t *cmd)
void void
OutofBandPrintf (netadr_t where, char *fmt, ...) OutofBandPrintf (netadr_t where, char *fmt, ...)
{ {
va_list argptr; char send[1024];
char send[1024]; va_list argptr;
send[0] = 0xff; send[0] = 0xff;
send[1] = 0xff; send[1] = 0xff;
@ -621,14 +588,10 @@ OutofBandPrintf (netadr_t where, char *fmt, ...)
NET_SendPacket (strlen (send) + 1, send, where); NET_SendPacket (strlen (send) + 1, send, where);
} }
/*
SV_NextUpload
*/
void void
SV_NextUpload (void) SV_NextUpload (void)
{ {
int percent; int percent, size;
int size;
if (!*host_client->uploadfn) { if (!*host_client->uploadfn) {
SV_ClientPrintf (host_client, PRINT_HIGH, "Upload denied\n"); SV_ClientPrintf (host_client, PRINT_HIGH, "Upload denied\n");
@ -662,7 +625,8 @@ SV_NextUpload (void)
host_client->uploadfn, host_client->userid); host_client->uploadfn, host_client->userid);
} }
Qwrite (host_client->upload, net_message->message->data + net_message->readcount, size); Qwrite (host_client->upload, net_message->message->data +
net_message->readcount, size);
net_message->readcount += size; net_message->readcount += size;
Con_DPrintf ("UPLOAD: %d received\n", size); Con_DPrintf ("UPLOAD: %d received\n", size);
@ -677,31 +641,27 @@ SV_NextUpload (void)
SV_Printf ("%s upload completed.\n", host_client->uploadfn); SV_Printf ("%s upload completed.\n", host_client->uploadfn);
if (host_client->remote_snap) { if (host_client->remote_snap) {
char *p; char *p;
if ((p = strchr (host_client->uploadfn, '/')) != NULL) if ((p = strchr (host_client->uploadfn, '/')) != NULL)
p++; p++;
else else
p = host_client->uploadfn; p = host_client->uploadfn;
OutofBandPrintf (host_client->snap_from, OutofBandPrintf (host_client->snap_from, "%s upload completed.\n"
"%s upload completed.\nTo download, enter:\ndownload %s\n", "To download, enter:\ndownload %s\n",
host_client->uploadfn, p); host_client->uploadfn, p);
} }
} }
} }
/*
SV_BeginDownload_f
*/
void void
SV_BeginDownload_f (ucmd_t *cmd) SV_BeginDownload_f (ucmd_t *cmd)
{ {
const char *name; const char *name;
VFile *file; char realname[MAX_OSPATH];
int size; int size, zip;
char realname[MAX_OSPATH]; VFile *file;
int zip;
name = Cmd_Argv (1); name = Cmd_Argv (1);
// hacked by zoid to allow more conrol over download // hacked by zoid to allow more conrol over download
@ -712,9 +672,11 @@ SV_BeginDownload_f (ucmd_t *cmd)
// next up, skin check // next up, skin check
|| (strncmp (name, "skins/", 6) == 0 && !allow_download_skins->int_val) || (strncmp (name, "skins/", 6) == 0 && !allow_download_skins->int_val)
// now models // now models
|| (strncmp (name, "progs/", 6) == 0 && !allow_download_models->int_val) || (strncmp (name, "progs/", 6) == 0 &&
!allow_download_models->int_val)
// now sounds // now sounds
|| (strncmp (name, "sound/", 6) == 0 && !allow_download_sounds->int_val) || (strncmp (name, "sound/", 6) == 0 &&
!allow_download_sounds->int_val)
// now maps (note special case for maps, must not be in pak) // now maps (note special case for maps, must not be in pak)
|| (strncmp (name, "maps/", 5) == 0 && !allow_download_maps->int_val) || (strncmp (name, "maps/", 5) == 0 && !allow_download_maps->int_val)
// MUST be in a subdirectory // MUST be in a subdirectory
@ -749,8 +711,8 @@ SV_BeginDownload_f (ucmd_t *cmd)
host_client->downloadcount = 0; host_client->downloadcount = 0;
if (!host_client->download if (!host_client->download
// special check for maps, if it came from a pak file, don't allow // ZOID: special check for maps, if it came from a pak file, don't
// download ZOID // allow download
|| (strncmp (name, "maps/", 5) == 0 && file_from_pak)) { || (strncmp (name, "maps/", 5) == 0 && file_from_pak)) {
if (host_client->download) { if (host_client->download) {
Qclose (host_client->download); Qclose (host_client->download);
@ -780,19 +742,14 @@ SV_BeginDownload_f (ucmd_t *cmd)
//============================================================================= //=============================================================================
/*
SV_Say
*/
void void
SV_Say (qboolean team) SV_Say (qboolean team)
{ {
client_t *client; char *i, *p;
int j, tmp; char text[2048], t1[32];
char *p;
char text[2048];
char t1[32];
const char *t2; const char *t2;
char *i; client_t *client;
int tmp, j;
if (Cmd_Argc () < 2) if (Cmd_Argc () < 2)
return; return;
@ -820,8 +777,7 @@ SV_Say (qboolean team)
tmp = host_client->whensaidhead - fp_messages + 1; tmp = host_client->whensaidhead - fp_messages + 1;
if (tmp < 0) if (tmp < 0)
tmp = 10 + tmp; tmp = 10 + tmp;
if (!sv.paused && if (!sv.paused && host_client->whensaid[tmp]
host_client->whensaid[tmp]
&& (realtime - host_client->whensaid[tmp] < fp_persecond)) { && (realtime - host_client->whensaid[tmp] < fp_persecond)) {
host_client->lockedtill = realtime + fp_secondsdead; host_client->lockedtill = realtime + fp_secondsdead;
if (fp_msg[0]) if (fp_msg[0])
@ -850,8 +806,11 @@ SV_Say (qboolean team)
for (i = p; *i; i++) for (i = p; *i; i++)
if (*i == 13) { // ^M if (*i == 13) { // ^M
if (sv_kickfake->int_val) { if (sv_kickfake->int_val) {
SV_BroadcastPrintf (PRINT_HIGH, "%s was kicked for attempting to fake messages\n", host_client->name); SV_BroadcastPrintf (PRINT_HIGH, "%s was kicked for "
SV_ClientPrintf (host_client, PRINT_HIGH, "You were kicked for attempting to fake messages\n"); "attempting to fake messages\n",
host_client->name);
SV_ClientPrintf (host_client, PRINT_HIGH, "You were kicked "
"for attempting to fake messages\n");
SV_DropClient (host_client); SV_DropClient (host_client);
return; return;
} else } else
@ -885,26 +844,18 @@ SV_Say (qboolean team)
} }
} }
/*
SV_Say_f
*/
void void
SV_Say_f (ucmd_t *cmd) SV_Say_f (ucmd_t *cmd)
{ {
SV_Say (false); SV_Say (false);
} }
/*
SV_Say_Team_f
*/
void void
SV_Say_Team_f (ucmd_t *cmd) SV_Say_Team_f (ucmd_t *cmd)
{ {
SV_Say (true); SV_Say (true);
} }
//============================================================================ //============================================================================
/* /*
@ -932,11 +883,6 @@ SV_Pings_f (ucmd_t *cmd)
} }
} }
/*
SV_Kill_f
*/
void void
SV_Kill_f (ucmd_t *cmd) SV_Kill_f (ucmd_t *cmd)
{ {
@ -953,14 +899,11 @@ SV_Kill_f (ucmd_t *cmd)
PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientKill); PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientKill);
} }
/*
SV_TogglePause
*/
void void
SV_TogglePause (const char *msg) SV_TogglePause (const char *msg)
{ {
int i;
client_t *cl; client_t *cl;
int i;
sv.paused ^= 1; sv.paused ^= 1;
@ -976,21 +919,18 @@ SV_TogglePause (const char *msg)
} }
} }
/*
SV_Pause_f
*/
void void
SV_Pause_f (ucmd_t *cmd) SV_Pause_f (ucmd_t *cmd)
{ {
static double lastpausetime; char st[sizeof (host_client->name) + 32];
double currenttime; static double lastpausetime;
char st[sizeof (host_client->name) + 32]; double currenttime;
currenttime = Sys_DoubleTime (); currenttime = Sys_DoubleTime ();
if (lastpausetime + 1 > currenttime) { if (lastpausetime + 1 > currenttime) {
SV_ClientPrintf (host_client, PRINT_HIGH, "Pause flood not allowed.\n"); SV_ClientPrintf (host_client, PRINT_HIGH,
"Pause flood not allowed.\n");
return; return;
} }
@ -1010,12 +950,12 @@ SV_Pause_f (ucmd_t *cmd)
if (!sv.paused) if (!sv.paused)
snprintf (st, sizeof (st), "%s paused the game\n", host_client->name); snprintf (st, sizeof (st), "%s paused the game\n", host_client->name);
else else
snprintf (st, sizeof (st), "%s unpaused the game\n", host_client->name); snprintf (st, sizeof (st), "%s unpaused the game\n",
host_client->name);
SV_TogglePause (st); SV_TogglePause (st);
} }
/* /*
SV_Drop_f SV_Drop_f
@ -1038,8 +978,8 @@ SV_Drop_f (ucmd_t *cmd)
void void
SV_PTrack_f (ucmd_t *cmd) SV_PTrack_f (ucmd_t *cmd)
{ {
int i;
edict_t *ent, *tent; edict_t *ent, *tent;
int i;
if (!host_client->spectator) if (!host_client->spectator)
return; return;
@ -1070,7 +1010,6 @@ SV_PTrack_f (ucmd_t *cmd)
SVentity (ent, goalentity) = EDICT_TO_PROG (&sv_pr_state, tent); SVentity (ent, goalentity) = EDICT_TO_PROG (&sv_pr_state, tent);
} }
/* /*
SV_Rate_f SV_Rate_f
@ -1079,7 +1018,7 @@ SV_PTrack_f (ucmd_t *cmd)
void void
SV_Rate_f (ucmd_t *cmd) SV_Rate_f (ucmd_t *cmd)
{ {
int rate; int rate;
if (Cmd_Argc () != 2) { if (Cmd_Argc () != 2) {
SV_ClientPrintf (host_client, PRINT_HIGH, "Current rate is %i\n", SV_ClientPrintf (host_client, PRINT_HIGH, "Current rate is %i\n",
@ -1098,7 +1037,6 @@ SV_Rate_f (ucmd_t *cmd)
host_client->netchan.rate = 1.0 / rate; host_client->netchan.rate = 1.0 / rate;
} }
/* /*
SV_Msg_f SV_Msg_f
@ -1153,7 +1091,8 @@ SV_SetInfo_f (ucmd_t *cmd)
} else { } else {
char oldval[MAX_INFO_STRING]; char oldval[MAX_INFO_STRING];
strcpy (oldval, Info_ValueForKey (host_client->userinfo, Cmd_Argv (1))); strcpy (oldval, Info_ValueForKey (host_client->userinfo,
Cmd_Argv (1)));
Info_SetValueForKey (host_client->userinfo, Cmd_Argv (1), Cmd_Argv (2), Info_SetValueForKey (host_client->userinfo, Cmd_Argv (1), Cmd_Argv (2),
!sv_highchars->int_val); !sv_highchars->int_val);
if (strequal if (strequal
@ -1257,8 +1196,8 @@ ucmds_free (void *_c, void *unused)
void void
SV_AddUserCommand (progs_t *pr) SV_AddUserCommand (progs_t *pr)
{ {
ucmd_t *cmd;
const char *name = P_STRING (pr, 0); const char *name = P_STRING (pr, 0);
ucmd_t *cmd;
cmd = Hash_Find (ucmd_table, name); cmd = Hash_Find (ucmd_table, name);
if (cmd && !cmd->overridable) { if (cmd && !cmd->overridable) {
@ -1277,7 +1216,7 @@ SV_AddUserCommand (progs_t *pr)
void void
SV_SetupUserCommands (void) SV_SetupUserCommands (void)
{ {
int i; int i;
Hash_FlushTable (ucmd_table); Hash_FlushTable (ucmd_table);
for (i = 0; i < sizeof (ucmds) / sizeof (ucmds[0]); i++) for (i = 0; i < sizeof (ucmds) / sizeof (ucmds[0]); i++)
@ -1313,9 +1252,7 @@ SV_ExecuteUserCommand (const char *s)
} }
} }
/* // USER CMD EXECUTION =========================================================
USER CMD EXECUTION
*/
/* /*
SV_CalcRoll SV_CalcRoll
@ -1325,10 +1262,8 @@ SV_ExecuteUserCommand (const char *s)
float float
SV_CalcRoll (vec3_t angles, vec3_t velocity) SV_CalcRoll (vec3_t angles, vec3_t velocity)
{ {
vec3_t forward, right, up; vec3_t forward, right, up;
float sign; float side, sign, value;
float side;
float value;
AngleVectors (angles, forward, right, up); AngleVectors (angles, forward, right, up);
side = DotProduct (velocity, right); side = DotProduct (velocity, right);
@ -1346,23 +1281,16 @@ SV_CalcRoll (vec3_t angles, vec3_t velocity)
} }
//============================================================================ //============================================================================
vec3_t pmove_mins, pmove_maxs; vec3_t pmove_mins, pmove_maxs;
/*
AddLinksToPmove
*/
void void
AddLinksToPmove (areanode_t *node) AddLinksToPmove (areanode_t *node)
{ {
link_t *l, *next;
edict_t *check; edict_t *check;
int pl; int pl, i;
int i; link_t *l, *next;
physent_t *pe; physent_t *pe;
pl = EDICT_TO_PROG (&sv_pr_state, sv_player); pl = EDICT_TO_PROG (&sv_pr_state, sv_player);
@ -1375,7 +1303,8 @@ AddLinksToPmove (areanode_t *node)
if (SVentity (check, owner) == pl) if (SVentity (check, owner) == pl)
continue; // player's own missile continue; // player's own missile
if (SVfloat (check, solid) == SOLID_BSP if (SVfloat (check, solid) == SOLID_BSP
|| SVfloat (check, solid) == SOLID_BBOX || SVfloat (check, solid) == SOLID_SLIDEBOX) { || SVfloat (check, solid) == SOLID_BBOX
|| SVfloat (check, solid) == SOLID_SLIDEBOX) {
if (check == sv_player) if (check == sv_player)
continue; continue;
@ -1395,8 +1324,9 @@ AddLinksToPmove (areanode_t *node)
if (sv_fields.rotated_bbox != -1 if (sv_fields.rotated_bbox != -1
&& SVinteger (check, rotated_bbox)) { && SVinteger (check, rotated_bbox)) {
int h = SVinteger (check, rotated_bbox) - 1;
extern clip_hull_t *pf_hull_list[]; extern clip_hull_t *pf_hull_list[];
int h = SVinteger (check, rotated_bbox) - 1;
pe->hull = pf_hull_list[h]->hulls[1]; pe->hull = pf_hull_list[h]->hulls[1];
} else { } else {
pe->hull = 0; pe->hull = 0;
@ -1422,7 +1352,6 @@ AddLinksToPmove (areanode_t *node)
AddLinksToPmove (node->children[1]); AddLinksToPmove (node->children[1]);
} }
/* /*
AddAllEntsToPmove AddAllEntsToPmove
@ -1431,11 +1360,9 @@ AddLinksToPmove (areanode_t *node)
void void
AddAllEntsToPmove (void) AddAllEntsToPmove (void)
{ {
int e;
edict_t *check; edict_t *check;
int i; int pl, e, i;
physent_t *pe; physent_t *pe;
int pl;
pl = EDICT_TO_PROG (&sv_pr_state, sv_player); pl = EDICT_TO_PROG (&sv_pr_state, sv_player);
check = NEXT_EDICT (&sv_pr_state, sv.edicts); check = NEXT_EDICT (&sv_pr_state, sv.edicts);
@ -1475,30 +1402,25 @@ AddAllEntsToPmove (void)
} }
} }
byte playertouch[(MAX_EDICTS + 7) / 8];
/* /*
SV_PreRunCmd SV_PreRunCmd
Done before running a player command. Clears the touch array Done before running a player command. Clears the touch array
*/ */
byte playertouch[(MAX_EDICTS + 7) / 8];
void void
SV_PreRunCmd (void) SV_PreRunCmd (void)
{ {
memset (playertouch, 0, sizeof (playertouch)); memset (playertouch, 0, sizeof (playertouch));
} }
/*
SV_RunCmd
*/
void void
SV_RunCmd (usercmd_t *ucmd, qboolean inside) SV_RunCmd (usercmd_t *ucmd, qboolean inside)
{ {
double tmp_time;
int oldmsec, tmp_time1, i, n;
edict_t *ent; edict_t *ent;
int i, n, oldmsec;
double tmp_time;
int tmp_time1;
if (!inside) { // prevent infinite loop if (!inside) { // prevent infinite loop
host_client->msecs += ucmd->msec; host_client->msecs += ucmd->msec;
@ -1512,8 +1434,8 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
if ((host_client->last_check != -1) // don't do it if new player if ((host_client->last_check != -1) // don't do it if new player
&& (host_client->msecs > tmp_time1)) { && (host_client->msecs > tmp_time1)) {
host_client->msec_cheating++; host_client->msec_cheating++;
SV_BroadcastPrintf (PRINT_HIGH, SV_BroadcastPrintf (PRINT_HIGH, "%s thinks there are %d ms "
"%s thinks there are %d ms in %d seconds (Strike %d/%d)\n", "in %d seconds (Strike %d/%d)\n",
host_client->name, host_client->msecs, host_client->name, host_client->msecs,
(int) tmp_time, host_client->msec_cheating, (int) tmp_time, host_client->msec_cheating,
sv_timekick->int_val); sv_timekick->int_val);
@ -1522,8 +1444,12 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
SV_BroadcastPrintf (PRINT_HIGH, "Strike %d for %s!!\n", SV_BroadcastPrintf (PRINT_HIGH, "Strike %d for %s!!\n",
host_client->msec_cheating, host_client->msec_cheating,
host_client->name); host_client->name);
SV_BroadcastPrintf (PRINT_HIGH, SV_BroadcastPrintf
"Please see http://www.quakeforge.net/speed_cheat.php for information on QuakeForge's time cheat protection. That page explains how some may be cheating without knowing it.\n"); (PRINT_HIGH, "Please see "
"http://www.quakeforge.net/speed_cheat.php for "
"information on QuakeForge's time cheat protection. "
"That page explains how some may be cheating "
"without knowing it.\n");
SV_DropClient (host_client); SV_DropClient (host_client);
} }
} }
@ -1561,23 +1487,24 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
if (host_client->cuff_time > realtime) if (host_client->cuff_time > realtime)
SVfloat (sv_player, button0) = SVfloat (sv_player, impulse) = 0; SVfloat (sv_player, button0) = SVfloat (sv_player, impulse) = 0;
//
// angles // angles
// show 1/3 the pitch angle and all the roll angle // show 1/3 the pitch angle and all the roll angle
if (SVfloat (sv_player, health) > 0) { if (SVfloat (sv_player, health) > 0) {
if (!SVfloat (sv_player, fixangle)) { if (!SVfloat (sv_player, fixangle)) {
SVvector (sv_player, angles)[PITCH] = -SVvector (sv_player, v_angle)[PITCH] / 3; SVvector (sv_player, angles)[PITCH] =
SVvector (sv_player, angles)[YAW] = SVvector (sv_player, v_angle)[YAW]; -SVvector (sv_player, v_angle)[PITCH] / 3;
SVvector (sv_player, angles)[YAW] =
SVvector (sv_player, v_angle)[YAW];
} }
SVvector (sv_player, angles)[ROLL] = SVvector (sv_player, angles)[ROLL] =
SV_CalcRoll (SVvector (sv_player, angles), SVvector (sv_player, velocity)) * 4; SV_CalcRoll (SVvector (sv_player, angles),
SVvector (sv_player, velocity)) * 4;
} }
sv_frametime = min (0.1, ucmd->msec * 0.001); sv_frametime = min (0.1, ucmd->msec * 0.001);
if (!host_client->spectator) { if (!host_client->spectator) {
*sv_globals.frametime = sv_frametime; *sv_globals.frametime = sv_frametime;
*sv_globals.time = sv.time; *sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player); *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.PlayerPreThink); PR_ExecuteProgram (&sv_pr_state, sv_funcs.PlayerPreThink);
@ -1586,8 +1513,7 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
} }
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
pmove.origin[i] = pmove.origin[i] = SVvector (sv_player, origin)[i]
SVvector (sv_player, origin)[i]
+ (SVvector (sv_player, mins)[i] - player_mins[i]); + (SVvector (sv_player, mins)[i] - player_mins[i]);
VectorCopy (SVvector (sv_player, velocity), pmove.velocity); VectorCopy (SVvector (sv_player, velocity), pmove.velocity);
VectorCopy (SVvector (sv_player, v_angle), pmove.angles); VectorCopy (SVvector (sv_player, v_angle), pmove.angles);
@ -1617,7 +1543,7 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
#if 0 #if 0
{ {
int before, after; int before, after;
before = PM_TestPlayerPosition (pmove.origin); before = PM_TestPlayerPosition (pmove.origin);
PlayerMove (); PlayerMove ();
@ -1636,11 +1562,15 @@ SV_RunCmd (usercmd_t *ucmd, qboolean inside)
SVfloat (sv_player, waterlevel) = waterlevel; SVfloat (sv_player, waterlevel) = waterlevel;
SVfloat (sv_player, watertype) = watertype; SVfloat (sv_player, watertype) = watertype;
if (onground != -1) { if (onground != -1) {
SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) | FL_ONGROUND; SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) |
FL_ONGROUND;
SVentity (sv_player, groundentity) = SVentity (sv_player, groundentity) =
EDICT_TO_PROG (&sv_pr_state, EDICT_NUM (&sv_pr_state, pmove.physents[onground].info)); EDICT_TO_PROG (&sv_pr_state,
EDICT_NUM (&sv_pr_state,
pmove.physents[onground].info));
} else { } else {
SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) & ~FL_ONGROUND; SVfloat (sv_player, flags) =
(int) SVfloat (sv_player, flags) & ~FL_ONGROUND;
} }
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
SVvector (sv_player, origin)[i] = SVvector (sv_player, origin)[i] =
@ -1694,7 +1624,6 @@ SV_PostRunCmd (void)
} }
} }
/* /*
SV_ExecuteClientMessage SV_ExecuteClientMessage
@ -1703,15 +1632,13 @@ SV_PostRunCmd (void)
void void
SV_ExecuteClientMessage (client_t *cl) SV_ExecuteClientMessage (client_t *cl)
{ {
int c;
const char *s;
usercmd_t oldest, oldcmd, newcmd;
client_frame_t *frame;
vec3_t o;
qboolean move_issued = false; // only allow one move command
int checksumIndex;
byte checksum, calculatedChecksum; byte checksum, calculatedChecksum;
int seq_hash; const char *s;
client_frame_t *frame;
int checksumIndex, seq_hash, c;
usercmd_t oldest, oldcmd, newcmd;
qboolean move_issued = false; // only allow one move command
vec3_t o;
// calc ping time // calc ping time
frame = &cl->frames[cl->netchan.incoming_acknowledged & UPDATE_MASK]; frame = &cl->frames[cl->netchan.incoming_acknowledged & UPDATE_MASK];
@ -1722,21 +1649,19 @@ SV_ExecuteClientMessage (client_t *cl)
if (cl->netchan.incoming_sequence >= cl->netchan.outgoing_sequence) if (cl->netchan.incoming_sequence >= cl->netchan.outgoing_sequence)
cl->netchan.outgoing_sequence = cl->netchan.incoming_sequence; cl->netchan.outgoing_sequence = cl->netchan.incoming_sequence;
else else
cl->send_message = false; // don't reply, sequences have cl->send_message = false; // don't reply, sequences have slipped
// slipped
// save time for ping calculations // save time for ping calculations
cl->frames[cl->netchan.outgoing_sequence & UPDATE_MASK].senttime = realtime; cl->frames[cl->netchan.outgoing_sequence & UPDATE_MASK].senttime =
realtime;
cl->frames[cl->netchan.outgoing_sequence & UPDATE_MASK].ping_time = -1; cl->frames[cl->netchan.outgoing_sequence & UPDATE_MASK].ping_time = -1;
host_client = cl; host_client = cl;
sv_player = host_client->edict; sv_player = host_client->edict;
// seq_hash = (cl->netchan.incoming_sequence & 0xffff) ; // ^ QW_CHECK_HASH; // seq_hash = (cl->netchan.incoming_sequence & 0xffff) ; // ^ QW_CHECK_HASH;
seq_hash = cl->netchan.incoming_sequence; seq_hash = cl->netchan.incoming_sequence;
// mark time so clients will know how much to predict // mark time so clients will know how much to predict other players
// other players
cl->localtime = sv.time; cl->localtime = sv.time;
cl->delta_sequence = -1; // no delta unless requested cl->delta_sequence = -1; // no delta unless requested
while (1) { while (1) {
@ -1784,8 +1709,8 @@ SV_ExecuteClientMessage (client_t *cl)
// if the checksum fails, ignore the rest of the packet // if the checksum fails, ignore the rest of the packet
calculatedChecksum = calculatedChecksum =
COM_BlockSequenceCRCByte (net_message->message->data + checksumIndex + COM_BlockSequenceCRCByte (net_message->message->data +
1, checksumIndex + 1,
MSG_GetReadCount (net_message) - MSG_GetReadCount (net_message) -
checksumIndex - 1, seq_hash); checksumIndex - 1, seq_hash);
@ -1842,23 +1767,21 @@ SV_ExecuteClientMessage (client_t *cl)
} }
} }
/*
SV_UserInit
*/
void void
SV_UserInit (void) SV_UserInit (void)
{ {
ucmd_table = Hash_NewTable (251, ucmds_getkey, ucmds_free, 0); ucmd_table = Hash_NewTable (251, ucmds_getkey, ucmds_free, 0);
PR_AddBuiltin (&sv_pr_state, "SV_AddUserCommand", SV_AddUserCommand, -1); PR_AddBuiltin (&sv_pr_state, "SV_AddUserCommand", SV_AddUserCommand, -1);
cl_rollspeed = Cvar_Get ("cl_rollspeed", "200", CVAR_NONE, NULL, cl_rollspeed = Cvar_Get ("cl_rollspeed", "200", CVAR_NONE, NULL,
"How quickly a player straightens out after strafing"); "How quickly a player straightens out after "
cl_rollangle = Cvar_Get ("cl_rollangle", "2", CVAR_NONE, NULL, "strafing");
"How much a player's screen tilts when strafing"); cl_rollangle = Cvar_Get ("cl_rollangle", "2", CVAR_NONE, NULL, "How much "
sv_spectalk = Cvar_Get ("sv_spectalk", "1", CVAR_NONE, NULL, "a player's screen tilts when strafing");
"Toggles the ability of spectators to talk to players"); sv_spectalk = Cvar_Get ("sv_spectalk", "1", CVAR_NONE, NULL, "Toggles "
sv_mapcheck = Cvar_Get ("sv_mapcheck", "1", CVAR_NONE, NULL, "the ability of spectators to talk to players");
"Toggle the use of map checksumming to check for players who edit maps to cheat"); sv_mapcheck = Cvar_Get ("sv_mapcheck", "1", CVAR_NONE, NULL, "Toggle the "
"use of map checksumming to check for players who "
"edit maps to cheat");
sv_kickfake = Cvar_Get ("sv_kickfake", "1", CVAR_NONE, NULL, sv_kickfake = Cvar_Get ("sv_kickfake", "1", CVAR_NONE, NULL,
"Kick users sending to send fake talk messages"); "Kick users sending to send fake talk messages");
} }