From b2272bd37755e485ba687241b853951512f275c4 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 9 Sep 2020 23:00:43 +1000 Subject: [PATCH] SW: Partially revert 73d0772e87a4e38bb8b98f04f91a29c0f5f3e6b2 and do in a way that's more fidele to the original workflow. --- source/sw/src/game.h | 2 +- source/sw/src/input.cpp | 6 ++--- source/sw/src/player.cpp | 51 +++++++++++++++++++++++----------------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 6d0c38a38..8193aaca0 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -1059,7 +1059,7 @@ enum PF2_INPUT_CAN_AIM = (BIT(1)), // Allow calling DoPlayerHorizon() from processMovement() PF2_INPUT_CAN_TURN_GENERAL = (BIT(2)), // Allow calling DoPlayerTurn() from processMovement() PF2_INPUT_CAN_TURN_VEHICLE = (BIT(3)), // Allow calling DoPlayerTurnVehicle() from processMovement() - PF2_INPUT_CAN_MOVE_TURRET = (BIT(4)), // Allow calling DoPlayerMoveTurret() from processMovement() + PF2_INPUT_CAN_TURN_TURRET = (BIT(4)), // Allow calling DoPlayerTurnTurret() from processMovement() }; /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index f1bec201e..b4e69949e 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -37,7 +37,7 @@ BEGIN_SW_NS void DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust); void DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust); void DoPlayerTurnVehicle(PLAYERp pp, fixed_t q16avel, int z, int floor_dist); -void DoPlayerMoveTurret(PLAYERp pp, fixed_t q16avel, fixed_t q16horz, double const scaleAdjust); +void DoPlayerTurnTurret(PLAYERp pp, fixed_t q16avel); static InputPacket loc; static int32_t turnheldtime; @@ -326,9 +326,9 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool DoPlayerTurnVehicle(pp, q16avel, pp->posz + Z(10), labs(pp->posz + Z(10) - pp->sop->floor_loz)); } - if (TEST(pp->Flags2, PF2_INPUT_CAN_MOVE_TURRET)) + if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET)) { - DoPlayerMoveTurret(pp, q16avel, q16horz, scaleAdjust); + DoPlayerTurnTurret(pp, q16avel); } } diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index e2aa24f72..054390928 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -1742,6 +1742,8 @@ DoPlayerTurnTurret(PLAYERp pp, fixed_t q16avel) pp->q16ang = new_ang; sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang); } + + OperateSectorObject(pp->sop, FixedToInt(pp->q16ang), pp->sop->xmid, pp->sop->ymid); } void SlipSlope(PLAYERp pp) @@ -3174,18 +3176,38 @@ DoPlayerMoveVehicle(PLAYERp pp) } void -DoPlayerMoveTurret(PLAYERp pp, fixed_t q16avel, fixed_t q16horz, double const scaleAdjust) +DoPlayerMoveTurret(PLAYERp pp) { - DoPlayerTurnTurret(pp, q16avel); + if (!Prediction) + { + if (pp->input.q16avel && !pp->lastinput.q16avel) + PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); + else if (!pp->input.q16avel && pp->lastinput.q16avel) + PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); + } + + if (!cl_syncinput) + { + SET(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET); + } + else + { + DoPlayerTurnTurret(pp, pp->input.q16avel); + } if (PLAYER_MOVING(pp) == 0) RESET(pp->Flags, PF_PLAYER_MOVED); else SET(pp->Flags, PF_PLAYER_MOVED); - OperateSectorObject(pp->sop, FixedToInt(pp->q16ang), pp->sop->xmid, pp->sop->ymid); - - DoPlayerHorizon(pp, q16horz, scaleAdjust); + if (!cl_syncinput) + { + SET(pp->Flags2, PF2_INPUT_CAN_AIM); + } + else + { + DoPlayerHorizon(pp, pp->input.q16horz, 1); + } } void @@ -5773,22 +5795,7 @@ DoPlayerOperateTurret(PLAYERp pp) if (pp->sop_remote) RemoteToPlayer(pp); - if (!Prediction) - { - if (pp->input.q16avel && !pp->lastinput.q16avel) - PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); - else if (!pp->input.q16avel && pp->lastinput.q16avel) - PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); - } - - if (!cl_syncinput) - { - SET(pp->Flags2, PF2_INPUT_CAN_MOVE_TURRET); - } - else - { - DoPlayerMoveTurret(pp, pp->input.q16avel, pp->input.q16horz, 1); - } + DoPlayerMoveTurret(pp); if (pp->sop_remote) { @@ -7450,7 +7457,7 @@ domovethings(void) ChopsCheck(pp); // Reset flags used while tying input to framerate - RESET(pp->Flags2, PF2_INPUT_CAN_AIM|PF2_INPUT_CAN_TURN_GENERAL|PF2_INPUT_CAN_TURN_VEHICLE|PF2_INPUT_CAN_MOVE_TURRET); + RESET(pp->Flags2, PF2_INPUT_CAN_AIM|PF2_INPUT_CAN_TURN_GENERAL|PF2_INPUT_CAN_TURN_VEHICLE|PF2_INPUT_CAN_TURN_TURRET); resetinputhelpers(pp); if (pp->DoPlayerAction) pp->DoPlayerAction(pp);