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 27 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/road.h
Show inline comments
 
@@ -55,13 +55,13 @@ struct SpriteGroup;
 

	
 
/** Sprite groups for a roadtype. */
 
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
 
	ROTSG_reserved2,      ///<           Placeholder, if we need specific level crossing sprites.
 
	ROTSG_DEPOT,          ///< Optional: Depot images
 
	ROTSG_reserved3,      ///<           Placeholder, if we add road fences (for highways).
src/road_cmd.cpp
Show inline comments
 
@@ -1486,15 +1486,17 @@ static void DrawRoadDetail(SpriteID img,
 
 * Draw road underlay and overlay sprites.
 
 * @param ti TileInfo
 
 * @param road_rti Road road type information
 
 * @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)
 
{
 
	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);
 
		}
 
@@ -1503,12 +1505,13 @@ void DrawRoadOverlays(const TileInfo *ti
 
			SpriteID ground = GetCustomRoadSprite(tram_rti, ti->tile, ROTSG_GROUND);
 
			DrawGroundSprite(ground + tram_offset, pal);
 
		} else {
 
			DrawGroundSprite(SPR_TRAMWAY_TRAM + tram_offset, pal);
 
		}
 
	}
 
	}
 

	
 
	/* Draw road overlay */
 
	if (road_rti != nullptr) {
 
		if (road_rti->UsesOverlay()) {
 
			SpriteID ground = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_OVERLAY);
 
			if (ground != 0) DrawGroundSprite(ground + road_offset, pal);
src/road_func.h
Show inline comments
 
@@ -155,9 +155,9 @@ RoadTypes AddDateIntroducedRoadTypes(Roa
 

	
 
void UpdateLevelCrossing(TileIndex tile, bool sound = true, bool force_bar = false);
 
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 */
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1304,14 +1304,34 @@ static void DrawTile_TunnelBridge(TileIn
 
		if (transport_type == TRANSPORT_ROAD) {
 
			RoadType road_rt = GetRoadTypeRoad(ti->tile);
 
			RoadType tram_rt = GetRoadTypeTram(ti->tile);
 
			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;
 
			if (road_rti != nullptr && HasRoadCatenaryDrawn(road_rt)) {
 
				catenary_sprite_base = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_CATENARY_FRONT);
 
				if (catenary_sprite_base == 0) {
0 comments (0 inline, 0 general)