- PlayerAngle::applyinput(): Consolidate some mostly duplicated code into a lambda.

This commit is contained in:
Mitch Richters 2021-11-06 17:57:00 +11:00
parent 1bb0c04e61
commit 5050947dca

View file

@ -389,19 +389,17 @@ void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const
if (abs(look_ang.signedbam()) < (BAMUNIT >> 2)) look_ang = bamang(0); if (abs(look_ang.signedbam()) < (BAMUNIT >> 2)) look_ang = bamang(0);
} }
if (*actions & SB_LOOK_LEFT) // Process keyboard input.
auto doLookKeys = [&](ESyncBits_ const key, double const direction)
{ {
// start looking left if (*actions & key)
look_ang -= getscaledangle(LOOKINGSPEED, scaleAdjust); {
rotscrnang += getscaledangle(ROTATESPEED, scaleAdjust); look_ang += getscaledangle(LOOKINGSPEED, scaleAdjust * direction);
} rotscrnang -= getscaledangle(ROTATESPEED, scaleAdjust * direction);
}
if (*actions & SB_LOOK_RIGHT) };
{ doLookKeys(SB_LOOK_LEFT, -1);
// start looking right doLookKeys(SB_LOOK_RIGHT, 1);
look_ang += getscaledangle(LOOKINGSPEED, scaleAdjust);
rotscrnang -= getscaledangle(ROTATESPEED, scaleAdjust);
}
if (!movementlocked()) if (!movementlocked())
{ {