From 4fc58b4491cbcfe53c252315f665aa322aa64ea1 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 19 Mar 2015 00:06:37 +0100 Subject: [PATCH] Skip shroud/fog calculations when both are disabled via lobby option. --- OpenRA.Game/Traits/CreatesShroud.cs | 10 ++++++++-- OpenRA.Game/Traits/RevealsShroud.cs | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Traits/CreatesShroud.cs b/OpenRA.Game/Traits/CreatesShroud.cs index bc6ecdc043..6adcb682aa 100644 --- a/OpenRA.Game/Traits/CreatesShroud.cs +++ b/OpenRA.Game/Traits/CreatesShroud.cs @@ -15,22 +15,28 @@ namespace OpenRA.Traits public class CreatesShroudInfo : ITraitInfo { public readonly WRange Range = WRange.Zero; - public object Create(ActorInitializer init) { return new CreatesShroud(this); } + + public object Create(ActorInitializer init) { return new CreatesShroud(init.Self, this); } } public class CreatesShroud : ITick, ISync { readonly CreatesShroudInfo info; + readonly bool lobbyShroudFogDisabled; [Sync] CPos cachedLocation; [Sync] bool cachedDisabled; - public CreatesShroud(CreatesShroudInfo info) + public CreatesShroud(Actor self, CreatesShroudInfo info) { this.info = info; + lobbyShroudFogDisabled = !self.World.LobbyInfo.GlobalSettings.Shroud && !self.World.LobbyInfo.GlobalSettings.Fog; } public void Tick(Actor self) { + if (lobbyShroudFogDisabled) + return; + var disabled = self.TraitsImplementing().Any(d => d.Disabled); if (cachedLocation != self.Location || cachedDisabled != disabled) { diff --git a/OpenRA.Game/Traits/RevealsShroud.cs b/OpenRA.Game/Traits/RevealsShroud.cs index 8c9d0b7399..cea05d54f4 100644 --- a/OpenRA.Game/Traits/RevealsShroud.cs +++ b/OpenRA.Game/Traits/RevealsShroud.cs @@ -15,21 +15,27 @@ namespace OpenRA.Traits public class RevealsShroudInfo : ITraitInfo { public readonly WRange Range = WRange.Zero; - public object Create(ActorInitializer init) { return new RevealsShroud(this); } + + public object Create(ActorInitializer init) { return new RevealsShroud(init.Self, this); } } public class RevealsShroud : ITick, ISync { readonly RevealsShroudInfo info; + readonly bool lobbyShroudFogDisabled; [Sync] CPos cachedLocation; - public RevealsShroud(RevealsShroudInfo info) + public RevealsShroud(Actor self, RevealsShroudInfo info) { this.info = info; + lobbyShroudFogDisabled = !self.World.LobbyInfo.GlobalSettings.Shroud && !self.World.LobbyInfo.GlobalSettings.Fog; } public void Tick(Actor self) { + if (lobbyShroudFogDisabled) + return; + if (cachedLocation != self.Location) { cachedLocation = self.Location;