]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_input.c
moved many cl_ prefixed variables into cl. or cls.
[xonotic/darkplaces.git] / cl_input.c
index 62451ea69295ac61fcfafc276060b4d3e82e628b..8d3b33774e74ac526aa5ff61ee7b4b61cf589b92 100644 (file)
@@ -510,7 +510,7 @@ void CL_UpdatePrydonCursor(void)
        VectorSet(temp, cl.cmd.cursor_screen[2] * scale[2], cl.cmd.cursor_screen[0] * scale[0], cl.cmd.cursor_screen[1] * scale[1]);
        Matrix4x4_Transform(&r_refdef.viewentitymatrix, temp, cl.cmd.cursor_end);
        // trace from view origin to the cursor
-       cl.cmd.cursor_fraction = CL_SelectTraceLine(cl.cmd.cursor_start, cl.cmd.cursor_end, cl.cmd.cursor_impact, cl.cmd.cursor_normal, &cl.cmd.cursor_entitynumber, (chase_active.integer || cl.intermission) ? &cl_entities[cl.playerentity].render : NULL, false);
+       cl.cmd.cursor_fraction = CL_SelectTraceLine(cl.cmd.cursor_start, cl.cmd.cursor_end, cl.cmd.cursor_impact, cl.cmd.cursor_normal, &cl.cmd.cursor_entitynumber, (chase_active.integer || cl.intermission) ? &cl.entities[cl.playerentity].render : NULL, false);
        // makes sparks where cursor is
        //CL_SparkShower(cl.cmd.cursor_impact, cl.cmd.cursor_normal, 5, 0);
 }
@@ -588,6 +588,20 @@ void CL_ClientMovement_Replay(void)
        int contents;
        int crouch;
        int onground;
+       float movevars_gravity;
+       float movevars_stopspeed;
+       float movevars_maxspeed;
+       float movevars_spectatormaxspeed;
+       float movevars_accelerate;
+       float movevars_airaccelerate;
+       float movevars_wateraccelerate;
+       float movevars_friction;
+       float movevars_waterfriction;
+       float movevars_entgravity;
+       float movevars_jumpvelocity;
+       float movevars_edgefriction;
+       float movevars_maxairspeed;
+       float movevars_stepheight;
        double edgefriction;
        double frametime;
        double t;
@@ -612,12 +626,48 @@ void CL_ClientMovement_Replay(void)
        trace_t trace2;
        trace_t trace3;
 
+
        if (!cl.movement_replay)
                return;
        cl.movement_replay = false;
 
+       if (cls.protocol == PROTOCOL_QUAKEWORLD)
+       {
+               movevars_gravity = cl.qw_movevars_gravity;
+               movevars_stopspeed = cl.qw_movevars_stopspeed;
+               movevars_maxspeed = cl.qw_movevars_maxspeed;
+               movevars_spectatormaxspeed = cl.qw_movevars_spectatormaxspeed;
+               movevars_accelerate = cl.qw_movevars_accelerate;
+               movevars_airaccelerate = cl.qw_movevars_airaccelerate;
+               movevars_wateraccelerate = cl.qw_movevars_wateraccelerate;
+               movevars_friction = cl.qw_movevars_friction;
+               movevars_waterfriction = cl.qw_movevars_waterfriction;
+               movevars_entgravity = cl.qw_movevars_entgravity;
+               movevars_jumpvelocity = cl_movement_jumpvelocity.value;
+               movevars_edgefriction = cl_movement_edgefriction.value;
+               movevars_maxairspeed = cl_movement_maxairspeed.value;
+               movevars_stepheight = cl_movement_stepheight.value;
+       }
+       else
+       {
+               movevars_gravity = sv_gravity.value;
+               movevars_stopspeed = cl_movement_stopspeed.value;
+               movevars_maxspeed = cl_movement_maxspeed.value;
+               movevars_spectatormaxspeed = cl_movement_maxspeed.value;
+               movevars_accelerate = cl_movement_accelerate.value;
+               movevars_airaccelerate = cl_movement_accelerate.value;
+               movevars_wateraccelerate = cl_movement_accelerate.value;
+               movevars_friction = cl_movement_friction.value;
+               movevars_waterfriction = cl_movement_friction.value;
+               movevars_entgravity = 1;
+               movevars_jumpvelocity = cl_movement_jumpvelocity.value;
+               movevars_edgefriction = cl_movement_edgefriction.value;
+               movevars_maxairspeed = cl_movement_maxairspeed.value;
+               movevars_stepheight = cl_movement_stepheight.value;
+       }
+
        // fetch current starting values
