diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 65cb6d067..f4102b48b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3960,6 +3960,9 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) playerconsole[newplayernum] = console; G_BuildLocalSplitscreenParty(newplayernum); + if (node == mynode && splitscreenplayer == 0) + S_AttemptToRestoreMusic(); // Earliest viable point + if (netgame) { char joinmsg[256]; diff --git a/src/p_local.h b/src/p_local.h index 98168afe2..3bc622743 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -184,6 +184,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean fromAir, angle_t oldPitch, an void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative); void P_RestoreMusic(player_t *player); +void P_StartPositionMusic(boolean exact); void P_EndingMusic(void); mobj_t *P_SpawnGhostMobj(mobj_t *mobj); mobj_t *P_SpawnFakeShadow(mobj_t *mobj, UINT8 offset); diff --git a/src/p_setup.c b/src/p_setup.c index 31022b835..6ee45f218 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8062,13 +8062,11 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) // Fade out music here. Deduct 2 tics so the fade volume actually reaches 0. // But don't halt the music! S_Start will take care of that. This dodges a MIDI crash bug. - if (!(reloadinggamestate || gamestate != GS_LEVEL)) + if (gamestate == GS_LEVEL) S_FadeMusic(0, FixedMul( FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE)); - if (reloadinggamestate) - ; - else if (K_PodiumSequence()) + if (K_PodiumSequence()) { // mapmusrng is set by local player position in K_ResetCeremony S_InitLevelMusic(true); diff --git a/src/p_tick.c b/src/p_tick.c index 1c756a8e5..7b7a64056 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -901,22 +901,7 @@ void P_Ticker(boolean run) } // POSITION!! music - if (encoremode) - { - // Encore humming starts immediately. - if (leveltime == 1) - S_ChangeMusicInternal("encore", true); - } - else - { - // Plays the POSITION music after the camera spin - if (leveltime == introtime) - S_ChangeMusicInternal( - (mapheaderinfo[gamemap-1]->positionmus[0] - ? mapheaderinfo[gamemap-1]->positionmus - : "postn" - ), true); - } + P_StartPositionMusic(true); // exact times only } } diff --git a/src/p_user.c b/src/p_user.c index 00d3420ab..dc8aee15c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -705,6 +705,37 @@ void P_PlayVictorySound(mobj_t *source) S_StartSound(source, sfx_kwin); } +// +// P_StartPositionMusic +// +// Consistently sets starting music! +// +void P_StartPositionMusic(boolean exact) +{ + if (encoremode) + { + if (exact + ? (leveltime != 1) + : (leveltime < 1)) + return; + + S_ChangeMusicInternal("encore", true); + } + else + { + if (exact + ? (leveltime != introtime) + : (leveltime < introtime)) + return; + + S_ChangeMusicInternal( + (mapheaderinfo[gamemap-1]->positionmus[0] + ? mapheaderinfo[gamemap-1]->positionmus + : "postn" + ), true); + } +} + // // P_EndingMusic // @@ -882,6 +913,7 @@ void P_RestoreMusic(player_t *player) if ((K_CheckBossIntro() == false) && (leveltime < (starttime + (TICRATE/2)))) // see also where time overs are handled { + P_StartPositionMusic(false); // inexact timing permitted return; } diff --git a/src/s_sound.c b/src/s_sound.c index 7a1acce5a..ed0e29661 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1362,7 +1362,7 @@ static UINT32 queue_fadeinms; static tic_t pause_starttic; -static void S_AttemptToRestoreMusic(void) +void S_AttemptToRestoreMusic(void) { switch (gamestate) { @@ -1376,6 +1376,9 @@ static void S_AttemptToRestoreMusic(void) case GS_INTERMISSION: S_ChangeMusicInternal("racent", true); break; + case GS_CEREMONY: + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + break; case GS_TITLESCREEN: S_ChangeMusicInternal("_title", looptitle); break; @@ -2975,14 +2978,7 @@ void S_InitLevelMusic(boolean fromnetsave) mapmusresume = 0; } - S_StopMusic(); // Starting ambience should always be restarted, if playing. - - if (leveltime < (starttime + (TICRATE/2))) // SRB2Kart - { - ; - } - else - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_StopMusic(); S_ResetMusicStack(); music_stack_noposition = false; diff --git a/src/s_sound.h b/src/s_sound.h index 48a5c571c..182c98160 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -346,6 +346,9 @@ void S_ResumeAudio(void); void S_EnableSound(void); void S_DisableSound(void); +// Attempt to restore music based on gamestate. +void S_AttemptToRestoreMusic(void); + // // Music Fading //