Changeset - r26650:a3a9730bcdc8
[Not reviewed]
master
0 4 0
Loïc Guilloux - 21 months ago 2022-12-17 14:01:47
glx22@users.noreply.github.com
Fix #10208: allow to use specific underlay for road/tram tunnels (#10233)
4 files changed with 38 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/road.h
Show inline comments
 
@@ -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
src/road_cmd.cpp
Show inline comments
 
@@ -1489,21 +1489,24 @@ static void DrawRoadDetail(SpriteID img,
 
 * @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);
 
			}
 
		}
 
	}
 

	
src/road_func.h
Show inline comments
 
@@ -158,6 +158,6 @@ void MarkDirtyAdjacentLevelCrossingTiles
 
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 */
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1307,8 +1307,28 @@ static void DrawTile_TunnelBridge(TileIn
 
			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;
 

	
 
			DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
 
			/* 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, draw_underlay);
 

	
 
			/* Road catenary takes precedence over tram */
 
			SpriteID catenary_sprite_base = 0;
0 comments (0 inline, 0 general)