-       VectorCopy(cl_entities[cl.playerentity].state_current.origin, currentorigin);
+       VectorCopy(cl.entities[cl.playerentity].state_current.origin, currentorigin);
        VectorCopy(cl.mvelocity[0], currentvelocity);
        // FIXME: try minor nudges in various directions if startsolid to find a
        // safe place to start the walk (due to network compression in some
@@ -628,7 +678,7 @@ void CL_ClientMovement_Replay(void)
        // check if onground
        VectorSet(currentorigin2, currentorigin[0], currentorigin[1], currentorigin[2] + 1);
        VectorSet(neworigin2, currentorigin[0], currentorigin[1], currentorigin[2] - 1);
-       trace = CL_TraceBox(currentorigin2, cl_playercrouchmins, cl_playercrouchmaxs, neworigin2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_PLAYERCLIP, true);
+       trace = CL_TraceBox(currentorigin2, cl.playercrouchmins, cl.playercrouchmaxs, neworigin2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_PLAYERCLIP, true);
        onground = trace.fraction < 1 && trace.plane.normal[2] > 0.7;
        //Con_Printf("%f: ", cl.mtime[0]);
 
@@ -654,20 +704,20 @@ void CL_ClientMovement_Replay(void)
                                // low ceiling first
                                if (crouch)
                                {
-                                       trace = CL_TraceBox(currentorigin, cl_playerstandmins, cl_playerstandmaxs, currentorigin, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_PLAYERCLIP, true);
+                                       trace = CL_TraceBox(currentorigin, cl.playerstandmins, cl.playerstandmaxs, currentorigin, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_PLAYERCLIP, true);
                                        if (!trace.startsolid)
                                                crouch = false;
                                }
                        }
                        if (crouch)
                        {
-                               playermins = cl_playercrouchmins;
-                               playermaxs = cl_playercrouchmaxs;
+                               playermins = cl.playercrouchmins;
+                               playermaxs = cl.playercrouchmaxs;
                        }
                        else
                        {
-                               playermins = cl_playerstandmins;
-                               playermaxs = cl_playerstandmaxs;
+                               playermins = cl.playerstandmins;
+                               playermaxs = cl.playerstandmaxs;
                        }
                        // change velocity according to q->viewangles and q->move
                        contents = CL_PointSuperContents(currentorigin);
@@ -682,15 +732,14 @@ void CL_ClientMovement_Replay(void)
                                        VectorScale(wishvel, 1 / wishspeed, wishdir);
                                else
                                        VectorSet( wishdir, 0.0, 0.0, 0.0 );
-                               wishspeed = min(wishspeed, cl_movement_maxspeed.value);
+                               wishspeed = min(wishspeed, movevars_maxspeed) * 0.6;
                                if (crouch)
                                        wishspeed *= 0.5;
-                               wishspeed *= 0.6;
-                               VectorScale(currentvelocity, (1 - frametime * cl_movement_friction.value), currentvelocity);
+                               VectorScale(currentvelocity, (1 - frametime * movevars_waterfriction), currentvelocity);
                                f = wishspeed - DotProduct(currentvelocity, wishdir);
                                if (f > 0)
                                {
-                                       f = min(f, cl_movement_accelerate.value * frametime * wishspeed);
+                                       f = min(f, movevars_wateraccelerate * frametime * wishspeed);
                                        VectorMA(currentvelocity, f, wishdir, currentvelocity);
                                }
                                if (q->jump)
