diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf.cpp | 1 | ||||
-rw-r--r-- | src/rail.h | 1 | ||||
-rw-r--r-- | src/table/sprites.h | 6 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 17 |
4 files changed, 21 insertions, 4 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index cce56ccaa..feccc2363 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5458,6 +5458,7 @@ static const Action5Type _action5_types[] = { /* 0x14 */ { A5BLOCK_ALLOW_OFFSET, SPR_FLAGS_BASE, 1, FLAGS_SPRITE_COUNT, "Flag graphics" }, /* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE, 1, OPENTTD_SPRITE_COUNT, "OpenTTD GUI graphics" }, /* 0x16 */ { A5BLOCK_ALLOW_OFFSET, SPR_AIRPORT_PREVIEW_BASE, 1, SPR_AIRPORT_PREVIEW_COUNT, "Airport preview graphics" }, + /* 0x17 */ { A5BLOCK_ALLOW_OFFSET, SPR_RAILTYPE_TUNNEL_BASE, 1, RAILTYPE_TUNNEL_BASE_COUNT, "Railtype tunnel base" }, }; /* Action 0x05 */ diff --git a/src/rail.h b/src/rail.h index 03bc69364..eb0b46c4c 100644 --- a/src/rail.h +++ b/src/rail.h @@ -46,6 +46,7 @@ enum RailTypeSpriteGroup { RTSG_CROSSING, ///< Level crossing overlay images RTSG_DEPOT, ///< Depot images RTSG_FENCES, ///< Fence images + RTSG_TUNNEL_PORTAL, ///< Tunnel portal overlay RTSG_END, }; diff --git a/src/table/sprites.h b/src/table/sprites.h index 4953070b3..8320e2c52 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -270,8 +270,12 @@ static const uint16 ONEWAY_SPRITE_COUNT = 6; static const SpriteID SPR_FLAGS_BASE = SPR_ONEWAY_BASE + ONEWAY_SPRITE_COUNT; static const uint16 FLAGS_SPRITE_COUNT = 36; +/** Tunnel sprites with grass only for custom railtype tunnel. */ +static const SpriteID SPR_RAILTYPE_TUNNEL_BASE = SPR_FLAGS_BASE + FLAGS_SPRITE_COUNT; +static const uint16 RAILTYPE_TUNNEL_BASE_COUNT = 16; + /* Not really a sprite, but an empty bounding box. Used to construct bounding boxes that help sorting the sprites, but do not have a sprite associated. */ -static const SpriteID SPR_EMPTY_BOUNDING_BOX = SPR_FLAGS_BASE + FLAGS_SPRITE_COUNT; +static const SpriteID SPR_EMPTY_BOUNDING_BOX = SPR_RAILTYPE_TUNNEL_BASE + RAILTYPE_TUNNEL_BASE_COUNT; static const uint16 EMPTY_BOUNDING_BOX_SPRITE_COUNT = 1; /* From where can we start putting NewGRFs? */ diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 797aa4725..945563fb5 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -1115,13 +1115,20 @@ static void DrawTile_TunnelBridge(TileInfo *ti) bool catenary = false; SpriteID image; + SpriteID railtype_overlay = 0; if (transport_type == TRANSPORT_RAIL) { - image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel; + const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); + image = rti->base_sprites.tunnel; + if (rti->UsesOverlay()) { + /* Check if the railtype has custom tunnel portals. */ + railtype_overlay = GetCustomRailSprite(rti, ti->tile, RTSG_TUNNEL_PORTAL); + if (railtype_overlay != 0) image = SPR_RAILTYPE_TUNNEL_BASE; // Draw blank grass tunnel base. + } } else { image = SPR_TUNNEL_ENTRY_REAR_ROAD; } - if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += 32; + if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += railtype_overlay != 0 ? 8 : 32; image += tunnelbridge_direction * 2; DrawGroundSprite(image, PAL_NONE); @@ -1164,9 +1171,13 @@ static void DrawTile_TunnelBridge(TileInfo *ti) } } + if (railtype_overlay != 0 && !catenary) StartSpriteCombine(); + AddSortableSpriteToDraw(image + 1, PAL_NONE, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, BB_data[0], BB_data[1], TILE_HEIGHT, ti->z, false, BB_data[2], BB_data[3], BB_Z_SEPARATOR); + /* Draw railtype tunnel portal overlay if defined. */ + if (railtype_overlay != 0) AddSortableSpriteToDraw(railtype_overlay + tunnelbridge_direction, PAL_NONE, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, BB_data[0], BB_data[1], TILE_HEIGHT, ti->z, false, BB_data[2], BB_data[3], BB_Z_SEPARATOR); - if (catenary) EndSpriteCombine(); + if (catenary || railtype_overlay != 0) EndSpriteCombine(); /* Add helper BB for sprite sorting that separates the tunnel from things beside of it. */ AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, ti->x, ti->y, BB_data[6], BB_data[7], TILE_HEIGHT, ti->z); |