Merge branch 'loop-patch' into 'next'

Let MUSICDEF set loop point

See merge request STJr/SRB2!762
This commit is contained in:
James R 2020-04-09 19:47:43 -04:00
commit e100f21dda
2 changed files with 17 additions and 0 deletions

View file

@ -1456,6 +1456,7 @@ musicdef_t soundtestsfx = {
0, // with no conditions 0, // with no conditions
0, 0,
0, 0,
0,
false, false,
NULL NULL
}; };
@ -1651,6 +1652,8 @@ ReadMusicDefFields (UINT16 wadnum, int line, boolean fields, char *stoken,
fixed_t bpmf = FLOAT_TO_FIXED(bpm); fixed_t bpmf = FLOAT_TO_FIXED(bpm);
if (bpmf > 0) if (bpmf > 0)
def->bpm = FixedDiv((60*TICRATE)<<FRACBITS, bpmf); def->bpm = FixedDiv((60*TICRATE)<<FRACBITS, bpmf);
} else if (!stricmp(stoken, "loopms")) {
def->loop_ms = atoi(textline);
} else { } else {
CONS_Alert(CONS_WARNING, CONS_Alert(CONS_WARNING,
"MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n",
@ -2262,6 +2265,8 @@ static void S_UnloadMusic(void)
static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
{ {
musicdef_t *def;
if (S_MusicDisabled()) if (S_MusicDisabled())
return false; return false;
@ -2273,6 +2278,17 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
return false; return false;
} }
/* set loop point from MUSICDEF */
for (def = musicdefstart; def; def = def->next)
{
if (strcasecmp(def->name, music_name) == 0)
{
if (def->loop_ms)
S_SetMusicLoopPoint(def->loop_ms);
break;
}
}
S_InitMusicVolume(); // switch between digi and sequence volume S_InitMusicVolume(); // switch between digi and sequence volume
if (S_MusicNotInFocus()) if (S_MusicNotInFocus())

View file

@ -208,6 +208,7 @@ typedef struct musicdef_s
INT16 soundtestcond; // +ve for map, -ve for conditionset, 0 for already here INT16 soundtestcond; // +ve for map, -ve for conditionset, 0 for already here
tic_t stoppingtics; tic_t stoppingtics;
fixed_t bpm; fixed_t bpm;
UINT32 loop_ms;/* override LOOPPOINT/LOOPMS */
boolean allowed; // question marks or listenable on sound test? boolean allowed; // question marks or listenable on sound test?
struct musicdef_s *next; struct musicdef_s *next;
} musicdef_t; } musicdef_t;