]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_input.c
physics: fix and refactor unsticking
[xonotic/darkplaces.git] / cl_input.c
index 49fd61d031416b57295220f9b60bf0e2f066ec1a..21c2ad6435e7049b3795e87dbe8342001b6e7f6d 100644 (file)
@@ -211,7 +211,7 @@ static void IN_BestWeapon_Register(const char *name, int impulse, int weaponbit,
                Con_Printf("no slot left for weapon definition; increase IN_BESTWEAPON_MAX\n");
                return; // sorry
        }
-       strlcpy(in_bestweapon_info[i].name, name, sizeof(in_bestweapon_info[i].name));
+       dp_strlcpy(in_bestweapon_info[i].name, name, sizeof(in_bestweapon_info[i].name));
        in_bestweapon_info[i].impulse = impulse;
        if(weaponbit != -1)
                in_bestweapon_info[i].weaponbit = weaponbit;
@@ -399,7 +399,7 @@ cvar_t in_pitch_min = {CF_CLIENT, "in_pitch_min", "-90", "how far you can aim up
 cvar_t in_pitch_max = {CF_CLIENT, "in_pitch_max", "90", "how far you can aim downward (quake used 80)"};
 
 cvar_t m_filter = {CF_CLIENT | CF_ARCHIVE, "m_filter","0", "smoothes mouse movement, less responsive but smoother aiming"}; 
-cvar_t m_accelerate = {CF_CLIENT | CF_ARCHIVE, "m_accelerate","1", "linear mouse acceleration factor (set to 1 to disable the linear acceleration and use only the power acceleration; set to 0 to disable all acceleration)"};
+cvar_t m_accelerate = {CF_CLIENT | CF_ARCHIVE, "m_accelerate","1", "linear mouse acceleration factor (set to 1 to disable the linear acceleration and use only the power or natural acceleration; set to 0 to disable all acceleration)"};
 cvar_t m_accelerate_minspeed = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_minspeed","5000", "below this speed in px/s, no acceleration is done, with a linear slope between (applied only on linear acceleration)"};
 cvar_t m_accelerate_maxspeed = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_maxspeed","10000", "above this speed in px/s, full acceleration is done, with a linear slope between (applied only on linear acceleration)"};
 cvar_t m_accelerate_filter = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_filter","0", "linear mouse acceleration factor filtering lowpass constant in seconds (set to 0 for no filtering)"};
@@ -407,6 +407,9 @@ cvar_t m_accelerate_power_offset = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_power_
 cvar_t m_accelerate_power = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_power","2", "acceleration power (must be above 1 to be useful)"};
 cvar_t m_accelerate_power_senscap = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_power_senscap", "0", "maximum acceleration factor generated by power acceleration; use 0 for unbounded"};
 cvar_t m_accelerate_power_strength = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_power_strength", "0", "strength of the power mouse acceleration effect"};
+cvar_t m_accelerate_natural_strength = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_natural_strength", "0", "How quickly the accelsensitivity approaches the m_accelerate_natural_accelsenscap, values are compressed between 0 and 1 but higher numbers are allowed"};
+cvar_t m_accelerate_natural_accelsenscap = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_natural_accelsenscap", "0", "Horizontal asymptote that sets the maximum value for the natural mouse acceleration curve, value 2, for example, means that the maximum sensitivity is 2 times the base sensitivity"};
+cvar_t m_accelerate_natural_offset = {CF_CLIENT | CF_ARCHIVE, "m_accelerate_natural_offset", "0", "below this speed in px/ms, no natural acceleration is done"};
 
 cvar_t cl_netfps = {CF_CLIENT | CF_ARCHIVE, "cl_netfps","72", "how many input packets to send to server each second"};
 cvar_t cl_netrepeatinput = {CF_CLIENT | CF_ARCHIVE, "cl_netrepeatinput", "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)"};
@@ -524,7 +527,7 @@ void CL_Input (void)
        IN_Move ();
 
        // send mouse move to csqc
-       if (cl.csqc_loaded && cl_csqc_generatemousemoveevents.integer)
+       if (CLVM_prog->loaded && cl_csqc_generatemousemoveevents.integer)
        {
                if (cl.csqc_wantsmousemove)
                {
@@ -532,7 +535,7 @@ void CL_Input (void)
                        static int oldwindowmouse[2];
                        if (oldwindowmouse[0] != in_windowmouse_x || oldwindowmouse[1] != in_windowmouse_y)
                        {
-                               CL_VM_InputEvent(3, in_windowmouse_x * vid_conwidth.value / vid.width, in_windowmouse_y * vid_conheight.value / vid.height);
+                               CL_VM_InputEvent(3, in_windowmouse_x * vid_conwidth.value / vid.mode.width, in_windowmouse_y * vid_conheight.value / vid.mode.height);
                                oldwindowmouse[0] = in_windowmouse_x;
                                oldwindowmouse[1] = in_windowmouse_y;
                        }
@@ -544,7 +547,7 @@ void CL_Input (void)
                }
        }
 
-       // apply m_accelerate if it is on
+       // apply m_accelerate if it is on
        if(m_accelerate.value > 0)
        {
                float mouse_deltadist = sqrtf(in_mouse_x * in_mouse_x + in_mouse_y * in_mouse_y);
@@ -552,9 +555,9 @@ void CL_Input (void)
                static float averagespeed = 0;
                float f, mi, ma;
                if(m_accelerate_filter.value > 0)
-                       f = bound(0, cl.realframetime / m_accelerate_filter.value, 1);
+                       f = bound(0, cl.realframetime / m_accelerate_filter.value, 1);
                else
-                       f = 1;
+                       f = 1;
                averagespeed = speed * f + averagespeed * (1 - f);
 
                // Note: this check is technically unnecessary, as everything in here cancels out if it is zero.
@@ -589,7 +592,7 @@ void CL_Input (void)
                {
                        // Then do Quake Live-style power acceleration.
                        // Note that this behavior REPLACES the usual
-                       // sensitivity, so we apply it but then dividie by
+                       // sensitivity, so we apply it but then divide by
                        // sensitivity.value so that the later multiplication
                        // restores it again.
                        float accelsens = 1.0f;
@@ -620,7 +623,25 @@ void CL_Input (void)
                        {
                                // TODO: How does this interact with sensitivity changes? Is this intended?
                                // Currently: senscap is in absolute sensitivity units, so if senscap < sensitivity, it overrides.
-                               accelsens = m_accelerate_power_senscap.value * inv_sensitivity;
+                               accelsens = m_accelerate_power_senscap.value * inv_sensitivity;
+                       }
+
+                       in_mouse_x *= accelsens;
+                       in_mouse_y *= accelsens;
+               }
+
+               if (m_accelerate_natural_strength.value > 0.0f && m_accelerate_natural_accelsenscap.value >= 0.0f)
+               {
+                       float accelsens = 1.0f;
+                       float adjusted_speed_pxms = (averagespeed * 0.001f - m_accelerate_natural_offset.value);
+
+                       if (adjusted_speed_pxms > 0 && m_accelerate_natural_accelsenscap.value != 1.0f)
+                       {
+                               float adjusted_accelsenscap = m_accelerate_natural_accelsenscap.value - 1.0f;
+                               // This equation is made to multiply the sensitivity for a factor between 1 and m_accelerate_natural_accelsenscap
+                               // this means there is no need to divide it for the sensitivity.value as the whole
+                               // expression needs to be multiplied by the sensitivity at the end instead of only having the sens multiplied
+                               accelsens += (adjusted_accelsenscap - adjusted_accelsenscap * exp( - ((adjusted_speed_pxms * m_accelerate_natural_strength.value) / fabs(adjusted_accelsenscap) )));
                        }
 
                        in_mouse_x *= accelsens;
@@ -683,8 +704,8 @@ void CL_Input (void)
                // mouse interacting with the scene, mostly stationary view
                V_StopPitchDrift();
                // update prydon cursor
-               cl.cmd.cursor_screen[0] = in_windowmouse_x * 2.0 / vid.width - 1.0;
-               cl.cmd.cursor_screen[1] = in_windowmouse_y * 2.0 / vid.height - 1.0;
+               cl.cmd.cursor_screen[0] = in_windowmouse_x * 2.0 / vid.mode.width - 1.0;
+               cl.cmd.cursor_screen[1] = in_windowmouse_y * 2.0 / vid.mode.height - 1.0;
        }
 
        if(v_flipped.integer)
@@ -1046,11 +1067,8 @@ static void CL_ClientMovement_Physics_Swim(cl_clientmovement_state_t *s)
        }
 
        // split wishvel into wishspeed and wishdir
-       wishspeed = VectorLength(wishvel);
-       if (wishspeed)
-               VectorScale(wishvel, 1 / wishspeed, wishdir);
-       else
-               VectorSet( wishdir, 0.0, 0.0, 0.0 );
+       VectorCopy(wishvel, wishdir);
+       wishspeed = VectorNormalizeLength(wishdir);
        wishspeed = min(wishspeed, cl.movevars_maxspeed) * 0.7;
 
        if (s->crouched)
@@ -1297,13 +1315,30 @@ static void CL_ClientMovement_Physics_PM_AirAccelerate(cl_clientmovement_state_t
     VectorMA( s->velocity, accelspeed, acceldir, s->velocity );
 }
 
+static void CL_ClientMovement_Physics_CheckJump(cl_clientmovement_state_t *s)
+{
+       // jump if on ground with jump button pressed but only if it has been
+       // released at least once since the last jump
+       if (s->cmd.jump)
+       {
+               if (s->onground && (s->cmd.canjump || !cl_movement_track_canjump.integer))
+               {
+                       s->velocity[2] += cl.movevars_jumpvelocity;
+                       s->onground = false;
+                       s->cmd.canjump = false;
+               }
+       }
+       else
+               s->cmd.canjump = true;
+}
+
 static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
 {
        vec_t friction;
        vec_t wishspeed;
        vec_t addspeed;
        vec_t accelspeed;
-       vec_t f;
+       vec_t speed;
        vec_t gravity;
        vec3_t forward;
        vec3_t right;
@@ -1313,19 +1348,7 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
        vec3_t yawangles;
        trace_t trace;
 
-       // jump if on ground with jump button pressed but only if it has been
-       // released at least once since the last jump
-       if (s->cmd.jump)
-       {
-               if (s->onground && (s->cmd.canjump || !cl_movement_track_canjump.integer))
-               {
-                       s->velocity[2] += cl.movevars_jumpvelocity;
-                       s->onground = false;
-                       s->cmd.canjump = false;
-               }
-       }
-       else
-               s->cmd.canjump = true;
+       CL_ClientMovement_Physics_CheckJump(s);
 
        // calculate movement vector
        VectorSet(yawangles, 0, s->cmd.viewangles[1], 0);
@@ -1333,11 +1356,9 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
        VectorMAM(s->cmd.forwardmove, forward, s->cmd.sidemove, right, wishvel);
 
        // split wishvel into wishspeed and wishdir
-       wishspeed = VectorLength(wishvel);
-       if (wishspeed)
-               VectorScale(wishvel, 1 / wishspeed, wishdir);
-       else
-               VectorSet( wishdir, 0.0, 0.0, 0.0 );
+       VectorCopy(wishvel, wishdir);
+       wishspeed = VectorNormalizeLength(wishdir);
+
        // check if onground
        if (s->onground)
        {
@@ -1346,8 +1367,8 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
                        wishspeed *= 0.5;
 
                // apply edge friction
-               f = sqrt(s->velocity[0] * s->velocity[0] + s->velocity[1] * s->velocity[1]);
-               if (f > 0)
+               speed = VectorLength2(s->velocity);
+               if (speed > 0)
                {
                        friction = cl.movevars_friction;
                        if (cl.movevars_edgefriction != 1)
@@ -1357,7 +1378,7 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
                                // note: QW uses the full player box for the trace, and yet still
                                // uses s->origin[2] + s->mins[2], which is clearly an bug, but
                                // this mimics it for compatibility
-                               VectorSet(neworigin2, s->origin[0] + s->velocity[0]*(16/f), s->origin[1] + s->velocity[1]*(16/f), s->origin[2] + s->mins[2]);
+                               VectorSet(neworigin2, s->origin[0] + s->velocity[0]*(16/speed), s->origin[1] + s->velocity[1]*(16/speed), s->origin[2] + s->mins[2]);
                                VectorSet(neworigin3, neworigin2[0], neworigin2[1], neworigin2[2] - 34);
                                if (cls.protocol == PROTOCOL_QUAKEWORLD)
                                        trace = CL_TraceBox(neworigin2, s->mins, s->maxs, neworigin3, MOVE_NORMAL, s->self, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | SUPERCONTENTS_PLAYERCLIP, 0, 0, collision_extendmovelength.value, true, true, NULL, true);
@@ -1367,9 +1388,9 @@ static void CL_ClientMovement_Physics_Walk(cl_clientmovement_state_t *s)
                                        friction *= cl.movevars_edgefriction;
                        }
                        // apply ground friction
-                       f = 1 - s->cmd.frametime * friction * ((f < cl.movevars_stopspeed) ? (cl.movevars_stopspeed / f) : 1);
-                       f = max(f, 0);
-                       VectorScale(s->velocity, f, s->velocity);
+                       speed = 1 - s->cmd.frametime * friction * ((speed < cl.movevars_stopspeed) ? (cl.movevars_stopspeed / speed) : 1);
+                       speed = max(speed, 0);
+                       VectorScale(s->velocity, speed, s->velocity);
                }
                addspeed = wishspeed - DotProduct(s->velocity, wishdir);
                if (addspeed > 0)
@@ -1517,8 +1538,8 @@ void CL_UpdateMoveVars(void)
        else
        {
                cl.moveflags = 0;
-               cl.movevars_ticrate = (cls.demoplayback ? 1.0f : host_timescale.value) / bound(1.0f, cl_netfps.value, 1000.0f);
-               cl.movevars_timescale = (cls.demoplayback ? 1.0f : host_timescale.value);
+               cl.movevars_ticrate = 0; // bones_was_here: no guessing, unavailable ticrate triggers better fallbacks
+               cl.movevars_timescale = (cls.demoplayback || host_timescale.value <= 0) ? 1.0f : host_timescale.value;
                cl.movevars_gravity = sv_gravity.value;
                cl.movevars_stopspeed = cl_movement_stopspeed.value;
                cl.movevars_maxspeed = cl_movement_maxspeed.value;
@@ -1756,8 +1777,8 @@ void CL_SendMove(void)
        usercmd_t *cmd;
        sizebuf_t buf;
        unsigned char data[1024];
-       double packettime;
-       int msecdelta;
+       float packettime, sv_frametime, lag, frames_per_tic;
+       qbool opportune_moment;
        qbool quemove;
        qbool important;
 
@@ -1786,7 +1807,7 @@ void CL_SendMove(void)
        if (in_button7.state  & 3) bits |=  64;
        if (in_button8.state  & 3) bits |= 128;
        if (in_use.state      & 3) bits |= 256;
-       if (key_dest != key_game || key_consoleactive) bits |= 512;
+       if (key_dest != key_game || key_consoleactive || !vid_activewindow) bits |= 512;
        if (cl_prydoncursor.integer > 0) bits |= 1024;
        if (in_button9.state  & 3)  bits |=   2048;
        if (in_button10.state  & 3) bits |=   4096;
@@ -1813,12 +1834,14 @@ void CL_SendMove(void)
        // set viewangles
        VectorCopy(cl.viewangles, cl.cmd.viewangles);
 
-       msecdelta = (int)(floor(cl.cmd.time * 1000) - floor(cl.movecmd[1].time * 1000));
-       cl.cmd.msec = (unsigned char)bound(0, msecdelta, 255);
+       // bones_was_here: previously cl.cmd.frametime was floored to nearest millisec
+       // this meant the smoothest async movement required integer millisec
+       // client and server frame times (eg 125fps)
+       cl.cmd.frametime = bound(0.0, cl.cmd.time - cl.movecmd[1].time, 0.255);
        // ridiculous value rejection (matches qw)
-       if (cl.cmd.msec > 250)
-               cl.cmd.msec = 100;
-       cl.cmd.frametime = cl.cmd.msec * (1.0 / 1000.0);
+       if (cl.cmd.frametime > 0.25)
+               cl.cmd.frametime = 0.1;
+       cl.cmd.msec = (unsigned char)floor(cl.cmd.frametime * 1000);
 
        switch(cls.protocol)
        {
@@ -1828,6 +1851,7 @@ void CL_SendMove(void)
                break;
        case PROTOCOL_DARKPLACES6:
        case PROTOCOL_DARKPLACES7:
+       case PROTOCOL_DARKPLACES8:
                cl.cmd.predicted = cl_movement.integer != 0;
                break;
        default:
@@ -1859,6 +1883,7 @@ void CL_SendMove(void)
                break;
        case PROTOCOL_DARKPLACES6:
        case PROTOCOL_DARKPLACES7:
+       case PROTOCOL_DARKPLACES8:
                // FIXME: cl.cmd.buttons & 16 is +button5, Nexuiz/Xonotic specific
                cl.cmd.crouch = (cl.cmd.buttons & 16) != 0;
                break;
@@ -1869,31 +1894,68 @@ void CL_SendMove(void)
        if (quemove)
                cl.movecmd[0] = cl.cmd;
 
-       // don't predict more than 200fps
-       if (host.realtime >= cl.lastpackettime + 0.005)
+       /* Accumulating cl.realframetime to prevent low packet rates,
+        * previously with cl_maxfps == cl_netfps it did not send every frame because
+        * host.realtime - cl.lastpackettime was often well below (or above) cl_packetinterval.
+        */
+       cl.timesincepacket += cl.realframetime;
+
+       // don't predict more than 256fps
+       if (cl.timesincepacket >= 1/256)
                cl.movement_replay = true; // redo the prediction
 
        // now decide whether to actually send this move
        // (otherwise it is only for prediction)
 
+       // do not send 0ms packets because they mess up physics
+       if(cl.cmd.msec == 0 && cl.time > cl.oldtime && (cls.protocol == PROTOCOL_QUAKEWORLD || cls.signon == SIGNONS))
+               return;
+
        // don't send too often or else network connections can get clogged by a
        // high renderer framerate
-       packettime = 1.0 / bound(1, cl_netfps.value, 1000);
-       if (cl.movevars_timescale && cl.movevars_ticrate)
+       packettime = 1.0f / bound(10.0f, cl_netfps.value, 1000.0f);
+       if (cl.movevars_ticrate)
        {
-               float maxtic = cl.movevars_ticrate / cl.movevars_timescale;
-               packettime = min(packettime, maxtic);
+               packettime = bound(cl.movevars_ticrate * 0.5f, packettime, cl.movevars_ticrate);
+               sv_frametime = cl.movevars_ticrate;
        }
+       else // fallback, may be affected by server->client network problems
+               sv_frametime = (cl.mtime[0] - cl.mtime[1]) / cl.movevars_timescale;
 
-       // do not send 0ms packets because they mess up physics
-       if(cl.cmd.msec == 0 && cl.time > cl.oldtime && (cls.protocol == PROTOCOL_QUAKEWORLD || cls.signon == SIGNONS))
-               return;
        // always send if buttons changed or an impulse is pending
        // even if it violates the rate limit!
        important = (cl.cmd.impulse || (cl_netimmediatebuttons.integer && cl.cmd.buttons != cl.movecmd[1].buttons));
-       // don't send too often (cl_netfps)
-       if (!important && host.realtime < cl.lastpackettime + packettime)
-               return;
+
+       lag = cl.mtime[0] - cl.cmd.time;
+       frames_per_tic = sv_frametime / cl.realframetime;
+//     opportune_moment = lag <= cl.realframetime * 2; // FAIL: can miss the moment with uncapped fps
+//     opportune_moment = lag <= cl.realframetime * frames_per_tic * 0.5; // FAIL: too early at high fps, reducing multi causes misses at moderate fps
+       opportune_moment = lag <= cl.realframetime * (frames_per_tic <= 1 ? 1 : sqrt(frames_per_tic)); // perfect
+
+       // Two methods for deciding when to send
+       if (!important)
+       {
+               // Traditional time interval, now used as fallback
+               if (sv_frametime <= 0 || lag > sv_frametime || lag < 0) // unknown ticrate || lag/PL || still connecting
+               {
+                       if (cl.timesincepacket < packettime * 0.99999f)
+                       {
+//                             Con_Printf("^6moveft %f realft %f lag %f tic %f inputsince %d\n", cl.cmd.frametime, cl.realframetime, lag, sv_frametime, cl.opt_inputs_since_update);
+                               return;
+                       }
+               }
+               // Server-synchronised, for better pings
+               // Sends at least once per server frame
+               else // cl.opt_inputs_since_update is usable
+               {
+                       if (!opportune_moment || cl.opt_inputs_since_update >= sv_frametime / packettime)
+                       {
+//                             Con_Printf("^1moveft %f realft %f lag %f tic %f inputsince %d\n", cl.cmd.frametime, cl.realframetime, lag, sv_frametime, cl.opt_inputs_since_update);
+                               return;
+                       }
+               }
+       }
+
        // don't choke the connection with packets (obey rate limit)
        // it is important that this check be last, because it adds a new
        // frame to the shownetgraph output and any cancelation after this
@@ -1901,12 +1963,14 @@ void CL_SendMove(void)
        // we also still send if it is important
        if (!NetConn_CanSend(cls.netcon) && !important)
                return;
-       // try to round off the lastpackettime to a multiple of the packet interval
-       // (this causes it to emit packets at a steady beat)
-       if (packettime > 0)
-               cl.lastpackettime = floor(host.realtime / packettime) * packettime;
-       else
-               cl.lastpackettime = host.realtime;
+
+//     Con_Printf("%smoveft %f realft %f lag %f tic %f inputsince %d important %d\n", (lag < 0.0005 || !opportune_moment) ? "^3" : "^2", cl.cmd.frametime, cl.realframetime, lag, sv_frametime, cl.opt_inputs_since_update, important);
+
+       if (opportune_moment) // this check is needed for optimal timing especially with cl_netimmediatebuttons
+               ++cl.opt_inputs_since_update;
+
+       // reset the packet timing accumulator
+       cl.timesincepacket = 0;
 
        buf.maxsize = sizeof(data);
        buf.cursize = 0;
@@ -1923,6 +1987,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 per move (can be up to 16 moves)
+       // PROTOCOL_DARKPLACES8  clc_move = 56 bytes total per move (can be up to 16 moves)
        // PROTOCOL_QUAKEWORLD   clc_move = 34 bytes total (typically, but can reach 43 bytes, or even 49 bytes with roll)
 
        // set prydon cursor info
@@ -2024,6 +2089,7 @@ void CL_SendMove(void)
                        MSG_WriteByte (&buf, cl.cmd.impulse);
                case PROTOCOL_DARKPLACES6:
                case PROTOCOL_DARKPLACES7:
+               case PROTOCOL_DARKPLACES8:
                        // set the maxusercmds variable to limit how many should be sent
                        maxusercmds = bound(1, cl_netrepeatinput.integer + 1, min(3, CL_MAX_USERCMDS));
                        // when movement prediction is off, there's not much point in repeating old input as it will just be ignored
@@ -2148,13 +2214,7 @@ void CL_SendMove(void)
        in_impulse = 0;
 
        if (cls.netcon->message.overflowed)
-       {
-               Con_Print("CL_SendMove: lost server connection\n");
-               CL_Disconnect();
-               SV_LockThreadMutex();
-               SV_Shutdown();
-               SV_UnlockThreadMutex();
-       }
+               CL_DisconnectEx(true, "Lost connection to server");
 }
 
 /*
@@ -2267,6 +2327,9 @@ void CL_InitInput (void)
        Cvar_RegisterVariable(&m_accelerate_power_offset);
        Cvar_RegisterVariable(&m_accelerate_power_senscap);
        Cvar_RegisterVariable(&m_accelerate_power_strength);
+       Cvar_RegisterVariable(&m_accelerate_natural_offset);
+       Cvar_RegisterVariable(&m_accelerate_natural_accelsenscap);
+       Cvar_RegisterVariable(&m_accelerate_natural_strength);
 
        Cvar_RegisterVariable(&cl_netfps);
        Cvar_RegisterVariable(&cl_netrepeatinput);