mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +00:00
S_TickSoundTest: Clean up significantly.
- Introduce comments to make flow understandable.
- Abstract the number of seconds in the fade out (previously handled across multiple places) into SOUNDTEST_FADEOUTSECONDS.
- Make all next/conclude song cases for autosequence and non-looping track handled in one place.
- Fixes the case where a non-looping track could stop the Sound Test even in autosequence mode.
This commit is contained in:
parent
c5bb660372
commit
1bdbfdf22b
3 changed files with 48 additions and 37 deletions
|
|
@ -6046,7 +6046,7 @@ void M_DrawSoundTest(void)
|
||||||
UINT32 exittime = soundtest.sequencemaxtime;
|
UINT32 exittime = soundtest.sequencemaxtime;
|
||||||
if (soundtest.dosequencefadeout == true)
|
if (soundtest.dosequencefadeout == true)
|
||||||
{
|
{
|
||||||
exittime += 3*TICRATE;
|
exittime += SOUNDTEST_FADEOUTSECONDS*TICRATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
V_DrawRightAlignedString(x + 272-1, 18+32+10, 0,
|
V_DrawRightAlignedString(x + 272-1, 18+32+10, 0,
|
||||||
|
|
|
||||||
|
|
@ -1694,66 +1694,75 @@ void S_TickSoundTest(void)
|
||||||
{
|
{
|
||||||
static UINT32 storetime = 0;
|
static UINT32 storetime = 0;
|
||||||
UINT32 lasttime = storetime;
|
UINT32 lasttime = storetime;
|
||||||
boolean donext = false;
|
|
||||||
|
|
||||||
storetime = I_GetTime();
|
storetime = I_GetTime();
|
||||||
|
|
||||||
if (soundtest.playing == false || soundtest.current == NULL)
|
if (soundtest.playing == false || soundtest.current == NULL)
|
||||||
{
|
{
|
||||||
|
// Nothing worth discussing.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (I_SongPlaying() == false)
|
if (I_SongPlaying() == false)
|
||||||
{
|
{
|
||||||
S_SoundTestStop();
|
// We stopped for some reason. Accomodate this.
|
||||||
return;
|
goto handlenextsong;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (I_SongPaused() == false)
|
if (I_SongPaused() == false)
|
||||||
{
|
{
|
||||||
|
// Increment the funny little timer.
|
||||||
soundtest.currenttime += (storetime - lasttime);
|
soundtest.currenttime += (storetime - lasttime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (soundtest.sequencefadeout > 0)
|
if (soundtest.sequencefadeout != 0)
|
||||||
{
|
{
|
||||||
if (soundtest.currenttime >= soundtest.sequencefadeout)
|
// Are we done fading out?
|
||||||
|
if (soundtest.currenttime > soundtest.sequencefadeout)
|
||||||
{
|
{
|
||||||
donext = true;
|
goto handlenextsong;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (soundtest.currenttime >= soundtest.sequencemaxtime)
|
|
||||||
{
|
|
||||||
if (soundtest.autosequence == false)
|
|
||||||
{
|
|
||||||
if (soundtest.current->basenoloop[soundtest.currenttrack] == true)
|
|
||||||
{
|
|
||||||
S_SoundTestStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (soundtest.dosequencefadeout == false)
|
|
||||||
{
|
|
||||||
donext = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (soundtest.sequencemaxtime > 0)
|
|
||||||
{
|
|
||||||
soundtest.privilegedrequest = true;
|
|
||||||
S_FadeMusic(0, 3000);
|
|
||||||
soundtest.privilegedrequest = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
soundtest.sequencefadeout = soundtest.currenttime + 3*TICRATE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (donext == false)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (soundtest.autosequence == false)
|
||||||
|
{
|
||||||
|
// There's nothing else for us here.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soundtest.currenttime >= soundtest.sequencemaxtime)
|
||||||
|
{
|
||||||
|
if (soundtest.dosequencefadeout == false)
|
||||||
|
{
|
||||||
|
// Handle the immediate progression.
|
||||||
|
goto handlenextsong;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soundtest.sequencemaxtime > 0)
|
||||||
|
{
|
||||||
|
// Handle the fade.
|
||||||
|
soundtest.privilegedrequest = true;
|
||||||
|
S_FadeMusic(0, SOUNDTEST_FADEOUTSECONDS*1000);
|
||||||
|
soundtest.privilegedrequest = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the conclusion.
|
||||||
|
soundtest.sequencefadeout = soundtest.currenttime + SOUNDTEST_FADEOUTSECONDS*TICRATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
handlenextsong:
|
||||||
|
// If the song's stopped while not in autosequence, stop visibly playing.
|
||||||
|
if (soundtest.autosequence == false)
|
||||||
|
{
|
||||||
|
S_SoundTestStop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Okay, this is autosequence in action.
|
||||||
S_UpdateSoundTestDef(false, true, true);
|
S_UpdateSoundTestDef(false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,8 @@ extern struct cursongcredit
|
||||||
fixed_t old_x;
|
fixed_t old_x;
|
||||||
} cursongcredit;
|
} cursongcredit;
|
||||||
|
|
||||||
|
#define SOUNDTEST_FADEOUTSECONDS 3
|
||||||
|
|
||||||
extern struct soundtest
|
extern struct soundtest
|
||||||
{
|
{
|
||||||
boolean playing; // Music is playing?
|
boolean playing; // Music is playing?
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue