116 static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope tileh) |
116 static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope tileh) |
117 { |
117 { |
118 uint32 valid; |
118 uint32 valid; |
119 |
119 |
120 valid = M(SLOPE_FLAT) | (axis == AXIS_X ? M(SLOPE_NE) : M(SLOPE_NW)); |
120 valid = M(SLOPE_FLAT) | (axis == AXIS_X ? M(SLOPE_NE) : M(SLOPE_NW)); |
121 if (HASBIT(valid, tileh)) return CommandCost(); |
121 if (HasBit(valid, tileh)) return CommandCost(); |
122 |
122 |
123 valid = |
123 valid = |
124 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_N) | M(SLOPE_STEEP_N) | |
124 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_N) | M(SLOPE_STEEP_N) | |
125 (axis == AXIS_X ? M(SLOPE_E) | M(SLOPE_STEEP_E) : M(SLOPE_W) | M(SLOPE_STEEP_W)); |
125 (axis == AXIS_X ? M(SLOPE_E) | M(SLOPE_STEEP_E) : M(SLOPE_W) | M(SLOPE_STEEP_W)); |
126 if (HASBIT(valid, tileh)) return CommandCost(_price.terraform); |
126 if (HasBit(valid, tileh)) return CommandCost(_price.terraform); |
127 |
127 |
128 return CMD_ERROR; |
128 return CMD_ERROR; |
129 } |
129 } |
130 |
130 |
131 static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope tileh) |
131 static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope tileh) |
132 { |
132 { |
133 uint32 valid; |
133 uint32 valid; |
134 |
134 |
135 valid = M(SLOPE_FLAT) | (axis == AXIS_X ? M(SLOPE_SW) : M(SLOPE_SE)); |
135 valid = M(SLOPE_FLAT) | (axis == AXIS_X ? M(SLOPE_SW) : M(SLOPE_SE)); |
136 if (HASBIT(valid, tileh)) return CommandCost(); |
136 if (HasBit(valid, tileh)) return CommandCost(); |
137 |
137 |
138 valid = |
138 valid = |
139 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_S) | M(SLOPE_STEEP_S) | |
139 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_S) | M(SLOPE_STEEP_S) | |
140 (axis == AXIS_X ? M(SLOPE_W) | M(SLOPE_STEEP_W) : M(SLOPE_E) | M(SLOPE_STEEP_E)); |
140 (axis == AXIS_X ? M(SLOPE_W) | M(SLOPE_STEEP_W) : M(SLOPE_E) | M(SLOPE_STEEP_E)); |
141 if (HASBIT(valid, tileh)) return CommandCost(_price.terraform); |
141 if (HasBit(valid, tileh)) return CommandCost(_price.terraform); |
142 |
142 |
143 return CMD_ERROR; |
143 return CMD_ERROR; |
144 } |
144 } |
145 #undef M |
145 #undef M |
146 |
146 |
208 bridge_type = GB(p2, 0, 8); |
208 bridge_type = GB(p2, 0, 8); |
209 |
209 |
210 if (p1 >= MapSize()) return CMD_ERROR; |
210 if (p1 >= MapSize()) return CMD_ERROR; |
211 |
211 |
212 /* type of bridge */ |
212 /* type of bridge */ |
213 if (HASBIT(p2, 15)) { |
213 if (HasBit(p2, 15)) { |
214 railtype = INVALID_RAILTYPE; // road bridge |
214 railtype = INVALID_RAILTYPE; // road bridge |
215 roadtypes = (RoadTypes)GB(p2, 8, 3); |
215 roadtypes = (RoadTypes)GB(p2, 8, 3); |
216 if (!AreValidRoadTypes(roadtypes) || !HasRoadTypesAvail(_current_player, roadtypes)) return CMD_ERROR; |
216 if (!AreValidRoadTypes(roadtypes) || !HasRoadTypesAvail(_current_player, roadtypes)) return CMD_ERROR; |
217 } else { |
217 } else { |
218 if (!ValParamRailtype(GB(p2, 8, 8))) return CMD_ERROR; |
218 if (!ValParamRailtype(GB(p2, 8, 8))) return CMD_ERROR; |
250 |
250 |
251 tileh_start = GetTileSlope(tile_start, &z_start); |
251 tileh_start = GetTileSlope(tile_start, &z_start); |
252 tileh_end = GetTileSlope(tile_end, &z_end); |
252 tileh_end = GetTileSlope(tile_end, &z_end); |
253 |
253 |
254 if (IsSteepSlope(tileh_start)) z_start += TILE_HEIGHT; |
254 if (IsSteepSlope(tileh_start)) z_start += TILE_HEIGHT; |
255 if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh_start)) z_start += TILE_HEIGHT; |
255 if (HasBit(BRIDGE_FULL_LEVELED_FOUNDATION, tileh_start)) z_start += TILE_HEIGHT; |
256 |
256 |
257 if (IsSteepSlope(tileh_end)) z_end += TILE_HEIGHT; |
257 if (IsSteepSlope(tileh_end)) z_end += TILE_HEIGHT; |
258 if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh_end)) z_end += TILE_HEIGHT; |
258 if (HasBit(BRIDGE_FULL_LEVELED_FOUNDATION, tileh_end)) z_end += TILE_HEIGHT; |
259 |
259 |
260 if (z_start != z_end) return_cmd_error(STR_BRIDGEHEADS_NOT_SAME_HEIGHT); |
260 if (z_start != z_end) return_cmd_error(STR_BRIDGEHEADS_NOT_SAME_HEIGHT); |
261 |
261 |
262 allow_on_slopes = (!_is_old_ai_player |
262 allow_on_slopes = (!_is_old_ai_player |
263 && _patches.build_on_slopes); |
263 && _patches.build_on_slopes); |
460 uint end_z; |
460 uint end_z; |
461 CommandCost cost; |
461 CommandCost cost; |
462 CommandCost ret; |
462 CommandCost ret; |
463 |
463 |
464 _build_tunnel_endtile = 0; |
464 _build_tunnel_endtile = 0; |
465 if (!HASBIT(p1, 9)) { |
465 if (!HasBit(p1, 9)) { |
466 if (!ValParamRailtype(p1)) return CMD_ERROR; |
466 if (!ValParamRailtype(p1)) return CMD_ERROR; |
467 } else { |
467 } else { |
468 const RoadTypes rts = (RoadTypes)GB(p1, 0, 3); |
468 const RoadTypes rts = (RoadTypes)GB(p1, 0, 3); |
469 if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, rts)) return CMD_ERROR; |
469 if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, rts)) return CMD_ERROR; |
470 } |
470 } |
826 */ |
826 */ |
827 static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, uint type, int x, int y, int z_bridge) |
827 static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, uint type, int x, int y, int z_bridge) |
828 { |
828 { |
829 SpriteID image = psid->sprite; |
829 SpriteID image = psid->sprite; |
830 if (image != 0) { |
830 if (image != 0) { |
831 bool drawfarpillar = !HASBIT(GetBridgeFlags(type), 0); |
831 bool drawfarpillar = !HasBit(GetBridgeFlags(type), 0); |
832 |
832 |
833 /* "side" specifies the side the pillars stand on. |
833 /* "side" specifies the side the pillars stand on. |
834 * The length of the pillars is then set to the height of the bridge over the corners of this edge. |
834 * The length of the pillars is then set to the height of the bridge over the corners of this edge. |
835 * |
835 * |
836 * axis==AXIS_X axis==AXIS_Y |
836 * axis==AXIS_X axis==AXIS_Y |
837 * side==false SW NW |
837 * side==false SW NW |
838 * side==true NE SE |
838 * side==true NE SE |
839 * |
839 * |
840 * I have no clue, why this was done this way. |
840 * I have no clue, why this was done this way. |
841 */ |
841 */ |
842 bool side = HASBIT(image, 0); |
842 bool side = HasBit(image, 0); |
843 |
843 |
844 /* "dir" means the edge the pillars stand on */ |
844 /* "dir" means the edge the pillars stand on */ |
845 DiagDirection dir = AxisToDiagDir(axis); |
845 DiagDirection dir = AxisToDiagDir(axis); |
846 if (side != (axis == AXIS_Y)) dir = ReverseDiagDir(dir); |
846 if (side != (axis == AXIS_Y)) dir = ReverseDiagDir(dir); |
847 |
847 |
871 } |
871 } |
872 } |
872 } |
873 |
873 |
874 Foundation GetBridgeFoundation(Slope tileh, Axis axis) |
874 Foundation GetBridgeFoundation(Slope tileh, Axis axis) |
875 { |
875 { |
876 if (HASBIT(BRIDGE_NO_FOUNDATION, tileh)) return FOUNDATION_NONE; |
876 if (HasBit(BRIDGE_NO_FOUNDATION, tileh)) return FOUNDATION_NONE; |
877 if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) return FlatteningFoundation(tileh); |
877 if (HasBit(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) return FlatteningFoundation(tileh); |
878 return InclinedFoundation(axis); |
878 return InclinedFoundation(axis); |
879 } |
879 } |
880 |
880 |
881 /** |
881 /** |
882 * Draws the trambits over an already drawn (lower end) of a bridge. |
882 * Draws the trambits over an already drawn (lower end) of a bridge. |
962 DrawGroundSprite(image, PAL_NONE); |
962 DrawGroundSprite(image, PAL_NONE); |
963 if (GetTunnelTransportType(ti->tile) == TRANSPORT_ROAD) { |
963 if (GetTunnelTransportType(ti->tile) == TRANSPORT_ROAD) { |
964 DiagDirection dir = GetTunnelDirection(ti->tile); |
964 DiagDirection dir = GetTunnelDirection(ti->tile); |
965 RoadTypes rts = GetRoadTypes(ti->tile); |
965 RoadTypes rts = GetRoadTypes(ti->tile); |
966 |
966 |
967 if (HASBIT(rts, ROADTYPE_TRAM)) { |
967 if (HasBit(rts, ROADTYPE_TRAM)) { |
968 static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, { 5, 76, 77, 4 } }; |
968 static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, { 5, 76, 77, 4 } }; |
969 |
969 |
970 DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][dir], PAL_NONE); |
970 DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][dir], PAL_NONE); |
971 |
971 |
972 catenary = true; |
972 catenary = true; |
1034 ); |
1034 ); |
1035 |
1035 |
1036 if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) { |
1036 if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) { |
1037 RoadTypes rts = GetRoadTypes(ti->tile); |
1037 RoadTypes rts = GetRoadTypes(ti->tile); |
1038 |
1038 |
1039 if (HASBIT(rts, ROADTYPE_TRAM)) { |
1039 if (HasBit(rts, ROADTYPE_TRAM)) { |
1040 uint offset = GetBridgeRampDirection(ti->tile); |
1040 uint offset = GetBridgeRampDirection(ti->tile); |
1041 uint z = ti->z; |
1041 uint z = ti->z; |
1042 if (ti->tileh != SLOPE_FLAT) { |
1042 if (ti->tileh != SLOPE_FLAT) { |
1043 offset = (offset + 1) & 1; |
1043 offset = (offset + 1) & 1; |
1044 z += TILE_HEIGHT; |
1044 z += TILE_HEIGHT; |
1045 } else { |
1045 } else { |
1046 offset += 2; |
1046 offset += 2; |
1047 } |
1047 } |
1048 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
1048 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
1049 DrawBridgeTramBits(ti->x, ti->y, z, offset, HASBIT(rts, ROADTYPE_ROAD)); |
1049 DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD)); |
1050 } |
1050 } |
1051 EndSpriteCombine(); |
1051 EndSpriteCombine(); |
1052 } else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) { |
1052 } else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) { |
1053 DrawCatenary(ti); |
1053 DrawCatenary(ti); |
1054 } |
1054 } |
1166 psid++; |
1166 psid++; |
1167 |
1167 |
1168 if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) { |
1168 if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) { |
1169 RoadTypes rts = GetRoadTypes(rampsouth); |
1169 RoadTypes rts = GetRoadTypes(rampsouth); |
1170 |
1170 |
1171 if (HASBIT(rts, ROADTYPE_TRAM)) { |
1171 if (HasBit(rts, ROADTYPE_TRAM)) { |
1172 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
1172 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
1173 DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HASBIT(rts, ROADTYPE_ROAD)); |
1173 DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD)); |
1174 } else { |
1174 } else { |
1175 EndSpriteCombine(); |
1175 EndSpriteCombine(); |
1176 StartSpriteCombine(); |
1176 StartSpriteCombine(); |
1177 } |
1177 } |
1178 } else if (GetRailType(rampsouth) == RAILTYPE_ELECTRIC) { |
1178 } else if (GetRailType(rampsouth) == RAILTYPE_ELECTRIC) { |
1232 |
1232 |
1233 /* On the bridge ramp? */ |
1233 /* On the bridge ramp? */ |
1234 if (5 <= pos && pos <= 10) { |
1234 if (5 <= pos && pos <= 10) { |
1235 uint delta; |
1235 uint delta; |
1236 |
1236 |
1237 if (HASBIT(BRIDGE_HORZ_RAMP, tileh)) return z + TILE_HEIGHT; |
1237 if (HasBit(BRIDGE_HORZ_RAMP, tileh)) return z + TILE_HEIGHT; |
1238 |
1238 |
1239 switch (dir) { |
1239 switch (dir) { |
1240 default: NOT_REACHED(); |
1240 default: NOT_REACHED(); |
1241 case DIAGDIR_NE: delta = (TILE_SIZE - 1 - x) / 2; break; |
1241 case DIAGDIR_NE: delta = (TILE_SIZE - 1 - x) / 2; break; |
1242 case DIAGDIR_SE: delta = y / 2; break; |
1242 case DIAGDIR_SE: delta = y / 2; break; |