(svn r6874) - [NewStations] Mark all tiles of a railway station dirty when adding or removing tiles.
authorpeter1138
Sat, 21 Oct 2006 19:32:46 +0000
changeset 4904 ed65b5e93fbd
parent 4903 d5805bdda3a7
child 4905 49b0d1b84fc3
(svn r6874) - [NewStations] Mark all tiles of a railway station dirty when adding or removing tiles.
station_cmd.c
--- a/station_cmd.c	Sat Oct 21 17:58:14 2006 +0000
+++ b/station_cmd.c	Sat Oct 21 19:32:46 2006 +0000
@@ -85,6 +85,30 @@
 
 extern void UpdateAirplanesOnNewStation(Station *st);
 
+static bool TileBelongsToRailStation(const Station *st, TileIndex tile)
+{
+	return IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st->index && IsRailwayStation(tile);
+}
+
+static void MarkStationTilesDirty(const Station *st)
+{
+	TileIndex tile = st->train_tile;
+	uint w, h;
+
+	// XXX No station is recorded as 0, not INVALID_TILE...
+	if (tile == 0) return;
+
+	for (h = 0; h < st->trainst_h; h++) {
+		for (w = 0; w < st->trainst_w; w++) {
+			if (TileBelongsToRailStation(st, tile)) {
+				MarkTileDirtyByTile(tile);
+			}
+			tile += TileDiffXY(1, 0);
+		}
+		tile += TileDiffXY(-w, 1);
+	}
+}
+
 static void MarkStationDirty(const Station* st)
 {
 	if (st->sign.width_1 != 0) {
@@ -1107,6 +1131,7 @@
 			tile_org += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
 		} while (--numtracks);
 
+		MarkStationTilesDirty(st);
 		UpdateStationVirtCoordDirty(st);
 		UpdateStationAcceptance(st, false);
 		RebuildStationLists();
@@ -1116,11 +1141,6 @@
 	return cost;
 }
 
-static bool TileBelongsToRailStation(const Station *st, TileIndex tile)
-{
-	return IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st->index && IsRailwayStation(tile);
-}
-
 static void MakeRailwayStationAreaSmaller(Station *st)
 {
 	uint w = st->trainst_w;
@@ -1208,6 +1228,7 @@
 		// now we need to make the "spanned" area of the railway station smaller if we deleted something at the edges.
 		// we also need to adjust train_tile.
 		MakeRailwayStationAreaSmaller(st);
+		MarkStationTilesDirty(st);
 
 		// if we deleted the whole station, delete the train facility.
 		if (st->train_tile == 0) {