mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-27 08:45:00 +01:00
Fix #5939: Crash when importing 'Six Flags Santa Fe'
Protect fix_invalid_vehicle_sprite_sizes from invalid vehicle chains.
This commit is contained in:
@@ -8706,13 +8706,13 @@ void fix_invalid_vehicle_sprite_sizes()
|
||||
for (uint16 j = 0; j < MAX_VEHICLES_PER_RIDE; j++) {
|
||||
uint16 rideSpriteIndex = ride->vehicles[j];
|
||||
while (rideSpriteIndex != SPRITE_INDEX_NULL) {
|
||||
rct_vehicle *vehicle = GET_VEHICLE(rideSpriteIndex);
|
||||
rct_ride_entry_vehicle *vehicleEntry = vehicle_get_vehicle_entry(vehicle);
|
||||
rct_vehicle * vehicle = try_get_vehicle(rideSpriteIndex);
|
||||
if (vehicle == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (vehicle == NULL ||
|
||||
vehicleEntry == NULL ||
|
||||
vehicleEntry == (rct_ride_entry_vehicle*)-1)
|
||||
{
|
||||
rct_ride_entry_vehicle * vehicleEntry = vehicle_get_vehicle_entry(vehicle);
|
||||
if (vehicleEntry == NULL || vehicleEntry == (rct_ride_entry_vehicle*)-1) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -657,6 +657,14 @@ static const struct { sint8 x, y, z; } SteamParticleOffsets[] = {
|
||||
{ -8, -4, 17 }
|
||||
};
|
||||
|
||||
rct_vehicle * try_get_vehicle(uint16 spriteIndex)
|
||||
{
|
||||
rct_sprite * sprite = try_get_sprite(spriteIndex);
|
||||
if (sprite == NULL) return NULL;
|
||||
if (sprite->unknown.sprite_identifier != SPRITE_IDENTIFIER_VEHICLE) return NULL;
|
||||
return &sprite->vehicle;
|
||||
}
|
||||
|
||||
static void vehicle_invalidate(rct_vehicle *vehicle)
|
||||
{
|
||||
invalidate_sprite_2((rct_sprite*)vehicle);
|
||||
|
||||
@@ -369,6 +369,7 @@ enum {
|
||||
#define VEHICLE_SEAT_PAIR_FLAG 0x80
|
||||
#define VEHICLE_SEAT_NUM_MASK 0x7F
|
||||
|
||||
rct_vehicle * try_get_vehicle(uint16 spriteIndex);
|
||||
void vehicle_update_all();
|
||||
sint32 sub_6BC2F3(rct_vehicle* vehicle);
|
||||
void vehicle_sounds_update();
|
||||
|
||||
Reference in New Issue
Block a user