mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 06:19:18 +02:00
build 210408. door opening logic enhancements, door permit sound, door permit indicator cab control
This commit is contained in:
45
DynObj.cpp
45
DynObj.cpp
@@ -4347,13 +4347,15 @@ void TDynamicObject::RenderSounds() {
|
|||||||
|
|
||||||
if( true == door.is_opening ) {
|
if( true == door.is_opening ) {
|
||||||
// door sounds
|
// door sounds
|
||||||
// due to potential wait for the doorstep we play the sound only during actual animation
|
if( ( false == door.step_unfolding ) // no wait if no doorstep
|
||||||
if( door.position > 0.f ) {
|
|| ( MoverParameters->Doors.step_type == 2 ) ) { // no wait for rotating doorstep
|
||||||
for( auto &doorsounds : m_doorsounds ) {
|
if( door.position < 0.5f ) { // safety measure, to keep slightly too short sounds from repeating
|
||||||
if( doorsounds.placement == side ) {
|
for( auto &doorsounds : m_doorsounds ) {
|
||||||
// determine left side doors from their offset
|
if( doorsounds.placement == side ) {
|
||||||
doorsounds.rsDoorOpen.play( sound_flags::exclusive );
|
// determine left side doors from their offset
|
||||||
doorsounds.rsDoorClose.stop();
|
doorsounds.rsDoorOpen.play( sound_flags::exclusive );
|
||||||
|
doorsounds.rsDoorClose.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4579,10 +4581,9 @@ void TDynamicObject::RenderSounds() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// McZapkie! - to wazne - SoundFlag wystawiane jest przez moje moduly
|
// McZapkie! - to wazne - SoundFlag wystawiane jest przez moje moduly gdy zachodza pewne wydarzenia komentowane dzwiekiem.
|
||||||
// gdy zachodza pewne wydarzenia komentowane dzwiekiem.
|
// pneumatic relay
|
||||||
if( TestFlag( MoverParameters->SoundFlag, sound::pneumatic ) ) {
|
if( TestFlag( MoverParameters->SoundFlag, sound::pneumatic ) ) {
|
||||||
// pneumatic relay
|
|
||||||
dsbPneumaticRelay
|
dsbPneumaticRelay
|
||||||
.gain(
|
.gain(
|
||||||
true == TestFlag( MoverParameters->SoundFlag, sound::loud ) ?
|
true == TestFlag( MoverParameters->SoundFlag, sound::loud ) ?
|
||||||
@@ -4590,6 +4591,16 @@ void TDynamicObject::RenderSounds() {
|
|||||||
0.8f )
|
0.8f )
|
||||||
.play();
|
.play();
|
||||||
}
|
}
|
||||||
|
// door permit
|
||||||
|
if( TestFlag( MoverParameters->SoundFlag, sound::doorpermit ) ) {
|
||||||
|
// NOTE: current implementation doesn't discern between permit for left/right side,
|
||||||
|
// which may be undesired in weird setups with doors only on one side
|
||||||
|
// TBD, TODO: rework into dedicated sound event flag for each door location instance?
|
||||||
|
for( auto &door : m_doorsounds ) {
|
||||||
|
door.permit_granted.play( sound_flags::exclusive );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// couplers
|
// couplers
|
||||||
int couplerindex { 0 };
|
int couplerindex { 0 };
|
||||||
for( auto &couplersounds : m_couplersounds ) {
|
for( auto &couplersounds : m_couplersounds ) {
|
||||||
@@ -5848,6 +5859,18 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if( token == "doorpermit:" ) {
|
||||||
|
sound_source soundtemplate { sound_placement::general };
|
||||||
|
soundtemplate.deserialize( parser, sound_type::single );
|
||||||
|
soundtemplate.owner( this );
|
||||||
|
for( auto &door : m_doorsounds ) {
|
||||||
|
// apply configuration to all defined doors, but preserve their individual offsets
|
||||||
|
auto const dooroffset { door.permit_granted.offset() };
|
||||||
|
door.permit_granted = soundtemplate;
|
||||||
|
door.permit_granted.offset( dooroffset );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if( token == "unloading:" ) {
|
else if( token == "unloading:" ) {
|
||||||
m_exchangesounds.unloading.range( MoverParameters->Dim.L * 0.5f * -1 );
|
m_exchangesounds.unloading.range( MoverParameters->Dim.L * 0.5f * -1 );
|
||||||
m_exchangesounds.unloading.deserialize( parser, sound_type::single );
|
m_exchangesounds.unloading.deserialize( parser, sound_type::single );
|
||||||
@@ -5982,6 +6005,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
door.unlock.offset( location );
|
door.unlock.offset( location );
|
||||||
door.step_close.offset( location );
|
door.step_close.offset( location );
|
||||||
door.step_open.offset( location );
|
door.step_open.offset( location );
|
||||||
|
door.permit_granted.offset( location );
|
||||||
m_doorsounds.emplace_back( door );
|
m_doorsounds.emplace_back( door );
|
||||||
}
|
}
|
||||||
if( ( sides == "both" )
|
if( ( sides == "both" )
|
||||||
@@ -5995,6 +6019,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
door.unlock.offset( location );
|
door.unlock.offset( location );
|
||||||
door.step_close.offset( location );
|
door.step_close.offset( location );
|
||||||
door.step_open.offset( location );
|
door.step_open.offset( location );
|
||||||
|
door.permit_granted.offset( location );
|
||||||
m_doorsounds.emplace_back( door );
|
m_doorsounds.emplace_back( door );
|
||||||
}
|
}
|
||||||
m_doorspeakers.emplace_back(
|
m_doorspeakers.emplace_back(
|
||||||
|
|||||||
1
DynObj.h
1
DynObj.h
@@ -356,6 +356,7 @@ private:
|
|||||||
sound_source unlock { sound_placement::general };
|
sound_source unlock { sound_placement::general };
|
||||||
sound_source step_open { sound_placement::general };
|
sound_source step_open { sound_placement::general };
|
||||||
sound_source step_close { sound_placement::general };
|
sound_source step_close { sound_placement::general };
|
||||||
|
sound_source permit_granted { sound_placement::general };
|
||||||
side placement {};
|
side placement {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ enum sound {
|
|||||||
attachheating = 1 << 13,
|
attachheating = 1 << 13,
|
||||||
attachadapter = 1 << 14,
|
attachadapter = 1 << 14,
|
||||||
removeadapter = 1 << 15,
|
removeadapter = 1 << 15,
|
||||||
|
doorpermit = 1 << 16,
|
||||||
};
|
};
|
||||||
|
|
||||||
// customizable reset button
|
// customizable reset button
|
||||||
@@ -882,6 +883,7 @@ private:
|
|||||||
// internal data
|
// internal data
|
||||||
float auto_timer { -1.f }; // delay between activation of open state and closing state for automatic doors
|
float auto_timer { -1.f }; // delay between activation of open state and closing state for automatic doors
|
||||||
float close_delay { 0.f }; // delay between activation of closing state and actual closing
|
float close_delay { 0.f }; // delay between activation of closing state and actual closing
|
||||||
|
float open_delay { 0.f }; // delay between activation of opening state and actual opening
|
||||||
float position { 0.f }; // current shift of the door from the closed position
|
float position { 0.f }; // current shift of the door from the closed position
|
||||||
float step_position { 0.f }; // current shift of the movable step from the retracted position
|
float step_position { 0.f }; // current shift of the movable step from the retracted position
|
||||||
// ld outputs
|
// ld outputs
|
||||||
@@ -897,6 +899,7 @@ private:
|
|||||||
// config
|
// config
|
||||||
control_t open_control { control_t::passenger };
|
control_t open_control { control_t::passenger };
|
||||||
float open_rate { 1.f };
|
float open_rate { 1.f };
|
||||||
|
float open_delay { 0.f };
|
||||||
control_t close_control { control_t::passenger };
|
control_t close_control { control_t::passenger };
|
||||||
float close_rate { 1.f };
|
float close_rate { 1.f };
|
||||||
float close_delay { 0.f };
|
float close_delay { 0.f };
|
||||||
@@ -1432,6 +1435,7 @@ public:
|
|||||||
heat_data dizel_heat;
|
heat_data dizel_heat;
|
||||||
std::array<cooling_fan, 2> MotorBlowers;
|
std::array<cooling_fan, 2> MotorBlowers;
|
||||||
door_data Doors;
|
door_data Doors;
|
||||||
|
float DoorsOpenWithPermitAfter { -1.f }; // remote open if permit button is held for specified time. NOTE: separate from door data as its cab control thing
|
||||||
|
|
||||||
int BrakeCtrlPos = -2; /*nastawa hamulca zespolonego*/
|
int BrakeCtrlPos = -2; /*nastawa hamulca zespolonego*/
|
||||||
double BrakeCtrlPosR = 0.0; /*nastawa hamulca zespolonego - plynna dla FV4a*/
|
double BrakeCtrlPosR = 0.0; /*nastawa hamulca zespolonego - plynna dla FV4a*/
|
||||||
@@ -1868,6 +1872,7 @@ public:
|
|||||||
bool AssignLoad( std::string const &Name, float const Amount = 0.f );
|
bool AssignLoad( std::string const &Name, float const Amount = 0.f );
|
||||||
bool LoadingDone(double LSpeed, std::string const &Loadname);
|
bool LoadingDone(double LSpeed, std::string const &Loadname);
|
||||||
bool PermitDoors( side const Door, bool const State = true, range_t const Notify = range_t::consist );
|
bool PermitDoors( side const Door, bool const State = true, range_t const Notify = range_t::consist );
|
||||||
|
void PermitDoors_( side const Door, bool const State = true );
|
||||||
bool ChangeDoorPermitPreset( int const Change, range_t const Notify = range_t::consist );
|
bool ChangeDoorPermitPreset( int const Change, range_t const Notify = range_t::consist );
|
||||||
bool PermitDoorStep( bool const State, range_t const Notify = range_t::consist );
|
bool PermitDoorStep( bool const State, range_t const Notify = range_t::consist );
|
||||||
bool ChangeDoorControlMode( bool const State, range_t const Notify = range_t::consist );
|
bool ChangeDoorControlMode( bool const State, range_t const Notify = range_t::consist );
|
||||||
|
|||||||
@@ -8236,7 +8236,7 @@ bool TMoverParameters::PermitDoors( side const Door, bool const State, range_t c
|
|||||||
|
|
||||||
bool const initialstate { Doors.instances[Door].open_permit };
|
bool const initialstate { Doors.instances[Door].open_permit };
|
||||||
|
|
||||||
Doors.instances[ Door ].open_permit = State;
|
PermitDoors_( Door, State );
|
||||||
|
|
||||||
if( Notify != range_t::local ) {
|
if( Notify != range_t::local ) {
|
||||||
|
|
||||||
@@ -8255,6 +8255,14 @@ bool TMoverParameters::PermitDoors( side const Door, bool const State, range_t c
|
|||||||
return ( Doors.instances[ Door ].open_permit != initialstate );
|
return ( Doors.instances[ Door ].open_permit != initialstate );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TMoverParameters::PermitDoors_( side const Door, bool const State ) {
|
||||||
|
|
||||||
|
if( ( State ) && ( State != Doors.instances[ Door ].open_permit ) ) {
|
||||||
|
SetFlag( SoundFlag, sound::doorpermit );
|
||||||
|
}
|
||||||
|
Doors.instances[ Door ].open_permit = State;
|
||||||
|
}
|
||||||
|
|
||||||
bool TMoverParameters::ChangeDoorControlMode( bool const State, range_t const Notify ) {
|
bool TMoverParameters::ChangeDoorControlMode( bool const State, range_t const Notify ) {
|
||||||
|
|
||||||
auto const initialstate { Doors.remote_only };
|
auto const initialstate { Doors.remote_only };
|
||||||
@@ -8483,21 +8491,15 @@ TMoverParameters::update_doors( double const Deltatime ) {
|
|||||||
// doors
|
// doors
|
||||||
if( true == door.is_opening ) {
|
if( true == door.is_opening ) {
|
||||||
// open door
|
// open door
|
||||||
if( ( TrainType == dt_EZT )
|
if( ( false == door.step_unfolding ) // no wait if no doorstep
|
||||||
|| ( TrainType == dt_DMU ) ) {
|
|| ( Doors.step_type == 2 ) ) { // no wait for rotating doorstep
|
||||||
// multi-unit vehicles typically open door only after unfolding the doorstep
|
door.open_delay += Deltatime;
|
||||||
if( ( false == door.step_unfolding ) // no wait if no doorstep
|
if( door.open_delay > Doors.open_delay ) {
|
||||||
|| ( Doors.step_type == 2 ) ) { // no wait for rotating doorstep
|
|
||||||
door.position = std::min<float>(
|
door.position = std::min<float>(
|
||||||
Doors.range,
|
Doors.range,
|
||||||
door.position + Doors.open_rate * Deltatime );
|
door.position + Doors.open_rate * Deltatime );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
door.position = std::min<float>(
|
|
||||||
Doors.range,
|
|
||||||
door.position + Doors.open_rate * Deltatime );
|
|
||||||
}
|
|
||||||
door.close_delay = 0.f;
|
door.close_delay = 0.f;
|
||||||
}
|
}
|
||||||
if( true == door.is_closing ) {
|
if( true == door.is_closing ) {
|
||||||
@@ -8508,6 +8510,7 @@ TMoverParameters::update_doors( double const Deltatime ) {
|
|||||||
0.f,
|
0.f,
|
||||||
door.position - Doors.close_rate * Deltatime );
|
door.position - Doors.close_rate * Deltatime );
|
||||||
}
|
}
|
||||||
|
door.open_delay = 0.f;
|
||||||
}
|
}
|
||||||
// doorsteps
|
// doorsteps
|
||||||
if( door.step_unfolding ) {
|
if( door.step_unfolding ) {
|
||||||
@@ -9973,6 +9976,7 @@ void TMoverParameters::LoadFIZ_Doors( std::string const &line ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extract_value( Doors.open_rate, "OpenSpeed", line, "" );
|
extract_value( Doors.open_rate, "OpenSpeed", line, "" );
|
||||||
|
extract_value( Doors.open_delay, "DoorOpenDelay", line, "" );
|
||||||
extract_value( Doors.close_rate, "CloseSpeed", line, "" );
|
extract_value( Doors.close_rate, "CloseSpeed", line, "" );
|
||||||
extract_value( Doors.close_delay, "DoorCloseDelay", line, "" );
|
extract_value( Doors.close_delay, "DoorCloseDelay", line, "" );
|
||||||
extract_value( Doors.range, "DoorMaxShiftL", line, "" );
|
extract_value( Doors.range, "DoorMaxShiftL", line, "" );
|
||||||
@@ -10016,6 +10020,7 @@ void TMoverParameters::LoadFIZ_Doors( std::string const &line ) {
|
|||||||
extract_value( MirrorMaxShift, "MirrorMaxShift", line, "" );
|
extract_value( MirrorMaxShift, "MirrorMaxShift", line, "" );
|
||||||
extract_value( MirrorVelClose, "MirrorVelClose", line, "");
|
extract_value( MirrorVelClose, "MirrorVelClose", line, "");
|
||||||
|
|
||||||
|
extract_value( DoorsOpenWithPermitAfter, "DoorOpenWithPermit", line, "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Index ) {
|
void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Index ) {
|
||||||
@@ -11841,10 +11846,10 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
|||||||
auto const right { 3 - left };
|
auto const right { 3 - left };
|
||||||
|
|
||||||
if( std::abs( static_cast<int>( CValue1 ) ) & right ) {
|
if( std::abs( static_cast<int>( CValue1 ) ) & right ) {
|
||||||
Doors.instances[ side::right ].open_permit = (CValue1 > 0);
|
PermitDoors_( side::right, ( CValue1 > 0 ) );
|
||||||
}
|
}
|
||||||
if( std::abs( static_cast<int>( CValue1 ) ) & left ) {
|
if( std::abs( static_cast<int>( CValue1 ) ) & left ) {
|
||||||
Doors.instances[ side::left ].open_permit = (CValue1 > 0);
|
PermitDoors_( side::left, ( CValue1 > 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
|
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
|
||||||
|
|||||||
78
Train.cpp
78
Train.cpp
@@ -1100,7 +1100,7 @@ void TTrain::OnCommand_secondcontrollerincrease( TTrain *Train, command_data con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( Train->ggScndCtrl.type() == TGaugeType::push ) {
|
if( Train->ggScndCtrl.is_push() ) {
|
||||||
// two-state control, active while the button is down
|
// two-state control, active while the button is down
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
// activate on press
|
// activate on press
|
||||||
@@ -1118,6 +1118,13 @@ void TTrain::OnCommand_secondcontrollerincrease( TTrain *Train, command_data con
|
|||||||
Train->mvControlled->IncScndCtrl( 1 );
|
Train->mvControlled->IncScndCtrl( 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// potentially animate tempomat button
|
||||||
|
if( ( Train->ggScndCtrlButton.is_push() )
|
||||||
|
&& ( Train->mvControlled->ScndCtrlPos <= 1 ) ) {
|
||||||
|
Train->ggScndCtrlButton.UpdateValue(
|
||||||
|
( ( Command.action == GLFW_RELEASE ) ? 0.f : 1.f ),
|
||||||
|
Train->dsbSwitch );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1252,6 +1259,20 @@ void TTrain::OnCommand_secondcontrollerdecrease( TTrain *Train, command_data con
|
|||||||
Train->mvControlled->DecScndCtrl( 1 );
|
Train->mvControlled->DecScndCtrl( 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// potentially animate tempomat button
|
||||||
|
if( ( Train->ggScndCtrlButton.is_push() )
|
||||||
|
&& ( Train->mvControlled->ScndCtrlPos <= 1 ) ) {
|
||||||
|
if( Train->m_controlmapper.contains( "tempomatoff_sw:" ) ) {
|
||||||
|
Train->ggScndCtrlOffButton.UpdateValue(
|
||||||
|
( ( Command.action == GLFW_RELEASE ) ? 0.f : 1.f ),
|
||||||
|
Train->dsbSwitch );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Train->ggScndCtrlButton.UpdateValue(
|
||||||
|
( ( Command.action == GLFW_RELEASE ) ? 0.f : 1.f ),
|
||||||
|
Train->dsbSwitch );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data const &Command ) {
|
||||||
@@ -5168,18 +5189,20 @@ void TTrain::OnCommand_doorpermitleft( TTrain *Train, command_data const &Comman
|
|||||||
if( Command.action == GLFW_REPEAT ) { return; }
|
if( Command.action == GLFW_REPEAT ) { return; }
|
||||||
if( false == Train->mvOccupied->Doors.permit_presets.empty() ) { return; }
|
if( false == Train->mvOccupied->Doors.permit_presets.empty() ) { return; }
|
||||||
|
|
||||||
|
auto const side { (
|
||||||
|
Train->cab_to_end() == end::front ?
|
||||||
|
side::left :
|
||||||
|
side::right ) };
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
|
|
||||||
auto const side { (
|
if( Train->ggDoorLeftPermitButton.is_push() ) {
|
||||||
Train->cab_to_end() == end::front ?
|
|
||||||
side::left :
|
|
||||||
side::right ) };
|
|
||||||
|
|
||||||
if( Train->ggDoorLeftPermitButton.type() == TGaugeType::push ) {
|
|
||||||
// impulse switch
|
// impulse switch
|
||||||
Train->mvOccupied->PermitDoors( side );
|
Train->mvOccupied->PermitDoors( side );
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggDoorLeftPermitButton.UpdateValue( 1.0, Train->dsbSwitch );
|
Train->ggDoorLeftPermitButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
// start potential timer for remote door control
|
||||||
|
Train->m_doorpermittimers[ side ] = Train->mvOccupied->DoorsOpenWithPermitAfter;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// two-state switch
|
// two-state switch
|
||||||
@@ -5192,10 +5215,12 @@ void TTrain::OnCommand_doorpermitleft( TTrain *Train, command_data const &Comman
|
|||||||
}
|
}
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
else if( Command.action == GLFW_RELEASE ) {
|
||||||
|
|
||||||
if( Train->ggDoorLeftPermitButton.type() == TGaugeType::push ) {
|
if( Train->ggDoorLeftPermitButton.is_push() ) {
|
||||||
// impulse switch
|
// impulse switch
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggDoorLeftPermitButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggDoorLeftPermitButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// reset potential remote door control timer
|
||||||
|
Train->m_doorpermittimers[ side ] = -1.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5205,18 +5230,20 @@ void TTrain::OnCommand_doorpermitright( TTrain *Train, command_data const &Comma
|
|||||||
if( Command.action == GLFW_REPEAT ) { return; }
|
if( Command.action == GLFW_REPEAT ) { return; }
|
||||||
if( false == Train->mvOccupied->Doors.permit_presets.empty() ) { return; }
|
if( false == Train->mvOccupied->Doors.permit_presets.empty() ) { return; }
|
||||||
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
auto const side { (
|
||||||
|
Train->cab_to_end() == end::front ?
|
||||||
|
side::right :
|
||||||
|
side::left ) };
|
||||||
|
|
||||||
auto const side { (
|
if( Command.action == GLFW_PRESS ) {
|
||||||
Train->cab_to_end() == end::front ?
|
|
||||||
side::right :
|
|
||||||
side::left ) };
|
|
||||||
|
|
||||||
if( Train->ggDoorRightPermitButton.type() == TGaugeType::push ) {
|
if( Train->ggDoorRightPermitButton.type() == TGaugeType::push ) {
|
||||||
// impulse switch
|
// impulse switch
|
||||||
Train->mvOccupied->PermitDoors( side );
|
Train->mvOccupied->PermitDoors( side );
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggDoorRightPermitButton.UpdateValue( 1.0, Train->dsbSwitch );
|
Train->ggDoorRightPermitButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||||
|
// start potential timer for remote door control
|
||||||
|
Train->m_doorpermittimers[ side ] = Train->mvOccupied->DoorsOpenWithPermitAfter;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// two-state switch
|
// two-state switch
|
||||||
@@ -5233,6 +5260,8 @@ void TTrain::OnCommand_doorpermitright( TTrain *Train, command_data const &Comma
|
|||||||
// impulse switch
|
// impulse switch
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggDoorRightPermitButton.UpdateValue( 0.0, Train->dsbSwitch );
|
Train->ggDoorRightPermitButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||||
|
// reset potential remote door control timer
|
||||||
|
Train->m_doorpermittimers[ side ] = -1.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6118,7 +6147,7 @@ void TTrain::UpdateCab() {
|
|||||||
|
|
||||||
bool TTrain::Update( double const Deltatime )
|
bool TTrain::Update( double const Deltatime )
|
||||||
{
|
{
|
||||||
// train state verification
|
// train state update
|
||||||
// line breaker:
|
// line breaker:
|
||||||
if( m_linebreakerstate == 0 ) {
|
if( m_linebreakerstate == 0 ) {
|
||||||
if( true == mvControlled->Mains ) {
|
if( true == mvControlled->Mains ) {
|
||||||
@@ -6169,13 +6198,29 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
0 );
|
0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// door permits
|
||||||
|
for( auto idx = 0; idx < 2; ++idx ) {
|
||||||
|
auto &doorpermittimer { m_doorpermittimers[ idx ] };
|
||||||
|
if( doorpermittimer < 0.f ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
doorpermittimer -= Deltatime;
|
||||||
|
if( doorpermittimer < 0.f ) {
|
||||||
|
mvOccupied->OperateDoors( static_cast<side>( idx ), true );
|
||||||
|
}
|
||||||
|
}
|
||||||
// helper variables
|
// helper variables
|
||||||
if( DynamicObject->Mechanik != nullptr ) {
|
if( DynamicObject->Mechanik != nullptr ) {
|
||||||
m_doors = ( DynamicObject->Mechanik->IsAnyDoorOpen[ side::right ] || DynamicObject->Mechanik->IsAnyDoorOpen[ side::left ] );
|
m_doors = (
|
||||||
|
DynamicObject->Mechanik->IsAnyDoorOpen[ side::right ]
|
||||||
|
|| DynamicObject->Mechanik->IsAnyDoorOpen[ side::left ] );
|
||||||
|
m_doorpermits = (
|
||||||
|
DynamicObject->Mechanik->IsAnyDoorPermitActive[ side::right ]
|
||||||
|
|| DynamicObject->Mechanik->IsAnyDoorPermitActive[ side::left ] );
|
||||||
}
|
}
|
||||||
m_dirforward = ( mvControlled->DirActive > 0 );
|
m_dirforward = ( mvControlled->DirActive > 0 );
|
||||||
m_dirneutral = ( mvControlled->DirActive == 0 );
|
m_dirneutral = ( mvControlled->DirActive == 0 );
|
||||||
m_dirbackward = ( mvControlled->DirActive <0 );
|
m_dirbackward = ( mvControlled->DirActive < 0 );
|
||||||
|
|
||||||
// check for received user commands
|
// check for received user commands
|
||||||
// NOTE: this is a temporary arrangement, for the transition period from old command setup to the new one
|
// NOTE: this is a temporary arrangement, for the transition period from old command setup to the new one
|
||||||
@@ -9213,6 +9258,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
|
|||||||
{ "i-doors:", &m_doors },
|
{ "i-doors:", &m_doors },
|
||||||
{ "i-doorpermit_left:", &mvOccupied->Doors.instances[ ( cab_to_end() == end::front ? side::left : side::right ) ].open_permit },
|
{ "i-doorpermit_left:", &mvOccupied->Doors.instances[ ( cab_to_end() == end::front ? side::left : side::right ) ].open_permit },
|
||||||
{ "i-doorpermit_right:", &mvOccupied->Doors.instances[ ( cab_to_end() == end::front ? side::right : side::left ) ].open_permit },
|
{ "i-doorpermit_right:", &mvOccupied->Doors.instances[ ( cab_to_end() == end::front ? side::right : side::left ) ].open_permit },
|
||||||
|
{ "i-doorpermit_any:", &m_doorpermits },
|
||||||
{ "i-doorstep:", &mvOccupied->Doors.step_enabled },
|
{ "i-doorstep:", &mvOccupied->Doors.step_enabled },
|
||||||
{ "i-mainpipelock:", &mvOccupied->LockPipe },
|
{ "i-mainpipelock:", &mvOccupied->LockPipe },
|
||||||
{ "i-battery:", &mvOccupied->Power24vIsAvailable },
|
{ "i-battery:", &mvOccupied->Power24vIsAvailable },
|
||||||
|
|||||||
2
Train.h
2
Train.h
@@ -818,6 +818,8 @@ private:
|
|||||||
bool m_dirforward{ false }; // helper, true if direction set to forward
|
bool m_dirforward{ false }; // helper, true if direction set to forward
|
||||||
bool m_dirneutral{ false }; // helper, true if direction set to neutral
|
bool m_dirneutral{ false }; // helper, true if direction set to neutral
|
||||||
bool m_dirbackward{ false }; // helper, true if direction set to backward
|
bool m_dirbackward{ false }; // helper, true if direction set to backward
|
||||||
|
bool m_doorpermits{ false }; // helper, true if any door permit is active
|
||||||
|
float m_doorpermittimers[2] = { -1.f, -1.f };
|
||||||
// ld substitute
|
// ld substitute
|
||||||
bool m_couplingdisconnect { false };
|
bool m_couplingdisconnect { false };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user