|
@@ -1226,54 +1226,48 @@ static uint GetSlopeZ_TunnelBridge(TileI
|
|
|
if (5 <= pos && pos <= 10) {
|
|
|
uint delta;
|
|
|
|
|
|
if (tileh != SLOPE_FLAT) return z + TILE_HEIGHT;
|
|
|
|
|
|
switch (dir) {
|
|
|
default: NOT_REACHED();
|
|
|
case DIAGDIR_NE: delta = (TILE_SIZE - 1 - x) / 2; break;
|
|
|
case DIAGDIR_SE: delta = y / 2; break;
|
|
|
case DIAGDIR_SW: delta = x / 2; break;
|
|
|
case DIAGDIR_NW: delta = (TILE_SIZE - 1 - y) / 2; break;
|
|
|
}
|
|
|
return z + 1 + delta;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return z + GetPartialZ(x, y, tileh);
|
|
|
}
|
|
|
|
|
|
static Foundation GetFoundation_TunnelBridge(TileIndex tile, Slope tileh)
|
|
|
{
|
|
|
return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(tile)));
|
|
|
}
|
|
|
|
|
|
|
|
|
static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac)
|
|
|
{
|
|
|
/* not used */
|
|
|
}
|
|
|
|
|
|
static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td)
|
|
|
{
|
|
|
TransportType tt = GetTunnelBridgeTransportType(tile);
|
|
|
|
|
|
if (IsTunnel(tile)) {
|
|
|
td->str = (tt == TRANSPORT_RAIL) ? STR_TUNNEL_DESCRIPTION_RAILROAD : STR_TUNNEL_DESCRIPTION_ROAD;
|
|
|
} else { // IsBridge(tile)
|
|
|
td->str = (tt == TRANSPORT_WATER) ? STR_BRIDGE_DESCRIPTION_AQUEDUCT : GetBridgeSpec(GetBridgeType(tile))->transport_name[tt];
|
|
|
}
|
|
|
td->owner[0] = GetTileOwner(tile);
|
|
|
|
|
|
Owner road_owner = INVALID_OWNER;
|
|
|
Owner tram_owner = INVALID_OWNER;
|
|
|
RoadTypes rts = GetRoadTypes(tile);
|
|
|
if (HasBit(rts, ROADTYPE_ROAD)) road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
|
|
|
if (HasBit(rts, ROADTYPE_TRAM)) tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM);
|
|
|
|
|
|
/* Is there a mix of owners? */
|
|
|
if ((tram_owner != INVALID_OWNER && tram_owner != td->owner[0]) ||
|
|
|
(road_owner != INVALID_OWNER && road_owner != td->owner[0])) {
|
|
|
uint i = 1;
|
|
|
if (road_owner != INVALID_OWNER) {
|
|
|
td->owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
|
|
|
td->owner[i] = road_owner;
|
|
@@ -1525,36 +1519,36 @@ static CommandCost TerraformTile_TunnelB
|
|
|
CommandCost res;
|
|
|
uint z_old;
|
|
|
Slope tileh_old = GetTileSlope(tile, &z_old);
|
|
|
|
|
|
/* Check if new slope is valid for bridges in general (so we can safely call GetBridgeFoundation()) */
|
|
|
if ((direction == DIAGDIR_NW) || (direction == DIAGDIR_NE)) {
|
|
|
CheckBridgeSlopeSouth(axis, &tileh_old, &z_old);
|
|
|
res = CheckBridgeSlopeSouth(axis, &tileh_new, &z_new);
|
|
|
} else {
|
|
|
CheckBridgeSlopeNorth(axis, &tileh_old, &z_old);
|
|
|
res = CheckBridgeSlopeNorth(axis, &tileh_new, &z_new);
|
|
|
}
|
|
|
|
|
|
/* Surface slope is valid and remains unchanged? */
|
|
|
if (!CmdFailed(res) && (z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
|
|
|
}
|
|
|
|
|
|
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
}
|
|
|
|
|
|
extern const TileTypeProcs _tile_type_tunnelbridge_procs = {
|
|
|
DrawTile_TunnelBridge, // draw_tile_proc
|
|
|
GetSlopeZ_TunnelBridge, // get_slope_z_proc
|
|
|
ClearTile_TunnelBridge, // clear_tile_proc
|
|
|
GetAcceptedCargo_TunnelBridge, // get_accepted_cargo_proc
|
|
|
NULL, // get_accepted_cargo_proc
|
|
|
GetTileDesc_TunnelBridge, // get_tile_desc_proc
|
|
|
GetTileTrackStatus_TunnelBridge, // get_tile_track_status_proc
|
|
|
ClickTile_TunnelBridge, // click_tile_proc
|
|
|
AnimateTile_TunnelBridge, // animate_tile_proc
|
|
|
TileLoop_TunnelBridge, // tile_loop_clear
|
|
|
ChangeTileOwner_TunnelBridge, // change_tile_owner_clear
|
|
|
NULL, // get_produced_cargo_proc
|
|
|
VehicleEnter_TunnelBridge, // vehicle_enter_tile_proc
|
|
|
GetFoundation_TunnelBridge, // get_foundation_proc
|
|
|
TerraformTile_TunnelBridge, // terraform_tile_proc
|
|
|
};
|