(svn r22960) -Feature: Allow depots, standard roadstops and airports on steep slopes.
This commit is contained in:
@@ -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: {
|
||||
|
Reference in New Issue
Block a user