diff --git a/OpenRA.Game/Traits/World/BibLayer.cs b/OpenRA.Game/Traits/World/BibLayer.cs index 3b5513af01..4feb47cfe4 100644 --- a/OpenRA.Game/Traits/World/BibLayer.cs +++ b/OpenRA.Game/Traits/World/BibLayer.cs @@ -12,7 +12,8 @@ using System; using System.Drawing; using System.Linq; using OpenRA.FileFormats; -using OpenRA.Graphics; +using OpenRA.Graphics; +using System.Collections.Generic; namespace OpenRA.Traits { @@ -26,9 +27,8 @@ namespace OpenRA.Traits class BibLayer: IRenderOverlay, IWorldLoaded { World world; - BibLayerInfo info; - - TileReference[,] tiles; + BibLayerInfo info; + Dictionary> tiles; Sprite[][] bibSprites; public BibLayer(Actor self, BibLayerInfo info) @@ -44,8 +44,8 @@ namespace OpenRA.Traits public void WorldLoaded(World w) { - world = w; - tiles = new TileReference[w.Map.MapSize.X,w.Map.MapSize.Y]; + world = w; + tiles = new Dictionary>(); } public void DoBib(Actor b, bool isAdd) @@ -67,7 +67,7 @@ namespace OpenRA.Traits byte type = (byte)((isAdd) ? bib+1 : 0); byte index = (byte)i; - tiles[p.X,p.Y] = new TileReference(type,index); + tiles[p] = new TileReference(type,index); } } @@ -75,22 +75,17 @@ namespace OpenRA.Traits { var cliprect = Game.viewport.ShroudBounds().HasValue ? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds; - - var minx = cliprect.Left; - var maxx = cliprect.Right; - - var miny = cliprect.Top; - var maxy = cliprect.Bottom; - - for (int x = minx; x < maxx; x++) - for (int y = miny; y < maxy; y++) - { - var t = new int2(x, y); - if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(t) || tiles[x,y].type == 0) continue; - - Game.Renderer.SpriteRenderer.DrawSprite(bibSprites[tiles[x, y].type - 1][tiles[x, y].image], - Game.CellSize * t, "terrain"); - } + + foreach (var kv in tiles) + { + if (!cliprect.Contains(kv.Key.X, kv.Key.Y)) + continue; + if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(kv.Key)) + continue; + + Game.Renderer.SpriteRenderer.DrawSprite(bibSprites[kv.Value.type - 1][kv.Value.image], + Game.CellSize * kv.Key, "terrain"); + } } } diff --git a/OpenRA.Game/Traits/World/SmudgeLayer.cs b/OpenRA.Game/Traits/World/SmudgeLayer.cs index 00631a8e96..96a54e48a4 100644 --- a/OpenRA.Game/Traits/World/SmudgeLayer.cs +++ b/OpenRA.Game/Traits/World/SmudgeLayer.cs @@ -64,9 +64,12 @@ namespace OpenRA.Traits var tile = tiles[loc]; // Existing smudge; make it deeper - int depth = Info.Depths[tile.type-1]; - if (tile.image < depth - 1) - tile.image++; + int depth = Info.Depths[tile.type-1]; + if (tile.image < depth - 1) + { + tile.image++; + tiles[loc] = tile; // struct semantics. + } } public void Render() @@ -81,7 +84,7 @@ namespace OpenRA.Traits if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(kv.Key)) continue; - Game.Renderer.SpriteRenderer.DrawSprite(smudgeSprites[tiles[kv.Key].type- 1][tiles[kv.Key].image], + Game.Renderer.SpriteRenderer.DrawSprite(smudgeSprites[kv.Value.type- 1][kv.Value.image], Game.CellSize * kv.Key, "terrain"); } }