]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Stop playback when removing the unique track of the playlist
authorterencehill <piuntn@gmail.com>
Mon, 5 Aug 2013 12:35:11 +0000 (14:35 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 5 Aug 2013 12:35:11 +0000 (14:35 +0200)
qcsrc/menu/xonotic/playlist.c

index 0127181d9cc427ccd1ca19c5e29d03413388f43b..c8fce97c01061a908fc56b1723f6ffc591935867 100644 (file)
@@ -105,22 +105,27 @@ void XonoticPlayList_removeSelectedFromPlayList(entity me)
                        {
                                if(cvar("music_playlist_current0") == i)
                                        cpt = TRUE; // current playing track (we can't start next track here because startSound calls tokenize_console)
-                               else
-                               {
-                                       if(cvar("music_playlist_current0") > i)
-                                               cvar_set("music_playlist_current0", ftos(cvar("music_playlist_current0") - 1));
-                               }
+                               else if(cvar("music_playlist_current0") > i)
+                                       cvar_set("music_playlist_current0", ftos(cvar("music_playlist_current0") - 1));
                        }
                        continue;
                }
                s = strcat(s, " ", argv(i));
        }
+       // we must stop the current playing track if it has been removed
+       // otherwise pause/play button will resume from another track
        if(s == "")
+       {
                cvar_set("music_playlist_list0", "");
+               if(cpt)
+                       me.stopSound(me);
+       }
        else
-               cvar_set("music_playlist_list0", substring(s, 1, strlen(s))); //remove initial space
-       if(cpt)
-               me.startSound(me, 0); // stop current playing track otherwise pause/play button will resume from another track
+       {
+               cvar_set("music_playlist_list0", substring(s, 1, strlen(s))); // remove initial space
+               if(cpt)
+                       me.startSound(me, 0);
+       }
 }
 
 void PlayList_Remove(entity btn, entity me)