mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
fixes for EZT and coupler config parsing, minor re-arrangement of the main loop.
This commit is contained in:
28
Driver.cpp
28
Driver.cpp
@@ -318,8 +318,8 @@ std::string TSpeedPos::TableText()
|
||||
{ // pozycja tabelki pr?dko?ci
|
||||
if (iFlags & spEnabled)
|
||||
{ // o ile pozycja istotna
|
||||
return "Flags=" + to_hex_str(iFlags, 6) + ", Dist=" + to_string(fDist, 1, 7) +
|
||||
", Vel=" + (fVelNext == -1.0 ? " * " : to_string(fVelNext, 1, 5)) + ", Name=" + GetName();
|
||||
return "Flags:" + to_hex_str(iFlags, 6) + ", Dist:" + to_string(fDist, 1, 6) +
|
||||
", Vel:" + (fVelNext == -1.0 ? " * " : to_string(static_cast<int>(fVelNext), 0, 3)) + ", Name:" + GetName();
|
||||
//if (iFlags & spTrack) // jeśli tor
|
||||
// return "Flags=#" + IntToHex(iFlags, 8) + ", Dist=" + FloatToStrF(fDist, ffFixed, 7, 1) +
|
||||
// ", Vel=" + AnsiString(fVelNext) + ", Track=" + trTrack->NameGet();
|
||||
@@ -2107,15 +2107,14 @@ bool TController::PrepareEngine()
|
||||
ReactionTime = PrepareTime;
|
||||
iDrivigFlags |= moveActive; // może skanować sygnały i reagować na komendy
|
||||
// with Controlling do
|
||||
if (((mvControlling->EnginePowerSource.SourceType ==
|
||||
CurrentCollector) /*||(mvOccupied->TrainType==dt_EZT)*/))
|
||||
if ( mvControlling->EnginePowerSource.SourceType == CurrentCollector )
|
||||
/*
|
||||
|| ( (mvOccupied->TrainType==dt_EZT)
|
||||
&& (mvControlling->GetTrainsetVoltage() > 0.0 ) ) ) // sprawdzanie, czy zasilanie jest może w innym członie
|
||||
*/
|
||||
{
|
||||
if (mvControlling
|
||||
->GetTrainsetVoltage()) // sprawdzanie, czy zasilanie jest może w innym członie
|
||||
{
|
||||
voltfront = true;
|
||||
voltrear = true;
|
||||
}
|
||||
voltfront = true;
|
||||
voltrear = true;
|
||||
}
|
||||
// begin
|
||||
// if Couplers[0].Connected<>nil)
|
||||
@@ -5266,10 +5265,15 @@ void TController::TakeControl(bool yes)
|
||||
pVehicle->Controller = AIdriver;
|
||||
iDirection = 0; // kierunek jazdy trzeba dopiero zgadnąć
|
||||
// gdy zgaszone światła, flaga podjeżdżania pod semafory pozostaje bez zmiany
|
||||
// conditional below disabled to get around the situation where the AI train does nothing ever
|
||||
// because it is waiting for orders which don't come until the engine is engaged, i.e. effectively never
|
||||
/*
|
||||
if (OrderCurrentGet()) // jeśli coś robi
|
||||
PrepareEngine(); // niech sprawdzi stan silnika
|
||||
*/ PrepareEngine(); // niech sprawdzi stan silnika
|
||||
/*
|
||||
else // jeśli nic nie robi
|
||||
if (pVehicle->iLights[mvOccupied->CabNo < 0 ? 1 : 0] &
|
||||
*/
|
||||
if (pVehicle->iLights[mvOccupied->CabNo < 0 ? 1 : 0] &
|
||||
21) // któreś ze świateł zapalone?
|
||||
{ // od wersji 357 oczekujemy podania komend dla AI przez scenerię
|
||||
OrderNext(Prepare_engine);
|
||||
|
||||
35
DynObj.cpp
35
DynObj.cpp
@@ -5897,3 +5897,38 @@ void TDynamicObject::OverheadTrack(float o)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// returns type of the nearest functional power source present in the trainset
|
||||
TPowerSource
|
||||
TDynamicObject::ConnectedEnginePowerSource( TDynamicObject const *Caller ) const {
|
||||
|
||||
// if there's engine in the current vehicle, that's good enough...
|
||||
if( MoverParameters->EnginePowerSource.SourceType != TPowerSource::NotDefined ) {
|
||||
return MoverParameters->EnginePowerSource.SourceType;
|
||||
}
|
||||
// ...otherwise check rear first...
|
||||
// NOTE: the order should be reversed in flipped vehicles, but we ignore this out of laziness
|
||||
if( ( nullptr != NextConnected )
|
||||
&& ( NextConnected != Caller )
|
||||
&& ( MoverParameters->Couplers[1].CouplingFlag & ctrain_controll == ctrain_controll ) ) {
|
||||
|
||||
auto source = NextConnected->ConnectedEnginePowerSource( this );
|
||||
if( source != TPowerSource::NotDefined ) {
|
||||
|
||||
return source;
|
||||
}
|
||||
}
|
||||
// ...then rear...
|
||||
if( ( nullptr != PrevConnected )
|
||||
&& ( PrevConnected != Caller )
|
||||
&& ( MoverParameters->Couplers[ 0 ].CouplingFlag & ctrain_controll == ctrain_controll ) ) {
|
||||
|
||||
auto source = PrevConnected->ConnectedEnginePowerSource( this );
|
||||
if( source != TPowerSource::NotDefined ) {
|
||||
|
||||
return source;
|
||||
}
|
||||
}
|
||||
// ...if we're still here, report lack of power source
|
||||
return MoverParameters->EnginePowerSource.SourceType;
|
||||
}
|
||||
|
||||
4
DynObj.h
4
DynObj.h
@@ -171,6 +171,10 @@ class TDynamicObject
|
||||
int PrevConnectedNo; // numer sprzęgu podłączonego z przodu
|
||||
double fScanDist; // odległość skanowania torów na obecność innych pojazdów
|
||||
|
||||
TPowerSource ConnectedEnginePowerSource( TDynamicObject const *Caller ) const;
|
||||
|
||||
private:
|
||||
// returns type of the nearest functional power source present in the trainset
|
||||
public: // modele składowe pojazdu
|
||||
TModel3d *mdModel; // model pudła
|
||||
TModel3d *mdLoad; // model zmiennego ładunku
|
||||
|
||||
12
Ground.cpp
12
Ground.cpp
@@ -1878,12 +1878,16 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
fTrainSetDist -=
|
||||
tf3; // przesunięcie dla kolejnego, minus bo idziemy w stronę punktu 1
|
||||
tmp->pCenter = tmp->DynamicObject->GetPosition();
|
||||
/* // NOTE: the ctrain_depot flag is used to mark merged together parts of modular trains
|
||||
// clearing it here breaks this connection, so i'm disabling this piece of code.
|
||||
// if it has some actual purpose and disabling it breaks that, a different solution has to be found
|
||||
// either for modular trains, or whatever it is this code does.
|
||||
if (TempConnectionType[iTrainSetWehicleNumber]) // jeśli jest sprzęg
|
||||
if (tmp->DynamicObject->MoverParameters->Couplers[tf1 == -1.0 ? 0 : 1]
|
||||
.AllowedFlag &
|
||||
ctrain_depot) // jesli zablokowany
|
||||
TempConnectionType[iTrainSetWehicleNumber] |= ctrain_depot; // będzie
|
||||
// blokada
|
||||
TempConnectionType[iTrainSetWehicleNumber] |= ctrain_depot; // będzie blokada
|
||||
*/
|
||||
iTrainSetWehicleNumber++;
|
||||
}
|
||||
else
|
||||
@@ -2380,8 +2384,10 @@ void TGround::FirstInit()
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, Global::diffuseDayLight); // kolor padający
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, Global::specularDayLight); // kolor odbity
|
||||
// musi być tutaj, bo wcześniej nie mieliśmy wartości światła
|
||||
/*
|
||||
if (Global::fMoveLight >= 0.0) // albo tak, albo niech ustala minimum ciemności w nocy
|
||||
{
|
||||
*/
|
||||
Global::fLuminance = // obliczenie luminacji "światła w ciemności"
|
||||
+0.150 * Global::ambientDayLight[0] // R
|
||||
+ 0.295 * Global::ambientDayLight[1] // G
|
||||
@@ -2391,9 +2397,11 @@ void TGround::FirstInit()
|
||||
Global::ambientDayLight[i] *=
|
||||
0.1 / Global::fLuminance; // ograniczenie jasności w nocy
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Global::ambientDayLight);
|
||||
/*
|
||||
}
|
||||
else if (Global::bDoubleAmbient) // Ra: wcześniej było ambient dawane na obydwa światła
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, Global::ambientDayLight);
|
||||
*/
|
||||
glEnable(GL_LIGHTING);
|
||||
WriteLog("FirstInit is done");
|
||||
};
|
||||
|
||||
@@ -1108,6 +1108,8 @@ public:
|
||||
/*funkcje ladujace pliki opisujace pojazd*/
|
||||
bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath);
|
||||
bool LoadFIZ_Doors( std::string const &line );
|
||||
void LoadFIZ_BuffCoupl( std::string const &line, int const Index );
|
||||
void LoadFIZ_Param( std::string const &line );
|
||||
bool readMPT0( std::string const &line );
|
||||
bool readMPT( std::string const &line ); //Q 20160717
|
||||
bool readMPTElectricSeries( std::string const &line );
|
||||
|
||||
@@ -39,6 +39,8 @@ inline double sqr(double val) // SQR() zle liczylo w current() ...
|
||||
|
||||
double ComputeCollision(double &v1, double &v2, double m1, double m2, double beta, bool vc)
|
||||
{ // oblicza zmiane predkosci i przyrost pedu wskutek kolizji
|
||||
assert( beta < 1.0 );
|
||||
|
||||
if( ( v1 < v2 ) && ( vc == true ) )
|
||||
return 0;
|
||||
else
|
||||
@@ -969,55 +971,56 @@ void TMoverParameters::CollisionDetect(int CouplerN, double dt)
|
||||
|
||||
CCF = 0;
|
||||
// with Couplers[CouplerN] do
|
||||
if (Couplers[CouplerN].Connected != NULL)
|
||||
auto &coupler = Couplers[ CouplerN ];
|
||||
|
||||
if (coupler.Connected != nullptr)
|
||||
{
|
||||
VirtualCoupling = (Couplers[CouplerN].CouplingFlag == ctrain_virtual);
|
||||
VirtualCoupling = (coupler.CouplingFlag == ctrain_virtual);
|
||||
Vprev = V;
|
||||
VprevC = Couplers[CouplerN].Connected->V;
|
||||
VprevC = coupler.Connected->V;
|
||||
switch (CouplerN)
|
||||
{
|
||||
case 0:
|
||||
CCF =
|
||||
ComputeCollision(
|
||||
V, Couplers[CouplerN].Connected->V, TotalMass,
|
||||
Couplers[CouplerN].Connected->TotalMass,
|
||||
(Couplers[CouplerN].beta +
|
||||
Couplers[CouplerN].Connected->Couplers[Couplers[CouplerN].ConnectedNr].beta) /
|
||||
2.0,
|
||||
VirtualCoupling) /
|
||||
(dt);
|
||||
V,
|
||||
coupler.Connected->V,
|
||||
TotalMass,
|
||||
coupler.Connected->TotalMass,
|
||||
(coupler.beta + coupler.Connected->Couplers[coupler.ConnectedNr].beta) / 2.0,
|
||||
VirtualCoupling)
|
||||
/ (dt);
|
||||
break; // yB: ej ej ej, a po
|
||||
case 1:
|
||||
CCF =
|
||||
ComputeCollision(
|
||||
Couplers[CouplerN].Connected->V, V, Couplers[CouplerN].Connected->TotalMass,
|
||||
coupler.Connected->V,
|
||||
V, coupler.Connected->TotalMass,
|
||||
TotalMass,
|
||||
(Couplers[CouplerN].beta +
|
||||
Couplers[CouplerN].Connected->Couplers[Couplers[CouplerN].ConnectedNr].beta) /
|
||||
2.0,
|
||||
VirtualCoupling) /
|
||||
(dt);
|
||||
(coupler.beta + coupler.Connected->Couplers[coupler.ConnectedNr].beta) / 2.0,
|
||||
VirtualCoupling)
|
||||
/ (dt);
|
||||
break; // czemu tu jest +0.01??
|
||||
}
|
||||
AccS = AccS + (V - Vprev) / dt; // korekta przyspieszenia o siły wynikające ze zderzeń?
|
||||
Couplers[CouplerN].Connected->AccS += (Couplers[CouplerN].Connected->V - VprevC) / dt;
|
||||
if ((Couplers[CouplerN].Dist > 0) && (!VirtualCoupling))
|
||||
if (FuzzyLogic(abs(CCF), 5.0 * (Couplers[CouplerN].FmaxC + 1.0), p_coupldmg))
|
||||
coupler.Connected->AccS += (coupler.Connected->V - VprevC) / dt;
|
||||
if ((coupler.Dist > 0) && (!VirtualCoupling))
|
||||
if (FuzzyLogic(abs(CCF), 5.0 * (coupler.FmaxC + 1.0), p_coupldmg))
|
||||
{ //! zerwanie sprzegu
|
||||
if (SetFlag(DamageFlag, dtrain_coupling))
|
||||
EventFlag = true;
|
||||
|
||||
if ((Couplers[CouplerN].CouplingFlag && ctrain_pneumatic > 0))
|
||||
if ((coupler.CouplingFlag & ctrain_pneumatic > 0))
|
||||
EmergencyBrakeFlag = true; // hamowanie nagle - zerwanie przewodow hamulcowych
|
||||
Couplers[CouplerN].CouplingFlag = 0;
|
||||
coupler.CouplingFlag = 0;
|
||||
|
||||
switch (CouplerN) // wyzerowanie flag podlaczenia ale ciagle sa wirtualnie polaczone
|
||||
{
|
||||
case 0:
|
||||
Couplers[CouplerN].Connected->Couplers[1].CouplingFlag = 0;
|
||||
coupler.Connected->Couplers[1].CouplingFlag = 0;
|
||||
break;
|
||||
case 1:
|
||||
Couplers[CouplerN].Connected->Couplers[0].CouplingFlag = 0;
|
||||
coupler.Connected->Couplers[0].CouplingFlag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1478,8 +1481,8 @@ int TMoverParameters::ShowCurrent(int AmpN)
|
||||
bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
|
||||
{
|
||||
// basic fail conditions:
|
||||
if( ( CabNo == 0 )
|
||||
|| ( MainCtrlPosNo <= 0 ) ) {
|
||||
if( ( MainCtrlPosNo <= 0 )
|
||||
|| ( CabNo == 0 ) ) {
|
||||
// nie ma sterowania
|
||||
return false;
|
||||
}
|
||||
@@ -1654,7 +1657,13 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
|
||||
bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
|
||||
{
|
||||
bool OK = false;
|
||||
if ((MainCtrlPosNo > 0) && (CabNo != 0))
|
||||
// basic fail conditions:
|
||||
if( ( MainCtrlPosNo <= 0 )
|
||||
|| ( CabNo == 0 ) ) {
|
||||
// nie ma sterowania
|
||||
OK = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MainCtrlPos > 0)
|
||||
{
|
||||
@@ -1739,8 +1748,6 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
|
||||
/*OK:=*/SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabNo);
|
||||
}
|
||||
}
|
||||
else
|
||||
OK = false;
|
||||
// if OK then LastRelayTime:=0;
|
||||
// hunter-101012: poprawka
|
||||
if (OK)
|
||||
@@ -3388,7 +3395,7 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer)
|
||||
}
|
||||
// else SlippingWheels:=false;
|
||||
// FStand:=0;
|
||||
for (b = 0; b < 2; b++)
|
||||
for (b = 0; b < 2; ++b)
|
||||
if (Couplers[b].Connected != NULL) /*and (Couplers[b].CouplerType<>Bare) and
|
||||
(Couplers[b].CouplerType<>Articulated)*/
|
||||
{ // doliczenie sił z innych pojazdów
|
||||
@@ -6232,28 +6239,8 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
{
|
||||
startBPT = false;
|
||||
secParam = true;
|
||||
SetFlag(OKFlag, param_ok);
|
||||
getkeyval( aCategory, "Category", xline, "none" );
|
||||
getkeyval( aType, "Type", xline, "none" ); aType = ToUpper( aType );
|
||||
getkeyval( aMass, "M", xline, "0" );
|
||||
getkeyval( aMred, "Mred", xline, "0" );
|
||||
getkeyval( aVmax, "Vmax", xline, "0" );
|
||||
getkeyval( aPWR, "PWR", xline, "0" );
|
||||
getkeyval( aSandCap, "SandCap", xline, "0" );
|
||||
getkeyval( aHeatingP, "HeatingP", xline, "0" );
|
||||
getkeyval( aLightP, "LightP", xline, "0" );
|
||||
// TODO: switch other sections to the new getkeyval() code
|
||||
/*
|
||||
aCategory = getkeyval(1, "Category");
|
||||
aType = ToUpper(getkeyval(1, "Type"));
|
||||
aMass = atof(getkeyval(3, "M").c_str());
|
||||
aMred = atof(getkeyval(3, "Mred").c_str());
|
||||
aVmax = atof(getkeyval(3, "Vmax").c_str());
|
||||
aPWR = atof(getkeyval(3, "PWR").c_str());
|
||||
aSandCap = atoi(getkeyval(2, "SandCap").c_str());
|
||||
aHeatingP = atof(getkeyval(3, "HeatingP").c_str());
|
||||
aLightP = atof(getkeyval(3, "LightP").c_str());
|
||||
*/
|
||||
SetFlag( OKFlag, param_ok );
|
||||
LoadFIZ_Param( xline );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -6272,6 +6259,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
|
||||
if( issection( "Doors:" ) ) {
|
||||
|
||||
startBPT = false;
|
||||
LoadFIZ_Doors( xline );
|
||||
continue;
|
||||
}
|
||||
@@ -6342,20 +6330,28 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("BuffCoupl.") || issection("BuffCoupl1."))
|
||||
{
|
||||
startBPT = false;
|
||||
secBuffCoupl = true;
|
||||
fCType = (getkeyval(1, "CType"));
|
||||
fkB = atof(getkeyval(3, "kB").c_str());
|
||||
fDmaxB = atof(getkeyval(3, "DmaxB").c_str());
|
||||
fFmaxB = atof(getkeyval(3, "FmaxB").c_str());
|
||||
fkC = atof(getkeyval(3, "kC").c_str());
|
||||
fDmaxC = atof(getkeyval(3, "DmaxC").c_str());
|
||||
fFmaxC = atof(getkeyval(3, "FmaxC").c_str());
|
||||
fbeta = atof(getkeyval(3, "beta").c_str());
|
||||
fAllowedFlag = atoi(getkeyval(2, "AllowedFlag").c_str());
|
||||
continue;
|
||||
if( issection( "BuffCoupl." ) ) {
|
||||
|
||||
startBPT = false;
|
||||
secBuffCoupl = true;
|
||||
LoadFIZ_BuffCoupl( xline, 0 );
|
||||
continue;
|
||||
}
|
||||
|
||||
else if( issection( "BuffCoupl1." ) ) {
|
||||
|
||||
startBPT = false;
|
||||
secBuffCoupl = true;
|
||||
LoadFIZ_BuffCoupl( xline, 1 );
|
||||
continue;
|
||||
}
|
||||
|
||||
else if( issection( "BuffCoupl2." ) ) {
|
||||
|
||||
startBPT = false;
|
||||
secBuffCoupl = true;
|
||||
LoadFIZ_BuffCoupl( xline, 2 );
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("Security:"))
|
||||
@@ -6631,57 +6627,6 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
// Operacje na zebranych parametrach - przypisywanie do wlasciwych zmiennych i ustawianie
|
||||
// zaleznosci
|
||||
|
||||
if (aCategory == "train")
|
||||
CategoryFlag = 1;
|
||||
else if (aCategory == "road")
|
||||
CategoryFlag = 2;
|
||||
else if (aCategory == "ship")
|
||||
CategoryFlag = 4;
|
||||
else if (aCategory == "airplane")
|
||||
CategoryFlag = 8;
|
||||
else if (aCategory == "unimog")
|
||||
CategoryFlag = 3;
|
||||
else
|
||||
ConversionError = MARKERROR(-7, "1", "Improper vechicle category");
|
||||
|
||||
Mass = aMass;
|
||||
Mred = aMred;
|
||||
Vmax = aVmax;
|
||||
Power = aPWR;
|
||||
HeatingPower = aHeatingP;
|
||||
LightPower = aLightP;
|
||||
SandCapacity = aSandCap;
|
||||
TrainType = dt_Default;
|
||||
if (aType == "PSEUDODIESEL")
|
||||
aType = "PDIS";
|
||||
|
||||
if (aType == "EZT")
|
||||
{
|
||||
TrainType = dt_EZT;
|
||||
IminLo = 1;
|
||||
IminHi = 2;
|
||||
Imin = 1;
|
||||
}
|
||||
else // wirtualne wartości dla rozrządczego
|
||||
if (aType == "ET41")
|
||||
TrainType = dt_ET41;
|
||||
else if (aType == "ET42")
|
||||
TrainType = dt_ET42;
|
||||
else if (aType == "ET22")
|
||||
TrainType = dt_ET22;
|
||||
else if (aType == "ET40")
|
||||
TrainType = dt_ET40;
|
||||
else if (aType == "EP05")
|
||||
TrainType = dt_EP05;
|
||||
else if (aType == "SN61")
|
||||
TrainType = dt_SN61;
|
||||
else if (aType == "PDIS")
|
||||
TrainType = dt_PseudoDiesel;
|
||||
else if (aType == "181")
|
||||
TrainType = dt_181;
|
||||
else if (aType == "182")
|
||||
TrainType = dt_181; // na razie tak
|
||||
|
||||
LoadAccepted = ToLower( bLoadAccepted );
|
||||
MaxLoad = bMaxLoad;
|
||||
LoadQuantity = bLoadQ;
|
||||
@@ -6875,68 +6820,6 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
// WriteLog("BrakeCylNo " + IntToStr(BrakeCylNo));
|
||||
}
|
||||
|
||||
// Couplers
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
if (fCType == "Automatic")
|
||||
Couplers[0].CouplerType = Automatic;
|
||||
else if (fCType == "Screw")
|
||||
Couplers[0].CouplerType = Screw;
|
||||
else if (fCType == "Chain")
|
||||
Couplers[0].CouplerType = Chain;
|
||||
else if (fCType == "Bare")
|
||||
Couplers[0].CouplerType = Bare;
|
||||
else if (fCType == "Articulated")
|
||||
Couplers[0].CouplerType = Articulated;
|
||||
else
|
||||
Couplers[0].CouplerType = NoCoupler;
|
||||
|
||||
if (fAllowedFlag > 0)
|
||||
Couplers[0].AllowedFlag = fAllowedFlag;
|
||||
if (Couplers[0].AllowedFlag < 0)
|
||||
Couplers[0].AllowedFlag = ((-Couplers[0].AllowedFlag) || ctrain_depot);
|
||||
if ((Couplers[0].CouplerType != NoCoupler) && (Couplers[0].CouplerType != Bare) &&
|
||||
(Couplers[0].CouplerType != Articulated))
|
||||
{
|
||||
|
||||
Couplers[0].SpringKC = fkC * 1000;
|
||||
Couplers[0].DmaxC = fDmaxC;
|
||||
Couplers[0].FmaxC = fFmaxC * 1000;
|
||||
Couplers[0].SpringKB = fkB * 1000;
|
||||
Couplers[0].DmaxB = fDmaxB;
|
||||
Couplers[0].FmaxB = fFmaxB * 1000;
|
||||
Couplers[0].beta = fbeta;
|
||||
}
|
||||
else if (Couplers[0].CouplerType == Bare)
|
||||
{
|
||||
Couplers[0].SpringKC = 50.0 * Mass + Ftmax / 0.05;
|
||||
Couplers[0].DmaxC = 0.05;
|
||||
Couplers[0].FmaxC = 100.0 * Mass + 2 * Ftmax;
|
||||
Couplers[0].SpringKB = 60.0 * Mass + Ftmax / 0.05;
|
||||
Couplers[0].DmaxB = 0.05;
|
||||
Couplers[0].FmaxB = 50.0 * Mass + 2.0 * Ftmax;
|
||||
Couplers[0].beta = 0.3;
|
||||
}
|
||||
else if (Couplers[0].CouplerType == Articulated)
|
||||
{
|
||||
Couplers[0].SpringKC = 60.0 * Mass + 1000;
|
||||
Couplers[0].DmaxC = 0.05;
|
||||
Couplers[0].FmaxC = 20000000.0 + 2.0 * Ftmax;
|
||||
Couplers[0].SpringKB = 70.0 * Mass + 1000;
|
||||
Couplers[0].DmaxB = 0.05;
|
||||
Couplers[0].FmaxB = 4000000.0 + 2.0 * Ftmax;
|
||||
Couplers[0].beta = 0.55;
|
||||
}
|
||||
Couplers[1].SpringKC = Couplers[0].SpringKC;
|
||||
Couplers[1].DmaxC = Couplers[0].DmaxC;
|
||||
Couplers[1].FmaxC = Couplers[0].FmaxC;
|
||||
Couplers[1].SpringKB = Couplers[0].SpringKB;
|
||||
Couplers[1].DmaxB = Couplers[0].DmaxB;
|
||||
Couplers[1].FmaxB = Couplers[0].FmaxB;
|
||||
Couplers[1].beta = Couplers[0].beta;
|
||||
Couplers[1].CouplerType = Couplers[0].CouplerType;
|
||||
Couplers[1].AllowedFlag = Couplers[0].AllowedFlag;
|
||||
|
||||
// Controllers
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
if (secCntrl)
|
||||
@@ -7334,6 +7217,145 @@ bool TMoverParameters::LoadFIZ_Doors( std::string const &line ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TMoverParameters::LoadFIZ_Param( std::string const &line ) {
|
||||
|
||||
getkeyval( Mass, "M", xline, "0" );
|
||||
getkeyval( Mred, "Mred", xline, "0" );
|
||||
getkeyval( Vmax, "Vmax", xline, "0" );
|
||||
getkeyval( Power, "PWR", xline, "0" );
|
||||
getkeyval( SandCapacity, "SandCap", xline, "0" );
|
||||
getkeyval( HeatingPower, "HeatingP", xline, "0" );
|
||||
getkeyval( LightPower, "LightP", xline, "0" );
|
||||
|
||||
{
|
||||
std::map<std::string, int> categories{
|
||||
{ "train", 1 },
|
||||
{ "road", 2 },
|
||||
{ "unimog", 3 },
|
||||
{ "ship", 4 },
|
||||
{ "airplane,", 8 }
|
||||
};
|
||||
std::string category; getkeyval( category, "Category", xline, "none" );
|
||||
auto lookup = categories.find( category );
|
||||
CategoryFlag = (
|
||||
lookup != categories.end() ?
|
||||
lookup->second :
|
||||
0 );
|
||||
if( CategoryFlag == 0 ) {
|
||||
ErrorLog( "Unknown vehicle category: \"" + category + "\"." );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, int> types{
|
||||
{ "pseudodiesel", dt_PseudoDiesel },
|
||||
{ "ezt", dt_EZT },
|
||||
{ "sn61", dt_SN61 },
|
||||
{ "et22", dt_ET22 },
|
||||
{ "et40", dt_ET40 },
|
||||
{ "et41", dt_ET41 },
|
||||
{ "et42", dt_ET42 },
|
||||
{ "ep05", dt_EP05 },
|
||||
{ "181", dt_181 },
|
||||
{ "182", dt_181 } // na razie tak
|
||||
};
|
||||
std::string type; getkeyval( type, "Type", xline, "none" );
|
||||
auto lookup = types.find( ToLower(type) );
|
||||
TrainType = (
|
||||
lookup != types.end() ?
|
||||
lookup->second :
|
||||
dt_Default );
|
||||
}
|
||||
|
||||
if( TrainType == dt_EZT ) {
|
||||
|
||||
IminLo = 1;
|
||||
IminHi = 2;
|
||||
Imin = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Index ) {
|
||||
|
||||
TCoupling *coupler;
|
||||
if( Index == 2 ) { coupler = &Couplers[ 1 ]; }
|
||||
else { coupler = &Couplers[ 0 ]; }
|
||||
|
||||
std::map<std::string, TCouplerType> couplertypes {
|
||||
{ "Automatic", Automatic },
|
||||
{ "Screw", Screw },
|
||||
{ "Chain", Chain },
|
||||
{ "Bare", Bare },
|
||||
{ "Articulated", Articulated },
|
||||
};
|
||||
std::string type; getkeyval( type, "CType", line, "" );
|
||||
auto lookup = couplertypes.find( type );
|
||||
coupler->CouplerType = (
|
||||
lookup != couplertypes.end() ?
|
||||
lookup->second :
|
||||
NoCoupler );
|
||||
|
||||
getkeyval( coupler->SpringKC, "kC", line, "" );
|
||||
getkeyval( coupler->DmaxC, "DmaxC", line, "" );
|
||||
getkeyval( coupler->FmaxC, "FmaxC", line, "" );
|
||||
getkeyval( coupler->SpringKB, "kB", line, "" );
|
||||
getkeyval( coupler->DmaxB, "DmaxB", line, "" );
|
||||
getkeyval( coupler->FmaxB, "FmaxB", line, "" );
|
||||
getkeyval( coupler->beta, "beta", line, "" );
|
||||
getkeyval( coupler->AllowedFlag, "AllowedFlag", line, "" );
|
||||
|
||||
if( coupler->AllowedFlag < 0 ) {
|
||||
|
||||
coupler->AllowedFlag = ( ( -coupler->AllowedFlag ) | ctrain_depot );
|
||||
}
|
||||
|
||||
if( ( coupler->CouplerType != NoCoupler )
|
||||
&& ( coupler->CouplerType != Bare )
|
||||
&& ( coupler->CouplerType != Articulated ) ) {
|
||||
|
||||
coupler->SpringKC *= 1000;
|
||||
coupler->FmaxC *= 1000;
|
||||
coupler->SpringKB *= 1000;
|
||||
coupler->FmaxB *= 1000;
|
||||
}
|
||||
else if( coupler->CouplerType == Bare ) {
|
||||
|
||||
coupler->SpringKC = 50.0 * Mass + Ftmax / 0.05;
|
||||
coupler->DmaxC = 0.05;
|
||||
coupler->FmaxC = 100.0 * Mass + 2 * Ftmax;
|
||||
coupler->SpringKB = 60.0 * Mass + Ftmax / 0.05;
|
||||
coupler->DmaxB = 0.05;
|
||||
coupler->FmaxB = 50.0 * Mass + 2.0 * Ftmax;
|
||||
coupler->beta = 0.3;
|
||||
}
|
||||
else if( coupler->CouplerType == Articulated ) {
|
||||
|
||||
coupler->SpringKC = 60.0 * Mass + 1000;
|
||||
coupler->DmaxC = 0.05;
|
||||
coupler->FmaxC = 20000000.0 + 2.0 * Ftmax;
|
||||
coupler->SpringKB = 70.0 * Mass + 1000;
|
||||
coupler->DmaxB = 0.05;
|
||||
coupler->FmaxB = 4000000.0 + 2.0 * Ftmax;
|
||||
coupler->beta = 0.55;
|
||||
}
|
||||
|
||||
if( Index == 0 ) {
|
||||
// 0 indicates single entry for both couplers
|
||||
Couplers[ 1 ] = Couplers[ 0 ];
|
||||
/*
|
||||
Couplers[ 1 ].SpringKC = coupler->SpringKC;
|
||||
Couplers[ 1 ].DmaxC = coupler->DmaxC;
|
||||
Couplers[ 1 ].FmaxC = coupler->FmaxC;
|
||||
Couplers[ 1 ].SpringKB = coupler->SpringKB;
|
||||
Couplers[ 1 ].DmaxB = coupler->DmaxB;
|
||||
Couplers[ 1 ].FmaxB = coupler->FmaxB;
|
||||
Couplers[ 1 ].beta = coupler->beta;
|
||||
Couplers[ 1 ].CouplerType = coupler->CouplerType;
|
||||
Couplers[ 1 ].AllowedFlag = coupler->AllowedFlag;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// *************************************************************************************************
|
||||
// Q: 20160717
|
||||
// *************************************************************************************************
|
||||
@@ -7798,12 +7820,18 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
|
||||
// OK:=Power>0.01;
|
||||
switch (static_cast<int>(CValue1 * CValue2))
|
||||
{ // CValue2 ma zmieniany znak przy niezgodności sprzęgów
|
||||
case 1:
|
||||
CabNo = 1;
|
||||
case -1:
|
||||
CabNo = -1;
|
||||
default:
|
||||
CabNo = 0; // gdy CValue1==0
|
||||
case 1: {
|
||||
CabNo = 1;
|
||||
break;
|
||||
}
|
||||
case -1: {
|
||||
CabNo = -1;
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
CabNo = 0; // gdy CValue1==0
|
||||
break;
|
||||
}
|
||||
}
|
||||
DirAbsolute = ActiveDir * CabNo;
|
||||
OK = SendCtrlToNext(Command, CValue1, CValue2);
|
||||
|
||||
@@ -2643,10 +2643,10 @@ void TTrain::UpdateMechPosition(double dt)
|
||||
pMechPosition += DynamicObject->GetPosition();
|
||||
};
|
||||
|
||||
bool TTrain::Update()
|
||||
bool TTrain::Update( double const Deltatime )
|
||||
{
|
||||
DWORD stat;
|
||||
double dt = Timer::GetDeltaTime();
|
||||
double dt = Deltatime; // Timer::GetDeltaTime();
|
||||
if (DynamicObject->mdKabina)
|
||||
{ // Ra: TODO: odczyty klawiatury/pulpitu nie
|
||||
// powinny być uzależnione od istnienia modelu
|
||||
|
||||
2
Train.h
2
Train.h
@@ -94,7 +94,7 @@ class TTrain
|
||||
return DynamicObject->VectorUp();
|
||||
};
|
||||
void UpdateMechPosition(double dt);
|
||||
bool Update();
|
||||
bool Update( double const Deltatime );
|
||||
void MechStop();
|
||||
void SetLights();
|
||||
// virtual bool RenderAlpha();
|
||||
|
||||
5
World.h
5
World.h
@@ -40,8 +40,11 @@ class TWorld
|
||||
std::string OutText2;
|
||||
std::string OutText3;
|
||||
std::string OutText4;
|
||||
void ShowHints();
|
||||
void Update_Lights();
|
||||
void Update_Camera( const double Deltatime );
|
||||
bool Render();
|
||||
void Render_Cab();
|
||||
void Render_UI();
|
||||
TCamera Camera;
|
||||
TGround Ground;
|
||||
TTrain *Train;
|
||||
|
||||
Reference in New Issue
Block a user