]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_user.c
added GL_AlphaTest function to enable/disable GL_ALPHA_TEST
[xonotic/darkplaces.git] / sv_user.c
index d2fafa04f64696b3541a6b41d7693d948262040a..23a98966a07ccb2842698a8ef539d7586e6e1dbd 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -38,12 +38,12 @@ SV_SetIdealPitch
 #define        MAX_FORWARD     6
 void SV_SetIdealPitch (void)
 {
-       float   angleval, sinval, cosval;
+       float   angleval, sinval, cosval, step, dir;
        trace_t tr;
        vec3_t  top, bottom;
        float   z[MAX_FORWARD];
        int             i, j;
-       int             step, dir, steps;
+       int             steps;
 
        if (!((int)host_client->edict->fields.server->flags & FL_ONGROUND))
                return;
@@ -604,8 +604,12 @@ SV_ReadClientMove
 */
 qboolean SV_ReadClientMove (void)
 {
+       qboolean kickplayer = false;
        int i;
        double oldmovetime;
+#ifdef NUM_PING_TIMES
+       double total;
+#endif
        usercmd_t *move = &host_client->cmd;
 
        oldmovetime = move->time;
@@ -623,6 +627,16 @@ qboolean SV_ReadClientMove (void)
        if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
        move->receivetime = sv.time;
 
+       // 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
+
        // read current angles
        for (i = 0;i < 3;i++)
        {
@@ -694,7 +708,7 @@ qboolean SV_ReadClientMove (void)
                // this fixes the timestamp to prevent a speed cheat from working
                move->time = sv.time;
                // but we kick the player for good measure
-               return true;
+               kickplayer = true;
        }
        else
        {
@@ -711,38 +725,31 @@ qboolean SV_ReadClientMove (void)
                        prog->globals.server->frametime = oldframetime;
                }
        }
-       return false;
+       return kickplayer;
 }
 
 void SV_ApplyClientMove (void)
 {
-#ifdef NUM_PING_TIMES
-       int i;
-       float total;
-#endif
        prvm_eval_t *val;
        usercmd_t *move = &host_client->cmd;
 
-       if (!move->receivetime || move->applied)
+       if (!move->receivetime)
                return;
 
+       // note: a move can be applied multiple times if the client packets are
+       // not coming as often as the physics is executed, and the move must be
+       // applied before running qc each time because the id1 qc had a bug where
+       // it clears self.button2 in PlayerJump, causing pogostick behavior if
+       // moves are not applied every time before calling qc
        move->applied = true;
 
-       // 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;
        if (move->impulse)
                host_client->edict->fields.server->impulse = move->impulse;
+       // only send the impulse to qc once
+       move->impulse = 0;
        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);
@@ -814,7 +821,7 @@ void SV_ReadClientMessage(void)
                        return;
                }
 
-               cmd = MSG_ReadChar ();
+               cmd = MSG_ReadByte ();
                if (cmd == -1)
                {
                        // end of message