mirror of https://github.com/OpenTTD/OpenTTD
(svn r16987) -Codechange: simplify the code to loop train station for the station demolish code
parent
30a1f1416a
commit
e6480d823a
|
@ -1252,35 +1252,28 @@ static CommandCost RemoveRailroadStation(TileIndex tile, DoCommandFlag flags)
|
||||||
|
|
||||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||||
/* clear all areas of the station */
|
/* clear all areas of the station */
|
||||||
do {
|
TILE_LOOP(tile, ta.w, ta.h, ta.tile) {
|
||||||
int w_bak = ta.w;
|
/* for nonuniform stations, only remove tiles that are actually train station tiles */
|
||||||
do {
|
if (!st->TileBelongsToRailStation(tile)) continue;
|
||||||
/* for nonuniform stations, only remove tiles that are actually train station tiles */
|
|
||||||
if (st->TileBelongsToRailStation(ta.tile)) {
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
if (!EnsureNoVehicleOnGround(ta.tile)) {
|
|
||||||
return CMD_ERROR;
|
cost.AddCost(_price.remove_rail_station);
|
||||||
}
|
if (flags & DC_EXEC) {
|
||||||
cost.AddCost(_price.remove_rail_station);
|
/* read variables before the station tile is removed */
|
||||||
if (flags & DC_EXEC) {
|
Track track = GetRailStationTrack(tile);
|
||||||
/* read variables before the station tile is removed */
|
Owner owner = GetTileOwner(tile); // _current_company can be OWNER_WATER
|
||||||
Track track = GetRailStationTrack(ta.tile);
|
Train *v = NULL;
|
||||||
Owner owner = GetTileOwner(ta.tile); // _current_company can be OWNER_WATER
|
if (HasStationReservation(tile)) {
|
||||||
Train *v = NULL;
|
v = GetTrainForReservation(tile, track);
|
||||||
if (HasStationReservation(ta.tile)) {
|
if (v != NULL) FreeTrainTrackReservation(v);
|
||||||
v = GetTrainForReservation(ta.tile, track);
|
|
||||||
if (v != NULL) FreeTrainTrackReservation(v);
|
|
||||||
}
|
|
||||||
DoClearSquare(ta.tile);
|
|
||||||
AddTrackToSignalBuffer(ta.tile, track, owner);
|
|
||||||
YapfNotifyTrackLayoutChange(ta.tile, track);
|
|
||||||
if (v != NULL) TryPathReserve(v, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ta.tile += TileDiffXY(1, 0);
|
DoClearSquare(tile);
|
||||||
} while (--ta.w);
|
AddTrackToSignalBuffer(tile, track, owner);
|
||||||
ta.w = w_bak;
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
ta.tile += TileDiffXY(-ta.w, 1);
|
if (v != NULL) TryPathReserve(v, true);
|
||||||
} while (--ta.h);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
st->rect.AfterRemoveRect(st, st->train_station.tile, st->train_station.w, st->train_station.h);
|
st->rect.AfterRemoveRect(st, st->train_station.tile, st->train_station.w, st->train_station.h);
|
||||||
|
|
Loading…
Reference in New Issue