mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-24 13:09:16 +01:00
Merge branch 'master' into feat/renderers-cleanup
This commit is contained in:
@@ -901,7 +901,7 @@ void TMoverParameters::UpdatePantVolume(double dt)
|
||||
// Ra 2013-12: Niebugocław mówi, że w EZT nie ma potrzeby odcinać kurkiem
|
||||
PantPress = ScndPipePress;
|
||||
// ograniczenie ciśnienia do MaxPress (tylko w pantografach!)
|
||||
PantPress = std::clamp(ScndPipePress, 0.0, EnginePowerSource.CollectorParameters.MaxPress);
|
||||
PantPress = safe_clamp(ScndPipePress, 0.0, EnginePowerSource.CollectorParameters.MaxPress);
|
||||
PantVolume = (PantPress + 1.0) * 0.1; // objętość, na wypadek odcięcia kurkiem
|
||||
}
|
||||
else
|
||||
@@ -913,7 +913,7 @@ void TMoverParameters::UpdatePantVolume(double dt)
|
||||
// Ra 2013-12: Niebugocław mówi, że w EZT nabija 1.5 raz wolniej niż jak było 0.005
|
||||
* (TrainType == dt_EZT ? 0.003 : 0.005) / std::max(1.0, PantPress) * (0.45 - (0.1 / PantVolume / 10 - 0.1)) / 0.45;
|
||||
}
|
||||
PantPress = std::clamp(10.0 * PantVolume - 1.0, 0.0, EnginePowerSource.CollectorParameters.MaxPress); // tu by się przydała objętość zbiornika
|
||||
PantPress = safe_clamp(10.0 * PantVolume - 1.0, 0.0, EnginePowerSource.CollectorParameters.MaxPress); // tu by się przydała objętość zbiornika
|
||||
}
|
||||
if (!PantCompFlag && PantVolume > 0.1)
|
||||
PantVolume -= dt * 0.0003 * std::max(1.0, PantPress * 0.5); // nieszczelności: 0.0003=0.3l/s
|
||||
@@ -3952,7 +3952,7 @@ bool TMoverParameters::ChangeCompressorPreset(int const State, range_t const Not
|
||||
|
||||
auto const initialstate{CompressorListPos};
|
||||
|
||||
CompressorListPos = std::clamp(State, 0, CompressorListPosNo);
|
||||
CompressorListPos = safe_clamp(State, 0, CompressorListPosNo);
|
||||
|
||||
if (Notify != range_t::local)
|
||||
{
|
||||
@@ -5625,7 +5625,7 @@ double TMoverParameters::CouplerForce(int const End, double dt)
|
||||
if (thiscoupler.CouplingFlag != coupling::faux || initialdistance < 0)
|
||||
{
|
||||
|
||||
thiscoupler.Dist = std::clamp(newdistance, thiscoupler.has_adapter() ? 0 : -thiscoupler.DmaxB, thiscoupler.DmaxC);
|
||||
thiscoupler.Dist = safe_clamp(newdistance, thiscoupler.has_adapter() ? 0 : -thiscoupler.DmaxB, thiscoupler.DmaxC);
|
||||
|
||||
double BetaAvg = 0;
|
||||
double Fmax = 0;
|
||||
@@ -5923,7 +5923,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
|
||||
if (enrot != tmp)
|
||||
{
|
||||
enrot = std::clamp(enrot + dt / dizel_AIM * (enrot < tmp ? 1.0 : -1.0 * dizel_RevolutionsDecreaseRate), // NOTE: revolutions typically drop faster than they rise
|
||||
enrot = safe_clamp(enrot + dt / dizel_AIM * (enrot < tmp ? 1.0 : -1.0 * dizel_RevolutionsDecreaseRate), // NOTE: revolutions typically drop faster than they rise
|
||||
0.0, std::max(tmp, enrot));
|
||||
if (std::abs(tmp - enrot) < 0.001)
|
||||
{
|
||||
@@ -7778,7 +7778,9 @@ double stepped_uc_value(double const Current, double const Ramped, TUniversalCtr
|
||||
{
|
||||
Progress = 0.0;
|
||||
}
|
||||
return safe_clamp(value, Position.MinCtrlVal, Position.MaxCtrlVal);
|
||||
// added after the move to std::clamp: bounds given the other way round are put in order, as master did it
|
||||
auto const [lowest, highest] = std::minmax(Position.MinCtrlVal, Position.MaxCtrlVal);
|
||||
return std::clamp(value, lowest, highest);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -7862,18 +7864,18 @@ void TMoverParameters::CheckEIMIC(double dt)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
eimic -= std::clamp(1.0 + eimic, 0.0, delta); // odejmuj do -1
|
||||
eimic -= safe_clamp(1.0 + eimic, 0.0, delta); // odejmuj do -1
|
||||
if (eimic > 0)
|
||||
eimic = 0;
|
||||
break;
|
||||
case 2:
|
||||
eimic -= std::clamp(0.0 + eimic, 0.0, delta); // odejmuj do 0
|
||||
eimic -= safe_clamp(0.0 + eimic, 0.0, delta); // odejmuj do 0
|
||||
break;
|
||||
case 3:
|
||||
eimic += std::clamp(0.0 - eimic, 0.0, delta); // dodawaj do 0
|
||||
eimic += safe_clamp(0.0 - eimic, 0.0, delta); // dodawaj do 0
|
||||
break;
|
||||
case 4:
|
||||
eimic += std::clamp(1.0 - eimic, 0.0, delta); // dodawaj do 1
|
||||
eimic += safe_clamp(1.0 - eimic, 0.0, delta); // dodawaj do 1
|
||||
if (eimic < 0)
|
||||
eimic = 0;
|
||||
break;
|
||||
@@ -7980,7 +7982,7 @@ void TMoverParameters::CheckEIMIC(double dt)
|
||||
eimic_max = 0.001;
|
||||
}
|
||||
}
|
||||
eimic = std::clamp(eimic, -1.0, eimicpowerenabled ? eimic_max : 0.0);
|
||||
eimic = safe_clamp(eimic, -1.0, eimicpowerenabled ? eimic_max : 0.0);
|
||||
}
|
||||
|
||||
void TMoverParameters::CheckSpeedCtrl(double dt)
|
||||
@@ -8038,7 +8040,7 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
|
||||
eimicSpeedCtrlIntegral = 0;
|
||||
}
|
||||
auto const DesiredeimicSpeedCtrl{safe_clamp(eimicSpeedCtrlIntegral + eSCP, -SpeedCtrlUnit.DesiredPower, accfactor)};
|
||||
eimicSpeedCtrl = std::clamp(DesiredeimicSpeedCtrl, eimicSpeedCtrl - SpeedCtrlUnit.PowerDownSpeed * dt, eimicSpeedCtrl + SpeedCtrlUnit.PowerUpSpeed * dt);
|
||||
eimicSpeedCtrl = safe_clamp(DesiredeimicSpeedCtrl, eimicSpeedCtrl - SpeedCtrlUnit.PowerDownSpeed * dt, eimicSpeedCtrl + SpeedCtrlUnit.PowerUpSpeed * dt);
|
||||
if (Vel < SpeedCtrlUnit.FullPowerVelocity)
|
||||
{
|
||||
eimicSpeedCtrl = std::min(eimicSpeedCtrl, SpeedCtrlUnit.InitialPower);
|
||||
@@ -8968,7 +8970,7 @@ bool TMoverParameters::AssignLoad(std::string const &Loadname, float const Amoun
|
||||
}
|
||||
LoadTypeChange = LoadType.name != Loadname;
|
||||
LoadType = *loadattributes;
|
||||
LoadAmount = std::clamp(Amount, 0.f, MaxLoad);
|
||||
LoadAmount = safe_clamp(Amount, 0.f, MaxLoad);
|
||||
ComputeMass();
|
||||
return true;
|
||||
}
|
||||
@@ -9013,7 +9015,7 @@ bool TMoverParameters::LoadingDone(double const LSpeed, std::string_view Loadnam
|
||||
{
|
||||
// pusto lub rozładowano żądaną ilość
|
||||
LoadStatus = 4; // skończony rozładunek
|
||||
LoadAmount = std::clamp(LoadAmount, 0.f, MaxLoad); // ładunek nie może być ujemny
|
||||
LoadAmount = safe_clamp(LoadAmount, 0.f, MaxLoad); // ładunek nie może być ujemny
|
||||
}
|
||||
if (LoadAmount == 0.f)
|
||||
{
|
||||
@@ -12891,7 +12893,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
|
||||
{
|
||||
SecuritySystem.MagnetLocation = Dim.L / 2 - 0.5;
|
||||
}
|
||||
SecuritySystem.MagnetLocation = std::clamp(SecuritySystem.MagnetLocation, 0.0, Dim.L);
|
||||
SecuritySystem.MagnetLocation = safe_clamp(SecuritySystem.MagnetLocation, 0.0, Dim.L);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -13293,7 +13295,7 @@ bool TMoverParameters::RunCommand(std::string const &Command, double CValue1, do
|
||||
}
|
||||
else if (Command == "CompressorPreset")
|
||||
{
|
||||
CompressorListPos = std::clamp(static_cast<int>(CValue1), 0, CompressorListPosNo);
|
||||
CompressorListPos = safe_clamp(static_cast<int>(CValue1), 0, CompressorListPosNo);
|
||||
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
|
||||
}
|
||||
else if (Command == "DoorPermit")
|
||||
|
||||
Reference in New Issue
Block a user