瀏覽代碼

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 9 年之前
父節點
當前提交
0451e85790
共有 1 個文件被更改,包括 7 次插入3 次删除
  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);
 	}