18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 17:37:09 +01:00

refactor(ai): the cab and the whois event are no longer friends of the AI, its public fields are private

TTrain and whois_event reached into the private members of TController as its
friends; they read what the AI knows of its consist and its route through
queries now (ConsistDoorsOpen(), ConsistConverterOverloaded(), ConsistLength(),
DesiredVelocity(), NextSignalVelocity(), BrakesReleaseLevel(), ...), and the cab
changes the radio channel through SetRadioChannel() rather than a reference to
the AI's field. The reversers of the consist, the stations of the timetable and
the obstacle ahead are public queries and operations.

The public fields of TController are private: whether the AI drives
(AIControllFlag()), the masks of the running without current the vehicles of
the consist set (MarkOverhead(), the same bits TDynamicObject::OverheadTrack()
set itself), the most deceleration of the blended brakes (MedAmax(),
SetMedAmax()), and the positions the driving aid panels show. Only the four
debug and timetable panels stay friends.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 13:06:16 +01:00
parent 439adc2f46
commit 74f0aa240d
29 changed files with 251 additions and 220 deletions
+100 -100
View File
@@ -82,7 +82,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
switch( Action ) {
// battery
case driver_hint::batteryon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->BatterySwitch( true );
}
remove_hint( driver_hint::batteryoff );
@@ -93,7 +93,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::batteryoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->BatterySwitch( false );
}
remove_hint( driver_hint::batteryon );
@@ -105,7 +105,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// battery
case driver_hint::cabactivation: {
if (AIControllFlag && occupied->lowVoltage.Is24vAvailable()) {
if (aiControlled && occupied->lowVoltage.Is24vAvailable()) {
occupied->CabActivisation();
CheckVehicles();
}
@@ -117,7 +117,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::cabdeactivation: {
if (AIControllFlag) {
if (aiControlled) {
occupied->CabDeactivisation();
}
remove_hint( driver_hint::cabactivation );
@@ -129,7 +129,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// radio
case driver_hint::radioon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->SetRadio(true);
}
remove_hint( driver_hint::radiooff );
@@ -140,7 +140,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::radiofuseon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->SetRadioFuse(true);
}
hint(
@@ -150,7 +150,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::radiochannel: {
if( AIControllFlag ) {
if( aiControlled ) {
iRadioChannel = static_cast<int>( Actionparameter );
}
hint(
@@ -161,7 +161,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::radiooff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->SetRadio(false);
}
remove_hint( driver_hint::radioon );
@@ -173,7 +173,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// oil pump
case driver_hint::oilpumpon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->OilPumpSwitch( true );
}
remove_hint( driver_hint::oilpumpoff );
@@ -185,7 +185,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::oilpumpoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->OilPumpSwitch( false );
}
remove_hint( driver_hint::oilpumpon );
@@ -198,7 +198,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// fuel pump
case driver_hint::fuelpumpon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->FuelPumpSwitch( true );
}
remove_hint( driver_hint::fuelpumpoff );
@@ -210,7 +210,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::fuelpumpoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->FuelPumpSwitch( false );
}
remove_hint( driver_hint::fuelpumpon );
@@ -223,7 +223,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// pantographs
case driver_hint::pantographairsourcesetmain: {
if( AIControllFlag ) {
if( aiControlled ) {
pantographUnit->pantographAir.ConnectToMainReservoir(true);
}
remove_hint( driver_hint::pantographairsourcesetauxiliary );
@@ -234,7 +234,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::pantographairsourcesetauxiliary: {
if( AIControllFlag ) {
if( aiControlled ) {
pantographUnit->pantographAir.ConnectToMainReservoir(false);
}
remove_hint( driver_hint::pantographcompressoron );
@@ -245,7 +245,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::pantographcompressoron: {
if( AIControllFlag ) {
if( aiControlled ) {
pantographUnit->pantographAir.SwitchCompressor(true);
}
remove_hint( driver_hint::pantographcompressoroff );
@@ -256,7 +256,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::pantographcompressoroff: {
if( AIControllFlag ) {
if( aiControlled ) {
pantographUnit->pantographAir.SwitchCompressor(false);
}
remove_hint( driver_hint::pantographcompressoron );
@@ -267,7 +267,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::pantographsvalveon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->OperatePantographsValve( operation_t::enable );
}
remove_hint( driver_hint::pantographsvalveoff );
@@ -278,7 +278,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::frontpantographvalveon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->OperatePantographValve( VehicleEnd::front, operation_t::enable );
}
remove_hint( driver_hint::frontpantographvalveoff );
@@ -290,7 +290,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::frontpantographvalveoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->OperatePantographValve( VehicleEnd::front, operation_t::disable );
}
remove_hint( driver_hint::frontpantographvalveon );
@@ -301,7 +301,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::rearpantographvalveon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->OperatePantographValve( VehicleEnd::rear, operation_t::enable );
}
remove_hint( driver_hint::rearpantographvalveoff );
@@ -313,7 +313,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::rearpantographvalveoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->OperatePantographValve( VehicleEnd::rear, operation_t::disable );
}
remove_hint( driver_hint::rearpantographvalveon );
@@ -325,7 +325,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// converter
case driver_hint::converteron: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->ConverterSwitch( true );
// the local switch of the converter too, where the line contactors wait for the vehicle's own converter
// (LineContactorsInterlock): left off by the human driver, that vehicle would never take power
@@ -344,7 +344,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::converteroff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->ConverterSwitch( false );
}
remove_hint( driver_hint::converteron );
@@ -356,7 +356,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// relays
case driver_hint::primaryconverteroverloadreset: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->RelayReset( relay_t::primaryconverteroverload );
}
hint(
@@ -366,7 +366,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::maincircuitgroundreset: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->RelayReset( relay_t::maincircuitground );
}
hint(
@@ -376,7 +376,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::tractionnmotoroverloadreset: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->RelayReset( relay_t::tractionnmotoroverload );
}
hint(
@@ -387,7 +387,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// line breaker
case driver_hint::linebreakerclose: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->MainSwitch( true );
}
remove_hint( driver_hint::linebreakeropen );
@@ -398,7 +398,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::linebreakeropen: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->MainSwitch( false );
}
remove_hint( driver_hint::linebreakerclose );
@@ -411,7 +411,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// compressor
case driver_hint::compressoron: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->CompressorSwitch( true );
}
remove_hint( driver_hint::compressoroff );
@@ -422,7 +422,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::compressoroff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->CompressorSwitch( false );
}
remove_hint( driver_hint::compressoron );
@@ -433,7 +433,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::frontmotorblowerson: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->MotorBlowersSwitchOff( false, VehicleEnd::front );
occupied->MotorBlowersSwitch( true, VehicleEnd::front );
}
@@ -446,7 +446,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::rearmotorblowerson: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->MotorBlowersSwitchOff( false, VehicleEnd::rear );
occupied->MotorBlowersSwitch( true, VehicleEnd::rear );
}
@@ -460,7 +460,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// spring brake
case driver_hint::springbrakeon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->SpringBrakeActivate( true );
}
remove_hint( driver_hint::springbrakeoff );
@@ -471,7 +471,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::springbrakeoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->SpringBrakeActivate( false );
}
remove_hint( driver_hint::springbrakeon );
@@ -483,7 +483,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// manual brake
case driver_hint::manualbrakon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->IncManualBrakeLevel( ManualBrakePosNo );
}
remove_hint( driver_hint::manualbrakoff );
@@ -494,7 +494,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::manualbrakoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->DecManualBrakeLevel( ManualBrakePosNo );
}
remove_hint( driver_hint::manualbrakon );
@@ -506,7 +506,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// master controller
case driver_hint::mastercontrollersetidle: {
if( AIControllFlag ) {
if( aiControlled ) {
while( mvControlling->RList[mvControlling->MainCtrlPos()].Mn == 0
&& mvControlling->IncMainCtrl(1) ) {
// all work is done in the loop header
@@ -520,7 +520,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::mastercontrollersetseriesmode: {
if (AIControllFlag && mvControlling->RList[ mvControlling->MainCtrlPos() ].Bn > 1) {
if (aiControlled && mvControlling->RList[ mvControlling->MainCtrlPos() ].Bn > 1) {
// limit yourself to series mode
if( mvControlling->ScndCtrlPos() ) {
mvControlling->DecScndCtrl( 2 );
@@ -538,7 +538,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::mastercontrollersetzerospeed: {
if( AIControllFlag ) {
if( aiControlled ) {
ZeroSpeed();
}
remove_master_controller_hints();
@@ -549,7 +549,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::mastercontrollersetreverserunlock: {
if( AIControllFlag ) {
if( aiControlled ) {
while( false == mvControlling->EIMDirectionChangeAllow()
&& mvControlling->DecMainCtrl(1) ) {
// all work is done in the loop header
@@ -564,7 +564,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::tractiveforcedecrease: {
if( AIControllFlag ) {
if( aiControlled ) {
DecSpeed();
}
remove_master_controller_hints();
@@ -580,7 +580,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::tractiveforceincrease: {
if( AIControllFlag ) {
if( aiControlled ) {
IncSpeed();
}
remove_master_controller_hints();
@@ -598,7 +598,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::bufferscompress: {
if (AIControllFlag && std::abs( mvControlling->Ft ) < 50000.0) {
if (aiControlled && std::abs( mvControlling->Ft ) < 50000.0) {
IncSpeed();
}
remove_master_controller_hints();
@@ -610,7 +610,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
case driver_hint::secondcontrollersetzero: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->DecScndCtrl( 2 );
}
remove_master_controller_hints();
@@ -622,7 +622,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
case driver_hint::waterpumpon: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterPumpSwitch( true );
}
remove_hint( driver_hint::waterpumpoff );
@@ -634,7 +634,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::waterpumpoff: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterPumpSwitch( false );
}
remove_hint( driver_hint::waterpumpon );
@@ -646,7 +646,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::waterpumpbreakeron: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterPumpBreakerSwitch( true );
}
remove_hint( driver_hint::waterpumpbreakeroff );
@@ -658,7 +658,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::waterpumpbreakeroff: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterPumpBreakerSwitch( false );
}
remove_hint( driver_hint::waterpumpbreakeron );
@@ -670,7 +670,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::waterheateron: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterHeaterSwitch( true );
}
remove_hint( driver_hint::waterheateroff );
@@ -682,7 +682,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::waterheateroff: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterHeaterSwitch( false );
}
remove_hint( driver_hint::waterheateron );
@@ -694,7 +694,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::waterheaterbreakeron: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterHeaterBreakerSwitch( true );
}
remove_hint( driver_hint::waterheaterbreakeroff );
@@ -706,7 +706,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::waterheaterbreakeroff: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterHeaterBreakerSwitch( false );
}
remove_hint( driver_hint::waterheaterbreakeron );
@@ -718,7 +718,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::watercircuitslinkon: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterCircuitsLinkSwitch( true );
}
remove_hint( driver_hint::watercircuitslinkoff );
@@ -729,7 +729,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::watercircuitslinkoff: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->WaterCircuitsLinkSwitch( false );
}
remove_hint( driver_hint::watercircuitslinkon );
@@ -796,7 +796,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
// driver_hint_brakingforcesetzero
// driver_hint_brakingforcelap
case driver_hint::trainbrakesetpipeunlock: {
if (AIControllFlag && occupied->brakes.pipeLock.unlockHandlePosition != -3) {
if (aiControlled && occupied->brakes.pipeLock.unlockHandlePosition != -3) {
while( BrakeCtrlPosition >= occupied->brakes.pipeLock.unlockHandlePosition
&& BrakeLevelAdd(-1) ) {
// all work is done in the header
@@ -810,7 +810,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::trainbrakerelease: {
if( AIControllFlag ) {
if( aiControlled ) {
// occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_RP ) );
BrakeLevelSet( gbh_RP );
}
@@ -823,7 +823,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::trainbrakeapply: {
if( AIControllFlag ) {
if( aiControlled ) {
// za radą yB ustawiamy pozycję 3 kranu (ruszanie kranem w innych miejscach powino zostać wyłączone)
if( BrakeSystem == TBrakeSystem::ElectroPneumatic && false == ForcePNBrake ) {
occupied->BrakeLevelSet( occupied->brakes.driverValve->GetPos( bh_EPB ) );
@@ -840,7 +840,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::brakingforcedecrease: {
if( AIControllFlag ) {
if( aiControlled ) {
auto const brakingcontrolschange { DecBrake() };
// set optional delay between brake adjustments
if( brakingcontrolschange && Actionparameter > 0 ) {
@@ -856,7 +856,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::brakingforceincrease: {
if( AIControllFlag ) {
if( aiControlled ) {
auto const brakingcontrolschange { IncBrake() };
// set optional delay between brake adjustments
if( brakingcontrolschange && Actionparameter > 0 ) {
@@ -876,7 +876,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::brakingforcesetzero: { // releases both train and independent brake
if( AIControllFlag ) {
if( aiControlled ) {
while( true == DecBrake() ) {
// all work is done in the loop condition
}
@@ -889,7 +889,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::brakingforcelap: {
if( AIControllFlag ) {
if( aiControlled ) {
LapBrake();
}
remove_train_brake_hints();
@@ -899,7 +899,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// independent brake
case driver_hint::independentbrakeapply: {
if (AIControllFlag && occupied->brakes.IndependentPosition() < 1.0) {
if (aiControlled && occupied->brakes.IndependentPosition() < 1.0) {
occupied->IncLocalBrakeLevel( LocalBrakePosNo );
if (occupied->EIMCtrlEmergency) {
occupied->DecLocalBrakeLevel(1);
@@ -914,7 +914,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::independentbrakerelease: {
if( AIControllFlag ) {
if( aiControlled ) {
ZeroLocalBrake();
}
remove_hint( driver_hint::independentbrakeapply );
@@ -926,7 +926,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// reverser
case driver_hint::directionforward: {
if( AIControllFlag ) {
if( aiControlled ) {
OrderDirectionChange( 1, occupied );
}
remove_reverser_hints();
@@ -937,7 +937,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::directionbackward: {
if( AIControllFlag ) {
if( aiControlled ) {
OrderDirectionChange( -1, occupied );
}
remove_reverser_hints();
@@ -948,7 +948,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::directionother: {
if( AIControllFlag ) {
if( aiControlled ) {
// DirectionForward( occupied->DirAbsolute < 0 );
OrderDirectionChange( iDirectionOrder, occupied );
DirectionChange();
@@ -961,7 +961,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::directionnone: {
if( AIControllFlag ) {
if( aiControlled ) {
ZeroDirection();
}
remove_reverser_hints();
@@ -973,7 +973,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// anti-slip systems
case driver_hint::sandingon: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->Sandbox( true );
}
remove_hint( driver_hint::sandingoff );
@@ -984,7 +984,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::sandingoff: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->Sandbox( false );
}
remove_hint( driver_hint::sandingon );
@@ -995,7 +995,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::antislip: {
if( AIControllFlag ) {
if( aiControlled ) {
mvControlling->AntiSlippingButton();
}
hint(
@@ -1006,7 +1006,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// horns
case driver_hint::hornon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->SetWarningSignal(static_cast<int>( Actionparameter ));
}
remove_hint( driver_hint::hornoff );
@@ -1018,7 +1018,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::hornoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->SetWarningSignal(0);
}
/*
@@ -1033,7 +1033,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// door locks
case driver_hint::consistdoorlockson: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->LockDoors( true );
}
// TODO: remove other door lock hints
@@ -1045,7 +1045,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// departure signal
case driver_hint::departuresignalon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->signal_departure( true );
}
remove_hint( driver_hint::departuresignaloff );
@@ -1056,7 +1056,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::departuresignaloff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->signal_departure( false );
}
remove_hint( driver_hint::departuresignalon );
@@ -1068,7 +1068,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// consist doors
case driver_hint::doorrightopen: {
if( AIControllFlag
if( aiControlled
|| pVehicle->physics->Doors.open_control == control_t::conductor ) {
pVehicle->physics->OperateDoors( VehicleSide::right, true );
}
@@ -1080,7 +1080,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::doorrightclose: {
if( AIControllFlag
if( aiControlled
|| pVehicle->physics->Doors.open_control == control_t::conductor ) {
pVehicle->physics->OperateDoors( VehicleSide::right, false );
}
@@ -1092,7 +1092,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::doorleftopen: {
if( AIControllFlag
if( aiControlled
|| pVehicle->physics->Doors.open_control == control_t::conductor ) {
pVehicle->physics->OperateDoors( VehicleSide::left, true );
}
@@ -1104,7 +1104,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::doorleftclose: {
if( AIControllFlag
if( aiControlled
|| pVehicle->physics->Doors.open_control == control_t::conductor ) {
pVehicle->physics->OperateDoors( VehicleSide::left, false );
}
@@ -1116,7 +1116,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::doorrightpermiton: {
if( AIControllFlag ) {
if( aiControlled ) {
pVehicle->physics->PermitDoors( VehicleSide::right, true );
}
remove_hint( driver_hint::doorrightpermitoff );
@@ -1127,7 +1127,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::doorrightpermitoff: {
if( AIControllFlag ) {
if( aiControlled ) {
pVehicle->physics->PermitDoors( VehicleSide::right, false );
}
remove_hint( driver_hint::doorrightpermiton );
@@ -1138,7 +1138,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::doorleftpermiton: {
if( AIControllFlag ) {
if( aiControlled ) {
pVehicle->physics->PermitDoors( VehicleSide::left, true );
}
remove_hint( driver_hint::doorleftpermitoff );
@@ -1149,7 +1149,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::doorleftpermitoff: {
if( AIControllFlag ) {
if( aiControlled ) {
pVehicle->physics->PermitDoors( VehicleSide::left, false );
}
remove_hint( driver_hint::doorleftpermiton );
@@ -1161,7 +1161,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// doorsteps, as the timetable asks (eu07/maszyna#95)
case driver_hint::doorstepon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->PermitDoorStep( true );
}
remove_hint( driver_hint::doorstepoff );
@@ -1172,7 +1172,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::doorstepoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->PermitDoorStep( false );
}
remove_hint( driver_hint::doorstepon );
@@ -1184,7 +1184,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// consist lights
case driver_hint::consistlightson: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->CompartmentLightsSwitch( true );
occupied->CompartmentLightsSwitchOff( false );
}
@@ -1197,7 +1197,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::consistlightsoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->CompartmentLightsSwitch( false );
occupied->CompartmentLightsSwitchOff( true );
}
@@ -1211,7 +1211,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// consist heating
case driver_hint::consistheatingon: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->HeatingSwitch( true );
}
remove_hint( driver_hint::consistheatingoff );
@@ -1222,7 +1222,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::consistheatingoff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->HeatingSwitch( false );
}
remove_hint( driver_hint::consistheatingon );
@@ -1234,7 +1234,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
case driver_hint::securitysystemreset: {
if (AIControllFlag && occupied->SecuritySystem.is_blinking())
if (aiControlled && occupied->SecuritySystem.is_blinking())
occupied->SecuritySystemReset();
hint(
Action,
@@ -1243,7 +1243,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::shpsystemreset: {
if (AIControllFlag && occupied->SecuritySystem.is_cabsignal_blinking())
if (aiControlled && occupied->SecuritySystem.is_cabsignal_blinking())
occupied->SecuritySystem.cabsignal_reset();
hint(
Action,
@@ -1253,7 +1253,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
case driver_hint::couplingadapterattach: {
// TODO: run also for potential settings-based virtual assistant
if( AIControllFlag ) {
if( aiControlled ) {
pVehicles[ VehicleEnd::front ]->attach_coupler_adapter( EndOf( static_cast<int>(Actionparameter) ) );
}
hint(
@@ -1264,7 +1264,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::couplingadapterremove: {
if( AIControllFlag || Global.AITrainman ) {
if( aiControlled || Global.AITrainman ) {
pVehicles[ VehicleEnd::front ]->remove_coupler_adapter( EndOf( static_cast<int>(Actionparameter) ) );
}
hint(
@@ -1276,7 +1276,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// lights
case driver_hint::headcodepc1: {
if( AIControllFlag ) {
if( aiControlled ) {
pVehicles[ VehicleEnd::front ]->RaLightsSet( light::headlight_left | light::headlight_right | light::headlight_upper, -1 );
}
remove_hint( driver_hint::headcodepc2 );
@@ -1289,7 +1289,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::headcodepc2: {
if( AIControllFlag ) {
if( aiControlled ) {
pVehicles[ VehicleEnd::front ]->RaLightsSet( light::redmarker_left | light::headlight_right | light::headlight_upper, -1 );
}
remove_hint( driver_hint::headcodepc1 );
@@ -1304,7 +1304,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
case driver_hint::headcodetb1: {
// HACK: the 'front' and 'rear' of the consist is determined by current consist direction
// since direction shouldn't affect Tb1 light configuration, we 'counter' this behaviour by virtually swapping end vehicles
if( AIControllFlag ) {
if( aiControlled ) {
if( occupied->DirActive >= 0 ) { Lights( light::headlight_right, light::headlight_left ); }
else { Lights( light::headlight_left, light::headlight_right ); }
}
@@ -1321,7 +1321,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::headcodepc5: {
if( AIControllFlag
if( aiControlled
|| ( Global.AITrainman && false == pVehicles[VehicleEnd::rear]->is_connected(pVehicle, Coupling::control) ) ) {
pVehicles[ VehicleEnd::rear ]->RaLightsSet( -1, light::redmarker_left | light::redmarker_right | light::rearendsignals );
}
@@ -1334,7 +1334,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::lightsoff: {
if( AIControllFlag ) {
if( aiControlled ) {
Lights( 0, 0 );
}
remove_hint( driver_hint::headcodepc1 );
@@ -1351,7 +1351,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// releaser
case driver_hint::releaseron: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->BrakeReleaser( 1 );
}
remove_hint( driver_hint::releaseroff );
@@ -1362,7 +1362,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
break;
}
case driver_hint::releaseroff: {
if( AIControllFlag ) {
if( aiControlled ) {
occupied->BrakeReleaser( 0 );
}
remove_hint( driver_hint::releaseron );
+1 -1
View File
@@ -222,7 +222,7 @@ drivingaid_panel::render_contents() {
auto const *driver = (simulation::Train && simulation::Train->Dynamic()) ? simulation::Train->Dynamic()->Mechanik : nullptr;
if (driver && (false == Global.RealisticControlMode || DebugModeFlag)) {
bool autopilot = driver->AIControllFlag;
bool autopilot = driver->AIControllFlag();
if (ImGui::Checkbox(STR_C("autopilot"), &autopilot)) {
command_relay commandrelay;
commandrelay.post(autopilot ? user_command::aidriverenable : user_command::aidriverdisable, 0.0, 0.0, GLFW_PRESS, 0);
+1 -1
View File
@@ -66,7 +66,7 @@ std::string text_of(std::string_view const Win1250) {
blackbox::driver driver_of(TDynamicObject const &Vehicle) {
if (Vehicle.Mechanik == nullptr)
return blackbox::driver::none;
return Vehicle.Mechanik->AIControllFlag ? blackbox::driver::ai : blackbox::driver::human;
return Vehicle.Mechanik->AIControllFlag() ? blackbox::driver::ai : blackbox::driver::human;
}
// the switches of the user's train: those of its own vehicle, and those of the one with the motors it drives
+1 -1
View File
@@ -312,7 +312,7 @@ void state_manager::process_commands() {
targetvehicle->ctOwner == currentvehicle->Mechanik
|| targetvehicle->ctOwner == currentvehicle->ctOwner };
auto const isincharge{ currentvehicle->Mechanik->primary() };
auto const aidriveractive{ currentvehicle->Mechanik->AIControllFlag };
auto const aidriveractive{ currentvehicle->Mechanik->AIControllFlag() };
// TODO: support for primary mode request passed as commanddata.param1
if( !sameconsist && isincharge ) {
// oddajemy dotychczasowy AI
+54 -9
View File
@@ -254,12 +254,10 @@ struct SandedStart
class TController {
// TBD: few authorized inspectors, or bunch of public getters?
friend class TTrain;
friend class drivingaid_panel;
friend class timetable_panel;
friend class scenario_panel;
friend class debug_panel;
friend class whois_event;
public:
TController( bool AI, TDynamicObject *NewControll, bool InitPsyche, bool primary = true );
@@ -316,6 +314,36 @@ public:
int light_hint( VehicleEnd const End ) const { return m_lighthints[ End ]; }
// the order the driver goes by now: a train run, shunting and the like
DriverOrders order_current() const { return OrderCurrentGet(); }
// the reversers of the consist set as the driver's one, where they went apart
void sync_consist_reversers();
// the stations of the timetable: where the train is among them, how many there are, whether it stops at the next
int StationIndex() const;
int StationCount() const;
bool IsStop() const;
// what the cab shows of the consist the driver leads
BySide<bool> const &ConsistDoorsOpen() const { return IsAnyDoorOpen; }
BySide<bool> const &ConsistDoorsOnlyOpen() const { return IsAnyDoorOnlyOpen; } // the steps not counted
BySide<bool> const &ConsistDoorPermits() const { return IsAnyDoorPermitActive; }
door_closure_t ConsistDoorClosure() const { return DoorClosure; }
bool ConsistConverterOverloaded() const { return IsAnyConverterOverloadRelayOpen; }
bool ConsistCompressorEnabled() const { return IsAnyCompressorEnabled; }
double ConsistLength() const { return fLength; }
int RadioChannel() const { return iRadioChannel; }
void SetRadioChannel( int const Channel ) { iRadioChannel = Channel; }
int Helper() const { return HelperState; }
// what the driver goes by on the route, for the screens of the cab and the events
double DesiredVelocity() const { return VelDesired; }
double RoadVelocity() const { return VelRoad; }
double LastLimitVelocity() const { return VelLimitLast; }
double LastSignalVelocity() const { return VelSignalLast; }
double NextSignalVelocity() const { return VelSignalNext; }
double NextVelocity() const { return VelNext; }
double ProximityDistance() const { return ActualProximityDist; }
bool AtPassengerStop() const { return IsAtPassengerStop; }
// how far the brakes of the consist are released (fReady), the most braked vehicle counting
double BrakesReleaseLevel() const { return fReady; }
// the distance to the obstacle ahead on the track
double TrackObstacle() const;
private:
// tells the black box of the train at the station of its timetable it makes for, at the stop point given
void record_station( TSpeedPos const &Point, std::uint8_t Kind ) const;
@@ -349,7 +377,6 @@ private:
void DirectionForward( bool forward );
void ZeroDirection();
int OrderDirectionChange( int newdir, physics::Vehicle *Vehicle );
void sync_consist_reversers();
void Lights( int head, int rear );
std::string StopReasonText() const;
double BrakeAccFactor() const;
@@ -446,7 +473,30 @@ private:
void cue_action( driver_hint const Action, float const Actionparameter = 0.f );
// members
public:
bool AIControllFlag = false; // rzeczywisty/wirtualny maszynista
// the AI drives, or a human does
bool AIControllFlag() const { return aiControlled; }
// what the overhead line of the track under a vehicle of the consist asks for (TDynamicObject::OverheadTrack()), by the
// bit of that vehicle: below zero the usual running, above it running without current with the pantographs down, zero
// running without current with them up
void MarkOverhead( int const Mask, float const Mode ) {
if( Mode < 0.0 ) { // normalna jazda po tym torze
iOverheadZero &= ~Mask; // zerowanie bitu - może pobierać prąd
iOverheadDown &= ~Mask; // zerowanie bitu - może podnieść pantograf
}
else if( Mode > 0.0 ) { // opuszczenie pantografów
iOverheadZero |= Mask; // ustawienie bitu - ma jechać bez pobierania prądu
iOverheadDown |= Mask; // ustawienie bitu - ma opuścić pantograf
}
else { // jazda bezprądowa z podniesionym pantografem
iOverheadZero |= Mask; // ustawienie bitu - ma jechać bez pobierania prądu
iOverheadDown &= ~Mask; // zerowanie bitu - może podnieść pantograf
}
}
// the most deceleration of the service braking of the consist with the blended brakes, which the driver goes by
double MedAmax() const { return fMedAmax; }
void SetMedAmax( double const Deceleration ) { fMedAmax = Deceleration; }
private:
bool aiControlled = false; // rzeczywisty/wirtualny maszynista
int iOverheadZero = 0; // suma bitowa jezdy bezprądowej, bity ustawiane przez pojazdy z podniesionymi pantografami
int iOverheadDown = 0; // suma bitowa opuszczenia pantografów, bity ustawiane przez pojazdy z podniesionymi pantografami
double BrakeCtrlPosition = 0.0; // intermediate position of main brake controller
@@ -624,8 +674,6 @@ private:
bool point_limit_latched( basic_event const *Cell ) const;
// how far before a point limit the speed is held down to it
double point_limit_approach() const;
// returns most recently calculated distance to potential obstacle ahead
double TrackObstacle() const;
void TablePurger();
void TableSort();
inline double MoveDistanceGet() const {
@@ -685,9 +733,6 @@ public:
Mtable::TTrainParameters const & TrainTimetable() const;
private:
std::string Relation() const;
int StationIndex() const;
int StationCount() const;
bool IsStop() const;
std::string NextStop() const;
// tests whether the train is delayed and sets accordingly a driving flag
void UpdateDelayFlag();
+2 -2
View File
@@ -1043,8 +1043,8 @@ private:
// plays provided sound from position of the radio
bool radio_message_played;
void radio_message( sound_source *Message, int const Channel );
inline auto RadioChannel() const { return Dynamic()->Mechanik ? Dynamic()->Mechanik->iRadioChannel : 1; }
inline auto &RadioChannel() { return Dynamic()->Mechanik->iRadioChannel; }
inline auto RadioChannel() const { return Dynamic()->Mechanik ? Dynamic()->Mechanik->RadioChannel() : 1; }
inline void SetRadioChannel( int const Channel ) { Dynamic()->Mechanik->SetRadioChannel( Channel ); }
inline TDynamicObject *Dynamic() { return DynamicObject; };
inline TDynamicObject const *Dynamic() const { return DynamicObject; };
inline physics::Vehicle *Controlled() { return controlled; };
+13 -13
View File
@@ -158,7 +158,7 @@ void TController::AutoRewident()
// 3. Nastawianie
auto setting{settings.begin()};
for (auto *d = pVehicles[0]; d != nullptr && setting != settings.end(); d = d->Next(), ++setting) {
if (false == AIControllFlag && d == pVehicle) {
if (false == aiControlled && d == pVehicle) {
// don't touch human-controlled vehicle, but others are free game
continue;
}
@@ -173,7 +173,7 @@ void TController::AutoRewident()
}
BrakeReinspectionPending = reinspect;
//ustawianie trybu pracy zadajnika hamulca, wystarczy raz po inicjalizacji AI
if( true == AIControllFlag ) {
if( true == aiControlled ) {
// if a human is in charge leave the brake mode up to them, otherwise do as you like
for( int i = 1; i <= 8; i *= 2 ) {
if( ( occupied->brakes.config.availableOperatingModes & i ) > 0 ) {
@@ -202,7 +202,7 @@ void TController::AutoRewident()
BrakeSystem = consist_brake_system();
// Change the EP fuse state only when AI is in charge, don't fiddle with controls when the user is controlling the vehicle
if (AIControllFlag) {
if (aiControlled) {
occupied->EpFuseSwitch(BrakeSystem == TBrakeSystem::ElectroPneumatic);
}
@@ -394,7 +394,7 @@ bool TController::CheckVehicles(DriverOrders user)
if( p->asDestination == "none" ) {
p->DestinationSet( TrainParams.Relation2, TrainParams.TrainName ); // relacja docelowa, jeśli nie było
}
if( AIControllFlag ) { // jeśli prowadzi komputer
if( aiControlled ) { // jeśli prowadzi komputer
p->RaLightsSet( 0, 0 ); // gasimy światła
}
p = p->Next(); // pojazd podłączony od tyłu (licząc od czoła)
@@ -450,7 +450,7 @@ bool TController::CheckVehicles(DriverOrders user)
// potentially adjust light state
control_lights();
// custom ai action for disconnect mode: switch off lights on disconnected vehicle(s)
if( is_train() && true == OrderCurrentGet().HasAll(DriverOrder::disconnect) && AIControllFlag ) {
if( is_train() && true == OrderCurrentGet().HasAll(DriverOrder::disconnect) && aiControlled ) {
// światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić odczepionego ze światłem
if (occupied->DirActive >= 0)
{ // jak ma kierunek do przodu
@@ -626,7 +626,7 @@ void TController::MoveTo(TDynamicObject *to)
if( to->Mechanik != nullptr
&& to->Mechanik != this ) {
// ai controller thunderdome, there can be only one
if( to->Mechanik->AIControllFlag ) {
if( to->Mechanik->aiControlled ) {
if( to->Mechanik->primary() ) {
// take over boss duties
primary( true );
@@ -635,7 +635,7 @@ void TController::MoveTo(TDynamicObject *to)
}
else {
// can't quite delete a human
if( AIControllFlag ) {
if( aiControlled ) {
delete this;
}
return;
@@ -741,7 +741,7 @@ TController::determine_consist_state() {
}
if( wasready ) {
// Ra: odluźnianie przeładowanych lokomotyw, ciągniętych na zimno - prowizorka...
if( bp >= 0.4 && (AIControllFlag || Global.AITrainman && occupied->Vel < EU07_AI_NOMOVEMENT && !is_emu() && !is_dmu()) && BrakeCtrlPosition == gbh_RP // jest pozycja jazdy
if( bp >= 0.4 && (aiControlled || Global.AITrainman && occupied->Vel < EU07_AI_NOMOVEMENT && !is_emu() && !is_dmu()) && BrakeCtrlPosition == gbh_RP // jest pozycja jazdy
&& false == TestFlag(vehicle->brakes.distributor->GetBrakeStatus(), b_dmg) // brake isn't broken
&& vehicle->brakePipe.Pressure() - occupied->brakes.driverValve->GetRP() > -0.1 // jeśli ciśnienie jak dla jazdy
&& vehicle->brakes.distributor->GetCRP() > vehicle->brakePipe.Pressure() + 0.12 ) { // wg UIC określone sztywno na 0.04
@@ -749,7 +749,7 @@ TController::determine_consist_state() {
// indywidualne luzowanko
vehicle->BrakeReleaser(1);
}
if (bp < 0.1 && (AIControllFlag || Global.AITrainman) && false == TestFlag(vehicle->brakes.distributor->GetBrakeStatus(), b_dmg) // brake isn't broken
if (bp < 0.1 && (aiControlled || Global.AITrainman) && false == TestFlag(vehicle->brakes.distributor->GetBrakeStatus(), b_dmg) // brake isn't broken
&& vehicle->brakes.distributor->GetCRP() < vehicle->brakePipe.Pressure() - 0.1) {
// już nie jest za dużo w zbiorniku
// koniec indywidualnego luzowanka
@@ -885,7 +885,7 @@ TController::determine_consist_state() {
BrakeCharge.going = false;
}
auto const trainbrakeapplied {
AIControllFlag ?
aiControlled ?
BrakeCtrlPosition > 0.0 :
// a human driver's handle, which BrakeCtrlPosition doesn't follow
occupied->brakes.HandlePositionSmooth() > occupied->brakes.driverValve->GetPos( bh_RP ) + 0.2 };
@@ -915,13 +915,13 @@ TController::determine_consist_state() {
IsConsistCharged = true;
BrakeCharge = {};
}
if( AIControllFlag
if( aiControlled
&& ( false == IsConsistCharged )
&& ( false == heldforstart ) ) {
Ready = false;
}
auto const departblocked {
AIControllFlag
aiControlled
&& occupied->Vel < EU07_AI_NOMOVEMENT
&& VelDesired > 0.0
&& ( false == Ready || fReady > 0.4 ) };
@@ -954,5 +954,5 @@ TController::determine_consist_state() {
&& ( false == IsAnyConverterPresent || true == IsAnyConverterEnabled )
&& ( false == IsAnyCompressorPresent || true == IsAnyCompressorEnabled )
// the ai goes back to preparing the engine and switches that converter on, the human driver may run with it off
&& ( false == AIControllFlag || false == islocalconverterswitchoff );
&& ( false == aiControlled || false == islocalconverterswitchoff );
}
+3 -3
View File
@@ -906,7 +906,7 @@ bool TController::BrakeLevelAdd(double b)
// ma dokręcać do bezoporowych i zdejmować pozycje w przypadku przekroczenia prądu
void TController::SpeedSet() {
if( false == AIControllFlag ) { return; }
if( false == aiControlled ) { return; }
switch (occupied->EngineType)
{
@@ -1115,7 +1115,7 @@ void TController::SpeedCntrl(double DesiredSpeed)
void TController::SetTimeControllers()
{
// TBD, TODO: rework this method to use hint system and regardless of driver type
if( false == AIControllFlag || 0 == occupied->CabActive ) { return; }
if( false == aiControlled || 0 == occupied->CabActive ) { return; }
//1. Check the type of Main Brake Handle
if( BrakeSystem == TBrakeSystem::Pneumatic || ForcePNBrake )
@@ -1329,7 +1329,7 @@ void TController::SetTimeControllers()
void TController::CheckTimeControllers()
{
// TODO: rework this method to use hint system and regardless of driver type
if( false == AIControllFlag || 0 == mvControlling->CabActive ) { return; }
if( false == aiControlled || 0 == mvControlling->CabActive ) { return; }
//1. Check the type of Main Brake Handle
if( BrakeSystem == TBrakeSystem::ElectroPneumatic && occupied->brakes.driverValve->TimeEP && !ForcePNBrake )
+1 -1
View File
@@ -186,7 +186,7 @@ TController::control_doors() {
// HACK: crude way to deal with automatic door opening on W4 preventing further ride
// for human-controlled vehicles with no door control and dynamic brake auto-activating with door open
// TODO: check if this situation still happens and the hack is still needed
if( false == AIControllFlag && (mvControlling->EngineType == TEngineType::DieselEngine ? mvControlling->RList[mvControlling->MainCtrlPos()].Mn > 0 : mvControlling->MainCtrlPowerPos() > 0) ) {
if( false == aiControlled && (mvControlling->EngineType == TEngineType::DieselEngine ? mvControlling->RList[mvControlling->MainCtrlPos()].Mn > 0 : mvControlling->MainCtrlPowerPos() > 0) ) {
// for diesel engines react when engine is put past idle revolutions
// for others straightforward master controller check
Doors(false);
+6 -6
View File
@@ -55,7 +55,7 @@ bool WriteLogFlag = false;
//---------------------------------------------------------------------------
TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, bool Primary) :// czy ma aktywnie prowadzić?
AIControllFlag( AI ), pVehicle( NewControll )
aiControlled( AI ), pVehicle( NewControll )
{
if( pVehicle != nullptr ) {
pVehicles[ VehicleEnd::front ] = pVehicle->GetFirstDynamic( VehicleEnd::front ); // pierwszy w kierunku jazdy (Np. Pc1)
@@ -388,15 +388,15 @@ TController::Update( double const Timedelta ) {
void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck )
{ // przejęcie kontroli przez AI albo oddanie
if (AIControllFlag == Aidriver && !Forcevehiclecheck)
if (aiControlled == Aidriver && !Forcevehiclecheck)
return; // już jest jak ma być
if( AIControllFlag != Aidriver ) {
if( aiControlled != Aidriver ) {
// the autopilot switched on or off
simulation::Blackbox.driver_changed( pVehicle, Aidriver );
}
if (Aidriver) //żeby nie wykonywać dwa razy
{ // teraz AI prowadzi
AIControllFlag = AIdriver;
aiControlled = AIdriver;
pVehicle->Controller = AIdriver;
// the AI doesn't operate the headlight dimmer, drop the state left by the human driver
// so the lights set by the AI aren't hidden (dimmer in off position) or dimmed
@@ -443,7 +443,7 @@ void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck
{ // a teraz użytkownik
if (eAction == TAction::actSleep || OrderCurrentGet() == DriverOrder::waitForOrders) // gasimy swiatla jesli przejmujemy odstawione
pVehicle->RaLightsSet(0, 0);
auto const aiwasdriving { AIControllFlag == AIdriver };
auto const aiwasdriving { aiControlled == AIdriver };
if( aiwasdriving ) {
// the horn, sandbox, departure signal and brake releaser the AI may have latched are momentary for the human driver
handover::release_ai_controls( *occupied, *mvControlling );
@@ -452,7 +452,7 @@ void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck
// the AI sets the lights directly, leave the selector in matching position so it doesn't revert them later
sync_lights_selector();
}
AIControllFlag = Humandriver;
aiControlled = Humandriver;
pVehicle->Controller = Humandriver;
if( aiwasdriving ) {
// same with the headlight dimmer, which is only applied for the human driver
+2 -2
View File
@@ -252,7 +252,7 @@ TController::report_power_stall( bool const Poweravailable, double const Pantogr
}
}
// a user driving the vehicle sees the voltmeters for themselves
if( auto const stall { m_powerstall.update( AIControllFlag ? ai_power::check( state ) : ai_power::stall::waiting, ElapsedTime ) };
if( auto const stall { m_powerstall.update( aiControlled ? ai_power::check( state ) : ai_power::stall::waiting, ElapsedTime ) };
stall.has_value() ) {
ErrorLog( ai_power::message( *stall, pVehicle->asName, pVehicle->GetPosition() ), logtype::traction );
}
@@ -264,7 +264,7 @@ bool TController::ReleaseEngine() {
if( occupied->Vel > 0.01 ) {
VelDesired = 0.0;
AccDesired = std::min( AccDesired, -1.25 ); // hamuj solidnie
if( true == AIControllFlag ) {
if( true == aiControlled ) {
// TBD, TODO: make a dedicated braking procedure out of it for potential reuse
ZeroSpeed();
IncBrake();
+3 -3
View File
@@ -105,7 +105,7 @@ TController::control_tractive_and_braking_force() {
// PrepareEngine(). a diesel-electric with AutoRelay=Optional alone is left as before, shunting by hand with the switch off
void TController::control_field_shunting() {
if( AIControllFlag
if( aiControlled
&& mvControlling->EngineType == TEngineType::DieselElectric
&& fieldshunting::has_switch( mvControlling->AutoRelayType, mvControlling->FieldShuntSwitch )
&& false == mvControlling->AutoRelayFlag ) {
@@ -329,7 +329,7 @@ void TController::secure_standing_train() {
// the first service position: the pipe and the reservoirs charge to a little below the working pressure, the
// distributors keep a light application. a stronger application already there is left as it is, but not
// the emergency one or an empty pipe's, which don't charge
if( AIControllFlag
if( aiControlled
&& ( ( BrakeCtrlPosition < 1.0 ) || ( BrakeCtrlPosition > uphill_start::top_up_position ) ) ) {
BrakeLevelSet( 1.0 );
}
@@ -518,7 +518,7 @@ void TController::control_braking_force() {
&& accdesiredresultant - fBrake_a1[0] * 0.51 - AbsAccS > 0.05 && OrderCurrentGet() != DriverOrder::disconnect && VelDesired > 0.0
// a human driver standing with the train not charged yet keeps the locomotive brake on, told so by the
// waitbrakecharge hint; the ai is held back in DecBrake()
&& ( AIControllFlag
&& ( aiControlled
|| ( false == brake_charge::release_waits(
IsConsistCharged,
occupied->Vel < EU07_AI_NOMOVEMENT,
+8 -8
View File
@@ -221,7 +221,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
else
{ // inicjacja pierwszego przystanku i pobranie jego nazwy
// HACK: clear the potentially set door state flag to ensure door get opened if applicable
if( true == AIControllFlag ) {
if( true == aiControlled ) {
// simplified door closing procedure, to sync actual door state with the door state flag
// NOTE: this may result in visually ugly quick switch between closing and opening the doors, but eh
if( pVehicle->physics->Doors.close_control == control_t::driver
@@ -293,7 +293,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
if (NewValue1<0) //dla ujemnej prędkości
iDirectionOrder=-iDirectionOrder; //ma jechać w drugą stronę
*/
if (AIControllFlag) // jeśli prowadzi komputer
if (aiControlled) // jeśli prowadzi komputer
Activation(); // umieszczenie obsługi we właściwym członie, ustawienie nawrotnika w
// przód
}
@@ -582,7 +582,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
// wybór kanału radiowego (którego powinien używać AI, ręczny maszynista musi go ustawić sam)
if (NewValue1 >= 0) {
// wartości ujemne są zarezerwowane, -1 = nie zmieniać kanału
if( AIControllFlag ) {
if( aiControlled ) {
iRadioChannel = NewValue1;
}
if( iGuardRadio ) {
@@ -881,7 +881,7 @@ TController::UpdateChangeDirection() {
// TODO: rework into driver mode independent routine
if( false == OrderCurrentGet().HasAll(DriverOrder::changeDirection) ) { return; }
if( true == AIControllFlag && occupied->Vel < EU07_AI_NOMOVEMENT ) {
if( true == aiControlled && occupied->Vel < EU07_AI_NOMOVEMENT ) {
// sprobuj zmienic kierunek (może być zmieszane z jeszcze jakąś komendą)
// jeśli się zatrzymał, to zmieniamy kierunek jazdy, a nawet kabinę/człon
Activation(); // ustawienie zadanego wcześniej kierunku i ewentualne przemieszczenie AI
@@ -910,7 +910,7 @@ void
TController::UpdateLooseShunt() {
// when loose shunting try to detect situations where engaged brakes in a consist to be pushed prevent movement
// TODO: run also for potential settings-based virtual assistant
auto const autobrakerelease { ( true == AIControllFlag ) };
auto const autobrakerelease { ( true == aiControlled ) };
if( autobrakerelease
&& Obstacle.distance < 1.0
@@ -1002,7 +1002,7 @@ TController::UpdateConnect() {
}
}
// próba podczepienia
if ((AIControllFlag || Global.AITrainman) && coupleriscompatible && neighbour.distance < 2)
if ((aiControlled || Global.AITrainman) && coupleriscompatible && neighbour.distance < 2)
{
vehicleparameters->Attach(couplingend, neighbour.vehicle_end, neighbour.vehicle->physics, iCoupler);
}
@@ -1058,7 +1058,7 @@ TController::UpdateDisconnect() {
if( iVehicleCount >= 0 ) {
// early test for human drivers, who might disregard the proper procedure, or perform it before they receive the order to
if( false == AIControllFlag && unit_count(iVehicleCount + 2) <= iVehicleCount + 1 ) {
if( false == aiControlled && unit_count(iVehicleCount + 2) <= iVehicleCount + 1 ) {
// iVehicleCount = 0 means the consist should be reduced to (1) leading unit, thus we increase our test values by 1
iVehicleCount = -2; // odczepiono, co było do odczepienia
return; // we'll wrap up the procedure on the next update beat
@@ -1106,7 +1106,7 @@ TController::UpdateDisconnect() {
iVehicleCount = -2; // odczepiono, co było do odczepienia
}
else {
if( AIControllFlag || Global.AITrainman ) {
if( aiControlled || Global.AITrainman ) {
decoupledvehicle->Dettach( decoupledend );
}
// tylko jeśli odepnie
+2 -2
View File
@@ -339,7 +339,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
/*
// NOTE: manual selection disabled due to multiplayer
int routewanted;
if( false == AIControllFlag ) {
if( false == aiControlled ) {
routewanted = (
input::keys[ GLFW_KEY_LEFT ] != GLFW_RELEASE ? 1 :
input::keys[ GLFW_KEY_RIGHT ] != GLFW_RELEASE ? 2 :
@@ -363,7 +363,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
fLastDir = -fLastDir;
}
/*
if (AIControllFlag) {
if (aiControlled) {
// dla AI na razie losujemy kierunek na kolejnym skrzyżowaniu
iRouteWanted = 1 + Random(3);
}
+2 -2
View File
@@ -511,7 +511,7 @@ TController::control_lights() {
}
else {
// custom light pattern
if( AIControllFlag ) {
if( aiControlled ) {
pVehicles[ VehicleEnd::front ]->RaLightsSet( m_lighthints[ VehicleEnd::front ], -1 );
}
}
@@ -520,7 +520,7 @@ TController::control_lights() {
cue_action( driver_hint::headcodepc5 );
}
else {
if( AIControllFlag ) {
if( aiControlled ) {
pVehicles[ VehicleEnd::rear ]->RaLightsSet( -1, m_lighthints[ VehicleEnd::rear ] );
}
}
+1 -1
View File
@@ -823,7 +823,7 @@ TController::adjust_desired_speed_for_braking_test() {
if( false == is_train() ) { return; } // not applicable
if( occupied->brakes.config.driverValveType == TBrakeHandle::FVel6 ) { return; } // leads to bugs in DecBrake, disable for now
if( false == OrderCurrentGet().HasAll(DriverOrder::obeyTrain) ) { return; } // not applicable
if( false == AIControllFlag ) { return; } // TBD: add notification about braking test and enable it for human driver as well?
if( false == aiControlled ) { return; } // TBD: add notification about braking test and enable it for human driver as well?
auto const vel { DirectionalVel() };
// what the route ahead asks for; the test may brake harder than that, never softer
+5 -5
View File
@@ -401,7 +401,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub
}
}
// for human-driven vehicles discard the stop point if they leave it far enough behind
if( false == AIControllFlag
if( false == aiControlled
&& Point.fDist < -1 * std::max(fLength + 100, 250.0) - Point.fMoved ) {
record_station( Point, blackbox::station_kinds::missed );
Point.ResetFlags(); // nie liczy się już zupełnie (nie wyśle SetVelocity)
@@ -438,7 +438,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub
}
} else if( true == IsAtPassengerStop ) {
// jeśli się zatrzymał przy W4, albo stał w momencie zobaczenia W4
if( !AIControllFlag ) {
if( !aiControlled ) {
// w razie przełączenia na AI ma nie podciągać do W4, gdy użytkownik zatrzymał za daleko
drivingFlags.stopCloser = false;
}
@@ -950,7 +950,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo
// NOTE: normally we'd activate the magnet once the leading vehicle passes it
// but on a fresh scan after direction change it would be detected as long as it's under consist, and meet the (simple) activation condition
// thus we're doing a more precise check in such situation (we presume direction change takes place only if the vehicle is standing still)
occupied->SecuritySystem.set_cabsignal_lock(!AIControllFlag); // don't make life difficult for the ai, but a human driver is a fair game
occupied->SecuritySystem.set_cabsignal_lock(!aiControlled); // don't make life difficult for the ai, but a human driver is a fair game
PutCommand(Point.evEvent->input_text(), Point.evEvent->input_value(1), Point.evEvent->input_value(2), nullptr);
}
if( ismagnetpassed ) {
@@ -1060,7 +1060,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo
{ // to semaphor
if( Point.fDist < 0 ) {
// for human-driven vehicles ignore the signal if it was passed by sufficient distance
if( false == AIControllFlag
if( false == aiControlled
&& Point.fDist < -1 * std::max(fLength + 100, 250.0) ) {
VelSignal = -1.0;
Point.Clear();
@@ -1248,7 +1248,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo
Command = TCommandType::cm_Command; // komenda z komórki, do wykonania po zatrzymaniu
}
// NOTE: human drivers are likely to stop wherever and expect things to still work, so we give them more leeway
else if (Point.fDist <= (AIControllFlag ? fMaxProximityDist : std::max(250.0, fMaxProximityDist)))
else if (Point.fDist <= (aiControlled ? fMaxProximityDist : std::max(250.0, fMaxProximityDist)))
{
// jeśli ma dociągnąć, to niech dociąga
// (moveStopCloser dotyczy dociągania do W4, nie semafora)
+2 -2
View File
@@ -682,7 +682,7 @@ void TTrain::OnCommand_convertertoggle(TTrain *Train, command_data const &Comman
if (Command.action == GLFW_PRESS)
{
// only reacting to press, so the switch doesn't flip back and forth if key is held down
auto const overloadrelayisopen{(Train->Dynamic()->Mechanik != nullptr ? Train->Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : Train->occupied->converter.IsOverloaded())};
auto const overloadrelayisopen{(Train->Dynamic()->Mechanik != nullptr ? Train->Dynamic()->Mechanik->ConsistConverterOverloaded() : Train->occupied->converter.IsOverloaded())};
if (Train->occupied->converter.config.switchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->occupied->lowVoltage.Is110vAvailable() && false == overloadrelayisopen)
{
@@ -843,7 +843,7 @@ void TTrain::OnCommand_compressortoggle(TTrain *Train, command_data const &Comma
if (Command.action == GLFW_PRESS)
{
// only reacting to press, so the switch doesn't flip back and forth if key is held down
auto const compressorisenabled{(Train->Dynamic()->Mechanik ? Train->Dynamic()->Mechanik->IsAnyCompressorEnabled : Train->occupied->air.compressor.IsAllowed())};
auto const compressorisenabled{(Train->Dynamic()->Mechanik ? Train->Dynamic()->Mechanik->ConsistCompressorEnabled() : Train->occupied->air.compressor.IsAllowed())};
if (false == compressorisenabled)
{
+1 -1
View File
@@ -59,7 +59,7 @@ void TTrain::OnCommand_aidriverenable(TTrain *Train, command_data const &Command
return;
}
if (true == Train->DynamicObject->Mechanik->AIControllFlag)
if (true == Train->DynamicObject->Mechanik->AIControllFlag())
{
// żeby nie trzeba było rozłączać dla zresetowania
Train->DynamicObject->Mechanik->TakeControl(false);
+1 -1
View File
@@ -932,7 +932,7 @@ void TTrain::set_cab_controls(int const Cab)
// motor connectors
ggStLinOffButton.PutValue(controlled->lineContactors.IsForcedOpen() ? 1.f : 0.f);
// radio
ggRadioChannelSelector.PutValue(static_cast<float>((Dynamic()->Mechanik ? Dynamic()->Mechanik->iRadioChannel : 1) - 1));
ggRadioChannelSelector.PutValue(static_cast<float>((Dynamic()->Mechanik ? Dynamic()->Mechanik->RadioChannel() : 1) - 1));
// pantographs
/*
if( occupied->PantSwitchType != "impulse" ) {
+1 -1
View File
@@ -310,7 +310,7 @@ void TTrain::OnCommand_radiochannelset(TTrain *Train, command_data const &Comman
if (Command.action != GLFW_RELEASE)
{
// on press or hold
Train->RadioChannel() = std::clamp((int)Command.param1, 1, 10);
Train->SetRadioChannel(std::clamp((int)Command.param1, 1, 10));
Train->ggRadioChannelSelector.UpdateValue(static_cast<float>(Train->RadioChannel() - 1));
}
}
+1 -1
View File
@@ -389,7 +389,7 @@ void TTrain::update_sounds(double const Deltatime)
if (m_distancecounterclear)
{
auto const *owner{(DynamicObject->ctOwner != nullptr ? DynamicObject->ctOwner : DynamicObject->Mechanik)};
if (m_distancecounter > owner->fLength)
if (m_distancecounter > owner->ConsistLength())
{
// play assigned sound if the train travelled its full length since meter activation
// TBD: check all combinations of directions and active cab
+16 -16
View File
@@ -146,7 +146,7 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d)
controlled->DirectionBackward();
}
*/
if (false == DynamicObject->Mechanik->AIControllFlag)
if (false == DynamicObject->Mechanik->AIControllFlag())
{
DynamicObject->Mechanik->sync_consist_reversers();
}
@@ -364,17 +364,17 @@ std::shared_ptr<dictionary_source> TTrain::GetTrainState(dictionary_source const
// ai state data
auto const *vehicledriver{(DynamicObject->ctOwner != nullptr ? DynamicObject->ctOwner : DynamicObject->Mechanik)};
dict->insert("velocity_desired", vehicledriver->VelDesired);
dict->insert("velroad", vehicledriver->VelRoad);
dict->insert("vellimitlast", vehicledriver->VelLimitLast);
dict->insert("velsignallast", vehicledriver->VelSignalLast);
dict->insert("velsignalnext", vehicledriver->VelSignalNext);
dict->insert("velnext", vehicledriver->VelNext);
dict->insert("actualproximitydist", vehicledriver->ActualProximityDist);
dict->insert("velocity_desired", vehicledriver->DesiredVelocity());
dict->insert("velroad", vehicledriver->RoadVelocity());
dict->insert("vellimitlast", vehicledriver->LastLimitVelocity());
dict->insert("velsignallast", vehicledriver->LastSignalVelocity());
dict->insert("velsignalnext", vehicledriver->NextSignalVelocity());
dict->insert("velnext", vehicledriver->NextVelocity());
dict->insert("actualproximitydist", vehicledriver->ProximityDistance());
// train data
vehicledriver->TrainTimetable().serialize(dict.get());
dict->insert("train_atpassengerstop", vehicledriver->IsAtPassengerStop);
dict->insert("train_length", vehicledriver->fLength);
dict->insert("train_atpassengerstop", vehicledriver->AtPassengerStop());
dict->insert("train_length", vehicledriver->ConsistLength());
// world state data
dict->insert("scenario", Global.SceneryFile);
dict->insert("hours", static_cast<int>(simulation::Time.data().wHour));
@@ -550,7 +550,7 @@ void TTrain::UpdateCab()
// Ra: przesiadka, jeśli AI zmieniło kabinę (a człon?)...
if (DynamicObject->Mechanik // może nie być?
&& DynamicObject->Mechanik->AIControllFlag && iCabn != ( // numer kabiny (-1: kabina B)
&& DynamicObject->Mechanik->AIControllFlag() && iCabn != ( // numer kabiny (-1: kabina B)
occupied->CabOccupied() == -1 ? 2 : occupied->CabOccupied()))
{
@@ -576,7 +576,7 @@ void TTrain::add_distance(double const Distance)
bool TTrain::CabChange(int iDirection)
{ // McZapkie-090902: zmiana kabiny 1->0->2 i z powrotem
if (DynamicObject->Mechanik == nullptr || true == DynamicObject->Mechanik->AIControllFlag)
if (DynamicObject->Mechanik == nullptr || true == DynamicObject->Mechanik->AIControllFlag())
{
// jeśli prowadzi AI albo jest w innym członie
// jak AI prowadzi, to nie można mu mieszać
@@ -659,7 +659,7 @@ void TTrain::MoveToVehicle(TDynamicObject *target)
{
// let's try to destroy this TTrain and move to already existing one
if (!Dynamic()->Mechanik || !Dynamic()->Mechanik->AIControllFlag)
if (!Dynamic()->Mechanik || !Dynamic()->Mechanik->AIControllFlag())
{
// tylko jeśli ręcznie prowadzony
// jeśli prowadzi AI, to mu nie robimy dywersji!
@@ -682,7 +682,7 @@ void TTrain::MoveToVehicle(TDynamicObject *target)
target_train->Dynamic()->MechInside = true;
if (target_train->Dynamic()->Mechanik)
{
target_train->Dynamic()->Controller = target_train->Dynamic()->Mechanik->AIControllFlag;
target_train->Dynamic()->Controller = target_train->Dynamic()->Mechanik->AIControllFlag();
target_train->Dynamic()->Mechanik->DirectionChange();
}
else
@@ -716,7 +716,7 @@ void TTrain::MoveToVehicle(TDynamicObject *target)
// remove TTrain from global list, we're going to change dynamic anyway
simulation::Trains.detach(Dynamic()->name());
if (!Dynamic()->Mechanik || !Dynamic()->Mechanik->AIControllFlag)
if (!Dynamic()->Mechanik || !Dynamic()->Mechanik->AIControllFlag())
{
// tylko jeśli ręcznie prowadzony
// jeśli prowadzi AI, to mu nie robimy dywersji!
@@ -740,7 +740,7 @@ void TTrain::MoveToVehicle(TDynamicObject *target)
Dynamic()->MechInside = true;
if (Dynamic()->Mechanik)
{
Dynamic()->Controller = Dynamic()->Mechanik->AIControllFlag;
Dynamic()->Controller = Dynamic()->Mechanik->AIControllFlag();
Dynamic()->Mechanik->DirectionChange();
}
else
+16 -16
View File
@@ -242,16 +242,16 @@ void TTrain::updateDoorAndDirectionStates()
// helper variables
if (DynamicObject->Mechanik != nullptr)
{
m_doors = DynamicObject->Mechanik->IsAnyDoorOpen[VehicleSide::right] || DynamicObject->Mechanik->IsAnyDoorOpen[VehicleSide::left];
m_doorpermits = DynamicObject->Mechanik->IsAnyDoorPermitActive[VehicleSide::right] || DynamicObject->Mechanik->IsAnyDoorPermitActive[VehicleSide::left];
m_doors = DynamicObject->Mechanik->ConsistDoorsOpen()[VehicleSide::right] || DynamicObject->Mechanik->ConsistDoorsOpen()[VehicleSide::left];
m_doorpermits = DynamicObject->Mechanik->ConsistDoorPermits()[VehicleSide::right] || DynamicObject->Mechanik->ConsistDoorPermits()[VehicleSide::left];
m_doorspermitleft = occupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right].open_permit &&
(simulation::Time.data().wSecond % 2 < 1 || occupied->DoorsPermitLightBlinking < 1 ||
occupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right] ||
(occupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right]));
occupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->ConsistDoorsOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right] ||
(occupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->ConsistDoorsOnlyOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right]));
m_doorspermitright = occupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left].open_permit &&
(simulation::Time.data().wSecond % 2 < 1 || occupied->DoorsPermitLightBlinking < 1 ||
occupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left] ||
(occupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left]));
occupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->ConsistDoorsOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left] ||
(occupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->ConsistDoorsOnlyOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left]));
}
m_dirforward = controlled->DirActive > 0;
m_dirneutral = controlled->DirActive == 0;
@@ -288,7 +288,7 @@ void TTrain::processReceivedCommands()
void TTrain::returnMasterController(double const Deltatime)
{
// nie blokujemy AI
if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag && (occupied->TrainType == train_type::et40 || occupied->TrainType == train_type::ep05 || occupied->HasCamshaft))
if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag() && (occupied->TrainType == train_type::et40 || occupied->TrainType == train_type::ep05 || occupied->HasCamshaft))
{
// dla ET40 i EU05 automatyczne cofanie nastawnika - i tak nie będzie to działać dobrze...
// TODO: use deltatime to stabilize speed
@@ -609,7 +609,7 @@ void TTrain::updateConverterOverload(double const Deltatime)
fConverterTimer += static_cast<float>(Deltatime);
if (controlled->air.compressor.IsRunning() == true && controlled->air.compressor.config.supply == physics::CompressorSupply::converterManual && (controlled->EngineType == TEngineType::ElectricSeriesMotor || controlled->TrainType == train_type::emu) &&
DynamicObject->Controller == Humandriver // hunter-110212: poprawka dla EZT
&& DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag)
&& DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag())
{ // hunter-091012: poprawka (zmiana warunku z CompressorPower /rozne od 0/ na /rowne 1/)
if (fConverterTimer < fConverterPrzekaznik)
{
@@ -834,7 +834,7 @@ void TTrain::updateCircuitLamps(double const Deltatime)
btLampkaPrzetw.Turn(occupied->lowVoltage.Is110vAvailable());
btLampkaPrzetwOff.Turn(!occupied->lowVoltage.Is110vAvailable());
btLampkaPrzetwAOff.Turn(!controlled->converter.IsRunning());
btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : controlled->converter.IsOverloaded());
btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->ConsistConverterOverloaded() : controlled->converter.IsOverloaded());
btLampkaOpory.Turn(controlled->lineContactors.IsClosed() && controlled->ResistorsFlagCheck());
btLampkaBezoporowa.Turn(controlled->ResistorsFlagCheck() || controlled->MainCtrlActualPos == 0); // do EU04
@@ -924,15 +924,15 @@ void TTrain::updateTrainLamps()
// NBMX wrzesien 2003 - drzwi oraz sygnał odjazdu
if (DynamicObject->Mechanik != nullptr)
{
btLampkaDoorLeft.Turn(DynamicObject->Mechanik->IsAnyDoorOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right]);
btLampkaDoorRight.Turn(DynamicObject->Mechanik->IsAnyDoorOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left]);
btLampkaDoorLeft.Turn(DynamicObject->Mechanik->ConsistDoorsOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right]);
btLampkaDoorRight.Turn(DynamicObject->Mechanik->ConsistDoorsOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left]);
}
if (DynamicObject->Mechanik != nullptr)
{
// with DoorClosureSignal in the definition of the cab's vehicle, the door closure signalling (SOD) of the whole
// consist: lit with all doors closed and locked, blinking with them closed but released, dark with a door open.
// without it, the lock of the vehicle's own doors, as before
btLampkaBlokadaDrzwi.Turn(occupied->door_closure_lamp_lit(DynamicObject->Mechanik->DoorClosure, simulation::Time.data().wSecond % 2 < 1));
btLampkaBlokadaDrzwi.Turn(occupied->door_closure_lamp_lit(DynamicObject->Mechanik->ConsistDoorClosure(), simulation::Time.data().wSecond % 2 < 1));
}
else
{
@@ -1203,7 +1203,7 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower)
{
#ifdef _WIN32
if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag // nie blokujemy AI
if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag() // nie blokujemy AI
&& Global.iFeedbackMode == 4 && Global.fCalibrateIn[2][1] != 0.0)
{
@@ -1272,7 +1272,7 @@ void TTrain::updateBrakeControllers()
if (ggBrakeCtrl.SubModel != nullptr)
{
#ifdef _WIN32
if (DynamicObject->Mechanik ? (DynamicObject->Mechanik->AIControllFlag ? false : Global.iFeedbackMode == 4 /*|| (Global.bMWDmasterEnable && Global.bMWDBreakEnable)*/) :
if (DynamicObject->Mechanik ? (DynamicObject->Mechanik->AIControllFlag() ? false : Global.iFeedbackMode == 4 /*|| (Global.bMWDmasterEnable && Global.bMWDBreakEnable)*/) :
false && Global.fCalibrateIn[0][1] != 0.0) // nie blokujemy AI
{ // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba
// Firleju: dlatego kasujemy i zastepujemy funkcją w Console
@@ -1314,7 +1314,7 @@ void TTrain::updateBrakeControllers()
if (ggLocalBrake.SubModel != nullptr)
{
#ifdef _WIN32
if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag // nie blokujemy AI
if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag() // nie blokujemy AI
&& occupied->brakes.config.independentValveType == TBrakeHandle::FD1 && Global.iFeedbackMode == 4 && Global.fCalibrateIn[0][1] != 0.0)
{
// Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba
@@ -1498,7 +1498,7 @@ void TTrain::updateAuxiliaryButtons(bool const lowvoltagepower)
ggWhistleButton.Update();
if (DynamicObject->Mechanik != nullptr)
{
ggHelperButton.UpdateValue(static_cast<float>(DynamicObject->Mechanik->HelperState));
ggHelperButton.UpdateValue(static_cast<float>(DynamicObject->Mechanik->Helper()));
}
ggHelperButton.Update();
+1 -1
View File
@@ -59,7 +59,7 @@ vehicle_state state_of(TDynamicObject &Vehicle) {
// to tell by, and each of them is driven from its own seat
state.has_cab = Vehicle.physics->HasDriverCab() || Vehicle.physics->CategoryFlag != rail_category;
state.has_driver = Vehicle.Mechanik != nullptr;
state.driver_is_ai = state.has_driver && Vehicle.Mechanik->AIControllFlag;
state.driver_is_ai = state.has_driver && Vehicle.Mechanik->AIControllFlag();
// a cab of the game is bound to the vehicle: the user's own, or another user's in a network game. the cab
// reads the driver of its vehicle all the time, so that driver stays
state.occupied = simulation::Trains.find(Vehicle.name()) != nullptr;
+4 -18
View File
@@ -337,8 +337,8 @@ void TDynamicObject::distributeInductionBraking( double const dt1 )
}
physics::ConsistBrakeBlending::Inputs inputs;
inputs.owner = ctOwner != nullptr ? ctOwner->Controlling() : nullptr;
inputs.aiDriving = Mechanik->AIControllFlag;
Mechanik->fMedAmax = brakeBlending.Update( *physics, consist, inputs, dt1 );
inputs.aiDriving = Mechanik->AIControllFlag();
Mechanik->SetMedAmax(brakeBlending.Update( *physics, consist, inputs, dt1 ));
}
// the main switch off, with the supply of the vehicle's circuits off, but for diesel engines and hand cars
@@ -1099,7 +1099,7 @@ void TDynamicObject::RadioStop()
Mechanik->PutCommand( "Emergency_brake", 1.0, 1.0, &pos, stopRadio );
// add onscreen notification for human driver
// TODO: do it selectively for the 'local' driver once the multiplayer is in
if( false == Mechanik->AIControllFlag ) {
if( false == Mechanik->AIControllFlag() ) {
ui::Transcripts.AddLine( "!! RADIO-STOP !!", 0.0, 10.0, false );
}
}
@@ -1119,20 +1119,6 @@ void TDynamicObject::OverheadTrack(float o)
// w torze
if (ctOwner) // jeśli ma obiekt nadzorujący
{ // trzeba zaktualizować mapę flag bitowych jazdy bezprądowej
if (o < 0.0)
{ // normalna jazda po tym torze
ctOwner->iOverheadZero &= ~iOverheadMask; // zerowanie bitu - może pobierać prąd
ctOwner->iOverheadDown &= ~iOverheadMask; // zerowanie bitu - może podnieść pantograf
}
else if (o > 0.0)
{ // opuszczenie pantografów
ctOwner->iOverheadZero |= iOverheadMask; // ustawienie bitu - ma jechać bez pobierania prądu
ctOwner->iOverheadDown |= iOverheadMask; // ustawienie bitu - ma opuścić pantograf
}
else
{ // jazda bezprądowa z podniesionym pantografem
ctOwner->iOverheadZero |= iOverheadMask; // ustawienie bitu - ma jechać bez pobierania prądu
ctOwner->iOverheadDown &= ~iOverheadMask; // zerowanie bitu - może podnieść pantograf
}
ctOwner->MarkOverhead( iOverheadMask, o );
}
};
+1 -1
View File
@@ -235,7 +235,7 @@ vehicle_table::update( double Deltatime, int Iterationcount ) {
if( false == vehicle->bEnabled ) { continue; }
++counts.enabled;
if( vehicle->physics->CategoryFlag & 2 ) { ++counts.road; }
if( ( vehicle->Mechanik != nullptr ) && vehicle->Mechanik->AIControllFlag ) { ++counts.ai; }
if( ( vehicle->Mechanik != nullptr ) && vehicle->Mechanik->AIControllFlag() ) { ++counts.ai; }
if( vehicle->physics->PhysicActivation || vehicle->MechInside ) { ++counts.active; }
}
+1 -1
View File
@@ -430,7 +430,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
auto const followsdirection {
Global.DriverFigureFollowsDirection
&& SingleDesk
&& false == Mechanik->AIControllFlag };
&& false == Mechanik->AIControllFlag() };
auto const figure { driver_figure::shown( physics->CabOccupied(), physics->DirAbsolute, followsdirection ) };
btMechanik1.Turn( figure > 0 );
btMechanik2.Turn( figure < 0 );
+1 -1
View File
@@ -1042,7 +1042,7 @@ whois_event::run_() {
m_activator->ctOwner ) };
auto const consistbrakelevel { (
owner != nullptr ?
owner->fReady :
owner->BrakesReleaseLevel() :
-1.0 ) };
auto const collisiondistance { (
owner != nullptr ?