From 6738b8b977a92ff9c5737a021ea901131a23df21 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 15 Jun 2015 18:00:50 +0100 Subject: [PATCH] Undo an invalid optimisation. Fixes a regression from #7746. --- OpenRA.Game/Traits/Player/FrozenActorLayer.cs | 5 +++-- OpenRA.Game/Traits/World/Shroud.cs | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs index 30c7cb3378..b1330efcae 100644 --- a/OpenRA.Game/Traits/Player/FrozenActorLayer.cs +++ b/OpenRA.Game/Traits/Player/FrozenActorLayer.cs @@ -28,7 +28,7 @@ namespace OpenRA.Traits public readonly WPos CenterPosition; public readonly Rectangle Bounds; readonly Actor actor; - readonly Func isVisibleTest; + readonly Shroud shroud; public Player Owner; @@ -45,7 +45,7 @@ namespace OpenRA.Traits public FrozenActor(Actor self, MPos[] footprint, Shroud shroud) { actor = self; - isVisibleTest = shroud.IsVisibleTest; + this.shroud = shroud; // Consider all cells inside the map area (ignoring the current map bounds) Footprint = footprint @@ -79,6 +79,7 @@ namespace OpenRA.Traits void UpdateVisibility() { var wasVisible = Visible; + var isVisibleTest = shroud.IsVisibleTest; // We are doing the following LINQ manually for performance since this is a hot path. // Visible = !Footprint.Any(isVisibleTest); diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 25e04cb5fb..cde61a26aa 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -325,6 +325,11 @@ namespace OpenRA.Traits return explored[uv] && (generatedShroudCount[uv] == 0 || visibleCount[uv] > 0); } + /// + /// Returns a fast exploration lookup that skips the usual validation. + /// The return value should not be cached across ticks, and should not + /// be called with cells outside the map bounds. + /// public Func IsExploredTest { get @@ -371,6 +376,11 @@ namespace OpenRA.Traits return visibleCount[uv] > 0; } + /// + /// Returns a fast visibility lookup that skips the usual validation. + /// The return value should not be cached across ticks, and should not + /// be called with cells outside the map bounds. + /// public Func IsVisibleTest { get