P_StartPositionMusic

Consistently sets position or encore hum for multiple contexts
Now can be used in P_RestoreMusic for restoration purposes
This commit is contained in:
toaster 2023-07-22 18:55:49 +01:00
parent 7c952e3509
commit 2fd7c7717c
3 changed files with 34 additions and 16 deletions

View file

@ -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);

View file

@ -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
}
}

View file

@ -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;
}