From 9101d2e2d2d6c80506f089d6dae418a8c4b9257c Mon Sep 17 00:00:00 2001 From: michi_cc Date: Wed, 15 Feb 2012 21:23:48 +0000 Subject: (svn r23952) -Feature: [NewGRF] Customisable tunnel portals for rail types (sprites by Snail). --- src/tunnelbridge_cmd.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/tunnelbridge_cmd.cpp') 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); -- cgit v1.2.3-54-g00ecf