Skip to content

Commit 5080aba

Browse files
committed
Always display tile variant 0 for tiles in BridgeSet and TrainBridgeSet
1 parent 1cbed02 commit 5080aba

4 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/TSMapEditor/CCEngine/Theater.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public Theater(string name)
7777
public List<TileSet> TileSets = new List<TileSet>();
7878
public List<LATGround> LATGrounds = new List<LATGround>();
7979
public TileSet RampTileSet { get; set; }
80+
public TileSet BridgeTileSet { get; set; }
81+
public TileSet TrainBridgeTileSet { get; set; }
8082

8183
private const string REQUIRED_SECTION = "General";
8284

@@ -131,11 +133,19 @@ public void ReadConfigINI(string baseDirectoryPath, CCFileManager ccFileManager)
131133

132134
int rampTileSetIndex = theaterIni.GetIntValue("General", "RampBase", -1);
133135
if (rampTileSetIndex < 0 || rampTileSetIndex >= TileSets.Count)
134-
{
135136
throw new INIConfigException("Invalid value specified for RampBase= in the theater configuration file!");
136-
}
137+
138+
int bridgeTileSetIndex = theaterIni.GetIntValue("General", "BridgeSet", -1);
139+
if (bridgeTileSetIndex < 0 || bridgeTileSetIndex >= TileSets.Count)
140+
throw new INIConfigException("Invalid value specified for BridgeSet= in the theater configuration file!");
141+
142+
int trainBridgeTileSetIndex = theaterIni.GetIntValue("General", "TrainBridgeSet", -1);
143+
if (trainBridgeTileSetIndex < 0 || trainBridgeTileSetIndex >= TileSets.Count)
144+
throw new INIConfigException("Invalid value specified for TrainBridgeSet= in the theater configuration file!");
137145

138146
RampTileSet = TileSets[rampTileSetIndex];
147+
BridgeTileSet = TileSets[bridgeTileSetIndex];
148+
TrainBridgeTileSet = TileSets[trainBridgeTileSetIndex];
139149
}
140150

141151
public TileSet TryGetTileSetById(int id)

src/TSMapEditor/Constants.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
using Rampastring.Tools;
2-
using System;
32

43
namespace TSMapEditor
54
{
65
public static class Constants
76
{
8-
public const string ReleaseVersion = "1.4.11";
7+
public const string ReleaseVersion = "1.4.12";
98

109
public static int CellSizeX = 48;
1110
public static int CellSizeY = 24;

src/TSMapEditor/Rendering/MapView.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,15 @@ public void DrawTerrainTile(MapTile tile)
654654
Point2D drawPoint = CellMath.CellTopLeftPointFromCellCoords(new Point2D(tile.X, tile.Y), Map);
655655

656656
if (tile.TileImage == null)
657-
tile.TileImage = TheaterGraphics.GetTileGraphics(tile.TileIndex);
657+
{
658+
// Hardcode variant 0 for bridges and train bridges so they don't appear damaged
659+
// Ideally we'd need to check HasDamagedData in the subcell's TmpImage, but that
660+
// would be very messy... gg, Westwood.
661+
if (TheaterGraphics.Theater.BridgeTileSet.ContainsTile(tile.TileIndex) || TheaterGraphics.Theater.TrainBridgeTileSet.ContainsTile(tile.TileIndex))
662+
tile.TileImage = TheaterGraphics.GetTileGraphics(tile.TileIndex, 0);
663+
else
664+
tile.TileImage = TheaterGraphics.GetTileGraphics(tile.TileIndex);
665+
}
658666

659667
TileImage tileImage;
660668
int subTileIndex;

src/TSMapEditor/Rendering/TheaterGraphics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public class TheaterGraphics : ITheater
424424
public int TileCount => terrainGraphicsList.Count;
425425

426426
public TileImage GetTileGraphics(int id) => terrainGraphicsList[id][random.Next(terrainGraphicsList[id].Length)];
427-
public TileImage GetTileGraphics(int id, int randomId) => terrainGraphicsList[id][randomId];
427+
public TileImage GetTileGraphics(int id, int variantId) => terrainGraphicsList[id][variantId];
428428
public TileImage GetMarbleMadnessTileGraphics(int id) => mmTerrainGraphicsList[id][0];
429429
public bool HasSeparateMarbleMadnessTileGraphics(int id) => hasMMGraphics[id];
430430

0 commit comments

Comments
 (0)