Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Fix for UMAPINFO music restarting issue. (#281)
Browse files Browse the repository at this point in the history
* Fix for UMAPINFO music restarting issue.

* Fix bugs with MUSINFO and UMAPINFO present simultaneously.

Fixes #279, fixes #102.
  • Loading branch information
JadingTsunami authored Apr 21, 2021
1 parent 7df77e2 commit 7349f8e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
20 changes: 16 additions & 4 deletions prboom2/src/s_advsound.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,27 @@ musinfo_t musinfo;
//
void S_ParseMusInfo(const char *mapid)
{
memset(&musinfo, 0, sizeof(musinfo));
musinfo.current_item = -1;

S_music[NUMMUSIC].lumpnum = -1;

if (W_CheckNumForName("MUSINFO") != -1)
{
int num, lumpnum;
int inMap = false;
int load_muslump = -1;
/* musinfo item zero is initialized
* before we reach the parser and it must be
* saved and restored */
int itemzero = musinfo.items[0];

/* don't restart music that is already playing */
if (mus_playing &&
mus_playing->lumpnum == S_music[NUMMUSIC].lumpnum) {
load_muslump = S_music[NUMMUSIC].lumpnum;
}

memset(&musinfo, 0, sizeof(musinfo));
musinfo.items[0] = itemzero;
musinfo.current_item = load_muslump;
S_music[NUMMUSIC].lumpnum = load_muslump;

SC_OpenLump("MUSINFO");

Expand Down
2 changes: 2 additions & 0 deletions prboom2/src/s_advsound.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define __S_ADVSOUND__

#include "p_mobj.h"
#include "sounds.h"

#ifdef __GNUG__
#pragma interface
Expand All @@ -55,6 +56,7 @@ typedef struct musinfo_s
int items[MAX_MUS_ENTRIES];
} musinfo_t;

extern musicinfo_t *mus_playing;
extern musinfo_t musinfo;

void S_ParseMusInfo(const char *mapid);
Expand Down
4 changes: 3 additions & 1 deletion prboom2/src/s_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int snd_MusicVolume = 15;
static dboolean mus_paused;

// music currently being played
static musicinfo_t *mus_playing;
musicinfo_t *mus_playing;

// music currently should play
static int musicnum_current;
Expand Down Expand Up @@ -207,6 +207,7 @@ void S_Start(void)
int muslump = W_CheckNumForName(gamemapinfo->music);
if (muslump >= 0)
{
musinfo.items[0] = muslump;
S_ChangeMusInfoMusic(muslump, true);
return;
}
Expand Down Expand Up @@ -533,6 +534,7 @@ void S_ChangeMusic(int musicnum, int looping)
// current music which should play
musicnum_current = musicnum;
musinfo.current_item = -1;
S_music[NUMMUSIC].lumpnum = -1;

//jff 1/22/98 return if music is not enabled
if (!mus_card || nomusicparm)
Expand Down

0 comments on commit 7349f8e

Please sign in to comment.