From 54a80ed035a96d701935c2184e67fb71c097053e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 28 Jul 2015 22:55:16 +0100 Subject: [PATCH] Include additional preview to prevent cutoff. Fun fact: The original TS sidestepped this issue by rendering everything outside the cordon, which looks much worse than what we do here. --- OpenRA.Game/Graphics/Minimap.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Graphics/Minimap.cs b/OpenRA.Game/Graphics/Minimap.cs index 62650b51aa..54a49749c0 100644 --- a/OpenRA.Game/Graphics/Minimap.cs +++ b/OpenRA.Game/Graphics/Minimap.cs @@ -22,8 +22,12 @@ namespace OpenRA.Graphics { var isDiamond = map.TileShape == TileShape.Diamond; var b = map.Bounds; + + // Fudge the heightmap offset by adding as much extra as we need / can. + // This tries to correct for our incorrect assumption that MPos == PPos + var heightOffset = Math.Min(map.MaximumTerrainHeight, map.MapSize.Y - b.Bottom); var width = b.Width; - var height = b.Height; + var height = b.Height + heightOffset; var bitmapWidth = width; if (isDiamond) @@ -59,7 +63,8 @@ namespace OpenRA.Graphics if (x + dx > 0) colors[y * stride + 2 * x + dx - 1] = leftColor.ToArgb(); - colors[y * stride + 2 * x + dx] = rightColor.ToArgb(); + if (2 * x + dx < stride) + colors[y * stride + 2 * x + dx] = rightColor.ToArgb(); } else colors[y * stride + x] = leftColor.ToArgb(); @@ -78,8 +83,12 @@ namespace OpenRA.Graphics var terrain = new Bitmap(terrainBitmap); var isDiamond = map.TileShape == TileShape.Diamond; var b = map.Bounds; + + // Fudge the heightmap offset by adding as much extra as we need / can + // This tries to correct for our incorrect assumption that MPos == PPos + var heightOffset = Math.Min(map.MaximumTerrainHeight, map.MapSize.Y - b.Bottom); var width = b.Width; - var height = b.Height; + var height = b.Height + heightOffset; var resources = resourceRules.Actors["world"].Traits.WithInterface() .ToDictionary(r => r.ResourceType, r => r.TerrainType); @@ -111,7 +120,8 @@ namespace OpenRA.Graphics if (x + dx > 0) colors[y * stride + 2 * x + dx - 1] = color; - colors[y * stride + 2 * x + dx] = color; + if (2 * x + dx < stride) + colors[y * stride + 2 * x + dx] = color; } else colors[y * stride + x] = color;