Changeset - r16234:63c5973c2988
[Not reviewed]
master
0 1 0
frosch - 14 years ago 2010-10-16 15:36:13
frosch@openttd.org
(svn r20945) -Codechange: Add helper function to draw single pillar sprites. (based on patch by uni657)
1 file changed with 17 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -825,6 +825,21 @@ static CommandCost ClearTile_TunnelBridg
 
}
 

	
 
/**
 
 * Draw a single pillar sprite.
 
 * @param psid      Pillarsprite
 
 * @param x         Pillar X
 
 * @param y         Pillar Y
 
 * @param z         Pillar Z
 
 * @param w         Bounding box size in X direction
 
 * @param h         Bounding box size in Y direction
 
 */
 
static inline void DrawPillar(const PalSpriteID *psid, int x, int y, int z, int w, int h)
 
{
 
	static const int PILLAR_Z_OFFSET = TILE_HEIGHT - BRIDGE_Z_START; ///< Start offset of pillar wrt. bridge (downwards)
 
	AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, w, h, BB_HEIGHT_UNDER_BRIDGE - PILLAR_Z_OFFSET, z, IsTransparencySet(TO_BRIDGES), 0, 0, -PILLAR_Z_OFFSET);
 
}
 

	
 
/**
 
 * Draws the pillars under high bridges.
 
 *
 
 * @param psid Image and palette of a bridge pillar.
 
@@ -840,7 +855,6 @@ static void DrawBridgePillars(const PalS
 
	/* Do not draw bridge pillars if they are invisible */
 
	if (IsInvisibilitySet(TO_BRIDGES)) return;
 

	
 
	static const int PILLAR_Z_OFFSET = TILE_HEIGHT - BRIDGE_Z_START; ///< Start offset of pillar wrt. bridge (downwards)
 
	static const int bounding_box_size[2]  = {16, 2}; ///< bounding box size of pillars along bridge direction
 
	static const int back_pillar_offset[2] = { 0, 9}; ///< sprite position offset of back facing pillar
 

	
 
@@ -877,12 +891,12 @@ static void DrawBridgePillars(const PalS
 
	for (int cur_z = z_bridge; cur_z >= front_height || cur_z >= back_height; cur_z -= TILE_HEIGHT) {
 
		/* Draw front facing pillar */
 
		if (cur_z >= front_height) {
 
			AddSortableSpriteToDraw(image, psid->pal, x, y, w, h, BB_HEIGHT_UNDER_BRIDGE - PILLAR_Z_OFFSET, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -PILLAR_Z_OFFSET);
 
			DrawPillar(psid, x, y, cur_z, w, h);
 
		}
 

	
 
		/* Draw back facing pillar, but not the highest part directly under the bridge-floor */
 
		if (drawfarpillar && cur_z >= back_height && cur_z < z_bridge - (int)TILE_HEIGHT) {
 
			AddSortableSpriteToDraw(image, psid->pal, x_back, y_back, w, h, BB_HEIGHT_UNDER_BRIDGE - PILLAR_Z_OFFSET, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -PILLAR_Z_OFFSET);
 
			DrawPillar(psid, x_back, y_back, cur_z, w, h);
 
		}
 
	}
 
}
0 comments (0 inline, 0 general)