829 if (image != 0) { |
829 if (image != 0) { |
830 bool drawfarpillar = !HASBIT(GetBridgeFlags(type), 0); |
830 bool drawfarpillar = !HASBIT(GetBridgeFlags(type), 0); |
831 int back_height, front_height; |
831 int back_height, front_height; |
832 int i = z; |
832 int i = z; |
833 const byte *p; |
833 const byte *p; |
834 SpriteID pal; |
|
835 |
834 |
836 static const byte _tileh_bits[4][8] = { |
835 static const byte _tileh_bits[4][8] = { |
837 { 2, 1, 8, 4, 16, 2, 0, 9 }, |
836 { 2, 1, 8, 4, 16, 2, 0, 9 }, |
838 { 1, 8, 4, 2, 2, 16, 9, 0 }, |
837 { 1, 8, 4, 2, 2, 16, 9, 0 }, |
839 { 4, 8, 1, 2, 16, 2, 0, 9 }, |
838 { 4, 8, 1, 2, 16, 2, 0, 9 }, |
840 { 2, 4, 8, 1, 2, 16, 9, 0 } |
839 { 2, 4, 8, 1, 2, 16, 9, 0 } |
841 }; |
840 }; |
842 |
841 |
843 if (HASBIT(_transparent_opt, TO_BRIDGES)) { |
|
844 SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
|
845 pal = PALETTE_TO_TRANSPARENT; |
|
846 } else { |
|
847 pal = psid->pal; |
|
848 } |
|
849 |
|
850 p = _tileh_bits[(image & 1) * 2 + (axis == AXIS_X ? 0 : 1)]; |
842 p = _tileh_bits[(image & 1) * 2 + (axis == AXIS_X ? 0 : 1)]; |
851 front_height = ti->z + (ti->tileh & p[0] ? TILE_HEIGHT : 0); |
843 front_height = ti->z + (ti->tileh & p[0] ? TILE_HEIGHT : 0); |
852 back_height = ti->z + (ti->tileh & p[1] ? TILE_HEIGHT : 0); |
844 back_height = ti->z + (ti->tileh & p[1] ? TILE_HEIGHT : 0); |
853 |
845 |
854 if (IsSteepSlope(ti->tileh)) { |
846 if (IsSteepSlope(ti->tileh)) { |
859 for (; z >= front_height || z >= back_height; z -= TILE_HEIGHT) { |
851 for (; z >= front_height || z >= back_height; z -= TILE_HEIGHT) { |
860 /* HACK set height of the BB of pillars to 1, because the origin of the |
852 /* HACK set height of the BB of pillars to 1, because the origin of the |
861 * sprites is at the top |
853 * sprites is at the top |
862 */ |
854 */ |
863 if (z >= front_height) { // front facing pillar |
855 if (z >= front_height) { // front facing pillar |
864 AddSortableSpriteToDraw(image, pal, x, y, p[4], p[5], 1, z); |
856 AddSortableSpriteToDraw(image, psid->pal, x, y, p[4], p[5], 1, z, HASBIT(_transparent_opt, TO_BRIDGES)); |
865 } |
857 } |
866 |
858 |
867 if (drawfarpillar && z >= back_height && z < i - TILE_HEIGHT) { // back facing pillar |
859 if (drawfarpillar && z >= back_height && z < i - TILE_HEIGHT) { // back facing pillar |
868 AddSortableSpriteToDraw(image, pal, x - p[6], y - p[7], p[4], p[5], 1, z); |
860 AddSortableSpriteToDraw(image, psid->pal, x - p[6], y - p[7], p[4], p[5], 1, z, HASBIT(_transparent_opt, TO_BRIDGES)); |
869 } |
861 } |
870 } |
862 } |
871 } |
863 } |
872 } |
864 } |
873 |
865 |
910 static const uint size_x[6] = { 11, 16, 16, 16, 16, 16 }; |
902 static const uint size_x[6] = { 11, 16, 16, 16, 16, 16 }; |
911 static const uint size_y[6] = { 16, 11, 16, 16, 16, 16 }; |
903 static const uint size_y[6] = { 16, 11, 16, 16, 16, 16 }; |
912 |
904 |
913 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 1 : 0, z); |
905 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 1 : 0, z); |
914 |
906 |
915 SpriteID front = SPR_TRAMWAY_BASE + front_offsets[offset]; |
907 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0, z, HASBIT(_transparent_opt, TO_BUILDINGS)); |
916 SpriteID back = SPR_TRAMWAY_BASE + back_offsets[offset]; |
|
917 SpriteID pal = PAL_NONE; |
|
918 if (HASBIT(_transparent_opt, TO_BUILDINGS)) { |
|
919 SETBIT(front, PALETTE_MODIFIER_TRANSPARENT); |
|
920 SETBIT(back, PALETTE_MODIFIER_TRANSPARENT); |
|
921 pal = PALETTE_TO_TRANSPARENT; |
|
922 } |
|
923 |
|
924 AddSortableSpriteToDraw(back, pal, x, y, size_x[offset], size_y[offset], 0, z); |
|
925 /* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */ |
908 /* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */ |
926 AddSortableSpriteToDraw(front, pal, x, y, size_x[offset], size_y[offset], offset >= 2 ? 0x30 : 0x10, z); |
909 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 0x30 : 0x10, z, HASBIT(_transparent_opt, TO_BUILDINGS)); |
927 } |
910 } |
928 |
911 |
929 /** |
912 /** |
930 * Draws a tunnel of bridge tile. |
913 * Draws a tunnel of bridge tile. |
931 * For tunnels, this is rather simple, as you only needa draw the entrance. |
914 * For tunnels, this is rather simple, as you only needa draw the entrance. |
940 * Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3 |
923 * Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3 |
941 */ |
924 */ |
942 static void DrawTile_TunnelBridge(TileInfo *ti) |
925 static void DrawTile_TunnelBridge(TileInfo *ti) |
943 { |
926 { |
944 SpriteID image; |
927 SpriteID image; |
945 SpriteID pal; |
|
946 |
928 |
947 if (IsTunnel(ti->tile)) { |
929 if (IsTunnel(ti->tile)) { |
948 if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) { |
930 if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) { |
949 image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel; |
931 image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel; |
950 } else { |
932 } else { |
1003 DrawClearLandTile(ti, 3); |
985 DrawClearLandTile(ti, 3); |
1004 } else { |
986 } else { |
1005 DrawGroundSprite(SPR_FLAT_SNOWY_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE); |
987 DrawGroundSprite(SPR_FLAT_SNOWY_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE); |
1006 } |
988 } |
1007 |
989 |
1008 image = psid->sprite; |
|
1009 |
|
1010 /* draw ramp */ |
990 /* draw ramp */ |
1011 if (HASBIT(_transparent_opt, TO_BRIDGES)) { |
|
1012 SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
|
1013 pal = PALETTE_TO_TRANSPARENT; |
|
1014 } else { |
|
1015 pal = psid->pal; |
|
1016 } |
|
1017 |
991 |
1018 /* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on |
992 /* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on |
1019 * it doesn't disappear behind it |
993 * it doesn't disappear behind it |
1020 */ |
994 */ |
1021 AddSortableSpriteToDraw( |
995 AddSortableSpriteToDraw( |
1022 image, pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z |
996 psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, HASBIT(_transparent_opt, TO_BRIDGES) |
1023 ); |
997 ); |
1024 |
998 |
1025 if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) { |
999 if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) { |
1026 RoadTypes rts = GetRoadTypes(ti->tile); |
1000 RoadTypes rts = GetRoadTypes(ti->tile); |
1027 |
1001 |
1118 x = ti->x; |
1090 x = ti->x; |
1119 y = ti->y; |
1091 y = ti->y; |
1120 uint bridge_z = GetBridgeHeight(rampsouth); |
1092 uint bridge_z = GetBridgeHeight(rampsouth); |
1121 z = bridge_z - 3; |
1093 z = bridge_z - 3; |
1122 |
1094 |
1123 image = psid->sprite; |
|
1124 if (HASBIT(_transparent_opt, TO_BRIDGES)) { |
|
1125 SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
|
1126 pal = PALETTE_TO_TRANSPARENT; |
|
1127 } else { |
|
1128 pal = psid->pal; |
|
1129 } |
|
1130 |
|
1131 if (axis == AXIS_X) { |
1095 if (axis == AXIS_X) { |
1132 AddSortableSpriteToDraw(image, pal, x, y, 16, 11, 1, z); |
1096 AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 11, 1, z, HASBIT(_transparent_opt, TO_BRIDGES)); |
1133 } else { |
1097 } else { |
1134 AddSortableSpriteToDraw(image, pal, x, y, 11, 16, 1, z); |
1098 AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 11, 16, 1, z, HASBIT(_transparent_opt, TO_BRIDGES)); |
1135 } |
1099 } |
1136 |
1100 |
1137 psid++; |
1101 psid++; |
1138 image = psid->sprite; |
|
1139 if (HASBIT(_transparent_opt, TO_BRIDGES)) { |
|
1140 SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
|
1141 pal = PALETTE_TO_TRANSPARENT; |
|
1142 } else { |
|
1143 pal = psid->pal; |
|
1144 } |
|
1145 |
1102 |
1146 if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) { |
1103 if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) { |
1147 RoadTypes rts = GetRoadTypes(rampsouth); |
1104 RoadTypes rts = GetRoadTypes(rampsouth); |
1148 |
1105 |
1149 if (HASBIT(rts, ROADTYPE_TRAM)) { |
1106 if (HASBIT(rts, ROADTYPE_TRAM)) { |
1154 } |
1111 } |
1155 |
1112 |
1156 /* draw roof, the component of the bridge which is logically between the vehicle and the camera */ |
1113 /* draw roof, the component of the bridge which is logically between the vehicle and the camera */ |
1157 if (axis == AXIS_X) { |
1114 if (axis == AXIS_X) { |
1158 y += 12; |
1115 y += 12; |
1159 if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, pal, x, y, 16, 1, 0x28, z); |
1116 if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES)); |
1160 } else { |
1117 } else { |
1161 x += 12; |
1118 x += 12; |
1162 if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, pal, x, y, 1, 16, 0x28, z); |
1119 if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES)); |
1163 } |
1120 } |
1164 |
1121 |
1165 psid++; |
1122 psid++; |
1166 if (ti->z + 5 == z) { |
1123 if (ti->z + 5 == z) { |
1167 /* draw poles below for small bridges */ |
1124 /* draw poles below for small bridges */ |
1168 if (psid->sprite != 0) { |
1125 if (psid->sprite != 0) { |
1169 image = psid->sprite; |
1126 SpriteID image = psid->sprite; |
|
1127 SpriteID pal = psid->pal; |
1170 if (HASBIT(_transparent_opt, TO_BRIDGES)) { |
1128 if (HASBIT(_transparent_opt, TO_BRIDGES)) { |
1171 SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
1129 SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
1172 pal = PALETTE_TO_TRANSPARENT; |
1130 pal = PALETTE_TO_TRANSPARENT; |
1173 } else { |
|
1174 pal = psid->pal; |
|
1175 } |
1131 } |
1176 |
1132 |
1177 DrawGroundSpriteAt(image, pal, x, y, z); |
1133 DrawGroundSpriteAt(image, pal, x, y, z); |
1178 } |
1134 } |
1179 } else if (_patches.bridge_pillars) { |
1135 } else if (_patches.bridge_pillars) { |