|
@@ -854,44 +854,29 @@ static void DrawBridgePillars(const PalS
|
|
|
*/
|
|
|
if (z >= front_height) { // front facing pillar
|
|
|
AddSortableSpriteToDraw(image, psid->pal, x, y, p[4], p[5], 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
|
|
|
}
|
|
|
|
|
|
if (drawfarpillar && z >= back_height && z < i - TILE_HEIGHT) { // back facing pillar
|
|
|
AddSortableSpriteToDraw(image, psid->pal, x - p[6], y - p[7], p[4], p[5], 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
uint GetBridgeFoundation(Slope tileh, Axis axis)
|
|
|
Foundation GetBridgeFoundation(Slope tileh, Axis axis)
|
|
|
{
|
|
|
uint i;
|
|
|
|
|
|
if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) return tileh;
|
|
|
|
|
|
/* inclined sloped building */
|
|
|
switch (tileh) {
|
|
|
case SLOPE_W:
|
|
|
case SLOPE_STEEP_W: i = 0; break;
|
|
|
case SLOPE_S:
|
|
|
case SLOPE_STEEP_S: i = 2; break;
|
|
|
case SLOPE_E:
|
|
|
case SLOPE_STEEP_E: i = 4; break;
|
|
|
case SLOPE_N:
|
|
|
case SLOPE_STEEP_N: i = 6; break;
|
|
|
default: return 0;
|
|
|
}
|
|
|
if (axis != AXIS_X) ++i;
|
|
|
return i + 15;
|
|
|
if (HASBIT(BRIDGE_NO_FOUNDATION, tileh)) return FOUNDATION_NONE;
|
|
|
if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) return FlatteningFoundation(tileh);
|
|
|
return InclinedFoundation(axis);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Draws the trambits over an already drawn (lower end) of a bridge.
|
|
|
* @param x the x of the bridge
|
|
|
* @param y the y of the bridge
|
|
|
* @param z the z of the bridge
|
|
|
* @param offset number representing whether to level or sloped and the direction
|
|
|
* @param overlay do we want to still see the road?
|
|
|
*/
|
|
|
static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay)
|
|
|
{
|
|
@@ -959,28 +944,25 @@ static void DrawTile_TunnelBridge(TileIn
|
|
|
bool ice = HasBridgeSnowOrDesert(ti->tile);
|
|
|
|
|
|
if (GetBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
|
|
|
base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset;
|
|
|
assert(base_offset != 8); // This one is used for roads
|
|
|
} else {
|
|
|
base_offset = 8;
|
|
|
}
|
|
|
|
|
|
/* as the lower 3 bits are used for other stuff, make sure they are clear */
|
|
|
assert( (base_offset & 0x07) == 0x00);
|
|
|
|
|
|
if (!HASBIT(BRIDGE_NO_FOUNDATION, ti->tileh)) {
|
|
|
int f = GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetBridgeRampDirection(ti->tile)));
|
|
|
if (f != 0) DrawFoundation(ti, f);
|
|
|
}
|
|
|
DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetBridgeRampDirection(ti->tile))));
|
|
|
|
|
|
/* HACK Wizardry to convert the bridge ramp direction into a sprite offset */
|
|
|
base_offset += (6 - GetBridgeRampDirection(ti->tile)) % 4;
|
|
|
|
|
|
if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head
|
|
|
|
|
|
/* Table number 6 always refers to the bridge heads for any bridge type */
|
|
|
psid = &GetBridgeSpriteTable(GetBridgeType(ti->tile), 6)[base_offset];
|
|
|
|
|
|
if (!ice) {
|
|
|
DrawClearLandTile(ti, 3);
|
|
|
} else {
|
|
@@ -1147,72 +1129,49 @@ static uint GetSlopeZ_TunnelBridge(TileI
|
|
|
x &= 0xF;
|
|
|
y &= 0xF;
|
|
|
|
|
|
if (IsTunnel(tile)) {
|
|
|
uint pos = (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? y : x);
|
|
|
|
|
|
/* In the tunnel entrance? */
|
|
|
if (5 <= pos && pos <= 10) return z;
|
|
|
} else {
|
|
|
DiagDirection dir = GetBridgeRampDirection(tile);
|
|
|
uint pos = (DiagDirToAxis(dir) == AXIS_X ? y : x);
|
|
|
|
|
|
z += ApplyFoundationToSlope(GetBridgeFoundation(tileh, DiagDirToAxis(dir)), &tileh);
|
|
|
|
|
|
/* On the bridge ramp? */
|
|
|
if (5 <= pos && pos <= 10) {
|
|
|
uint delta;
|
|
|
|
|
|
if (IsSteepSlope(tileh)) return z + TILE_HEIGHT * 2;
|
|
|
if (HASBIT(BRIDGE_HORZ_RAMP, tileh)) return z + TILE_HEIGHT;
|
|
|
|
|
|
if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) 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;
|
|
|
} else {
|
|
|
uint f = GetBridgeFoundation(tileh, DiagDirToAxis(dir));
|
|
|
|
|
|
if (f != 0) {
|
|
|
if (IsSteepSlope(tileh)) {
|
|
|
z += TILE_HEIGHT;
|
|
|
} else if (f < 15) {
|
|
|
return z + TILE_HEIGHT;
|
|
|
}
|
|
|
tileh = (Slope)_inclined_tileh[f - 15];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return z + GetPartialZ(x, y, tileh);
|
|
|
}
|
|
|
|
|
|
static Slope GetSlopeTileh_TunnelBridge(TileIndex tile, Slope tileh)
|
|
|
static Foundation GetFoundation_TunnelBridge(TileIndex tile, Slope tileh)
|
|
|
{
|
|
|
if (IsTunnel(tile)) {
|
|
|
return tileh;
|
|
|
} else {
|
|
|
if (HASBIT(BRIDGE_NO_FOUNDATION, tileh)) {
|
|
|
return tileh;
|
|
|
} else {
|
|
|
uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(tile)));
|
|
|
|
|
|
if (f == 0) return tileh;
|
|
|
if (f < 15) return SLOPE_FLAT;
|
|
|
return (Slope)_inclined_tileh[f - 15];
|
|
|
}
|
|
|
}
|
|
|
return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(tile)));
|
|
|
}
|
|
|
|
|
|
|
|
|
static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac)
|
|
|
{
|
|
|
/* not used */
|
|
|
}
|
|
|
|
|
|
static const StringID _bridge_tile_str[(MAX_BRIDGES + 3) + (MAX_BRIDGES + 3)] = {
|
|
|
STR_501F_WOODEN_RAIL_BRIDGE,
|
|
|
STR_5020_CONCRETE_RAIL_BRIDGE,
|
|
|
STR_501C_STEEL_GIRDER_RAIL_BRIDGE,
|
|
@@ -1466,14 +1425,14 @@ extern const TileTypeProcs _tile_type_tu
|
|
|
DrawTile_TunnelBridge, /* draw_tile_proc */
|
|
|
GetSlopeZ_TunnelBridge, /* get_slope_z_proc */
|
|
|
ClearTile_TunnelBridge, /* clear_tile_proc */
|
|
|
GetAcceptedCargo_TunnelBridge, /* 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 */
|
|
|
GetSlopeTileh_TunnelBridge, /* get_slope_tileh_proc */
|
|
|
GetFoundation_TunnelBridge, /* get_foundation_proc */
|
|
|
};
|