]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_input.c
OGG_FreeSfx and WAV_FreeSfx no longer reference sfx_t
[xonotic/darkplaces.git] / cl_input.c
index d0eb0098e2b406e6dc941634cf23e39c971eb623..a5387e0e2c3aef1f6f9a658d435503aa260adf47 100644 (file)
@@ -349,11 +349,14 @@ cvar_t in_pitch_max = {0, "in_pitch_max", "90", "how far upward you can aim (qua
 
 cvar_t m_filter = {CVAR_SAVE, "m_filter","0", "smoothes mouse movement, less responsive but smoother aiming"};
 
-cvar_t cl_netinputpacketspersecond = {CVAR_SAVE, "cl_netinputpacketspersecond","50", "how many input packets to send to server each second"};
+cvar_t cl_netinputpacketsperserverpacket = {CVAR_SAVE, "cl_netinputpacketsperserverpacket", "1.0", "send this many input packets per server packet received"};
+cvar_t cl_netinputpacketspersecond = {CVAR_SAVE, "cl_netinputpacketspersecond","20", "how many input packets to send to server each second (only used on old servers, and note this is multiplied by cl_netinputpacketsperserverpacket)"};
+cvar_t cl_netinputpacketspersecond_qw = {CVAR_SAVE, "cl_netinputpacketspersecond","72", "how many input packets to send to a qw server each second (only used on qw servers)"};
 cvar_t cl_netinputpacketlosstolerance = {CVAR_SAVE, "cl_netinputpacketlosstolerance", "1", "how many packets in a row can be lost without movement issues when using cl_movement (technically how many input messages to repeat in each packet that have not yet been acknowledged by the server), only affects DP7 and later servers (Quake uses 0, QuakeWorld uses 2, and just for comparison Quake3 uses 1)"};
 
 cvar_t cl_nodelta = {0, "cl_nodelta", "0", "disables delta compression of non-player entities in QW network protocol"};
 
+extern cvar_t v_flipped;
 
 /*
 ================
@@ -424,6 +427,9 @@ void CL_Input (void)
        // clamp before the move to prevent starting with bad angles
        CL_AdjustAngles ();
 
+       if(v_flipped.integer)
+               cl.viewangles[YAW] = -cl.viewangles[YAW];
+
        // reset some of the command fields
        cl.cmd.forwardmove = 0;
        cl.cmd.sidemove = 0;
@@ -519,6 +525,12 @@ void CL_Input (void)
                }
        }
 
+       if(v_flipped.integer)
+       {
+               cl.viewangles[YAW] = -cl.viewangles[YAW];
+               cl.cmd.sidemove = -cl.cmd.sidemove;
+       }
+
        // clamp after the move to prevent rendering with bad angles
        CL_AdjustAngles ();
 }
@@ -561,7 +573,7 @@ void CL_UpdatePrydonCursor(void)
        // calculate current view matrix
        Matrix4x4_OriginFromMatrix(&r_view.matrix, cl.cmd.cursor_start);
        // calculate direction vector of cursor in viewspace by using frustum slopes
-       VectorSet(temp, cl.cmd.cursor_screen[2] * 1000000, cl.cmd.cursor_screen[0] * -r_view.frustum_x * 1000000, cl.cmd.cursor_screen[1] * -r_view.frustum_y * 1000000);
+       VectorSet(temp, cl.cmd.cursor_screen[2] * 1000000, (v_flipped.integer ? -1 : 1) * cl.cmd.cursor_screen[0] * -r_view.frustum_x * 1000000, cl.cmd.cursor_screen[1] * -r_view.frustum_y * 1000000);
        Matrix4x4_Transform(&r_view.matrix, 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);
@@ -1048,13 +1060,7 @@ extern cvar_t slowmo;
 void CL_UpdateMoveVars(void)
 {
        if (cls.protocol == PROTOCOL_QUAKEWORLD)
-       {
-               cl.movevars_timescale = 1;
-               cl.movevars_ticrate = 1.0 / bound(1, cl_netinputpacketspersecond.value, 100);
-               // scale playback speed of demos by slowmo cvar
-               if (cls.demoplayback)
-                       cl.movevars_timescale *= slowmo.value;
-       }
+               cl.movevars_ticrate = 1.0 / bound(1, cl_netinputpacketspersecond_qw.value, 100);
        else if (cl.stats[STAT_MOVEVARS_TICRATE])
        {
                cl.movevars_ticrate = cl.statsf[STAT_MOVEVARS_TICRATE];
@@ -1076,9 +1082,6 @@ void CL_UpdateMoveVars(void)
                cl.movevars_friction = cl.statsf[STAT_MOVEVARS_FRICTION];
                cl.movevars_wallfriction = cl.statsf[STAT_MOVEVARS_WALLFRICTION];
                cl.movevars_waterfriction = cl.statsf[STAT_MOVEVARS_WATERFRICTION];
-               // scale playback speed of demos by slowmo cvar
-               if (cls.demoplayback)
-                       cl.movevars_timescale *= slowmo.value;
        }
        else
        {
@@ -1270,33 +1273,28 @@ void CL_SendMove(void)
 
        // don't send too often or else network connections can get clogged by a high renderer framerate
        packettime = cl.movevars_ticrate;
+       if (cls.protocol != PROTOCOL_QUAKEWORLD)
+               packettime /= (double)bound(1, cl_netinputpacketsperserverpacket.value, 10);
+       // send input every frame in singleplayer
+       if (cl.islocalgame)
+               packettime = 0;
        // quakeworld servers take only frametimes
        // predicted dp7 servers take current interpolation time
        // unpredicted servers take an echo of the latest server timestamp
+       cl.cmd.time = cl.time;
+       cl.cmd.sequence = cls.movesequence;
        if (cls.protocol == PROTOCOL_QUAKEWORLD)
        {
                if (realtime < lastsendtime + packettime)
                        return;
-               cl.cmd.time = realtime;
                cl.cmd.sequence = cls.netcon->qw.outgoing_sequence;
        }
-       else if (cl.movement_predicted)
-       {
-               if (realtime < lastsendtime + packettime)
-                       return;
-               cl.cmd.time = cl.time;
-               cl.cmd.sequence = cls.movesequence;
-       }
        else
        {
-               // unpredicted movement should be sent immediately whenever a server
+               // movement should be sent immediately whenever a server
                // packet is received, to minimize ping times
                if (!cl.movement_needupdate && realtime < lastsendtime + packettime)
                        return;
-               if (cl.mtime[0] == cl.movecmd[0].time && cl.mtime[1] != cl.mtime[0])
-                       return;
-               cl.cmd.time = cl.mtime[0];
-               cl.cmd.sequence = cls.movesequence;
        }
 
        // don't let it fall behind if CL_SendMove hasn't been called recently
@@ -1315,7 +1313,7 @@ void CL_SendMove(void)
        // don't send a new input packet if the connection is still saturated from
        // the last one (or chat messages, etc)
        // note: this behavior comes from QW
-       if ((cls.protocol == PROTOCOL_QUAKEWORLD || cls.signon == SIGNONS) && !NetConn_CanSend(cls.netcon))
+       if ((cls.protocol == PROTOCOL_QUAKEWORLD || cls.signon == SIGNONS) && !NetConn_CanSend(cls.netcon) && !cl.islocalgame)
                return;
 
        // increase the move counter since we intend to send a move
@@ -1564,7 +1562,7 @@ void CL_SendMove(void)
 
        // send the reliable message (forwarded commands) if there is one
        if (buf.cursize || cls.netcon->message.cursize)
-               NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, max(20*(buf.cursize+40), cl_rate.integer));
+               NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, max(20*(buf.cursize+40), cl_rate.integer), false);
 
        if (cls.netcon->message.overflowed)
        {
@@ -1673,7 +1671,9 @@ void CL_InitInput (void)
        Cvar_RegisterVariable(&in_pitch_max);
        Cvar_RegisterVariable(&m_filter);
 
+       Cvar_RegisterVariable(&cl_netinputpacketsperserverpacket);
        Cvar_RegisterVariable(&cl_netinputpacketspersecond);
+       Cvar_RegisterVariable(&cl_netinputpacketspersecond_qw);
        Cvar_RegisterVariable(&cl_netinputpacketlosstolerance);
 
        Cvar_RegisterVariable(&cl_nodelta);