summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-06-26 12:25:53 +0000
committersmatz <smatz@openttd.org>2009-06-26 12:25:53 +0000
commit2987f021447d47a2678a8fdce81547e3d66a7217 (patch)
treea032d65e31564e4e55143f9a08289844eff9306b /src
parent90554ee39091c98cb89b0c9a90b529564a82ff38 (diff)
downloadopenttd-2987f021447d47a2678a8fdce81547e3d66a7217.tar.xz
(svn r16663) -Codechange: make removing of railway station tiles faster
Diffstat (limited to 'src')
-rw-r--r--src/station_cmd.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index abee45c61..080ded56b 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1151,6 +1151,8 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
int size_x = ex - sx + 1;
int size_y = ey - sy + 1;
+ SmallVector<Station *, 4> affected_stations;
+
/* Do the action for every tile into the area */
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
/* Make sure the specified tile is a railroad station */
@@ -1203,12 +1205,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
DeallocateSpecFromStation(st, specindex);
- /* 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);
- st->MarkTilesDirty(false);
- UpdateStationSignCoord(st);
+ affected_stations.Include(st);
if (v != NULL) {
/* Restore station reservation. */
@@ -1217,18 +1214,29 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
for (; v->Next() != NULL; v = v->Next()) ;
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
}
+ }
+ } END_TILE_LOOP(tile2, size_x, size_y, tile)
- /* if we deleted the whole station, delete the train facility. */
- if (st->train_tile == INVALID_TILE) {
- st->facilities &= ~FACIL_TRAIN;
- InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
- UpdateStationVirtCoordDirty(st);
- DeleteStationIfEmpty(st);
- }
+ for (Station **stp = affected_stations.Begin(); stp != affected_stations.End(); stp++) {
+ Station *st = *stp;
+
+ /* 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);
+ st->MarkTilesDirty(false);
+ UpdateStationSignCoord(st);
- st->RecomputeIndustriesNear();
+ /* if we deleted the whole station, delete the train facility. */
+ if (st->train_tile == INVALID_TILE) {
+ st->facilities &= ~FACIL_TRAIN;
+ InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
+ UpdateStationVirtCoordDirty(st);
+ DeleteStationIfEmpty(st);
}
- } END_TILE_LOOP(tile2, size_x, size_y, tile)
+
+ st->RecomputeIndustriesNear();
+ }
/* If we've not removed any tiles, give an error */
if (quantity == 0) return CMD_ERROR;