]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_input.c
reworked most of q3bsp q3 shader loading, now supports more shader effects (the first...
[xonotic/darkplaces.git] / cl_input.c
index 3266a92eb1d17e0b032281bdef1b35e76fc72e52..cff67be27fa6e2e5e3e0c81ee7c4f2dbcd12b907 100644 (file)
@@ -304,9 +304,9 @@ void CL_AdjustAngles (void)
        float   up, down;
 
        if (in_speed.state & 1)
-               speed = host_realframetime * cl_anglespeedkey.value;
+               speed = cl.realframetime * cl_anglespeedkey.value;
        else
-               speed = host_realframetime;
+               speed = cl.realframetime;
 
        if (!(in_strafe.state & 1))
        {
@@ -354,19 +354,18 @@ Send the intended movement message to the server
 */
 void CL_Move (void)
 {
-       vec3_t temp;
        float mx, my;
        static float old_mouse_x = 0, old_mouse_y = 0;
 
        // clamp before the move to prevent starting with bad angles
        CL_AdjustAngles ();
 
-       // get basic movement from keyboard
-       // PRYDON_CLIENTCURSOR needs to survive basemove resets
-       VectorCopy (cl.cmd.cursor_screen, temp);
-       memset (&cl.cmd, 0, sizeof(cl.cmd));
-       VectorCopy (temp, cl.cmd.cursor_screen);
+       // reset some of the command fields
+       cl.cmd.forwardmove = 0;
+       cl.cmd.sidemove = 0;
+       cl.cmd.upmove = 0;
 
+       // get basic movement from keyboard
        if (in_strafe.state & 1)
        {
                cl.cmd.sidemove += cl_sidespeed.value * CL_KeyState (&in_right);
@@ -511,8 +510,6 @@ void CL_UpdatePrydonCursor(void)
        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);
-       // makes sparks where cursor is
-       //CL_SparkShower(cl.cmd.cursor_impact, cl.cmd.cursor_normal, 5, 0);
 }
 
 void CL_ClientMovement_InputQW(qw_usercmd_t *cmd)
@@ -686,7 +683,7 @@ void CL_ClientMovement_Replay(void)
        VectorSet(neworigin2, currentorigin[0], currentorigin[1], currentorigin[2] - 1);
        if (cl.movement)
        {
-               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_BODY | SUPERCONTENTS_PLAYERCLIP, true);
                onground = trace.fraction < 1 && trace.plane.normal[2] > 0.7;
                crouch = false; // this will be updated on first move
                canjump = true;
@@ -714,7 +711,7 @@ 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_BODY | SUPERCONTENTS_PLAYERCLIP, true);
                                                if (!trace.startsolid)
                                                        crouch = false;
                                        }
@@ -799,7 +796,7 @@ void CL_ClientMovement_Replay(void)
                                                {
                                                        VectorSet(currentorigin2, currentorigin[0] + currentvelocity[0]*(16/f), currentorigin[1] + currentvelocity[1]*(16/f), currentorigin[2] + playermins[2]);
                                                        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);
+                                                       trace = CL_TraceBox(currentorigin2, vec3_origin, vec3_origin, neworigin2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_PLAYERCLIP, true);
                                                        if (trace.fraction == 1)
                                                                edgefriction = movevars_edgefriction;
                                                }
@@ -841,24 +838,27 @@ void CL_ClientMovement_Replay(void)
                                for (bump = 0, t = frametime;bump < 8 && VectorLength2(currentvelocity) > 0;bump++)
                                {
                                        VectorMA(currentorigin, t, currentvelocity, neworigin);
-                                       trace = CL_TraceBox(currentorigin, playermins, playermaxs, neworigin, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_PLAYERCLIP, true);
+                                       trace = CL_TraceBox(currentorigin, playermins, playermaxs, neworigin, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_PLAYERCLIP, true);
                                        if (trace.fraction < 1 && trace.plane.normal[2] == 0)
                                        {
                                                // may be a step or wall, try stepping up
                                                // first move forward at a higher level
                                                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);
-                                               VectorSet(neworigin2, trace2.endpos[0], trace2.endpos[1], currentorigin[2]);
-                                               trace3 = CL_TraceBox(currentorigin2, playermins, playermaxs, neworigin2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_PLAYERCLIP, true);
-                                               //Con_Printf("%f %f %f %f : %f %f %f %f : %f %f %f %f\n", trace.fraction, trace.endpos[0], trace.endpos[1], trace.endpos[2], trace2.fraction, trace2.endpos[0], trace2.endpos[1], trace2.endpos[2], trace3.fraction, trace3.endpos[0], trace3.endpos[1], trace3.endpos[2]);
-                                               // accept the new trace if it made some progress
-                                               if (fabs(trace3.endpos[0] - trace.endpos[0]) >= 0.03125 || fabs(trace3.endpos[1] - trace.endpos[1]) >= 0.03125)
+                                               trace2 = CL_TraceBox(currentorigin2, playermins, playermaxs, neworigin2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_PLAYERCLIP, true);
+                                               if (!trace2.startsolid)
                                                {
-                                                       trace = trace2;
-                                                       VectorCopy(trace3.endpos, trace.endpos);
+                                                       // then move down from there
+                                                       VectorCopy(trace2.endpos, currentorigin2);
+                                                       VectorSet(neworigin2, trace2.endpos[0], trace2.endpos[1], currentorigin[2]);
+                                                       trace3 = CL_TraceBox(currentorigin2, playermins, playermaxs, neworigin2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_PLAYERCLIP, true);
+                                                       //Con_Printf("%f %f %f %f : %f %f %f %f : %f %f %f %f\n", trace.fraction, trace.endpos[0], trace.endpos[1], trace.endpos[2], trace2.fraction, trace2.endpos[0], trace2.endpos[1], trace2.endpos[2], trace3.fraction, trace3.endpos[0], trace3.endpos[1], trace3.endpos[2]);
+                                                       // accept the new trace if it made some progress
+                                                       if (fabs(trace3.endpos[0] - trace.endpos[0]) >= 0.03125 || fabs(trace3.endpos[1] - trace.endpos[1]) >= 0.03125)
+                                                       {
+                                                               trace = trace2;
+                                                               VectorCopy(trace3.endpos, trace.endpos);
+                                                       }
                                                }
                                        }
                                        if (trace.fraction == 1)
@@ -1195,8 +1195,8 @@ void CL_SendMove(void)
                                MSG_WriteByte (&buf, impulse);
                                // PRYDON_CLIENTCURSOR
                                // 30 bytes
-                               MSG_WriteShort (&buf, cl.cmd.cursor_screen[0] * 32767.0f);
-                               MSG_WriteShort (&buf, cl.cmd.cursor_screen[1] * 32767.0f);
+                               MSG_WriteShort (&buf, (short)(cl.cmd.cursor_screen[0] * 32767.0f));
+                               MSG_WriteShort (&buf, (short)(cl.cmd.cursor_screen[1] * 32767.0f));
                                MSG_WriteFloat (&buf, cl.cmd.cursor_start[0]);
                                MSG_WriteFloat (&buf, cl.cmd.cursor_start[1]);
                                MSG_WriteFloat (&buf, cl.cmd.cursor_start[2]);