]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_user.c
simplified dlight fading code
[xonotic/darkplaces.git] / sv_user.c
index f895390fd635365e710092243376677092d08ccb..23c31cbc27127402cf6460e2c9caa8881619ef47 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 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"};
@@ -472,10 +471,6 @@ void SV_ReadClientMove (usercmd_t *move)
                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(sv_player, eval_ping)))
                val->_float = host_client->ping * 1000.0;
 
@@ -517,113 +512,95 @@ void SV_ReadClientMove (usercmd_t *move)
 /*
 ===================
 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
@@ -640,12 +617,6 @@ void SV_RunClients (void)
 
                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