From 9b93f561117fbca5a5458d238c16419ced3efece Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 10 Mar 2024 14:08:59 -0400 Subject: [PATCH] Add pre-Podium intermission music --- src/g_game.c | 16 ++-- src/k_follower.c | 6 +- src/k_kart.c | 8 +- src/k_vote.c | 2 +- src/k_zvote.c | 16 ++-- src/lua_baselib.c | 22 +++--- src/music.cpp | 14 ---- src/music.h | 4 - src/objects/shrink.c | 2 +- src/p_inter.c | 6 +- src/p_local.h | 4 +- src/p_spec.c | 6 +- src/p_user.c | 20 ++--- src/r_skins.c | 4 +- src/s_sound.c | 3 +- src/st_stuff.c | 2 +- src/y_inter.cpp | 172 ++++++++++++++++++++++++++++++++++++++++++- src/y_inter.h | 2 + 18 files changed, 230 insertions(+), 79 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 74d7a2564..ca932995c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2010,7 +2010,7 @@ void G_Ticker(boolean run) musiccountdown--; if (musiccountdown == 1) { - Music_PlayIntermission(); + Y_PlayIntermissionMusic(); } else if (musiccountdown == MUSIC_COUNTDOWN_MAX - K_TallyDelay()) { @@ -2596,7 +2596,7 @@ void G_MovePlayerToSpawnOrCheatcheck(INT32 playernum) mapthing_t *G_FindTeamStart(INT32 playernum) { - const boolean doprints = P_IsLocalPlayer(&players[playernum]); + const boolean doprints = P_IsPartyPlayer(&players[playernum]); INT32 i,j; if (!numredctfstarts && !numbluectfstarts) //why even bother, eh? @@ -2651,7 +2651,7 @@ mapthing_t *G_FindTeamStart(INT32 playernum) mapthing_t *G_FindBattleStart(INT32 playernum) { - const boolean doprints = P_IsLocalPlayer(&players[playernum]); + const boolean doprints = P_IsPartyPlayer(&players[playernum]); INT32 i, j; if (numdmstarts) @@ -2674,7 +2674,7 @@ mapthing_t *G_FindBattleStart(INT32 playernum) mapthing_t *G_FindRaceStart(INT32 playernum) { - const boolean doprints = P_IsLocalPlayer(&players[playernum]); + const boolean doprints = P_IsPartyPlayer(&players[playernum]); if (numcoopstarts) { @@ -2770,7 +2770,7 @@ mapthing_t *G_FindRaceStart(INT32 playernum) mapthing_t *G_FindPodiumStart(INT32 playernum) { - const boolean doprints = P_IsLocalPlayer(&players[playernum]); + const boolean doprints = P_IsPartyPlayer(&players[playernum]); if (numcoopstarts) { @@ -2893,13 +2893,13 @@ mapthing_t *G_FindMapStart(INT32 playernum) { if (nummapthings) { - if (P_IsLocalPlayer(&players[playernum])) + if (P_IsPartyPlayer(&players[playernum])) CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the first mapthing!\n")); spawnpoint = &mapthings[0]; } else { - if (P_IsLocalPlayer(&players[playernum])) + if (P_IsPartyPlayer(&players[playernum])) CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the origin!\n")); } } @@ -3791,7 +3791,7 @@ void G_UpdateVisited(void) if (!playeringame[i]) // Not here. continue; - if (!P_IsLocalPlayer(&players[i])) // Not local. + if (!P_IsPartyPlayer(&players[i])) // Not local. continue; if (players[i].spectator == true) // Not playing. diff --git a/src/k_follower.c b/src/k_follower.c index c7ef5713b..466b17720 100644 --- a/src/k_follower.c +++ b/src/k_follower.c @@ -110,7 +110,7 @@ boolean K_SetFollowerByName(INT32 playernum, const char *skinname) } } - if (P_IsLocalPlayer(player)) + if (P_IsPartyPlayer(player)) { CONS_Alert(CONS_WARNING, M_GetText("Follower '%s' not found.\n"), skinname); } @@ -181,7 +181,7 @@ void K_SetFollowerByNum(INT32 playernum, INT32 skinnum) return; } - if (P_IsLocalPlayer(player)) + if (P_IsPartyPlayer(player)) { CONS_Alert(CONS_WARNING, M_GetText("Follower %d not found\n"), skinnum); } @@ -738,7 +738,7 @@ void K_FollowerHornTaunt(player_t *taunter, player_t *victim, boolean mysticmelo (demo.playback == false) // No downloading somebody else's replay && (fl->hornsound == sfx_melody) // Must be the Mystic Melody && (taunter->bot == false) // No getting your puppies to do it for you - && P_IsLocalPlayer(taunter) // Must be in your party + && P_IsPartyPlayer(taunter) // Must be in your party && !(mapheaderinfo[gamemap-1]->records.mapvisited & MV_MYSTICMELODY) // Not already done ); } diff --git a/src/k_kart.c b/src/k_kart.c index 5bf83869a..d69ee7928 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6762,7 +6762,7 @@ void K_DoInvincibility(player_t *player, tic_t time) P_SetScale(overlay, player->mo->scale); } - if (P_IsLocalPlayer(player) == false) + if (P_IsPartyPlayer(player) == false) { S_StartSound(player->mo, sfx_alarmi); } @@ -7969,7 +7969,7 @@ static void K_UpdateInvincibilitySounds(player_t *player) { INT32 sfxnum = sfx_None; - if (player->mo->health > 0 && !P_IsLocalPlayer(player)) // used to be !P_IsDisplayPlayer(player) + if (player->mo->health > 0 && !P_IsPartyPlayer(player)) // used to be !P_IsDisplayPlayer(player) { if (player->invincibilitytimer > 0) // Prioritize invincibility sfxnum = sfx_alarmi; @@ -11012,7 +11012,7 @@ void K_KartUpdatePosition(player_t *player) } // Special stages: fade out music near the finish line - if (P_IsLocalPlayer(player)) + if (P_IsPartyPlayer(player)) { K_FadeOutSpecialMusic(player->distancetofinish); } @@ -12601,7 +12601,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->mo->destscale = FixedMul(player->mo->destscale, SHRINK_SCALE); } - if (P_IsLocalPlayer(player) == false && player->invincibilitytimer == 0) + if (P_IsPartyPlayer(player) == false && player->invincibilitytimer == 0) { // don't play this if the player has invincibility -- that takes priority S_StartSound(player->mo, sfx_alarmg); diff --git a/src/k_vote.c b/src/k_vote.c index da617ceb5..57e014464 100644 --- a/src/k_vote.c +++ b/src/k_vote.c @@ -1037,7 +1037,7 @@ static void Y_VoteStops(SINT8 pick, SINT8 level) { Y_FinalizeVote(level); - if (netgame && P_IsLocalPlayer(&players[pick])) + if (netgame && P_IsPartyPlayer(&players[pick])) { S_StartSound(NULL, sfx_yeeeah); // yeeeah! } diff --git a/src/k_zvote.c b/src/k_zvote.c index 535508c43..bc12d51b7 100644 --- a/src/k_zvote.c +++ b/src/k_zvote.c @@ -586,7 +586,7 @@ boolean K_AllowNewMidVote(player_t *caller, midVoteType_e type, INT32 variable, if (g_midVote.active == true) { // Don't allow another vote if one is already running. - if (P_IsLocalPlayer(caller) == true) + if (P_IsMachineLocalPlayer(caller) == true) { CONS_Alert(CONS_ERROR, "A vote is already in progress.\n"); } @@ -597,7 +597,7 @@ boolean K_AllowNewMidVote(player_t *caller, midVoteType_e type, INT32 variable, if (g_midVote.delay > 0) { // Don't allow another vote if one has recently just ran. - if (P_IsLocalPlayer(caller) == true) + if (P_IsMachineLocalPlayer(caller) == true) { CONS_Alert(CONS_ERROR, "Another vote was called too recently.\n"); } @@ -608,7 +608,7 @@ boolean K_AllowNewMidVote(player_t *caller, midVoteType_e type, INT32 variable, if (type < 0 || type >= MVT__MAX) { // Invalid range. - if (P_IsLocalPlayer(caller) == true) + if (P_IsMachineLocalPlayer(caller) == true) { CONS_Alert(CONS_ERROR, "Invalid vote type.\n"); } @@ -619,7 +619,7 @@ boolean K_AllowNewMidVote(player_t *caller, midVoteType_e type, INT32 variable, if (g_midVoteTypeDefs[type].cv_allowed.value == 0) { // These types of votes aren't allowed on this server. - if (P_IsLocalPlayer(caller) == true) + if (P_IsMachineLocalPlayer(caller) == true) { CONS_Alert(CONS_ERROR, "Vote type is not allowed in this server.\n"); } @@ -630,7 +630,7 @@ boolean K_AllowNewMidVote(player_t *caller, midVoteType_e type, INT32 variable, if (caller == NULL || K_PlayerIDAllowedInMidVote(caller - players) == false) { // Invalid calling player. - if (caller != NULL && P_IsLocalPlayer(caller) == true) + if (caller != NULL && P_IsMachineLocalPlayer(caller) == true) { CONS_Alert(CONS_ERROR, "Invalid calling player.\n"); } @@ -643,7 +643,7 @@ boolean K_AllowNewMidVote(player_t *caller, midVoteType_e type, INT32 variable, if (victim == NULL) { // Invalid victim. - if (P_IsLocalPlayer(caller) == true) + if (P_IsMachineLocalPlayer(caller) == true) { CONS_Alert(CONS_ERROR, "Can't kick this player; it's invalid.\n"); } @@ -653,7 +653,7 @@ boolean K_AllowNewMidVote(player_t *caller, midVoteType_e type, INT32 variable, if (caller == victim) { - if (P_IsLocalPlayer(caller) == true) + if (P_IsMachineLocalPlayer(caller) == true) { CONS_Alert(CONS_ERROR, "Can't kick yourself.\n"); } @@ -668,7 +668,7 @@ boolean K_AllowNewMidVote(player_t *caller, midVoteType_e type, INT32 variable, ) { // Victim is the server or an admin. - if (P_IsLocalPlayer(caller) == true) + if (P_IsMachineLocalPlayer(caller) == true) { CONS_Alert(CONS_ERROR, "Can't kick this player; they are an administrator.\n"); } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c76888ce9..8eb4b406b 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -675,7 +675,7 @@ static int lib_pSpawnLockOn(lua_State *L) if (state >= NUMSTATES) return luaL_error(L, "state %d out of range (0 - %d)", state, NUMSTATES-1); #if 0 - if (P_IsLocalPlayer(player)) // Only display it on your own view. + if (P_IsPartyPlayer(player)) // Only display it on your own view. { mobj_t *visual = P_SpawnMobj(lockon->x, lockon->y, lockon->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker P_SetTarget(&visual->target, lockon); @@ -1639,7 +1639,7 @@ static int lib_pPlayRinglossSound(lua_State *L) if (!player) return LUA_ErrInvalid(L, "player_t"); } - if (!player || P_IsLocalPlayer(player)) + if (!player || P_IsPartyPlayer(player)) P_PlayRinglossSound(source); return 0; } @@ -1658,7 +1658,7 @@ static int lib_pPlayDeathSound(lua_State *L) if (!player) return LUA_ErrInvalid(L, "player_t"); } - if (!player || P_IsLocalPlayer(player)) + if (!player || P_IsPartyPlayer(player)) P_PlayDeathSound(source); return 0; } @@ -1677,7 +1677,7 @@ static int lib_pPlayVictorySound(lua_State *L) if (!player) return LUA_ErrInvalid(L, "player_t"); } - if (!player || P_IsLocalPlayer(player)) + if (!player || P_IsPartyPlayer(player)) P_PlayVictorySound(source); return 0; } @@ -1880,7 +1880,7 @@ static int lib_pSwitchWeather(lua_State *L) user = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); if (!user) // global globalweather = weathernum; - if (!user || P_IsLocalPlayer(user)) + if (!user || P_IsPartyPlayer(user)) P_SwitchWeather(weathernum); return 0; } @@ -1935,7 +1935,7 @@ static int lib_pSetupLevelSky(lua_State *L) user = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); if (!user) // global P_SetupLevelSky(skytexname, true); - else if (P_IsLocalPlayer(user)) + else if (P_IsPartyPlayer(user)) P_SetupLevelSky(skytexname, false); return 0; } @@ -1984,7 +1984,7 @@ static int lib_pSetSkyboxMobj(lua_State *L) return luaL_error(L, "skybox mobj index %d is out of range for P_SetSkyboxMobj argument #2 (expected 0 or 1)", w); #if 0 - if (!user || P_IsLocalPlayer(user)) + if (!user || P_IsPartyPlayer(user)) skyboxmo[w] = mo; #else CONS_Alert(CONS_WARNING, "TODO: P_SetSkyboxMobj is unimplemented\n"); @@ -2409,7 +2409,7 @@ static int lib_sStartSound(lua_State *L) if (!lua_isnil(L, 1)) if (!GetValidSoundOrigin(L, &origin)) return 0; - if (!player || P_IsLocalPlayer(player)) + if (!player || P_IsPartyPlayer(player)) { if (hud_running || hook_cmd_running) origin = NULL; // HUD rendering and CMD building startsound shouldn't have an origin, just remove it instead of having a retarded error. @@ -2439,7 +2439,7 @@ static int lib_sStartSoundAtVolume(lua_State *L) if (!GetValidSoundOrigin(L, &origin)) return LUA_ErrInvalid(L, "mobj_t/sector_t"); - if (!player || P_IsLocalPlayer(player)) + if (!player || P_IsPartyPlayer(player)) S_StartSoundAtVolume(origin, sound_id, volume); return 0; } @@ -2524,7 +2524,7 @@ static int lib_sStartMusicCaption(lua_State *L) return LUA_ErrInvalid(L, "player_t"); } - if (lifespan && (!player || P_IsLocalPlayer(player))) + if (lifespan && (!player || P_IsPartyPlayer(player))) { strlcpy(S_sfx[sfx_None].caption, caption, sizeof(S_sfx[sfx_None].caption)); S_StartCaption(sfx_None, -1, lifespan); @@ -2542,7 +2542,7 @@ static int lib_sShowMusicCredit(lua_State *L) if (!player) return LUA_ErrInvalid(L, "player_t"); } - if (!player || P_IsLocalPlayer(player)) + if (!player || P_IsPartyPlayer(player)) S_ShowMusicCredit(); return 0; } diff --git a/src/music.cpp b/src/music.cpp index 7205c2535..caa77e51c 100644 --- a/src/music.cpp +++ b/src/music.cpp @@ -218,20 +218,6 @@ void Music_Play(const char* id) } } -void Music_PlayIntermission(void) -{ - // why aren't the ATTACK_ enums declared alongside modeattacking? - if (modeattacking != 0) - { - Music_Remap("intermission", "timent"); - } - else - { - Music_Remap("intermission", "racent"); - } - Music_Play("intermission"); -} - void Music_DelayEnd(const char* id, tic_t duration) { Tune* tune = g_tunes.find(id); diff --git a/src/music.h b/src/music.h index 9661ce056..2265639ea 100644 --- a/src/music.h +++ b/src/music.h @@ -59,10 +59,6 @@ const char *Music_CurrentId(void); // back to the start.) void Music_Play(const char *id); -// Same as Music_Play, but a convenience for remapping intermission -// based on game state. -void Music_PlayIntermission(void); - // Postpone the end of this tune until N tics from now. The // tune should already be playing before calling this. void Music_DelayEnd(const char *id, tic_t duration); diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 1aa3fc3d0..942d2e816 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -576,7 +576,7 @@ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim) victim->destscale = FixedMul(victim->destscale, SHRINK_SCALE); } - if (P_IsLocalPlayer(victim->player) == false && victim->player->invincibilitytimer == 0) + if (P_IsPartyPlayer(victim->player) == false && victim->player->invincibilitytimer == 0) { // don't play this if the player has invincibility -- that takes priority S_StartSound(victim, sfx_alarmg); diff --git a/src/p_inter.c b/src/p_inter.c index 3fb9dd22a..fb39564ed 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -695,7 +695,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!P_CanPickupEmblem(player, special->health - 1)) return; - if (!P_IsLocalPlayer(player)) + if (!P_IsPartyPlayer(player)) { // Must be party. return; @@ -733,7 +733,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; } - if (!P_IsLocalPlayer(player)) + if (!P_IsPartyPlayer(player)) { // Must be party. return; @@ -832,7 +832,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; } - if (!P_IsLocalPlayer(player)) + if (!P_IsPartyPlayer(player)) { // Must be party. return; diff --git a/src/p_local.h b/src/p_local.h index c9e1860c1..421bf35fc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -162,8 +162,8 @@ boolean P_PlayerInPain(const player_t *player); void P_ResetPlayer(player_t *player); boolean P_PlayerCanDamage(player_t *player, mobj_t *thing); -boolean P_IsLocalPlayer(const player_t *player); -boolean P_IsMachineLocalPlayer(const player_t *player); +boolean P_IsPartyPlayer(const player_t *player); +boolean P_IsMachineLocalPlayer(const player_t *player); // TODO: rename back to P_IsLocalPlayer? boolean P_IsDisplayPlayer(const player_t *player); void P_SetPlayerAngle(player_t *player, angle_t angle); diff --git a/src/p_spec.c b/src/p_spec.c index ba3374cea..bb536982e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2197,7 +2197,7 @@ static void K_HandleLapIncrement(player_t *player) lastLowestLap = lowestLap; - if (P_IsLocalPlayer(player)) + if (P_IsPartyPlayer(player)) { player->roundconditions.checkthisframe = true; gamedata->deferredconditioncheck = true; @@ -3191,7 +3191,7 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha break; case 423: // Change Sky - if ((mo && mo->player && P_IsLocalPlayer(mo->player)) || args[1]) + if ((mo && mo->player && P_IsPartyPlayer(mo->player)) || args[1]) P_SetupLevelSky(stringargs[0], args[1]); break; @@ -3201,7 +3201,7 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha globalweather = (UINT8)(args[0]); P_SwitchWeather(globalweather); } - else if (mo && mo->player && P_IsLocalPlayer(mo->player)) + else if (mo && mo->player && P_IsPartyPlayer(mo->player)) P_SwitchWeather(args[0]); break; diff --git a/src/p_user.c b/src/p_user.c index 956bf7d37..4bc036470 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -449,7 +449,7 @@ INT32 P_GivePlayerRings(player_t *player, INT32 num_rings) if ((gametyperules & GTR_SPHERES)) // No rings in Battle Mode return 0; - if (gamedata && num_rings > 0 && P_IsLocalPlayer(player) && gamedata->totalrings <= GDMAX_RINGS) + if (gamedata && num_rings > 0 && P_IsPartyPlayer(player) && gamedata->totalrings <= GDMAX_RINGS) { gamedata->totalrings += num_rings; } @@ -747,7 +747,7 @@ void P_InvincGrowMusic(void) { player_t *player = &players[displayplayers[i]]; - if (!P_IsLocalPlayer(player)) + if (!P_IsPartyPlayer(player)) { // Director cam on another player? Don't play // this. @@ -1002,13 +1002,13 @@ boolean P_IsMachineLocalPlayer(const player_t *player) } // -// P_IsLocalPlayer +// P_IsPartyPlayer // // Returns true if player is // on the local machine // (or simulated party) // -boolean P_IsLocalPlayer(const player_t *player) +boolean P_IsPartyPlayer(const player_t *player) { if (player == NULL) { @@ -1226,7 +1226,7 @@ void P_DoPlayerExit(player_t *player, pflags_t flags) player->pflags |= flags; - if (P_IsLocalPlayer(player) && (!player->spectator && !demo.playback)) + if (P_IsPartyPlayer(player) && (!player->spectator && !demo.playback)) { legitimateexit = true; player->roundconditions.checkthisframe = true; @@ -1268,7 +1268,7 @@ void P_DoPlayerExit(player_t *player, pflags_t flags) K_UpdatePowerLevelsFinalize(player, false); - if (P_IsLocalPlayer(player) && !specialout && musiccountdown == 0) + if (P_IsPartyPlayer(player) && !specialout && musiccountdown == 0) { Music_Play("finish_silence"); musiccountdown = MUSIC_COUNTDOWN_MAX; @@ -3802,7 +3802,7 @@ void P_DoTimeOver(player_t *player) return; } - if (P_IsLocalPlayer(player) && !demo.playback) + if (P_IsPartyPlayer(player) && !demo.playback) { legitimateexit = true; // SRB2kart: losing a race is still seeing it through to the end :p player->roundconditions.checkthisframe = true; @@ -3828,7 +3828,7 @@ void P_DoTimeOver(player_t *player) P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER); } - if (P_IsLocalPlayer(player) && musiccountdown == 0) + if (P_IsPartyPlayer(player) && musiccountdown == 0) { Music_Play("finish_silence"); musiccountdown = MUSIC_COUNTDOWN_MAX; @@ -4205,7 +4205,7 @@ void P_PlayerThink(player_t *player) // SRB2Kart: despite how perfect this is, it's disabled FOR A REASON if (racecountdown == 11*TICRATE - 1) { - if (P_IsLocalPlayer(player)) + if (P_IsPartyPlayer(player)) S_ChangeMusicInternal("drown", false); } #endif @@ -4733,7 +4733,7 @@ void P_CheckRaceGriefing(player_t *player, boolean dopunishment) if (dopunishment && !player->griefWarned && player->griefValue >= (griefMax/2)) { K_AddMessageForPlayer(player, "Get moving!", true, false); - if (P_IsLocalPlayer(player)) + if (P_IsPartyPlayer(player)) S_StartSound(NULL, sfx_cftbl0); player->griefWarned = true; } diff --git a/src/r_skins.c b/src/r_skins.c index 89e5ff159..a7ffc6f89 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -462,7 +462,7 @@ void SetPlayerSkin(INT32 playernum, const char *skinname) return; } - if (P_IsLocalPlayer(player)) + if (P_IsPartyPlayer(player)) CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); else if(server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); @@ -482,7 +482,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) return; } - if (P_IsLocalPlayer(player)) + if (P_IsPartyPlayer(player)) CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); else if (server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); diff --git a/src/s_sound.c b/src/s_sound.c index 265deef97..d5cae81cf 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -37,6 +37,7 @@ #include "i_time.h" #include "v_video.h" // V_ThinStringWidth #include "music.h" +#include "y_inter.h" // Y_PlayIntermissionMusic extern consvar_t cv_mastervolume; @@ -1217,7 +1218,7 @@ void S_AttemptToRestoreMusic(void) } // FALLTHRU case GS_INTERMISSION: - Music_PlayIntermission(); + Y_PlayIntermissionMusic(); break; case GS_CEREMONY: Music_Play("level"); diff --git a/src/st_stuff.c b/src/st_stuff.c index 0b3c1a490..9b3007b78 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1277,7 +1277,7 @@ static void ST_overlayDrawer(void) { if (cv_showviewpointtext.value) { - if (!demo.attract && !P_IsLocalPlayer(stplyr) && !camera[viewnum].freecam) + if (!demo.attract && !P_IsPartyPlayer(stplyr) && !camera[viewnum].freecam) { if (r_splitscreen <= 1) { diff --git a/src/y_inter.cpp b/src/y_inter.cpp index 688afbd8c..57bd0d594 100644 --- a/src/y_inter.cpp +++ b/src/y_inter.cpp @@ -365,7 +365,7 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) break; } - if (!P_IsLocalPlayer(&players[i])) + if (!P_IsPartyPlayer(&players[i])) { continue; } @@ -530,7 +530,7 @@ void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 xoffset) boolean (*_isHighlightedPlayer)(const player_t *) = (demo.playback ? P_IsDisplayPlayer - : P_IsLocalPlayer + : P_IsPartyPlayer ); boolean doreverse = ( @@ -1972,6 +1972,172 @@ void Y_DetermineIntermissionType(void) } } +static UINT8 Y_PlayersBestPossiblePosition(player_t *const player) +{ + UINT8 bestPossiblePosition = MAXPLAYERS + 1; + UINT8 i = UINT8_MAX; + + if ((player->pflags & PF_NOCONTEST) == 0) + { + if (player->exiting) + { + // They are finished, so their position is set in stone. + bestPossiblePosition = player->position; + } + else + { + // If they're NOT finished, then check what their points could be + // if they finished in the first available position. + bestPossiblePosition = 1; + + for (i = 0; i < MAXPLAYERS; i++) + { + player_t *const other = &players[i]; + + if (!playeringame[i] || other->spectator) + { + continue; + } + + if (other == player) + { + continue; + } + + if (other->exiting) + { + bestPossiblePosition = std::max(bestPossiblePosition, other->position + 1); + } + } + } + } + + return bestPossiblePosition; +} + +static UINT32 Y_EstimatePodiumScore(player_t *const player, UINT8 numPlaying) +{ + UINT8 pos = Y_PlayersBestPossiblePosition(player); + UINT32 ourScore = player->score; + + if (pos < numPlaying) + { + ourScore += K_CalculateGPRankPoints(pos, numPlaying); + } + + return ourScore; +} + +static boolean Y_GuaranteedGPFirstPlace(void) +{ + player_t *bestInParty = nullptr; + UINT32 bestPartyScore = 0; + + UINT8 numPlaying = spectateGriefed; + + UINT8 i = UINT8_MAX; + + // Quick first loop to count players. + for (i = 0; i < MAXPLAYERS; i++) + { + player_t *const comparePlayer = &players[i]; + + if (!playeringame[i] || comparePlayer->spectator) + { + continue; + } + + numPlaying++; + } + + // Iterate our party, estimate the best possible exiting score out of all of them. + for (i = 0; i <= r_splitscreen; i++) + { + player_t *const comparePlayer = &players[displayplayers[i]]; + + if (comparePlayer->spectator) + { + continue; + } + + if (!comparePlayer->exiting) + { + continue; + } + + UINT32 newScore = Y_EstimatePodiumScore(comparePlayer, numPlaying); + if (bestInParty == nullptr || newScore > bestPartyScore) + { + bestInParty = comparePlayer; + bestPartyScore = newScore; + } + } + + if (bestInParty == nullptr) + { + // No partied players are actually available, + // so always use the regular intermission music. + return false; + } + + // Iterate through all players not belonging to our party. + // Estimate the possible scores that they could get. + // Play special music only if none of these scores beat ours! + for (i = 0; i < MAXPLAYERS; i++) + { + player_t *comparePlayer = &players[i]; + + if (!playeringame[i] || comparePlayer->spectator) + { + continue; + } + + if (P_IsPartyPlayer(comparePlayer)) + { + continue; + } + + if (Y_EstimatePodiumScore(comparePlayer, numPlaying) >= bestPartyScore) + { + // NO, there is a chance that we will NOT finish first! + // You may still be able to finish first, but it is NOT guaranteed. + return false; + } + } + + // There is an overwhelmingly good chance + // that we are finishing in first place. + return true; +} + +void Y_PlayIntermissionMusic(void) +{ + if (modeattacking != ATTACKING_NONE) + { + Music_Remap("intermission", "timent"); + } + else if (grandprixinfo.gp == true + && grandprixinfo.cup != nullptr + && roundqueue.size > 0 + && roundqueue.roundnum >= grandprixinfo.cup->numlevels) + { + if (Y_GuaranteedGPFirstPlace()) + { + Music_Remap("intermission", "gprnds"); + } + else + { + Music_Remap("intermission", "gprnd5"); + } + } + else + { + Music_Remap("intermission", "racent"); + } + + Music_Play("intermission"); +} + // // Y_StartIntermission // @@ -2106,7 +2272,7 @@ void Y_StartIntermission(void) if (musiccountdown == 0) { - Music_PlayIntermission(); + Y_PlayIntermissionMusic(); } S_ShowMusicCredit(); // Always call diff --git a/src/y_inter.h b/src/y_inter.h index b3b4bfeea..7e7530856 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -61,6 +61,8 @@ void Y_EndIntermission(void); void Y_DetermineIntermissionType(void); +void Y_PlayIntermissionMusic(void); + typedef enum { int_none,