1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-28 01:04:50 +01:00

Reduce the use of GET_VEHICLE (#12494)

* Start removing GET_VEHICLE macro use

* Further work

* Remove further GET_VEHICLE's

* Further removal of GET_VEHICLE

* Remove the last of GET_VEHICLE

* Fix testpaint

* Fix nullptr deref

* Make review changes

Also swapped in helper functions and used a standard patern for iterating the train cars

* Further simplify loops for train cars
This commit is contained in:
Duncan
2020-07-31 07:48:27 +01:00
committed by GitHub
parent d32809eaef
commit c6e26267a4
31 changed files with 421 additions and 401 deletions

View File

@@ -256,14 +256,12 @@ static int32_t cc_rides(InteractiveConsole& console, const arguments_t& argv)
}
else
{
for (int32_t i = 0; i < ride->num_vehicles; i++)
for (int32_t i = 0; i < ride->num_vehicles; ++i)
{
uint16_t vehicle_index = ride->vehicles[i];
while (vehicle_index != SPRITE_INDEX_NULL)
for (Vehicle* vehicle = GetEntity<Vehicle>(ride->vehicles[i]); vehicle != nullptr;
vehicle = GetEntity<Vehicle>(vehicle->next_vehicle_on_train))
{
Vehicle* vehicle = GET_VEHICLE(vehicle_index);
vehicle->mass = mass;
vehicle_index = vehicle->next_vehicle_on_train;
}
}
}