diff --git a/src/k_kart.c b/src/k_kart.c index 402ee021..fccb6867 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3651,8 +3651,8 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) { const INT32 numsnds = 13; INT32 class = ((player->kartspeed-1)/3) + (3*((player->kartweight-1)/3)); // engine class number - INT32 numcloseplayers = 0; UINT8 volume = 255; + fixed_t volumedampen = 0; INT32 targetsnd = 0; INT32 i; @@ -3692,19 +3692,42 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) for (i = 0; i < MAXPLAYERS; i++) { + UINT8 thisvol = 0; + fixed_t dist; + if (!playeringame[i] || !players[i].mo || players[i].spectator || players[i].exiting) continue; - if (((i == displayplayer) + + if ((i == displayplayer) || (i == secondarydisplayplayer && splitscreen) || (i == thirddisplayplayer && splitscreen > 1) || (i == fourthdisplayplayer && splitscreen > 2)) - || (P_AproxDistance(P_AproxDistance(player->mo->x-players[i].mo->x, - player->mo->y-players[i].mo->y), player->mo->z-players[i].mo->z) <= 3072<mo->x-players[i].mo->x, + player->mo->y-players[i].mo->y), player->mo->z-players[i].mo->z) / 2; + + if (dist > 1536<>FRACBITS)) / (((1536<>(FRACBITS+4)); + + if (thisvol == 0) + continue; + + volumedampen += (thisvol * 257); // 255 * 257 = FRACUNIT } - if (numcloseplayers > 1) - volume /= numcloseplayers; + if (volumedampen > FRACUNIT) + volume = FixedDiv(volume<>FRACBITS; + + if (volume <= 0) // Might as well + return; S_StartSoundAtVolume(player->mo, (sfx_krta00 + player->kartstuff[k_enginesnd]) + (class*numsnds), volume); }