K_FadeOutSpecialMusic: Iterate over all display players in K_TickSpecialStage, instead of clobbering the volume in K_KartUpdatePosition

Prevents weird audio clipping near the end of the course
This commit is contained in:
toaster 2024-03-30 16:00:08 +00:00
parent e9205e19d6
commit a752ed095f
2 changed files with 13 additions and 6 deletions

View file

@ -11143,12 +11143,6 @@ void K_KartUpdatePosition(player_t *player)
player->topinfirst = 0;
}
// Special stages: fade out music near the finish line
if (P_IsPartyPlayer(player))
{
K_FadeOutSpecialMusic(player->distancetofinish);
}
player->position = position;
}

View file

@ -120,6 +120,19 @@ void K_TickSpecialStage(void)
return;
}
// Special stages: fade out music near the finish line
UINT8 i;
UINT32 lowestdistance = UINT32_MAX;
for (i = 0; i <= r_splitscreen; i++)
{
if (!playeringame[displayplayers[i]] || players[displayplayers[i]].spectator)
continue;
if (players[displayplayers[i]].distancetofinish >= lowestdistance)
continue;
lowestdistance = players[displayplayers[i]].distancetofinish;
}
K_FadeOutSpecialMusic(lowestdistance);
if (P_MobjWasRemoved(specialstageinfo.ufo))
{
P_SetTarget(&specialstageinfo.ufo, NULL);