From 0b4543919de70b53ccd0cfc86ddc14d0e16708e4 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 3 Aug 2015 20:34:22 +0100 Subject: [PATCH] Account for disabled shroud/fog in ShroudRenderer. Fixes #8827. --- OpenRA.Game/Traits/World/Shroud.cs | 4 ++-- OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index de47db980d..d9517f08ec 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -282,7 +282,7 @@ namespace OpenRA.Traits return explored.Contains(uv) && explored[uv] && (generatedShroudCount[uv] == 0 || visibleCount[uv] > 0); } - bool ShroudEnabled { get { return !Disabled && self.World.LobbyInfo.GlobalSettings.Shroud; } } + public bool ShroudEnabled { get { return !Disabled && self.World.LobbyInfo.GlobalSettings.Shroud; } } /// /// Returns a fast exploration lookup that skips the usual validation. @@ -329,7 +329,7 @@ namespace OpenRA.Traits return visibleCount.Contains(uv) && visibleCount[uv] > 0; } - bool FogEnabled { get { return !Disabled && self.World.LobbyInfo.GlobalSettings.Fog; } } + public bool FogEnabled { get { return !Disabled && self.World.LobbyInfo.GlobalSettings.Fog; } } /// /// Returns a fast visibility lookup that skips the usual validation. diff --git a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs index e948a68034..c5169ebe7b 100644 --- a/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs +++ b/OpenRA.Mods.Common/Traits/World/ShroudRenderer.cs @@ -237,18 +237,18 @@ namespace OpenRA.Mods.Common.Traits currentShroud.CellsChanged -= DirtyCells; if (shroud != null) - { shroud.CellsChanged += DirtyCells; - // Needs the anonymous function to ensure the correct overload is chosen - visibleUnderShroud = uv => currentShroud.IsExplored(uv); - visibleUnderFog = uv => currentShroud.IsVisible(uv); - } + // Needs the anonymous function to ensure the correct overload is chosen + if (shroud != null && shroud.ShroudEnabled) + visibleUnderShroud = puv => currentShroud.IsExplored(puv); else - { visibleUnderShroud = puv => map.Contains(puv); + + if (shroud != null && shroud.FogEnabled) + visibleUnderFog = puv => currentShroud.IsVisible(puv); + else visibleUnderFog = puv => map.Contains(puv); - } currentShroud = shroud; DirtyCells(map.ProjectedCellBounds);