From fda39f713657a4aa47ebc30045828eaeeedfb63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 29 Aug 2015 08:04:37 +0200 Subject: [PATCH 1/6] add missing ISync --- OpenRA.Mods.Common/Traits/BodyOrientation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/BodyOrientation.cs b/OpenRA.Mods.Common/Traits/BodyOrientation.cs index 39c47652a3..86c1339a35 100644 --- a/OpenRA.Mods.Common/Traits/BodyOrientation.cs +++ b/OpenRA.Mods.Common/Traits/BodyOrientation.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits public object Create(ActorInitializer init) { return new BodyOrientation(init, this); } } - public class BodyOrientation : IBodyOrientation + public class BodyOrientation : IBodyOrientation, ISync { readonly BodyOrientationInfo info; readonly Lazy quantizedFacings; From 45f75269675b848e3022742f005eb79ed9442fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 29 Aug 2015 08:05:00 +0200 Subject: [PATCH 2/6] fix dereference after null check --- OpenRA.Mods.Common/Traits/BodyOrientation.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/BodyOrientation.cs b/OpenRA.Mods.Common/Traits/BodyOrientation.cs index 86c1339a35..c15462f434 100644 --- a/OpenRA.Mods.Common/Traits/BodyOrientation.cs +++ b/OpenRA.Mods.Common/Traits/BodyOrientation.cs @@ -76,9 +76,14 @@ namespace OpenRA.Mods.Common.Traits var isb = self.HasTrait(); // If a sprite actor has neither custom QuantizedFacings nor a trait implementing IQuantizeBodyOrientationInfo, throw - if (qboi == null && isb) - throw new InvalidOperationException("Actor" + self.Info.Name + "has a sprite body but no facing quantization." - + " Either add the QuantizeFacingsFromSequence trait or set custom QuantizedFacings on BodyOrientation."); + if (qboi == null) + { + if (isb) + throw new InvalidOperationException("Actor" + self.Info.Name + "has a sprite body but no facing quantization." + + " Either add the QuantizeFacingsFromSequence trait or set custom QuantizedFacings on BodyOrientation."); + else + throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a quantized body orientation."); + } return qboi.QuantizedBodyFacings(self.Info, self.World.Map.SequenceProvider, faction); }); From da0c80dc3d4630915addf41f7176a2d7c9cf4beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 29 Aug 2015 08:15:17 +0200 Subject: [PATCH 3/6] fix bridges not defining body orientation --- mods/cnc/rules/defaults.yaml | 1 + mods/ra/rules/defaults.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 46d7572e6d..6369541f62 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -691,6 +691,7 @@ DamagedSounds: xplos.aud DestroyedSounds: xplobig4.aud BodyOrientation: + QuantizedFacings: 1 ScriptTriggers: ^Crate: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 14921451c6..59c584a3aa 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -636,6 +636,7 @@ Type: Concrete AutoTargetIgnore: BodyOrientation: + QuantizedFacings: 1 ScriptTriggers: ^Rock: From 1dfb982d6f2311a7f9900ff93dc9b7fe031e57ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 29 Aug 2015 18:49:51 +0200 Subject: [PATCH 4/6] fix paradrop camera not defining a body orientation --- mods/ra/rules/misc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ra/rules/misc.yaml b/mods/ra/rules/misc.yaml index e0acacb67d..9e329f55ef 100644 --- a/mods/ra/rules/misc.yaml +++ b/mods/ra/rules/misc.yaml @@ -200,6 +200,7 @@ camera.paradrop: ProximityCaptor: Types: Camera BodyOrientation: + QuantizedFacings: 1 SONAR: AlwaysVisible: From 25a0143b46973a855880b8b82dd4a6a8f6802606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 29 Aug 2015 18:58:30 +0200 Subject: [PATCH 5/6] avoid unnecessary trait lookups --- OpenRA.Mods.Common/Traits/BodyOrientation.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/BodyOrientation.cs b/OpenRA.Mods.Common/Traits/BodyOrientation.cs index c15462f434..92c407f394 100644 --- a/OpenRA.Mods.Common/Traits/BodyOrientation.cs +++ b/OpenRA.Mods.Common/Traits/BodyOrientation.cs @@ -73,12 +73,11 @@ namespace OpenRA.Mods.Common.Traits return info.QuantizedFacings; var qboi = self.Info.Traits.GetOrDefault(); - var isb = self.HasTrait(); // If a sprite actor has neither custom QuantizedFacings nor a trait implementing IQuantizeBodyOrientationInfo, throw if (qboi == null) { - if (isb) + if (self.HasTrait()) throw new InvalidOperationException("Actor" + self.Info.Name + "has a sprite body but no facing quantization." + " Either add the QuantizeFacingsFromSequence trait or set custom QuantizedFacings on BodyOrientation."); else From 539e25920c0ec8925d694004cc272ee4cba642fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 29 Aug 2015 21:24:58 +0200 Subject: [PATCH 6/6] add missing spaces --- OpenRA.Mods.Common/Traits/BodyOrientation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/BodyOrientation.cs b/OpenRA.Mods.Common/Traits/BodyOrientation.cs index 92c407f394..b10fdc89a0 100644 --- a/OpenRA.Mods.Common/Traits/BodyOrientation.cs +++ b/OpenRA.Mods.Common/Traits/BodyOrientation.cs @@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits if (qboi == null) { if (self.HasTrait()) - throw new InvalidOperationException("Actor" + self.Info.Name + "has a sprite body but no facing quantization." + throw new InvalidOperationException("Actor '" + self.Info.Name + "' has a sprite body but no facing quantization." + " Either add the QuantizeFacingsFromSequence trait or set custom QuantizedFacings on BodyOrientation."); else throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a quantized body orientation.");