mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 00:49:19 +02:00
fix: guard Random/LocalRandom against inverted min>max bounds
std::uniform_real/int_distribution has UB when min>max. The old "fancy Random" used interpolate(a,b,t) which tolerated a>b; the migration to std::uniform_real_distribution did not, and only one inverted call site was fixed by hand. Swap the bounds inside Random()/Random(int)/LocalRandom() so every call site is safe, and reorder the two inverted literal calls in Driver.cpp (fActionTime buzzer / departure delay) for readability.
This commit is contained in:
@@ -4293,12 +4293,12 @@ void TController::Doors( bool const Open, int const Side ) {
|
||||
{
|
||||
// Not warned yet, not warning yet - start the warning signal.
|
||||
cue_action( driver_hint::departuresignalon ); // załącenie bzyczka
|
||||
fActionTime = Random( -0.3, -0.8 ); // 0.3-0.8 second buzzer
|
||||
fActionTime = Random( -0.8, -0.3 ); // 0.3-0.8 second buzzer
|
||||
return;
|
||||
}
|
||||
// Not warned yet, warning now - stop the warning signal and mark it as done.
|
||||
cue_action( driver_hint::departuresignaloff );
|
||||
fActionTime = Random( 0.0, -0.2 ); // Wait just a bit more before departing
|
||||
fActionTime = Random( -0.2, 0.0 ); // Wait just a bit more before departing
|
||||
iDrivigFlags |= moveDepartureWarned;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user