mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-14 00:21:30 +00:00
- Duke: Tidy up some unnecessarily deep branches in vehicle input code.
This commit is contained in:
parent
51a20211f3
commit
401236980c
1 changed files with 88 additions and 103 deletions
|
@ -570,60 +570,57 @@ static float motoApplyTurn(player_struct* p, HIDInput* const hidInput, bool cons
|
|||
p->TiltStatus = 10;
|
||||
}
|
||||
}
|
||||
else if (p->vehTurnLeft || p->vehTurnRight || p->moto_drink)
|
||||
{
|
||||
constexpr float velScale = (3.f / 10.f);
|
||||
const float baseVel = (buttonMap.ButtonDown(gamefunc_Move_Backward) || hidInput->joyaxes[JOYAXIS_Forward] < 0) && p->MotoSpeed <= 0 ? -VEHICLETURN : VEHICLETURN;
|
||||
|
||||
if (p->vehTurnLeft || p->moto_drink < 0)
|
||||
{
|
||||
p->TiltStatus -= (float)factor;
|
||||
|
||||
if (p->TiltStatus < -10)
|
||||
p->TiltStatus = -10;
|
||||
|
||||
if (kbdLeft)
|
||||
turnvel -= isTurboTurnTime() && p->MotoSpeed > 0 ? baseVel : baseVel * velScale;
|
||||
|
||||
if (hidInput->mouseturnx < 0)
|
||||
turnvel -= Sgn(baseVel) * sqrtf(abs(p->MotoSpeed > 0 ? baseVel : baseVel * velScale) * -(hidInput->mouseturnx / factor) * (7.f / 20.f));
|
||||
|
||||
if (hidInput->joyaxes[JOYAXIS_Yaw] > 0)
|
||||
turnvel += (p->MotoSpeed > 0 ? baseVel : baseVel * velScale) * hidInput->joyaxes[JOYAXIS_Yaw];
|
||||
|
||||
updateTurnHeldAmt(factor);
|
||||
}
|
||||
|
||||
if (p->vehTurnRight || p->moto_drink > 0)
|
||||
{
|
||||
p->TiltStatus += (float)factor;
|
||||
|
||||
if (p->TiltStatus > 10)
|
||||
p->TiltStatus = 10;
|
||||
|
||||
if (kbdRight)
|
||||
turnvel += isTurboTurnTime() && p->MotoSpeed > 0 ? baseVel : baseVel * velScale;
|
||||
|
||||
if (hidInput->mouseturnx > 0)
|
||||
turnvel += Sgn(baseVel) * sqrtf(abs(p->MotoSpeed > 0 ? baseVel : baseVel * velScale) * (hidInput->mouseturnx / factor) * (7.f / 20.f));
|
||||
|
||||
if (hidInput->joyaxes[JOYAXIS_Yaw] < 0)
|
||||
turnvel += (p->MotoSpeed > 0 ? baseVel : baseVel * velScale) * hidInput->joyaxes[JOYAXIS_Yaw];
|
||||
|
||||
updateTurnHeldAmt(factor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p->vehTurnLeft || p->vehTurnRight || p->moto_drink)
|
||||
{
|
||||
constexpr float velScale = (3.f / 10.f);
|
||||
const float baseVel = (buttonMap.ButtonDown(gamefunc_Move_Backward) || hidInput->joyaxes[JOYAXIS_Forward] < 0) && p->MotoSpeed <= 0 ? -VEHICLETURN : VEHICLETURN;
|
||||
resetTurnHeldAmt();
|
||||
|
||||
if (p->vehTurnLeft || p->moto_drink < 0)
|
||||
{
|
||||
p->TiltStatus -= (float)factor;
|
||||
|
||||
if (p->TiltStatus < -10)
|
||||
p->TiltStatus = -10;
|
||||
|
||||
if (kbdLeft)
|
||||
turnvel -= isTurboTurnTime() && p->MotoSpeed > 0 ? baseVel : baseVel * velScale;
|
||||
|
||||
if (hidInput->mouseturnx < 0)
|
||||
turnvel -= Sgn(baseVel) * sqrtf(abs(p->MotoSpeed > 0 ? baseVel : baseVel * velScale) * -(hidInput->mouseturnx / factor) * (7.f / 20.f));
|
||||
|
||||
if (hidInput->joyaxes[JOYAXIS_Yaw] > 0)
|
||||
turnvel += (p->MotoSpeed > 0 ? baseVel : baseVel * velScale) * hidInput->joyaxes[JOYAXIS_Yaw];
|
||||
|
||||
updateTurnHeldAmt(factor);
|
||||
}
|
||||
|
||||
if (p->vehTurnRight || p->moto_drink > 0)
|
||||
{
|
||||
p->TiltStatus += (float)factor;
|
||||
|
||||
if (p->TiltStatus > 10)
|
||||
p->TiltStatus = 10;
|
||||
|
||||
if (kbdRight)
|
||||
turnvel += isTurboTurnTime() && p->MotoSpeed > 0 ? baseVel : baseVel * velScale;
|
||||
|
||||
if (hidInput->mouseturnx > 0)
|
||||
turnvel += Sgn(baseVel) * sqrtf(abs(p->MotoSpeed > 0 ? baseVel : baseVel * velScale) * (hidInput->mouseturnx / factor) * (7.f / 20.f));
|
||||
|
||||
if (hidInput->joyaxes[JOYAXIS_Yaw] < 0)
|
||||
turnvel += (p->MotoSpeed > 0 ? baseVel : baseVel * velScale) * hidInput->joyaxes[JOYAXIS_Yaw];
|
||||
|
||||
updateTurnHeldAmt(factor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resetTurnHeldAmt();
|
||||
|
||||
if (p->TiltStatus > 0)
|
||||
p->TiltStatus -= (float)factor;
|
||||
else if (p->TiltStatus < 0)
|
||||
p->TiltStatus += (float)factor;
|
||||
}
|
||||
if (p->TiltStatus > 0)
|
||||
p->TiltStatus -= (float)factor;
|
||||
else if (p->TiltStatus < 0)
|
||||
p->TiltStatus += (float)factor;
|
||||
}
|
||||
|
||||
if (fabs(p->TiltStatus) < factor)
|
||||
|
@ -643,63 +640,51 @@ static float boatApplyTurn(player_struct *p, HIDInput* const hidInput, bool cons
|
|||
float turnvel = 0;
|
||||
p->oTiltStatus = p->TiltStatus;
|
||||
|
||||
if (p->MotoSpeed)
|
||||
if (p->MotoSpeed && (p->vehTurnLeft || p->vehTurnRight || p->moto_drink))
|
||||
{
|
||||
if (p->vehTurnLeft || p->vehTurnRight || p->moto_drink)
|
||||
const float velScale = !p->NotOnWater? 1.f : (6.f / 19.f);
|
||||
const float baseVel = VEHICLETURN * velScale;
|
||||
|
||||
if (p->vehTurnLeft || p->moto_drink < 0)
|
||||
{
|
||||
const float velScale = !p->NotOnWater? 1.f : (6.f / 19.f);
|
||||
const float baseVel = VEHICLETURN * velScale;
|
||||
|
||||
if (p->vehTurnLeft || p->moto_drink < 0)
|
||||
if (!p->NotOnWater)
|
||||
{
|
||||
if (!p->NotOnWater)
|
||||
{
|
||||
p->TiltStatus -= (float)factor;
|
||||
if (p->TiltStatus < -10)
|
||||
p->TiltStatus = -10;
|
||||
}
|
||||
|
||||
if (kbdLeft)
|
||||
turnvel -= isTurboTurnTime() ? baseVel : baseVel * velScale;
|
||||
|
||||
if (hidInput->mouseturnx < 0)
|
||||
turnvel -= Sgn(baseVel) * sqrtf(abs(baseVel) * -(hidInput->mouseturnx / factor) * (7.f / 20.f));
|
||||
|
||||
if (hidInput->joyaxes[JOYAXIS_Yaw] > 0)
|
||||
turnvel += baseVel * hidInput->joyaxes[JOYAXIS_Yaw];
|
||||
|
||||
updateTurnHeldAmt(factor);
|
||||
}
|
||||
|
||||
if (p->vehTurnRight || p->moto_drink > 0)
|
||||
{
|
||||
if (!p->NotOnWater)
|
||||
{
|
||||
p->TiltStatus += (float)factor;
|
||||
if (p->TiltStatus > 10)
|
||||
p->TiltStatus = 10;
|
||||
}
|
||||
|
||||
if (kbdRight)
|
||||
turnvel += isTurboTurnTime() ? baseVel : baseVel * velScale;
|
||||
|
||||
if (hidInput->mouseturnx > 0)
|
||||
turnvel += Sgn(baseVel) * sqrtf(abs(baseVel) * (hidInput->mouseturnx / factor) * (7.f / 20.f));
|
||||
|
||||
if (hidInput->joyaxes[JOYAXIS_Yaw] < 0)
|
||||
turnvel += baseVel * hidInput->joyaxes[JOYAXIS_Yaw];
|
||||
|
||||
updateTurnHeldAmt(factor);
|
||||
}
|
||||
}
|
||||
else if (!p->NotOnWater)
|
||||
{
|
||||
resetTurnHeldAmt();
|
||||
|
||||
if (p->TiltStatus > 0)
|
||||
p->TiltStatus -= (float)factor;
|
||||
else if (p->TiltStatus < 0)
|
||||
if (p->TiltStatus < -10)
|
||||
p->TiltStatus = -10;
|
||||
}
|
||||
|
||||
if (kbdLeft)
|
||||
turnvel -= isTurboTurnTime() ? baseVel : baseVel * velScale;
|
||||
|
||||
if (hidInput->mouseturnx < 0)
|
||||
turnvel -= Sgn(baseVel) * sqrtf(abs(baseVel) * -(hidInput->mouseturnx / factor) * (7.f / 20.f));
|
||||
|
||||
if (hidInput->joyaxes[JOYAXIS_Yaw] > 0)
|
||||
turnvel += baseVel * hidInput->joyaxes[JOYAXIS_Yaw];
|
||||
|
||||
updateTurnHeldAmt(factor);
|
||||
}
|
||||
|
||||
if (p->vehTurnRight || p->moto_drink > 0)
|
||||
{
|
||||
if (!p->NotOnWater)
|
||||
{
|
||||
p->TiltStatus += (float)factor;
|
||||
if (p->TiltStatus > 10)
|
||||
p->TiltStatus = 10;
|
||||
}
|
||||
|
||||
if (kbdRight)
|
||||
turnvel += isTurboTurnTime() ? baseVel : baseVel * velScale;
|
||||
|
||||
if (hidInput->mouseturnx > 0)
|
||||
turnvel += Sgn(baseVel) * sqrtf(abs(baseVel) * (hidInput->mouseturnx / factor) * (7.f / 20.f));
|
||||
|
||||
if (hidInput->joyaxes[JOYAXIS_Yaw] < 0)
|
||||
turnvel += baseVel * hidInput->joyaxes[JOYAXIS_Yaw];
|
||||
|
||||
updateTurnHeldAmt(factor);
|
||||
}
|
||||
}
|
||||
else if (!p->NotOnWater)
|
||||
|
|
Loading…
Reference in a new issue