diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 10226b003..b30aedfd8 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -344,11 +344,14 @@ void GameInput::getInput(const double scaleAdjust, InputPacket* packet) // //--------------------------------------------------------------------------- -void PlayerAngles::doPitchKeys(InputPacket* const input) +void PlayerAngles::doPitchInput(InputPacket* const input) { - // Cancel return to center if conditions met. + // Add player's mouse/device input. if (input->horz) + { + pActor->spr.Angles.Pitch += DAngle::fromDeg(input->horz * SyncInput()); input->actions &= ~SB_CENTERVIEW; + } // Set up a myriad of bools. const auto aimingUp = (input->actions & SB_LOOK_UP) == SB_AIM_UP; @@ -390,8 +393,11 @@ void PlayerAngles::doPitchKeys(InputPacket* const input) // //--------------------------------------------------------------------------- -void PlayerAngles::doYawKeys(InputPacket* const input) +void PlayerAngles::doYawInput(InputPacket* const input) { + // Add player's mouse/device input. + pActor->spr.Angles.Yaw += DAngle::fromDeg(input->avel * SyncInput()); + if (input->actions & SB_TURNAROUND) { if (YawSpin == nullAngle) diff --git a/source/core/gameinput.h b/source/core/gameinput.h index ec860dabc..da15cbb94 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -86,8 +86,8 @@ struct PlayerAngles 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); // Prototypes. - void doPitchKeys(InputPacket* const input); - void doYawKeys(InputPacket* const input); + void doPitchInput(InputPacket* const input); + void doYawInput(InputPacket* const input); void doViewPitch(const bool canslopetilt, const bool climbing = false); void doViewYaw(InputPacket* const input); diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 1f29f0703..e678c66e5 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1574,13 +1574,7 @@ void ProcessInput(PLAYER* pPlayer) } pPlayer->Angles.doViewYaw(pInput); - - if (SyncInput()) - { - pPlayer->actor->spr.Angles.Yaw += DAngle::fromDeg(pInput->avel); - } - - pPlayer->Angles.doYawKeys(pInput); + pPlayer->Angles.doYawInput(pInput); if (!(pInput->actions & SB_JUMP)) pPlayer->cantJump = 0; @@ -1704,14 +1698,9 @@ void ProcessInput(PLAYER* pPlayer) pInput->actions &= ~SB_OPEN; } - if (SyncInput()) - { - pPlayer->actor->spr.Angles.Pitch += DAngle::fromDeg(pInput->horz); - } - const int florhit = pPlayer->actor->hit.florhit.type; pPlayer->Angles.doViewPitch(actor->xspr.height < 16 && (florhit == kHitSector || florhit == 0)); - pPlayer->Angles.doPitchKeys(pInput); + pPlayer->Angles.doPitchInput(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 07430f0a9..1d4804516 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1775,15 +1775,12 @@ void processinput_d(int snum) p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floortexture == mirrortex) || !p->insector())); - p->Angles.doYawKeys(&p->sync); - // Shrinking code if (psectlotag == ST_2_UNDERWATER) { underwater(snum, actions, floorz, ceilingz); } - else if (p->jetpack_on) { operateJetpack(snum, actions, psectlotag, floorz, ceilingz, shrunk); @@ -1800,17 +1797,16 @@ void processinput_d(int snum) doubvel = 0; p->vel.X = 0; p->vel.Y = 0; + p->sync.avel = 0; setForcedSyncInput(snum); } - else if (SyncInput()) + else { - //p->ang += syncangvel * constant - //ENGINE calculates angvel for you - // may still be needed later for demo recording - - p->GetActor()->spr.Angles.Yaw += p->adjustavel(PlayerInputAngVel(snum)); + p->sync.avel = p->adjustavel(PlayerInputAngVel(snum)); } + p->Angles.doYawInput(&p->sync); + purplelavacheck(p); if (p->spritebridge == 0 && pact->insector()) @@ -2020,12 +2016,7 @@ HORIZONLY: playerAimDown(snum, actions); } - if (SyncInput()) - { - p->GetActor()->spr.Angles.Pitch += GetPlayerHorizon(snum); - } - - p->Angles.doPitchKeys(&p->sync); + p->Angles.doPitchInput(&p->sync); p->checkhardlanding(); diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index d3d20e192..8c27135a3 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2562,8 +2562,6 @@ void processinput_r(int snum) p->backuppos(ud.clipping == 0 && ((p->insector() && p->cursector->floortexture == mirrortex) || !p->insector())); - p->Angles.doYawKeys(&p->sync); - // Shrinking code if (psectlotag == ST_17_PLATFORM_UP || (isRRRA() && psectlotag == ST_18_ELEVATOR_DOWN)) @@ -2578,13 +2576,13 @@ void processinput_r(int snum) else S_StopSound(432); } + if (isRRRA() && p->sea_sick_stat) { p->pycount += 32; p->pycount &= 2047; p->pyoff = BobVal(p->pycount) * (p->SeaSick? 32 : 1); } - if (psectlotag == ST_2_UNDERWATER) { underwater(snum, actions, floorz, ceilingz); @@ -2601,17 +2599,16 @@ void processinput_r(int snum) doubvel = 0; p->vel.X = 0; p->vel.Y = 0; + p->sync.avel = 0; setForcedSyncInput(snum); } - else if (SyncInput()) + else { - //p->ang += syncangvel * constant - //ENGINE calculates angvel for you - // may still be needed later for demo recording - - p->GetActor()->spr.Angles.Yaw += p->adjustavel(PlayerInputAngVel(snum)); + p->sync.avel = p->adjustavel(PlayerInputAngVel(snum)); } + p->Angles.doYawInput(&p->sync); + purplelavacheck(p); if (p->spritebridge == 0 && pact->insector()) @@ -2948,12 +2945,7 @@ HORIZONLY: p->GetActor()->spr.Angles.Pitch += maphoriz(d); } - if (SyncInput()) - { - p->GetActor()->spr.Angles.Pitch += GetPlayerHorizon(snum); - } - - p->Angles.doPitchKeys(&p->sync); + p->Angles.doPitchInput(&p->sync); p->checkhardlanding(); diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index f7c27132f..f22a4e8ef 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -356,9 +356,9 @@ struct player_struct void checkhardlanding(); void playerweaponsway(double xvel); - DAngle adjustavel(float avel) + float adjustavel(float avel) { - return DAngle::fromDeg((psectlotag == ST_2_UNDERWATER)? avel * 0.875f : avel); + return (psectlotag == ST_2_UNDERWATER)? avel * 0.875f : avel; } void setCursector(sectortype* sect) diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index db1d7458e..548056921 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1534,43 +1534,6 @@ static void doPlayerGravity(DExhumedActor* const pPlayerActor) // //--------------------------------------------------------------------------- -static void doPlayerPitch(Player* const pPlayer) -{ - const auto pInput = &pPlayer->input; - - if (SyncInput()) - { - pPlayer->pActor->spr.Angles.Pitch += DAngle::fromDeg(pInput->horz); - } - - pPlayer->Angles.doPitchKeys(pInput); -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void doPlayerYaw(Player* const pPlayer) -{ - const auto pInput = &pPlayer->input; - - if (SyncInput()) - { - pPlayer->pActor->spr.Angles.Yaw += DAngle::fromDeg(pInput->avel); - } - - pPlayer->Angles.doYawKeys(pInput); - pPlayer->Angles.doViewYaw(pInput); -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - static void doPlayerCameraEffects(Player* const pPlayer, const double nDestVertPan) { const auto pPlayerActor = pPlayer->pActor; @@ -1835,8 +1798,10 @@ static bool doPlayerInput(Player* const pPlayer) return false; // update player yaw here as per the original workflow. - doPlayerYaw(pPlayer); - doPlayerPitch(pPlayer); + const auto pInput = &pPlayer->input; + pPlayer->Angles.doViewYaw(pInput); + pPlayer->Angles.doYawInput(pInput); + pPlayer->Angles.doPitchInput(pInput); if (nMove.type || nMove.exbits) { diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 2c6dafa4f..d7eff90dd 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -2025,13 +2025,7 @@ void DoPlayerMove(PLAYER* pp) SlipSlope(pp); pp->Angles.doViewYaw(&pp->input); - - if (SyncInput()) - { - pp->actor->spr.Angles.Yaw += DAngle::fromDeg(pp->input.avel); - } - - pp->Angles.doYawKeys(&pp->input); + pp->Angles.doYawInput(&pp->input); UpdatePlayerSpriteAngle(pp); pp->lastcursector = pp->cursector; @@ -2150,13 +2144,8 @@ void DoPlayerMove(PLAYER* pp) DoPlayerSetWadeDepth(pp); - if (SyncInput()) - { - pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); - } - DoPlayerSlopeTilting(pp); - pp->Angles.doPitchKeys(&pp->input); + pp->Angles.doPitchInput(&pp->input); if (pp->insector() && (pp->cursector->extra & SECTFX_DYNAMIC_AREA)) { @@ -2722,13 +2711,8 @@ void DoPlayerMoveVehicle(PLAYER* pp) OperateSectorObject(pp->sop, pp->actor->spr.Angles.Yaw, pp->actor->spr.pos.XY()); pp->cursector = save_sect; // for speed - if (SyncInput()) - { - pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); - } - DoPlayerSlopeTilting(pp); - pp->Angles.doPitchKeys(&pp->input); + pp->Angles.doPitchInput(&pp->input); DoTankTreads(pp); } @@ -2757,13 +2741,8 @@ void DoPlayerMoveTurret(PLAYER* pp) else pp->Flags |= (PF_PLAYER_MOVED); - if (SyncInput()) - { - pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); - } - DoPlayerSlopeTilting(pp); - pp->Angles.doPitchKeys(&pp->input); + pp->Angles.doPitchInput(&pp->input); } //--------------------------------------------------------------------------- @@ -3354,13 +3333,8 @@ void DoPlayerClimb(PLAYER* pp) // setsprite to players location ChangeActorSect(pp->actor, pp->cursector); - if (SyncInput()) - { - pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz); - } - DoPlayerSlopeTilting(pp); - pp->Angles.doPitchKeys(&pp->input); + pp->Angles.doPitchInput(&pp->input); if (FAF_ConnectArea(pp->cursector)) {