Browse Source

Added some flexibility on EmitRoundEndMusic

The song being referenced might not be the first song in the active
queue (or even in the active queue at all), so we shouldn't be removing
the head track blindly.
nosoop 8 years ago
parent
commit
0451e85790
1 changed files with 7 additions and 3 deletions
  1. 7 3
      scripting/round_end_music.sp

+ 7 - 3
scripting/round_end_music.sp

@@ -12,7 +12,7 @@
 #pragma newdecls required
 #include <round_end_music>
 
-#define PLUGIN_VERSION "0.4.1"
+#define PLUGIN_VERSION "0.4.2"
 public Plugin myinfo = {
     name = "[CSRD] Round End Music",
     author = "nosoop",
@@ -21,6 +21,7 @@ public Plugin myinfo = {
     url = "https://pika.nom-nom-nom.us/"
 }
 
+// Note:  All lists share the same handle reference, they aren't cloned.
 bool g_bQueueLocked = false;
 ArrayList g_QueuedSongs, g_ActiveSongs, g_PlayedSongs;
 
@@ -231,8 +232,11 @@ void EmitRoundEndMusic(MusicEntry song) {
 		if (g_PlayedSongs.FindValue(song) == -1) {
 			g_PlayedSongs.Push(song);
 		}
-
-		g_ActiveSongs.Erase(0);
+		
+		int pos;
+		if ( (pos = g_ActiveSongs.FindValue(song)) != -1 ) {
+			g_ActiveSongs.Erase(pos);
+		}
 		
 		FireOnREMPlayedPostEvent(song);
 	}