- Duke/RR: Re-add micro-movement cancellation for RR's vehicles that was dropped in 466bc84697.

This commit is contained in:
Mitch Richters 2021-12-06 17:21:41 +11:00 committed by Christoph Oelckers
parent 379c4f1a60
commit c6774d5efd
3 changed files with 15 additions and 3 deletions

View file

@ -64,8 +64,8 @@ CVAR(Float, m_side, 1.f, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
void InputState::GetMouseDelta(ControlInfo * hidInput)
{
hidInput->mouseturnx = g_mousePos.X * m_yaw * (1.f / 18.f);
hidInput->mouseturny = g_mousePos.Y * m_pitch * (1.f / 14.f);
hidInput->mouseturnx = g_mousePos.X * m_yaw * backendinputscale();
hidInput->mouseturny = g_mousePos.Y * m_pitch * backendinputscale();
hidInput->mousemovex = g_mousePos.X * m_side;
hidInput->mousemovey = g_mousePos.Y * m_forward;

View file

@ -111,6 +111,11 @@ inline bool SyncInput()
return gamesetinput || cl_syncinput;
}
inline float backendinputscale()
{
return (1.f / 16.f);
}
//---------------------------------------------------------------------------
//
// Inline functions to help with edge cases where synchronised input is needed.

View file

@ -39,6 +39,9 @@ source as it is released.
#include "v_video.h"
#include "dukeactor.h"
EXTERN_CVAR(Float, m_sensitivity_x)
EXTERN_CVAR(Float, m_yaw)
BEGIN_DUKE_NS
// State timer counters.
@ -733,6 +736,10 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I
{
bool const kbdLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left);
bool const kbdRight = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right);
// Cancel out micro-movement
if (fabs(hidInput->mouseturnx) < (m_sensitivity_x * m_yaw * backendinputscale() * 2.f)) hidInput->mouseturnx = 0;
p->vehTurnLeft = kbdLeft || hidInput->mouseturnx < 0 || hidInput->dyaw < 0;
p->vehTurnRight = kbdRight || hidInput->mouseturnx > 0 || hidInput->dyaw > 0;
@ -753,7 +760,7 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I
input.avel = (float)boatApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust);
}
loc.fvel = (int16_t)clamp<int>(xs_CRoundToInt(p->MotoSpeed), -(MAXVELMOTO >> 3), MAXVELMOTO);
loc.fvel = clamp<int16_t>(xs_CRoundToInt(p->MotoSpeed), -(MAXVELMOTO >> 3), MAXVELMOTO);
input.avel *= BAngToDegree;
loc.avel += input.avel;
}