1
0
Fork 0

(svn r20943) -Codechange: Name some magic constants. (Based on patch by uni657)

release/1.1
frosch 2010-10-16 15:34:59 +00:00
parent 0b67a7ccd5
commit 58ed553068
1 changed files with 13 additions and 9 deletions

View File

@ -46,6 +46,9 @@
BridgeSpec _bridge[MAX_BRIDGES]; BridgeSpec _bridge[MAX_BRIDGES];
TileIndex _build_tunnel_endtile; TileIndex _build_tunnel_endtile;
/* Z position of the bridge sprites relative to bridge height (downwards) */
static const int BRIDGE_Z_START = 3;
/** Reset the data been eventually changed by the grf loaded. */ /** Reset the data been eventually changed by the grf loaded. */
void ResetBridges() void ResetBridges()
{ {
@ -837,6 +840,10 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis
/* Do not draw bridge pillars if they are invisible */ /* Do not draw bridge pillars if they are invisible */
if (IsInvisibilitySet(TO_BRIDGES)) return; 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
SpriteID image = psid->sprite; SpriteID image = psid->sprite;
if (image != 0) { if (image != 0) {
@ -861,21 +868,21 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis
GetSlopeZOnEdge(ti->tileh, dir, &front_height, &back_height); GetSlopeZOnEdge(ti->tileh, dir, &front_height, &back_height);
/* x and y size of bounding-box of pillars */ /* x and y size of bounding-box of pillars */
int w = (axis == AXIS_X ? 16 : 2); int w = bounding_box_size[axis];
int h = (axis == AXIS_X ? 2 : 16); int h = bounding_box_size[OtherAxis(axis)];
/* sprite position of back facing pillar */ /* sprite position of back facing pillar */
int x_back = x - (axis == AXIS_X ? 0 : 9); int x_back = x - back_pillar_offset[axis];
int y_back = y - (axis == AXIS_X ? 9 : 0); 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) { for (int cur_z = z_bridge; cur_z >= front_height || cur_z >= back_height; cur_z -= TILE_HEIGHT) {
/* Draw front facing pillar */ /* Draw front facing pillar */
if (cur_z >= front_height) { if (cur_z >= front_height) {
AddSortableSpriteToDraw(image, psid->pal, x, y, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5); 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);
} }
/* Draw back facing pillar, but not the highest part directly under the bridge-floor */ /* 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) { 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 - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5); 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);
} }
} }
} }
@ -1174,9 +1181,6 @@ void DrawBridgeMiddle(const TileInfo *ti)
* *
*/ */
/* Z position of the bridge sprites relative to bridge height (downwards) */
static const int BRIDGE_Z_START = 3;
if (!IsBridgeAbove(ti->tile)) return; if (!IsBridgeAbove(ti->tile)) return;
TileIndex rampnorth = GetNorthernBridgeEnd(ti->tile); TileIndex rampnorth = GetNorthernBridgeEnd(ti->tile);