diff options
author | rubidium <rubidium@openttd.org> | 2007-02-23 00:17:46 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-02-23 00:17:46 +0000 |
commit | 202702c0077b4cda81cdc194fb225d3fc779c55a (patch) | |
tree | 7e92dee8a90a165f6b39d9c0ca40c40e554032cf /src/station_cmd.cpp | |
parent | dcb217a6ace27ae989a59d8503c139f613694b1b (diff) | |
download | openttd-202702c0077b4cda81cdc194fb225d3fc779c55a.tar.xz |
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
-Fix (r8735): remove drive through road stops on town owned roads when going bankrupt/being removed.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 8f90b8d21..577bc3d49 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2584,10 +2584,31 @@ static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerI RebuildStationLists(); InvalidateWindowClasses(WC_STATION_LIST); } else { - DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); + if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) { + /* For a drive-through stop on a town-owned road remove the stop and replace the road */ + DoCommand(tile, 0, (GetStationType(tile) == STATION_TRUCK) ? RoadStop::TRUCK : RoadStop::BUS, DC_EXEC, CMD_REMOVE_ROAD_STOP); + } else { + DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); + } } } +/** + * Check if a drive-through road stop tile can be cleared. + * Road stops built on town-owned roads check the conditions + * that would allow clearing of the original road. + * @param tile road stop tile to check + * @return true if the road can be cleared + */ +static bool CanRemoveRoadWithStop(TileIndex tile) +{ + /* The road can always be cleared if it was not a town-owned road */ + if (!GetStopBuiltOnTownRoad(tile)) return true; + + bool edge_road; + return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile), OWNER_TOWN, &edge_road); +} + static int32 ClearTile_Station(TileIndex tile, byte flags) { if (flags & DC_AUTO) { @@ -2610,11 +2631,11 @@ static int32 ClearTile_Station(TileIndex tile, byte flags) case STATION_RAIL: return RemoveRailroadStation(st, tile, flags); case STATION_AIRPORT: return RemoveAirport(st, flags); case STATION_TRUCK: - if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) + if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile)) return_cmd_error(STR_3047_MUST_DEMOLISH_TRUCK_STATION); return RemoveRoadStop(st, flags, tile); case STATION_BUS: - if (IsDriveThroughStopTile(tile) && GetStopBuiltOnTownRoad(tile)) + if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile)) return_cmd_error(STR_3046_MUST_DEMOLISH_BUS_STATION); return RemoveRoadStop(st, flags, tile); case STATION_BUOY: return RemoveBuoy(st, flags); |