Fix #26602: Crash when find mechanic for ride that hasn't been inspected (#26606)

This commit is contained in:
mix authored and GitHub committed 2026-05-23 13:57:30 +02:00
1 parent d841b2dcec
commit 5ddd9d746a
2 files changed
+6 -1

No files matched your search

+1
View File
@@ -2,6 +2,7 @@
------------------------------------------------------------------------
- Improved: [#26566] Improve the performance of sorting sprites.
- Fix: [#26583] The default tab is not highlighted when opening a ride window.
- Fix: [#26602] Crash when locating the nearest mechanic for a ride that has not previously been inspected.
0.5.1 (2026-05-17)
------------------------------------------------------------------------
+5 -1
View File
@@ -1487,8 +1487,12 @@ static void RideCallClosestMechanic(Ride& ride)
Staff* RideFindClosestMechanic(const Ride& ride, int32_t forInspection)
{
const auto stationIndex = ride.inspectionStation.IsNull() ? RideGetFirstValidStationExit(ride) : ride.inspectionStation;
if (stationIndex.IsNull())
return nullptr;
// Get either exit position or entrance position if there is no exit
auto& station = ride.getStation(ride.inspectionStation);
const auto& station = ride.getStation(stationIndex);
TileCoordsXYZD location = station.Exit;
if (location.IsNull())
{