소스 검색

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);
 	}