mirror of https://github.com/OpenRCT2/OpenRCT2.git
* Fix #19245: NPE in UpdateRideApproachExitWaypoints() * Apply suggestions from code review Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
parent
1bf5d2eb50
commit
c260a95abc
|
@ -4515,16 +4515,26 @@ void Guest::UpdateRideApproachExitWaypoints()
|
|||
return;
|
||||
}
|
||||
|
||||
const auto& rtd = ride->GetRideTypeDescriptor();
|
||||
CoordsXY targetLoc = rtd.GetGuestWaypointLocation(*vehicle, *ride, CurrentRideStation);
|
||||
|
||||
RideObjectEntry* rideEntry = vehicle->GetRideEntry();
|
||||
CarEntry* carEntry = &rideEntry->Cars[vehicle->vehicle_type];
|
||||
if (rideEntry == nullptr)
|
||||
return;
|
||||
|
||||
Guard::Assert((Var37 & 3) < 3);
|
||||
targetLoc.x += carEntry->peep_loading_waypoints[Var37 / 4][Var37 & 3].x;
|
||||
targetLoc.y += carEntry->peep_loading_waypoints[Var37 / 4][Var37 & 3].y;
|
||||
if (vehicle->vehicle_type >= std::size(rideEntry->Cars))
|
||||
return;
|
||||
|
||||
const CarEntry& carEntry = rideEntry->Cars[vehicle->vehicle_type];
|
||||
|
||||
const size_t carPosition = Var37 / 4;
|
||||
if (carPosition >= carEntry.peep_loading_waypoints.size())
|
||||
return;
|
||||
|
||||
const auto waypoint = Var37 & 3;
|
||||
Guard::Assert(waypoint < 3);
|
||||
|
||||
const auto& rtd = ride->GetRideTypeDescriptor();
|
||||
|
||||
CoordsXY targetLoc = rtd.GetGuestWaypointLocation(*vehicle, *ride, CurrentRideStation);
|
||||
targetLoc += carEntry.peep_loading_waypoints[carPosition][waypoint];
|
||||
SetDestination(targetLoc);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue