From 62561d863ee5e32cc3f91d3a761248ae0e8be039 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 13 Mar 2023 21:17:53 +1100 Subject: [PATCH] - Tidy up `PlayerAngles::doPitchKeys()` interface by passing the whole sync packet through. --- source/core/gameinput.cpp | 21 +++++++++++---------- source/core/gameinput.h | 2 +- source/games/blood/src/player.cpp | 2 +- source/games/duke/src/player_d.cpp | 2 +- source/games/duke/src/player_r.cpp | 2 +- source/games/exhumed/src/player.cpp | 2 +- source/games/sw/src/player.cpp | 8 ++++---- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index cf45b90d7..0dc32701a 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -167,30 +167,31 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe // //--------------------------------------------------------------------------- -void PlayerAngles::doPitchKeys(ESyncBits* actions, const bool stopcentering) +void PlayerAngles::doPitchKeys(InputPacket* const input) { // Cancel return to center if conditions met. - if (stopcentering) *actions &= ~SB_CENTERVIEW; + if (input->horz) + input->actions &= ~SB_CENTERVIEW; // Process keyboard input. - if (auto aiming = !!(*actions & SB_AIM_DOWN) - !!(*actions & SB_AIM_UP)) + if (const auto aiming = !!(input->actions & SB_AIM_DOWN) - !!(input->actions & SB_AIM_UP)) { - pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_AIMSPEED)) * aiming; - *actions &= ~SB_CENTERVIEW; + pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_AIMSPEED) * aiming); + input->actions &= ~SB_CENTERVIEW; } - if (auto looking = !!(*actions & SB_LOOK_DOWN) - !!(*actions & SB_LOOK_UP)) + if (const auto looking = !!(input->actions & SB_LOOK_DOWN) - !!(input->actions & SB_LOOK_UP)) { - pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_LOOKSPEED)) * looking; - *actions |= SB_CENTERVIEW; + pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_LOOKSPEED) * looking); + input->actions |= SB_CENTERVIEW; } // Do return to centre. - if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN))) + if ((input->actions & SB_CENTERVIEW) && !(input->actions & (SB_LOOK_UP|SB_LOOK_DOWN))) { const auto pitch = abs(pActor->spr.Angles.Pitch); const auto scale = pitch > PITCH_CNTRSINEOFFSET ? (pitch - PITCH_CNTRSINEOFFSET).Cos() : 1.; if (scaletozero(pActor->spr.Angles.Pitch, PITCH_CENTERSPEED * scale)) - *actions &= ~SB_CENTERVIEW; + input->actions &= ~SB_CENTERVIEW; } // clamp before we finish, factoring in the player's view pitch offset. diff --git a/source/core/gameinput.h b/source/core/gameinput.h index d7a4e2164..c8951476b 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -20,7 +20,7 @@ struct PlayerAngles friend FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, PlayerAngles* def); // Prototypes. - void doPitchKeys(ESyncBits* actions, const bool stopcentering); + void doPitchKeys(InputPacket* const input); void doYawKeys(ESyncBits* actions); void doViewPitch(const bool canslopetilt, const bool climbing = false); void doViewYaw(const ESyncBits actions); diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 0394fa357..829d565d0 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1705,7 +1705,7 @@ void ProcessInput(PLAYER* pPlayer) const int florhit = pPlayer->actor->hit.florhit.type; pPlayer->Angles.doViewPitch(actor->xspr.height < 16 && (florhit == kHitSector || florhit == 0)); - pPlayer->Angles.doPitchKeys(&pInput->actions, pInput->horz); + pPlayer->Angles.doPitchKeys(pInput); pPlayer->slope = pPlayer->actor->spr.Angles.Pitch.Tan(); if (pInput->actions & SB_INVPREV) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index f7d6e972f..67b6b7fe3 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2988,7 +2988,7 @@ HORIZONLY: p->GetActor()->spr.Angles.Pitch += GetPlayerHorizon(snum); } - p->Angles.doPitchKeys(&actions, GetPlayerHorizon(snum).Sgn()); + p->Angles.doPitchKeys(&p->sync); p->checkhardlanding(); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 6575a524c..a2664a379 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3802,7 +3802,7 @@ HORIZONLY: p->GetActor()->spr.Angles.Pitch += GetPlayerHorizon(snum); } - p->Angles.doPitchKeys(&actions, GetPlayerHorizon(snum).Sgn()); + p->Angles.doPitchKeys(&p->sync); p->checkhardlanding(); diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index b95217738..ce0cd3b32 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -2471,7 +2471,7 @@ sectdone: pPlayer->pActor->spr.Angles.Pitch += DAngle::fromDeg(PlayerList[nPlayer].input.horz); } - pPlayer->Angles.doPitchKeys(&PlayerList[nLocalPlayer].input.actions, PlayerList[nPlayer].input.pan); + pPlayer->Angles.doPitchKeys(&PlayerList[nLocalPlayer].input); if (actions & (SB_AIM_UP | SB_AIM_DOWN) || PlayerList[nPlayer].input.horz) { diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 7abc652c7..8d7a23779 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -2163,7 +2163,7 @@ void DoPlayerMove(PLAYER* pp) pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); } - pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz); + pp->Angles.doPitchKeys(&pp->input); DoPlayerSlopeTilting(pp); @@ -2750,7 +2750,7 @@ void DoPlayerMoveVehicle(PLAYER* pp) pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); } - pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz); + pp->Angles.doPitchKeys(&pp->input); DoPlayerSlopeTilting(pp); @@ -2796,7 +2796,7 @@ void DoPlayerMoveTurret(PLAYER* pp) pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); } - pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz); + pp->Angles.doPitchKeys(&pp->input); DoPlayerSlopeTilting(pp); } @@ -3398,7 +3398,7 @@ void DoPlayerClimb(PLAYER* pp) pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); } - pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz); + pp->Angles.doPitchKeys(&pp->input); DoPlayerSlopeTilting(pp);