Even better: base it off how much timer is left

So instead of prioritizing a specific track, the person who activated their powerup the latest gets their music. That should be a nicer solution for when multiple players are activating their powerups at the same time.
This commit is contained in:
TehRealSalt 2018-10-28 01:38:01 -04:00
parent a8e549e0c5
commit ab518c611c

View file

@ -1235,15 +1235,21 @@ void P_RestoreMusic(player_t *player)
S_ChangeMusicInternal((encoremode ? "estart" : "kstart"), false); //S_StopMusic(); S_ChangeMusicInternal((encoremode ? "estart" : "kstart"), false); //S_StopMusic();
else // see also where time overs are handled - search for "lives = 2" in this file else // see also where time overs are handled - search for "lives = 2" in this file
{ {
INT32 bestlocalmus = 0; // 0 is level music, 1 is invincibility, 2 is grow INT32 wantedmus = 0; // 0 is level music, 1 is invincibility, 2 is grow
if (splitscreen) if (splitscreen)
{ {
if (players[displayplayer].playerstate == PST_LIVE) INT32 bestlocaltimer = 1;
bestlocalmus = (players[displayplayer].kartstuff[k_growshrinktimer] > 1 ? 2 : (players[displayplayer].kartstuff[k_invincibilitytimer] > 1 ? 1 : 0));
#define setbests(p) \ #define setbests(p) \
if (players[p].playerstate == PST_LIVE && (players[p].kartstuff[k_growshrinktimer] > 1 ? 2 : (players[p].kartstuff[k_invincibilitytimer] > 1 ? 1 : 0)) > bestlocalmus) \ if (players[p].playerstate == PST_LIVE) \
bestlocalmus = (players[p].kartstuff[k_growshrinktimer] > 1 ? 2 : (players[p].kartstuff[k_invincibilitytimer] > 1 ? 1 : 0)); { \
if (players[p].kartstuff[k_growshrinktimer] > bestlocaltimer) \
{ wantedmus = 2; bestlocaltimer = players[p].kartstuff[k_growshrinktimer]; } \
else if (players[p].kartstuff[k_invincibilitytimer] > bestlocaltimer) \
{ wantedmus = 1; bestlocaltimer = players[p].kartstuff[k_invincibilitytimer]; } \
}
setbests(displayplayer);
setbests(secondarydisplayplayer); setbests(secondarydisplayplayer);
if (splitscreen > 1) if (splitscreen > 1)
setbests(thirddisplayplayer); setbests(thirddisplayplayer);
@ -1254,14 +1260,19 @@ void P_RestoreMusic(player_t *player)
else else
{ {
if (player->playerstate == PST_LIVE) if (player->playerstate == PST_LIVE)
bestlocalmus = (player->kartstuff[k_growshrinktimer] > 1 ? 2 : (player->kartstuff[k_invincibilitytimer] > 1 ? 1 : 0)); {
if (player->kartstuff[k_growshrinktimer] > 1)
wantedmus = 2;
else if (player->kartstuff[k_invincibilitytimer] > 1)
wantedmus = 1;
}
} }
// Item - Grow // Item - Grow
if (bestlocalmus == 2) if (wantedmus == 2)
S_ChangeMusicInternal("kgrow", true); S_ChangeMusicInternal("kgrow", true);
// Item - Invincibility // Item - Invincibility
else if (bestlocalmus == 1) else if (wantedmus == 1)
S_ChangeMusicInternal("kinvnc", true); S_ChangeMusicInternal("kinvnc", true);
else else
{ {