diff --git a/physics/components/devices.h b/physics/components/devices.h index f032bd84a..1b76e2971 100644 --- a/physics/components/devices.h +++ b/physics/components/devices.h @@ -132,7 +132,6 @@ struct basic_pantograph basic_valve valve; // associated pneumatic valve // ld outputs bool is_active{false}; // device is working - bool sound_event{false}; // indicates last state which generated sound event double voltage{0.0}; }; diff --git a/physics/vehicle.h b/physics/vehicle.h index bf1f66bcb..4d6cc4277 100644 --- a/physics/vehicle.h +++ b/physics/vehicle.h @@ -1710,6 +1710,26 @@ class Vehicle void FuseOff(void); // wylaczenie nadmiarowego // the faults of the equipment the scenery or the network sets: each sets its fault, or clears it where it was set void SetEquipmentFaults(EquipmentFaultSet Faults); + // the stabiliser of the brake pipe set to the pressure the pipe has, as a driver taking over a cab finds it + void ResetPipeStabiliser() + { + brakes.pipeLimiterPressure = brakePipe.Pressure(); + actFlowSpeed = 0; + } + // the spring brake released by hand, without the command to the other vehicles (SpringBrakeActivate()) + void ReleaseSpringBrake() { brakes.spring.activate = false; } + // the mode of the brake (bom_*: PS/PN/EP/MED) set at the selector + void SetBrakeOperatingMode(int const Mode) { brakes.operatingMode = Mode; } + // the brake cut out or put back by the player, which the AI's wagon inspector no longer puts back on its own + void ClaimBrakeCutOut() { brakes.cutOutByInspector = false; } + // the pressure of the brake pipe of the consist, as the driver's vehicle measures it + void SetEquivalentPipePressure(double const Pressure) { brakes.equivalentPipePressure = Pressure; } + // the inverters of an induction motor drive, switched in and out from the cab + bool InverterActivated(std::size_t const Index) const { return inductionMotor.inverters[Index].Activate; } + void SwitchInverter(std::size_t const Index, bool const State) { inductionMotor.inverters[Index].Activate = State; } + // the distance run, kept between the sessions, and whether a cab shows it + void SetOdometer(odometer::reading const &Reading) { Odometer = Reading; } + void ShowOdometer() { Odometer.shown = true; } bool UniversalResetButton(int const Button, range_t const Notify = range_t::consist); bool RelayReset(int const Relays, range_t const Notify = range_t::consist); // resets specified relays // the drive of the kind of engine of the vehicle (physics/components/drive.h) diff --git a/vehicle/DynObj.h b/vehicle/DynObj.h index 4566e17f0..5e1f86745 100644 --- a/vehicle/DynObj.h +++ b/vehicle/DynObj.h @@ -1046,6 +1046,8 @@ public: // the blending of the ED and EP brakes of the consist this vehicle leads, with induction motors physics::ConsistBrakeBlending brakeBlending; + // the state of each pantograph the sounds last followed, up or down + ByEnd m_pantographsoundstate{ false, false }; // vehicle shaking calculations // TBD, TODO: make an object out of it diff --git a/vehicle/ai/consist.cpp b/vehicle/ai/consist.cpp index 6ced9b912..514bae9f2 100644 --- a/vehicle/ai/consist.cpp +++ b/vehicle/ai/consist.cpp @@ -107,8 +107,7 @@ void TController::Activation() if( occupied->brakes.config.handlePositions > 0 && ( BrakeSystem == TBrakeSystem::Pneumatic || BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) { - occupied->brakes.pipeLimiterPressure = occupied->brakePipe.Pressure(); - occupied->SetActFlowSpeed(0); + occupied->ResetPipeStabiliser(); } BrakeLevelSet( occupied->brakes.HandlePosition() ); } @@ -170,7 +169,7 @@ void TController::AutoRewident() } // potentially release manual brake d->physics->DecManualBrakeLevel( ManualBrakePosNo ); - d->physics->brakes.spring.activate = false; + d->physics->ReleaseSpringBrake(); } BrakeReinspectionPending = reinspect; //ustawianie trybu pracy zadajnika hamulca, wystarczy raz po inicjalizacji AI @@ -178,7 +177,7 @@ void TController::AutoRewident() // 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 ) { - occupied->brakes.operatingMode = i; + occupied->SetBrakeOperatingMode(i); } } } diff --git a/vehicle/cab/brakecommands.cpp b/vehicle/cab/brakecommands.cpp index 3d5cb341c..19085f5e5 100644 --- a/vehicle/cab/brakecommands.cpp +++ b/vehicle/cab/brakecommands.cpp @@ -468,7 +468,7 @@ void TTrain::OnCommand_trainbrakeoperationtoggle(TTrain *Train, command_data con vehicle->physics->brakes.distributor->SetBrakeStatus(vehicle->physics->brakes.distributor->GetBrakeStatus() ^ b_dmg); // the brake is the player's now, the wagon inspector won't put it back on its own - vehicle->physics->brakes.cutOutByInspector = false; + vehicle->physics->ClaimBrakeCutOut(); } } diff --git a/vehicle/cab/equipmentcommands.cpp b/vehicle/cab/equipmentcommands.cpp index c1c73a5c7..fb017f240 100644 --- a/vehicle/cab/equipmentcommands.cpp +++ b/vehicle/cab/equipmentcommands.cpp @@ -421,7 +421,7 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command { if (itemindex < p->physics->inductionMotor.inverterCount) { - p->physics->inductionMotor.inverters[itemindex].Activate = true; + p->physics->SwitchInverter(itemindex, true); break; } else @@ -460,7 +460,7 @@ void TTrain::OnCommand_inverterdisable(TTrain *Train, command_data const &Comman { if (itemindex < p->physics->inductionMotor.inverterCount) { - p->physics->inductionMotor.inverters[itemindex].Activate = false; + p->physics->SwitchInverter(itemindex, false); break; } else @@ -499,7 +499,7 @@ void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command { if (itemindex < p->physics->inductionMotor.inverterCount) { - p->physics->inductionMotor.inverters[itemindex].Activate = !p->physics->inductionMotor.inverters[itemindex].Activate; + p->physics->SwitchInverter(itemindex, !p->physics->InverterActivated(itemindex)); // visual feedback item.UpdateValue(p->physics->inductionMotor.inverters[itemindex].Activate ? 1.0 : 0.0, Train->dsbSwitch); break; diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index ae1add60b..0f4a65b83 100644 --- a/vehicle/cab/setup.cpp +++ b/vehicle/cab/setup.cpp @@ -552,7 +552,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) DynamicObject->mdKabina->Init(); // obrócenie modelu oraz optymalizacja, również zapisanie binarnego // the vehicle has a cab, a player is in it: the odometer store keeps the vehicle also when its type has no // driver's brake valve (eu07/maszyna#72) - DynamicObject->physics->Odometer.shown = true; + DynamicObject->physics->ShowOdometer(); } set_cab_controls(NewCabNo < 0 ? 2 : NewCabNo); @@ -2006,7 +2006,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con gauge.AssignDouble(&controlled->Odometer.km); // the vehicle the counter counts for is one the odometer store keeps, also in the sessions the counter seeds // nothing (its state is a saved one by then) and when it's the motor car of the unit the cab is in - controlled->Odometer.shown = true; + controlled->ShowOdometer(); } else if (Label == "shuntmodepower:") { diff --git a/vehicle/dynamic/lifecycle.cpp b/vehicle/dynamic/lifecycle.cpp index 9fac4a7b1..114c279af 100644 --- a/vehicle/dynamic/lifecycle.cpp +++ b/vehicle/dynamic/lifecycle.cpp @@ -237,7 +237,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // utworzenie parametrów fizyki physics = new physics::Vehicle(iDirection ? fVel : -fVel, Type_Name, asName, Cab); // the vehicle carries on with the odometer state of its earlier sessions (eu07/maszyna#72) - physics->Odometer = odometer::starting_state( odometer::states(), asName, asBaseDir ); + physics->SetOdometer( odometer::starting_state( odometer::states(), asName, asBaseDir ) ); // McZapkie: TypeName musi byc nazwą CHK/MMD pojazdu if (!physics->LoadFIZ(asBaseDir)) { // jak wczytanie CHK się nie uda, to błąd diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index 9968a9b35..bfe675a9e 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -302,7 +302,7 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) void TDynamicObject::updateDriver( double const dt1 ) { if( Mechanik->primary() ) { - physics->brakes.equivalentPipePressure = GetEPP(); // srednie cisnienie w PG + physics->SetEquivalentPipePressure( GetEPP() ); // srednie cisnienie w PG } if (Mechanik->primary() && (physics->EngineType == TEngineType::DieselEngine || @@ -843,7 +843,7 @@ void TDynamicObject::updatePantographMotion( int const i, TAnimPant *p, double c void TDynamicObject::playPantographDropSounds() { // TBD, TODO: generate sound event during physics update instead? - if( physics->pantographs[VehicleEnd::front].sound_event != physics->pantographs[ VehicleEnd::front ].is_active ) { + if( m_pantographsoundstate[ VehicleEnd::front ] != physics->pantographs[ VehicleEnd::front ].is_active ) { if( physics->pantographs[ VehicleEnd::front ].is_active ) { // pantograph moving up // TBD: add a sound? @@ -857,9 +857,9 @@ void TDynamicObject::playPantographDropSounds() } } } - physics->pantographs[ VehicleEnd::front ].sound_event = physics->pantographs[ VehicleEnd::front ].is_active; + m_pantographsoundstate[ VehicleEnd::front ] = physics->pantographs[ VehicleEnd::front ].is_active; } - if( physics->pantographs[ VehicleEnd::rear ].sound_event != physics->pantographs[ VehicleEnd::rear ].is_active ) { + if( m_pantographsoundstate[ VehicleEnd::rear ] != physics->pantographs[ VehicleEnd::rear ].is_active ) { if( physics->pantographs[ VehicleEnd::rear ].is_active ) { // pantograph moving up // TBD: add a sound? @@ -873,7 +873,7 @@ void TDynamicObject::playPantographDropSounds() } } } - physics->pantographs[ VehicleEnd::rear ].sound_event = physics->pantographs[ VehicleEnd::rear ].is_active; + m_pantographsoundstate[ VehicleEnd::rear ] = physics->pantographs[ VehicleEnd::rear ].is_active; } }