16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

Tweak the door closing and warning signal delays

- The warning signal is no longer going to be played for an obnoxiously long amount of time by AI drivers when driving vehicles with a manual warning signal switch, most notably EN57.
  - A new `moveDepartureWarned` driving flag has been created to accomodate this behavior.
- Added the action time counter and the missing driving flags to the Vehicle AI section.
This commit is contained in:
jakubg1
2026-04-04 00:13:26 +02:00
parent b4fdb9ce73
commit 4b847e79b9
3 changed files with 55 additions and 51 deletions

View File

@@ -1138,9 +1138,12 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) {
"Current order: [" + std::to_string( mechanik.OrderPos ) + "] "
+ mechanik.Order2Str( mechanik.OrderCurrentGet() );
if( mechanik.fStopTime < 0.0 ) {
textline += "\n stop time: " + to_string( std::abs( mechanik.fStopTime ), 1 );
}
if( mechanik.fStopTime < 0.0 ) {
textline += "\n stop time: " + to_string( std::abs( mechanik.fStopTime ), 1 );
}
if( mechanik.fActionTime < 0.0 ) {
textline += "\n action time: " + to_string( std::abs( mechanik.fActionTime ), 1 );
}
Output.emplace_back( textline, Global.UITextColor );
@@ -1231,7 +1234,8 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) {
std::vector<std::string> const drivingflagnames {
"StopCloser", "StopPoint", "Active", "Press", "Connect", "Primary", "Late", "StopHere",
"StartHorn", "StartHornNow", "StartHornDone", "Oerlikons", "IncSpeed", "TrackEnd", "SwitchFound", "GuardSignal",
"Visibility", "DoorOpened", "PushPull", "SignalFound", "StopPointFound" /*"SemaphorWasElapsed", "TrainInsideStation", "SpeedLimitFound"*/ };
"Visibility", "DoorOpened", "PushPull", "SignalFound", "StopPointFound", "GuardOpenDoor", "DepartureWarned"
/*"SemaphorWasElapsed", "TrainInsideStation", "SpeedLimitFound"*/ };
textline = "Driving flags:";
for( int idx = 0, flagbit = 1; idx < drivingflagnames.size(); ++idx, flagbit <<= 1 ) {

View File

@@ -4359,62 +4359,61 @@ void TController::Doors( bool const Open, int const Side ) {
if( ( false == doors_permit_active() )
&& ( false == doors_open() ) ) {
iDrivigFlags &= ~moveDoorOpened;
iDrivigFlags &= ~moveDepartureWarned;
return;
}
if (mvOccupied->Doors.has_warning && !TestFlag(iDrivigFlags, moveDepartureWarned))
{
if (!mvOccupied->DepartureSignal)
{
// Not warned yet, not warning yet - start the warning signal.
cue_action( driver_hint::departuresignalon ); // załącenie bzyczka
fActionTime = Random( -0.3, -0.8 ); // 0.3-0.8 second buzzer
return;
}
// Not warned yet, warning now - stop the warning signal and mark it as done.
cue_action( driver_hint::departuresignaloff );
fActionTime = Random( 0.0, -0.2 ); // Wait just a bit more before departing
iDrivigFlags |= moveDepartureWarned;
return;
}
if( true == doors_open() ) {
if( ( true == mvOccupied->Doors.has_warning )
&& ( false == mvOccupied->DepartureSignal )
&& ( true == TestFlag( iDrivigFlags, moveDoorOpened ) ) ) {
cue_action( driver_hint::departuresignalon ); // załącenie bzyczka
fActionTime = -1.5 - 0.1 * Random( 10 ); // 1.5-2.5 second wait
// consist-wide remote signals to close doors
if( ( pVehicle->MoverParameters->Doors.close_control == control_t::conductor )
|| ( pVehicle->MoverParameters->Doors.close_control == control_t::driver )
|| ( pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) ) {
cue_action( driver_hint::doorrightclose );
cue_action( driver_hint::doorleftclose );
}
}
if( true == doors_permit_active() ) {
cue_action( driver_hint::doorrightpermitoff );
cue_action( driver_hint::doorleftpermitoff );
}
// if applicable close manually-operated doors in vehicles which may ignore remote signals
{
const auto *vehicle = pVehicles[ end::front ]; // pojazd na czole składu
while( vehicle != nullptr ) {
// zamykanie drzwi w pojazdach - flaga zezwolenia była by lepsza
auto const ismanualdoor {
( vehicle->MoverParameters->Doors.auto_velocity == -1.f )
&& ( ( vehicle->MoverParameters->Doors.close_control == control_t::passenger )
|| ( vehicle->MoverParameters->Doors.close_control == control_t::mixed ) ) };
if( ( false == AIControllFlag ) || ( fActionTime > -0.5 ) ) {
// ai doesn't close the door until it's free to depart, but human driver has free reign to do stupid things
if( true == doors_open() ) {
// consist-wide remote signals to close doors
if( ( pVehicle->MoverParameters->Doors.close_control == control_t::conductor )
|| ( pVehicle->MoverParameters->Doors.close_control == control_t::driver )
|| ( pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) ) {
cue_action( driver_hint::doorrightclose );
cue_action( driver_hint::doorleftclose );
if( ( true == ismanualdoor )
&& ( ( vehicle->LoadExchangeTime() == 0.f )
|| ( vehicle->MoverParameters->Vel > EU07_AI_MOVEMENT ) ) ) {
vehicle->MoverParameters->OperateDoors( side::right, false, range_t::local );
vehicle->MoverParameters->OperateDoors( side::left, false, range_t::local );
}
}
if( true == doors_permit_active() ) {
cue_action( driver_hint::doorrightpermitoff );
cue_action( driver_hint::doorleftpermitoff );
}
// if applicable close manually-operated doors in vehicles which may ignore remote signals
{
auto *vehicle = pVehicles[ end::front ]; // pojazd na czole składu
while( vehicle != nullptr ) {
// zamykanie drzwi w pojazdach - flaga zezwolenia była by lepsza
auto const ismanualdoor {
( vehicle->MoverParameters->Doors.auto_velocity == -1.f )
&& ( ( vehicle->MoverParameters->Doors.close_control == control_t::passenger )
|| ( vehicle->MoverParameters->Doors.close_control == control_t::mixed ) ) };
if( ( true == ismanualdoor )
&& ( ( vehicle->LoadExchangeTime() == 0.f )
|| ( vehicle->MoverParameters->Vel > EU07_AI_MOVEMENT ) ) ) {
vehicle->MoverParameters->OperateDoors( side::right, false, range_t::local );
vehicle->MoverParameters->OperateDoors( side::left, false, range_t::local );
}
vehicle = vehicle->Next(); // pojazd podłączony z tyłu (patrząc od czoła)
}
}
fActionTime = -2.0 - 0.1 * Random( 15 ); // 2.0-3.5 sec wait, +potentially 0.5 remaining
iDrivigFlags &= ~moveDoorOpened; // zostały zamknięte - nie wykonywać drugi raz
if( ( true == mvOccupied->DepartureSignal )
&& ( Random( 100 ) < Random( 100 ) ) ) {
// potentially turn off the warning before actual departure
// TBD, TODO: dedicated buzzer duration counter?
cue_action( driver_hint::departuresignaloff );
vehicle = vehicle->Next(); // pojazd podłączony z tyłu (patrząc od czoła)
}
}
fActionTime = Random( -1.0, -3.5 ); // 1.0-3.5 sec wait
iDrivigFlags &= ~moveDoorOpened; // zostały zamknięte - nie wykonywać drugi raz
iDrivigFlags &= ~moveDepartureWarned;
}
}

View File

@@ -75,7 +75,8 @@ enum TMovementStatus
movePushPull = 0x40000, // zmiana czoła przez zmianę kabiny - nie odczepiać przy zmianie kierunku
moveSignalFound = 0x80000, // na drodze skanowania został znaleziony semafor
moveStopPointFound = 0x100000, // stop point detected ahead
moveGuardOpenDoor = 0x200000 // time for opening a door before departure
moveGuardOpenDoor = 0x200000, // time for opening a door before departure
moveDepartureWarned = 0x400000 // driver has already warned about the doors being closed (only for manual warning - i.e. EN57-ish)
/*
moveSemaphorWasElapsed = 0x100000, // minięty został semafor
moveTrainInsideStation = 0x200000, // pociąg między semaforem a rozjazdami lub następnym semaforem