From 9270a85619c9877940bac833964bfc3e755829a0 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 30 Mar 2010 22:08:37 +1300 Subject: [PATCH] fix units disappearing if their topleftmost cell was not in the map (proc at top edge, etc) --- OpenRA.Game/Traits/World/SpatialBins.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Traits/World/SpatialBins.cs b/OpenRA.Game/Traits/World/SpatialBins.cs index a3aa30d5ff..432cac2957 100644 --- a/OpenRA.Game/Traits/World/SpatialBins.cs +++ b/OpenRA.Game/Traits/World/SpatialBins.cs @@ -34,10 +34,13 @@ namespace OpenRA.Traits foreach (var a in self.World.Actors) { - if (!self.World.Map.IsInMap(a.Location)) - continue; - var bounds = a.GetBounds(true); + + if (bounds.Right <= Game.CellSize * self.World.Map.XOffset) continue; + if (bounds.Bottom <= Game.CellSize * self.World.Map.YOffset) continue; + if (bounds.Left >= Game.CellSize * (self.World.Map.XOffset + self.World.Map.Width)) continue; + if (bounds.Top >= Game.CellSize * (self.World.Map.YOffset + self.World.Map.Height)) continue; + var i1 = Math.Max(0, (int)bounds.Left / scale); var i2 = Math.Min(bins.GetUpperBound(0), (int)bounds.Right / scale); var j1 = Math.Max(0, (int)bounds.Top / scale);