summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-15 17:27:15 +0000
committertron <tron@openttd.org>2006-03-15 17:27:15 +0000
commit23d5188b7bf9eb9a097f5296501f2506aeff6aeb (patch)
treedfff458d3f484bf166116fb807438f023da5fa3b
parente74d77211fab8ea22aad6d95bcbb855aebe3c85c (diff)
downloadopenttd-23d5188b7bf9eb9a097f5296501f2506aeff6aeb.tar.xz
(svn r3889) Change a part of the bridge drawing code to make it more comprehensible and add the needed accessors
-rw-r--r--bridge_map.h17
-rw-r--r--table/bridge_land.h4
-rw-r--r--tunnelbridge_cmd.c34
3 files changed, 32 insertions, 23 deletions
diff --git a/bridge_map.h b/bridge_map.h
index 9d504f06c..7214425c6 100644
--- a/bridge_map.h
+++ b/bridge_map.h
@@ -28,6 +28,23 @@ static inline DiagDirection GetBridgeRampDirection(TileIndex t)
}
+static inline bool IsClearUnderBridge(TileIndex t)
+{
+ return GB(_m[t].m5, 3, 3) == 0;
+}
+
+
+static inline bool IsTransportUnderBridge(TileIndex t)
+{
+ return HASBIT(_m[t].m5, 5);
+}
+
+static inline TransportType GetTransportTypeUnderBridge(TileIndex t)
+{
+ return (TransportType)GB(_m[t].m5, 3, 2);
+}
+
+
/**
* Starting at one bridge end finds the other bridge end
*/
diff --git a/table/bridge_land.h b/table/bridge_land.h
index 9c5995aee..ba81385de 100644
--- a/table/bridge_land.h
+++ b/table/bridge_land.h
@@ -26,10 +26,6 @@
* </ul>
*/
-static const SpriteID _bridge_land_below[] = {
- SPR_FLAT_GRASS_TILE, SPR_FLAT_WATER_TILE, SPR_FLAT_SNOWY_TILE, SPR_FLAT_WATER_TILE
-};
-
static const PalSpriteID _bridge_sprite_table_2_0[] = {
0x9C3, 0x9C7, 0x9C9, 0x0, 0x9C4, 0x9C8, 0x9CA, 0x0,
0x9C5, 0x9C7, 0x9C9, 0x0, 0x9C6, 0x9C8, 0x9CA, 0x0,
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index a14386280..53eeae041 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -1033,23 +1033,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
uint z;
int x,y;
- image = GB(ti->map5, 3, 2); // type of stuff under bridge (only defined for 0,1)
- /** @todo So why do we even WASTE that one bit?! (map5, bit 4) */
- assert(image <= 1);
-
- if (!(ti->map5 & 0x20)) {
- // draw land under bridge
- if (ice) image += 2;
-
- if (image != 1 || ti->tileh == 0) {
- DrawGroundSprite(_bridge_land_below[image] + _tileh_to_sprite[ti->tileh]);
- } else {
- DrawGroundSprite(_water_shore_sprites[ti->tileh]);
- }
-
- // draw canal water?
- if (ti->map5 & 8 && ti->z != 0) DrawCanalWater(ti->tile);
- } else {
+ if (IsTransportUnderBridge(ti->tile)) {
// draw transport route under bridge
// draw foundation?
@@ -1058,9 +1042,9 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
if (f) DrawFoundation(ti, f);
}
- if (!(image&1)) {
+ if (GetTransportTypeUnderBridge(ti->tile) == TRANSPORT_RAIL) {
const RailtypeInfo *rti = GetRailTypeInfo(GB(_m[ti->tile].m3, 0, 4));
- // railway
+
image = SPR_RAIL_TRACK_Y + (ti->map5 & 1);
if (ti->tileh != 0) image = SPR_RAIL_TRACK_Y + _track_sloped_sprites[ti->tileh - 1];
image += rti->total_offset;
@@ -1072,6 +1056,18 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
if (ice) image += 19;
}
DrawGroundSprite(image);
+ } else {
+ if (IsClearUnderBridge(ti->tile)) {
+ image = (ice ? SPR_FLAT_SNOWY_TILE : SPR_FLAT_GRASS_TILE);
+ DrawGroundSprite(image + _tileh_to_sprite[ti->tileh]);
+ } else {
+ if (ti->tileh == 0) {
+ DrawGroundSprite(SPR_FLAT_WATER_TILE);
+ if (ti->z != 0) DrawCanalWater(ti->tile);
+ } else {
+ DrawGroundSprite(_water_shore_sprites[ti->tileh]);
+ }
+ }
}
/* Cope for the direction of the bridge */