From b777759744052ac9825d5a7aa44a5f8e8d07a1a8 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Wed, 1 Mar 2023 22:27:00 -0700 Subject: [PATCH] Use postfix for P_FindClosestTurningForAngle iterations --- src/p_user.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 2716a9b8b..f95d5afc1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2131,7 +2131,7 @@ static INT16 P_FindClosestTurningForAngle(player_t *player, INT32 targetAngle, I // Slightly frumpy binary search for the ideal turning input. // We do this instead of reversing K_GetKartTurnValue so that future handling changes are automatically accounted for. - while (attempts < 20) // Practical calls of this function search maximum 10 times, this is solely for safety. + while (attempts++ < 20) // Practical calls of this function search maximum 10 times, this is solely for safety. { // These need to be treated as signed, or situations where boundaries straddle 0 are a mess. INT32 lowAngle = K_GetKartTurnValue(player, lowBound) << TICCMD_REDUCE; @@ -2174,14 +2174,11 @@ static INT16 P_FindClosestTurningForAngle(player_t *player, INT32 targetAngle, I if (newError <= lowError && newError <= highError) preferred = newBound; - // ...adjust the bounds... + // ....and adjust the bounds for another run. if (lowAngle <= targetAngle && targetAngle <= newAngle) highBound = newBound; else lowBound = newBound; - - // ...and go next - attempts++; } return preferred;