mirror of https://github.com/OpenTTD/OpenTTD
(svn r16663) -Codechange: make removing of railway station tiles faster
parent
90554ee390
commit
2987f02144
|
@ -1151,6 +1151,8 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
|
||||||
int size_x = ex - sx + 1;
|
int size_x = ex - sx + 1;
|
||||||
int size_y = ey - sy + 1;
|
int size_y = ey - sy + 1;
|
||||||
|
|
||||||
|
SmallVector<Station *, 4> affected_stations;
|
||||||
|
|
||||||
/* Do the action for every tile into the area */
|
/* Do the action for every tile into the area */
|
||||||
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
|
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
|
||||||
/* Make sure the specified tile is a railroad station */
|
/* Make sure the specified tile is a railroad station */
|
||||||
|
@ -1203,12 +1205,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
|
||||||
|
|
||||||
DeallocateSpecFromStation(st, specindex);
|
DeallocateSpecFromStation(st, specindex);
|
||||||
|
|
||||||
/* now we need to make the "spanned" area of the railway station smaller
|
affected_stations.Include(st);
|
||||||
* if we deleted something at the edges.
|
|
||||||
* we also need to adjust train_tile. */
|
|
||||||
MakeRailwayStationAreaSmaller(st);
|
|
||||||
st->MarkTilesDirty(false);
|
|
||||||
UpdateStationSignCoord(st);
|
|
||||||
|
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
/* Restore station reservation. */
|
/* Restore station reservation. */
|
||||||
|
@ -1217,6 +1214,18 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
|
||||||
for (; v->Next() != NULL; v = v->Next()) ;
|
for (; v->Next() != NULL; v = v->Next()) ;
|
||||||
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
|
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} END_TILE_LOOP(tile2, size_x, size_y, tile)
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
/* if we deleted the whole station, delete the train facility. */
|
/* if we deleted the whole station, delete the train facility. */
|
||||||
if (st->train_tile == INVALID_TILE) {
|
if (st->train_tile == INVALID_TILE) {
|
||||||
|
@ -1228,7 +1237,6 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
|
||||||
|
|
||||||
st->RecomputeIndustriesNear();
|
st->RecomputeIndustriesNear();
|
||||||
}
|
}
|
||||||
} END_TILE_LOOP(tile2, size_x, size_y, tile)
|
|
||||||
|
|
||||||
/* If we've not removed any tiles, give an error */
|
/* If we've not removed any tiles, give an error */
|
||||||
if (quantity == 0) return CMD_ERROR;
|
if (quantity == 0) return CMD_ERROR;
|
||||||
|
|
Loading…
Reference in New Issue