Remove lazy loading of binary map data.

This commit is contained in:
Paul Chote
2016-03-12 21:23:32 +00:00
parent 51bfe4accc
commit 65df25b1a4
22 changed files with 141 additions and 183 deletions

View File

@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Widgets
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
{
// Check the actor is inside the map
if (!footprint.All(c => world.Map.MapTiles.Value.Contains(cell + locationOffset + c)))
if (!footprint.All(c => world.Map.Tiles.Contains(cell + locationOffset + c)))
return true;
var newActorReference = new ActorReference(Actor.Name);

View File

@@ -94,9 +94,9 @@ namespace OpenRA.Mods.Common.Widgets
void Copy(CellRegion source, CVec offset)
{
var gridType = worldRenderer.World.Map.Grid.Type;
var mapTiles = worldRenderer.World.Map.MapTiles.Value;
var mapHeight = worldRenderer.World.Map.MapHeight.Value;
var mapResources = worldRenderer.World.Map.MapResources.Value;
var mapTiles = worldRenderer.World.Map.Tiles;
var mapHeight = worldRenderer.World.Map.Height;
var mapResources = worldRenderer.World.Map.Resources;
var dest = new CellRegion(gridType, source.TopLeft + offset, source.BottomRight + offset);

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Widgets
var underCursor = editorLayer.PreviewsAt(worldPixel).MinByOrDefault(CalculateActorSelectionPriority);
var mapResources = world.Map.MapResources.Value;
var mapResources = world.Map.Resources;
ResourceType type;
if (underCursor != null)
editorWidget.SetTooltip(underCursor.Tooltip);

View File

@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Widgets
{
var type = (byte)ResourceType.ResourceType;
var index = (byte)ResourceType.MaxDensity;
world.Map.MapResources.Value[cell] = new ResourceTile(type, index);
world.Map.Resources[cell] = new ResourceTile(type, index);
}
return true;
@@ -77,11 +77,11 @@ namespace OpenRA.Mods.Common.Widgets
public bool AllowResourceAt(CPos cell)
{
var mapResources = world.Map.MapResources.Value;
var mapResources = world.Map.Resources;
if (!mapResources.Contains(cell))
return false;
var tile = world.Map.MapTiles.Value[cell];
var tile = world.Map.Tiles[cell];
var tileInfo = world.Map.Rules.TileSet.GetTileInfo(tile);
if (tileInfo == null)
return false;

View File

@@ -97,8 +97,8 @@ namespace OpenRA.Mods.Common.Widgets
void PaintCell(CPos cell, bool isMoving)
{
var map = world.Map;
var mapTiles = map.MapTiles.Value;
var mapHeight = map.MapHeight.Value;
var mapTiles = map.Tiles;
var mapHeight = map.Height;
var tileset = map.Rules.TileSet;
var template = tileset.Templates[Template];
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.Common.Widgets
void FloodFillWithBrush(CPos cell, bool isMoving)
{
var map = world.Map;
var mapTiles = map.MapTiles.Value;
var mapTiles = map.Tiles;
var replace = mapTiles[cell];
if (replace.Type == Template)
@@ -203,7 +203,7 @@ namespace OpenRA.Mods.Common.Widgets
bool PlacementOverlapsSameTemplate(TerrainTemplateInfo template, CPos cell)
{
var map = world.Map;
var mapTiles = map.MapTiles.Value;
var mapTiles = map.Tiles;
var i = 0;
for (var y = 0; y < template.Size.Y; y++)
{

View File

@@ -447,7 +447,7 @@ namespace OpenRA.Mods.Common.Effects
if (!world.Map.Contains(world.Map.CellContaining(posProbe)))
break;
var ht = world.Map.MapHeight.Value[world.Map.CellContaining(posProbe)] * 512;
var ht = world.Map.Height[world.Map.CellContaining(posProbe)] * 512;
curDist += stepSize;
if (ht > predClfHgt)

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
if (!bi.AllowInvalidPlacement && world.ActorMap.GetActorsAt(cell).Any(a => a != toIgnore))
return false;
var tile = world.Map.MapTiles.Value[cell];
var tile = world.Map.Tiles[cell];
var tileInfo = world.Map.Rules.TileSet.GetTileInfo(tile);
// TODO: This is bandaiding over bogus tilesets.

View File

@@ -49,7 +49,6 @@ namespace OpenRA.Mods.Common.Traits
var world = self.World;
var map = world.Map;
var tiles = map.MapTiles.Value;
var pos = map.CellContaining(self.CenterPosition);
var terrainType = map.GetTerrainInfo(pos).Type;

View File

@@ -158,7 +158,6 @@ namespace OpenRA.Mods.Common.Traits
if (!checkTerrainType)
return true;
var tiles = self.World.Map.MapTiles.Value;
var terrainType = self.World.Map.GetTerrainInfo(self.Location).Type;
return info.AllowedTerrainTypes.Contains(terrainType);
@@ -172,7 +171,7 @@ namespace OpenRA.Mods.Common.Traits
var ramp = 0;
if (self.World.Map.Contains(self.Location))
{
var tile = self.World.Map.MapTiles.Value[self.Location];
var tile = self.World.Map.Tiles[self.Location];
var ti = self.World.Map.Rules.TileSet.GetTileInfo(tile);
if (ti != null)
ramp = ti.RampType;

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
}
// Take all templates to overlay from the map
foreach (var cell in w.Map.AllCells.Where(cell => bridgeTypes.ContainsKey(w.Map.MapTiles.Value[cell].Type)))
foreach (var cell in w.Map.AllCells.Where(cell => bridgeTypes.ContainsKey(w.Map.Tiles[cell].Type)))
ConvertBridgeToActor(w, cell);
// Link adjacent (long)-bridges so that artwork is updated correctly
@@ -65,8 +65,8 @@ namespace OpenRA.Mods.Common.Traits
return;
// Correlate the tile "image" aka subtile with its position to find the template origin
var tile = w.Map.MapTiles.Value[cell].Type;
var index = w.Map.MapTiles.Value[cell].Index;
var tile = w.Map.Tiles[cell].Type;
var index = w.Map.Tiles[cell].Index;
var template = w.Map.Rules.TileSet.Templates[tile];
var ni = cell.X - index % template.Size.X;
var nj = cell.Y - index / template.Size.X;
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits
}).Trait<Bridge>();
var subTiles = new Dictionary<CPos, byte>();
var mapTiles = w.Map.MapTiles.Value;
var mapTiles = w.Map.Tiles;
// For each subtile in the template
for (byte ind = 0; ind < template.Size.X * template.Size.Y; ind++)

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
Resources = self.TraitsImplementing<ResourceType>()
.ToDictionary(r => r.Info.ResourceType, r => r);
Map.MapResources.Value.CellEntryChanged += UpdateCell;
Map.Resources.CellEntryChanged += UpdateCell;
}
public void WorldLoaded(World w, WorldRenderer wr)
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Traits
public void UpdateCell(CPos cell)
{
var uv = cell.ToMPos(Map);
var tile = Map.MapResources.Value[uv];
var tile = Map.Resources[uv];
var t = Tiles[cell];
if (t.Density > 0)
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Traits
// Set density based on the number of neighboring resources
var adjacent = 0;
var type = Tiles[c].Type;
var resources = Map.MapResources.Value;
var resources = Map.Resources;
for (var u = -1; u < 2; u++)
{
for (var v = -1; v < 2; v++)
@@ -205,7 +205,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var kv in spriteLayers.Values)
kv.Dispose();
Map.MapResources.Value.CellEntryChanged -= UpdateCell;
Map.Resources.CellEntryChanged -= UpdateCell;
disposed = true;
}

View File

@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var cell in w.Map.AllCells)
{
ResourceType t;
if (!resources.TryGetValue(w.Map.MapResources.Value[cell].Type, out t))
if (!resources.TryGetValue(w.Map.Resources[cell].Type, out t))
continue;
if (!AllowResourceAt(t, cell))
@@ -193,7 +193,7 @@ namespace OpenRA.Mods.Common.Traits
if (!rt.Info.AllowOnRamps)
{
var tile = world.Map.MapTiles.Value[cell];
var tile = world.Map.Tiles[cell];
var tileInfo = world.Map.Rules.TileSet.GetTileInfo(tile);
if (tileInfo != null && tileInfo.RampType > 0)
return false;

View File

@@ -57,11 +57,11 @@ namespace OpenRA.Mods.Common.Traits
foreach (var uv in wr.Viewport.AllVisibleCells.CandidateMapCoords)
{
if (!map.MapHeight.Value.Contains(uv))
if (!map.Height.Contains(uv))
continue;
var height = (int)map.MapHeight.Value[uv];
var tile = map.MapTiles.Value[uv];
var height = (int)map.Height[uv];
var tile = map.Tiles[uv];
var ti = tileSet.GetTileInfo(tile);
var ramp = ti != null ? ti.RampType : 0;

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Widgets
foreach (var cell in world.Map.AllCells)
UpdateTerrainCell(cell);
world.Map.MapTiles.Value.CellEntryChanged += UpdateTerrainCell;
world.Map.Tiles.CellEntryChanged += UpdateTerrainCell;
world.Map.CustomTerrain.CellEntryChanged += UpdateTerrainCell;
}
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Widgets
int leftColor, rightColor;
if (custom == byte.MaxValue)
{
var type = world.Map.Rules.TileSet.GetTileInfo(world.Map.MapTiles.Value[uv]);
var type = world.Map.Rules.TileSet.GetTileInfo(world.Map.Tiles[uv]);
leftColor = type != null ? type.LeftColor.ToArgb() : Color.Black.ToArgb();
rightColor = type != null ? type.RightColor.ToArgb() : Color.Black.ToArgb();
}
@@ -444,7 +444,7 @@ namespace OpenRA.Mods.Common.Widgets
public override void Removed()
{
base.Removed();
world.Map.MapTiles.Value.CellEntryChanged -= UpdateTerrainCell;
world.Map.Tiles.CellEntryChanged -= UpdateTerrainCell;
world.Map.CustomTerrain.CellEntryChanged -= UpdateTerrainCell;
Dispose();
}