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

pull/461/head
Loïc Guilloux 1 year ago committed by GitHub
parent 131b7f5127
commit c50fabb574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,7 +58,7 @@ enum RoadTypeSpriteGroup {
ROTSG_CURSORS, ///< Optional: Cursor and toolbar icon images
ROTSG_OVERLAY, ///< Optional: Images for overlaying track
ROTSG_GROUND, ///< Required: Main group of ground images
ROTSG_reserved1, ///< Placeholder, if we need specific tunnel sprites.
ROTSG_TUNNEL, ///< Optional: Ground images for tunnels
ROTSG_CATENARY_FRONT, ///< Optional: Catenary front
ROTSG_CATENARY_BACK, ///< Optional: Catenary back
ROTSG_BRIDGE, ///< Required: Bridge surface images

@ -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);
}
}
}

@ -158,6 +158,6 @@ void MarkDirtyAdjacentLevelCrossingTiles(TileIndex tile, Axis road_axis);
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count);
struct TileInfo;
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rit, uint road_offset, uint tram_offset);
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rit, uint road_offset, uint tram_offset, bool draw_underlay = true);
#endif /* ROAD_FUNC_H */

@ -1307,8 +1307,28 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
const RoadTypeInfo *road_rti = road_rt == INVALID_ROADTYPE ? nullptr : GetRoadTypeInfo(road_rt);
const RoadTypeInfo *tram_rti = tram_rt == INVALID_ROADTYPE ? nullptr : GetRoadTypeInfo(tram_rt);
uint sprite_offset = DiagDirToAxis(tunnelbridge_direction) == AXIS_X ? 1 : 0;
bool draw_underlay = true;
/* Road underlay takes precedence over tram */
if (road_rti != nullptr) {
if (road_rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_TUNNEL);
if (ground != 0) {
DrawGroundSprite(ground + tunnelbridge_direction, PAL_NONE);
draw_underlay = false;
}
}
} else {
if (tram_rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(tram_rti, ti->tile, ROTSG_TUNNEL);
if (ground != 0) {
DrawGroundSprite(ground + tunnelbridge_direction, PAL_NONE);
draw_underlay = false;
}
}
}
DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset, draw_underlay);
/* Road catenary takes precedence over tram */
SpriteID catenary_sprite_base = 0;

Loading…
Cancel
Save