mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-05 20:39:09 +01:00
refactor(sonar): rename locals that shadow outer declarations (cpp:S1117)
Only local variables and definition parameters are renamed; shadowing struct fields and enumerators in headers are left for a separate change.
This commit is contained in:
@@ -591,29 +591,29 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &coupler{Couplers[ConnectNo]};
|
auto &thiscoupler{Couplers[ConnectNo]};
|
||||||
auto &othercoupler = ConnectTo->Couplers[ConnectToNr != 2 ? ConnectToNr : coupler.ConnectedNr];
|
auto &othercoupler = ConnectTo->Couplers[ConnectToNr != 2 ? ConnectToNr : thiscoupler.ConnectedNr];
|
||||||
auto const distance{CouplerDist(this, ConnectTo) - (coupler.adapter_length + othercoupler.adapter_length)};
|
auto const distance{CouplerDist(this, ConnectTo) - (thiscoupler.adapter_length + othercoupler.adapter_length)};
|
||||||
|
|
||||||
|
|
||||||
if (auto const couplercheck{Enforce || (distance <= dEpsilon && coupler.type() != TCouplerType::NoCoupler && coupler.type() == othercoupler.type())}; false == couplercheck)
|
if (auto const couplercheck{Enforce || (distance <= dEpsilon && thiscoupler.type() != TCouplerType::NoCoupler && thiscoupler.type() == othercoupler.type())}; false == couplercheck)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stykaja sie zderzaki i kompatybilne typy sprzegow, chyba że łączenie na starcie
|
// stykaja sie zderzaki i kompatybilne typy sprzegow, chyba że łączenie na starcie
|
||||||
if (coupler.CouplingFlag == coupling::faux)
|
if (thiscoupler.CouplingFlag == coupling::faux)
|
||||||
{
|
{
|
||||||
// jeśli wcześniej nie było połączone, ustalenie z której strony rysować sprzęg
|
// jeśli wcześniej nie było połączone, ustalenie z której strony rysować sprzęg
|
||||||
coupler.Render = true; // tego rysować
|
thiscoupler.Render = true; // tego rysować
|
||||||
othercoupler.Render = false; // a tego nie
|
othercoupler.Render = false; // a tego nie
|
||||||
}
|
}
|
||||||
auto const couplingchange{CouplingType ^ coupler.CouplingFlag};
|
auto const couplingchange{CouplingType ^ thiscoupler.CouplingFlag};
|
||||||
coupler.Connected = ConnectTo;
|
thiscoupler.Connected = ConnectTo;
|
||||||
coupler.CouplingFlag = CouplingType; // ustawienie typu sprzęgu
|
thiscoupler.CouplingFlag = CouplingType; // ustawienie typu sprzęgu
|
||||||
if (ConnectToNr != 2)
|
if (ConnectToNr != 2)
|
||||||
{
|
{
|
||||||
coupler.ConnectedNr = ConnectToNr; // 2=nic nie podłączone
|
thiscoupler.ConnectedNr = ConnectToNr; // 2=nic nie podłączone
|
||||||
}
|
}
|
||||||
othercoupler.Connected = this;
|
othercoupler.Connected = this;
|
||||||
othercoupler.CouplingFlag = CouplingType;
|
othercoupler.CouplingFlag = CouplingType;
|
||||||
@@ -633,7 +633,7 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
|
|||||||
soundflag |= mappingsound;
|
soundflag |= mappingsound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetFlag(coupler.sounds, soundflag);
|
SetFlag(thiscoupler.sounds, soundflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -657,30 +657,30 @@ int TMoverParameters::DettachStatus(int ConnectNo)
|
|||||||
bool TMoverParameters::Dettach(int ConnectNo)
|
bool TMoverParameters::Dettach(int ConnectNo)
|
||||||
{ // rozlaczanie
|
{ // rozlaczanie
|
||||||
|
|
||||||
auto &coupler{Couplers[ConnectNo]};
|
auto &thiscoupler{Couplers[ConnectNo]};
|
||||||
auto &othervehicle{coupler.Connected};
|
auto &othervehicle{thiscoupler.Connected};
|
||||||
auto &othercoupler{othervehicle->Couplers[coupler.ConnectedNr]};
|
auto &othercoupler{othervehicle->Couplers[thiscoupler.ConnectedNr]};
|
||||||
|
|
||||||
if (othervehicle == nullptr)
|
if (othervehicle == nullptr)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
} // nie ma nic, to odczepiono
|
} // nie ma nic, to odczepiono
|
||||||
|
|
||||||
auto couplingchange{coupler.CouplingFlag}; // presume we'll uncouple all active flags
|
auto couplingchange{thiscoupler.CouplingFlag}; // presume we'll uncouple all active flags
|
||||||
auto const couplingstate{DettachStatus(ConnectNo)}; // stan sprzęgu
|
auto const couplingstate{DettachStatus(ConnectNo)}; // stan sprzęgu
|
||||||
if (couplingstate < 0)
|
if (couplingstate < 0)
|
||||||
{
|
{
|
||||||
// gdy scisniete zderzaki, chyba ze zerwany sprzeg (wirtualnego nie odpinamy z drugiej strony)
|
// gdy scisniete zderzaki, chyba ze zerwany sprzeg (wirtualnego nie odpinamy z drugiej strony)
|
||||||
std::tie(othercoupler.Connected, othercoupler.ConnectedNr, othercoupler.CouplingFlag) = std::make_tuple(nullptr, -1, coupling::faux);
|
std::tie(othercoupler.Connected, othercoupler.ConnectedNr, othercoupler.CouplingFlag) = std::make_tuple(nullptr, -1, coupling::faux);
|
||||||
std::tie(coupler.Connected, coupler.ConnectedNr, coupler.CouplingFlag) = std::make_tuple(nullptr, -1, coupling::faux);
|
std::tie(thiscoupler.Connected, thiscoupler.ConnectedNr, thiscoupler.CouplingFlag) = std::make_tuple(nullptr, -1, coupling::faux);
|
||||||
}
|
}
|
||||||
else if (couplingstate > 0)
|
else if (couplingstate > 0)
|
||||||
{ // odłączamy węże i resztę, pozostaje sprzęg fizyczny, który wymaga dociśnięcia (z wirtualnym nic)
|
{ // odłączamy węże i resztę, pozostaje sprzęg fizyczny, który wymaga dociśnięcia (z wirtualnym nic)
|
||||||
coupler.CouplingFlag &= coupling::coupler;
|
thiscoupler.CouplingFlag &= coupling::coupler;
|
||||||
othercoupler.CouplingFlag &= coupling::coupler;
|
othercoupler.CouplingFlag &= coupling::coupler;
|
||||||
}
|
}
|
||||||
// set sound event flag
|
// set sound event flag
|
||||||
couplingchange ^= coupler.CouplingFlag; // remaining bits were removed from coupling
|
couplingchange ^= thiscoupler.CouplingFlag; // remaining bits were removed from coupling
|
||||||
if (couplingchange != 0)
|
if (couplingchange != 0)
|
||||||
{
|
{
|
||||||
int soundflag{sound::detach}; // HACK: use detach flag to indicate removal of listed coupling
|
int soundflag{sound::detach}; // HACK: use detach flag to indicate removal of listed coupling
|
||||||
@@ -694,7 +694,7 @@ bool TMoverParameters::Dettach(int ConnectNo)
|
|||||||
soundflag |= mappingsound;
|
soundflag |= mappingsound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetFlag(coupler.sounds, soundflag);
|
SetFlag(thiscoupler.sounds, soundflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return couplingstate < 0;
|
return couplingstate < 0;
|
||||||
@@ -1188,7 +1188,7 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
|
|||||||
return;
|
return;
|
||||||
} // shouldn't normally happen but, eh
|
} // shouldn't normally happen but, eh
|
||||||
|
|
||||||
auto &coupler{Couplers[End]};
|
auto &thiscoupler{Couplers[End]};
|
||||||
auto *othervehicle{Neighbours[End].vehicle->MoverParameters};
|
auto *othervehicle{Neighbours[End].vehicle->MoverParameters};
|
||||||
auto const otherend{Neighbours[End].vehicle_end};
|
auto const otherend{Neighbours[End].vehicle_end};
|
||||||
auto &othercoupler{othervehicle->Couplers[otherend]};
|
auto &othercoupler{othervehicle->Couplers[otherend]};
|
||||||
@@ -1196,19 +1196,19 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
|
|||||||
auto velocity{V};
|
auto velocity{V};
|
||||||
auto othervehiclevelocity{othervehicle->V};
|
auto othervehiclevelocity{othervehicle->V};
|
||||||
// calculate collision force and new velocities for involved vehicles
|
// calculate collision force and new velocities for involved vehicles
|
||||||
auto const VirtualCoupling{(coupler.CouplingFlag == coupling::faux)};
|
auto const VirtualCoupling{(thiscoupler.CouplingFlag == coupling::faux)};
|
||||||
auto CCF{0.0};
|
auto CCF{0.0};
|
||||||
|
|
||||||
switch (End)
|
switch (End)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
CCF = ComputeCollision(velocity, othervehiclevelocity, TotalMass, othervehicle->TotalMass, (coupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
|
CCF = ComputeCollision(velocity, othervehiclevelocity, TotalMass, othervehicle->TotalMass, (thiscoupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
|
||||||
break; // yB: ej ej ej, a po
|
break; // yB: ej ej ej, a po
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->TotalMass, TotalMass, (coupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
|
CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->TotalMass, TotalMass, (thiscoupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -1219,13 +1219,13 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
|
|||||||
|
|
||||||
if (Global.crash_damage)
|
if (Global.crash_damage)
|
||||||
{
|
{
|
||||||
if (-coupler.Dist >= coupler.DmaxB && FuzzyLogic(std::abs(CCF), 5.0 * (coupler.FmaxC + 1.0), p_coupldmg))
|
if (-thiscoupler.Dist >= thiscoupler.DmaxB && FuzzyLogic(std::abs(CCF), 5.0 * (thiscoupler.FmaxC + 1.0), p_coupldmg))
|
||||||
{
|
{
|
||||||
// small chance to smash the coupler if it's hit with excessive force
|
// small chance to smash the coupler if it's hit with excessive force
|
||||||
damage_coupler(End);
|
damage_coupler(End);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coupler.CouplingFlag == coupling::faux || true == TestFlag(othervehicle->DamageFlag, dtrain_out))
|
if (thiscoupler.CouplingFlag == coupling::faux || true == TestFlag(othervehicle->DamageFlag, dtrain_out))
|
||||||
{ // HACK: limit excessive speed derailment checks to vehicles which aren't part of the same consist
|
{ // HACK: limit excessive speed derailment checks to vehicles which aren't part of the same consist
|
||||||
auto const safevelocitylimit{15.0};
|
auto const safevelocitylimit{15.0};
|
||||||
auto const velocitydifference{glm::length(glm::angleAxis(Rot.Rz, glm::dvec3{0, 1, 0}) * V - glm::angleAxis(othervehicle->Rot.Rz, glm::dvec3{0, 1, 0}) * othervehicle->V) *
|
auto const velocitydifference{glm::length(glm::angleAxis(Rot.Rz, glm::dvec3{0, 1, 0}) * V - glm::angleAxis(othervehicle->Rot.Rz, glm::dvec3{0, 1, 0}) * othervehicle->V) *
|
||||||
@@ -1276,9 +1276,9 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
|
|||||||
void TMoverParameters::damage_coupler(int const End)
|
void TMoverParameters::damage_coupler(int const End)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto &coupler{Couplers[End]};
|
auto &thiscoupler{Couplers[End]};
|
||||||
|
|
||||||
if (coupler.type() == TCouplerType::Articulated)
|
if (thiscoupler.type() == TCouplerType::Articulated)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
} // HACK: don't break articulated couplings no matter what
|
} // HACK: don't break articulated couplings no matter what
|
||||||
@@ -1286,27 +1286,27 @@ void TMoverParameters::damage_coupler(int const End)
|
|||||||
if (SetFlag(DamageFlag, dtrain_coupling))
|
if (SetFlag(DamageFlag, dtrain_coupling))
|
||||||
EventFlag = true;
|
EventFlag = true;
|
||||||
|
|
||||||
if ((coupler.CouplingFlag & coupling::brakehose) == coupling::brakehose)
|
if ((thiscoupler.CouplingFlag & coupling::brakehose) == coupling::brakehose)
|
||||||
{
|
{
|
||||||
// hamowanie nagle - zerwanie przewodow hamulcowych
|
// hamowanie nagle - zerwanie przewodow hamulcowych
|
||||||
AlarmChainFlag = true;
|
AlarmChainFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
coupler.CouplingFlag = 0;
|
thiscoupler.CouplingFlag = 0;
|
||||||
|
|
||||||
if (coupler.Connected != nullptr)
|
if (thiscoupler.Connected != nullptr)
|
||||||
{
|
{
|
||||||
switch (End)
|
switch (End)
|
||||||
{
|
{
|
||||||
// break connection with other vehicle, if there's any
|
// break connection with other vehicle, if there's any
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
coupler.Connected->Couplers[end::rear].CouplingFlag = coupling::faux;
|
thiscoupler.Connected->Couplers[end::rear].CouplingFlag = coupling::faux;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
coupler.Connected->Couplers[end::front].CouplingFlag = coupling::faux;
|
thiscoupler.Connected->Couplers[end::front].CouplingFlag = coupling::faux;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -1831,7 +1831,7 @@ void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, coupling c
|
|||||||
for (auto side = 0; side < 2; ++side)
|
for (auto side = 0; side < 2; ++side)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto &coupler{Couplers[side]};
|
auto &thiscoupler{Couplers[side]};
|
||||||
// NOTE: in the loop we actually update the state of the coupler on the opposite end of the vehicle
|
// NOTE: in the loop we actually update the state of the coupler on the opposite end of the vehicle
|
||||||
auto &oppositecoupler{Couplers[side == end::front ? end::rear : end::front]};
|
auto &oppositecoupler{Couplers[side == end::front ? end::rear : end::front]};
|
||||||
|
|
||||||
@@ -1871,9 +1871,9 @@ void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, coupling c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const *coupling = Coupling == coupling::highvoltage ? &coupler.power_high :
|
auto const *coupling = Coupling == coupling::highvoltage ? &thiscoupler.power_high :
|
||||||
Coupling == coupling::power110v ? &coupler.power_110v :
|
Coupling == coupling::power110v ? &thiscoupler.power_110v :
|
||||||
Coupling == coupling::power24v ? &coupler.power_24v :
|
Coupling == coupling::power24v ? &thiscoupler.power_24v :
|
||||||
nullptr;
|
nullptr;
|
||||||
auto *oppositecoupling = Coupling == coupling::highvoltage ? &oppositecoupler.power_high :
|
auto *oppositecoupling = Coupling == coupling::highvoltage ? &oppositecoupler.power_high :
|
||||||
Coupling == coupling::power110v ? &oppositecoupler.power_110v :
|
Coupling == coupling::power110v ? &oppositecoupler.power_110v :
|
||||||
@@ -1885,9 +1885,9 @@ void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, coupling c
|
|||||||
oppositecoupling->is_live = false;
|
oppositecoupling->is_live = false;
|
||||||
oppositecoupling->is_local = localpowersource; // indicate power source
|
oppositecoupling->is_local = localpowersource; // indicate power source
|
||||||
// draw from external source
|
// draw from external source
|
||||||
if (coupler.Connected != nullptr)
|
if (thiscoupler.Connected != nullptr)
|
||||||
{
|
{
|
||||||
auto const &connectedcoupler{coupler.Connected->Couplers[coupler.ConnectedNr]};
|
auto const &connectedcoupler{thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr]};
|
||||||
auto const *connectedcoupling = Coupling == coupling::highvoltage ? &connectedcoupler.power_high :
|
auto const *connectedcoupling = Coupling == coupling::highvoltage ? &connectedcoupler.power_high :
|
||||||
Coupling == coupling::power110v ? &connectedcoupler.power_110v :
|
Coupling == coupling::power110v ? &connectedcoupler.power_110v :
|
||||||
Coupling == coupling::power24v ? &connectedcoupler.power_24v :
|
Coupling == coupling::power24v ? &connectedcoupler.power_24v :
|
||||||
@@ -1934,21 +1934,21 @@ void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, coupling c
|
|||||||
Coupling == coupling::power24v ? &PowerCircuits[0].second :
|
Coupling == coupling::power24v ? &PowerCircuits[0].second :
|
||||||
nullptr;
|
nullptr;
|
||||||
|
|
||||||
for (auto &coupler : Couplers)
|
for (auto &thiscoupler : Couplers)
|
||||||
{
|
{
|
||||||
auto *coupling = Coupling == coupling::highvoltage ? &coupler.power_high :
|
auto *coupling = Coupling == coupling::highvoltage ? &thiscoupler.power_high :
|
||||||
Coupling == coupling::power110v ? &coupler.power_110v :
|
Coupling == coupling::power110v ? &thiscoupler.power_110v :
|
||||||
Coupling == coupling::power24v ? &coupler.power_24v :
|
Coupling == coupling::power24v ? &thiscoupler.power_24v :
|
||||||
nullptr;
|
nullptr;
|
||||||
|
|
||||||
coupling->current = 0.0;
|
coupling->current = 0.0;
|
||||||
|
|
||||||
if (coupler.Connected == nullptr)
|
if (thiscoupler.Connected == nullptr)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const &connectedothercoupler{coupler.Connected->Couplers[coupler.ConnectedNr == end::front ? end::rear : end::front]};
|
auto const &connectedothercoupler{thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr == end::front ? end::rear : end::front]};
|
||||||
auto const *connectedothercoupling = Coupling == coupling::highvoltage ? &connectedothercoupler.power_high :
|
auto const *connectedothercoupling = Coupling == coupling::highvoltage ? &connectedothercoupler.power_high :
|
||||||
Coupling == coupling::power110v ? &connectedothercoupler.power_110v :
|
Coupling == coupling::power110v ? &connectedothercoupler.power_110v :
|
||||||
Coupling == coupling::power24v ? &connectedothercoupler.power_24v :
|
Coupling == coupling::power24v ? &connectedothercoupler.power_24v :
|
||||||
@@ -3983,10 +3983,10 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch)
|
|||||||
{
|
{
|
||||||
DynamicBrakeFlag = Switch;
|
DynamicBrakeFlag = Switch;
|
||||||
DBS = true;
|
DBS = true;
|
||||||
for (auto &coupler : Couplers)
|
for (auto &thiscoupler : Couplers)
|
||||||
// with Couplers[b] do
|
// with Couplers[b] do
|
||||||
if (TestFlag(coupler.CouplingFlag, coupling::control))
|
if (TestFlag(thiscoupler.CouplingFlag, coupling::control))
|
||||||
coupler.Connected->DynamicBrakeFlag = Switch;
|
thiscoupler.Connected->DynamicBrakeFlag = Switch;
|
||||||
// end;
|
// end;
|
||||||
// if (DynamicBrakeType=dbrake_passive) and (TrainType=dt_ET42) then
|
// if (DynamicBrakeType=dbrake_passive) and (TrainType=dt_ET42) then
|
||||||
// begin
|
// begin
|
||||||
@@ -5165,7 +5165,7 @@ double TMoverParameters::BrakeForce(TTrackParam const & /*Track*/)
|
|||||||
{
|
{
|
||||||
|
|
||||||
double K{0};
|
double K{0};
|
||||||
double Fb{0};
|
double brakeforce{0};
|
||||||
|
|
||||||
switch (LocalBrake)
|
switch (LocalBrake)
|
||||||
{
|
{
|
||||||
@@ -5222,11 +5222,11 @@ double TMoverParameters::BrakeForce(TTrackParam const & /*Track*/)
|
|||||||
// Fb:=UnitBrakeForce*NBpA {ham. reczny dziala na jedna os}
|
// Fb:=UnitBrakeForce*NBpA {ham. reczny dziala na jedna os}
|
||||||
// else //yB: to nie do konca ma sens, ponieważ ręczny w wagonie działa na jeden cylinder
|
// else //yB: to nie do konca ma sens, ponieważ ręczny w wagonie działa na jeden cylinder
|
||||||
// hamulcowy/wózek, dlatego potrzebne są oddzielnie liczone osie
|
// hamulcowy/wózek, dlatego potrzebne są oddzielnie liczone osie
|
||||||
Fb = UnitBrakeForce * NBrakeAxles * std::max(1, NBpA);
|
brakeforce = UnitBrakeForce * NBrakeAxles * std::max(1, NBpA);
|
||||||
|
|
||||||
// u:=((BrakePress*P2FTrans)-BrakeCylSpring*BrakeCylMult[BCMFlag]/BrakeCylNo-0.83*BrakeSlckAdj/(BrakeCylNo))*BrakeCylNo;
|
// u:=((BrakePress*P2FTrans)-BrakeCylSpring*BrakeCylMult[BCMFlag]/BrakeCylNo-0.83*BrakeSlckAdj/(BrakeCylNo))*BrakeCylNo;
|
||||||
// { end; }
|
// { end; }
|
||||||
return Fb;
|
return brakeforce;
|
||||||
}
|
}
|
||||||
|
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
@@ -5306,7 +5306,7 @@ double TMoverParameters::Adhesive(double staticfriction) const
|
|||||||
double TMoverParameters::CouplerForce(int const End, double dt)
|
double TMoverParameters::CouplerForce(int const End, double dt)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto &coupler{Couplers[End]};
|
auto &thiscoupler{Couplers[End]};
|
||||||
auto *othervehicle{Neighbours[End].vehicle->MoverParameters};
|
auto *othervehicle{Neighbours[End].vehicle->MoverParameters};
|
||||||
auto const otherend{Neighbours[End].vehicle_end};
|
auto const otherend{Neighbours[End].vehicle_end};
|
||||||
auto &othercoupler{othervehicle->Couplers[otherend]};
|
auto &othercoupler{othervehicle->Couplers[otherend]};
|
||||||
@@ -5321,81 +5321,81 @@ double TMoverParameters::CouplerForce(int const End, double dt)
|
|||||||
auto const absdV{std::abs(dV)};
|
auto const absdV{std::abs(dV)};
|
||||||
|
|
||||||
// potentially generate sounds on clash or stretch
|
// potentially generate sounds on clash or stretch
|
||||||
if (newdistance < 0.0 && coupler.Dist > newdistance && dV < -0.1 && false == coupler.has_adapter())
|
if (newdistance < 0.0 && thiscoupler.Dist > newdistance && dV < -0.1 && false == thiscoupler.has_adapter())
|
||||||
{ // HACK: with adapter present we presume buffers won't clash
|
{ // HACK: with adapter present we presume buffers won't clash
|
||||||
// 090503: dzwieki pracy zderzakow
|
// 090503: dzwieki pracy zderzakow
|
||||||
SetFlag(coupler.sounds, absdV > 5.0 ? sound::bufferclash | sound::loud : sound::bufferclash);
|
SetFlag(thiscoupler.sounds, absdV > 5.0 ? sound::bufferclash | sound::loud : sound::bufferclash);
|
||||||
}
|
}
|
||||||
else if (coupler.CouplingFlag != coupling::faux && newdistance > 0.001 && coupler.Dist <= 0.001 && absdV > 0.005 && Vel > 1.0)
|
else if (thiscoupler.CouplingFlag != coupling::faux && newdistance > 0.001 && thiscoupler.Dist <= 0.001 && absdV > 0.005 && Vel > 1.0)
|
||||||
{
|
{
|
||||||
// 090503: dzwieki pracy sprzegu
|
// 090503: dzwieki pracy sprzegu
|
||||||
SetFlag(coupler.sounds, absdV > 0.035 ? sound::couplerstretch | sound::loud : sound::couplerstretch);
|
SetFlag(thiscoupler.sounds, absdV > 0.035 ? sound::couplerstretch | sound::loud : sound::couplerstretch);
|
||||||
}
|
}
|
||||||
|
|
||||||
coupler.CheckCollision = false;
|
thiscoupler.CheckCollision = false;
|
||||||
coupler.Dist = 0.0;
|
thiscoupler.Dist = 0.0;
|
||||||
|
|
||||||
double CF{0.0};
|
double CF{0.0};
|
||||||
|
|
||||||
if (coupler.CouplingFlag == coupling::faux && initialdistance > 0.05)
|
if (thiscoupler.CouplingFlag == coupling::faux && initialdistance > 0.05)
|
||||||
{ // arbitrary distance
|
{ // arbitrary distance
|
||||||
// potentially reset auto coupling lock
|
// potentially reset auto coupling lock
|
||||||
coupler.AutomaticCouplingAllowed = true;
|
thiscoupler.AutomaticCouplingAllowed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coupler.CouplingFlag != coupling::faux || initialdistance < 0)
|
if (thiscoupler.CouplingFlag != coupling::faux || initialdistance < 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
coupler.Dist = std::clamp(newdistance, coupler.has_adapter() ? 0 : -coupler.DmaxB, coupler.DmaxC);
|
thiscoupler.Dist = std::clamp(newdistance, thiscoupler.has_adapter() ? 0 : -thiscoupler.DmaxB, thiscoupler.DmaxC);
|
||||||
|
|
||||||
double BetaAvg = 0;
|
double BetaAvg = 0;
|
||||||
double Fmax = 0;
|
double Fmax = 0;
|
||||||
|
|
||||||
if (coupler.CouplingFlag == coupling::faux)
|
if (thiscoupler.CouplingFlag == coupling::faux)
|
||||||
{
|
{
|
||||||
|
|
||||||
BetaAvg = coupler.beta;
|
BetaAvg = thiscoupler.beta;
|
||||||
Fmax = (coupler.FmaxC + coupler.FmaxB) * CouplerTune;
|
Fmax = (thiscoupler.FmaxC + thiscoupler.FmaxB) * CouplerTune;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// usrednij bo wspolny sprzeg
|
// usrednij bo wspolny sprzeg
|
||||||
BetaAvg = 0.5 * (coupler.beta + othercoupler.beta);
|
BetaAvg = 0.5 * (thiscoupler.beta + othercoupler.beta);
|
||||||
Fmax = 0.5 * (coupler.FmaxC + coupler.FmaxB + othercoupler.FmaxC + othercoupler.FmaxB) * CouplerTune;
|
Fmax = 0.5 * (thiscoupler.FmaxC + thiscoupler.FmaxB + othercoupler.FmaxC + othercoupler.FmaxB) * CouplerTune;
|
||||||
}
|
}
|
||||||
auto const distDelta{std::abs(newdistance) - std::abs(coupler.Dist)}; // McZapkie-191103: poprawka na histereze
|
auto const distDelta{std::abs(newdistance) - std::abs(thiscoupler.Dist)}; // McZapkie-191103: poprawka na histereze
|
||||||
|
|
||||||
if (newdistance > 0)
|
if (newdistance > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (distDelta > 0)
|
if (distDelta > 0)
|
||||||
{
|
{
|
||||||
CF = -(coupler.SpringKC + othercoupler.SpringKC) * coupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
|
CF = -(thiscoupler.SpringKC + othercoupler.SpringKC) * thiscoupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CF = -(coupler.SpringKC + othercoupler.SpringKC) * coupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
|
CF = -(thiscoupler.SpringKC + othercoupler.SpringKC) * thiscoupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
|
||||||
}
|
}
|
||||||
// liczenie sily ze sprezystosci sprzegu
|
// liczenie sily ze sprezystosci sprzegu
|
||||||
if (newdistance > coupler.DmaxC + othercoupler.DmaxC)
|
if (newdistance > thiscoupler.DmaxC + othercoupler.DmaxC)
|
||||||
{
|
{
|
||||||
// zderzenie
|
// zderzenie
|
||||||
coupler.CheckCollision = true;
|
thiscoupler.CheckCollision = true;
|
||||||
}
|
}
|
||||||
if (std::abs(CF) > coupler.FmaxC)
|
if (std::abs(CF) > thiscoupler.FmaxC)
|
||||||
{
|
{
|
||||||
// coupler is stretched with excessive force, may break
|
// coupler is stretched with excessive force, may break
|
||||||
coupler.stretch_duration += static_cast<float>(dt);
|
thiscoupler.stretch_duration += static_cast<float>(dt);
|
||||||
// give coupler 1 sec of leeway to account for simulation glitches, before checking whether it breaks
|
// give coupler 1 sec of leeway to account for simulation glitches, before checking whether it breaks
|
||||||
// (arbitrary) chance to break grows from 10-100% over 10 sec period
|
// (arbitrary) chance to break grows from 10-100% over 10 sec period
|
||||||
if (Global.crash_damage && coupler.stretch_duration > 1.f && Random() < coupler.stretch_duration * 0.1f * dt)
|
if (Global.crash_damage && thiscoupler.stretch_duration > 1.f && Random() < thiscoupler.stretch_duration * 0.1f * dt)
|
||||||
{
|
{
|
||||||
damage_coupler(End);
|
damage_coupler(End);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
coupler.stretch_duration = 0.f;
|
thiscoupler.stretch_duration = 0.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newdistance < 0)
|
if (newdistance < 0)
|
||||||
@@ -5403,29 +5403,29 @@ double TMoverParameters::CouplerForce(int const End, double dt)
|
|||||||
|
|
||||||
if (distDelta > 0)
|
if (distDelta > 0)
|
||||||
{
|
{
|
||||||
CF = -(coupler.SpringKB + othercoupler.SpringKB) * coupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
|
CF = -(thiscoupler.SpringKB + othercoupler.SpringKB) * thiscoupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CF = -(coupler.SpringKB + othercoupler.SpringKB) * coupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
|
CF = -(thiscoupler.SpringKB + othercoupler.SpringKB) * thiscoupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
|
||||||
}
|
}
|
||||||
// liczenie sily ze sprezystosci zderzaka
|
// liczenie sily ze sprezystosci zderzaka
|
||||||
auto const collisiondistance{(coupler.has_adapter() || othercoupler.has_adapter() ?
|
auto const collisiondistance{(thiscoupler.has_adapter() || othercoupler.has_adapter() ?
|
||||||
std::min(coupler.DmaxB, othercoupler.DmaxB) : // HACK: only take into account buffering ability of automatic coupler
|
std::min(thiscoupler.DmaxB, othercoupler.DmaxB) : // HACK: only take into account buffering ability of automatic coupler
|
||||||
coupler.DmaxB + othercoupler.DmaxB)};
|
thiscoupler.DmaxB + othercoupler.DmaxB)};
|
||||||
if (-newdistance > collisiondistance)
|
if (-newdistance > collisiondistance)
|
||||||
{
|
{
|
||||||
// zderzenie
|
// zderzenie
|
||||||
coupler.CheckCollision = true;
|
thiscoupler.CheckCollision = true;
|
||||||
}
|
}
|
||||||
if (-newdistance >= std::min(collisiondistance, dEpsilon) && coupler.type() == TCouplerType::Automatic && coupler.type() == othercoupler.type() && coupler.CouplingFlag == coupling::faux &&
|
if (-newdistance >= std::min(collisiondistance, dEpsilon) && thiscoupler.type() == TCouplerType::Automatic && thiscoupler.type() == othercoupler.type() && thiscoupler.CouplingFlag == coupling::faux &&
|
||||||
coupler.AutomaticCouplingAllowed &&
|
thiscoupler.AutomaticCouplingAllowed &&
|
||||||
othercoupler.AutomaticCouplingAllowed)
|
othercoupler.AutomaticCouplingAllowed)
|
||||||
{
|
{
|
||||||
// sprzeganie wagonow z samoczynnymi sprzegami
|
// sprzeganie wagonow z samoczynnymi sprzegami
|
||||||
auto couplingtype{coupler.AutomaticCouplingFlag & othercoupler.AutomaticCouplingFlag};
|
auto couplingtype{thiscoupler.AutomaticCouplingFlag & othercoupler.AutomaticCouplingFlag};
|
||||||
// potentially exclude incompatible control coupling
|
// potentially exclude incompatible control coupling
|
||||||
if (coupler.control_type != othercoupler.control_type)
|
if (thiscoupler.control_type != othercoupler.control_type)
|
||||||
{
|
{
|
||||||
couplingtype &= ~coupling::control;
|
couplingtype &= ~coupling::control;
|
||||||
}
|
}
|
||||||
@@ -5434,7 +5434,7 @@ double TMoverParameters::CouplerForce(int const End, double dt)
|
|||||||
{
|
{
|
||||||
// HACK: we're reusing sound enum to mark whether vehicle was connected to another
|
// HACK: we're reusing sound enum to mark whether vehicle was connected to another
|
||||||
SetFlag(AIFlag, sound::attachcoupler);
|
SetFlag(AIFlag, sound::attachcoupler);
|
||||||
coupler.AutomaticCouplingAllowed = false;
|
thiscoupler.AutomaticCouplingAllowed = false;
|
||||||
othercoupler.AutomaticCouplingAllowed = false;
|
othercoupler.AutomaticCouplingAllowed = false;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -5445,7 +5445,7 @@ double TMoverParameters::CouplerForce(int const End, double dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coupler.CouplingFlag != coupling::faux)
|
if (thiscoupler.CouplingFlag != coupling::faux)
|
||||||
{
|
{
|
||||||
// uzgadnianie prawa Newtona
|
// uzgadnianie prawa Newtona
|
||||||
othervehicle->Couplers[1 - End].CForce = -CF;
|
othervehicle->Couplers[1 - End].CForce = -CF;
|
||||||
@@ -6569,9 +6569,9 @@ bool TMoverParameters::FuseFlagCheck(void) const
|
|||||||
if (Power > 0.01)
|
if (Power > 0.01)
|
||||||
FFC = FuseFlag;
|
FFC = FuseFlag;
|
||||||
else // pobor pradu jezeli niema mocy
|
else // pobor pradu jezeli niema mocy
|
||||||
for (auto &coupler : Couplers)
|
for (auto &thiscoupler : Couplers)
|
||||||
if (TestFlag(coupler.CouplingFlag, coupling::control) && coupler.Connected->Power > 0.01)
|
if (TestFlag(thiscoupler.CouplingFlag, coupling::control) && thiscoupler.Connected->Power > 0.01)
|
||||||
FFC = coupler.Connected->FuseFlagCheck();
|
FFC = thiscoupler.Connected->FuseFlagCheck();
|
||||||
|
|
||||||
return FFC;
|
return FFC;
|
||||||
}
|
}
|
||||||
@@ -6799,9 +6799,9 @@ bool TMoverParameters::ResistorsFlagCheck(void) const
|
|||||||
RFC = ResistorsFlag;
|
RFC = ResistorsFlag;
|
||||||
else // pobor pradu jezeli niema mocy
|
else // pobor pradu jezeli niema mocy
|
||||||
{
|
{
|
||||||
for (auto &coupler : Couplers)
|
for (auto &thiscoupler : Couplers)
|
||||||
if (TestFlag(coupler.CouplingFlag, coupling::control) && coupler.Connected->Power > 0.01)
|
if (TestFlag(thiscoupler.CouplingFlag, coupling::control) && thiscoupler.Connected->Power > 0.01)
|
||||||
RFC = coupler.Connected->ResistorsFlagCheck();
|
RFC = thiscoupler.Connected->ResistorsFlagCheck();
|
||||||
}
|
}
|
||||||
return RFC;
|
return RFC;
|
||||||
}
|
}
|
||||||
@@ -7974,7 +7974,7 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt)
|
|||||||
// Q: 20160715
|
// Q: 20160715
|
||||||
// Oblicza moment siły wytwarzany przez silnik spalinowy
|
// Oblicza moment siły wytwarzany przez silnik spalinowy
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
|
double TMoverParameters::dizel_Momentum(double Fill, double n, double dt)
|
||||||
{ // liczy moment sily wytwarzany przez silnik spalinowy}
|
{ // liczy moment sily wytwarzany przez silnik spalinowy}
|
||||||
double Moment = 0;
|
double Moment = 0;
|
||||||
double enMoment = 0;
|
double enMoment = 0;
|
||||||
@@ -7997,14 +7997,14 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
|
|||||||
{
|
{
|
||||||
if (dizel_Momentum_Table.size() > 1)
|
if (dizel_Momentum_Table.size() > 1)
|
||||||
{
|
{
|
||||||
Moment = TableInterpolation(dizel_Momentum_Table, enrot) * dizel_fill - dizel_Mstand;
|
Moment = TableInterpolation(dizel_Momentum_Table, enrot) * Fill - dizel_Mstand;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Moment = (dizel_Mmax - (dizel_Mmax - dizel_Mnmax) * square((enrot - dizel_nMmax) / (dizel_nMmax - dizel_nmax))) * dizel_fill - dizel_Mstand;
|
Moment = (dizel_Mmax - (dizel_Mmax - dizel_Mnmax) * square((enrot - dizel_nMmax) / (dizel_nMmax - dizel_nmax))) * Fill - dizel_Mstand;
|
||||||
}
|
}
|
||||||
Mm = Moment;
|
Mm = Moment;
|
||||||
dizel_FuelConsumptionActual = dizel_FuelConsumption * enrot * dizel_fill;
|
dizel_FuelConsumptionActual = dizel_FuelConsumption * enrot * Fill;
|
||||||
dizel_FuelConsumptedTotal += dizel_FuelConsumptionActual * dt / 3600.0;
|
dizel_FuelConsumptedTotal += dizel_FuelConsumptionActual * dt / 3600.0;
|
||||||
if (hydro_R && hydro_R_Placement == 2)
|
if (hydro_R && hydro_R_Placement == 2)
|
||||||
Moment -= dizel_MomentumRetarder(enrot, dt);
|
Moment -= dizel_MomentumRetarder(enrot, dt);
|
||||||
@@ -8375,10 +8375,10 @@ void TMoverParameters::dizel_Heat(double const dt)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TMoverParameters::AssignLoad(std::string const &Name, float const Amount)
|
bool TMoverParameters::AssignLoad(std::string const &Loadname, float const Amount)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Name == "pantstate")
|
if (Loadname == "pantstate")
|
||||||
{
|
{
|
||||||
if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector)
|
if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector)
|
||||||
{
|
{
|
||||||
@@ -8418,27 +8418,27 @@ bool TMoverParameters::AssignLoad(std::string const &Name, float const Amount)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Name.empty())
|
if (Loadname.empty())
|
||||||
{
|
{
|
||||||
// empty the vehicle if requested
|
// empty the vehicle if requested
|
||||||
LoadTypeChange = LoadType.name != Name;
|
LoadTypeChange = LoadType.name != Loadname;
|
||||||
LoadType = load_attributes();
|
LoadType = load_attributes();
|
||||||
LoadAmount = 0.f;
|
LoadAmount = 0.f;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// can't mix load types, at least for the time being
|
// can't mix load types, at least for the time being
|
||||||
if (LoadAmount > 0 && LoadType.name != Name)
|
if (LoadAmount > 0 && LoadType.name != Loadname)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const loadattributes = std::ranges::find_if(LoadAttributes, [&](auto const &attributes) { return attributes.name == Name; });
|
auto const loadattributes = std::ranges::find_if(LoadAttributes, [&](auto const &attributes) { return attributes.name == Loadname; });
|
||||||
if (loadattributes == std::end(LoadAttributes))
|
if (loadattributes == std::end(LoadAttributes))
|
||||||
{
|
{
|
||||||
// didn't find matching load configuration, this type is unsupported
|
// didn't find matching load configuration, this type is unsupported
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LoadTypeChange = LoadType.name != Name;
|
LoadTypeChange = LoadType.name != Loadname;
|
||||||
LoadType = *loadattributes;
|
LoadType = *loadattributes;
|
||||||
LoadAmount = std::clamp(Amount, 0.f, MaxLoad);
|
LoadAmount = std::clamp(Amount, 0.f, MaxLoad);
|
||||||
ComputeMass();
|
ComputeMass();
|
||||||
@@ -8936,14 +8936,14 @@ double TMoverParameters::GetTrainsetVoltage(int const Coupling) const
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto const &coupler{Couplers[end]};
|
auto const &thiscoupler{Couplers[end]};
|
||||||
if (auto const fullcoupling{coupler.CouplingFlag | (TestFlag(coupler.CouplingFlag, coupler.PowerCoupling) ? coupler.PowerFlag : 0)}; (fullcoupling & Coupling) == 0)
|
if (auto const fullcoupling{thiscoupler.CouplingFlag | (TestFlag(thiscoupler.CouplingFlag, thiscoupler.PowerCoupling) ? thiscoupler.PowerFlag : 0)}; (fullcoupling & Coupling) == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto *connectedpowercoupling = (Coupling & (coupling::highvoltage | coupling::heating)) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_high :
|
auto *connectedpowercoupling = (Coupling & (coupling::highvoltage | coupling::heating)) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_high :
|
||||||
(Coupling & coupling::power110v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_110v :
|
(Coupling & coupling::power110v) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_110v :
|
||||||
(Coupling & coupling::power24v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_24v :
|
(Coupling & coupling::power24v) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_24v :
|
||||||
nullptr;
|
nullptr;
|
||||||
if (connectedpowercoupling != nullptr && connectedpowercoupling->is_live)
|
if (connectedpowercoupling != nullptr && connectedpowercoupling->is_live)
|
||||||
{
|
{
|
||||||
@@ -10613,59 +10613,59 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line)
|
|||||||
void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Index)
|
void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Index)
|
||||||
{
|
{
|
||||||
|
|
||||||
TCoupling *coupler;
|
TCoupling *thiscoupler;
|
||||||
if (Index == 2)
|
if (Index == 2)
|
||||||
{
|
{
|
||||||
coupler = &Couplers[1];
|
thiscoupler = &Couplers[1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
coupler = &Couplers[0];
|
thiscoupler = &Couplers[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, TCouplerType> couplertypes{
|
std::map<std::string, TCouplerType> couplertypes{
|
||||||
{"Automatic", TCouplerType::Automatic}, {"Screw", TCouplerType::Screw}, {"Chain", TCouplerType::Chain}, {"Bare", TCouplerType::Bare}, {"Articulated", TCouplerType::Articulated},
|
{"Automatic", TCouplerType::Automatic}, {"Screw", TCouplerType::Screw}, {"Chain", TCouplerType::Chain}, {"Bare", TCouplerType::Bare}, {"Articulated", TCouplerType::Articulated},
|
||||||
};
|
};
|
||||||
auto lookup = couplertypes.find(extract_value("CType", line));
|
auto lookup = couplertypes.find(extract_value("CType", line));
|
||||||
coupler->CouplerType = lookup != couplertypes.end() ? lookup->second : TCouplerType::NoCoupler;
|
thiscoupler->CouplerType = lookup != couplertypes.end() ? lookup->second : TCouplerType::NoCoupler;
|
||||||
|
|
||||||
extract_value(coupler->SpringKC, "kC", line, "");
|
extract_value(thiscoupler->SpringKC, "kC", line, "");
|
||||||
extract_value(coupler->DmaxC, "DmaxC", line, "");
|
extract_value(thiscoupler->DmaxC, "DmaxC", line, "");
|
||||||
extract_value(coupler->FmaxC, "FmaxC", line, "");
|
extract_value(thiscoupler->FmaxC, "FmaxC", line, "");
|
||||||
extract_value(coupler->SpringKB, "kB", line, "");
|
extract_value(thiscoupler->SpringKB, "kB", line, "");
|
||||||
extract_value(coupler->DmaxB, "DmaxB", line, "");
|
extract_value(thiscoupler->DmaxB, "DmaxB", line, "");
|
||||||
extract_value(coupler->FmaxB, "FmaxB", line, "");
|
extract_value(thiscoupler->FmaxB, "FmaxB", line, "");
|
||||||
extract_value(coupler->beta, "beta", line, "");
|
extract_value(thiscoupler->beta, "beta", line, "");
|
||||||
extract_value(coupler->AutomaticCouplingFlag, "AutomaticFlag", line, "");
|
extract_value(thiscoupler->AutomaticCouplingFlag, "AutomaticFlag", line, "");
|
||||||
extract_value(coupler->AllowedFlag, "AllowedFlag", line, "");
|
extract_value(thiscoupler->AllowedFlag, "AllowedFlag", line, "");
|
||||||
if (coupler->AllowedFlag < 0)
|
if (thiscoupler->AllowedFlag < 0)
|
||||||
{
|
{
|
||||||
coupler->AllowedFlag = -coupler->AllowedFlag | coupling::permanent;
|
thiscoupler->AllowedFlag = -thiscoupler->AllowedFlag | coupling::permanent;
|
||||||
}
|
}
|
||||||
extract_value(coupler->PowerCoupling, "PowerCoupling", line, "");
|
extract_value(thiscoupler->PowerCoupling, "PowerCoupling", line, "");
|
||||||
extract_value(coupler->PowerFlag, "PowerFlag", line, "");
|
extract_value(thiscoupler->PowerFlag, "PowerFlag", line, "");
|
||||||
extract_value(coupler->control_type, "ControlType", line, "");
|
extract_value(thiscoupler->control_type, "ControlType", line, "");
|
||||||
|
|
||||||
if (coupler->CouplerType != TCouplerType::NoCoupler && coupler->CouplerType != TCouplerType::Bare && coupler->CouplerType != TCouplerType::Articulated)
|
if (thiscoupler->CouplerType != TCouplerType::NoCoupler && thiscoupler->CouplerType != TCouplerType::Bare && thiscoupler->CouplerType != TCouplerType::Articulated)
|
||||||
{
|
{
|
||||||
|
|
||||||
coupler->SpringKC *= 1000;
|
thiscoupler->SpringKC *= 1000;
|
||||||
coupler->FmaxC *= 1000;
|
thiscoupler->FmaxC *= 1000;
|
||||||
coupler->SpringKB *= 1000;
|
thiscoupler->SpringKB *= 1000;
|
||||||
coupler->FmaxB *= 1000;
|
thiscoupler->FmaxB *= 1000;
|
||||||
}
|
}
|
||||||
else if (coupler->CouplerType == TCouplerType::Bare)
|
else if (thiscoupler->CouplerType == TCouplerType::Bare)
|
||||||
{
|
{
|
||||||
|
|
||||||
coupler->SpringKC = 50.0 * Mass + Ftmax / 0.05;
|
thiscoupler->SpringKC = 50.0 * Mass + Ftmax / 0.05;
|
||||||
coupler->DmaxC = 0.05;
|
thiscoupler->DmaxC = 0.05;
|
||||||
coupler->FmaxC = 100.0 * Mass + 2 * Ftmax;
|
thiscoupler->FmaxC = 100.0 * Mass + 2 * Ftmax;
|
||||||
coupler->SpringKB = 60.0 * Mass + Ftmax / 0.05;
|
thiscoupler->SpringKB = 60.0 * Mass + Ftmax / 0.05;
|
||||||
coupler->DmaxB = 0.05;
|
thiscoupler->DmaxB = 0.05;
|
||||||
coupler->FmaxB = 50.0 * Mass + 2.0 * Ftmax;
|
thiscoupler->FmaxB = 50.0 * Mass + 2.0 * Ftmax;
|
||||||
coupler->beta = 0.3;
|
thiscoupler->beta = 0.3;
|
||||||
}
|
}
|
||||||
else if (coupler->CouplerType == TCouplerType::Articulated)
|
else if (thiscoupler->CouplerType == TCouplerType::Articulated)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
coupler->SpringKC = 60.0 * Mass + 1000;
|
coupler->SpringKC = 60.0 * Mass + 1000;
|
||||||
@@ -10676,13 +10676,13 @@ void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Inde
|
|||||||
coupler->FmaxB = 4000000.0 + 2.0 * Ftmax;
|
coupler->FmaxB = 4000000.0 + 2.0 * Ftmax;
|
||||||
coupler->beta = 0.55;
|
coupler->beta = 0.55;
|
||||||
*/
|
*/
|
||||||
coupler->SpringKC = 4500 * 1000;
|
thiscoupler->SpringKC = 4500 * 1000;
|
||||||
coupler->DmaxC = 0.05;
|
thiscoupler->DmaxC = 0.05;
|
||||||
coupler->FmaxC = 850 * 1000;
|
thiscoupler->FmaxC = 850 * 1000;
|
||||||
coupler->SpringKB = 9200 * 1000;
|
thiscoupler->SpringKB = 9200 * 1000;
|
||||||
coupler->DmaxB = 0.05;
|
thiscoupler->DmaxB = 0.05;
|
||||||
coupler->FmaxB = 320 * 1000;
|
thiscoupler->FmaxB = 320 * 1000;
|
||||||
coupler->beta = 0.55;
|
thiscoupler->beta = 0.55;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Index == 0)
|
if (Index == 0)
|
||||||
@@ -11656,12 +11656,12 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Power) const
|
TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Powertype) const
|
||||||
{
|
{
|
||||||
|
|
||||||
std::map<std::string, TPowerType> powertypes{
|
std::map<std::string, TPowerType> powertypes{
|
||||||
{"BioPower", TPowerType::BioPower}, {"MechPower", TPowerType::MechPower}, {"ElectricPower", TPowerType::ElectricPower}, {"SteamPower", TPowerType::SteamPower}};
|
{"BioPower", TPowerType::BioPower}, {"MechPower", TPowerType::MechPower}, {"ElectricPower", TPowerType::ElectricPower}, {"SteamPower", TPowerType::SteamPower}};
|
||||||
auto lookup = powertypes.find(Power);
|
auto lookup = powertypes.find(Powertype);
|
||||||
return lookup != powertypes.end() ? lookup->second : TPowerType::NoPower;
|
return lookup != powertypes.end() ? lookup->second : TPowerType::NoPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12489,13 +12489,13 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
|
|||||||
else if (Command == "DoorPermit")
|
else if (Command == "DoorPermit")
|
||||||
{
|
{
|
||||||
|
|
||||||
auto const left{CValue2 > 0 ? 1 : 2};
|
auto const leftside{CValue2 > 0 ? 1 : 2};
|
||||||
|
|
||||||
if (auto const right{3 - left}; std::abs(static_cast<int>(CValue1)) & right)
|
if (auto const rightside{3 - leftside}; std::abs(static_cast<int>(CValue1)) & rightside)
|
||||||
{
|
{
|
||||||
PermitDoors_(side::right, CValue1 > 0);
|
PermitDoors_(side::right, CValue1 > 0);
|
||||||
}
|
}
|
||||||
if (std::abs(static_cast<int>(CValue1)) & left)
|
if (std::abs(static_cast<int>(CValue1)) & leftside)
|
||||||
{
|
{
|
||||||
PermitDoors_(side::left, CValue1 > 0);
|
PermitDoors_(side::left, CValue1 > 0);
|
||||||
}
|
}
|
||||||
@@ -12508,15 +12508,15 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
|
|||||||
if ((Doors.open_control == control_t::conductor || Doors.open_control == control_t::driver || Doors.open_control == control_t::mixed) && (Power24vIsAvailable || Power110vIsAvailable))
|
if ((Doors.open_control == control_t::conductor || Doors.open_control == control_t::driver || Doors.open_control == control_t::mixed) && (Power24vIsAvailable || Power110vIsAvailable))
|
||||||
{
|
{
|
||||||
|
|
||||||
auto const left{CValue2 > 0 ? 1 : 2};
|
auto const leftside{CValue2 > 0 ? 1 : 2};
|
||||||
auto const right{3 - left};
|
auto const rightside{3 - leftside};
|
||||||
|
|
||||||
if (static_cast<int>(CValue1) & right)
|
if (static_cast<int>(CValue1) & rightside)
|
||||||
{
|
{
|
||||||
Doors.instances[side::right].remote_open = true;
|
Doors.instances[side::right].remote_open = true;
|
||||||
Doors.instances[side::right].remote_close = false;
|
Doors.instances[side::right].remote_close = false;
|
||||||
}
|
}
|
||||||
if (static_cast<int>(CValue1) & left)
|
if (static_cast<int>(CValue1) & leftside)
|
||||||
{
|
{
|
||||||
Doors.instances[side::left].remote_open = true;
|
Doors.instances[side::left].remote_open = true;
|
||||||
Doors.instances[side::left].remote_close = false;
|
Doors.instances[side::left].remote_close = false;
|
||||||
@@ -12530,15 +12530,15 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
|
|||||||
if ((Doors.close_control == control_t::conductor || Doors.close_control == control_t::driver || Doors.close_control == control_t::mixed) && (Power24vIsAvailable || Power110vIsAvailable))
|
if ((Doors.close_control == control_t::conductor || Doors.close_control == control_t::driver || Doors.close_control == control_t::mixed) && (Power24vIsAvailable || Power110vIsAvailable))
|
||||||
{
|
{
|
||||||
|
|
||||||
auto const left{CValue2 > 0 ? 1 : 2};
|
auto const leftside{CValue2 > 0 ? 1 : 2};
|
||||||
auto const right{3 - left};
|
auto const rightside{3 - leftside};
|
||||||
|
|
||||||
if (static_cast<int>(CValue1) & right)
|
if (static_cast<int>(CValue1) & rightside)
|
||||||
{
|
{
|
||||||
Doors.instances[side::right].remote_close = true;
|
Doors.instances[side::right].remote_close = true;
|
||||||
Doors.instances[side::right].remote_open = false;
|
Doors.instances[side::right].remote_open = false;
|
||||||
}
|
}
|
||||||
if (static_cast<int>(CValue1) & left)
|
if (static_cast<int>(CValue1) & leftside)
|
||||||
{
|
{
|
||||||
Doors.instances[side::left].remote_close = true;
|
Doors.instances[side::left].remote_close = true;
|
||||||
Doors.instances[side::left].remote_open = false;
|
Doors.instances[side::left].remote_open = false;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ drivingaid_panel::update() {
|
|||||||
|| controlled->Mechanik == nullptr ) { return; }
|
|| controlled->Mechanik == nullptr ) { return; }
|
||||||
|
|
||||||
auto const *mover = controlled->MoverParameters;
|
auto const *mover = controlled->MoverParameters;
|
||||||
auto const *driver = controlled->Mechanik;
|
auto const *vehicledriver = controlled->Mechanik;
|
||||||
auto const *owner = controlled->ctOwner != nullptr ? controlled->ctOwner : controlled->Mechanik;
|
auto const *owner = controlled->ctOwner != nullptr ? controlled->ctOwner : controlled->Mechanik;
|
||||||
|
|
||||||
{ // throttle, velocity, speed limits and grade
|
{ // throttle, velocity, speed limits and grade
|
||||||
@@ -140,8 +140,8 @@ drivingaid_panel::update() {
|
|||||||
std::snprintf(
|
std::snprintf(
|
||||||
m_buffer.data(), m_buffer.size(),
|
m_buffer.data(), m_buffer.size(),
|
||||||
STR_C("Throttle: %3d+%d %c%s"),
|
STR_C("Throttle: %3d+%d %c%s"),
|
||||||
mover->EIMCtrlType > 0 ? std::max(0, static_cast<int>(100.4 * mover->eimic_real)) : driver->Controlling()->MainCtrlPos,
|
mover->EIMCtrlType > 0 ? std::max(0, static_cast<int>(100.4 * mover->eimic_real)) : vehicledriver->Controlling()->MainCtrlPos,
|
||||||
mover->EIMCtrlType > 0 ? driver->Controlling()->MainCtrlPos : driver->Controlling()->ScndCtrlPos,
|
mover->EIMCtrlType > 0 ? vehicledriver->Controlling()->MainCtrlPos : vehicledriver->Controlling()->ScndCtrlPos,
|
||||||
mover->SpeedCtrlUnit.IsActive ? 'T' :
|
mover->SpeedCtrlUnit.IsActive ? 'T' :
|
||||||
mover->DirActive > 0 ? 'D' :
|
mover->DirActive > 0 ? 'D' :
|
||||||
mover->DirActive < 0 ? 'R' :
|
mover->DirActive < 0 ? 'R' :
|
||||||
@@ -569,8 +569,8 @@ debug_panel::render() {
|
|||||||
// sections
|
// sections
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (true == render_section( "Vehicle", m_vehiclelines ) && DebugModeFlag && m_input.mover && m_input.mover->DamageFlag != 0 && true == ImGui::Button( "Stop and repair consist" )) {
|
if (true == render_section( "Vehicle", m_vehiclelines ) && DebugModeFlag && m_input.mover && m_input.mover->DamageFlag != 0 && true == ImGui::Button( "Stop and repair consist" )) {
|
||||||
command_relay relay;
|
command_relay commandrelay;
|
||||||
relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
|
commandrelay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
|
||||||
}
|
}
|
||||||
render_section( "Vehicle Engine", m_enginelines );
|
render_section( "Vehicle Engine", m_enginelines );
|
||||||
render_section( "Vehicle AI", m_ailines );
|
render_section( "Vehicle AI", m_ailines );
|
||||||
@@ -601,8 +601,8 @@ debug_panel::render() {
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
bool flag = DebugModeFlag;
|
bool flag = DebugModeFlag;
|
||||||
if (ImGui::Checkbox("Debug Mode", &flag)) {
|
if (ImGui::Checkbox("Debug Mode", &flag)) {
|
||||||
command_relay relay;
|
command_relay commandrelay;
|
||||||
relay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
|
commandrelay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,8 +623,8 @@ debug_panel::render_section_scenario() {
|
|||||||
auto fogrange = std::log( Global.fFogEnd );
|
auto fogrange = std::log( Global.fFogEnd );
|
||||||
if( ImGui::SliderFloat(
|
if( ImGui::SliderFloat(
|
||||||
( to_string( std::exp( fogrange ), 0, 5 ) + " m###fogend" ).c_str(), &fogrange, std::log( 10.0f ), std::log( 50000.0f ), "Fog distance" ) ) {
|
( to_string( std::exp( fogrange ), 0, 5 ) + " m###fogend" ).c_str(), &fogrange, std::log( 10.0f ), std::log( 50000.0f ), "Fog distance" ) ) {
|
||||||
command_relay relay;
|
command_relay commandrelay;
|
||||||
relay.post(
|
commandrelay.post(
|
||||||
user_command::setweather,
|
user_command::setweather,
|
||||||
std::clamp( std::exp( fogrange ), 10.0f, 50000.0f ),
|
std::clamp( std::exp( fogrange ), 10.0f, 50000.0f ),
|
||||||
Global.Overcast,
|
Global.Overcast,
|
||||||
@@ -637,8 +637,8 @@ debug_panel::render_section_scenario() {
|
|||||||
(to_string(Airtemperature, 1) + " deg C###Airtemperature").c_str(),
|
(to_string(Airtemperature, 1) + " deg C###Airtemperature").c_str(),
|
||||||
&Airtemperature, -35.0f, 40.0f, "Air Temperature"))
|
&Airtemperature, -35.0f, 40.0f, "Air Temperature"))
|
||||||
{
|
{
|
||||||
command_relay relay;
|
command_relay commandrelay;
|
||||||
relay.post(
|
commandrelay.post(
|
||||||
user_command::settemperature,
|
user_command::settemperature,
|
||||||
std::clamp(Airtemperature, -35.0f, 40.0f),
|
std::clamp(Airtemperature, -35.0f, 40.0f),
|
||||||
Global.Overcast,
|
Global.Overcast,
|
||||||
@@ -649,8 +649,8 @@ debug_panel::render_section_scenario() {
|
|||||||
{
|
{
|
||||||
if( ImGui::SliderFloat(
|
if( ImGui::SliderFloat(
|
||||||
( to_string( Global.Overcast, 2, 5 ) + " (" + Global.Weather + ")###overcast" ).c_str(), &Global.Overcast, 0.0f, 2.0f, "Cloud cover" ) ) {
|
( to_string( Global.Overcast, 2, 5 ) + " (" + Global.Weather + ")###overcast" ).c_str(), &Global.Overcast, 0.0f, 2.0f, "Cloud cover" ) ) {
|
||||||
command_relay relay;
|
command_relay commandrelay;
|
||||||
relay.post(
|
commandrelay.post(
|
||||||
user_command::setweather,
|
user_command::setweather,
|
||||||
Global.fFogEnd,
|
Global.fFogEnd,
|
||||||
std::clamp( Global.Overcast, 0.0f, 2.0f ),
|
std::clamp( Global.Overcast, 0.0f, 2.0f ),
|
||||||
@@ -661,8 +661,8 @@ debug_panel::render_section_scenario() {
|
|||||||
{
|
{
|
||||||
if( ImGui::SliderFloat(
|
if( ImGui::SliderFloat(
|
||||||
( to_string( Global.fMoveLight, 0, 5 ) + " (" + Global.Season + ")###movelight" ).c_str(), &Global.fMoveLight, 0.0f, 364.0f, "Day of year" ) ) {
|
( to_string( Global.fMoveLight, 0, 5 ) + " (" + Global.Season + ")###movelight" ).c_str(), &Global.fMoveLight, 0.0f, 364.0f, "Day of year" ) ) {
|
||||||
command_relay relay;
|
command_relay commandrelay;
|
||||||
relay.post(
|
commandrelay.post(
|
||||||
user_command::setdatetime,
|
user_command::setdatetime,
|
||||||
std::clamp( Global.fMoveLight, 0.0f, 365.0f ),
|
std::clamp( Global.fMoveLight, 0.0f, 365.0f ),
|
||||||
simulation::Time.data().wHour * 60 + simulation::Time.data().wMinute,
|
simulation::Time.data().wHour * 60 + simulation::Time.data().wMinute,
|
||||||
@@ -687,8 +687,8 @@ debug_panel::render_section_scenario() {
|
|||||||
+ ":"
|
+ ":"
|
||||||
+ std::string( std::to_string( int( 100 + simulation::Time.data().wMinute ) ).substr( 1, 2 ) ) ) };
|
+ std::string( std::to_string( int( 100 + simulation::Time.data().wMinute ) ).substr( 1, 2 ) ) ) };
|
||||||
if( ImGui::SliderInt( ( timestring + " (" + Global.Period + ")###simulationtime" ).c_str(), &time, 0, 1439, "Time of day" ) ) {
|
if( ImGui::SliderInt( ( timestring + " (" + Global.Period + ")###simulationtime" ).c_str(), &time, 0, 1439, "Time of day" ) ) {
|
||||||
command_relay relay;
|
command_relay commandrelay;
|
||||||
relay.post(
|
commandrelay.post(
|
||||||
user_command::setdatetime,
|
user_command::setdatetime,
|
||||||
Global.fMoveLight,
|
Global.fMoveLight,
|
||||||
std::clamp( time, 0, 1439 ),
|
std::clamp( time, 0, 1439 ),
|
||||||
@@ -1314,36 +1314,36 @@ debug_panel::update_section_eventqueue( std::vector<text_line> &Output ) {
|
|||||||
|
|
||||||
// current event queue
|
// current event queue
|
||||||
auto const time { Timer::GetTime() };
|
auto const time { Timer::GetTime() };
|
||||||
auto const *event { simulation::Events.begin() };
|
auto const *queuedevent { simulation::Events.begin() };
|
||||||
auto const searchfilter { std::string( m_eventsearch.data() ) };
|
auto const searchfilter { std::string( m_eventsearch.data() ) };
|
||||||
|
|
||||||
Output.emplace_back( "Delay: Event:", Global.UITextColor );
|
Output.emplace_back( "Delay: Event:", Global.UITextColor );
|
||||||
|
|
||||||
while( event != nullptr
|
while( queuedevent != nullptr
|
||||||
&& Output.size() < 30 ) {
|
&& Output.size() < 30 ) {
|
||||||
|
|
||||||
if( false == event->m_ignored
|
if( false == queuedevent->m_ignored
|
||||||
&& false == event->m_passive
|
&& false == queuedevent->m_passive
|
||||||
&& ( false == m_eventqueueactivevehicleonly
|
&& ( false == m_eventqueueactivevehicleonly
|
||||||
|| event->m_activator == m_input.vehicle ) ) {
|
|| queuedevent->m_activator == m_input.vehicle ) ) {
|
||||||
|
|
||||||
auto const label { event->m_name + ( event->m_activator ? " (by: " + event->m_activator->asName + ")" : "" ) };
|
auto const label { queuedevent->m_name + ( queuedevent->m_activator ? " (by: " + queuedevent->m_activator->asName + ")" : "" ) };
|
||||||
|
|
||||||
if( false == searchfilter.empty()
|
if( false == searchfilter.empty()
|
||||||
&& false == contains(label, searchfilter) ) {
|
&& false == contains(label, searchfilter) ) {
|
||||||
event = event->m_next;
|
queuedevent = queuedevent->m_next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const delay { " " + to_string( std::max( 0.0, event->m_launchtime - time ), 1 ) };
|
auto const delay { " " + to_string( std::max( 0.0, queuedevent->m_launchtime - time ), 1 ) };
|
||||||
textline =
|
textline =
|
||||||
delay.substr( delay.length() - 6 )
|
delay.substr( delay.length() - 6 )
|
||||||
+ " "
|
+ " "
|
||||||
+ label + ( event->m_sibling ? " (joint event)" : "" );
|
+ label + ( queuedevent->m_sibling ? " (joint event)" : "" );
|
||||||
|
|
||||||
Output.emplace_back( textline, Global.UITextColor );
|
Output.emplace_back( textline, Global.UITextColor );
|
||||||
}
|
}
|
||||||
event = event->m_next;
|
queuedevent = queuedevent->m_next;
|
||||||
}
|
}
|
||||||
if( Output.size() == 1 ) {
|
if( Output.size() == 1 ) {
|
||||||
// event queue can be empty either because no event got through active filters, or because it is genuinely empty
|
// event queue can be empty either because no event got through active filters, or because it is genuinely empty
|
||||||
@@ -1569,8 +1569,8 @@ debug_panel::render_section_settings() const {
|
|||||||
if (simulation::Train) {
|
if (simulation::Train) {
|
||||||
float val = simulation::Train->get_radiovolume();
|
float val = simulation::Train->get_radiovolume();
|
||||||
if( ImGui::SliderFloat( ( std::to_string( static_cast<int>( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) {
|
if( ImGui::SliderFloat( ( std::to_string( static_cast<int>( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) {
|
||||||
command_relay relay;
|
command_relay commandrelay;
|
||||||
relay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
|
commandrelay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ std::optional<int64_t> gl::query::result()
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum gl::query::glenum_target(targets target) const
|
GLenum gl::query::glenum_target(targets Target) const
|
||||||
{
|
{
|
||||||
static GLenum mapping[6] =
|
static GLenum mapping[6] =
|
||||||
{
|
{
|
||||||
@@ -60,7 +60,7 @@ GLenum gl::query::glenum_target(targets target) const
|
|||||||
GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
|
GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
|
||||||
GL_TIME_ELAPSED
|
GL_TIME_ELAPSED
|
||||||
};
|
};
|
||||||
return mapping[target];
|
return mapping[Target];
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_local gl::query* gl::query::active_queries[6];
|
thread_local gl::query* gl::query::active_queries[6];
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ void gl::shader::parse_texture_entries(std::string &str)
|
|||||||
std::istringstream ss(str.substr(fp + 1, fe - fp - 1));
|
std::istringstream ss(str.substr(fp + 1, fe - fp - 1));
|
||||||
std::string token;
|
std::string token;
|
||||||
|
|
||||||
std::string name;
|
std::string uniformname;
|
||||||
texture_entry conf;
|
texture_entry conf;
|
||||||
|
|
||||||
size_t arg = 0;
|
size_t arg = 0;
|
||||||
@@ -206,7 +206,7 @@ void gl::shader::parse_texture_entries(std::string &str)
|
|||||||
{
|
{
|
||||||
std::istringstream token_ss(token);
|
std::istringstream token_ss(token);
|
||||||
if (arg == 0)
|
if (arg == 0)
|
||||||
token_ss >> name;
|
token_ss >> uniformname;
|
||||||
else if (arg == 1)
|
else if (arg == 1)
|
||||||
token_ss >> conf.id;
|
token_ss >> conf.id;
|
||||||
else if (arg == 2)
|
else if (arg == 2)
|
||||||
@@ -223,12 +223,12 @@ void gl::shader::parse_texture_entries(std::string &str)
|
|||||||
|
|
||||||
if (arg == 3)
|
if (arg == 3)
|
||||||
{
|
{
|
||||||
if (name.empty())
|
if (uniformname.empty())
|
||||||
log_error("empty name");
|
log_error("empty name");
|
||||||
else if (conf.id >= gl::MAX_TEXTURES)
|
else if (conf.id >= gl::MAX_TEXTURES)
|
||||||
log_error("invalid texture binding: " + std::to_string(conf.id));
|
log_error("invalid texture binding: " + std::to_string(conf.id));
|
||||||
else
|
else
|
||||||
texture_conf.try_emplace(name, conf);
|
texture_conf.try_emplace(uniformname, conf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log_error("invalid argument count to #texture");
|
log_error("invalid argument count to #texture");
|
||||||
@@ -252,7 +252,7 @@ void gl::shader::parse_param_entries(std::string &str)
|
|||||||
std::istringstream ss(str.substr(fp + 1, fe - fp - 1));
|
std::istringstream ss(str.substr(fp + 1, fe - fp - 1));
|
||||||
std::string token;
|
std::string token;
|
||||||
|
|
||||||
std::string name;
|
std::string uniformname;
|
||||||
param_entry conf;
|
param_entry conf;
|
||||||
|
|
||||||
size_t arg = 0;
|
size_t arg = 0;
|
||||||
@@ -260,7 +260,7 @@ void gl::shader::parse_param_entries(std::string &str)
|
|||||||
{
|
{
|
||||||
std::istringstream token_ss(token);
|
std::istringstream token_ss(token);
|
||||||
if (arg == 0)
|
if (arg == 0)
|
||||||
token_ss >> name;
|
token_ss >> uniformname;
|
||||||
else if (arg == 1)
|
else if (arg == 1)
|
||||||
token_ss >> conf.location;
|
token_ss >> conf.location;
|
||||||
else if (arg == 2)
|
else if (arg == 2)
|
||||||
@@ -280,7 +280,7 @@ void gl::shader::parse_param_entries(std::string &str)
|
|||||||
|
|
||||||
if (arg == 5)
|
if (arg == 5)
|
||||||
{
|
{
|
||||||
if (name.empty())
|
if (uniformname.empty())
|
||||||
log_error("empty name");
|
log_error("empty name");
|
||||||
else if (conf.location >= gl::MAX_PARAMS)
|
else if (conf.location >= gl::MAX_PARAMS)
|
||||||
log_error("invalid param binding: " + std::to_string(conf.location));
|
log_error("invalid param binding: " + std::to_string(conf.location));
|
||||||
@@ -289,7 +289,7 @@ void gl::shader::parse_param_entries(std::string &str)
|
|||||||
else if (conf.offset + conf.size > 4)
|
else if (conf.offset + conf.size > 4)
|
||||||
log_error("invalid size: " + std::to_string(conf.size));
|
log_error("invalid size: " + std::to_string(conf.size));
|
||||||
else
|
else
|
||||||
param_conf.try_emplace(name, conf);
|
param_conf.try_emplace(uniformname, conf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log_error("invalid argument count to #param");
|
log_error("invalid argument count to #param");
|
||||||
|
|||||||
@@ -355,19 +355,19 @@ drivermouse_input::button( int const Button, int const Action ) {
|
|||||||
// if not release then it's press
|
// if not release then it's press
|
||||||
m_pickwaiting = true;
|
m_pickwaiting = true;
|
||||||
GfxRenderer->Pick_Control_Callback(
|
GfxRenderer->Pick_Control_Callback(
|
||||||
[this, Button, Action, &mousecommand](TSubModel const *control, const glm::vec2 pos) {
|
[this, Button, Action, &mousecommand](TSubModel const *controlsubmodel, const glm::vec2 pos) {
|
||||||
|
|
||||||
bool pickwaiting = m_pickwaiting;
|
bool pickwaiting = m_pickwaiting;
|
||||||
m_pickwaiting = false;
|
m_pickwaiting = false;
|
||||||
|
|
||||||
// click on python screen
|
// click on python screen
|
||||||
if (Button == GLFW_MOUSE_BUTTON_LEFT
|
if (Button == GLFW_MOUSE_BUTTON_LEFT
|
||||||
&& control && control->screen_touch_list) {
|
&& controlsubmodel && controlsubmodel->screen_touch_list) {
|
||||||
|
|
||||||
control->screen_touch_list->emplace_back(pos);
|
controlsubmodel->screen_touch_list->emplace_back(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const [leftbinding, rightbinding]{ bindings( simulation::Train->GetLabel( control ) ) };
|
auto const [leftbinding, rightbinding]{ bindings( simulation::Train->GetLabel( controlsubmodel ) ) };
|
||||||
// if the recognized element under the cursor has a command associated with the pressed button, notify the recipient
|
// if the recognized element under the cursor has a command associated with the pressed button, notify the recipient
|
||||||
mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? leftbinding : rightbinding;
|
mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? leftbinding : rightbinding;
|
||||||
|
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
|||||||
std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) + " rcvd" );
|
std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) + " rcvd" );
|
||||||
|
|
||||||
if( Global.iMultiplayer ) {
|
if( Global.iMultiplayer ) {
|
||||||
auto *event = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
auto *foundevent = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
||||||
if (event != nullptr && (typeid(*event) == typeid(multi_event)
|
if (foundevent != nullptr && (typeid(*foundevent) == typeid(multi_event)
|
||||||
|| typeid(*event) == typeid(lights_event)
|
|| typeid(*foundevent) == typeid(lights_event)
|
||||||
|| event->m_sibling != nullptr)) {
|
|| foundevent->m_sibling != nullptr)) {
|
||||||
// tylko jawne albo niejawne Multiple
|
// tylko jawne albo niejawne Multiple
|
||||||
command_relay relay;
|
command_relay commandrelay;
|
||||||
relay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &event->name());
|
commandrelay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &foundevent->name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -178,14 +178,14 @@ std::shared_ptr<ui::skin_meta> ui::vehicles_bank::parse_meta(const std::string &
|
|||||||
std::ranges::replace(meta->photo_author, '_', ' ');
|
std::ranges::replace(meta->photo_author, '_', ' ');
|
||||||
|
|
||||||
if (!meta->rev_date.empty() && meta->rev_date != "?") {
|
if (!meta->rev_date.empty() && meta->rev_date != "?") {
|
||||||
std::istringstream stream(meta->rev_date);
|
std::istringstream datestream(meta->rev_date);
|
||||||
std::string day;
|
std::string day;
|
||||||
std::string month;
|
std::string month;
|
||||||
|
|
||||||
std::getline(stream, day, '.');
|
std::getline(datestream, day, '.');
|
||||||
std::getline(stream, month, '.');
|
std::getline(datestream, month, '.');
|
||||||
|
|
||||||
stream >> meta->rev_year;
|
datestream >> meta->rev_year;
|
||||||
}
|
}
|
||||||
|
|
||||||
return meta;
|
return meta;
|
||||||
|
|||||||
@@ -183,17 +183,17 @@ void network::tcp::client::connect()
|
|||||||
if (this->conn)
|
if (this->conn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto conn = std::make_shared<connection>(io_ctx, true, resume_frame_counter);
|
auto newconnection = std::make_shared<connection>(io_ctx, true, resume_frame_counter);
|
||||||
conn->set_handler(std::bind(&client::handle_message, this, conn, std::placeholders::_1));
|
newconnection->set_handler(std::bind(&client::handle_message, this, newconnection, std::placeholders::_1));
|
||||||
|
|
||||||
asio::ip::tcp::endpoint endpoint(
|
asio::ip::tcp::endpoint endpoint(
|
||||||
asio::ip::make_address(host), static_cast<asio::ip::port_type>(port));
|
asio::ip::make_address(host), static_cast<asio::ip::port_type>(port));
|
||||||
conn->m_socket.open(endpoint.protocol());
|
newconnection->m_socket.open(endpoint.protocol());
|
||||||
conn->m_socket.set_option(asio::ip::tcp::no_delay(true));
|
newconnection->m_socket.set_option(asio::ip::tcp::no_delay(true));
|
||||||
conn->m_socket.async_connect(endpoint,
|
newconnection->m_socket.async_connect(endpoint,
|
||||||
std::bind(&client::handle_accept, this, std::placeholders::_1));
|
std::bind(&client::handle_accept, this, std::placeholders::_1));
|
||||||
|
|
||||||
this->conn = conn;
|
this->conn = newconnection;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ void network::request_command::deserialize(std::istream &stream)
|
|||||||
uint32_t sequence_size = sn_utils::ld_uint32(stream);
|
uint32_t sequence_size = sn_utils::ld_uint32(stream);
|
||||||
|
|
||||||
command_queue::commanddata_sequence sequence;
|
command_queue::commanddata_sequence sequence;
|
||||||
for (uint32_t i = 0; i < sequence_size; i++)
|
for (uint32_t j = 0; j < sequence_size; j++)
|
||||||
{
|
{
|
||||||
command_data data;
|
command_data data;
|
||||||
data.command = (user_command)sn_utils::ld_uint32(stream);
|
data.command = (user_command)sn_utils::ld_uint32(stream);
|
||||||
|
|||||||
@@ -232,17 +232,17 @@ void network::client::send_commands(command_queue::commands_map commands) const
|
|||||||
conn->send_message(msg);
|
conn->send_message(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void network::client::handle_message(std::shared_ptr<connection> conn, const message &msg)
|
void network::client::handle_message(std::shared_ptr<connection> Connection, const message &msg)
|
||||||
{
|
{
|
||||||
if (msg.type >= message::TYPE_MAX)
|
if (msg.type >= message::TYPE_MAX)
|
||||||
{
|
{
|
||||||
conn->disconnect();
|
Connection->disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.type == message::SERVER_HELLO) {
|
if (msg.type == message::SERVER_HELLO) {
|
||||||
const auto& cmd = dynamic_cast<const server_hello&>(msg);
|
const auto& cmd = dynamic_cast<const server_hello&>(msg);
|
||||||
conn->state = connection::ACTIVE;
|
Connection->state = connection::ACTIVE;
|
||||||
|
|
||||||
if (!Global.ready_to_load) {
|
if (!Global.ready_to_load) {
|
||||||
Global.random_seed = cmd.seed;
|
Global.random_seed = cmd.seed;
|
||||||
@@ -253,14 +253,14 @@ void network::client::handle_message(std::shared_ptr<connection> conn, const mes
|
|||||||
Global.ready_to_load = true;
|
Global.ready_to_load = true;
|
||||||
} else if (Global.random_seed != cmd.seed) {
|
} else if (Global.random_seed != cmd.seed) {
|
||||||
ErrorLog("net: seed mismatch", logtype::net);
|
ErrorLog("net: seed mismatch", logtype::net);
|
||||||
conn->disconnect();
|
Connection->disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteLog("net: accept received", logtype::net);
|
WriteLog("net: accept received", logtype::net);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->state != connection::ACTIVE)
|
if (Connection->state != connection::ACTIVE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (msg.type == message::FRAME_INFO) {
|
if (msg.type == message::FRAME_INFO) {
|
||||||
|
|||||||
@@ -145,10 +145,10 @@ int lua::scriptapi_event_create(lua_State *L)
|
|||||||
int lua::scriptapi_event_find(lua_State *L)
|
int lua::scriptapi_event_find(lua_State *L)
|
||||||
{
|
{
|
||||||
std::string name = lua_tostring(L, 1);
|
std::string name = lua_tostring(L, 1);
|
||||||
basic_event *event = simulation::Events.FindEvent(name);
|
basic_event *foundevent = simulation::Events.FindEvent(name);
|
||||||
if (event)
|
if (foundevent)
|
||||||
{
|
{
|
||||||
lua_pushlightuserdata(L, event);
|
lua_pushlightuserdata(L, foundevent);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ErrorLog("lua: missing event: " + name);
|
ErrorLog("lua: missing event: " + name);
|
||||||
@@ -158,8 +158,8 @@ int lua::scriptapi_event_find(lua_State *L)
|
|||||||
int lua::scriptapi_event_exists(lua_State *L)
|
int lua::scriptapi_event_exists(lua_State *L)
|
||||||
{
|
{
|
||||||
std::string name = lua_tostring(L, 1);
|
std::string name = lua_tostring(L, 1);
|
||||||
basic_event *event = simulation::Events.FindEvent(name);
|
basic_event *foundevent = simulation::Events.FindEvent(name);
|
||||||
lua_pushboolean(L, event != nullptr);
|
lua_pushboolean(L, foundevent != nullptr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +189,9 @@ int lua::scriptapi_event_dispatch_n(lua_State *L)
|
|||||||
std::string name = lua_tostring(L, 1);
|
std::string name = lua_tostring(L, 1);
|
||||||
auto *activator = static_cast<TDynamicObject *>(lua_touserdata(L, 2));
|
auto *activator = static_cast<TDynamicObject *>(lua_touserdata(L, 2));
|
||||||
double delay = lua_tonumber(L, 3);
|
double delay = lua_tonumber(L, 3);
|
||||||
basic_event *event = simulation::Events.FindEvent(name);
|
basic_event *foundevent = simulation::Events.FindEvent(name);
|
||||||
if (event)
|
if (foundevent)
|
||||||
simulation::Events.AddToQuery(event, activator, delay);
|
simulation::Events.AddToQuery(foundevent, activator, delay);
|
||||||
else
|
else
|
||||||
ErrorLog("lua: missing event: " + name);
|
ErrorLog("lua: missing event: " + name);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ void motiontelemetry::update()
|
|||||||
|
|
||||||
double dt = Timer::GetDeltaTime();
|
double dt = Timer::GetDeltaTime();
|
||||||
|
|
||||||
glm::dvec3 front = t->Dynamic()->VectorFront();
|
glm::dvec3 frontvector = t->Dynamic()->VectorFront();
|
||||||
glm::dvec3 up = t->Dynamic()->VectorUp();
|
glm::dvec3 up = t->Dynamic()->VectorUp();
|
||||||
glm::dvec3 left = t->Dynamic()->VectorLeft();
|
glm::dvec3 leftvector = t->Dynamic()->VectorLeft();
|
||||||
|
|
||||||
glm::dvec3 pos = t->Dynamic()->GetPosition();
|
glm::dvec3 pos = t->Dynamic()->GetPosition();
|
||||||
glm::dvec3 vel = (pos - last_pos) / dt;
|
glm::dvec3 vel = (pos - last_pos) / dt;
|
||||||
@@ -86,18 +86,18 @@ void motiontelemetry::update()
|
|||||||
if (conf.includegravity)
|
if (conf.includegravity)
|
||||||
{
|
{
|
||||||
glm::dvec3 gravity(0.0, 9.81, 0.0);
|
glm::dvec3 gravity(0.0, 9.81, 0.0);
|
||||||
local_acc = glm::dvec3(-glm::dot(gravity, left), glm::dot(gravity, up), glm::dot(gravity, front));
|
local_acc = glm::dvec3(-glm::dot(gravity, leftvector), glm::dot(gravity, up), glm::dot(gravity, frontvector));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf.latposbased)
|
if (conf.latposbased)
|
||||||
local_acc.x -= glm::dot(acc, left);
|
local_acc.x -= glm::dot(acc, leftvector);
|
||||||
else
|
else
|
||||||
local_acc.x -= t->Occupied()->AccN;
|
local_acc.x -= t->Occupied()->AccN;
|
||||||
|
|
||||||
local_acc.y += glm::dot(acc, up) + t->Occupied()->AccVert * conf.axlebumpscale;
|
local_acc.y += glm::dot(acc, up) + t->Occupied()->AccVert * conf.axlebumpscale;
|
||||||
|
|
||||||
if (conf.fwdposbased)
|
if (conf.fwdposbased)
|
||||||
local_acc.z += glm::dot(acc, front);
|
local_acc.z += glm::dot(acc, frontvector);
|
||||||
else
|
else
|
||||||
local_acc.z += t->Occupied()->AccSVBased;
|
local_acc.z += t->Occupied()->AccSVBased;
|
||||||
|
|
||||||
@@ -106,16 +106,16 @@ void motiontelemetry::update()
|
|||||||
// roll calculation, maybe too complicated?
|
// roll calculation, maybe too complicated?
|
||||||
|
|
||||||
// transform to left-handed
|
// transform to left-handed
|
||||||
front.z *= -1;
|
frontvector.z *= -1;
|
||||||
up.z *= -1;
|
up.z *= -1;
|
||||||
|
|
||||||
// make sure that vectors are orthonormal
|
// make sure that vectors are orthonormal
|
||||||
glm::dvec3 oright = glm::normalize(glm::cross(up, front));
|
glm::dvec3 oright = glm::normalize(glm::cross(up, frontvector));
|
||||||
glm::dvec3 oup = glm::cross(front, oright);
|
glm::dvec3 oup = glm::cross(frontvector, oright);
|
||||||
|
|
||||||
// right and up vector without roll
|
// right and up vector without roll
|
||||||
glm::dvec3 right0 = glm::normalize(glm::cross(glm::dvec3(0.0, 1.0, 0.0), front));
|
glm::dvec3 right0 = glm::normalize(glm::cross(glm::dvec3(0.0, 1.0, 0.0), frontvector));
|
||||||
glm::dvec3 up0 = glm::cross(front, right0);
|
glm::dvec3 up0 = glm::cross(frontvector, right0);
|
||||||
|
|
||||||
double cosroll = glm::dot(up0, oup);
|
double cosroll = glm::dot(up0, oup);
|
||||||
double sinroll;
|
double sinroll;
|
||||||
@@ -127,7 +127,7 @@ void motiontelemetry::update()
|
|||||||
else
|
else
|
||||||
sinroll = (up0.z * cosroll - oup.z) / right0.z;
|
sinroll = (up0.z * cosroll - oup.z) / right0.z;
|
||||||
|
|
||||||
glm::dvec3 rot(asin(-front.y), atan2(front.x, front.z), asin(sinroll));
|
glm::dvec3 rot(asin(-frontvector.y), atan2(frontvector.x, frontvector.z), asin(sinroll));
|
||||||
|
|
||||||
double velocity = t->Occupied()->V;
|
double velocity = t->Occupied()->V;
|
||||||
double yaw_vel = (rot.y - last_yaw) / dt;
|
double yaw_vel = (rot.y - last_yaw) / dt;
|
||||||
|
|||||||
@@ -902,19 +902,19 @@ std::shared_ptr<dictionary_source> TTrain::GetTrainState(dictionary_source const
|
|||||||
dict->insert("slip_" + caridx, bSlip[i]);
|
dict->insert("slip_" + caridx, bSlip[i]);
|
||||||
}
|
}
|
||||||
// ai state data
|
// ai state data
|
||||||
auto const *driver{(DynamicObject->ctOwner != nullptr ? DynamicObject->ctOwner : DynamicObject->Mechanik)};
|
auto const *vehicledriver{(DynamicObject->ctOwner != nullptr ? DynamicObject->ctOwner : DynamicObject->Mechanik)};
|
||||||
|
|
||||||
dict->insert("velocity_desired", driver->VelDesired);
|
dict->insert("velocity_desired", vehicledriver->VelDesired);
|
||||||
dict->insert("velroad", driver->VelRoad);
|
dict->insert("velroad", vehicledriver->VelRoad);
|
||||||
dict->insert("vellimitlast", driver->VelLimitLast);
|
dict->insert("vellimitlast", vehicledriver->VelLimitLast);
|
||||||
dict->insert("velsignallast", driver->VelSignalLast);
|
dict->insert("velsignallast", vehicledriver->VelSignalLast);
|
||||||
dict->insert("velsignalnext", driver->VelSignalNext);
|
dict->insert("velsignalnext", vehicledriver->VelSignalNext);
|
||||||
dict->insert("velnext", driver->VelNext);
|
dict->insert("velnext", vehicledriver->VelNext);
|
||||||
dict->insert("actualproximitydist", driver->ActualProximityDist);
|
dict->insert("actualproximitydist", vehicledriver->ActualProximityDist);
|
||||||
// train data
|
// train data
|
||||||
driver->TrainTimetable().serialize(dict.get());
|
vehicledriver->TrainTimetable().serialize(dict.get());
|
||||||
dict->insert("train_atpassengerstop", driver->IsAtPassengerStop);
|
dict->insert("train_atpassengerstop", vehicledriver->IsAtPassengerStop);
|
||||||
dict->insert("train_length", driver->fLength);
|
dict->insert("train_length", vehicledriver->fLength);
|
||||||
// world state data
|
// world state data
|
||||||
dict->insert("scenario", Global.SceneryFile);
|
dict->insert("scenario", Global.SceneryFile);
|
||||||
dict->insert("hours", static_cast<int>(simulation::Time.data().wHour));
|
dict->insert("hours", static_cast<int>(simulation::Time.data().wHour));
|
||||||
@@ -1075,10 +1075,10 @@ TDynamicObject *TTrain::find_nearest_consist_vehicle(bool freefly, glm::vec3 pos
|
|||||||
if (!freefly)
|
if (!freefly)
|
||||||
return DynamicObject;
|
return DynamicObject;
|
||||||
|
|
||||||
auto coupler{-2}; // scan for vehicle, not any specific coupler
|
auto couplerindex{-2}; // scan for vehicle, not any specific coupler
|
||||||
auto *vehicle{DynamicObject->ABuScanNearestObject(pos, DynamicObject->GetTrack(), 1, 1500, coupler)};
|
auto *vehicle{DynamicObject->ABuScanNearestObject(pos, DynamicObject->GetTrack(), 1, 1500, couplerindex)};
|
||||||
if (vehicle == nullptr)
|
if (vehicle == nullptr)
|
||||||
vehicle = DynamicObject->ABuScanNearestObject(pos, DynamicObject->GetTrack(), -1, 1500, coupler);
|
vehicle = DynamicObject->ABuScanNearestObject(pos, DynamicObject->GetTrack(), -1, 1500, couplerindex);
|
||||||
// TBD, TODO: perform owner test for the located vehicle
|
// TBD, TODO: perform owner test for the located vehicle
|
||||||
return vehicle;
|
return vehicle;
|
||||||
}
|
}
|
||||||
@@ -7669,15 +7669,15 @@ void TTrain::OnCommand_nearestcarcouplingincrease(TTrain *Train, command_data co
|
|||||||
if (true == Command.freefly && Command.action == GLFW_PRESS)
|
if (true == Command.freefly && Command.action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
// tryb freefly, press only
|
// tryb freefly, press only
|
||||||
auto coupler{-1};
|
auto couplerindex{-1};
|
||||||
auto *vehicle{Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), 1, 1500, coupler)};
|
auto *vehicle{Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), 1, 1500, couplerindex)};
|
||||||
if (vehicle == nullptr)
|
if (vehicle == nullptr)
|
||||||
vehicle = Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), -1, 1500, coupler);
|
vehicle = Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), -1, 1500, couplerindex);
|
||||||
|
|
||||||
if (coupler != -1 && vehicle != nullptr)
|
if (couplerindex != -1 && vehicle != nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
vehicle->couple(coupler);
|
vehicle->couple(couplerindex);
|
||||||
}
|
}
|
||||||
if (Train->DynamicObject->Mechanik)
|
if (Train->DynamicObject->Mechanik)
|
||||||
{
|
{
|
||||||
@@ -7693,15 +7693,15 @@ void TTrain::OnCommand_nearestcarcouplingdisconnect(TTrain *Train, command_data
|
|||||||
if (true == Command.freefly && Command.action == GLFW_PRESS)
|
if (true == Command.freefly && Command.action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
// tryb freefly, press only
|
// tryb freefly, press only
|
||||||
auto coupler{-1};
|
auto couplerindex{-1};
|
||||||
auto *vehicle{Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), 1, 1500, coupler)};
|
auto *vehicle{Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), 1, 1500, couplerindex)};
|
||||||
if (vehicle == nullptr)
|
if (vehicle == nullptr)
|
||||||
vehicle = Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), -1, 1500, coupler);
|
vehicle = Train->DynamicObject->ABuScanNearestObject(Command.location, Train->DynamicObject->GetTrack(), -1, 1500, couplerindex);
|
||||||
|
|
||||||
if (coupler != -1 && vehicle != nullptr)
|
if (couplerindex != -1 && vehicle != nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
vehicle->uncouple(coupler);
|
vehicle->uncouple(couplerindex);
|
||||||
}
|
}
|
||||||
if (Train->DynamicObject->Mechanik)
|
if (Train->DynamicObject->Mechanik)
|
||||||
{
|
{
|
||||||
@@ -7723,10 +7723,10 @@ void TTrain::OnCommand_nearestcarcoupleradapterattach(TTrain * /*Train*/, comman
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const coupler =
|
auto const couplerindex =
|
||||||
glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : end::rear;
|
glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : end::rear;
|
||||||
|
|
||||||
vehicle->attach_coupler_adapter(coupler);
|
vehicle->attach_coupler_adapter(couplerindex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7742,10 +7742,10 @@ void TTrain::OnCommand_nearestcarcoupleradapterremove(TTrain * /*Train*/, comman
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const coupler =
|
auto const couplerindex =
|
||||||
glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : end::rear;
|
glm::length2(glm::vec3{vehicle->CouplerPosition(end::front)} - Command.location) < glm::length2(glm::vec3{vehicle->CouplerPosition(end::rear)} - Command.location) ? end::front : end::rear;
|
||||||
|
|
||||||
vehicle->remove_coupler_adapter(coupler);
|
vehicle->remove_coupler_adapter(couplerindex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9964,8 +9964,8 @@ void TTrain::update_sounds(double const Deltatime)
|
|||||||
{
|
{
|
||||||
if (fTachoCount >= 3.f)
|
if (fTachoCount >= 3.f)
|
||||||
{
|
{
|
||||||
auto const frequency{(true == dsbHasler->is_combined() ? fTachoVelocity * 0.01 : dsbHasler->m_frequencyoffset + dsbHasler->m_frequencyfactor)};
|
auto const soundfrequency{(true == dsbHasler->is_combined() ? fTachoVelocity * 0.01 : dsbHasler->m_frequencyoffset + dsbHasler->m_frequencyfactor)};
|
||||||
dsbHasler->pitch(static_cast<float>(frequency));
|
dsbHasler->pitch(static_cast<float>(soundfrequency));
|
||||||
dsbHasler->gain(dsbHasler->m_amplitudeoffset + dsbHasler->m_amplitudefactor);
|
dsbHasler->gain(dsbHasler->m_amplitudeoffset + dsbHasler->m_amplitudefactor);
|
||||||
dsbHasler->play(sound_flags::exclusive | sound_flags::looping);
|
dsbHasler->play(sound_flags::exclusive | sound_flags::looping);
|
||||||
}
|
}
|
||||||
@@ -10067,14 +10067,14 @@ void TTrain::update_sounds_resonancenoise(sound_source &Sound) const
|
|||||||
{
|
{
|
||||||
// frequency calculation
|
// frequency calculation
|
||||||
auto const normalizer{mvOccupied->Vmax * 0.01f};
|
auto const normalizer{mvOccupied->Vmax * 0.01f};
|
||||||
auto const frequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * mvOccupied->Vel * normalizer};
|
auto const soundfrequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * mvOccupied->Vel * normalizer};
|
||||||
|
|
||||||
// volume calculation
|
// volume calculation
|
||||||
auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(mvOccupied->Vel / (1 + mvOccupied->Vmax), 1.0, 0.5); // scale base volume between 0.5-1.0
|
auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(mvOccupied->Vel / (1 + mvOccupied->Vmax), 1.0, 0.5); // scale base volume between 0.5-1.0
|
||||||
|
|
||||||
if (volume > 0.05)
|
if (volume > 0.05)
|
||||||
{
|
{
|
||||||
Sound.pitch(static_cast<float>(frequency)).gain(static_cast<float>(volume)).play(sound_flags::exclusive | sound_flags::looping);
|
Sound.pitch(static_cast<float>(soundfrequency)).gain(static_cast<float>(volume)).play(sound_flags::exclusive | sound_flags::looping);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -10086,7 +10086,7 @@ void TTrain::update_sounds_runningnoise(sound_source &Sound)
|
|||||||
{
|
{
|
||||||
// frequency calculation
|
// frequency calculation
|
||||||
auto const normalizer{(true == Sound.is_combined() ? mvOccupied->Vmax * 0.01f : 1.f)};
|
auto const normalizer{(true == Sound.is_combined() ? mvOccupied->Vmax * 0.01f : 1.f)};
|
||||||
auto const frequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * mvOccupied->Vel * normalizer};
|
auto const soundfrequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * mvOccupied->Vel * normalizer};
|
||||||
|
|
||||||
// volume calculation
|
// volume calculation
|
||||||
auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(mvOccupied->Vel / (1 + mvOccupied->Vmax), 1.0,
|
auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(mvOccupied->Vel / (1 + mvOccupied->Vmax), 1.0,
|
||||||
@@ -10109,7 +10109,7 @@ void TTrain::update_sounds_runningnoise(sound_source &Sound)
|
|||||||
|
|
||||||
if (volume > 0.05)
|
if (volume > 0.05)
|
||||||
{
|
{
|
||||||
Sound.pitch(static_cast<float>(frequency)).gain(static_cast<float>(volume)).play(sound_flags::exclusive | sound_flags::looping);
|
Sound.pitch(static_cast<float>(soundfrequency)).gain(static_cast<float>(volume)).play(sound_flags::exclusive | sound_flags::looping);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -164,9 +164,9 @@ void ui::cameraview_panel::record_func()
|
|||||||
|
|
||||||
if (!rec_name.empty()) {
|
if (!rec_name.empty()) {
|
||||||
const std::string magic{"{RECORD}"};
|
const std::string magic{"{RECORD}"};
|
||||||
size_t pos = cmdline.find(magic);
|
size_t magicpos = cmdline.find(magic);
|
||||||
if (pos != -1)
|
if (magicpos != -1)
|
||||||
cmdline.replace(pos, magic.size(), rec_name);
|
cmdline.replace(magicpos, magic.size(), rec_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
piped_proc proc(cmdline, true);
|
piped_proc proc(cmdline, true);
|
||||||
|
|||||||
@@ -157,11 +157,11 @@ bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1,
|
|||||||
|
|
||||||
if( TestFlag( CheckMask, basic_event::flags::text ) ) {
|
if( TestFlag( CheckMask, basic_event::flags::text ) ) {
|
||||||
// porównać teksty
|
// porównać teksty
|
||||||
auto range = szTestText.find( '*' );
|
auto wildcardpos = szTestText.find( '*' );
|
||||||
auto const result { (
|
auto const result { (
|
||||||
range == std::string::npos ?
|
wildcardpos == std::string::npos ?
|
||||||
compare( szText, szTestText, TextOperator ) :
|
compare( szText, szTestText, TextOperator ) :
|
||||||
compare( szText.substr( 0, range ), szTestText.substr( 0, range ), TextOperator ) ) };
|
compare( szText.substr( 0, wildcardpos ), szTestText.substr( 0, wildcardpos ), TextOperator ) ) };
|
||||||
checkpassed |= result;
|
checkpassed |= result;
|
||||||
checkfailed |= !result;
|
checkfailed |= !result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ TTraction::endpoints() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::size_t
|
std::size_t
|
||||||
TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) {
|
TTraction::create_geometry( gfx::geometrybank_handle const &Geometrybank ) {
|
||||||
if( m_geometry != null_handle ) {
|
if( m_geometry != null_handle ) {
|
||||||
return GfxRenderer->Vertices( m_geometry ).size() / 2;
|
return GfxRenderer->Vertices( m_geometry ).size() / 2;
|
||||||
}
|
}
|
||||||
@@ -343,7 +343,7 @@ TTraction::create_geometry( gfx::geometrybank_handle const &Bank ) {
|
|||||||
auto const elementcount = vertices.size() / 2;
|
auto const elementcount = vertices.size() / 2;
|
||||||
|
|
||||||
gfx::userdata_array empty_userdata{};
|
gfx::userdata_array empty_userdata{};
|
||||||
m_geometry = GfxRenderer->Insert( vertices, empty_userdata, Bank, GL_LINES );
|
m_geometry = GfxRenderer->Insert( vertices, empty_userdata, Geometrybank, GL_LINES );
|
||||||
|
|
||||||
return elementcount;
|
return elementcount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ void TTrainParameters::NewName(std::string const &NewTrainName)
|
|||||||
LocLoad = 0;
|
LocLoad = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrainParameters::UpdateVelocity(int StationCount, double vActual)
|
void TTrainParameters::UpdateVelocity(int Stationcount, double vActual)
|
||||||
// zapisywanie prędkości maksymalnej do wcześniejszych odcinków
|
// zapisywanie prędkości maksymalnej do wcześniejszych odcinków
|
||||||
// wywoływane z numerem ostatniego przetworzonego przystanku
|
// wywoływane z numerem ostatniego przetworzonego przystanku
|
||||||
{
|
{
|
||||||
@@ -254,7 +254,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
|||||||
bool EndTable;
|
bool EndTable;
|
||||||
double vActual;
|
double vActual;
|
||||||
|
|
||||||
int ConversionError = 0;
|
int conversionerror = 0;
|
||||||
EndTable = false;
|
EndTable = false;
|
||||||
if (TrainName == "")
|
if (TrainName == "")
|
||||||
{ // jeśli pusty rozkład
|
{ // jeśli pusty rozkład
|
||||||
@@ -277,15 +277,15 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
|||||||
{
|
{
|
||||||
TTVmax = vmax; // Ra 2014-07: zamiast rozkładu można podać Vmax
|
TTVmax = vmax; // Ra 2014-07: zamiast rozkładu można podać Vmax
|
||||||
UpdateVelocity(StationCount, vmax); // ograniczenie do prędkości startowej
|
UpdateVelocity(StationCount, vmax); // ograniczenie do prędkości startowej
|
||||||
ConversionError = 0;
|
conversionerror = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ConversionError = -8; /*Ra: ten błąd jest niepotrzebny*/
|
conversionerror = -8; /*Ra: ten błąd jest niepotrzebny*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /*analiza rozkładu jazdy*/
|
{ /*analiza rozkładu jazdy*/
|
||||||
ConversionError = 0;
|
conversionerror = 0;
|
||||||
while (fin.good() && !(ConversionError != 0 || EndTable))
|
while (fin.good() && !(conversionerror != 0 || EndTable))
|
||||||
{
|
{
|
||||||
std::getline(fin, lines); /*wczytanie linii*/
|
std::getline(fin, lines); /*wczytanie linii*/
|
||||||
if (contains( lines, "___________________") ) /*linia pozioma górna*/
|
if (contains( lines, "___________________") ) /*linia pozioma górna*/
|
||||||
@@ -353,7 +353,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
|||||||
win1250_to_ascii( Relation1 );
|
win1250_to_ascii( Relation1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ConversionError = -5;
|
conversionerror = -5;
|
||||||
while (fin >> s || !fin.bad())
|
while (fin >> s || !fin.bad())
|
||||||
{
|
{
|
||||||
if (s == "Relacja")
|
if (s == "Relacja")
|
||||||
@@ -408,7 +408,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
|||||||
if (s == "[")
|
if (s == "[")
|
||||||
fin >> s;
|
fin >> s;
|
||||||
else
|
else
|
||||||
ConversionError = -4;
|
conversionerror = -4;
|
||||||
if (false == contains( s,"|") )
|
if (false == contains( s,"|") )
|
||||||
{
|
{
|
||||||
record->km = static_cast<float>(atof(s.c_str()));
|
record->km = static_cast<float>(atof(s.c_str()));
|
||||||
@@ -565,7 +565,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// jeśli nazwa pierwszego zgodna z relacją
|
// jeśli nazwa pierwszego zgodna z relacją
|
||||||
if (ConversionError == 0 && TimeTable[1].StationName == Relation1 && TimeTable[1].Ah < 0) // a nie podany czas przyjazdu
|
if (conversionerror == 0 && TimeTable[1].StationName == Relation1 && TimeTable[1].Ah < 0) // a nie podany czas przyjazdu
|
||||||
{ // to mamy zatrzymanie na pierwszym, a nie przelot
|
{ // to mamy zatrzymanie na pierwszym, a nie przelot
|
||||||
TimeTable[1].Ah = TimeTable[1].Dh;
|
TimeTable[1].Ah = TimeTable[1].Dh;
|
||||||
TimeTable[1].Am = TimeTable[1].Dm;
|
TimeTable[1].Am = TimeTable[1].Dm;
|
||||||
@@ -593,7 +593,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ConversionError == 0;
|
return conversionerror == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user