From b6c34067bbd8bda4cb61f8064fb2d21d05f8f49d Mon Sep 17 00:00:00 2001 From: Anonimus Date: Thu, 18 Sep 2025 15:12:02 -0400 Subject: [PATCH] Universal scale for cluster distancing Should hopefully make gradienting less punishing on maps like Green Cave --- src/k_kart.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 8b9d98270..7a9697293 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9364,6 +9364,30 @@ void K_KartLegacyUpdatePosition(player_t *player) player->position = position; } +/*-------------------------------------------------- + UINT32 K_UndoMapScaling(UINT32 distance) + + Takes a raw map distance and adjusts it to + be in x1 scale. + + Input Arguments:- + distance - Original distance. + + Return:- + Distance unscaled by mapobjectscale. +--------------------------------------------------*/ +static UINT32 K_UndoMapScaling(UINT32 distance) +{ + if (mapobjectscale != FRACUNIT) + { + // Bring back to normal scale. + return FixedDiv(distance, mapobjectscale); + } + + return distance; +} + + // Brute-force finds the area on the course with the highest player density in a given radius. // Based on DBSCAN, so it "chain-scans" neighboring players as well for a more accurate result. UINT32 clusterid = 0; @@ -9462,8 +9486,9 @@ void K_UpdateAllPlayerPositions(void) // First loop: Ensure all players' distance to the finish line are all accurate for (i = 0; i < MAXPLAYERS; i++) { - player_t *player = &players[i]; - if (!playeringame[i] || player->spectator || !player->mo || P_MobjWasRemoved(player->mo)) + player_t* player = &players[i]; + if (!playeringame[i] || player->spectator || !player->mo || + P_MobjWasRemoved(player->mo)) { continue; } @@ -9482,8 +9507,9 @@ void K_UpdateAllPlayerPositions(void) else K_KartUpdatePosition(&players[i]); - // Get the cluster distance. - players[i].distancefromcluster = K_UpdateDistanceFromCluster(&players[i]); + // Get the cluster distance. + players[i].distancefromcluster = + K_UndoMapScaling(K_UpdateDistanceFromCluster(&players[i])); } } }