summaryrefslogtreecommitdiff
path: root/src/elrail.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-07-26 14:07:11 +0000
committerrubidium <rubidium@openttd.org>2007-07-26 14:07:11 +0000
commita26ef1ee3aa21ff064d70971a4bb3605b40100db (patch)
treef9ea4c50fe8ce5b57839ce0b5407aac9a6f2b452 /src/elrail.cpp
parente97c2bf6211478399723099ac9e50ba695e536b7 (diff)
downloadopenttd-a26ef1ee3aa21ff064d70971a4bb3605b40100db.tar.xz
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
Diffstat (limited to 'src/elrail.cpp')
-rw-r--r--src/elrail.cpp64
1 files changed, 16 insertions, 48 deletions
diff --git a/src/elrail.cpp b/src/elrail.cpp
index 6faf76615..a0a0bbdf9 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -270,15 +270,9 @@ static void DrawCatenaryRailway(const TileInfo *ti)
continue; /* No neighbour, go looking for a better position */
}
- SpriteID img = pylons_normal[temp];
- SpriteID pal = PAL_NONE;
- if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
- SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
- pal = PALETTE_TO_TRANSPARENT;
- }
-
- AddSortableSpriteToDraw(img, pal, x, y, 1, 1, 10,
- GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i]));
+ AddSortableSpriteToDraw(pylons_normal[temp], PAL_NONE, x, y, 1, 1, 10,
+ GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i]),
+ HASBIT(_transparent_opt, TO_BUILDINGS));
break; /* We already have drawn a pylon, bail out */
}
}
@@ -315,15 +309,9 @@ static void DrawCatenaryRailway(const TileInfo *ti)
assert(!IsSteepSlope(tileh[TS_HOME]));
sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]];
- SpriteID img = sss->image;
- SpriteID pal = PAL_NONE;
- if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
- SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
- pal = PALETTE_TO_TRANSPARENT;
- }
-
- AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
- sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset);
+ AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
+ sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset,
+ HASBIT(_transparent_opt, TO_BUILDINGS));
}
}
}
@@ -354,41 +342,27 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
height = GetBridgeHeight(end);
- SpriteID img = sss->image;
- SpriteID pal = PAL_NONE;
- if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
- SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
- pal = PALETTE_TO_TRANSPARENT;
- }
-
- AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
- sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset
+ AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
+ sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset,
+ HASBIT(_transparent_opt, TO_BUILDINGS)
);
/* Finished with wires, draw pylons */
/* every other tile needs a pylon on the northern end */
if (num % 2) {
if (axis == AXIS_X) {
- img = pylons_bridge[0 + HASBIT(tlg, 0)];
- if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
- AddSortableSpriteToDraw(img, pal, ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
+ AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], PAL_NONE, ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height, HASBIT(_transparent_opt, TO_BUILDINGS));
} else {
- img = pylons_bridge[2 + HASBIT(tlg, 1)];
- if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
- AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height);
+ AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], PAL_NONE, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height, HASBIT(_transparent_opt, TO_BUILDINGS));
}
}
/* need a pylon on the southern end of the bridge */
if (DistanceMax(ti->tile, start) == length) {
if (axis == AXIS_X) {
- img = pylons_bridge[0 + HASBIT(tlg, 0)];
- if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
- AddSortableSpriteToDraw(img, pal, ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height);
+ AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], PAL_NONE, ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height, HASBIT(_transparent_opt, TO_BUILDINGS));
} else {
- img = pylons_bridge[2 + HASBIT(tlg, 1)];
- if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
- AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height);
+ AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], PAL_NONE, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height, HASBIT(_transparent_opt, TO_BUILDINGS));
}
}
}
@@ -410,17 +384,11 @@ void DrawCatenary(const TileInfo *ti)
if (IsRailDepot(ti->tile)) {
const SortableSpriteStruct *sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)];
- SpriteID img = sss->image;
- SpriteID pal = PAL_NONE;
- if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
- SETBIT(img, PALETTE_MODIFIER_TRANSPARENT);
- pal = PALETTE_TO_TRANSPARENT;
- }
-
AddSortableSpriteToDraw(
- img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset,
+ sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
sss->x_size, sss->y_size, sss->z_size,
- GetTileMaxZ(ti->tile) + sss->z_offset
+ GetTileMaxZ(ti->tile) + sss->z_offset,
+ HASBIT(_transparent_opt, TO_BUILDINGS)
);
return;
}