Validate access to peep_loading_positions (#4475)

This commit is contained in:
Michał Janiszewski 2017-06-07 22:56:29 +02:00 committed by Ted John
parent dccc9f88c2
commit ff9417f4a6
5 changed files with 13 additions and 2 deletions

View File

@ -126,6 +126,7 @@ void RideObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
numPeepLoadingPositions = stream->ReadValue<uint16>();
}
_peepLoadingPositions[i] = stream->ReadArray<sint8>(numPeepLoadingPositions);
_peepLoadingPositionsCount[i] = numPeepLoadingPositions;
}
GetImageTable()->Read(context, stream);
@ -354,6 +355,9 @@ void RideObject::Load()
set_vehicle_type_image_max_sizes(vehicleEntry, num_images);
}
vehicleEntry->peep_loading_positions = _peepLoadingPositions[i];
#ifdef NO_RCT2
vehicleEntry->peep_loading_positions_count = _peepLoadingPositionsCount[i];
#endif
}
}
}

View File

@ -29,6 +29,7 @@ private:
rct_ride_entry _legacyType = { 0 };
vehicle_colour_preset_list _presetColours = { 0 };
sint8 * _peepLoadingPositions[4] = { nullptr };
uint16 _peepLoadingPositionsCount[4] = { 0 };
public:
explicit RideObject(const rct_object_entry &entry) : Object(entry) { }

View File

@ -2778,6 +2778,9 @@ static void peep_update_ride_sub_state_1(rct_peep* peep){
return;
}
#ifdef NO_RCT2
assert(peep->current_seat < vehicle_type->peep_loading_positions_count);
#endif
sint8 load_position = vehicle_type->peep_loading_positions[peep->current_seat];
switch (vehicle->sprite_direction / 8){

View File

@ -123,7 +123,7 @@ typedef struct rct_ride_entry {
uint8 shop_item; // 0x1C0
uint8 shop_item_secondary; // 0x1C1
} rct_ride_entry;
#ifdef PLATFORM_32BIT
#if defined(PLATFORM_32BIT) && !defined(NO_RCT2)
assert_struct_size(rct_ride_entry, 0x1c2);
#endif

View File

@ -77,8 +77,11 @@ typedef struct rct_ride_entry_vehicle {
uint8 draw_order;
uint8 special_frames; // 0x60 , 0x7A
sint8* peep_loading_positions; // 0x61 , 0x7B
#ifdef NO_RCT2
uint16 peep_loading_positions_count;
#endif
} rct_ride_entry_vehicle;
#ifdef PLATFORM_32BIT
#if defined(PLATFORM_32BIT) && !defined(NO_RCT2)
assert_struct_size(rct_ride_entry_vehicle, 0x65);
#endif