mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-25 22:01:01 +00:00
Only restart current music if its lump ID changed
This commit is contained in:
parent
2876a02466
commit
c6477ee32f
3 changed files with 25 additions and 4 deletions
|
@ -1353,6 +1353,7 @@ void S_InitSfxChannels(INT32 sfxVolume)
|
|||
/// ------------------------
|
||||
|
||||
static char music_name[7]; // up to 6-character name
|
||||
static lumpnum_t music_lump;
|
||||
static void *music_data;
|
||||
static UINT16 music_flags;
|
||||
static boolean music_looping;
|
||||
|
@ -1985,6 +1986,17 @@ static musicstack_t *S_GetMusicStackEntry(UINT16 status, boolean fromfirst, INT1
|
|||
return NULL;
|
||||
}
|
||||
|
||||
boolean S_CheckDeletedMusic(void)
|
||||
{
|
||||
if (music_lump != S_GetMusicLumpNum(music_name))
|
||||
{
|
||||
S_StopMusic();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void S_RetainMusic(const char *mname, UINT16 mflags, boolean looping, UINT32 position, UINT16 status)
|
||||
{
|
||||
musicstack_t *mst;
|
||||
|
@ -2150,12 +2162,12 @@ static boolean S_LoadMusic(const char *mname)
|
|||
// load & register it
|
||||
mdata = W_CacheLumpNum(mlumpnum, PU_MUSIC);
|
||||
|
||||
|
||||
if (I_LoadSong(mdata, W_LumpLength(mlumpnum)))
|
||||
{
|
||||
strncpy(music_name, mname, 7);
|
||||
music_name[6] = 0;
|
||||
music_data = mdata;
|
||||
music_lump = mlumpnum;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -2325,6 +2337,8 @@ void S_StopMusic(void)
|
|||
I_StopSong();
|
||||
S_UnloadMusic(); // for now, stopping also means you unload the song
|
||||
|
||||
music_lump = LUMPERROR;
|
||||
|
||||
if (cv_closedcaptioning.value)
|
||||
{
|
||||
if (closedcaptions[0].s-S_sfx == sfx_None)
|
||||
|
|
|
@ -127,6 +127,8 @@ void S_StopSounds(void);
|
|||
void S_ClearSfx(void);
|
||||
void S_PlayMapMusic(boolean reset);
|
||||
|
||||
boolean S_CheckDeletedMusic(void);
|
||||
|
||||
//
|
||||
// Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum.
|
||||
//
|
||||
|
|
11
src/w_wad.c
11
src/w_wad.c
|
@ -1259,6 +1259,9 @@ void W_UnloadWadFile(UINT16 num)
|
|||
|
||||
W_ClearCachedData();
|
||||
|
||||
if (is_important)
|
||||
S_StopMusic();
|
||||
|
||||
W_UnloadFile(wadfiles[num]);
|
||||
|
||||
wadfiles[num] = NULL;
|
||||
|
@ -1272,10 +1275,13 @@ void W_UnloadWadFile(UINT16 num)
|
|||
HU_LoadGraphics();
|
||||
ST_LoadGraphics();
|
||||
ST_ReloadSkinFaceGraphics();
|
||||
S_PlayMapMusic(true);
|
||||
if (S_CheckDeletedMusic())
|
||||
S_PlayMapMusic(true);
|
||||
return;
|
||||
}
|
||||
|
||||
S_CheckDeletedMusic();
|
||||
|
||||
D_ReloadFiles();
|
||||
|
||||
G_LoadGameData(clientGamedata);
|
||||
|
@ -1286,10 +1292,9 @@ void W_UnloadWadFile(UINT16 num)
|
|||
|
||||
void W_ClearCachedData(void)
|
||||
{
|
||||
// Stop all sounds, stop current music
|
||||
// Stop all sounds
|
||||
S_StopSounds();
|
||||
S_ClearSfx();
|
||||
S_StopMusic();
|
||||
|
||||
// Unload HUD graphics
|
||||
ST_UnloadGraphics();
|
||||
|
|
Loading…
Reference in a new issue