edict_t *sv_player;
cvar_t sv_edgefriction = {0, "edgefriction", "2"};
-cvar_t sv_predict = {0, "sv_predict", "1"};
cvar_t sv_deltacompress = {0, "sv_deltacompress", "1"};
cvar_t sv_idealpitchscale = {0, "sv_idealpitchscale","0.8"};
cvar_t sv_maxspeed = {CVAR_NOTIFY, "sv_maxspeed", "320"};
total += host_client->ping_times[i];
// can be used for prediction
host_client->ping = total / NUM_PING_TIMES;
- host_client->latency = 0;
- // if paused or a local game, don't predict
- if (sv_predict.integer && (svs.maxclients > 1) && (!sv.paused))
- host_client->latency = host_client->ping;
- if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_ping)))
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_ping)))
val->_float = host_client->ping * 1000.0;
// read current angles
for (i = 0;i < 3;i++)
angle[i] = MSG_ReadFloat ();
- VectorCopy (angle, host_client->edict->v->v_angle);
+ VectorCopy (angle, sv_player->v->v_angle);
// read movement
move->forwardmove = MSG_ReadShort ();
move->sidemove = MSG_ReadShort ();
move->upmove = MSG_ReadShort ();
- if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_movement)))
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_movement)))
{
val->vector[0] = move->forwardmove;
val->vector[1] = move->sidemove;
// read buttons
bits = MSG_ReadByte ();
- host_client->edict->v->button0 = bits & 1;
- host_client->edict->v->button2 = (bits & 2)>>1;
+ sv_player->v->button0 = bits & 1;
+ sv_player->v->button2 = (bits & 2)>>1;
// LordHavoc: added 6 new buttons
- if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button3))) val->_float = ((bits >> 2) & 1);
- if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button4))) val->_float = ((bits >> 3) & 1);
- if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button5))) val->_float = ((bits >> 4) & 1);
- if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button6))) val->_float = ((bits >> 5) & 1);
- if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button7))) val->_float = ((bits >> 6) & 1);
- if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_button8))) val->_float = ((bits >> 7) & 1);
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_button3))) val->_float = ((bits >> 2) & 1);
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_button4))) val->_float = ((bits >> 3) & 1);
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_button5))) val->_float = ((bits >> 4) & 1);
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_button6))) val->_float = ((bits >> 5) & 1);
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_button7))) val->_float = ((bits >> 6) & 1);
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_button8))) val->_float = ((bits >> 7) & 1);
i = MSG_ReadByte ();
if (i)
- host_client->edict->v->impulse = i;
+ sv_player->v->impulse = i;
}
/*
===================
SV_ReadClientMessage
-
-Returns false if the client should be killed
===================
*/
-extern void SV_SendServerinfo (client_t *client);
-qboolean SV_ReadClientMessage (void)
+extern void SV_SendServerinfo(client_t *client);
+void SV_ReadClientMessage(void)
{
- int ret;
- int cmd;
- char *s;
+ int cmd;
+ char *s;
+
+ //MSG_BeginReading ();
- do
+ for(;;)
{
-nextmsg:
- ret = NET_GetMessage (host_client->netconnection);
- if (ret == -1)
+ if (!host_client->active)
{
- Con_Printf ("SV_ReadClientMessage: NET_GetMessage failed\n");
- return false;
+ // a command caused an error
+ SV_DropClient (false);
+ return;
}
- if (!ret)
- return true;
- MSG_BeginReading ();
+ if (msg_badread)
+ {
+ Con_Printf ("SV_ReadClientMessage: badread\n");
+ SV_DropClient (false);
+ return;
+ }
- while (1)
+ cmd = MSG_ReadChar ();
+ if (cmd == -1)
{
- if (!host_client->active)
- // a command caused an error
- return false;
+ // end of message
+ break;
+ }
- if (msg_badread)
- {
- Con_Printf ("SV_ReadClientMessage: badread\n");
- return false;
- }
+ switch (cmd)
+ {
+ default:
+ Con_Printf ("SV_ReadClientMessage: unknown command char %i\n", cmd);
+ SV_DropClient (false);
+ return;
- cmd = MSG_ReadChar ();
+ case clc_nop:
+ break;
-#ifndef NOROUTINGFIX
- if (cmd != -1 && host_client->waitingforconnect)
+ case clc_stringcmd:
+ s = MSG_ReadString ();
+ if (strncasecmp(s, "spawn", 5) == 0
+ || strncasecmp(s, "begin", 5) == 0
+ || strncasecmp(s, "prespawn", 8) == 0)
+ Cmd_ExecuteString (s, src_client);
+ else if (SV_ParseClientCommandQC)
{
- host_client->waitingforconnect = false;
- host_client->sendserverinfo = true;
+ G_INT(OFS_PARM0) = PR_SetString(s);
+ pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
+ PR_ExecuteProgram ((func_t)(SV_ParseClientCommandQC - pr_functions), "");
}
-#endif
+ else if (strncasecmp(s, "status", 6) == 0
+ || strncasecmp(s, "name", 4) == 0
+ || strncasecmp(s, "say", 3) == 0
+ || strncasecmp(s, "say_team", 8) == 0
+ || strncasecmp(s, "tell", 4) == 0
+ || strncasecmp(s, "color", 5) == 0
+ || strncasecmp(s, "kill", 4) == 0
+ || strncasecmp(s, "pause", 5) == 0
+ || strncasecmp(s, "kick", 4) == 0
+ || strncasecmp(s, "ping", 4) == 0
+ || strncasecmp(s, "ban", 3) == 0
+ || strncasecmp(s, "pmodel", 6) == 0
+ || (gamemode == GAME_NEHAHRA && (strncasecmp(s, "max", 3) == 0 || strncasecmp(s, "monster", 7) == 0 || strncasecmp(s, "scrag", 5) == 0 || strncasecmp(s, "gimme", 5) == 0 || strncasecmp(s, "wraith", 6) == 0))
+ || (gamemode != GAME_NEHAHRA && (strncasecmp(s, "god", 3) == 0 || strncasecmp(s, "notarget", 8) == 0 || strncasecmp(s, "fly", 3) == 0 || strncasecmp(s, "give", 4) == 0 || strncasecmp(s, "noclip", 6) == 0)))
+ Cmd_ExecuteString (s, src_client);
+ else
+ Con_Printf("%s tried to %s\n", host_client->name, s);
+ break;
- switch (cmd)
- {
- case -1:
- // end of message
- goto nextmsg;
-
- default:
- Con_Printf ("SV_ReadClientMessage: unknown command char %i\n", cmd);
- return false;
-
- case clc_nop:
- break;
-
- case clc_stringcmd:
- s = MSG_ReadString ();
- ret = 0;
- if (strncasecmp(s, "status", 6) == 0
- || strncasecmp(s, "name", 4) == 0
- || strncasecmp(s, "say", 3) == 0
- || strncasecmp(s, "say_team", 8) == 0
- || strncasecmp(s, "tell", 4) == 0
- || strncasecmp(s, "color", 5) == 0
- || strncasecmp(s, "kill", 4) == 0
- || strncasecmp(s, "pause", 5) == 0
- || strncasecmp(s, "spawn", 5) == 0
- || strncasecmp(s, "begin", 5) == 0
- || strncasecmp(s, "prespawn", 8) == 0
- || strncasecmp(s, "kick", 4) == 0
- || strncasecmp(s, "ping", 4) == 0
- || strncasecmp(s, "ban", 3) == 0
- || strncasecmp(s, "pmodel", 6) == 0
- || (gamemode == GAME_NEHAHRA && (strncasecmp(s, "max", 3) == 0 || strncasecmp(s, "monster", 7) == 0 || strncasecmp(s, "scrag", 5) == 0 || strncasecmp(s, "gimme", 5) == 0 || strncasecmp(s, "wraith", 6) == 0))
- || (gamemode != GAME_NEHAHRA && (strncasecmp(s, "god", 3) == 0 || strncasecmp(s, "notarget", 8) == 0 || strncasecmp(s, "fly", 3) == 0 || strncasecmp(s, "give", 4) == 0 || strncasecmp(s, "noclip", 6) == 0)))
- {
- ret = 1;
- Cmd_ExecuteString (s, src_client);
- }
- else
- Con_Printf("%s tried to %s\n", host_client->name, s);
- break;
-
- case clc_disconnect:
- return false;
-
- case clc_move:
- SV_ReadClientMove (&host_client->cmd);
- break;
-
- case clc_ackentities:
- EntityFrame_AckFrame(&host_client->entitydatabase, MSG_ReadLong());
- break;
- }
+ case clc_disconnect:
+ SV_DropClient (false); // client wants to disconnect
+ return;
+
+ case clc_move:
+ SV_ReadClientMove (&host_client->cmd);
+ break;
+
+ case clc_ackentities:
+ EntityFrame_AckFrame(&host_client->entitydatabase, MSG_ReadLong());
+ break;
}
}
- while (ret == 1);
-
- return true;
}
-
/*
==================
SV_RunClients
sv_player = host_client->edict;
- if (!SV_ReadClientMessage ())
- {
- SV_DropClient (false); // client misbehaved...
- continue;
- }
-
if (!host_client->spawned)
{
// clear client movement until a new packet is received