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.
// it's a (auto) repeat event), do nothing. This especially
// optimises traffic to the server and other clients.
if (!PlayerController::action(action, value, /*dry_run*/true))
return false;
if (!PlayerController::action(action, value, /*dry_run*/true)) return false;
// Register event with history
if(!history->replayHistory())

View File

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