mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- Reduce GameInput::processVehicle()
interface by changing three bools to a bitfield.
This commit is contained in:
parent
ce236c795f
commit
e0e459216d
3 changed files with 18 additions and 10 deletions
|
@ -185,7 +185,7 @@ void GameInput::processMovement(PlayerAngles* const plrAngles, const float scale
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInput::processVehicle(PlayerAngles* const plrAngles, const float scaleAdjust, const float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate)
|
||||
void GameInput::processVehicle(PlayerAngles* const plrAngles, const float scaleAdjust, const float baseVel, const float velScale, const unsigned flags)
|
||||
{
|
||||
// open up input packet for this session.
|
||||
InputPacket thisInput{};
|
||||
|
@ -194,7 +194,7 @@ void GameInput::processVehicle(PlayerAngles* const plrAngles, const float scaleA
|
|||
inputBuffer.actions &= ~(SB_WEAPONMASK_BITS | SB_TURNAROUND | SB_CENTERVIEW | SB_HOLSTER | SB_JUMP | SB_CROUCH | SB_RUN |
|
||||
SB_AIM_UP | SB_AIM_DOWN | SB_AIMMODE | SB_LOOK_UP | SB_LOOK_DOWN | SB_LOOK_LEFT | SB_LOOK_RIGHT);
|
||||
|
||||
if (canMove)
|
||||
if (flags & VEH_CANMOVE)
|
||||
{
|
||||
const auto kbdForwards = buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe);
|
||||
const auto kbdBackward = buttonMap.ButtonDown(gamefunc_Move_Backward);
|
||||
|
@ -205,7 +205,7 @@ void GameInput::processVehicle(PlayerAngles* const plrAngles, const float scaleA
|
|||
if (buttonMap.ButtonDown(gamefunc_Run)) inputBuffer.actions |= SB_CROUCH;
|
||||
}
|
||||
|
||||
if (canTurn)
|
||||
if (flags & VEH_CANTURN)
|
||||
{
|
||||
// Keyboard turning.
|
||||
const auto kbdLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left);
|
||||
|
@ -217,7 +217,7 @@ void GameInput::processVehicle(PlayerAngles* const plrAngles, const float scaleA
|
|||
const auto hidRight = mouseInput.X > 0 || joyAxes[JOYAXIS_Yaw] < 0;
|
||||
|
||||
// Velocity setup.
|
||||
const auto turnVel = (!attenuate && (isTurboTurnTime() || hidLeft || hidRight)) ? (baseVel) : (baseVel * velScale);
|
||||
const auto turnVel = (!(flags & VEH_SCALETURN) && (isTurboTurnTime() || hidLeft || hidRight)) ? (baseVel) : (baseVel * velScale);
|
||||
const auto mouseVel = abs(turnVel * mouseInput.X * m_yaw) * (45.f / 2048.f) / scaleAdjust;
|
||||
const auto maxVel = abs(turnVel * 1.5f);
|
||||
|
||||
|
|
|
@ -9,6 +9,13 @@ enum : unsigned
|
|||
CS_DISABLETOGGLE = 2,
|
||||
};
|
||||
|
||||
enum : unsigned
|
||||
{
|
||||
VEH_CANMOVE = 1,
|
||||
VEH_CANTURN = 2,
|
||||
VEH_SCALETURN = 4,
|
||||
};
|
||||
|
||||
inline double getTicrateScale(const double value)
|
||||
{
|
||||
return value / GameTicRate;
|
||||
|
@ -75,7 +82,7 @@ public:
|
|||
|
||||
// Prototypes for large member functions.
|
||||
void processMovement(PlayerAngles* const plrAngles, const float scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const float turnscale = 1.f);
|
||||
void processVehicle(PlayerAngles* const plrAngles, const float scaleAdjust, const float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate);
|
||||
void processVehicle(PlayerAngles* const plrAngles, const float scaleAdjust, const float baseVel, const float velScale, const unsigned flags);
|
||||
void getInput(const double scaleAdjust, InputPacket* packet = nullptr);
|
||||
void resetCrouchToggle();
|
||||
};
|
||||
|
@ -93,7 +100,7 @@ struct PlayerAngles
|
|||
|
||||
friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, PlayerAngles* def);
|
||||
friend void GameInput::processMovement(PlayerAngles* const plrAngles, const float scaleAdjust, const int drink_amt, const bool allowstrafe, const float turnscale);
|
||||
friend void GameInput::processVehicle(PlayerAngles* const plrAngles, const float scaleAdjust, const float baseVel, const float velScale, const bool canMove, const bool canTurn, const bool attenuate);
|
||||
friend void GameInput::processVehicle(PlayerAngles* const plrAngles, const float scaleAdjust, const float baseVel, const float velScale, const unsigned flags);
|
||||
|
||||
// Prototypes.
|
||||
void doPitchInput(InputPacket* const input);
|
||||
|
|
|
@ -529,11 +529,12 @@ void GameInterface::doPlayerMovement(const float scaleAdjust)
|
|||
baseVel = VEHICLETURN * velScale;
|
||||
}
|
||||
|
||||
const auto canMove = p->OnBoat || !p->moto_underwater;
|
||||
const auto canTurn = p->OnMotorcycle || p->MotoSpeed || p->moto_drink;
|
||||
const auto attenuate = p->OnMotorcycle && p->MotoSpeed <= 0;
|
||||
unsigned vehFlags = 0;
|
||||
vehFlags |= VEH_CANMOVE * (p->OnBoat || !p->moto_underwater);
|
||||
vehFlags |= VEH_CANTURN * (p->OnMotorcycle || p->MotoSpeed || p->moto_drink);
|
||||
vehFlags |= VEH_SCALETURN * (p->OnMotorcycle && p->MotoSpeed <= 0);
|
||||
|
||||
gameInput.processVehicle(&p->Angles, scaleAdjust, baseVel, velScale, canMove, canTurn, attenuate);
|
||||
gameInput.processVehicle(&p->Angles, scaleAdjust, baseVel, velScale, vehFlags);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue