From 3dfce53bf87820d0b67441311bc7d70d9e4b6538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 1 Apr 2013 10:11:34 +0200 Subject: [PATCH] throw specific exception on missing sound definitions --- OpenRA.Game/Sound.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs index 9c4d9cad30..dc47dc0871 100644 --- a/OpenRA.Game/Sound.cs +++ b/OpenRA.Game/Sound.cs @@ -259,9 +259,7 @@ namespace OpenRA var ID = (voicedUnit != null) ? voicedUnit.ActorID : 0; - var clip = (voicedUnit != null) ? rules.VoicePools.Value[definition].GetNext() : rules.NotificationsPools.Value[definition].GetNext(); - if (clip == null) return false; - + string clip; var suffix = rules.DefaultVariant; var prefix = rules.DefaultPrefix; @@ -272,7 +270,21 @@ namespace OpenRA if (!rules.VoicePools.Value.ContainsKey("AttackMove")) rules.VoicePools.Value.Add("AttackMove", rules.VoicePools.Value["Move"]); + + if (!rules.VoicePools.Value.ContainsKey(definition)) + throw new InvalidOperationException("Can't find {0} in voice pool.".F(definition)); + + clip = rules.VoicePools.Value[definition].GetNext(); } + else + { + if (!rules.NotificationsPools.Value.ContainsKey(definition)) + throw new InvalidOperationException("Can't find {0} in notification pool.".F(definition)); + + clip = rules.NotificationsPools.Value[definition].GetNext(); + } + + if (String.IsNullOrEmpty(clip)) return false; if (variant != null) {