diff options
author | frosch <frosch@openttd.org> | 2011-09-25 13:35:17 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-09-25 13:35:17 +0000 |
commit | 8d5c1479f417dc8a79997a6c4a1b357fb30a9411 (patch) | |
tree | 05f340e63c07d081cb44f5a7b6424b874e812057 /src/station_cmd.cpp | |
parent | fa1f8b309e13aa2872f6c520c0bcb121e559eb6b (diff) | |
download | openttd-8d5c1479f417dc8a79997a6c4a1b357fb30a9411.tar.xz |
(svn r22960) -Feature: Allow depots, standard roadstops and airports on steep slopes.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 452dbe9da..5f140365b 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -672,10 +672,11 @@ CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags); * @param tile TileIndex to check. * @param invalid_dirs Prohibited directions for slopes (set of #DiagDirection). * @param allowed_z Height allowed for the tile. If allowed_z is negative, it will be set to the height of this tile. + * @param allow_steep Whether steep slopes are allowed. * @param check_bridge Check for the existance of a bridge. * @return The cost in case of success, or an error code if it failed. */ -CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z, bool check_bridge = true) +CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge = true) { if (check_bridge && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) { return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); @@ -691,23 +692,21 @@ CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z * 1) The tile is "steep" (i.e. stretches two height levels). * 2) The tile is non-flat and the build_on_slopes switch is disabled. */ - if (IsSteepSlope(tileh) || + if ((!allow_steep && IsSteepSlope(tileh)) || ((!_settings_game.construction.build_on_slopes) && tileh != SLOPE_FLAT)) { return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); } CommandCost cost(EXPENSES_CONSTRUCTION); - int flat_z = z; + int flat_z = z + GetSlopeMaxZ(tileh); if (tileh != SLOPE_FLAT) { /* Forbid building if the tile faces a slope in a invalid direction. */ - if ((HasBit(invalid_dirs, DIAGDIR_NE) && !(tileh & SLOPE_NE)) || - (HasBit(invalid_dirs, DIAGDIR_SE) && !(tileh & SLOPE_SE)) || - (HasBit(invalid_dirs, DIAGDIR_SW) && !(tileh & SLOPE_SW)) || - (HasBit(invalid_dirs, DIAGDIR_NW) && !(tileh & SLOPE_NW))) { - return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); + for (DiagDirection dir = DIAGDIR_BEGIN; dir != DIAGDIR_END; dir++) { + if (HasBit(invalid_dirs, dir) && !CanBuildDepotByTileh(dir, tileh)) { + return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); + } } cost.AddCost(_price[PR_BUILD_FOUNDATION]); - flat_z += TILE_HEIGHT; } /* The level of this tile must be equal to allowed_z. */ @@ -733,7 +732,7 @@ CommandCost CheckFlatLand(TileArea tile_area, DoCommandFlag flags) int allowed_z = -1; TILE_AREA_LOOP(tile_cur, tile_area) { - CommandCost ret = CheckBuildableTile(tile_cur, 0, allowed_z); + CommandCost ret = CheckBuildableTile(tile_cur, 0, allowed_z, true); if (ret.Failed()) return ret; cost.AddCost(ret); @@ -769,7 +768,7 @@ static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag fl bool slope_cb = statspec != NULL && HasBit(statspec->callback_mask, CBM_STATION_SLOPE_CHECK); TILE_AREA_LOOP(tile_cur, tile_area) { - CommandCost ret = CheckBuildableTile(tile_cur, invalid_dirs, allowed_z); + CommandCost ret = CheckBuildableTile(tile_cur, invalid_dirs, allowed_z, false); if (ret.Failed()) return ret; cost.AddCost(ret); @@ -851,7 +850,7 @@ static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags int allowed_z = -1; TILE_AREA_LOOP(cur_tile, tile_area) { - CommandCost ret = CheckBuildableTile(cur_tile, invalid_dirs, allowed_z); + CommandCost ret = CheckBuildableTile(cur_tile, invalid_dirs, allowed_z, !is_drive_through); if (ret.Failed()) return ret; cost.AddCost(ret); @@ -3586,7 +3585,7 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, ui /* TODO: If you implement newgrf callback 149 'land slope check', you have to decide what to do with it here. * TTDP does not call it. */ - if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) { + if (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) { switch (GetStationType(tile)) { case STATION_WAYPOINT: case STATION_RAIL: { |