Changeset - r22087:04c8ad187e4e
[Not reviewed]
master
0 2 0
frosch - 9 years ago 2015-04-26 09:51:24
frosch@openttd.org
(svn r27251) -Feature [FS#6252]: Make Ctrl+Remove-Roadstop also remove the road, just like for rail stations. (adf88)
2 files changed with 24 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/road_gui.cpp
Show inline comments
 
@@ -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;
 
				}
 
			}
src/station_cmd.cpp
Show inline comments
 
@@ -1999,6 +1999,7 @@ static CommandCost RemoveRoadStop(TileIn
 
 * @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 
 
{
 
	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 
 
		/* 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));
 

	
 
		Owner road_owner = GetRoadOwner(cur_tile, ROADTYPE_ROAD);
 
		Owner tram_owner = GetRoadOwner(cur_tile, ROADTYPE_TRAM);
 
		/* 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)));
 
		}
 

	
 
		CommandCost ret = RemoveRoadStop(cur_tile, flags);
 
		if (ret.Failed()) {
 
			last_error = ret;
 
@@ -2039,10 +2049,10 @@ CommandCost CmdRemoveRoadStop(TileIndex 
 
		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;
0 comments (0 inline, 0 general)