mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 09:59:18 +02:00
merge
This commit is contained in:
288
Train.cpp
288
Train.cpp
@@ -295,35 +295,58 @@ PyObject *TTrain::GetTrainState() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyDict_SetItemString( dict, "direction", PyGetInt( DynamicObject->MoverParameters->ActiveDir ) );
|
||||
PyDict_SetItemString( dict, "cab", PyGetInt( DynamicObject->MoverParameters->ActiveCab ) );
|
||||
PyDict_SetItemString( dict, "slipping_wheels",
|
||||
PyGetBool( DynamicObject->MoverParameters->SlippingWheels ) );
|
||||
PyDict_SetItemString( dict, "converter",
|
||||
PyGetBool( DynamicObject->MoverParameters->ConverterFlag ) );
|
||||
PyDict_SetItemString( dict, "main_ctrl_actual_pos",
|
||||
PyGetInt( DynamicObject->MoverParameters->MainCtrlActualPos ) );
|
||||
PyDict_SetItemString( dict, "scnd_ctrl_actual_pos",
|
||||
PyGetInt( DynamicObject->MoverParameters->ScndCtrlActualPos ) );
|
||||
PyDict_SetItemString( dict, "fuse", PyGetBool( DynamicObject->MoverParameters->FuseFlag ) );
|
||||
PyDict_SetItemString( dict, "converter_overload",
|
||||
PyGetBool( DynamicObject->MoverParameters->ConvOvldFlag ) );
|
||||
PyDict_SetItemString( dict, "voltage", PyGetFloat( DynamicObject->MoverParameters->Voltage ) );
|
||||
PyDict_SetItemString( dict, "velocity", PyGetFloat( DynamicObject->MoverParameters->Vel ) );
|
||||
PyDict_SetItemString( dict, "im", PyGetFloat( DynamicObject->MoverParameters->Im ) );
|
||||
PyDict_SetItemString( dict, "compress",
|
||||
PyGetBool( DynamicObject->MoverParameters->CompressorFlag ) );
|
||||
PyDict_SetItemString( dict, "hours", PyGetInt( GlobalTime->hh ) );
|
||||
PyDict_SetItemString( dict, "minutes", PyGetInt( GlobalTime->mm ) );
|
||||
PyDict_SetItemString( dict, "seconds", PyGetInt( GlobalTime->mr ) );
|
||||
PyDict_SetItemString( dict, "velocity_desired", PyGetFloat( DynamicObject->Mechanik->VelDesired ) );
|
||||
auto const &mover = DynamicObject->MoverParameters;
|
||||
|
||||
PyDict_SetItemString( dict, "cab", PyGetInt( mover->ActiveCab ) );
|
||||
// basic systems state data
|
||||
PyDict_SetItemString( dict, "battery", PyGetBool( mvControlled->Battery ) );
|
||||
PyDict_SetItemString( dict, "linebreaker", PyGetBool( mvControlled->Mains ) );
|
||||
PyDict_SetItemString( dict, "converter", PyGetBool( mover->ConverterFlag ) );
|
||||
PyDict_SetItemString( dict, "converter_overload", PyGetBool( mover->ConvOvldFlag ) );
|
||||
PyDict_SetItemString( dict, "compress", PyGetBool( mover->CompressorFlag ) );
|
||||
// reverser
|
||||
PyDict_SetItemString( dict, "direction", PyGetInt( mover->ActiveDir ) );
|
||||
// throttle
|
||||
PyDict_SetItemString( dict, "mainctrl_pos", PyGetInt( mover->MainCtrlPos ) );
|
||||
PyDict_SetItemString( dict, "main_ctrl_actual_pos", PyGetInt( mover->MainCtrlActualPos ) );
|
||||
PyDict_SetItemString( dict, "scndctrl_pos", PyGetInt( mover->ScndCtrlPos ) );
|
||||
PyDict_SetItemString( dict, "scnd_ctrl_actual_pos", PyGetInt( mover->ScndCtrlActualPos ) );
|
||||
// brakes
|
||||
PyDict_SetItemString( dict, "manual_brake", PyGetBool( mvOccupied->ManualBrakePos > 0 ) );
|
||||
bool const bEP = ( mvControlled->LocHandle->GetCP()>0.2 ) || ( fEIMParams[ 0 ][ 2 ]>0.01 );
|
||||
PyDict_SetItemString( dict, "dir_brake", PyGetBool( bEP ) );
|
||||
bool bPN;
|
||||
if( ( typeid( *mvControlled->Hamulec ) == typeid( TLSt ) )
|
||||
|| ( typeid( *mvControlled->Hamulec ) == typeid( TEStED ) ) ) {
|
||||
|
||||
TBrake* temp_ham = mvControlled->Hamulec.get();
|
||||
bPN = ( static_cast<TLSt*>( temp_ham )->GetEDBCP()>0.2 );
|
||||
}
|
||||
else
|
||||
bPN = false;
|
||||
PyDict_SetItemString( dict, "indir_brake", PyGetBool( bPN ) );
|
||||
// other controls
|
||||
PyDict_SetItemString( dict, "ca", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_aware ) ) );
|
||||
PyDict_SetItemString( dict, "shp", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) ) );
|
||||
PyDict_SetItemString( dict, "pantpress", PyGetFloat( mvControlled->PantPress ) );
|
||||
PyDict_SetItemString( dict, "universal3", PyGetBool( LampkaUniversal3_st ) );
|
||||
// movement data
|
||||
PyDict_SetItemString( dict, "velocity", PyGetFloat( mover->Vel ) );
|
||||
PyDict_SetItemString( dict, "tractionforce", PyGetFloat( mover->Ft ) );
|
||||
PyDict_SetItemString( dict, "slipping_wheels", PyGetBool( mover->SlippingWheels ) );
|
||||
// electric current data
|
||||
PyDict_SetItemString( dict, "traction_voltage", PyGetFloat( mover->RunningTraction.TractionVoltage ) );
|
||||
PyDict_SetItemString( dict, "voltage", PyGetFloat( mover->Voltage ) );
|
||||
PyDict_SetItemString( dict, "im", PyGetFloat( mover->Im ) );
|
||||
PyDict_SetItemString( dict, "fuse", PyGetBool( mover->FuseFlag ) );
|
||||
// induction motor state data
|
||||
char* TXTT[ 10 ] = { "fd", "fdt", "fdb", "pd", "pdt", "pdb", "itothv", "1", "2", "3" };
|
||||
char* TXTC[ 10 ] = { "fr", "frt", "frb", "pr", "prt", "prb", "im", "vm", "ihv", "uhv" };
|
||||
char* TXTP[ 3 ] = { "bc", "bp", "sp" };
|
||||
for( int j = 0; j<10; j++ )
|
||||
for( int j = 0; j < 10; ++j )
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_t_" ) + std::string( TXTT[ j ] ) ).c_str(), PyGetFloatS( fEIMParams[ 0 ][ j ] ) );
|
||||
for( int i = 0; i<8; i++ ) {
|
||||
for( int j = 0; j<10; j++ )
|
||||
for( int i = 0; i < 8; ++i ) {
|
||||
for( int j = 0; j < 10; ++j )
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_" ) + std::string( TXTC[ j ] ) ).c_str(), PyGetFloatS( fEIMParams[ i + 1 ][ j ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_ms" ) ).c_str(), PyGetBool( bMains[ i ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_cv" ) ).c_str(), PyGetFloatS( fCntVol[ i ] ) );
|
||||
@@ -337,25 +360,17 @@ PyObject *TTrain::GetTrainState() {
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_c" ) + std::to_string( i + 1 ) + std::string( "_heat" ) ).c_str(), PyGetBool( bHeat[ i ] ) );
|
||||
|
||||
}
|
||||
for( int i = 0; i<20; i++ ) {
|
||||
for( int j = 0; j<3; j++ )
|
||||
for( int i = 0; i < 20; ++i ) {
|
||||
for( int j = 0; j < 3; ++j )
|
||||
PyDict_SetItemString( dict, ( std::string( "eimp_pn" ) + std::to_string( i + 1 ) + std::string( "_" ) + std::string( TXTP[ j ] ) ).c_str(),
|
||||
PyGetFloatS( fPress[ i ][ j ] ) );
|
||||
}
|
||||
bool bEP, bPN;
|
||||
bEP = ( mvControlled->LocHandle->GetCP()>0.2 ) || ( fEIMParams[ 0 ][ 2 ]>0.01 );
|
||||
PyDict_SetItemString( dict, "dir_brake", PyGetBool( bEP ) );
|
||||
if( ( typeid( *mvControlled->Hamulec ) == typeid( TLSt ) )
|
||||
|| ( typeid( *mvControlled->Hamulec ) == typeid( TEStED ) ) ) {
|
||||
// multi-unit state data
|
||||
PyDict_SetItemString( dict, "car_no", PyGetInt( iCarNo ) );
|
||||
PyDict_SetItemString( dict, "power_no", PyGetInt( iPowerNo ) );
|
||||
PyDict_SetItemString( dict, "unit_no", PyGetInt( iUnitNo ) );
|
||||
|
||||
TBrake* temp_ham = mvControlled->Hamulec.get();
|
||||
// TLSt* temp_ham2 = temp_ham;
|
||||
bPN = ( static_cast<TLSt*>( temp_ham )->GetEDBCP()>0.2 );
|
||||
}
|
||||
else
|
||||
bPN = false;
|
||||
PyDict_SetItemString( dict, "indir_brake", PyGetBool( bPN ) );
|
||||
for( int i = 0; i<20; i++ ) {
|
||||
for( int i = 0; i < 20; i++ ) {
|
||||
PyDict_SetItemString( dict, ( std::string( "doors_" ) + std::to_string( i + 1 ) ).c_str(), PyGetFloatS( bDoors[ i ][ 0 ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "doors_r_" ) + std::to_string( i + 1 ) ).c_str(), PyGetFloatS( bDoors[ i ][ 1 ] ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "doors_l_" ) + std::to_string( i + 1 ) ).c_str(), PyGetFloatS( bDoors[ i ][ 2 ] ) );
|
||||
@@ -364,23 +379,21 @@ PyObject *TTrain::GetTrainState() {
|
||||
cCode[ i ] ).c_str() ) );
|
||||
PyDict_SetItemString( dict, ( std::string( "car_name" ) + std::to_string( i + 1 ) ).c_str(), PyGetString( asCarName[ i ].c_str() ) );
|
||||
}
|
||||
PyDict_SetItemString( dict, "car_no", PyGetInt( iCarNo ) );
|
||||
PyDict_SetItemString( dict, "power_no", PyGetInt( iPowerNo ) );
|
||||
PyDict_SetItemString( dict, "unit_no", PyGetInt( iUnitNo ) );
|
||||
PyDict_SetItemString( dict, "universal3", PyGetBool( LampkaUniversal3_st ) );
|
||||
PyDict_SetItemString( dict, "ca", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_aware ) ) );
|
||||
PyDict_SetItemString( dict, "shp", PyGetBool( TestFlag( mvOccupied->SecuritySystem.Status, s_active ) ) );
|
||||
PyDict_SetItemString( dict, "manual_brake", PyGetBool( mvOccupied->ManualBrakePos > 0 ) );
|
||||
PyDict_SetItemString( dict, "pantpress", PyGetFloat( mvControlled->PantPress ) );
|
||||
PyDict_SetItemString( dict, "trainnumber", PyGetString( DynamicObject->Mechanik->TrainName().c_str() ) );
|
||||
PyDict_SetItemString( dict, "velnext", PyGetFloat( DynamicObject->Mechanik->VelNext ) );
|
||||
PyDict_SetItemString( dict, "actualproximitydist", PyGetFloat( DynamicObject->Mechanik->ActualProximityDist ) );
|
||||
PyDict_SetItemString( dict, "velsignallast", PyGetFloat( DynamicObject->Mechanik->VelSignalLast ) );
|
||||
PyDict_SetItemString( dict, "vellimitlast", PyGetFloat( DynamicObject->Mechanik->VelLimitLast ) );
|
||||
PyDict_SetItemString( dict, "velroad", PyGetFloat( DynamicObject->Mechanik->VelRoad ) );
|
||||
PyDict_SetItemString( dict, "velsignalnext", PyGetFloat( DynamicObject->Mechanik->VelSignalNext ) );
|
||||
PyDict_SetItemString( dict, "battery", PyGetBool( mvControlled->Battery ) );
|
||||
PyDict_SetItemString( dict, "tractionforce", PyGetFloat( DynamicObject->MoverParameters->Ft ) );
|
||||
// ai state data
|
||||
auto const &driver = DynamicObject->Mechanik;
|
||||
|
||||
PyDict_SetItemString( dict, "velocity_desired", PyGetFloat( driver->VelDesired ) );
|
||||
PyDict_SetItemString( dict, "velroad", PyGetFloat( driver->VelRoad ) );
|
||||
PyDict_SetItemString( dict, "vellimitlast", PyGetFloat( driver->VelLimitLast ) );
|
||||
PyDict_SetItemString( dict, "velsignallast", PyGetFloat( driver->VelSignalLast ) );
|
||||
PyDict_SetItemString( dict, "velsignalnext", PyGetFloat( driver->VelSignalNext ) );
|
||||
PyDict_SetItemString( dict, "velnext", PyGetFloat( driver->VelNext ) );
|
||||
PyDict_SetItemString( dict, "actualproximitydist", PyGetFloat( driver->ActualProximityDist ) );
|
||||
PyDict_SetItemString( dict, "trainnumber", PyGetString( driver->TrainName().c_str() ) );
|
||||
// world state data
|
||||
PyDict_SetItemString( dict, "hours", PyGetInt( GlobalTime->hh ) );
|
||||
PyDict_SetItemString( dict, "minutes", PyGetInt( GlobalTime->mm ) );
|
||||
PyDict_SetItemString( dict, "seconds", PyGetInt( GlobalTime->mr ) );
|
||||
|
||||
return dict;
|
||||
}
|
||||
@@ -508,7 +521,7 @@ void TTrain::OnKeyDown(int cKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cKey == Global::Keys[k_StLinOff])
|
||||
else if ((cKey == Global::Keys[k_StLinOff]) && (!Global::shiftState) && (!Global::ctrlState)) // shift&ctrl are used for light dimming
|
||||
{
|
||||
if (mvControlled->TrainType == dt_EZT)
|
||||
{
|
||||
@@ -1792,21 +1805,18 @@ if
|
||||
{ // tryb freefly
|
||||
int CouplNr = -1; // normalnie żaden ze sprzęgów
|
||||
TDynamicObject *tmp;
|
||||
tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500,
|
||||
CouplNr);
|
||||
if (tmp == NULL)
|
||||
tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1,
|
||||
1500, CouplNr);
|
||||
if (tmp && (CouplNr != -1))
|
||||
tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500, CouplNr);
|
||||
if (tmp == nullptr)
|
||||
tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1, 1500, CouplNr);
|
||||
if( ( CouplNr != -1 )
|
||||
&& ( tmp != nullptr )
|
||||
&& ( tmp->MoverParameters->Couplers[ CouplNr ].Connected != nullptr ) )
|
||||
{
|
||||
if (tmp->MoverParameters->Couplers[CouplNr].CouplingFlag ==
|
||||
0) // najpierw hak
|
||||
if (tmp->MoverParameters->Couplers[CouplNr].CouplingFlag == 0) // najpierw hak
|
||||
{
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr]
|
||||
.Connected->Couplers[CouplNr]
|
||||
.AllowedFlag &
|
||||
tmp->MoverParameters->Couplers[CouplNr].AllowedFlag &
|
||||
ctrain_coupler) == ctrain_coupler)
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr].Connected->Couplers[CouplNr].AllowedFlag
|
||||
& tmp->MoverParameters->Couplers[CouplNr].AllowedFlag
|
||||
& ctrain_coupler) == ctrain_coupler)
|
||||
if (tmp->MoverParameters->Attach(
|
||||
CouplNr, 2,
|
||||
tmp->MoverParameters->Couplers[CouplNr].Connected,
|
||||
@@ -1815,46 +1825,37 @@ if
|
||||
// tmp->MoverParameters->Couplers[CouplNr].Render=true;
|
||||
// //podłączony sprzęg będzie widoczny
|
||||
if (DynamicObject->Mechanik) // na wszelki wypadek
|
||||
DynamicObject->Mechanik->CheckVehicles(
|
||||
Connect); // aktualizacja flag kierunku w składzie
|
||||
DynamicObject->Mechanik->CheckVehicles(Connect); // aktualizacja flag kierunku w składzie
|
||||
dsbCouplerAttach->SetVolume(DSBVOLUME_MAX);
|
||||
dsbCouplerAttach->Play(0, 0, 0);
|
||||
}
|
||||
else
|
||||
WriteLog("Mechanical coupling failed.");
|
||||
}
|
||||
else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag,
|
||||
ctrain_pneumatic)) // pneumatyka
|
||||
else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag, ctrain_pneumatic)) // pneumatyka
|
||||
{
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr]
|
||||
.Connected->Couplers[CouplNr]
|
||||
.AllowedFlag &
|
||||
tmp->MoverParameters->Couplers[CouplNr].AllowedFlag &
|
||||
ctrain_pneumatic) == ctrain_pneumatic)
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr].Connected->Couplers[CouplNr].AllowedFlag
|
||||
& tmp->MoverParameters->Couplers[CouplNr].AllowedFlag
|
||||
& ctrain_pneumatic) == ctrain_pneumatic)
|
||||
if (tmp->MoverParameters->Attach(
|
||||
CouplNr, 2,
|
||||
tmp->MoverParameters->Couplers[CouplNr].Connected,
|
||||
tmp->MoverParameters->Couplers[CouplNr].CouplingFlag +
|
||||
ctrain_pneumatic))
|
||||
(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag | ctrain_pneumatic)))
|
||||
{
|
||||
rsHiss.Play(1, DSBPLAY_LOOPING, true, tmp->GetPosition());
|
||||
DynamicObject->SetPneumatic(CouplNr != 0, true); // Ra: to mi się nie podoba !!!!
|
||||
tmp->SetPneumatic(CouplNr != 0, true);
|
||||
}
|
||||
}
|
||||
else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag,
|
||||
ctrain_scndpneumatic)) // zasilajacy
|
||||
else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag, ctrain_scndpneumatic)) // zasilajacy
|
||||
{
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr]
|
||||
.Connected->Couplers[CouplNr]
|
||||
.AllowedFlag &
|
||||
tmp->MoverParameters->Couplers[CouplNr].AllowedFlag &
|
||||
ctrain_scndpneumatic) == ctrain_scndpneumatic)
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr].Connected->Couplers[CouplNr].AllowedFlag
|
||||
& tmp->MoverParameters->Couplers[CouplNr].AllowedFlag
|
||||
& ctrain_scndpneumatic) == ctrain_scndpneumatic)
|
||||
if (tmp->MoverParameters->Attach(
|
||||
CouplNr, 2,
|
||||
tmp->MoverParameters->Couplers[CouplNr].Connected,
|
||||
tmp->MoverParameters->Couplers[CouplNr].CouplingFlag +
|
||||
ctrain_scndpneumatic))
|
||||
(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag | ctrain_scndpneumatic)))
|
||||
{
|
||||
// rsHiss.Play(1,DSBPLAY_LOOPING,true,tmp->GetPosition());
|
||||
dsbCouplerDetach->SetVolume(DSBVOLUME_MAX);
|
||||
@@ -1863,8 +1864,7 @@ if
|
||||
tmp->SetPneumatic(CouplNr != 0, false);
|
||||
}
|
||||
}
|
||||
else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag,
|
||||
ctrain_controll)) // ukrotnionko
|
||||
else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag, ctrain_controll)) // ukrotnionko
|
||||
{
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr]
|
||||
.Connected->Couplers[CouplNr]
|
||||
@@ -1874,15 +1874,13 @@ if
|
||||
if (tmp->MoverParameters->Attach(
|
||||
CouplNr, 2,
|
||||
tmp->MoverParameters->Couplers[CouplNr].Connected,
|
||||
tmp->MoverParameters->Couplers[CouplNr].CouplingFlag +
|
||||
ctrain_controll))
|
||||
(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag | ctrain_controll)))
|
||||
{
|
||||
dsbCouplerAttach->SetVolume(DSBVOLUME_MAX);
|
||||
dsbCouplerAttach->Play(0, 0, 0);
|
||||
}
|
||||
}
|
||||
else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag,
|
||||
ctrain_passenger)) // mostek
|
||||
else if (!TestFlag(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag, ctrain_passenger)) // mostek
|
||||
{
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr]
|
||||
.Connected->Couplers[CouplNr]
|
||||
@@ -1892,8 +1890,7 @@ if
|
||||
if (tmp->MoverParameters->Attach(
|
||||
CouplNr, 2,
|
||||
tmp->MoverParameters->Couplers[CouplNr].Connected,
|
||||
tmp->MoverParameters->Couplers[CouplNr].CouplingFlag +
|
||||
ctrain_passenger))
|
||||
(tmp->MoverParameters->Couplers[CouplNr].CouplingFlag | ctrain_passenger)))
|
||||
{
|
||||
// rsHiss.Play(1,DSBPLAY_LOOPING,true,tmp->GetPosition());
|
||||
dsbCouplerDetach->SetVolume(DSBVOLUME_MAX);
|
||||
@@ -1912,8 +1909,7 @@ if
|
||||
// odlegle wagony
|
||||
if (iCabn > 0)
|
||||
{
|
||||
if (!FreeFlyModeFlag) // tryb 'kabinowy' (pozwala również rozłączyć
|
||||
// sprzęgi zablokowane)
|
||||
if (!FreeFlyModeFlag) // tryb 'kabinowy' (pozwala również rozłączyć sprzęgi zablokowane)
|
||||
{
|
||||
if (DynamicObject->DettachStatus(iCabn - 1) < 0) // jeśli jest co odczepić
|
||||
if (DynamicObject->Dettach(iCabn - 1)) // iCab==1:przód,iCab==2:tył
|
||||
@@ -1926,15 +1922,12 @@ if
|
||||
{ // tryb freefly
|
||||
int CouplNr = -1;
|
||||
TDynamicObject *tmp;
|
||||
tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500,
|
||||
CouplNr);
|
||||
tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), 1, 1500, CouplNr);
|
||||
if (tmp == NULL)
|
||||
tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1,
|
||||
1500, CouplNr);
|
||||
tmp = DynamicObject->ABuScanNearestObject(DynamicObject->GetTrack(), -1, 1500, CouplNr);
|
||||
if (tmp && (CouplNr != -1))
|
||||
{
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr].CouplingFlag & ctrain_depot) ==
|
||||
0) // jeżeli sprzęg niezablokowany
|
||||
if ((tmp->MoverParameters->Couplers[CouplNr].CouplingFlag & ctrain_depot) == 0) // jeżeli sprzęg niezablokowany
|
||||
if (tmp->DettachStatus(CouplNr) < 0) // jeśli jest co odczepić i się da
|
||||
if (!tmp->Dettach(CouplNr))
|
||||
{ // dźwięk odczepiania
|
||||
@@ -2352,7 +2345,7 @@ if
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cKey == Global::Keys[k_StLinOff]) // Winger 110904: wylacznik st.
|
||||
else if ((cKey == Global::Keys[k_StLinOff]) && (!Global::shiftState) && (!Global::ctrlState)) // Winger 110904: wylacznik st.
|
||||
// liniowych
|
||||
{
|
||||
if ((mvControlled->TrainType != dt_EZT) && (mvControlled->TrainType != dt_EP05) &&
|
||||
@@ -2481,6 +2474,29 @@ if
|
||||
++iRadioChannel; // 0=wyłączony
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: break the mess above into individual command-based routines.
|
||||
// TODO: test for modifiers inside the routines, instead of grouping by the modifier
|
||||
// TODO: do away with the modifier tests, each command should be separate and issued by input processor(s) up the chain
|
||||
if( cKey == Global::Keys[ k_DimHeadlights ] ) {
|
||||
// headlight strength toggle
|
||||
if( !Global::ctrlState ) {
|
||||
// switch uses either ctrl, or ctrl+shift, so we can bail early here
|
||||
return;
|
||||
}
|
||||
if( DynamicObject->DimHeadlights && (!Global::shiftState)) {
|
||||
DynamicObject->DimHeadlights = false;
|
||||
// switch sound
|
||||
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||
dsbSwitch->Play( 0, 0, 0 );
|
||||
}
|
||||
else if( (!DynamicObject->DimHeadlights) && (Global::shiftState)) {
|
||||
DynamicObject->DimHeadlights = true;
|
||||
// switch sound
|
||||
dsbSwitch->SetVolume( DSBVOLUME_MAX );
|
||||
dsbSwitch->Play( 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnKeyUp(int cKey)
|
||||
@@ -2490,7 +2506,7 @@ void TTrain::OnKeyUp(int cKey)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cKey == Global::Keys[k_StLinOff]) // Winger 110904: wylacznik st. liniowych
|
||||
if ((cKey == Global::Keys[k_StLinOff]) && (!Global::shiftState) && (!Global::ctrlState)) // Winger 110904: wylacznik st. liniowych
|
||||
{ // zwolnienie klawisza daje powrót przycisku do zwykłego stanu
|
||||
if ((mvControlled->TrainType != dt_EZT) && (mvControlled->TrainType != dt_EP05) &&
|
||||
(mvControlled->TrainType != dt_ET40))
|
||||
@@ -2686,10 +2702,9 @@ bool TTrain::Update( double const Deltatime )
|
||||
iSekunda=floor(GlobalTime->mr);
|
||||
}
|
||||
*/
|
||||
// Ra 2014-09: napięcia i prądy muszą być ustalone najpierw, bo wysyłane są
|
||||
// ewentualnie na
|
||||
// PoKeys
|
||||
if ((mvControlled->EngineType != DieselElectric) && (mvControlled->EngineType != ElectricInductionMotor)) // Ra 2014-09: czy taki rozdzia? ma sens?
|
||||
// Ra 2014-09: napięcia i prądy muszą być ustalone najpierw, bo wysyłane są ewentualnie na PoKeys
|
||||
if ((mvControlled->EngineType != DieselElectric)
|
||||
&& (mvControlled->EngineType != ElectricInductionMotor)) // Ra 2014-09: czy taki rozdzia? ma sens?
|
||||
fHVoltage = mvControlled->RunningTraction.TractionVoltage; // Winger czy to nie jest zle?
|
||||
// *mvControlled->Mains);
|
||||
else
|
||||
@@ -3901,41 +3916,6 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggLeftEndLightButton.PutValue(0);
|
||||
}
|
||||
|
||||
//---------
|
||||
// hunter-101211: poprawka na zle obracajace sie przelaczniki
|
||||
/*
|
||||
if (((DynamicObject->iLights[0]&1)==1)
|
||||
||((DynamicObject->iLights[1]&1)==1))
|
||||
ggLeftLightButton.PutValue(1);
|
||||
if (((DynamicObject->iLights[0]&16)==16)
|
||||
||((DynamicObject->iLights[1]&16)==16))
|
||||
ggRightLightButton.PutValue(1);
|
||||
if (((DynamicObject->iLights[0]&4)==4)
|
||||
||((DynamicObject->iLights[1]&4)==4))
|
||||
ggUpperLightButton.PutValue(1);
|
||||
|
||||
if (((DynamicObject->iLights[0]&2)==2)
|
||||
||((DynamicObject->iLights[1]&2)==2))
|
||||
if (ggLeftEndLightButton.SubModel)
|
||||
{
|
||||
ggLeftEndLightButton.PutValue(1);
|
||||
ggLeftLightButton.PutValue(0);
|
||||
}
|
||||
else
|
||||
ggLeftLightButton.PutValue(-1);
|
||||
|
||||
if (((DynamicObject->iLights[0]&32)==32)
|
||||
||((DynamicObject->iLights[1]&32)==32))
|
||||
if (ggRightEndLightButton.SubModel)
|
||||
{
|
||||
ggRightEndLightButton.PutValue(1);
|
||||
ggRightLightButton.PutValue(0);
|
||||
}
|
||||
else
|
||||
ggRightLightButton.PutValue(-1);
|
||||
*/
|
||||
|
||||
//--------------
|
||||
// hunter-230112
|
||||
|
||||
// REFLEKTOR LEWY
|
||||
@@ -4073,6 +4053,11 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggLightsButton.PutValue(mvOccupied->LightsPos - 1);
|
||||
ggLightsButton.Update();
|
||||
}
|
||||
if( ggDimHeadlightsButton.SubModel ) {
|
||||
|
||||
ggDimHeadlightsButton.PutValue( DynamicObject->DimHeadlights ? 1.0 : 0.0 );
|
||||
ggDimHeadlightsButton.Update();
|
||||
}
|
||||
|
||||
//---------
|
||||
// Winger 010304 - pantografy
|
||||
@@ -5879,6 +5864,7 @@ void TTrain::clear_cab_controls()
|
||||
ggLeftLightButton.Clear();
|
||||
ggRightLightButton.Clear();
|
||||
ggUpperLightButton.Clear();
|
||||
ggDimHeadlightsButton.Clear();
|
||||
ggLeftEndLightButton.Clear();
|
||||
ggRightEndLightButton.Clear();
|
||||
ggLightsButton.Clear();
|
||||
@@ -6283,7 +6269,11 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
// swiatlo
|
||||
ggRightLightButton.Load(Parser, DynamicObject->mdKabina);
|
||||
}
|
||||
else if (Label == "leftend_sw:")
|
||||
else if( Label == "dimheadlights_sw:" ) {
|
||||
// swiatlo
|
||||
ggDimHeadlightsButton.Load( Parser, DynamicObject->mdKabina );
|
||||
}
|
||||
else if( Label == "leftend_sw:" )
|
||||
{
|
||||
// swiatlo
|
||||
ggLeftEndLightButton.Load(Parser, DynamicObject->mdKabina);
|
||||
|
||||
Reference in New Issue
Block a user