MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ChooseRandomTrainToBreakdownSafe

Function ChooseRandomTrainToBreakdownSafe

src/openrct2/ride/Ride.cpp:1226–1240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1224}
1225
1226static void ChooseRandomTrainToBreakdownSafe(Ride& ride)
1227{
1228 // Prevent integer division by zero in case of hacked ride.
1229 if (ride.numTrains == 0)
1230 return;
1231
1232 ride.brokenTrain = ScenarioRand() % ride.numTrains;
1233
1234 // Prevent crash caused by accessing SPRITE_INDEX_NULL on hacked rides.
1235 // This should probably be cleaned up on import instead.
1236 while (ride.vehicles[ride.brokenTrain].IsNull() && ride.brokenTrain != 0)
1237 {
1238 --ride.brokenTrain;
1239 }
1240}
1241
1242/**
1243 *

Callers 1

RidePrepareBreakdownFunction · 0.85

Calls 2

ScenarioRandFunction · 0.85
IsNullMethod · 0.45

Tested by

no test coverage detected