mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-31 11:23:21 +00:00
(svn r27251) -Feature [FS#6252]: Make Ctrl+Remove-Roadstop also remove the road, just like for rail stations. (adf88)
This commit is contained in:
parent
4fa052dd19
commit
0ea4127837
@ -642,13 +642,13 @@ struct BuildRoadToolbarWindow : Window {
|
||||
|
||||
case DDSP_REMOVE_BUSSTOP: {
|
||||
TileArea ta(start_tile, end_tile);
|
||||
DoCommandP(ta.tile, ta.w | ta.h << 8, ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS]), CcPlaySound1D);
|
||||
DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS]), CcPlaySound1D);
|
||||
break;
|
||||
}
|
||||
|
||||
case DDSP_REMOVE_TRUCKSTOP: {
|
||||
TileArea ta(start_tile, end_tile);
|
||||
DoCommandP(ta.tile, ta.w | ta.h << 8, ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]), CcPlaySound1D);
|
||||
DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]), CcPlaySound1D);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1999,6 +1999,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
|
||||
* @param p1 bit 0..7: Width of the removal area.
|
||||
* bit 8..15: Height of the removal area.
|
||||
* @param p2 bit 0: 0 For bus stops, 1 for truck stops.
|
||||
* @param p2 bit 1: 0 to keep roads of all drive-through stops, 1 to remove them.
|
||||
* @param text Unused.
|
||||
* @return The cost of this operation or an error.
|
||||
*/
|
||||
@ -2006,11 +2007,14 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
{
|
||||
uint8 width = (uint8)GB(p1, 0, 8);
|
||||
uint8 height = (uint8)GB(p1, 8, 8);
|
||||
bool keep_drive_through_roads = !HasBit(p2, 1);
|
||||
|
||||
/* Check for incorrect width / height. */
|
||||
if (width == 0 || height == 0) return CMD_ERROR;
|
||||
/* Check if the first tile and the last tile are valid */
|
||||
if (!IsValidTile(tile) || TileAddWrap(tile, width - 1, height - 1) == INVALID_TILE) return CMD_ERROR;
|
||||
/* Bankrupting company is not supposed to remove roads, there may be road vehicles. */
|
||||
if (!keep_drive_through_roads && (flags & DC_BANKRUPT)) return CMD_ERROR;
|
||||
|
||||
TileArea roadstop_area(tile, width, height);
|
||||
|
||||
@ -2022,15 +2026,21 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
/* Make sure the specified tile is a road stop of the correct type */
|
||||
if (!IsTileType(cur_tile, MP_STATION) || !IsRoadStop(cur_tile) || (uint32)GetRoadStopType(cur_tile) != GB(p2, 0, 1)) continue;
|
||||
|
||||
/* Save the stop info before it is removed */
|
||||
bool is_drive_through = IsDriveThroughStopTile(cur_tile);
|
||||
RoadTypes rts = GetRoadTypes(cur_tile);
|
||||
RoadBits road_bits = IsDriveThroughStopTile(cur_tile) ?
|
||||
((GetRoadStopDir(cur_tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y) :
|
||||
DiagDirToRoadBits(GetRoadStopDir(cur_tile));
|
||||
/* Save information on to-be-restored roads before the stop is removed. */
|
||||
RoadTypes rts = ROADTYPES_NONE;
|
||||
RoadBits road_bits = ROAD_NONE;
|
||||
Owner road_owner[] = { OWNER_NONE, OWNER_NONE };
|
||||
assert_compile(lengthof(road_owner) == ROADTYPE_END);
|
||||
if (IsDriveThroughStopTile(cur_tile)) {
|
||||
RoadType rt;
|
||||
FOR_EACH_SET_ROADTYPE(rt, GetRoadTypes(cur_tile)) {
|
||||
road_owner[rt] = GetRoadOwner(cur_tile, rt);
|
||||
/* If we don't want to preserve our roads then restore only roads of others. */
|
||||
if (keep_drive_through_roads || road_owner[rt] != _current_company) SetBit(rts, rt);
|
||||
}
|
||||
road_bits = AxisToRoadBits(DiagDirToAxis(GetRoadStopDir(cur_tile)));
|
||||
}
|
||||
|
||||
Owner road_owner = GetRoadOwner(cur_tile, ROADTYPE_ROAD);
|
||||
Owner tram_owner = GetRoadOwner(cur_tile, ROADTYPE_TRAM);
|
||||
CommandCost ret = RemoveRoadStop(cur_tile, flags);
|
||||
if (ret.Failed()) {
|
||||
last_error = ret;
|
||||
@ -2039,10 +2049,10 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
cost.AddCost(ret);
|
||||
had_success = true;
|
||||
|
||||
/* If the stop was a drive-through stop replace the road */
|
||||
if ((flags & DC_EXEC) && is_drive_through) {
|
||||
/* Restore roads. */
|
||||
if ((flags & DC_EXEC) && rts != ROADTYPES_NONE) {
|
||||
MakeRoadNormal(cur_tile, road_bits, rts, ClosestTownFromTile(cur_tile, UINT_MAX)->index,
|
||||
road_owner, tram_owner);
|
||||
road_owner[ROADTYPE_ROAD], road_owner[ROADTYPE_TRAM]);
|
||||
|
||||
/* Update company infrastructure counts. */
|
||||
RoadType rt;
|
||||
|
Loading…
Reference in New Issue
Block a user