summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-04-04 12:31:29 +0000
committercelestar <celestar@openttd.org>2006-04-04 12:31:29 +0000
commit1be26a510cdbf1492aba3465d5de180f528744fc (patch)
tree67d93a140175ed44020d915cec925917cec1f6bf
parenta281b0ebd393b5053f14e8707c07f650e63add0c (diff)
downloadopenttd-1be26a510cdbf1492aba3465d5de180f528744fc.tar.xz
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
-rw-r--r--elrail.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/elrail.c b/elrail.c
index 0edc97d1c..5b4a628fc 100644
--- a/elrail.c
+++ b/elrail.c
@@ -309,9 +309,12 @@ static void DrawCatenaryRailway(const TileInfo *ti)
static void DrawCatenaryOnBridge(const TileInfo *ti)
{
- TileIndex start = GetOtherBridgeEnd(GetSouthernBridgeEnd(ti->tile));
- uint length = GetBridgeLength(GetSouthernBridgeEnd(ti->tile), GetOtherBridgeEnd(GetSouthernBridgeEnd(ti->tile)));
+ TileIndex end = GetSouthernBridgeEnd(ti->tile);
+ TileIndex start = GetOtherBridgeEnd(end);
+
+ uint length = GetBridgeLength(start, end);
uint num = DistanceMax(ti->tile, start);
+
const SortableSpriteStruct *sss;
Axis axis = GetBridgeAxis(ti->tile);
TLG tlg = GetTLG(ti->tile);
@@ -319,11 +322,19 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
CatenarySprite offset = axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH;
if ((length % 2) && num == length) {
+ /* Draw the "short" wire on the southern end of the bridge
+ * only needed if the length of the bridge is odd */
sss = &CatenarySpriteData[WIRE_X_FLAT_BOTH + offset];
} else {
+ /* Draw "long" wires on all other tiles of the bridge (one pylon every two tiles) */
sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset];
}
+ AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset,
+ sss->x_size, sss->y_size, sss->z_size, GetBridgeHeight(ti->tile) + sss->z_offset + 8);
+
+ /* Finished with wires, draw pylons */
+ /* every other tile needs a pylon on the northern end */
if (num % 2) {
if (axis == AXIS_X) {
AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + 8);
@@ -332,16 +343,14 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
}
}
- if (DistanceMax(ti->tile, start) == length) { /* need a pylon here (the southern end) */
+ /* need a pylon on the southern end of the bridge */
+ if (DistanceMax(ti->tile, start) == length) {
if (axis == AXIS_X) {
AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + 8);
} else {
AddSortableSpriteToDraw( pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, GetBridgeHeight(ti->tile) + 8);
}
}
-
- AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset,
- sss->x_size, sss->y_size, sss->z_size, GetBridgeHeight(ti->tile) + sss->z_offset + 8);
}
void DrawCatenary(const TileInfo *ti)