From c17f5c22ffabd5a6aa0e9c7cdda60a3a1d5a24b6 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Fri, 24 Feb 2023 21:16:53 -0700 Subject: [PATCH] Suspend local camera during DRIFTEND kickout --- src/g_game.c | 11 ++++++++--- src/p_user.c | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c1028d4aa..b0b01098a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1095,9 +1095,14 @@ static void G_DoAnglePrediction(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer, p realtics--; } - // In case of angle debugging, break glass - localangle[ssplayer - 1] += angleChange; - //player->angleturn = localangle[ssplayer - 1]; + if (player->pflags & PF_DRIFTEND) + { + localangle[ssplayer - 1] = player->mo->angle; + } + else + { + localangle[ssplayer - 1] += angleChange; + } } void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) diff --git a/src/p_user.c b/src/p_user.c index 9ba6beb07..b27bbb815 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2137,39 +2137,39 @@ static void P_UpdatePlayerAngle(player_t *player) if (!K_PlayerUsesBotMovement(player)) { + // With a full slam on the analog stick, how far could we steer in either direction? INT16 steeringRight = K_UpdateSteeringValue(player->steering, KART_FULLTURN); angle_t maxTurnRight = K_GetKartTurnValue(player, steeringRight) << TICCMD_REDUCE; INT16 steeringLeft = K_UpdateSteeringValue(player->steering, -1 * KART_FULLTURN); angle_t maxTurnLeft = K_GetKartTurnValue(player, steeringLeft) << TICCMD_REDUCE; + // Grab local camera angle from ticcmd. Where do we actually want to go? angle_t targetAngle = (player->cmd.angle) << TICCMD_REDUCE; - angle_t targetDelta = targetAngle - (player->mo->angle); - //CONS_Printf("%u, steering by %u but we want %u, MTL %d %u, MTR %d %u\n", targetAngle, angleChange, targetDelta, steeringLeft, maxTurnLeft, steeringRight, maxTurnRight); - if (targetDelta == angleChange || player->pflags & PF_DRIFTEND) { - //CONS_Printf("Facing correct, thank god\n"); + // We are where we need to be. :) + + // Alternatively, while in DRIFTEND we want to trust inputs for a bit, not camera. + // The game client doesn't know we're DRIFTEND until after a response gets back, + // so we momentarily ignore the camera angle and let the server trust our inputs instead. + // That way, even if you're steering blind, you get the intended "kick-out" effect. } - else if (targetDelta >= ANGLE_180 && maxTurnLeft >= targetDelta) + else if (targetDelta >= ANGLE_180 && maxTurnLeft >= targetDelta) // Overshot, so just fudge it. { - //CONS_Printf("undershoot left\n"); angleChange = targetDelta; } - else if (targetDelta <= ANGLE_180 && maxTurnRight <= targetDelta) + else if (targetDelta <= ANGLE_180 && maxTurnRight <= targetDelta) // Overshot, so just fudge it. { - //CONS_Printf("undershoot right\n"); angleChange = targetDelta; } - else if (targetDelta >= ANGLE_180 && maxTurnLeft < targetDelta) + else if (targetDelta >= ANGLE_180 && maxTurnLeft < targetDelta) // Undershot, slam the stick. { - //CONS_Printf("overshoot left\n"); angleChange = maxTurnLeft; } - else if (targetDelta <= ANGLE_180 && maxTurnRight < targetDelta) + else if (targetDelta <= ANGLE_180 && maxTurnRight < targetDelta) // Undershot, slam the stick. { - //CONS_Printf("overshoot right\n"); angleChange = maxTurnRight; } }