From 1ad82e7651fdb796caa395bfddafb30ec5b40d92 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 9 Jan 2022 00:10:14 -0500 Subject: [PATCH] Update how scaled speed is calculated This makes it so that the scaled speed shows up on the percentage speedometer. --- src/k_kart.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 04b65ac75..1085d0a76 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2906,22 +2906,20 @@ static void K_GetKartBoostPower(player_t *player) fixed_t K_GrowShrinkSpeedMul(player_t *player) { fixed_t scaleDiff = player->mo->scale - mapobjectscale; - fixed_t physicsScale = mapobjectscale; + fixed_t playerScale = FixedDiv(player->mo->scale, mapobjectscale); fixed_t speedMul = FRACUNIT; if (scaleDiff > 0) { // Grown // Change x2 speed into x1.5 - physicsScale = FixedMul(GROW_PHYSICS_SCALE, mapobjectscale); - speedMul = FixedDiv(physicsScale, player->mo->scale); + speedMul = FixedDiv(FixedMul(playerScale, GROW_PHYSICS_SCALE), GROW_SCALE); } else if (scaleDiff < 0) { // Shrunk // Change x0.5 speed into x0.75 - physicsScale = FixedMul(SHRINK_PHYSICS_SCALE, mapobjectscale); - speedMul = FixedDiv(physicsScale, player->mo->scale); + speedMul = FixedDiv(FixedMul(playerScale, SHRINK_PHYSICS_SCALE), SHRINK_SCALE); } return speedMul; @@ -2965,18 +2963,16 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower) } } - if (mobjValid == true) - { - finalspeed = FixedMul(finalspeed, player->mo->scale); - finalspeed = FixedMul(finalspeed, K_GrowShrinkSpeedMul(player)); - } - else - { - finalspeed = FixedMul(finalspeed, mapobjectscale); - } + finalspeed = FixedMul(finalspeed, mapobjectscale); if (doboostpower == true) { + if (mobjValid == true) + { + // Scale with the player. + finalspeed = FixedMul(finalspeed, K_GrowShrinkSpeedMul(player)); + } + if (K_PlayerUsesBotMovement(player)) { finalspeed = FixedMul(finalspeed, K_BotTopSpeedRubberband(player));