diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp index 7aad3300..156d16cc 100644 --- a/utilities/utilities.cpp +++ b/utilities/utilities.cpp @@ -125,12 +125,14 @@ bool ClearFlag(int &Flag, int const Value) double Random(double min, double max) { + if (max < min) { std::swap(min, max); } // std::uniform_real_distribution requires min <= max (inverted bounds are UB) std::uniform_real_distribution dist(min, max); return dist(Global.random_engine); } int Random(int min, int max) { + if (max < min) { std::swap(min, max); } // std::uniform_int_distribution requires min <= max (inverted bounds are UB) std::uniform_int_distribution dist(min, max); return dist(Global.random_engine); } @@ -163,6 +165,7 @@ std::string generate_uuid_v4() double LocalRandom(double a, double b) { + if (b < a) { std::swap(a, b); } // std::uniform_real_distribution requires a <= b (inverted bounds are UB) std::uniform_real_distribution dist(a, b); return dist(Global.local_random_engine); } diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 328f4273..1552ead7 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -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; }