Просмотр исходного кода

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