mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Automatic neutral direction when deactivating cab
This commit is contained in:
@@ -276,6 +276,7 @@ enum activation {
|
||||
doorpermition = 1 << 4,
|
||||
springbrakeon = 1 << 5,
|
||||
springbrakeoff = 1 << 6,
|
||||
neutraldirection = 1 << 7,
|
||||
};
|
||||
|
||||
//szczególne typy pojazdów (inna obsługa) dla zmiennej TrainType
|
||||
@@ -1524,6 +1525,7 @@ public:
|
||||
int CabActive = 0; //numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad
|
||||
int CabOccupied = 0; //numer kabiny, w ktorej jest obsada (zwykle jedna na skład) // TODO: move to TController
|
||||
bool CabMaster = false; //czy pojazd jest nadrzędny w składzie
|
||||
inline bool IsCabMaster() { return ((CabActive == CabOccupied) && CabMaster); } //czy aktualna kabina jest na pewno tą, z której można sterować
|
||||
bool AutomaticCabActivation = true; //czy zmostkowany rozrzad przelacza sie sam przy zmianie kabiny
|
||||
int InactiveCabFlag = 0; //co sie dzieje przy dezaktywacji kabiny
|
||||
bool InactiveCabPantsCheck = false; //niech DynamicObject sprawdzi pantografy
|
||||
|
||||
@@ -554,7 +554,9 @@ bool TMoverParameters::DirectionForward()
|
||||
{
|
||||
if( false == EIMDirectionChangeAllow() ) { return false; }
|
||||
|
||||
if ((MainCtrlPosNo > 0) && (DirActive < 1))
|
||||
if ((MainCtrlPosNo > 0)
|
||||
&& (DirActive < 1)
|
||||
&& ( (CabActive != 0) || ( (InactiveCabFlag & activation::neutraldirection) == 0) ) )
|
||||
{
|
||||
++DirActive;
|
||||
DirAbsolute = DirActive * CabActive;
|
||||
@@ -2689,6 +2691,7 @@ bool TMoverParameters::CabActivisation( bool const Enforce )
|
||||
CabMaster = true;
|
||||
SecuritySystem.Status |= s_waiting; // activate the alerter TODO: make it part of control based cab selection
|
||||
SendCtrlToNext("CabActivisation", 1, CabActive);
|
||||
SendCtrlToNext("Direction", DirAbsolute, CabActive);
|
||||
if (InactiveCabFlag & activation::springbrakeoff)
|
||||
{
|
||||
SpringBrakeActivate(false);
|
||||
@@ -2711,7 +2714,7 @@ bool TMoverParameters::CabDeactivisation( bool const Enforce )
|
||||
{
|
||||
bool OK = false;
|
||||
|
||||
OK = Enforce || ((CabActive == CabOccupied) && CabMaster); // o ile obsada jest w kabinie ze sterowaniem
|
||||
OK = Enforce || IsCabMaster(); // o ile obsada jest w kabinie ze sterowaniem
|
||||
if (OK)
|
||||
{
|
||||
if (InactiveCabFlag & activation::springbrakeon)
|
||||
@@ -2727,6 +2730,11 @@ bool TMoverParameters::CabDeactivisation( bool const Enforce )
|
||||
PermitDoors(side::right, true, range_t::consist);
|
||||
PermitDoors(side::left, true, range_t::consist);
|
||||
}
|
||||
if (InactiveCabFlag & activation::neutraldirection)
|
||||
{
|
||||
DirActive = 0;
|
||||
SendCtrlToNext("Direction", 0, CabActive);
|
||||
}
|
||||
|
||||
CabActive = 0;
|
||||
DirAbsolute = DirActive * CabActive;
|
||||
@@ -3160,7 +3168,9 @@ bool TMoverParameters::DirectionBackward(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ((MainCtrlPosNo > 0) && (DirActive > -1))
|
||||
if ((MainCtrlPosNo > 0)
|
||||
&& (DirActive > -1)
|
||||
&& ( (CabActive != 0) || ( (InactiveCabFlag & activation::neutraldirection) == 0) ) )
|
||||
{
|
||||
if (EngineType == TEngineType::WheelsDriven)
|
||||
--CabActive;
|
||||
@@ -7277,7 +7287,8 @@ void TMoverParameters::CheckEIMIC(double dt)
|
||||
auto const eimicpowerenabled {
|
||||
( ( true == Mains ) || ( Power == 0.0 ) )
|
||||
&& ( !SpringBrake.IsActive || !SpringBrakeCutsOffDrive )
|
||||
&& ( !LockPipe ) };
|
||||
&& ( !LockPipe )
|
||||
&& ( DirAbsolute != 0 ) };
|
||||
auto const eimicdoorenabled {
|
||||
(SpringBrake.IsActive && ReleaseParkingBySpringBrakeWhenDoorIsOpen)
|
||||
};
|
||||
|
||||
@@ -7705,7 +7705,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggBatteryOffButton.Update();
|
||||
if ((ggCabActivationButton.SubModel != nullptr) && (ggCabActivationButton.type() != TGaugeType::push))
|
||||
{
|
||||
ggCabActivationButton.UpdateValue((mvOccupied->CabMaster) && (mvOccupied->CabOccupied == mvOccupied->CabActive) ? 1.0 : 0.0);
|
||||
ggCabActivationButton.UpdateValue(mvOccupied->IsCabMaster() ? 1.0 : 0.0);
|
||||
}
|
||||
ggCabActivationButton.Update();
|
||||
|
||||
@@ -9174,10 +9174,10 @@ void TTrain::set_cab_controls( int const Cab ) {
|
||||
( ggBatteryButton.type() == TGaugeType::push ? 0.5f :
|
||||
mvOccupied->Power24vIsAvailable ? 1.f :
|
||||
0.f ) );
|
||||
// battery
|
||||
// activation
|
||||
ggCabActivationButton.PutValue(
|
||||
(ggCabActivationButton.type() == TGaugeType::push ? 0.5f :
|
||||
(mvOccupied->CabActive == mvOccupied->CabOccupied) && mvOccupied->CabMaster ? 1.f :
|
||||
mvOccupied->IsCabMaster() ? 1.f :
|
||||
0.f));
|
||||
// line breaker
|
||||
if( ggMainButton.SubModel != nullptr ) { // instead of single main button there can be on/off pair
|
||||
|
||||
@@ -110,7 +110,7 @@ TController::cue_action( locale::string const Action, float const Actionparamete
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
return ( ( mvOccupied->AutomaticCabActivation ) || ( ( mvOccupied->CabMaster == true ) && ( mvOccupied->CabActive == mvOccupied->CabOccupied ) ) ); } );
|
||||
return ( ( mvOccupied->AutomaticCabActivation ) || ( mvOccupied->IsCabMaster() ) ); } );
|
||||
break;
|
||||
}
|
||||
case locale::string::driver_hint_cabdeactivation: {
|
||||
|
||||
Reference in New Issue
Block a user