|
@@ -1365,42 +1365,46 @@ CommandCost CmdBuildRoadStop(TileIndex t
|
|
|
if (is_drive_through && !IsValidAxis((Axis)p1)) return CMD_ERROR;
|
|
|
/* Road bits in the wrong direction */
|
|
|
if (build_over_road && (GetAllRoadBits(tile) & ((Axis)p1 == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return_cmd_error(STR_DRIVE_THROUGH_ERROR_DIRECTION);
|
|
|
|
|
|
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR;
|
|
|
|
|
|
RoadTypes cur_rts = IsNormalRoadTile(tile) ? GetRoadTypes(tile) : ROADTYPES_NONE;
|
|
|
uint num_roadbits = 0;
|
|
|
/* Not allowed to build over this road */
|
|
|
if (build_over_road) {
|
|
|
RoadTypes cur_rts = GetRoadTypes(tile);
|
|
|
|
|
|
/* there is a road, check if we can build road+tram stop over it */
|
|
|
if (HasBit(cur_rts, ROADTYPE_ROAD)) {
|
|
|
Owner road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
|
|
|
if (road_owner == OWNER_TOWN) {
|
|
|
town_owned_road = true;
|
|
|
if (!_settings_game.construction.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD);
|
|
|
} else {
|
|
|
if (road_owner != OWNER_NONE && !CheckOwnership(road_owner)) return CMD_ERROR;
|
|
|
}
|
|
|
num_roadbits += CountBits(GetRoadBits(tile, ROADTYPE_ROAD));
|
|
|
}
|
|
|
|
|
|
/* there is a tram, check if we can build road+tram stop over it */
|
|
|
if (HasBit(cur_rts, ROADTYPE_TRAM)) {
|
|
|
Owner tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM);
|
|
|
if (tram_owner != OWNER_NONE && !CheckOwnership(tram_owner)) return CMD_ERROR;
|
|
|
num_roadbits += CountBits(GetRoadBits(tile, ROADTYPE_TRAM));
|
|
|
}
|
|
|
|
|
|
/* Don't allow building the roadstop when vehicles are already driving on it */
|
|
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
|
|
|
|
|
/* Do not remove roadtypes! */
|
|
|
rts |= cur_rts;
|
|
|
}
|
|
|
|
|
|
CommandCost cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road);
|
|
|
if (CmdFailed(cost)) return cost;
|
|
|
uint roadbits_to_build = CountBits(rts) * 2 - num_roadbits;
|
|
|
cost.AddCost(_price.build_road * roadbits_to_build);
|
|
|
|
|
|
Station *st = NULL;
|
|
|
|
|
|
if (!_settings_game.station.adjacent_stations || !HasBit(p2, 5)) {
|
|
|
st = GetStationAround(tile, 1, 1, INVALID_STATION);
|
|
|
if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
|