From 71c17d7e89fd8c31008385df1dbfc69749b54493 Mon Sep 17 00:00:00 2001 From: sezero Date: Mon, 4 Aug 2014 21:20:09 +0000 Subject: [PATCH] cd_sdl: prev and next commands must handle data tracks properly. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@951 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/cd_sdl.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/quakespasm/Quake/cd_sdl.c b/quakespasm/Quake/cd_sdl.c index 6a7fba3d..672ce366 100644 --- a/quakespasm/Quake/cd_sdl.c +++ b/quakespasm/Quake/cd_sdl.c @@ -219,6 +219,15 @@ void CDAudio_Resume(void) pausetime = -1.0; } +static int get_first_audiotrk (void) +{ + int i; + for (i = 0; i < cd_handle->numtracks; ++i) + if (cd_handle->track[i].type != SDL_DATA_TRACK) + return ++i; + return 1; +} + static void CD_f (void) { const char *command; @@ -356,15 +365,15 @@ static void CD_f (void) if (q_strcasecmp(command, "next") == 0) { - if (playTrack == cd_handle->numtracks) - playTrack = 0; + if (playTrack == cd_handle->numtracks) + playTrack = get_first_audiotrk() - 1; CDAudio_Play(playTrack + 1, playLooping); return; } if (q_strcasecmp(command, "prev") == 0) { - if (playTrack == 1) + if (playTrack == get_first_audiotrk()) playTrack = cd_handle->numtracks + 1; CDAudio_Play(playTrack - 1, playLooping); return;