From 672bd2d9fecf4b1c362259fe8a46a6d170a5927d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 18 May 2020 22:57:43 +0200 Subject: [PATCH] Don't crash when putting the trait on the World actor. --- OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs b/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs index 0f1574939f..a3ceafa840 100644 --- a/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs +++ b/OpenRA.Mods.Common/Traits/Sound/AmbientSound.cs @@ -52,13 +52,16 @@ namespace OpenRA.Mods.Common.Traits.Sound currentSounds.RemoveWhere(s => s == null || s.Complete); - var pos = self.CenterPosition; - if (pos != cachedPosition) + if (self.OccupiesSpace != null) { - foreach (var s in currentSounds) - s.SetPosition(pos); + var pos = self.CenterPosition; + if (pos != cachedPosition) + { + foreach (var s in currentSounds) + s.SetPosition(pos); - cachedPosition = pos; + cachedPosition = pos; + } } if (delay < 0)