|
@@ -801,12 +801,13 @@ static void DrawBridgeTramBits(int x, in
|
|
|
* </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)
|
|
|
{
|
|
|
SpriteID image;
|
|
|
DiagDirection tunnelbridge_direction = GetTunnelBridgeDirection(ti->tile);
|
|
|
|
|
|
if (IsTunnel(ti->tile)) {
|
|
|
/* Front view of tunnel bounding boxes:
|
|
|
*
|
|
|
* 122223 <- BB_Z_SEPARATOR
|
|
|
* 1 3
|
|
@@ -820,38 +821,37 @@ static void DrawTile_TunnelBridge(TileIn
|
|
|
* w h bb_x bb_y| x y w h |bb_x bb_y w h */
|
|
|
{ 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 }, // NE
|
|
|
{ 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 }, // SE
|
|
|
{ 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 }, // SW
|
|
|
{ 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 }, // NW
|
|
|
};
|
|
|
const int *BB_data = _tunnel_BB[GetTunnelBridgeDirection(ti->tile)];
|
|
|
const int *BB_data = _tunnel_BB[tunnelbridge_direction];
|
|
|
|
|
|
bool catenary = false;
|
|
|
|
|
|
if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
|
|
|
image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
|
|
|
} else {
|
|
|
image = SPR_TUNNEL_ENTRY_REAR_ROAD;
|
|
|
}
|
|
|
|
|
|
if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += 32;
|
|
|
|
|
|
image += GetTunnelBridgeDirection(ti->tile) * 2;
|
|
|
image += tunnelbridge_direction * 2;
|
|
|
DrawGroundSprite(image, PAL_NONE);
|
|
|
if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
|
|
|
DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
|
|
|
RoadTypes rts = GetRoadTypes(ti->tile);
|
|
|
|
|
|
if (HasBit(rts, ROADTYPE_TRAM)) {
|
|
|
static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, { 5, 76, 77, 4 } };
|
|
|
|
|
|
DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][dir], PAL_NONE);
|
|
|
DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][tunnelbridge_direction], PAL_NONE);
|
|
|
|
|
|
catenary = true;
|
|
|
StartSpriteCombine();
|
|
|
AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + dir, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
|
|
|
AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR);
|
|
|
}
|
|
|
} else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) {
|
|
|
DrawCatenary(ti);
|
|
|
|
|
|
catenary = true;
|
|
|
StartSpriteCombine();
|
|
@@ -879,16 +879,16 @@ static void DrawTile_TunnelBridge(TileIn
|
|
|
base_offset = 8;
|
|
|
}
|
|
|
|
|
|
/* as the lower 3 bits are used for other stuff, make sure they are clear */
|
|
|
assert( (base_offset & 0x07) == 0x00);
|
|
|
|
|
|
DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetTunnelBridgeDirection(ti->tile))));
|
|
|
DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(tunnelbridge_direction)));
|
|
|
|
|
|
/* HACK Wizardry to convert the bridge ramp direction into a sprite offset */
|
|
|
base_offset += (6 - GetTunnelBridgeDirection(ti->tile)) % 4;
|
|
|
base_offset += (6 - tunnelbridge_direction) % 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];
|
|
|
|
|
@@ -911,13 +911,13 @@ static void DrawTile_TunnelBridge(TileIn
|
|
|
);
|
|
|
|
|
|
if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
|
|
|
RoadTypes rts = GetRoadTypes(ti->tile);
|
|
|
|
|
|
if (HasBit(rts, ROADTYPE_TRAM)) {
|
|
|
uint offset = GetTunnelBridgeDirection(ti->tile);
|
|
|
uint offset = tunnelbridge_direction;
|
|
|
uint z = ti->z;
|
|
|
if (ti->tileh != SLOPE_FLAT) {
|
|
|
offset = (offset + 1) & 1;
|
|
|
z += TILE_HEIGHT;
|
|
|
} else {
|
|
|
offset += 2;
|
|
@@ -1226,22 +1226,21 @@ static const byte _tunnel_fractcoord_7[4
|
|
|
|
|
|
static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y)
|
|
|
{
|
|
|
int z = GetSlopeZ(x, y) - v->z_pos;
|
|
|
|
|
|
if (abs(z) > 2) return VETSB_CANNOT_ENTER;
|
|
|
const DiagDirection dir = GetTunnelBridgeDirection(tile);
|
|
|
|
|
|
if (IsTunnel(tile)) {
|
|
|
byte fc;
|
|
|
DiagDirection dir;
|
|
|
DiagDirection vdir;
|
|
|
|
|
|
if (v->type == VEH_TRAIN) {
|
|
|
fc = (x & 0xF) + (y << 4);
|
|
|
|
|
|
dir = GetTunnelBridgeDirection(tile);
|
|
|
vdir = DirToDiagDir(v->direction);
|
|
|
|
|
|
if (v->u.rail.track != TRACK_BIT_WORMHOLE && dir == vdir) {
|
|
|
if (IsFrontEngine(v) && fc == _tunnel_fractcoord_1[dir]) {
|
|
|
if (!PlayVehicleSound(v, VSE_TUNNEL) && RailVehInfo(v->engine_type)->engclass == 0) {
|
|
|
SndPlayVehicleFx(SND_05_TRAIN_THROUGH_TUNNEL, v);
|
|
@@ -1263,13 +1262,12 @@ static VehicleEnterTileStatus VehicleEnt
|
|
|
assert(v->u.rail.track);
|
|
|
v->vehstatus &= ~VS_HIDDEN;
|
|
|
return VETSB_ENTERED_WORMHOLE;
|
|
|
}
|
|
|
} else if (v->type == VEH_ROAD) {
|
|
|
fc = (x & 0xF) + (y << 4);
|
|
|
dir = GetTunnelBridgeDirection(tile);
|
|
|
vdir = DirToDiagDir(v->direction);
|
|
|
|
|
|
/* Enter tunnel? */
|
|
|
if (v->u.road.state != RVSB_WORMHOLE && dir == vdir) {
|
|
|
if (fc == _tunnel_fractcoord_4[dir] ||
|
|
|
fc == _tunnel_fractcoord_5[dir]) {
|
|
@@ -1293,23 +1291,21 @@ static VehicleEnterTileStatus VehicleEnt
|
|
|
v->u.road.frame = _road_exit_tunnel_frame[dir];
|
|
|
v->vehstatus &= ~VS_HIDDEN;
|
|
|
return VETSB_ENTERED_WORMHOLE;
|
|
|
}
|
|
|
}
|
|
|
} else { // IsBridge(tile)
|
|
|
DiagDirection dir;
|
|
|
|
|
|
if (v->IsPrimaryVehicle()) {
|
|
|
/* modify speed of vehicle */
|
|
|
uint16 spd = GetBridgeSpec(GetBridgeType(tile))->speed;
|
|
|
|
|
|
if (v->type == VEH_ROAD) spd *= 2;
|
|
|
if (v->cur_speed > spd) v->cur_speed = spd;
|
|
|
}
|
|
|
|
|
|
dir = GetTunnelBridgeDirection(tile);
|
|
|
if (DirToDiagDir(v->direction) == dir) {
|
|
|
switch (dir) {
|
|
|
default: NOT_REACHED();
|
|
|
case DIAGDIR_NE: if ((x & 0xF) != 0) return VETSB_CONTINUE; break;
|
|
|
case DIAGDIR_SE: if ((y & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break;
|
|
|
case DIAGDIR_SW: if ((x & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break;
|