- 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 (*actions & SB_LOOK_LEFT)
// Process keyboard input.
auto doLookKeys = [&](ESyncBits_ const key, double const direction)
{
// start looking left
look_ang -= getscaledangle(LOOKINGSPEED, scaleAdjust);
rotscrnang += getscaledangle(ROTATESPEED, scaleAdjust);
}
if (*actions & SB_LOOK_RIGHT)
{
// start looking right
look_ang += getscaledangle(LOOKINGSPEED, scaleAdjust);
rotscrnang -= getscaledangle(ROTATESPEED, scaleAdjust);
}
if (*actions & key)
{
look_ang += getscaledangle(LOOKINGSPEED, scaleAdjust * direction);
rotscrnang -= getscaledangle(ROTATESPEED, scaleAdjust * direction);
}
};
doLookKeys(SB_LOOK_LEFT, -1);
doLookKeys(SB_LOOK_RIGHT, 1);
if (!movementlocked())
{