src/station_cmd.cpp
changeset 9342 6daf441eee26
parent 9341 bd60c3b2d1e0
child 9354 845e07db4549
equal deleted inserted replaced
9341:bd60c3b2d1e0 9342:6daf441eee26
  2993 /**
  2993 /**
  2994  * Check if a drive-through road stop tile can be cleared.
  2994  * Check if a drive-through road stop tile can be cleared.
  2995  * Road stops built on town-owned roads check the conditions
  2995  * Road stops built on town-owned roads check the conditions
  2996  * that would allow clearing of the original road.
  2996  * that would allow clearing of the original road.
  2997  * @param tile road stop tile to check
  2997  * @param tile road stop tile to check
       
  2998  * @param flags command flags
  2998  * @return true if the road can be cleared
  2999  * @return true if the road can be cleared
  2999  */
  3000  */
  3000 static bool CanRemoveRoadWithStop(TileIndex tile)
  3001 static bool CanRemoveRoadWithStop(TileIndex tile, uint32 flags)
  3001 {
  3002 {
  3002 	/* The road can always be cleared if it was not a town-owned road */
  3003 	/* The road can always be cleared if it was not a town-owned road */
  3003 	if (!GetStopBuiltOnTownRoad(tile)) return true;
  3004 	if (!GetStopBuiltOnTownRoad(tile)) return true;
  3004 
  3005 
  3005 	bool edge_road;
  3006 	return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_ROAD), OWNER_TOWN, ROADTYPE_ROAD, flags);
  3006 	return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_ROAD), OWNER_TOWN, &edge_road, ROADTYPE_ROAD) &&
       
  3007 				CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_TRAM), OWNER_TOWN, &edge_road, ROADTYPE_TRAM);
       
  3008 }
  3007 }
  3009 
  3008 
  3010 static CommandCost ClearTile_Station(TileIndex tile, byte flags)
  3009 static CommandCost ClearTile_Station(TileIndex tile, byte flags)
  3011 {
  3010 {
  3012 	if (flags & DC_AUTO) {
  3011 	if (flags & DC_AUTO) {
  3027 
  3026 
  3028 	switch (GetStationType(tile)) {
  3027 	switch (GetStationType(tile)) {
  3029 		case STATION_RAIL:    return RemoveRailroadStation(st, tile, flags);
  3028 		case STATION_RAIL:    return RemoveRailroadStation(st, tile, flags);
  3030 		case STATION_AIRPORT: return RemoveAirport(st, flags);
  3029 		case STATION_AIRPORT: return RemoveAirport(st, flags);
  3031 		case STATION_TRUCK:
  3030 		case STATION_TRUCK:
  3032 			if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile))
  3031 			if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile, flags))
  3033 				return_cmd_error(STR_3047_MUST_DEMOLISH_TRUCK_STATION);
  3032 				return_cmd_error(STR_3047_MUST_DEMOLISH_TRUCK_STATION);
  3034 			return RemoveRoadStop(st, flags, tile);
  3033 			return RemoveRoadStop(st, flags, tile);
  3035 		case STATION_BUS:
  3034 		case STATION_BUS:
  3036 			if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile))
  3035 			if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile, flags))
  3037 				return_cmd_error(STR_3046_MUST_DEMOLISH_BUS_STATION);
  3036 				return_cmd_error(STR_3046_MUST_DEMOLISH_BUS_STATION);
  3038 			return RemoveRoadStop(st, flags, tile);
  3037 			return RemoveRoadStop(st, flags, tile);
  3039 		case STATION_BUOY:    return RemoveBuoy(st, flags);
  3038 		case STATION_BUOY:    return RemoveBuoy(st, flags);
  3040 		case STATION_DOCK:    return RemoveDock(st, flags);
  3039 		case STATION_DOCK:    return RemoveDock(st, flags);
  3041 		default: break;
  3040 		default: break;