Changeset - r25038:e3007a7a86a5
[Not reviewed]
master
0 1 0
frosch - 3 years ago 2021-03-10 21:49:56
frosch@openttd.org
Fix #8647: draw tram catenary using 4 bounding boxes.
The back sprite is now supposed to contain west, north and east pillars.
The front sprite is supposed to contain the south pillar and the wires.
1 file changed with 17 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/road_cmd.cpp
Show inline comments
 
@@ -1423,8 +1423,23 @@ void DrawRoadTypeCatenary(const TileInfo
 
	 * For tiles with OWNER_TOWN or OWNER_NONE, recolour CC to grey as a neutral colour. */
 
	Owner owner = GetRoadOwner(ti->tile, GetRoadTramType(rt));
 
	PaletteID pal = (owner == OWNER_NONE || owner == OWNER_TOWN ? GENERAL_SPRITE_COLOUR(COLOUR_GREY) : COMPANY_SPRITE_COLOUR(owner));
 
	if (back != 0) AddSortableSpriteToDraw(back,  pal, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY));
 
	if (front != 0) AddSortableSpriteToDraw(front, pal, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY));
 
	int z_wires = (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT) + BB_HEIGHT_UNDER_BRIDGE;
 
	if (back != 0) {
 
		/* The "back" sprite contains the west, north and east pillars.
 
		 * We cut the sprite at 3/8 of the west/east edges to create 3 sprites.
 
		 * 3/8 is chosen so that sprites can somewhat graphically extend into the tile. */
 
		static const int INF = 1000; ///< big number compared to sprite size
 
		static const SubSprite west  = { -INF, -INF, -12, INF };
 
		static const SubSprite north = {  -12, -INF,  12, INF };
 
		static const SubSprite east  = {   12, -INF, INF, INF };
 
		AddSortableSpriteToDraw(back, pal, ti->x, ti->y, 16,  1, z_wires, ti->z, IsTransparencySet(TO_CATENARY), 15,  0, GetSlopePixelZInCorner(ti->tileh, CORNER_W), &west);
 
		AddSortableSpriteToDraw(back, pal, ti->x, ti->y,  1,  1, z_wires, ti->z, IsTransparencySet(TO_CATENARY),  0,  0, GetSlopePixelZInCorner(ti->tileh, CORNER_N), &north);
 
		AddSortableSpriteToDraw(back, pal, ti->x, ti->y,  1, 16, z_wires, ti->z, IsTransparencySet(TO_CATENARY),  0, 15, GetSlopePixelZInCorner(ti->tileh, CORNER_E), &east);
 
	}
 
	if (front != 0) {
 
		/* Draw the "front" sprite (containing south pillar and wires) at a Z height that is both above the vehicles and above the "back" pillars. */
 
		AddSortableSpriteToDraw(front, pal, ti->x, ti->y, 16, 16, z_wires + 1, ti->z, IsTransparencySet(TO_CATENARY), 0, 0, z_wires);
 
	}
 
}
 

	
 
/**
0 comments (0 inline, 0 general)