From 380beaa0233f81c401ee5e9895fc54932561a94f Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 2 Apr 2023 23:49:45 +0100 Subject: [PATCH] Refactor Rumble condition check to iterate over splitscreen players once in p_tick.c, instead of players*splitscreen players in k_kart.c --- src/k_kart.c | 25 ------------------------- src/p_tick.c | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index c920e836f..a0730608c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8337,31 +8337,6 @@ void K_KartPlayerAfterThink(player_t *player) player->nullHitlag = 0; } - - // Apply rumble to player if local to machine and not in demo playback - if (!demo.playback) - { - int i; - - for (i = 0; i <= splitscreen; i++) - { - if (player == &players[g_localplayers[i]]) - { - UINT16 low = 0; - UINT16 high = 0; - - if (player->boostpower < FRACUNIT && P_IsObjectOnGround(player->mo)) - { - low = 65536 / 4; - high = 65536 / 4; - } - - G_PlayerDeviceRumble(i, low, high); - - break; - } - } - } } /*-------------------------------------------------- diff --git a/src/p_tick.c b/src/p_tick.c index 7327e5c1d..4c731bf9d 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -747,6 +747,28 @@ void P_Ticker(boolean run) } } + // Apply rumble to player if local to machine and not in demo playback + if (!demo.playback) + { + for (i = 0; i <= splitscreen; i++) + { + player_t *player = &players[g_localplayers[i]]; + UINT16 low = 0; + UINT16 high = 0; + + if (player->mo == NULL) + continue; + + if (player->boostpower < FRACUNIT && P_IsObjectOnGround(player->mo)) + { + low = 65536 / 4; + high = 65536 / 4; + } + + G_PlayerDeviceRumble(i, low, high); + } + } + if (numFinishingPlayers > 1) { for (i = 0; i < numFinishingPlayers; i++)