|
@@ -873,112 +873,112 @@ static void DrawBridgePillars(PalSpriteI
|
|
|
|
|
|
p = _tileh_bits[(image & 1) * 2 + (axis == AXIS_X ? 0 : 1)];
|
|
|
front_height = ti->z + (ti->tileh & p[0] ? TILE_HEIGHT : 0);
|
|
|
back_height = ti->z + (ti->tileh & p[1] ? TILE_HEIGHT : 0);
|
|
|
|
|
|
if (IsSteepSlope(ti->tileh)) {
|
|
|
if (!(ti->tileh & p[2])) front_height += TILE_HEIGHT;
|
|
|
if (!(ti->tileh & p[3])) back_height += TILE_HEIGHT;
|
|
|
}
|
|
|
|
|
|
for (; z >= front_height || z >= back_height; z -= TILE_HEIGHT) {
|
|
|
/* HACK set height of the BB of pillars to 1, because the origin of the
|
|
|
* sprites is at the top
|
|
|
*/
|
|
|
if (z >= front_height) { // front facing pillar
|
|
|
AddSortableSpriteToDraw(image, x, y, p[4], p[5], 1, z);
|
|
|
}
|
|
|
|
|
|
if (drawfarpillar && z >= back_height && z < i - TILE_HEIGHT) { // back facing pillar
|
|
|
AddSortableSpriteToDraw(image, x - p[6], y - p[7], p[4], p[5], 1, z);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
uint 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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Draws a tunnel of bridge tile.
|
|
|
* For tunnels, this is rather simple, as you only needa draw the entrance.
|
|
|
* Bridges are a bit more complex. base_offset is where the sprite selection comes into play
|
|
|
* and it works a bit like a bitmask.<p> For bridge heads:
|
|
|
* <ul><li>Bit 0: direction</li>
|
|
|
* <li>Bit 1: northern or southern heads</li>
|
|
|
* <li>Bit 2: Set if the bridge head is sloped</li>
|
|
|
* <li>Bit 3 and more: Railtype Specific subset</li>
|
|
|
* </ul>
|
|
|
* For middle parts:
|
|
|
* <ul><li>Bits 0-1: need to be 0</li>
|
|
|
* <li>Bit 2: direction</li>
|
|
|
* <li>Bit 3 and above: Railtype Specific subset</li>
|
|
|
* </ul>
|
|
|
* Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3
|
|
|
*/
|
|
|
* Draws a tunnel of bridge tile.
|
|
|
* For tunnels, this is rather simple, as you only needa draw the entrance.
|
|
|
* Bridges are a bit more complex. base_offset is where the sprite selection comes into play
|
|
|
* and it works a bit like a bitmask.<p> For bridge heads:
|
|
|
* <ul><li>Bit 0: direction</li>
|
|
|
* <li>Bit 1: northern or southern heads</li>
|
|
|
* <li>Bit 2: Set if the bridge head is sloped</li>
|
|
|
* <li>Bit 3 and more: Railtype Specific subset</li>
|
|
|
* </ul>
|
|
|
* For middle parts:
|
|
|
* <ul><li>Bits 0-1: need to be 0</li>
|
|
|
* <li>Bit 2: direction</li>
|
|
|
* <li>Bit 3 and above: Railtype Specific subset</li>
|
|
|
* </ul>
|
|
|
* Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3
|
|
|
*/
|
|
|
static void DrawTile_TunnelBridge(TileInfo *ti)
|
|
|
{
|
|
|
uint32 image;
|
|
|
const PalSpriteID *b;
|
|
|
bool ice = _m[ti->tile].m4 & 0x80;
|
|
|
|
|
|
if (IsTunnel(ti->tile)) {
|
|
|
if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) {
|
|
|
image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
|
|
|
} else {
|
|
|
image = SPR_TUNNEL_ENTRY_REAR_ROAD;
|
|
|
}
|
|
|
|
|
|
if (ice) image += 32;
|
|
|
|
|
|
image += GetTunnelDirection(ti->tile) * 2;
|
|
|
DrawGroundSprite(image);
|
|
|
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
|
|
|
|
|
|
AddSortableSpriteToDraw(image+1, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, 1, 1, 8, (byte)ti->z);
|
|
|
} else if (IsBridge(ti->tile)) { // XXX is this necessary?
|
|
|
int base_offset;
|
|
|
|
|
|
if (GetBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
|
|
|
RailType rt;
|
|
|
|
|
|
if (IsBridgeRamp(ti->tile)) {
|
|
|
rt = GetRailType(ti->tile);
|
|
|
} else {
|
|
|
rt = GetRailTypeOnBridge(ti->tile);
|
|
|
}
|
|
|
|
|
|
base_offset = GetRailTypeInfo(rt)->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 (IsBridgeRamp(ti->tile)) {
|
|
|
if (!HASBIT(BRIDGE_NO_FOUNDATION, ti->tileh)) {
|
|
|
int f = GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetBridgeRampDirection(ti->tile)));
|
|
|
if (f) DrawFoundation(ti, f);
|
|
|
}
|
|
|
|
|
|
// HACK Wizardry to convert the bridge ramp direction into a sprite offset
|