Merge remote-tracking branch 'origin/network' into voting_gui

This commit is contained in:
Benau 2018-12-22 10:48:12 +08:00
commit 12a67d6e6b
2 changed files with 12 additions and 24 deletions

View File

@ -178,22 +178,10 @@ bool LocalPlayerController::action(PlayerAction action, int value,
} }
} }
// Check if skid key is pressed and if turn button is in disagreement
// with the current steering dominant, ignore the skid key press, see #3168
if (action == PA_DRIFT && value != 0)
{
if ((!PlayerController::action(PA_STEER_LEFT, 0, /*dry_run*/true) &&
m_controls->getSteer() < 0.0f) ||
(!PlayerController::action(PA_STEER_RIGHT, 0, /*dry_run*/true) &&
m_controls->getSteer() > 0.0f))
return false;
}
// If this event does not change the control state (e.g. // If this event does not change the control state (e.g.
// it's a (auto) repeat event), do nothing. This especially // it's a (auto) repeat event), do nothing. This especially
// optimises traffic to the server and other clients. // optimises traffic to the server and other clients.
if (!PlayerController::action(action, value, /*dry_run*/true)) if (!PlayerController::action(action, value, /*dry_run*/true)) return false;
return false;
// Register event with history // Register event with history
if(!history->replayHistory()) if(!history->replayHistory())

View File

@ -222,15 +222,21 @@ bool PlayerController::action(PlayerAction action, int value, bool dry_run)
break; break;
case PA_DRIFT: case PA_DRIFT:
if (value == 0) if (value == 0)
{
SET_OR_TEST_GETTER(SkidControl, KartControl::SC_NONE); SET_OR_TEST_GETTER(SkidControl, KartControl::SC_NONE);
else }
else if (m_controls->getSkidControl() == KartControl::SC_NONE)
{ {
if (m_steer_val == 0) if (m_steer_val == 0)
{
SET_OR_TEST_GETTER(SkidControl, KartControl::SC_NO_DIRECTION); SET_OR_TEST_GETTER(SkidControl, KartControl::SC_NO_DIRECTION);
}
else else
{
SET_OR_TEST_GETTER(SkidControl, m_steer_val<0 SET_OR_TEST_GETTER(SkidControl, m_steer_val<0
? KartControl::SC_RIGHT ? KartControl::SC_RIGHT
: KartControl::SC_LEFT ); : KartControl::SC_LEFT );
}
} }
break; break;
case PA_PAUSE_RACE: case PA_PAUSE_RACE:
@ -279,19 +285,13 @@ void PlayerController::steer(int ticks, int steer_val)
: dt/m_kart->getTimeFullSteer(fabsf(steer)); : dt/m_kart->getTimeFullSteer(fabsf(steer));
if (steer_val < 0) if (steer_val < 0)
{ {
// If we got analog values do not cumulate. steer += STEER_CHANGE;
if (steer_val > -32767) steer = std::min(steer, -steer_val/32767.0f);
steer = -steer_val/32767.0f;
else
steer += STEER_CHANGE;
} }
else if(steer_val > 0) else if(steer_val > 0)
{ {
// If we got analog values do not cumulate. steer -= STEER_CHANGE;
if (steer_val < 32767) steer = std::max(steer, -steer_val/32767.0f);
steer = -steer_val/32767.0f;
else
steer -= STEER_CHANGE;
} }
else else
{ // no key is pressed { // no key is pressed