From 2fd7c7717c1b95ffc655ff9e4b8506a227184be3 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 22 Jul 2023 18:55:49 +0100 Subject: [PATCH] P_StartPositionMusic Consistently sets position or encore hum for multiple contexts Now can be used in P_RestoreMusic for restoration purposes --- src/p_local.h | 1 + src/p_tick.c | 17 +---------------- src/p_user.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 16 deletions(-) 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_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; }