mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #3781: Glitchy map causing crash
This commit is contained in:
parent
216836cd12
commit
75685fa75d
|
@ -220,6 +220,10 @@ static void park_entrance_paint(paint_session * session, uint8 direction, sint32
|
|||
}
|
||||
|
||||
entrance = (rct_entrance_type*)object_entry_groups[OBJECT_TYPE_PARK_ENTRANCE].chunks[0];
|
||||
if (entrance == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
image_id = (entrance->image_id + direction * 3) | ghost_id;
|
||||
sub_98197C(session, image_id, 0, 0, 0x1C, 0x1C, 0x2F, height, 2, 2, height + 32, get_current_rotation());
|
||||
|
||||
|
@ -258,6 +262,10 @@ static void park_entrance_paint(paint_session * session, uint8 direction, sint32
|
|||
case 1:
|
||||
case 2:
|
||||
entrance = (rct_entrance_type*)object_entry_groups[OBJECT_TYPE_PARK_ENTRANCE].chunks[0];
|
||||
if (entrance == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
image_id = (entrance->image_id + part_index + direction * 3) | ghost_id;
|
||||
sub_98197C(session, image_id, 0, 0, 0x1A, di, 0x4F, height, 3, 3, height, get_current_rotation());
|
||||
break;
|
||||
|
|
|
@ -2980,6 +2980,11 @@ static void peep_update_ride_sub_state_1(rct_peep * peep)
|
|||
ride_entry = get_ride_entry(vehicle->ride_subtype);
|
||||
rct_ride_entry_vehicle * vehicle_type = &ride_entry->vehicles[vehicle->vehicle_type];
|
||||
|
||||
if (ride_entry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (vehicle_type->flags & VEHICLE_ENTRY_FLAG_26)
|
||||
{
|
||||
x = ride->entrances[peep->current_ride_station].x;
|
||||
|
@ -3264,6 +3269,10 @@ static void peep_update_ride_sub_state_2(rct_peep * peep)
|
|||
}
|
||||
|
||||
rct_ride_entry * ride_entry = get_ride_entry(vehicle->ride_subtype);
|
||||
if (ride_entry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ride_entry->vehicles[0].flags & VEHICLE_ENTRY_FLAG_MINI_GOLF)
|
||||
{
|
||||
|
@ -3434,6 +3443,11 @@ static void peep_update_ride_sub_state_7(rct_peep * peep)
|
|||
rct_ride_entry * ride_entry = get_ride_entry(vehicle->ride_subtype);
|
||||
rct_ride_entry_vehicle * vehicle_entry = &ride_entry->vehicles[vehicle->vehicle_type];
|
||||
|
||||
if (ride_entry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(vehicle_entry->flags & VEHICLE_ENTRY_FLAG_26))
|
||||
{
|
||||
sint16 x, y, z;
|
||||
|
@ -3772,6 +3786,11 @@ static void peep_update_ride_sub_state_12(rct_peep * peep)
|
|||
rct_ride_entry * ride_entry = get_ride_entry(vehicle->ride_subtype);
|
||||
rct_ride_entry_vehicle * vehicle_type = &ride_entry->vehicles[vehicle->vehicle_type];
|
||||
|
||||
if (ride_entry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x += vehicle_type->peep_loading_positions[peep->var_37 * 2 + 1];
|
||||
y += vehicle_type->peep_loading_positions[peep->var_37 * 2 + 2];
|
||||
|
||||
|
@ -5902,7 +5921,7 @@ static sint32 peep_update_walking_find_bench(rct_peep * peep)
|
|||
return 0;
|
||||
rct_scenery_entry * sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element));
|
||||
|
||||
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH))
|
||||
if (sceneryEntry == nullptr || !(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH))
|
||||
return 0;
|
||||
|
||||
if (map_element->flags & MAP_ELEMENT_FLAG_BROKEN)
|
||||
|
@ -6005,6 +6024,10 @@ static sint32 peep_update_walking_find_bin(rct_peep * peep)
|
|||
if (!footpath_element_has_path_scenery(map_element))
|
||||
return 0;
|
||||
rct_scenery_entry * sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element));
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))
|
||||
return 0;
|
||||
|
@ -6236,6 +6259,10 @@ static void peep_update_buying(rct_peep * peep)
|
|||
else
|
||||
{
|
||||
rct_ride_entry * ride_type = get_ride_entry(ride->subtype);
|
||||
if (ride_type == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ride_type->shop_item_secondary != SHOP_ITEM_NONE)
|
||||
{
|
||||
money16 price = ride->price_secondary;
|
||||
|
@ -6271,7 +6298,6 @@ static void peep_update_buying(rct_peep * peep)
|
|||
ride_update_popularity(ride, 0);
|
||||
}
|
||||
peep->sub_state = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
/** rct2: 0x0097EFCC */
|
||||
|
@ -7248,6 +7274,10 @@ static void peep_update_walking(rct_peep * peep)
|
|||
if (!footpath_element_path_scenery_is_ghost(map_element))
|
||||
{
|
||||
rct_scenery_entry * sceneryEntry = get_footpath_item_entry(footpath_element_get_path_scenery_index(map_element));
|
||||
if (sceneryEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH))
|
||||
ebp = 9;
|
||||
|
@ -9644,6 +9674,10 @@ static uint8 footpath_element_dest_in_dir(sint16 x, sint16 y, sint16 z, rct_map_
|
|||
x += TileDirectionDelta[chosenDirection].x;
|
||||
y += TileDirectionDelta[chosenDirection].y;
|
||||
mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||
if (mapElement == nullptr)
|
||||
{
|
||||
return PATH_SEARCH_FAILED;
|
||||
}
|
||||
do
|
||||
{
|
||||
if (mapElement->flags & MAP_ELEMENT_FLAG_GHOST)
|
||||
|
@ -9988,6 +10022,10 @@ static void peep_pathfind_heuristic_search(sint16 x, sint16 y, uint8 z, rct_peep
|
|||
/* Get the next map element of interest in the direction of test_edge. */
|
||||
bool found = false;
|
||||
rct_map_element * mapElement = map_get_first_element_at(x / 32, y / 32);
|
||||
if (mapElement == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
do
|
||||
{
|
||||
/* Look for all map elements that the peep could walk onto while
|
||||
|
@ -12632,7 +12670,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT
|
|||
continue;
|
||||
if (map_element_get_direction(mapElement) != edge)
|
||||
continue;
|
||||
if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
auto wallEntry = get_wall_entry(mapElement->properties.wall.type);
|
||||
if (wallEntry == nullptr || wallEntry->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
continue;
|
||||
if (peep->next_z + 4 <= mapElement->base_height)
|
||||
continue;
|
||||
|
@ -12665,7 +12704,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT
|
|||
continue;
|
||||
if (map_element_get_direction_with_offset(mapElement, 2) != edge)
|
||||
continue;
|
||||
if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
auto wallEntry = get_wall_entry(mapElement->properties.wall.type);
|
||||
if (wallEntry == nullptr || wallEntry->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
continue;
|
||||
// TODO: Check whether this shouldn't be <=, as the other loops use. If so, also extract as loop A.
|
||||
if (peep->next_z + 4 >= mapElement->base_height)
|
||||
|
@ -12743,7 +12783,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT
|
|||
|
||||
if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL)
|
||||
{
|
||||
if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
auto wallEntry = get_wall_entry(mapElement->properties.wall.type);
|
||||
if (wallEntry == nullptr || wallEntry->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -12776,7 +12817,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT
|
|||
continue;
|
||||
if (map_element_get_direction_with_offset(mapElement, 2) != edge)
|
||||
continue;
|
||||
if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
auto wallEntry = get_wall_entry(mapElement->properties.wall.type);
|
||||
if (wallEntry == nullptr || wallEntry->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
continue;
|
||||
if (peep->next_z + 6 <= mapElement->base_height)
|
||||
continue;
|
||||
|
@ -12812,7 +12854,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT
|
|||
|
||||
if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_SCENERY_MULTIPLE)
|
||||
{
|
||||
if (!(get_large_scenery_entry(mapElement->properties.scenerymultiple.type & 0x3FF)->large_scenery.flags &
|
||||
auto sceneryEntry = get_large_scenery_entry(mapElement->properties.scenerymultiple.type & 0x3FF);
|
||||
if (!(sceneryEntry == nullptr || sceneryEntry->large_scenery.flags &
|
||||
LARGE_SCENERY_FLAG_PHOTOGENIC))
|
||||
{
|
||||
continue;
|
||||
|
@ -12852,7 +12895,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT
|
|||
|
||||
if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_WALL)
|
||||
{
|
||||
if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
auto wallEntry = get_wall_entry(mapElement->properties.wall.type);
|
||||
if (wallEntry == nullptr || wallEntry->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -12885,7 +12929,8 @@ static bool peep_find_ride_to_look_at(rct_peep * peep, uint8 edge, uint8 * rideT
|
|||
continue;
|
||||
if (map_element_get_direction_with_offset(mapElement, 2) != edge)
|
||||
continue;
|
||||
if (get_wall_entry(mapElement->properties.wall.type)->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
auto wallEntry = get_wall_entry(mapElement->properties.wall.type);
|
||||
if (wallEntry == nullptr || wallEntry->wall.flags2 & WALL_SCENERY_2_FLAG4)
|
||||
continue;
|
||||
if (peep->next_z + 8 <= mapElement->base_height)
|
||||
continue;
|
||||
|
|
|
@ -1420,6 +1420,10 @@ static sint32 vehicle_open_restraints(rct_vehicle * vehicle)
|
|||
rct_ride_entry * rideEntry = get_ride_entry(vehicle->ride_subtype);
|
||||
rct_ride_entry_vehicle * vehicleEntry = &rideEntry->vehicles[vehicle->vehicle_type];
|
||||
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
|
||||
{
|
||||
if (abs(vehicle->var_B6) <= 700 && !(vehicle->var_BA & 0x30) &&
|
||||
|
@ -2066,6 +2070,11 @@ static void vehicle_update_moving_to_end_of_station(rct_vehicle * vehicle)
|
|||
rct_ride_entry * rideEntry = get_ride_entry(vehicle->ride_subtype);
|
||||
rct_ride_entry_vehicle * vehicleEntry = &rideEntry->vehicles[vehicle->vehicle_type];
|
||||
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_POWERED))
|
||||
{
|
||||
if (vehicle->velocity <= 131940)
|
||||
|
@ -2419,6 +2428,10 @@ static void vehicle_update_dodgems_mode(rct_vehicle * vehicle)
|
|||
{
|
||||
Ride * ride = get_ride(vehicle->ride);
|
||||
rct_ride_entry * rideEntry = get_ride_entry(vehicle->ride_subtype);
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
rct_ride_entry_vehicle * vehicleEntry = &rideEntry->vehicles[vehicle->vehicle_type];
|
||||
|
||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_7 && vehicle->var_C5 != 1)
|
||||
|
@ -3180,6 +3193,10 @@ static void vehicle_update_departing(rct_vehicle * vehicle)
|
|||
{
|
||||
Ride * ride = get_ride(vehicle->ride);
|
||||
rct_ride_entry * rideEntry = get_ride_entry(vehicle->ride_subtype);
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (vehicle->sub_state == 0)
|
||||
{
|
||||
|
@ -4862,6 +4879,10 @@ static void vehicle_update_rotating(rct_vehicle * vehicle)
|
|||
|
||||
Ride * ride = get_ride(vehicle->ride);
|
||||
rct_ride_entry * rideEntry = get_ride_entry(vehicle->ride_subtype);
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8 * timeToSpriteMap;
|
||||
if (rideEntry->flags & RIDE_ENTRY_FLAG_ALTERNATIVE_ROTATION_MODE_1)
|
||||
|
|
|
@ -39,6 +39,11 @@ static void paint_merry_go_round_structure(paint_session * session, uint8 rideIn
|
|||
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);
|
||||
rct_vehicle * vehicle = NULL;
|
||||
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 baseImageId = rideEntry->vehicles[0].base_image_id;
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && ride->vehicles[0] != SPRITE_INDEX_NULL)
|
||||
|
|
|
@ -2332,7 +2332,7 @@ static sint32 ride_get_new_breakdown_problem(Ride *ride)
|
|||
_breakdownProblemProbabilities[BREAKDOWN_BRAKES_FAILURE] = gClimateCurrentRainLevel == 0 ? 3 : 20;
|
||||
|
||||
entry = get_ride_entry_by_ride(ride);
|
||||
if (entry->flags & RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN)
|
||||
if (entry == NULL || entry->flags & RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN)
|
||||
return -1;
|
||||
|
||||
availableBreakdownProblems = RideAvailableBreakdowns[ride->type];
|
||||
|
@ -3278,6 +3278,10 @@ static void ride_shop_connected(Ride* ride, sint32 ride_idx)
|
|||
uint16 entrance_directions = 0;
|
||||
uint8 track_type = mapElement->properties.track.type;
|
||||
ride = get_ride(mapElement->properties.track.ride_index);
|
||||
if (ride == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) {
|
||||
entrance_directions = FlatRideTrackSequenceProperties[track_type][0];
|
||||
} else {
|
||||
|
|
|
@ -823,6 +823,11 @@ static void ride_ratings_apply_adjustments(Ride *ride, rating_tuple *ratings)
|
|||
{
|
||||
rct_ride_entry *rideEntry = get_ride_entry(ride->subtype);
|
||||
|
||||
if (rideEntry == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply ride entry multipliers
|
||||
ride_ratings_add(ratings,
|
||||
(((sint32)ratings->excitement * rideEntry->excitement_multipler) >> 7),
|
||||
|
@ -963,6 +968,10 @@ static sint32 get_num_of_sheltered_eighths(Ride *ride)
|
|||
|
||||
sint32 dh = numShelteredEighths;
|
||||
rct_ride_entry *rideType = get_ride_entry(ride->subtype);
|
||||
if (rideType == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (rideType->flags & RIDE_ENTRY_FLAG_COVERED_RIDE)
|
||||
numShelteredEighths = 7;
|
||||
|
||||
|
|
|
@ -31,6 +31,11 @@ static void paint_3d_cinema_structure(paint_session * session, uint8 rideIndex,
|
|||
Ride * ride = get_ride(rideIndex);
|
||||
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);
|
||||
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && ride->vehicles[0] != SPRITE_INDEX_NULL)
|
||||
{
|
||||
session->InteractionType = VIEWPORT_INTERACTION_ITEM_SPRITE;
|
||||
|
|
|
@ -31,6 +31,11 @@ static void paint_enterprise_structure(paint_session * session, Ride * ride, sin
|
|||
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);
|
||||
rct_vehicle * vehicle = NULL;
|
||||
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 baseImageId = rideEntry->vehicles[0].base_image_id;
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && ride->vehicles[0] != SPRITE_INDEX_NULL)
|
||||
|
|
|
@ -30,6 +30,11 @@ static void paint_twist_structure(paint_session * session, Ride * ride, uint8 di
|
|||
rct_ride_entry * rideEntry = get_ride_entry(ride->subtype);
|
||||
rct_vehicle * vehicle = NULL;
|
||||
|
||||
if (rideEntry == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
height += 7;
|
||||
uint32 baseImageId = rideEntry->vehicles[0].base_image_id;
|
||||
|
||||
|
|
|
@ -3545,7 +3545,7 @@ sint32 map_element_get_banner_index(rct_map_element *mapElement)
|
|||
((mapElement->properties.scenerymultiple.colour[1] & 0xE0) >> 5);
|
||||
case MAP_ELEMENT_TYPE_WALL:
|
||||
sceneryEntry = get_wall_entry(mapElement->properties.wall.type);
|
||||
if (sceneryEntry->wall.scrolling_mode == 0xFF)
|
||||
if (sceneryEntry == NULL || sceneryEntry->wall.scrolling_mode == 0xFF)
|
||||
return -1;
|
||||
|
||||
return mapElement->properties.wall.banner_index;
|
||||
|
|
Loading…
Reference in New Issue