(svn r16989) -Codechange: unify the code for demolishing (dynamite) stations and waypoints.

This commit is contained in:
rubidium
2009-07-29 22:13:12 +00:00
parent 34cb882127
commit df1c950d6a
3 changed files with 43 additions and 54 deletions

View File

@@ -210,48 +210,6 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1
return CommandCost(EXPENSES_CONSTRUCTION, _price.build_train_depot);
}
/**
* Remove a waypoint
* @param tile from which to remove waypoint
* @param flags type of operation
* @param justremove will indicate if it is removed from rail or if rails are removed too
* @pre IsRailWaypointTile(tile)
* @return cost of operation or error
*/
CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags)
{
/* Make sure it's a waypoint */
if (!IsRailWaypointTile(tile) ||
(!CheckTileOwnership(tile) && _current_company != OWNER_WATER) ||
!EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
if (flags & DC_EXEC) {
Track track = GetRailStationTrack(tile);
Waypoint *wp = Waypoint::GetByTile(tile);
wp->sign.MarkDirty();
wp->facilities &= ~FACIL_TRAIN;
Train *v = NULL;
uint specindex = GetCustomStationSpecIndex(tile);
if (HasStationReservation(tile)) {
v = GetTrainForReservation(tile, track);
if (v != NULL) FreeTrainTrackReservation(v);
}
DoClearSquare(tile);
AddTrackToSignalBuffer(tile, track, wp->owner);
YapfNotifyTrackLayoutChange(tile, track);
if (v != NULL) TryPathReserve(v, true);
DeallocateSpecFromStation(wp, specindex);
wp->rect.AfterRemoveTile(wp, tile);
}
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_train_depot);
}
/** Build a buoy.
* @param tile tile where to place the bouy
* @param flags operation to perform