Changeset - r16235:750325256b5c
[Not reviewed]
master
0 1 0
frosch - 14 years ago 2010-10-16 15:36:51
frosch@openttd.org
(svn r20946) -Codechange: Add helper function to draw pillar columns.
1 file changed with 25 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -837,12 +837,32 @@ static inline void DrawPillar(const PalS
 
{
 
	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);
 
}
 

	
 
/**
 
 * Draw two bridge pillars (north and south).
 
 * @param z_bottom Bottom Z
 
 * @param z_top    Top Z
 
 * @param psid     Pillarsprite
 
 * @param x        Pillar X
 
 * @param y        Pillar Y
 
 * @param w        Bounding box size in X direction
 
 * @param h        Bounding box size in Y direction
 
 * @return Reached Z at the bottom
 
 */
 
static int DrawPillarColumn(int z_bottom, int z_top, const PalSpriteID *psid, int x, int y, int w, int h)
 
{
 
	int cur_z;
 
	for (cur_z = z_top; cur_z >= z_bottom; cur_z -= TILE_HEIGHT) {
 
		DrawPillar(psid, x, y, cur_z, w, h);
 
	}
 
	return cur_z;
 
}
 

	
 
/**
 
 * Draws the pillars under high bridges.
 
 *
 
 * @param psid Image and palette of a bridge pillar.
 
 * @param ti #TileInfo of current bridge-middle-tile.
 
 * @param axis Orientation of bridge.
 
 * @param drawfarpillar Whether to draw the pillar at the back
 
@@ -885,22 +905,18 @@ static void DrawBridgePillars(const PalS
 
	int w = bounding_box_size[axis];
 
	int h = bounding_box_size[OtherAxis(axis)];
 
	/* sprite position of back facing pillar */
 
	int x_back = x - back_pillar_offset[axis];
 
	int y_back = y - back_pillar_offset[OtherAxis(axis)];
 

	
 
	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) {
 
			DrawPillar(psid, x, y, cur_z, w, h);
 
		}
 
	/* Draw front pillars */
 
	DrawPillarColumn(front_height, z_bridge, psid, x, y, 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) {
 
			DrawPillar(psid, x_back, y_back, cur_z, w, h);
 
		}
 
	/* Draw back pillars, skip top two parts, which are hidden by the bridge */
 
	if (drawfarpillar) {
 
		DrawPillarColumn(back_height, z_bridge - 2 * (int)TILE_HEIGHT, psid, x_back, y_back, w, h);
 
	}
 
}
 

	
 
/**
 
 * Draws the trambits over an already drawn (lower end) of a bridge.
 
 * @param x       the x of the bridge
0 comments (0 inline, 0 general)