|
@@ -208,13 +208,13 @@ CommandCost CmdBuildBridge(TileIndex end
|
|
|
RailType railtype = INVALID_RAILTYPE;
|
|
|
RoadTypes roadtypes = ROADTYPES_NONE;
|
|
|
|
|
|
/* unpack parameters */
|
|
|
BridgeType bridge_type = GB(p2, 0, 8);
|
|
|
|
|
|
if (p1 >= MapSize()) return CMD_ERROR;
|
|
|
if (!IsValidTile(p1)) return CMD_ERROR;
|
|
|
|
|
|
TransportType transport_type = Extract<TransportType, 15, 2>(p2);
|
|
|
|
|
|
/* type of bridge */
|
|
|
switch (transport_type) {
|
|
|
case TRANSPORT_ROAD:
|
|
@@ -267,12 +267,14 @@ CommandCost CmdBuildBridge(TileIndex end
|
|
|
Slope tileh_end = GetTileSlope(tile_end, &z_end);
|
|
|
bool pbs_reservation = false;
|
|
|
|
|
|
CommandCost terraform_cost_north = CheckBridgeSlopeNorth(direction, &tileh_start, &z_start);
|
|
|
CommandCost terraform_cost_south = CheckBridgeSlopeSouth(direction, &tileh_end, &z_end);
|
|
|
|
|
|
/* Aqueducts can't be built of flat land. */
|
|
|
if (transport_type == TRANSPORT_WATER && (tileh_start == SLOPE_FLAT || tileh_end == SLOPE_FLAT)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
|
|
if (z_start != z_end) return_cmd_error(STR_ERROR_BRIDGEHEADS_NOT_SAME_HEIGHT);
|
|
|
|
|
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
|
|
Owner owner;
|
|
|
if (IsBridgeTile(tile_start) && IsBridgeTile(tile_end) &&
|
|
|
GetOtherBridgeEnd(tile_start) == tile_end &&
|
|
@@ -342,14 +344,12 @@ CommandCost CmdBuildBridge(TileIndex end
|
|
|
cost.AddCost(ret);
|
|
|
|
|
|
/* false - end tile slope check */
|
|
|
if (terraform_cost_south.Failed() || (terraform_cost_south.GetCost() != 0 && !allow_on_slopes)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
|
|
cost.AddCost(terraform_cost_south);
|
|
|
|
|
|
if (transport_type == TRANSPORT_WATER && (tileh_start == SLOPE_FLAT || tileh_end == SLOPE_FLAT)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
|
|
|
|
|
const TileIndex heads[] = {tile_start, tile_end};
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
if (MayHaveBridgeAbove(heads[i])) {
|
|
|
if (IsBridgeAbove(heads[i])) {
|
|
|
TileIndex north_head = GetNorthernBridgeEnd(heads[i]);
|
|
|
|