Fix #10208: allow to use specific underlay for road/tram tunnels (#10233)

This commit is contained in:
Loïc Guilloux
2022-12-17 15:01:47 +01:00
committed by GitHub
parent 131b7f5127
commit c50fabb574
4 changed files with 38 additions and 15 deletions

View File

@@ -1489,21 +1489,24 @@ static void DrawRoadDetail(SpriteID img, const TileInfo *ti, int dx, int dy, int
* @param tram_rti Tram road type information
* @param road_offset Road sprite offset (based on road bits)
* @param tram_offset Tram sprite offset (based on road bits)
* @param draw_underlay Whether to draw underlays
*/
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, uint road_offset, uint tram_offset)
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, uint road_offset, uint tram_offset, bool draw_underlay)
{
/* Road underlay takes precedence over tram */
if (road_rti != nullptr) {
if (road_rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_GROUND);
DrawGroundSprite(ground + road_offset, pal);
}
} else {
if (tram_rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(tram_rti, ti->tile, ROTSG_GROUND);
DrawGroundSprite(ground + tram_offset, pal);
if (draw_underlay) {
/* Road underlay takes precedence over tram */
if (road_rti != nullptr) {
if (road_rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_GROUND);
DrawGroundSprite(ground + road_offset, pal);
}
} else {
DrawGroundSprite(SPR_TRAMWAY_TRAM + tram_offset, pal);
if (tram_rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(tram_rti, ti->tile, ROTSG_GROUND);
DrawGroundSprite(ground + tram_offset, pal);
} else {
DrawGroundSprite(SPR_TRAMWAY_TRAM + tram_offset, pal);
}
}
}