From 81c8f0360f1cb0905a60e29a05650abd7ee2e465 Mon Sep 17 00:00:00 2001 From: Scott_NZ Date: Tue, 26 Feb 2013 18:08:55 +1300 Subject: [PATCH] Let's not crash if WeaponInfo.Report[] is empty --- OpenRA.Mods.RA/CarpetBomb.cs | 5 +++-- OpenRA.Mods.RA/Combat.cs | 2 +- OpenRA.Mods.RA/Weapon.cs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.RA/CarpetBomb.cs b/OpenRA.Mods.RA/CarpetBomb.cs index 1e9473f972..a6162d66c7 100644 --- a/OpenRA.Mods.RA/CarpetBomb.cs +++ b/OpenRA.Mods.RA/CarpetBomb.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made @@ -8,6 +8,7 @@ */ #endregion +using System.Linq; using OpenRA.GameRules; using OpenRA.Traits; @@ -56,7 +57,7 @@ namespace OpenRA.Mods.RA self.World.Add(args.weapon.Projectile.Create(args)); - if (args.weapon.Report != null) + if (args.weapon.Report != null && args.weapon.Report.Any()) Sound.Play(args.weapon.Report.Random(self.World.SharedRandom) + ".aud", self.CenterLocation); } } diff --git a/OpenRA.Mods.RA/Combat.cs b/OpenRA.Mods.RA/Combat.cs index f880f01a12..37e9ea0263 100755 --- a/OpenRA.Mods.RA/Combat.cs +++ b/OpenRA.Mods.RA/Combat.cs @@ -153,7 +153,7 @@ namespace OpenRA.Mods.RA facing = 0 }; - if (args.weapon.Report != null) + if (args.weapon.Report != null && args.weapon.Report.Any()) Sound.Play(args.weapon.Report.Random(attacker.World.SharedRandom) + ".aud", pos); DoImpacts(args); diff --git a/OpenRA.Mods.RA/Weapon.cs b/OpenRA.Mods.RA/Weapon.cs index ecee503ad6..a22ae8c82f 100644 --- a/OpenRA.Mods.RA/Weapon.cs +++ b/OpenRA.Mods.RA/Weapon.cs @@ -148,7 +148,7 @@ namespace OpenRA.Mods.RA if (projectile != null) self.World.Add(projectile); - if (args.weapon.Report != null) + if (args.weapon.Report != null && args.weapon.Report.Any()) Sound.Play(args.weapon.Report.Random(self.World.SharedRandom) + ".aud", self.CenterLocation); } });