summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-10-21 19:32:46 +0000
committerpeter1138 <peter1138@openttd.org>2006-10-21 19:32:46 +0000
commit6a955f38920c12776638bc0fddf4510f9d42356f (patch)
tree7a35f63110c20251ceefada3e579868f6832df02
parent608c88e56f953dfa85ca31a39f402a01d6b9c2a1 (diff)
downloadopenttd-6a955f38920c12776638bc0fddf4510f9d42356f.tar.xz
(svn r6874) - [NewStations] Mark all tiles of a railway station dirty when adding or removing tiles.
-rw-r--r--station_cmd.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/station_cmd.c b/station_cmd.c
index c846a7b6d..73a8c7f1c 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -85,6 +85,30 @@ MemoryPool _roadstop_pool = { "RoadStop", ROADSTOP_POOL_MAX_BLOCKS, ROADSTOP_POO
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 @@ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint3
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 @@ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint3
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 @@ int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint
// 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) {