16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

Merge pull request #108 from docentYT/fix-clamp-exception

Fix two bugs that causes simulator crash
This commit is contained in:
Christopher Kwiatkowski
2026-05-12 16:58:41 +02:00
committed by GitHub
3 changed files with 4 additions and 4 deletions

View File

@@ -96,9 +96,9 @@ bool ClearFlag(int &Flag, int const Value)
}
}
double Random(double a, double b)
double Random(double min, double max)
{
std::uniform_real_distribution<double> dist(a, b);
std::uniform_real_distribution<double> dist(min, max);
return dist(Global.random_engine);
}

View File

@@ -4410,7 +4410,7 @@ void TController::Doors( bool const Open, int const Side ) {
vehicle = vehicle->Next(); // pojazd podłączony z tyłu (patrząc od czoła)
}
}
fActionTime = Random( -1.0, -3.5 ); // 1.0-3.5 sec wait
fActionTime = Random(-3.5, -1.0); // 1.0-3.5 sec wait
iDrivigFlags &= ~moveDoorOpened; // zostały zamknięte - nie wykonywać drugi raz
iDrivigFlags &= ~moveDepartureWarned;
}

View File

@@ -3076,7 +3076,7 @@ TDynamicObject::update_load_offset() {
0.0 :
100.0 * MoverParameters->LoadAmount / MoverParameters->MaxLoad ) };
LoadOffset = std::lerp( MoverParameters->LoadType.offset_min, 0.f, std::clamp( 0.0, 1.0, loadpercentage * 0.01 ) );
LoadOffset = std::lerp( MoverParameters->LoadType.offset_min, 0.f, std::clamp( 0.0, loadpercentage * 0.01, 1.0 ) );
}
void