@@ -713,7 +762,7 @@ void CL_ClientMovement_Replay(void)
                                // walk
                                if (onground && q->jump)
                                {
-                                       currentvelocity[2] += cl_movement_jumpvelocity.value;
+                                       currentvelocity[2] += movevars_jumpvelocity;
                                        onground = false;
                                }
                                VectorSet(yawangles, 0, q->viewangles[1], 0);
@@ -724,7 +773,7 @@ void CL_ClientMovement_Replay(void)
                                        VectorScale(wishvel, 1 / wishspeed, wishdir);
                                else
                                        VectorSet( wishdir, 0.0, 0.0, 0.0 );
-                               wishspeed = min(wishspeed, cl_movement_maxspeed.value);
+                               wishspeed = min(wishspeed, movevars_maxspeed);
                                if (crouch)
                                        wishspeed *= 0.5;
                                // check if onground
@@ -739,17 +788,17 @@ void CL_ClientMovement_Replay(void)
                                                VectorSet(neworigin2, currentorigin2[0], currentorigin2[1], currentorigin2[2] - 34);
                                                trace = CL_TraceBox(currentorigin2, vec3_origin, vec3_origin, neworigin2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_PLAYERCLIP, true);
                                                if (trace.fraction == 1)
-                                                       edgefriction = cl_movement_edgefriction.value;
+                                                       edgefriction = movevars_edgefriction;
                                        }
                                        // apply friction
-                                       f = 1 - frametime * edgefriction * ((f < cl_movement_stopspeed.value) ? (cl_movement_stopspeed.value / f) : 1) * cl_movement_friction.value;
+                                       f = 1 - frametime * edgefriction * ((f < movevars_stopspeed) ? (movevars_stopspeed / f) : 1) * movevars_friction;
                                        f = max(f, 0);
                                        VectorScale(currentvelocity, f, currentvelocity);
                                }
                                else
                                {
                                        // apply air speed limit
-                                       wishspeed = min(wishspeed, cl_movement_maxairspeed.value);
+                                       wishspeed = min(wishspeed, movevars_maxairspeed);
                                }
                                if (gamemode == GAME_NEXUIZ)
                                        addspeed = wishspeed;
@@ -757,7 +806,7 @@ void CL_ClientMovement_Replay(void)
                                        addspeed = wishspeed - DotProduct(currentvelocity, wishdir);
                                if (addspeed > 0)
                                {
-                                       accelspeed = min(cl_movement_accelerate.value * frametime * wishspeed, addspeed);
+                                       accelspeed = min(movevars_accelerate * frametime * wishspeed, addspeed);
                                        VectorMA(currentvelocity, accelspeed, wishdir, currentvelocity);
                                }
                                currentvelocity[2] -= cl_gravity.value * frametime;
