736 * @param type Bridge type. |
736 * @param type Bridge type. |
737 * @param x Sprite X position of front pillar. |
737 * @param x Sprite X position of front pillar. |
738 * @param y Sprite Y position of front pillar. |
738 * @param y Sprite Y position of front pillar. |
739 * @param z_bridge Absolute height of bridge bottom. |
739 * @param z_bridge Absolute height of bridge bottom. |
740 */ |
740 */ |
741 static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, BridgeType type, int x, int y, int z_bridge) |
741 static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, bool drawfarpillar, int x, int y, int z_bridge) |
742 { |
742 { |
743 /* Do not draw bridge pillars if they are invisible */ |
743 /* Do not draw bridge pillars if they are invisible */ |
744 if (IsInvisibilitySet(TO_BRIDGES)) return; |
744 if (IsInvisibilitySet(TO_BRIDGES)) return; |
745 |
745 |
746 SpriteID image = psid->sprite; |
746 SpriteID image = psid->sprite; |
747 |
747 |
748 if (image != 0) { |
748 if (image != 0) { |
749 bool drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 0); |
|
750 |
|
751 /* "side" specifies the side the pillars stand on. |
749 /* "side" specifies the side the pillars stand on. |
752 * The length of the pillars is then set to the height of the bridge over the corners of this edge. |
750 * The length of the pillars is then set to the height of the bridge over the corners of this edge. |
753 * |
751 * |
754 * axis==AXIS_X axis==AXIS_Y |
752 * axis==AXIS_X axis==AXIS_Y |
755 * side==false SW NW |
753 * side==false SW NW |
1039 */ |
1037 */ |
1040 |
1038 |
1041 /* Z position of the bridge sprites relative to bridge height (downwards) */ |
1039 /* Z position of the bridge sprites relative to bridge height (downwards) */ |
1042 static const int BRIDGE_Z_START = 3; |
1040 static const int BRIDGE_Z_START = 3; |
1043 |
1041 |
1044 const PalSpriteID *psid; |
|
1045 uint base_offset; |
|
1046 TileIndex rampnorth; |
|
1047 TileIndex rampsouth; |
|
1048 TransportType transport_type; |
|
1049 Axis axis; |
|
1050 uint piece; |
|
1051 BridgeType type; |
|
1052 int x; |
|
1053 int y; |
|
1054 uint z; |
|
1055 |
|
1056 if (!IsBridgeAbove(ti->tile)) return; |
1042 if (!IsBridgeAbove(ti->tile)) return; |
1057 |
1043 |
1058 rampnorth = GetNorthernBridgeEnd(ti->tile); |
1044 TileIndex rampnorth = GetNorthernBridgeEnd(ti->tile); |
1059 rampsouth = GetSouthernBridgeEnd(ti->tile); |
1045 TileIndex rampsouth = GetSouthernBridgeEnd(ti->tile); |
1060 transport_type = GetTunnelBridgeTransportType(rampsouth); |
1046 TransportType transport_type = GetTunnelBridgeTransportType(rampsouth); |
1061 |
1047 |
1062 axis = GetBridgeAxis(ti->tile); |
1048 Axis axis = GetBridgeAxis(ti->tile); |
1063 piece = CalcBridgePiece( |
1049 uint piece = CalcBridgePiece( |
1064 GetTunnelBridgeLength(ti->tile, rampnorth) + 1, |
1050 GetTunnelBridgeLength(ti->tile, rampnorth) + 1, |
1065 GetTunnelBridgeLength(ti->tile, rampsouth) + 1 |
1051 GetTunnelBridgeLength(ti->tile, rampsouth) + 1 |
1066 ); |
1052 ); |
1067 type = GetBridgeType(rampsouth); |
1053 |
1068 |
1054 const PalSpriteID *psid; |
|
1055 bool drawfarpillar; |
1069 if (transport_type != TRANSPORT_WATER) { |
1056 if (transport_type != TRANSPORT_WATER) { |
|
1057 BridgeType type = GetBridgeType(rampsouth); |
|
1058 drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 0); |
|
1059 |
|
1060 uint base_offset; |
1070 if (transport_type == TRANSPORT_RAIL) { |
1061 if (transport_type == TRANSPORT_RAIL) { |
1071 base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset; |
1062 base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset; |
1072 } else { |
1063 } else { |
1073 base_offset = 8; |
1064 base_offset = 8; |
1074 } |
1065 } |
1075 |
1066 |
1076 psid = base_offset + GetBridgeSpriteTable(type, piece); |
1067 psid = base_offset + GetBridgeSpriteTable(type, piece); |
1077 } else { |
1068 } else { |
|
1069 drawfarpillar = true; |
1078 psid = _aqueduct_sprites; |
1070 psid = _aqueduct_sprites; |
1079 } |
1071 } |
|
1072 |
1080 if (axis != AXIS_X) psid += 4; |
1073 if (axis != AXIS_X) psid += 4; |
1081 |
1074 |
1082 x = ti->x; |
1075 int x = ti->x; |
1083 y = ti->y; |
1076 int y = ti->y; |
1084 uint bridge_z = GetBridgeHeight(rampsouth); |
1077 uint bridge_z = GetBridgeHeight(rampsouth); |
1085 z = bridge_z - BRIDGE_Z_START; |
1078 uint z = bridge_z - BRIDGE_Z_START; |
1086 |
1079 |
1087 /* Add a bounding box, that separates the bridge from things below it. */ |
1080 /* Add a bounding box, that separates the bridge from things below it. */ |
1088 AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR); |
1081 AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR); |
1089 |
1082 |
1090 /* Draw Trambits as SpriteCombine */ |
1083 /* Draw Trambits as SpriteCombine */ |
1145 |
1138 |
1146 DrawGroundSpriteAt(image, pal, x, y, z); |
1139 DrawGroundSpriteAt(image, pal, x, y, z); |
1147 } |
1140 } |
1148 } else if (_settings_client.gui.bridge_pillars) { |
1141 } else if (_settings_client.gui.bridge_pillars) { |
1149 /* draw pillars below for high bridges */ |
1142 /* draw pillars below for high bridges */ |
1150 DrawBridgePillars(psid, ti, axis, type, x, y, z); |
1143 DrawBridgePillars(psid, ti, axis, drawfarpillar, x, y, z); |
1151 } |
1144 } |
1152 } |
1145 } |
1153 |
1146 |
1154 |
1147 |
1155 static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y) |
1148 static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y) |