| 79 | //--------------------------------------------------------------------------- |
| 80 | |
| 81 | void GameInput::processMovement(const double turnscale, const bool allowstrafe, const int drink_amt) |
| 82 | { |
| 83 | // set up variables. |
| 84 | InputPacket thisInput{}; |
| 85 | keymove = 1 << int(!!(inputBuffer.actions & SB_RUN)); |
| 86 | const auto hidspeed = getTicrateAngle(YAW_TURNSPEEDS[2]); |
| 87 | |
| 88 | // get all input amounts. |
| 89 | const auto turning = buttonMap.ButtonDown(gamefunc_Turn_Right) - |
| 90 | buttonMap.ButtonDown(gamefunc_Turn_Left); |
| 91 | |
| 92 | const auto moving = buttonMap.ButtonDown(gamefunc_Move_Forward) - |
| 93 | buttonMap.ButtonDown(gamefunc_Move_Backward) + |
| 94 | joyAxes[JOYAXIS_Forward] * scaleAdjust; |
| 95 | |
| 96 | const auto strafing = buttonMap.ButtonDown(gamefunc_Strafe_Right) - |
| 97 | buttonMap.ButtonDown(gamefunc_Strafe_Left) - |
| 98 | joyAxes[JOYAXIS_Side] * scaleAdjust; |
| 99 | |
| 100 | const auto soaring = buttonMap.ButtonDown(gamefunc_Move_Up) - |
| 101 | buttonMap.ButtonDown(gamefunc_Move_Down) + |
| 102 | joyAxes[JOYAXIS_Up] * scaleAdjust; |
| 103 | |
| 104 | // process player yaw input. |
| 105 | if (!(buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)) |
| 106 | { |
| 107 | const double turndir = clamp(turning + strafing * !allowstrafe, -1., 1.); |
| 108 | const double tttscale = (cl_noturnscaling || isTurboTurnTime()) ? 1 : (5. / 19.); |
| 109 | const DAngle turnspeed = getTicrateAngle(YAW_TURNSPEEDS[keymove] * tttscale); |
| 110 | thisInput.ang.Yaw += MOUSE_SCALE * mouseInput.X * m_yaw; |
| 111 | thisInput.ang.Yaw -= hidspeed * joyAxes[JOYAXIS_Yaw] * scaleAdjust; |
| 112 | thisInput.ang.Yaw += turnspeed * turndir * scaleAdjust; |
| 113 | thisInput.ang.Yaw *= turnscale; |
| 114 | if (turndir) updateTurnHeldAmt(); else turnheldtime = 0; |
| 115 | } |
| 116 | else |
| 117 | { |
| 118 | thisInput.vel.Y += mouseInput.X * MOUSE_SCALE.Degrees() * m_side; |
| 119 | thisInput.vel.Y -= joyAxes[JOYAXIS_Yaw] * keymove * scaleAdjust; |
| 120 | thisInput.vel.Y += turning * keymove * scaleAdjust; |
| 121 | } |
| 122 | |
| 123 | // process player pitch input. |
| 124 | if (!(inputBuffer.actions & SB_AIMMODE)) |
| 125 | { |
| 126 | thisInput.ang.Pitch -= MOUSE_SCALE * mouseInput.Y * m_pitch; |
| 127 | thisInput.ang.Pitch -= hidspeed * joyAxes[JOYAXIS_Pitch] * scaleAdjust; |
| 128 | thisInput.ang.Pitch *= turnscale; |
| 129 | } |
| 130 | else |
| 131 | { |
| 132 | thisInput.vel.X += mouseInput.Y * MOUSE_SCALE.Degrees() * m_forward; |
| 133 | thisInput.vel.X += joyAxes[JOYAXIS_Pitch] * keymove * scaleAdjust; |
| 134 | } |
| 135 | |
| 136 | // process movement input. |
| 137 | thisInput.vel.X += moving * keymove; |
| 138 | thisInput.vel.Y += strafing * keymove * allowstrafe; |
no test coverage detected