]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_user.c
allow multiple lightning beams owned by world
[xonotic/darkplaces.git] / sv_user.c
index ef51038a78dc5b1306245d75e5ee824edd00cd05..f251a8bc0c4db2c7ac019596679eccb98a69fb92 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -603,6 +603,7 @@ SV_ReadClientMove
 ===================
 */
 extern void SV_Physics_Entity (prvm_edict_t *ent, qboolean runmove);
+void SV_ApplyClientMove (void);
 void SV_ReadClientMove (void)
 {
        int i;
@@ -649,9 +650,7 @@ void SV_ReadClientMove (void)
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
 
        // read impulse
-       i = MSG_ReadByte ();
-       if (i)
-               move->impulse = i;
+       move->impulse = MSG_ReadByte ();
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
 
        // PRYDON_CLIENTCURSOR
@@ -683,6 +682,8 @@ void SV_ReadClientMove (void)
                memset(move, 0, sizeof(*move));
        else
        {
+               // apply the latest accepted move to the entity fields
+               SV_ApplyClientMove();
                host_client->movesequence = move->sequence;
                if (host_client->movesequence)
                {
@@ -699,22 +700,28 @@ void SV_ReadClientMove (void)
 
 void SV_ApplyClientMove (void)
 {
+#ifdef NUM_PING_TIMES
        int i;
-       prvm_eval_t *val;
        float total;
+#endif
+       prvm_eval_t *val;
        usercmd_t *move = &host_client->cmd;
 
        // calculate average ping time
+       host_client->ping = move->receivetime - move->time;
+#ifdef NUM_PING_TIMES
        host_client->ping_times[host_client->num_pings % NUM_PING_TIMES] = move->receivetime - move->time;
        host_client->num_pings++;
        for (i=0, total = 0;i < NUM_PING_TIMES;i++)
                total += host_client->ping_times[i];
        host_client->ping = total / NUM_PING_TIMES;
+#endif
 
        // set the edict fields
        host_client->edict->fields.server->button0 = move->buttons & 1;
        host_client->edict->fields.server->button2 = (move->buttons & 2)>>1;
-       host_client->edict->fields.server->impulse = move->impulse;
+       if (move->impulse)
+               host_client->edict->fields.server->impulse = move->impulse;
        VectorCopy(move->viewangles, host_client->edict->fields.server->v_angle);
        if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button3))) val->_float = ((move->buttons >> 2) & 1);
        if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_button4))) val->_float = ((move->buttons >> 3) & 1);