diff --git a/OpenRA.FileFormats/Map/TileReference.cs b/OpenRA.FileFormats/Map/TileReference.cs index de410c429f..91fd67c686 100644 --- a/OpenRA.FileFormats/Map/TileReference.cs +++ b/OpenRA.FileFormats/Map/TileReference.cs @@ -14,20 +14,11 @@ namespace OpenRA.FileFormats { public T type; public U index; - public U image; public TileReference(T t, U i) { type = t; index = i; - image = i; - } - - public TileReference(T t, U i, U im) - { - type = t; - index = i; - image = im; } public override int GetHashCode() { return type.GetHashCode() ^ index.GetHashCode(); } diff --git a/OpenRA.FileFormats/Map/TileSet.cs b/OpenRA.FileFormats/Map/TileSet.cs index 12582b720b..6d28b854c9 100644 --- a/OpenRA.FileFormats/Map/TileSet.cs +++ b/OpenRA.FileFormats/Map/TileSet.cs @@ -136,7 +136,7 @@ namespace OpenRA.FileFormats { Terrain tile; if( Tiles.TryGetValue( r.type, out tile ) ) - return tile.TileBitmapBytes[ r.image ]; + return tile.TileBitmapBytes[ r.index ]; byte[] missingTile = new byte[ TileSize * TileSize ]; for( int i = 0 ; i < missingTile.Length ; i++ ) @@ -149,7 +149,7 @@ namespace OpenRA.FileFormats { var tt = Templates[r.type].Tiles; string ret; - if (!tt.TryGetValue(r.image, out ret)) + if (!tt.TryGetValue(r.index, out ret)) return "Clear"; // Default walkable return ret; } diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index b1d45e9ac5..ce1f742fa8 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -66,8 +66,7 @@ namespace OpenRA MapTiles = new TileReference[1, 1] { { new TileReference { type = tile.Key, - image = (byte)(tile.Value.PickAny ? 0xffu : 0), - index = (byte)(tile.Value.PickAny ? 0xffu : 0) } + index = (byte)0 } } }, }; @@ -324,8 +323,10 @@ namespace OpenRA { ushort tile = ReadWord(dataStream); byte index = ReadByte(dataStream); - byte image = (index == byte.MaxValue) ? (byte)(i % 4 + (j % 4) * 4) : index; - MapTiles[i, j] = new TileReference(tile, index, image); + if (index == byte.MaxValue) + index = (byte)(i % 4 + (j % 4) * 4); + + MapTiles[i, j] = new TileReference(tile, index); } // Load resource data @@ -350,7 +351,8 @@ namespace OpenRA for (int j = 0; j < MapSize.Y; j++) { writer.Write(MapTiles[i, j].type); - writer.Write(MapTiles[i, j].index); + var PickAny = OpenRA.Rules.TileSets[Tileset].Templates[MapTiles[i, j].type].PickAny; + writer.Write(PickAny ? (byte)(i % 4 + (j % 4) * 4) : MapTiles[i, j].index); } // Resource data diff --git a/OpenRA.Mods.RA/BridgeLayer.cs b/OpenRA.Mods.RA/BridgeLayer.cs index 1c630335e1..74ddd1eb70 100644 --- a/OpenRA.Mods.RA/BridgeLayer.cs +++ b/OpenRA.Mods.RA/BridgeLayer.cs @@ -67,10 +67,10 @@ namespace OpenRA.Mods.RA // Correlate the tile "image" aka subtile with its position to find the template origin var tile = w.Map.MapTiles[i, j].type; - var image = w.Map.MapTiles[i, j].image; + var index = w.Map.MapTiles[i, j].index; var template = w.TileSet.Templates[tile]; - var ni = i - image % template.Size.X; - var nj = j - image / template.Size.X; + var ni = i - index % template.Size.X; + var nj = j - index / template.Size.X; // Create a new actor for this bridge and keep track of which subtiles this bridge includes var bridge = w.CreateActor(BridgeTypes[tile].First, new TypeDictionary @@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA var y = nj + ind / template.Size.X; // This isn't the bridge you're looking for - if (!w.Map.IsInMap(x, y) || w.Map.MapTiles[x, y].image != ind) + if (!w.Map.IsInMap(x, y) || w.Map.MapTiles[x, y].index != ind) continue; subTiles.Add(new int2(x,y),ind); diff --git a/OpenRA.Mods.RA/Buildings/BibLayer.cs b/OpenRA.Mods.RA/Buildings/BibLayer.cs index d1ec4cdc6c..b7d2a37291 100755 --- a/OpenRA.Mods.RA/Buildings/BibLayer.cs +++ b/OpenRA.Mods.RA/Buildings/BibLayer.cs @@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA.Buildings if (!world.LocalShroud.IsExplored(kv.Key)) continue; - bibSprites[kv.Value.type - 1][kv.Value.image].DrawAt( wr, + bibSprites[kv.Value.type - 1][kv.Value.index].DrawAt( wr, Game.CellSize * kv.Key, "terrain"); } } diff --git a/OpenRA.Mods.RA/World/SmudgeLayer.cs b/OpenRA.Mods.RA/World/SmudgeLayer.cs index 2716d38099..4cdcaa64a1 100755 --- a/OpenRA.Mods.RA/World/SmudgeLayer.cs +++ b/OpenRA.Mods.RA/World/SmudgeLayer.cs @@ -72,9 +72,9 @@ namespace OpenRA.Mods.RA var tile = tiles[loc]; // Existing smudge; make it deeper int depth = Info.Depths[tile.type-1]; - if (tile.image < depth - 1) + if (tile.index < depth - 1) { - tile.image++; + tile.index++; tiles[loc] = tile; // struct semantics. } } @@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA if (localPlayer != null && !localPlayer.Shroud.IsExplored(kv.Key)) continue; - smudgeSprites[kv.Value.type- 1][kv.Value.image].DrawAt( wr, + smudgeSprites[kv.Value.type- 1][kv.Value.index].DrawAt( wr, Game.CellSize * kv.Key, "terrain"); } }