From f0ea329b2c227254f2d6cbed0bcf441eb9a4f438 Mon Sep 17 00:00:00 2001 From: alzeih Date: Sun, 13 Jun 2010 19:37:31 +1200 Subject: [PATCH] Fix crash if no music --- .../Widgets/Delegates/MusicPlayerDelegate.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs b/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs index a4d2db5459..b8572a9bb2 100644 --- a/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs @@ -64,8 +64,20 @@ namespace OpenRA.Widgets.Delegates }; } - string GetNextSong() { return Rules.Music["allmusic"].Pool.GetNext(); } - string GetPrevSong() { return Rules.Music["allmusic"].Pool.GetPrev(); } - string GetSong() { return Rules.Music["allmusic"].Pool.GetCurrent(); } + string GetNextSong() + { + if (!Rules.Music.ContainsKey("allmusic")) return null; + return Rules.Music["allmusic"].Pool.GetNext(); + } + string GetPrevSong() + { + if (!Rules.Music.ContainsKey("allmusic")) return null; + return Rules.Music["allmusic"].Pool.GetPrev(); + } + string GetSong() + { + if (!Rules.Music.ContainsKey("allmusic")) return null; + return Rules.Music["allmusic"].Pool.GetCurrent(); + } } }