@@ -767,13 +816,13 @@ void CL_ClientMovement_Replay(void)
                {
                        if (crouch)
                        {
-                               playermins = cl_playercrouchmins;
-                               playermaxs = cl_playercrouchmaxs;
+                               playermins = cl.playercrouchmins;
+                               playermaxs = cl.playercrouchmaxs;
                        }
                        else
                        {
-                               playermins = cl_playerstandmins;
-                               playermaxs = cl_playerstandmaxs;
+                               playermins = cl.playerstandmins;
+                               playermaxs = cl.playerstandmaxs;
                        }
                        onground = false;
                        for (bump = 0, t = frametime;bump < 8 && VectorLength2(currentvelocity) > 0;bump++)
@@ -784,8 +833,8 @@ void CL_ClientMovement_Replay(void)
                                {
                                        // may be a step or wall, try stepping up
                                        // first move forward at a higher level
-                                       VectorSet(currentorigin2, currentorigin[0], currentorigin[1], currentorigin[2] + cl_movement_stepheight.value);
-                                       VectorSet(neworigin2, neworigin[0], neworigin[1], currentorigin[2] + cl_movement_stepheight.value);
+                                       VectorSet(currentorigin2, currentorigin[0], currentorigin[1], currentorigin[2] + movevars_stepheight);
+                                       VectorSet(neworigin2, neworigin[0], neworigin[1], currentorigin[2] + movevars_stepheight);
                                        trace2 = CL_TraceBox(currentorigin2, playermins, playermaxs, neworigin2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_PLAYERCLIP, true);
                                        // then move down from there
                                        VectorCopy(trace2.endpos, currentorigin2);
@@ -818,8 +867,8 @@ void CL_ClientMovement_Replay(void)
        VectorCopy(cl.movement_origin, cl.movement_oldorigin);
        VectorCopy(currentorigin, cl.movement_origin);
        VectorCopy(currentvelocity, cl.movement_velocity);
-       //VectorCopy(currentorigin, cl_entities[cl.playerentity].state_current.origin);
-       //VectorSet(cl_entities[cl.playerentity].state_current.angles, 0, cl.viewangles[1], 0);
+       //VectorCopy(currentorigin, cl.entities[cl.playerentity].state_current.origin);
+       //VectorSet(cl.entities[cl.playerentity].state_current.angles, 0, cl.viewangles[1], 0);
 }
 
 void QW_MSG_WriteDeltaUsercmd(sizebuf_t *buf, qw_usercmd_t *from, qw_usercmd_t *to)
@@ -858,9 +907,9 @@ void QW_MSG_WriteDeltaUsercmd(sizebuf_t *buf, qw_usercmd_t *from, qw_usercmd_t *
        if (bits & QW_CM_UP)
                MSG_WriteShort(buf, to->upmove);
        if (bits & QW_CM_BUTTONS)
-               MSG_WriteShort(buf, to->buttons);
+               MSG_WriteByte(buf, to->buttons);
        if (bits & QW_CM_IMPULSE)
-               MSG_WriteShort(buf, to->impulse);
+               MSG_WriteByte(buf, to->impulse);
        MSG_WriteByte(buf, to->msec);
 }
 
@@ -896,7 +945,7 @@ void CL_SendMove(void)
        accumtotal++;
 #endif
 
-       if (cl_movement.integer && cls.signon == SIGNONS)
+       if (cl_movement.integer && cls.signon == SIGNONS && cls.protocol != PROTOCOL_QUAKEWORLD)
        {
                if (!cl.movement_needupdate)
                        return;
@@ -986,6 +1035,7 @@ void CL_SendMove(void)
                        // PROTOCOL_DARKPLACES5  clc_move = 19 bytes total
                        // PROTOCOL_DARKPLACES6  clc_move = 52 bytes total
                        // PROTOCOL_DARKPLACES7  clc_move = 56 bytes total
+                       // PROTOCOL_QUAKEWORLD   clc_move = 34 bytes total (typically, but can reach 43 bytes, or even 49 bytes with roll)
                        if (cls.protocol == PROTOCOL_QUAKEWORLD)
                        {
                                int checksumindex;
@@ -1042,9 +1092,12 @@ void CL_SendMove(void)
                                // request delta compression if appropriate
                                if (cl.qw_validsequence && !cl_nodelta.integer && cls.state == ca_connected && !cls.demorecording)
                                {
+                                       cl.qw_deltasequence[cls.netcon->qw.outgoing_sequence & QW_UPDATE_MASK] = cl.qw_validsequence;
                                        MSG_WriteByte(&buf, qw_clc_delta);
                                        MSG_WriteByte(&buf, cl.qw_validsequence & 255);
                                }
+                               else
+                                       cl.qw_deltasequence[cls.netcon->qw.outgoing_sequence & QW_UPDATE_MASK] = -1;
                        }
                        else if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE)
                        {