diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 27c2c9bda..8c7ae8645 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -1009,6 +1009,7 @@ struct PLAYERstruct // Input helper variables and setters. double horizAdjust, angAdjust, pitchAdjust; + fixed_t angTarget; void addang(int v) { q16ang = (q16ang + IntToFixed(v)) & 0x7FFFFFF; } void setang(int v) { q16ang = IntToFixed(v); } void addhoriz(int v) { q16horiz += (IntToFixed(v)); } diff --git a/source/sw/src/input.cpp b/source/sw/src/input.cpp index fd4c43f82..33f588a97 100644 --- a/source/sw/src/input.cpp +++ b/source/sw/src/input.cpp @@ -280,22 +280,45 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool if (!cl_syncinput) { if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM)) + { DoPlayerHorizon(pp, q16horz, scaleAdjust); + } if (pp->horizAdjust) + { pp->q16horiz += FloatToFixed(scaleAdjust * pp->horizAdjust); + } if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_GENERAL)) + { DoPlayerTurn(pp, q16avel, scaleAdjust); + } - if (pp->angAdjust) + if (pp->angTarget) + { + fixed_t angDelta = GetDeltaQ16Angle(pp->angTarget, pp->q16ang); + pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * angDelta)); + + if (pp->q16ang >= pp->angTarget) + { + pp->q16ang = pp->angTarget; + pp->angTarget = 0; + } + } + else if (pp->angAdjust) + { pp->q16ang = (pp->q16ang + FloatToFixed(scaleAdjust * pp->angAdjust)) & 0x7FFFFFF; + } if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN_VEHICLE)) + { 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)) + { DoPlayerMoveTurret(pp, q16avel, q16horz, scaleAdjust); + } } loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL); diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 4a25cbd93..51593e82c 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -4258,7 +4258,7 @@ PlayerOnLadder(PLAYERp pp) pp->lx = lsp->x + nx * 5; pp->ly = lsp->y + ny * 5; - playerAddAngle(pp, FixedToFloat(GetDeltaQ16Angle(IntToFixed(pp->LadderAngle), pp->q16ang))); + playerSetAngle(pp, pp->LadderAngle); return TRUE; } @@ -7801,7 +7801,16 @@ void playerSetAngle(PLAYERp pp, double ang) { if (!cl_syncinput) { - pp->angAdjust += -1. * ((pp->q16ang / 65536.) - ang); + // Cancel out any angle adjustments as we're setting angle now. + pp->angAdjust = 0; + + // Add slight offset if input angle is coming in as absolute 0. + if (ang == 0) + { + ang += 0.1; + } + + pp->angTarget = pp->q16ang + GetDeltaQ16Angle(ang, pp->q16ang); } else {