From d0387753f87e12273e80ef79f0df80ce3e19364b Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sat, 28 Nov 2026 23:56:46 +0100 Subject: [PATCH] refactor(physics): TMoverParameters becomes physics::Vehicle, the mover is gone The physics of a vehicle loses the name it had from the Pascal of 2001. Done by tools/rename/mover_to_physics.py, committed with it: physics/mover.h physics/vehicle.h TMoverParameters physics::Vehicle (in namespace physics) TDynamicObject::MoverParameters physics mvOccupied, mvControlled occupied, controlled (TTrain, TController) mvSecond, mvThird secondUnit, thirdUnit mvPantographUnit pantographUnit mover, Mover, movers physics, Physics, vehicles (locals, params) m_mover, othermover, currentMover, from_movers, renderMoverEventSounds m_physics, otherPhysics, currentPhysics, from_vehicles, renderPhysicsEventSounds The code and the comments are renamed, the string literals are not: no text the game shows, logs or looks up has changed (none had the names). The movers of the editor, the tracks a slide moves, keep their name. By hand: two member functions of TDynamicObject (gather_off_track_terrain, begin_off_track) had a local mover aliasing their own MoverParameters, which the rename made physics { *physics }; the alias is gone, they use physics->. No other function has a renamed local meeting a renamed member (checked over all the functions of the code before the rename). For the branches made before it: run the script on the branch (python tools/rename/mover_to_physics.py, from the root of the repository) before merging it with this one, and the names don't conflict. It can be run again; the second time it changes nothing. The class is the same as it was; breaking it into its parts (braking, electrics, controls, load) and making its data private are the next stages. No change in behaviour: 1149/1149 tests, golden traces exact against staging 62f7a29b. --- AGENTS.md | 6 +- application/application.cpp | 2 +- application/consistviews.cpp | 28 +- application/driverhints.cpp | 296 ++++---- application/drivermode.cpp | 38 +- application/driveruipanels.cpp | 374 +++++----- application/driveruipanels.h | 2 +- application/editormode.cpp | 4 +- application/editormodejoints.cpp | 22 +- application/editormodeselftestscene.cpp | 4 +- audio/sound.cpp | 4 +- directoryDescription.md | 2 +- input/drivermouseinput.cpp | 4 +- input/messaging.cpp | 70 +- physics/brakes.cpp | 2 +- physics/brakes.h | 2 +- physics/collision.h | 2 +- physics/components/body.cpp | 64 +- physics/components/cab.cpp | 22 +- physics/components/collisions.cpp | 56 +- physics/components/commands.cpp | 38 +- physics/components/controllers.cpp | 108 +-- physics/components/couplers.cpp | 44 +- physics/components/diesel.cpp | 104 +-- physics/components/doors.cpp | 44 +- physics/components/drive.cpp | 142 ++-- physics/components/drive.h | 36 +- physics/components/electrics.cpp | 94 +-- physics/components/fizparser.cpp | 62 +- physics/components/fizsections.cpp | 96 +-- physics/components/internal.h | 2 +- physics/components/pneumatics.cpp | 162 ++--- physics/components/securitysystem.cpp | 8 +- physics/components/setup.cpp | 20 +- physics/components/traction.cpp | 126 ++-- physics/couplerphysics.h | 2 +- physics/derailment.h | 4 +- physics/{mover.h => vehicle.h} | 47 +- rendering/common/locallights.cpp | 4 +- rendering/common/localshadows.cpp | 4 +- rendering/common/scenewalk.cpp | 6 +- rendering/common/screenreflections.cpp | 4 +- rendering/common/windscreenwater.cpp | 6 +- rendering/lightarray.cpp | 30 +- rendering/opengl46/opengl46renderer.cpp | 10 +- rendering/particles.cpp | 18 +- rendering/vulkan14/vulkan14frame.cpp | 10 +- scene/scene.cpp | 8 +- scripting/lua.cpp | 4 +- simulation/blackboxrecorder.cpp | 48 +- simulation/simulation.cpp | 24 +- simulation/simulationstateserializer.cpp | 8 +- tests/unit/COVERAGE.md | 12 +- tests/unit/README.md | 2 +- tests/unit/consist.cpp | 40 +- tests/unit/consist.h | 2 +- tests/unit/drive.cpp | 44 +- tests/unit/drive.h | 12 +- tests/unit/figures.cpp | 2 +- tests/unit/figures.h | 4 +- tests/unit/fiz.h | 2 +- tests/unit/golden.cpp | 2 +- tests/unit/golden.h | 6 +- tests/unit/invariants.cpp | 4 +- tests/unit/invariants.h | 6 +- tests/unit/scenario.cpp | 2 +- tests/unit/scenario.h | 4 +- tests/unit/test_brake_pipe.cpp | 8 +- tests/unit/test_brake_setting.cpp | 72 +- tests/unit/test_brakes.cpp | 4 +- tests/unit/test_cab.cpp | 14 +- tests/unit/test_camshaft.cpp | 48 +- tests/unit/test_cntrl.cpp | 10 +- tests/unit/test_collisions.cpp | 100 +-- tests/unit/test_commands.cpp | 28 +- tests/unit/test_consist.cpp | 2 +- tests/unit/test_controls.cpp | 6 +- tests/unit/test_coupler_physics.cpp | 6 +- tests/unit/test_couplers.cpp | 94 +-- tests/unit/test_couplers_trains.cpp | 18 +- tests/unit/test_crew.cpp | 14 +- tests/unit/test_definition.cpp | 2 +- tests/unit/test_derail_motion.cpp | 10 +- tests/unit/test_derailment_vehicle.cpp | 4 +- tests/unit/test_door_wings.cpp | 4 +- tests/unit/test_drivingaid.cpp | 14 +- tests/unit/test_dynamic_brake_diesel.cpp | 12 +- tests/unit/test_elf_controller.cpp | 94 +-- tests/unit/test_engine_start.cpp | 52 +- tests/unit/test_est3al2_relay.cpp | 2 +- tests/unit/test_fcfuh_default.cpp | 2 +- tests/unit/test_feed_pipe.cpp | 36 +- tests/unit/test_figures.cpp | 26 +- tests/unit/test_fiz.cpp | 2 +- tests/unit/test_gauge_scale.cpp | 6 +- tests/unit/test_genset.cpp | 76 +-- tests/unit/test_handover.cpp | 40 +- tests/unit/test_horn.cpp | 4 +- tests/unit/test_invariants.cpp | 8 +- tests/unit/test_lights_preset_cablight.cpp | 2 +- tests/unit/test_line_contactors_interlock.cpp | 54 +- tests/unit/test_linebreaker.cpp | 14 +- tests/unit/test_motor_param_bounds.cpp | 2 +- tests/unit/test_parser.cpp | 2 +- tests/unit/test_pullee.cpp | 24 +- tests/unit/test_queries.cpp | 2 +- tests/unit/test_smoke.cpp | 32 +- tests/unit/test_speed_control.cpp | 4 +- tests/unit/test_timetable.cpp | 18 +- tests/unit/test_traction.cpp | 2 +- tests/unit/test_wheelslip.cpp | 2 +- tests/unit/vehicle.cpp | 126 ++-- tests/unit/vehicle.h | 10 +- tools/rename/mover_to_physics.py | 190 ++++++ utilities/Classes.h | 2 +- utilities/Globals.h | 4 +- utilities/Timer.h | 8 +- utilities/motiontelemetry.cpp | 2 +- utilities/translation.cpp | 2 +- utilities/uart.cpp | 2 +- vehicle/Camera.cpp | 2 +- vehicle/Driver.h | 14 +- vehicle/DynObj.h | 34 +- vehicle/Train.h | 22 +- vehicle/ai/consist.cpp | 212 +++--- vehicle/ai/controls.cpp | 382 +++++------ vehicle/ai/doors.cpp | 44 +- vehicle/ai/driver.cpp | 66 +- vehicle/ai/engine.cpp | 84 +-- vehicle/ai/force.cpp | 136 ++-- vehicle/ai/internal.h | 4 +- vehicle/ai/obstacles.cpp | 24 +- vehicle/ai/orders.cpp | 96 +-- vehicle/ai/physicslog.cpp | 38 +- vehicle/ai/routescan.cpp | 14 +- vehicle/ai/situation.cpp | 130 ++-- vehicle/ai/speed.cpp | 62 +- vehicle/ai/speedpos.cpp | 2 +- vehicle/ai/speedtable.cpp | 44 +- vehicle/brakesetting.cpp | 8 +- vehicle/brakesetting.h | 8 +- vehicle/cab/auxiliarycommands.cpp | 242 +++---- vehicle/cab/brakecommands.cpp | 198 +++--- vehicle/cab/cab.cpp | 2 +- vehicle/cab/cabcommands.cpp | 152 ++--- vehicle/cab/commandtable.cpp | 2 +- vehicle/cab/controllercommands.cpp | 134 ++-- vehicle/cab/couplingcommands.cpp | 8 +- vehicle/cab/doorcommands.cpp | 110 +-- vehicle/cab/equipmentcommands.cpp | 84 +-- vehicle/cab/internal.h | 2 +- vehicle/cab/lightcommands.cpp | 262 +++---- vehicle/cab/pantographcommands.cpp | 78 +-- vehicle/cab/powercommands.cpp | 48 +- vehicle/cab/screens.cpp | 2 +- vehicle/cab/setup.cpp | 276 ++++---- vehicle/cab/signalcommands.cpp | 54 +- vehicle/cab/sounds.cpp | 64 +- vehicle/cab/train.cpp | 288 ++++---- vehicle/cab/update.cpp | 642 +++++++++--------- vehicle/crew.cpp | 6 +- vehicle/crew.h | 6 +- vehicle/crewchange.cpp | 14 +- vehicle/derailmotion.h | 4 +- vehicle/doorwings.h | 4 +- vehicle/drivingaid.cpp | 4 +- vehicle/drivingaid.h | 4 +- vehicle/dynamic/animations.cpp | 42 +- vehicle/dynamic/consist.cpp | 94 +-- vehicle/dynamic/couplers.cpp | 70 +- vehicle/dynamic/destinations.cpp | 14 +- vehicle/dynamic/internal.h | 2 +- vehicle/dynamic/lifecycle.cpp | 188 ++--- vehicle/dynamic/lights.cpp | 56 +- vehicle/dynamic/load.cpp | 86 +-- vehicle/dynamic/mmd.cpp | 92 +-- vehicle/dynamic/movement.cpp | 36 +- vehicle/dynamic/neighbours.cpp | 16 +- vehicle/dynamic/offtrack.cpp | 108 ++- vehicle/dynamic/sounds.cpp | 218 +++--- vehicle/dynamic/update.cpp | 588 ++++++++-------- vehicle/dynamic/vehicletable.cpp | 164 ++--- vehicle/dynamic/visual.cpp | 142 ++-- vehicle/enginestart.cpp | 14 +- vehicle/enginestart.h | 16 +- vehicle/handover.cpp | 8 +- vehicle/handover.h | 8 +- vehicle/lightsprogrammer.h | 2 +- vehicle/linebreaker.h | 2 +- vehicle/mainctrlact.h | 6 +- vehicle/odometer.h | 2 +- vehicle/odometerreading.h | 2 +- vehicle/pulleemode.h | 2 +- vehicle/smoke.cpp | 22 +- vehicle/smoke.h | 6 +- vehicle/timetableservice.cpp | 4 +- vehicle/timetableservice.h | 4 +- widgets/trainingcard.cpp | 4 +- widgets/vehicleparams.cpp | 102 +-- widgets/vehicleparams.h | 2 +- world/Event.cpp | 24 +- world/Road.cpp | 6 +- world/RoadPoint.cpp | 16 +- world/Track.cpp | 4 +- world/TrackBuckle.cpp | 6 +- world/TrkFoll.cpp | 6 +- world/station.cpp | 4 +- 207 files changed, 5147 insertions(+), 4950 deletions(-) rename physics/{mover.h => vehicle.h} (98%) create mode 100644 tools/rename/mover_to_physics.py diff --git a/AGENTS.md b/AGENTS.md index 82285b488..533d09efa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -107,12 +107,12 @@ Code that isn't otherwise touched keeps its names; renaming a member goes togeth scripts and the log read stays byte for byte the same whatever the C++ names are: the keywords of the `.fiz` and the scenery, the keys of the dictionaries of the Python screens, the texts of the log and of `STR(...)`. -The vehicle code is in `physics/` (the physics of the vehicles: `mover.h` and `physics/components/*.cpp` by subsystem, `brakes.*`, +The vehicle code is in `physics/` (the physics of the vehicles: `vehicle.h` with the class `physics::Vehicle`, and `physics/components/*.cpp` by subsystem, `brakes.*`, couplers, collisions, derailment) and `vehicle/` (the vehicle in the scenery, the cab, the AI). Keep it that way: - `physics/vehicletypes.h` holds the vocabulary the rest of the simulator passes around (vehicle ends, sides, couplings, lights, - sounds, the types of drive and brake). A header that only names these includes it, not `physics/mover.h`; a header that only - points at a `TMoverParameters` or a `TDynamicObject` declares it (`utilities/Classes.h`) and includes neither. + sounds, the types of drive and brake). A header that only names these includes it, not `physics/vehicle.h`; a header that only + points at a `physics::Vehicle` or a `TDynamicObject` declares it (`utilities/Classes.h`) and includes neither. - A state of several mutually exclusive values is an `enum class`, a set of independent conditions is named fields, not the bits of an `int`. Numbers of the formats (`.scn`, events, the network) are read into these where they come in and written where they go out. - The commands between the vehicles are `VehicleCommand` (`physics/vehiclecommand.h`); their text names only matter where a command diff --git a/application/application.cpp b/application/application.cpp index 8181c014e..6b3cc4a8f 100644 --- a/application/application.cpp +++ b/application/application.cpp @@ -47,7 +47,7 @@ http://mozilla.org/MPL/2.0/. #include #include #include "utilities/translation.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #if WITH_DISCORD_RPC #include "ref/discord-rpc/include/discord_rpc.h" diff --git a/application/consistviews.cpp b/application/consistviews.cpp index 42cd41257..4d9fe76ab 100644 --- a/application/consistviews.cpp +++ b/application/consistviews.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/Camera.h" #include "vehicle/Driver.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace { @@ -29,16 +29,16 @@ cameraviews::vehicle_pose pose_of(TDynamicObject const *Vehicle) { cameraviews::vehicle_pose pose; pose.position = Vehicle->GetPosition(); pose.front = Vehicle->VectorFront(); - pose.length = Vehicle->MoverParameters->Dim.L; - pose.width = Vehicle->MoverParameters->Dim.W; - pose.height = Vehicle->MoverParameters->Dim.H; + pose.length = Vehicle->physics->Dim.L; + pose.width = Vehicle->physics->Dim.W; + pose.height = Vehicle->physics->Dim.H; return pose; } // the end of the Vehicle the Other vehicle is beyond, -1 when it's beyond neither int end_towards(TDynamicObject const *Vehicle, TDynamicObject const *Other) { for (auto const side : VehicleEnds) { - if (Vehicle->MoverParameters->Neighbours[side].vehicle == Other) { + if (Vehicle->physics->Neighbours[side].vehicle == Other) { return NumberOf(side); } } @@ -58,14 +58,14 @@ cameraviews::coupler coupler_of(TDynamicObject const *Vehicle, VehicleEnd const cameraviews::coupler coupler; coupler.position = Vehicle->CouplerPosition(End); coupler.outward = Vehicle->VectorFront() * (End == VehicleEnd::front ? 1.0 : -1.0); - coupler.width = Vehicle->MoverParameters->Dim.W; + coupler.width = Vehicle->physics->Dim.W; return coupler; } // the driver's way: the front (1) or the rear (-1) of the Driven vehicle, as the user drives it int driven_way(TDynamicObject const *Driven) { - auto const cab{Driven->MoverParameters->CabOccupied < 0 ? -1 : 1}; - auto const direction{Driven->MoverParameters->DirActive < 0 ? -1 : 1}; + auto const cab{Driven->physics->CabOccupied < 0 ? -1 : 1}; + auto const direction{Driven->physics->DirActive < 0 ? -1 : 1}; return cab * direction; } @@ -143,8 +143,8 @@ TDynamicObject *consist_views::pick(std::vector const &Train, } double consist_views::gap_beyond(TDynamicObject const *Vehicle, VehicleEnd const End) { - auto const &neighbour{Vehicle->MoverParameters->Neighbours[End]}; - if (neighbour.vehicle == nullptr || false == Vehicle->MoverParameters->Couplers[End].CouplingFlag.Empty()) { + auto const &neighbour{Vehicle->physics->Neighbours[End]}; + if (neighbour.vehicle == nullptr || false == Vehicle->physics->Couplers[End].CouplingFlag.Empty()) { return -1.0; } if (neighbour.distance > cameraviews::coupler_watch_range) { @@ -175,7 +175,7 @@ consist_views::coupling_place consist_views::coupling_at(std::vectorMoverParameters->Neighbours[outer]}; + auto const &neighbour{vehicle->physics->Neighbours[outer]}; place.gap = gap_beyond(vehicle, EndOf(outer)); if (place.gap >= 0.0 && (neighbour.FacingEnd() == VehicleEnd::front || neighbour.FacingEnd() == VehicleEnd::rear)) { place.other = true; @@ -208,7 +208,7 @@ cameraviews::train_motion consist_views::motion_of(std::vector motion.head = end_along(Train[head], m_direction); motion.tail = end_along(Train[tail], -m_direction); motion.speed = std::abs(m_vehicle->GetVelocity()) / 3.6; - motion.width = m_vehicle->MoverParameters->Dim.W; + motion.width = m_vehicle->physics->Dim.W; if (Train.size() > 1) { auto const *behind{Train[head == 0 ? 1 : head - 1]}; motion.curvature = cameraviews::line_curvature(Train[head]->GetPosition(), facing_along(Train[head], m_direction), behind->GetPosition(), facing_along(behind, m_direction)); @@ -232,10 +232,10 @@ cameraviews::placement consist_views::place_shunting(TCamera const &Camera, std: auto const pose{pose_of(m_vehicle)}; auto length{0.0}; for (auto const *vehicle : Train) { - length += vehicle->MoverParameters->Dim.L; + length += vehicle->physics->Dim.L; } m_topdown = cameraviews::topdown_moved(m_topdown, Camera.Velocity, Seconds, pose, 0.5 * length + 50.0); - auto const facing{cameraviews::driving_facing(m_vehicle->VectorFront(), Driven->VectorFront(), Driven->MoverParameters->CabOccupied)}; + auto const facing{cameraviews::driving_facing(m_vehicle->VectorFront(), Driven->VectorFront(), Driven->physics->CabOccupied)}; return cameraviews::topdown_placement(m_topdown, pose, facing); } diff --git a/application/driverhints.cpp b/application/driverhints.cpp index 93e2735fd..721636949 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -11,7 +11,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/Driver.h" #include "utilities/Globals.h" #include "utilities/utilities.h" -#include "physics/mover.h" +#include "physics/vehicle.h" void TController::hint( driver_hint const Value, hintpredicate const Predicate, float const Predicateparameter ) { @@ -83,70 +83,70 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // battery case driver_hint::batteryon: { if( AIControllFlag ) { - mvOccupied->BatterySwitch( true ); + occupied->BatterySwitch( true ); } remove_hint( driver_hint::batteryoff ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == true; } ); + return occupied->BatteryStart != start_t::manual || occupied->Power24vIsAvailable == true; } ); break; } case driver_hint::batteryoff: { if( AIControllFlag ) { - mvOccupied->BatterySwitch( false ); + occupied->BatterySwitch( false ); } remove_hint( driver_hint::batteryon ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == false; } ); + return occupied->BatteryStart != start_t::manual || occupied->Power24vIsAvailable == false; } ); break; } // battery case driver_hint::cabactivation: { - if (AIControllFlag && mvOccupied->Power24vIsAvailable) { - mvOccupied->CabActivisation(); + if (AIControllFlag && occupied->Power24vIsAvailable) { + occupied->CabActivisation(); CheckVehicles(); } remove_hint( driver_hint::cabdeactivation ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->AutomaticCabActivation || mvOccupied->IsCabMaster(); } ); + return occupied->AutomaticCabActivation || occupied->IsCabMaster(); } ); break; } case driver_hint::cabdeactivation: { if (AIControllFlag) { - mvOccupied->CabDeactivisation(); + occupied->CabDeactivisation(); } remove_hint( driver_hint::cabactivation ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->AutomaticCabActivation || (mvOccupied->CabMaster == false && mvOccupied->CabActive == 0); } ); + return occupied->AutomaticCabActivation || (occupied->CabMaster == false && occupied->CabActive == 0); } ); break; } // radio case driver_hint::radioon: { if( AIControllFlag ) { - mvOccupied->Radio = true; + occupied->Radio = true; } remove_hint( driver_hint::radiooff ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->Radio == true; } ); + return occupied->Radio == true; } ); break; } case driver_hint::radiofuseon: { if( AIControllFlag ) { - mvOccupied->RadioFuse = true; + occupied->RadioFuse = true; } hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->RadioFuse == true; } ); + return occupied->RadioFuse == true; } ); break; } case driver_hint::radiochannel: { @@ -162,177 +162,177 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::radiooff: { if( AIControllFlag ) { - mvOccupied->Radio = false; + occupied->Radio = false; } remove_hint( driver_hint::radioon ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->Radio == false; } ); + return occupied->Radio == false; } ); break; } // oil pump case driver_hint::oilpumpon: { if( AIControllFlag ) { - mvOccupied->OilPumpSwitch( true ); + occupied->OilPumpSwitch( true ); } remove_hint( driver_hint::oilpumpoff ); hint( Action, [this](float const /*Parameter*/) { - auto const &device { mvOccupied->OilPump }; - return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true || mvOccupied->Mains; } ); + auto const &device { occupied->OilPump }; + return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true || occupied->Mains; } ); break; } case driver_hint::oilpumpoff: { if( AIControllFlag ) { - mvOccupied->OilPumpSwitch( false ); + occupied->OilPumpSwitch( false ); } remove_hint( driver_hint::oilpumpon ); hint( Action, [this](float const /*Parameter*/) { - auto const &device { mvOccupied->OilPump }; + auto const &device { occupied->OilPump }; return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } ); break; } // fuel pump case driver_hint::fuelpumpon: { if( AIControllFlag ) { - mvOccupied->FuelPumpSwitch( true ); + occupied->FuelPumpSwitch( true ); } remove_hint( driver_hint::fuelpumpoff ); hint( Action, [this](float const /*Parameter*/) { - auto const &device { mvOccupied->FuelPump }; + auto const &device { occupied->FuelPump }; return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true; } ); break; } case driver_hint::fuelpumpoff: { if( AIControllFlag ) { - mvOccupied->FuelPumpSwitch( false ); + occupied->FuelPumpSwitch( false ); } remove_hint( driver_hint::fuelpumpon ); hint( Action, [this](float const /*Parameter*/) { - auto const &device { mvOccupied->FuelPump }; + auto const &device { occupied->FuelPump }; return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } ); break; } // pantographs case driver_hint::pantographairsourcesetmain: { if( AIControllFlag ) { - mvPantographUnit->bPantKurek3 = true; + pantographUnit->bPantKurek3 = true; } remove_hint( driver_hint::pantographairsourcesetauxiliary ); hint( Action, [this](float const /*Parameter*/) { - return mvPantographUnit->bPantKurek3 == true; } ); + return pantographUnit->bPantKurek3 == true; } ); break; } case driver_hint::pantographairsourcesetauxiliary: { if( AIControllFlag ) { - mvPantographUnit->bPantKurek3 = false; + pantographUnit->bPantKurek3 = false; } remove_hint( driver_hint::pantographcompressoron ); hint( Action, [this](float const /*Parameter*/) { - return mvPantographUnit->bPantKurek3 == false; } ); + return pantographUnit->bPantKurek3 == false; } ); break; } case driver_hint::pantographcompressoron: { if( AIControllFlag ) { - mvPantographUnit->PantCompFlag = true; + pantographUnit->PantCompFlag = true; } remove_hint( driver_hint::pantographcompressoroff ); hint( Action, [this](float const /*Parameter*/) { - return mvPantographUnit->PantCompFlag == true; } ); + return pantographUnit->PantCompFlag == true; } ); break; } case driver_hint::pantographcompressoroff: { if( AIControllFlag ) { - mvPantographUnit->PantCompFlag = false; + pantographUnit->PantCompFlag = false; } remove_hint( driver_hint::pantographcompressoron ); hint( Action, [this](float const /*Parameter*/) { - return mvPantographUnit->PantCompFlag == false; } ); + return pantographUnit->PantCompFlag == false; } ); break; } case driver_hint::pantographsvalveon: { if( AIControllFlag ) { - mvOccupied->OperatePantographsValve( operation_t::enable ); + occupied->OperatePantographsValve( operation_t::enable ); } remove_hint( driver_hint::pantographsvalveoff ); hint( Action, [this](float const /*Parameter*/) { - return mvPantographUnit->PantsValve.is_active == true; } ); + return pantographUnit->PantsValve.is_active == true; } ); break; } case driver_hint::frontpantographvalveon: { if( AIControllFlag ) { - mvOccupied->OperatePantographValve( VehicleEnd::front, operation_t::enable ); + occupied->OperatePantographValve( VehicleEnd::front, operation_t::enable ); } remove_hint( driver_hint::frontpantographvalveoff ); hint( Action, [ this ]( float const Parameter ) { - return mvPantographUnit->Pantographs[VehicleEnd::front].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); }, + return pantographUnit->Pantographs[VehicleEnd::front].valve.is_active == true || (Parameter > 0 && occupied->Vel > Parameter); }, Actionparameter ); break; } case driver_hint::frontpantographvalveoff: { if( AIControllFlag ) { - mvOccupied->OperatePantographValve( VehicleEnd::front, operation_t::disable ); + occupied->OperatePantographValve( VehicleEnd::front, operation_t::disable ); } remove_hint( driver_hint::frontpantographvalveon ); hint( Action, [this](float const /*Parameter*/) { - return mvPantographUnit->Pantographs[VehicleEnd::front].valve.is_active == false; } ); + return pantographUnit->Pantographs[VehicleEnd::front].valve.is_active == false; } ); break; } case driver_hint::rearpantographvalveon: { if( AIControllFlag ) { - mvOccupied->OperatePantographValve( VehicleEnd::rear, operation_t::enable ); + occupied->OperatePantographValve( VehicleEnd::rear, operation_t::enable ); } remove_hint( driver_hint::rearpantographvalveoff ); hint( Action, [ this ]( float const Parameter ) { - return mvPantographUnit->Pantographs[VehicleEnd::rear].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); }, + return pantographUnit->Pantographs[VehicleEnd::rear].valve.is_active == true || (Parameter > 0 && occupied->Vel > Parameter); }, Actionparameter ); break; } case driver_hint::rearpantographvalveoff: { if( AIControllFlag ) { - mvOccupied->OperatePantographValve( VehicleEnd::rear, operation_t::disable ); + occupied->OperatePantographValve( VehicleEnd::rear, operation_t::disable ); } remove_hint( driver_hint::rearpantographvalveon ); hint( Action, [this](float const /*Parameter*/) { - return mvPantographUnit->Pantographs[VehicleEnd::rear].valve.is_active == false; } ); + return pantographUnit->Pantographs[VehicleEnd::rear].valve.is_active == false; } ); break; } // converter case driver_hint::converteron: { if( AIControllFlag ) { - mvOccupied->ConverterSwitch( true ); + 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 pVehicle->for_each( Coupling::control, []( TDynamicObject * Vehicle ) { - auto *vehicle { Vehicle->MoverParameters }; + auto *vehicle { Vehicle->physics }; if( vehicle->LineContactorsHeldByLocalConverterSwitch() ) { vehicle->ConverterAllowLocal = true; } } ); } @@ -345,7 +345,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::converteroff: { if( AIControllFlag ) { - mvOccupied->ConverterSwitch( false ); + occupied->ConverterSwitch( false ); } remove_hint( driver_hint::converteron ); hint( @@ -357,38 +357,38 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // relays case driver_hint::primaryconverteroverloadreset: { if( AIControllFlag ) { - mvOccupied->RelayReset( relay_t::primaryconverteroverload ); + occupied->RelayReset( relay_t::primaryconverteroverload ); } hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->ConverterOverloadRelayStart != start_t::manual || mvOccupied->ConvOvldFlag == false; } ); + return occupied->ConverterOverloadRelayStart != start_t::manual || occupied->ConvOvldFlag == false; } ); break; } case driver_hint::maincircuitgroundreset: { if( AIControllFlag ) { - mvOccupied->RelayReset( relay_t::maincircuitground ); + occupied->RelayReset( relay_t::maincircuitground ); } hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->GroundRelayStart != start_t::manual || mvOccupied->GroundRelay == true; } ); + return occupied->GroundRelayStart != start_t::manual || occupied->GroundRelay == true; } ); break; } case driver_hint::tractionnmotoroverloadreset: { if( AIControllFlag ) { - mvOccupied->RelayReset( relay_t::tractionnmotoroverload ); + occupied->RelayReset( relay_t::tractionnmotoroverload ); } hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->FuseFlag == false; } ); + return occupied->FuseFlag == false; } ); break; } // line breaker case driver_hint::linebreakerclose: { if( AIControllFlag ) { - mvOccupied->MainSwitch( true ); + occupied->MainSwitch( true ); } remove_hint( driver_hint::linebreakeropen ); hint( @@ -399,7 +399,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::linebreakeropen: { if( AIControllFlag ) { - mvOccupied->MainSwitch( false ); + occupied->MainSwitch( false ); } remove_hint( driver_hint::linebreakerclose ); hint( @@ -412,7 +412,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // compressor case driver_hint::compressoron: { if( AIControllFlag ) { - mvOccupied->CompressorSwitch( true ); + occupied->CompressorSwitch( true ); } remove_hint( driver_hint::compressoroff ); hint( @@ -423,7 +423,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::compressoroff: { if( AIControllFlag ) { - mvOccupied->CompressorSwitch( false ); + occupied->CompressorSwitch( false ); } remove_hint( driver_hint::compressoron ); hint( @@ -434,74 +434,74 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::frontmotorblowerson: { if( AIControllFlag ) { - mvOccupied->MotorBlowersSwitchOff( false, VehicleEnd::front ); - mvOccupied->MotorBlowersSwitch( true, VehicleEnd::front ); + occupied->MotorBlowersSwitchOff( false, VehicleEnd::front ); + occupied->MotorBlowersSwitch( true, VehicleEnd::front ); } remove_hint( driver_hint::frontmotorblowersoff ); hint( Action, [this]( float const /*Parameter*/ ) { - auto const &device { mvOccupied->MotorBlowers[ VehicleEnd::front ] }; + auto const &device { occupied->MotorBlowers[ VehicleEnd::front ] }; return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } ); break; } case driver_hint::rearmotorblowerson: { if( AIControllFlag ) { - mvOccupied->MotorBlowersSwitchOff( false, VehicleEnd::rear ); - mvOccupied->MotorBlowersSwitch( true, VehicleEnd::rear ); + occupied->MotorBlowersSwitchOff( false, VehicleEnd::rear ); + occupied->MotorBlowersSwitch( true, VehicleEnd::rear ); } remove_hint( driver_hint::rearmotorblowersoff ); hint( Action, [this]( float const /*Parameter*/ ) { - auto const &device { mvOccupied->MotorBlowers[ VehicleEnd::rear ] }; + auto const &device { occupied->MotorBlowers[ VehicleEnd::rear ] }; return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } ); break; } // spring brake case driver_hint::springbrakeon: { if( AIControllFlag ) { - mvOccupied->SpringBrakeActivate( true ); + occupied->SpringBrakeActivate( true ); } remove_hint( driver_hint::springbrakeoff ); hint( Action, [this]( float const /*Parameter*/ ) { - return mvOccupied->SpringBrake.Activate == true; } ); + return occupied->SpringBrake.Activate == true; } ); break; } case driver_hint::springbrakeoff: { if( AIControllFlag ) { - mvOccupied->SpringBrakeActivate( false ); + occupied->SpringBrakeActivate( false ); } remove_hint( driver_hint::springbrakeon ); hint( Action, [this]( float const /*Parameter*/ ) { - return mvOccupied->SpringBrake.Activate == false; } ); + return occupied->SpringBrake.Activate == false; } ); break; } // manual brake case driver_hint::manualbrakon: { if( AIControllFlag ) { - mvOccupied->IncManualBrakeLevel( ManualBrakePosNo ); + occupied->IncManualBrakeLevel( ManualBrakePosNo ); } remove_hint( driver_hint::manualbrakoff ); hint( Action, [this]( float const /*Parameter*/ ) { - return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == ManualBrakePosNo; } ); + return occupied->LocalBrake != TLocalBrake::ManualBrake || occupied->MBrake == false || occupied->ManualBrakePos == ManualBrakePosNo; } ); break; } case driver_hint::manualbrakoff: { if( AIControllFlag ) { - mvOccupied->DecManualBrakeLevel( ManualBrakePosNo ); + occupied->DecManualBrakeLevel( ManualBrakePosNo ); } remove_hint( driver_hint::manualbrakon ); hint( Action, [this]( float const /*Parameter*/ ) { - return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == 0; } ); + return occupied->LocalBrake != TLocalBrake::ManualBrake || occupied->MBrake == false || occupied->ManualBrakePos == 0; } ); break; } // master controller @@ -593,8 +593,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return AccDesired <= EU07_AI_NOACCELERATION || (false == Ready && false == mvOccupied->ShuntMode) || AccDesired - AbsAccS <= 0.05 || - (mvOccupied->EIMCtrlType > 0 ? mvControlling->eimic_real >= 1.0 : mvControlling->IsScndCtrlMaxPowerPos() && mvControlling->IsMainCtrlMaxPowerPos()); } ); + return AccDesired <= EU07_AI_NOACCELERATION || (false == Ready && false == occupied->ShuntMode) || AccDesired - AbsAccS <= 0.05 || + (occupied->EIMCtrlType > 0 ? mvControlling->eimic_real >= 1.0 : mvControlling->IsScndCtrlMaxPowerPos() && mvControlling->IsMainCtrlMaxPowerPos()); } ); break; } case driver_hint::bufferscompress: { @@ -760,7 +760,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvPantographUnit->PantPress >= (is_emu() ? (mvPantographUnit->PantPressLockActive ? 4.6 : 2.6) : 4.2); } ); + return pantographUnit->PantPress >= (is_emu() ? (pantographUnit->PantPressLockActive ? 4.6 : 2.6) : 4.2); } ); break; } case driver_hint::waitbrakecharge: { @@ -796,8 +796,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // driver_hint_brakingforcesetzero // driver_hint_brakingforcelap case driver_hint::trainbrakesetpipeunlock: { - if (AIControllFlag && mvOccupied->HandleUnlock != -3) { - while( BrakeCtrlPosition >= mvOccupied->HandleUnlock + if (AIControllFlag && occupied->HandleUnlock != -3) { + while( BrakeCtrlPosition >= occupied->HandleUnlock && BrakeLevelAdd(-1) ) { // all work is done in the header } @@ -806,19 +806,19 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->HandleUnlock == -3 || BrakeCtrlPosition == mvOccupied->HandleUnlock; } ); + return occupied->HandleUnlock == -3 || BrakeCtrlPosition == occupied->HandleUnlock; } ); break; } case driver_hint::trainbrakerelease: { if( AIControllFlag ) { -// mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); +// occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_RP ) ); BrakeLevelSet( gbh_RP ); } remove_train_brake_hints(); hint( Action, [this](float const /*Parameter*/) { - return is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2) || (mvOccupied->Handle->Time && mvOccupied->Handle->GetCP() > mvOccupied->HighPipePress - 0.05); } ); + return is_equal(occupied->fBrakeCtrlPos, occupied->Handle->GetPos(bh_RP), 0.2) || (occupied->Handle->Time && occupied->Handle->GetCP() > occupied->HighPipePress - 0.05); } ); // return ( BrakeCtrlPosition == gbh_RP ); } ); break; } @@ -826,7 +826,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) if( AIControllFlag ) { // za radą yB ustawiamy pozycję 3 kranu (ruszanie kranem w innych miejscach powino zostać wyłączone) if( BrakeSystem == TBrakeSystem::ElectroPneumatic && false == ForcePNBrake ) { - mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPB ) ); + occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_EPB ) ); } else { BrakeCtrlPosition = 3; @@ -867,7 +867,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const Parameter) { - return std::abs(mvControlling->Fb) > Parameter || is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_EB), 0.2); }, + return std::abs(mvControlling->Fb) > Parameter || is_equal(occupied->fBrakeCtrlPos, occupied->Handle->GetPos(bh_EB), 0.2); }, static_cast(std::max( 0.0, std::max( @@ -885,7 +885,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return Ready && fReady < 0.4 && is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2); } ); + return Ready && fReady < 0.4 && is_equal(occupied->fBrakeCtrlPos, occupied->Handle->GetPos(bh_RP), 0.2); } ); break; } case driver_hint::brakingforcelap: { @@ -899,18 +899,18 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } // independent brake case driver_hint::independentbrakeapply: { - if (AIControllFlag && mvOccupied->LocalBrakePosA < 1.0) { - mvOccupied->IncLocalBrakeLevel( LocalBrakePosNo ); - if (mvOccupied->EIMCtrlEmergency) { - mvOccupied->DecLocalBrakeLevel(1); + if (AIControllFlag && occupied->LocalBrakePosA < 1.0) { + occupied->IncLocalBrakeLevel( LocalBrakePosNo ); + if (occupied->EIMCtrlEmergency) { + occupied->DecLocalBrakeLevel(1); } } remove_hint( driver_hint::independentbrakerelease ); hint( Action, [this](float const Parameter) { - return mvOccupied->LocalBrakePosA >= Parameter; }, - ( LocalBrakePosNo - ( mvOccupied->EIMCtrlEmergency ? 1 : 0 ) ) / LocalBrakePosNo ); + return occupied->LocalBrakePosA >= Parameter; }, + ( LocalBrakePosNo - ( occupied->EIMCtrlEmergency ? 1 : 0 ) ) / LocalBrakePosNo ); break; } case driver_hint::independentbrakerelease: { @@ -921,36 +921,36 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->LocalBrakePosA < 0.05; } ); + return occupied->LocalBrakePosA < 0.05; } ); break; } // reverser case driver_hint::directionforward: { if( AIControllFlag ) { - OrderDirectionChange( 1, mvOccupied ); + OrderDirectionChange( 1, occupied ); } remove_reverser_hints(); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->DirActive * mvOccupied->CabActive > 0; } ); + return occupied->DirActive * occupied->CabActive > 0; } ); break; } case driver_hint::directionbackward: { if( AIControllFlag ) { - OrderDirectionChange( -1, mvOccupied ); + OrderDirectionChange( -1, occupied ); } remove_reverser_hints(); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->DirActive * mvOccupied->CabActive < 0; } ); + return occupied->DirActive * occupied->CabActive < 0; } ); break; } case driver_hint::directionother: { if( AIControllFlag ) { -// DirectionForward( mvOccupied->DirAbsolute < 0 ); - OrderDirectionChange( iDirectionOrder, mvOccupied ); +// DirectionForward( occupied->DirAbsolute < 0 ); + OrderDirectionChange( iDirectionOrder, occupied ); DirectionChange(); } remove_reverser_hints(); @@ -968,7 +968,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->DirActive == 0; } ); + return occupied->DirActive == 0; } ); break; } // anti-slip systems @@ -1007,19 +1007,19 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // horns case driver_hint::hornon: { if( AIControllFlag ) { - mvOccupied->WarningSignal = static_cast( Actionparameter ); + occupied->WarningSignal = static_cast( Actionparameter ); } remove_hint( driver_hint::hornoff ); hint( Action, [this](float const /*Parameter*/) { // NOTE: we provide slightly larger horn activation window for human driver - return fWarningDuration + 5.0 < 0.05 || mvOccupied->WarningSignal != 0; } ); + return fWarningDuration + 5.0 < 0.05 || occupied->WarningSignal != 0; } ); break; } case driver_hint::hornoff: { if( AIControllFlag ) { - mvOccupied->WarningSignal = 0; + occupied->WarningSignal = 0; } /* // NOTE: for human driver the hint to switch horn on will disappear automatically @@ -1027,50 +1027,50 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const Parameter) -> bool { - return ( mvOccupied->WarningSignal == 0 ); } ); + return ( occupied->WarningSignal == 0 ); } ); */ break; } // door locks case driver_hint::consistdoorlockson: { if( AIControllFlag ) { - mvOccupied->LockDoors( true ); + occupied->LockDoors( true ); } // TODO: remove other door lock hints hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->Doors.has_lock == false || mvOccupied->Doors.lock_enabled == true; } ); + return occupied->Doors.has_lock == false || occupied->Doors.lock_enabled == true; } ); break; } // departure signal case driver_hint::departuresignalon: { if( AIControllFlag ) { - mvOccupied->signal_departure( true ); + occupied->signal_departure( true ); } remove_hint( driver_hint::departuresignaloff ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == true || mvOccupied->Vel > 5.0; } ); + return occupied->Doors.has_warning == false || occupied->Doors.has_autowarning == true || occupied->DepartureSignal == true || occupied->Vel > 5.0; } ); break; } case driver_hint::departuresignaloff: { if( AIControllFlag ) { - mvOccupied->signal_departure( false ); + occupied->signal_departure( false ); } remove_hint( driver_hint::departuresignalon ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == false; } ); + return occupied->Doors.has_warning == false || occupied->Doors.has_autowarning == true || occupied->DepartureSignal == false; } ); break; } // consist doors case driver_hint::doorrightopen: { if( AIControllFlag - || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) { - pVehicle->MoverParameters->OperateDoors( VehicleSide::right, true ); + || pVehicle->physics->Doors.open_control == control_t::conductor ) { + pVehicle->physics->OperateDoors( VehicleSide::right, true ); } remove_hint( driver_hint::doorrightclose ); hint( @@ -1081,8 +1081,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::doorrightclose: { if( AIControllFlag - || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) { - pVehicle->MoverParameters->OperateDoors( VehicleSide::right, false ); + || pVehicle->physics->Doors.open_control == control_t::conductor ) { + pVehicle->physics->OperateDoors( VehicleSide::right, false ); } remove_hint( driver_hint::doorrightopen ); hint( @@ -1093,8 +1093,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::doorleftopen: { if( AIControllFlag - || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) { - pVehicle->MoverParameters->OperateDoors( VehicleSide::left, true ); + || pVehicle->physics->Doors.open_control == control_t::conductor ) { + pVehicle->physics->OperateDoors( VehicleSide::left, true ); } remove_hint( driver_hint::doorleftclose ); hint( @@ -1105,8 +1105,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::doorleftclose: { if( AIControllFlag - || pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) { - pVehicle->MoverParameters->OperateDoors( VehicleSide::left, false ); + || pVehicle->physics->Doors.open_control == control_t::conductor ) { + pVehicle->physics->OperateDoors( VehicleSide::left, false ); } remove_hint( driver_hint::doorleftopen ); hint( @@ -1117,7 +1117,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::doorrightpermiton: { if( AIControllFlag ) { - pVehicle->MoverParameters->PermitDoors( VehicleSide::right, true ); + pVehicle->physics->PermitDoors( VehicleSide::right, true ); } remove_hint( driver_hint::doorrightpermitoff ); hint( @@ -1128,7 +1128,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::doorrightpermitoff: { if( AIControllFlag ) { - pVehicle->MoverParameters->PermitDoors( VehicleSide::right, false ); + pVehicle->physics->PermitDoors( VehicleSide::right, false ); } remove_hint( driver_hint::doorrightpermiton ); hint( @@ -1139,7 +1139,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::doorleftpermiton: { if( AIControllFlag ) { - pVehicle->MoverParameters->PermitDoors( VehicleSide::left, true ); + pVehicle->physics->PermitDoors( VehicleSide::left, true ); } remove_hint( driver_hint::doorleftpermitoff ); hint( @@ -1150,7 +1150,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) } case driver_hint::doorleftpermitoff: { if( AIControllFlag ) { - pVehicle->MoverParameters->PermitDoors( VehicleSide::left, false ); + pVehicle->physics->PermitDoors( VehicleSide::left, false ); } remove_hint( driver_hint::doorleftpermiton ); hint( @@ -1162,93 +1162,93 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // doorsteps, as the timetable asks (eu07/maszyna#95) case driver_hint::doorstepon: { if( AIControllFlag ) { - mvOccupied->PermitDoorStep( true ); + occupied->PermitDoorStep( true ); } remove_hint( driver_hint::doorstepoff ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->Doors.step_enabled == true; } ); + return occupied->Doors.step_enabled == true; } ); break; } case driver_hint::doorstepoff: { if( AIControllFlag ) { - mvOccupied->PermitDoorStep( false ); + occupied->PermitDoorStep( false ); } remove_hint( driver_hint::doorstepon ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->Doors.step_enabled == false; } ); + return occupied->Doors.step_enabled == false; } ); break; } // consist lights case driver_hint::consistlightson: { if( AIControllFlag ) { - mvOccupied->CompartmentLightsSwitch( true ); - mvOccupied->CompartmentLightsSwitchOff( false ); + occupied->CompartmentLightsSwitch( true ); + occupied->CompartmentLightsSwitchOff( false ); } remove_hint( driver_hint::consistlightsoff ); hint( Action, [this](float const /*Parameter*/) { - auto const &device { mvOccupied->CompartmentLights }; + auto const &device { occupied->CompartmentLights }; return Global.fLuminance * ConsistShade > 0.40 || device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false) || device.is_active == true; } ); break; } case driver_hint::consistlightsoff: { if( AIControllFlag ) { - mvOccupied->CompartmentLightsSwitch( false ); - mvOccupied->CompartmentLightsSwitchOff( true ); + occupied->CompartmentLightsSwitch( false ); + occupied->CompartmentLightsSwitchOff( true ); } remove_hint( driver_hint::consistlightson ); hint( Action, [this](float const /*Parameter*/) { - auto const &device { mvOccupied->CompartmentLights }; + auto const &device { occupied->CompartmentLights }; return Global.fLuminance * ConsistShade < 0.35 || device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } ); break; } // consist heating case driver_hint::consistheatingon: { if( AIControllFlag ) { - mvOccupied->HeatingSwitch( true ); + occupied->HeatingSwitch( true ); } remove_hint( driver_hint::consistheatingoff ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->HeatingAllow == true; } ); + return occupied->HeatingAllow == true; } ); break; } case driver_hint::consistheatingoff: { if( AIControllFlag ) { - mvOccupied->HeatingSwitch( false ); + occupied->HeatingSwitch( false ); } remove_hint( driver_hint::consistheatingon ); hint( Action, [this](float const /*Parameter*/) { - return mvOccupied->HeatingAllow == false; } ); + return occupied->HeatingAllow == false; } ); break; } case driver_hint::securitysystemreset: { - if (AIControllFlag && mvOccupied->SecuritySystem.is_blinking()) - mvOccupied->SecuritySystemReset(); + if (AIControllFlag && occupied->SecuritySystem.is_blinking()) + occupied->SecuritySystemReset(); hint( Action, [this](float const /*Parameter*/) { - return !mvOccupied->SecuritySystem.is_vigilance_blinking(); } ); + return !occupied->SecuritySystem.is_vigilance_blinking(); } ); break; } case driver_hint::shpsystemreset: { - if (AIControllFlag && mvOccupied->SecuritySystem.is_cabsignal_blinking()) - mvOccupied->SecuritySystem.cabsignal_reset(); + if (AIControllFlag && occupied->SecuritySystem.is_cabsignal_blinking()) + occupied->SecuritySystem.cabsignal_reset(); hint( Action, [this](float const /*Parameter*/) { - return !mvOccupied->SecuritySystem.is_cabsignal_blinking(); } ); + return !occupied->SecuritySystem.is_cabsignal_blinking(); } ); break; } case driver_hint::couplingadapterattach: { @@ -1259,7 +1259,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const Parameter) { - auto const &device { pVehicles[ VehicleEnd::front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] }; + auto const &device { pVehicles[ VehicleEnd::front ]->physics->Couplers[ static_cast( Parameter ) ] }; return device.type() == TCouplerType::Automatic; } ); break; } @@ -1270,7 +1270,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const Parameter) { - auto const &device { pVehicles[ VehicleEnd::front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] }; + auto const &device { pVehicles[ VehicleEnd::front ]->physics->Couplers[ static_cast( Parameter ) ] }; return false == device.has_adapter(); } ); break; } @@ -1305,7 +1305,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // 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( mvOccupied->DirActive >= 0 ) { Lights( light::headlight_right, light::headlight_left ); } + if( occupied->DirActive >= 0 ) { Lights( light::headlight_right, light::headlight_left ); } else { Lights( light::headlight_left, light::headlight_right ); } } remove_hint( driver_hint::headcodepc1 ); @@ -1315,8 +1315,8 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - auto const activeend { mvOccupied->CabActive >= 0 ? VehicleEnd::front : VehicleEnd::rear }; - auto const consistfront { mvOccupied->DirActive >= 0 ? VehicleEnd::front : VehicleEnd::rear }; + auto const activeend { occupied->CabActive >= 0 ? VehicleEnd::front : VehicleEnd::rear }; + auto const consistfront { occupied->DirActive >= 0 ? VehicleEnd::front : VehicleEnd::rear }; return pVehicles[consistfront]->has_signal_on(activeend, light::headlight_right) && pVehicles[Opposite(consistfront)]->has_signal_on(Opposite(activeend), light::headlight_left); } ); break; } @@ -1344,32 +1344,32 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - auto const activeend { mvOccupied->CabActive >= 0 ? VehicleEnd::front : VehicleEnd::rear }; - auto const consistfront { mvOccupied->DirActive >= 0 ? VehicleEnd::front : VehicleEnd::rear }; + auto const activeend { occupied->CabActive >= 0 ? VehicleEnd::front : VehicleEnd::rear }; + auto const consistfront { occupied->DirActive >= 0 ? VehicleEnd::front : VehicleEnd::rear }; return pVehicles[consistfront]->has_signal_on(activeend, 0) && pVehicles[Opposite(consistfront)]->has_signal_on(Opposite(activeend), 0); } ); break; } // releaser case driver_hint::releaseron: { if( AIControllFlag ) { - mvOccupied->BrakeReleaser( 1 ); + occupied->BrakeReleaser( 1 ); } remove_hint( driver_hint::releaseroff ); hint( Action, [this](float const /*Parameter*/) { - return true == mvOccupied->Hamulec->Releaser(); } ); + return true == occupied->Hamulec->Releaser(); } ); break; } case driver_hint::releaseroff: { if( AIControllFlag ) { - mvOccupied->BrakeReleaser( 0 ); + occupied->BrakeReleaser( 0 ); } remove_hint( driver_hint::releaseron ); hint( Action, [this](float const /*Parameter*/) { - return false == mvOccupied->Hamulec->Releaser(); } ); + return false == occupied->Hamulec->Releaser(); } ); break; } diff --git a/application/drivermode.cpp b/application/drivermode.cpp index b121d7250..3b132cb60 100644 --- a/application/drivermode.cpp +++ b/application/drivermode.cpp @@ -31,7 +31,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "rendering/renderer.h" #include "utilities/Logs.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include @@ -682,7 +682,7 @@ void driver_mode::update_camera(double const Deltatime) if (controlled && glm::length2(controlled->GetPosition() - Camera.Pos) < sq(1500)) // length2 is better than length for comparing because it does not require sqrt function { // gdy bliżej niż 1.5km - Camera.LookAt = controlled->GetPosition() + 0.4 * controlled->VectorUp() * controlled->MoverParameters->Dim.H; + Camera.LookAt = controlled->GetPosition() + 0.4 * controlled->VectorUp() * controlled->physics->Dim.H; } else { @@ -702,7 +702,7 @@ void driver_mode::update_camera(double const Deltatime) if (d) pDynamicNearest = d; // zmiana na nowy, jeśli coś znaleziony niepusty if (pDynamicNearest) - Camera.LookAt = pDynamicNearest->GetPosition() + 0.4 * pDynamicNearest->VectorUp() * pDynamicNearest->MoverParameters->Dim.H; + Camera.LookAt = pDynamicNearest->GetPosition() + 0.4 * pDynamicNearest->VectorUp() * pDynamicNearest->physics->Dim.H; } Camera.RaLook(); // jednorazowe przestawienie kamery } @@ -787,7 +787,7 @@ void driver_mode::update_camera(double const Deltatime) { // jeśli jazda w kabinie, przeliczyć trzeba parametry kamery /* - auto tempangle = controlled->VectorFront() * ( controlled->MoverParameters->CabOccupied == -1 ? -1 : 1 ); + auto tempangle = controlled->VectorFront() * ( controlled->physics->CabOccupied == -1 ? -1 : 1 ); double modelrotate = atan2( -tempangle.x, tempangle.z ); */ if (false == FreeFlyModeFlag && true == Global.ctrlState && (m_input.keyboard.key(GLFW_KEY_LEFT) != GLFW_RELEASE || m_input.keyboard.key(GLFW_KEY_RIGHT) != GLFW_RELEASE)) @@ -1192,7 +1192,7 @@ void driver_mode::DistantView(bool const Near) return; } - auto const cab = vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied; + auto const cab = vehicle->physics->CabOccupied == 0 ? 1 : vehicle->physics->CabOccupied; auto const left = vehicle->VectorLeft() * (double)cab; if (true == Near) @@ -1203,7 +1203,7 @@ void driver_mode::DistantView(bool const Near) else { - Camera.Pos = vehicle->GetPosition() + vehicle->VectorFront() * (double)vehicle->MoverParameters->CabOccupied * 50.0 + glm::dvec3(-10.0 * left.x, 1.6, -10.0 * left.z); + Camera.Pos = vehicle->GetPosition() + vehicle->VectorFront() * (double)vehicle->physics->CabOccupied * 50.0 + glm::dvec3(-10.0 * left.x, 1.6, -10.0 * left.z); } Camera.m_owner = nullptr; @@ -1256,12 +1256,12 @@ void driver_mode::ExternalView() else { // default view setup - auto const offsetflip{(vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied) * - (vehicle->MoverParameters->DirActive == 0 ? 1 : vehicle->MoverParameters->DirActive)}; + auto const offsetflip{(vehicle->physics->CabOccupied == 0 ? 1 : vehicle->physics->CabOccupied) * + (vehicle->physics->DirActive == 0 ? 1 : vehicle->physics->DirActive)}; - Camera.m_owneroffset = {1.5 * owner->MoverParameters->Dim.W * offsetflip, std::max(5.0, 1.25 * owner->MoverParameters->Dim.H), -0.4 * owner->MoverParameters->Dim.L * offsetflip}; + Camera.m_owneroffset = {1.5 * owner->physics->Dim.W * offsetflip, std::max(5.0, 1.25 * owner->physics->Dim.H), -0.4 * owner->physics->Dim.L * offsetflip}; - Camera.Angle.y = glm::radians(vehicle->MoverParameters->DirActive < 0 ? 180.0 : 0.0); + Camera.Angle.y = glm::radians(vehicle->physics->DirActive < 0 ? 180.0 : 0.0); } auto const shakeangles{owner->shake_angles()}; Camera.Angle.x -= 0.5 * shakeangles.second; // hustanie kamery przod tyl @@ -1286,12 +1286,12 @@ void driver_mode::ExternalView() else { // default view setup - auto const offsetflip{(vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied) * - (vehicle->MoverParameters->DirActive == 0 ? 1 : vehicle->MoverParameters->DirActive) * -1}; + auto const offsetflip{(vehicle->physics->CabOccupied == 0 ? 1 : vehicle->physics->CabOccupied) * + (vehicle->physics->DirActive == 0 ? 1 : vehicle->physics->DirActive) * -1}; - Camera.m_owneroffset = {1.5 * owner->MoverParameters->Dim.W * offsetflip, std::max(5.0, 1.25 * owner->MoverParameters->Dim.H), 0.2 * owner->MoverParameters->Dim.L * offsetflip}; + Camera.m_owneroffset = {1.5 * owner->physics->Dim.W * offsetflip, std::max(5.0, 1.25 * owner->physics->Dim.H), 0.2 * owner->physics->Dim.L * offsetflip}; - Camera.Angle.y = glm::radians(vehicle->MoverParameters->DirActive < 0 ? 0.0 : 180.0); + Camera.Angle.y = glm::radians(vehicle->physics->DirActive < 0 ? 0.0 : 180.0); } auto const shakeangles{owner->shake_angles()}; Camera.Angle.x -= 0.5 * shakeangles.second; // hustanie kamery przod tyl @@ -1314,12 +1314,12 @@ void driver_mode::ExternalView() else { // default view setup - auto const offsetflip{(vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied) * - (vehicle->MoverParameters->DirActive == 0 ? 1 : vehicle->MoverParameters->DirActive)}; + auto const offsetflip{(vehicle->physics->CabOccupied == 0 ? 1 : vehicle->physics->CabOccupied) * + (vehicle->physics->DirActive == 0 ? 1 : vehicle->physics->DirActive)}; - Camera.m_owneroffset = {-0.65 * owner->MoverParameters->Dim.W * offsetflip, 0.90, 0.15 * owner->MoverParameters->Dim.L * offsetflip}; + Camera.m_owneroffset = {-0.65 * owner->physics->Dim.W * offsetflip, 0.90, 0.15 * owner->physics->Dim.L * offsetflip}; - Camera.Angle.y = glm::radians(vehicle->MoverParameters->DirActive < 0 ? 180.0 : 0.0); + Camera.Angle.y = glm::radians(vehicle->physics->DirActive < 0 ? 180.0 : 0.0); } auto const shakeangles{owner->shake_angles()}; Camera.Angle.x -= 0.5 * shakeangles.second; // hustanie kamery przod tyl @@ -1389,7 +1389,7 @@ void driver_mode::CabView() else { // patrz w strone wlasciwej kabiny - Camera.LookAt = Camera.m_owner->GetWorldPosition(Camera.m_owneroffset) + Camera.m_owner->VectorFront() * 5.0 * (double)Camera.m_owner->MoverParameters->CabOccupied; + Camera.LookAt = Camera.m_owner->GetWorldPosition(Camera.m_owneroffset) + Camera.m_owner->VectorFront() * 5.0 * (double)Camera.m_owner->physics->CabOccupied; } train->pMechOffset = Camera.m_owneroffset; } diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 53d988a29..f811d8df0 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -34,7 +34,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "widgets/vehicleparams.h" #include "utilities/U8.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #define DRIVER_HINT_CONTENT #include "application/driverhints.h" @@ -57,11 +57,11 @@ constexpr float coupler_repair_radius { 5.f }; // the broken coupler nearest to the camera, within reach: the vehicle and its end, or no vehicle std::pair broken_coupler_nearby( glm::dvec3 const &Camera ) { auto const *vehicle { std::get( simulation::Region->find_vehicle( Camera, coupler_repair_radius, false, true ) ) }; - if( vehicle == nullptr || vehicle->MoverParameters == nullptr ) { return { nullptr, VehicleEnd::front }; } + if( vehicle == nullptr || vehicle->physics == nullptr ) { return { nullptr, VehicleEnd::front }; } auto const front { glm::distance( vehicle->CouplerPosition( VehicleEnd::front ), Camera ) }; auto const rear { glm::distance( vehicle->CouplerPosition( VehicleEnd::rear ), Camera ) }; auto const nearest { front <= rear ? VehicleEnd::front : VehicleEnd::rear }; - if( std::min( front, rear ) > coupler_repair_radius || false == vehicle->MoverParameters->Couplers[ nearest ].broken ) { return { nullptr, VehicleEnd::front }; } + if( std::min( front, rear ) > coupler_repair_radius || false == vehicle->physics->Couplers[ nearest ].broken ) { return { nullptr, VehicleEnd::front }; } return { vehicle, nearest }; } @@ -82,12 +82,12 @@ drivingaid_panel::update() { if( controlled == nullptr || controlled->Mechanik == nullptr ) { return; } - auto const *mover = controlled->MoverParameters; + auto const *physics = controlled->physics; auto const *vehicledriver = controlled->Mechanik; auto const *owner = controlled->ctOwner != nullptr ? controlled->ctOwner : controlled->Mechanik; // the numbers of the throttle and brakes lines, with the controls of the cab the driver is in - auto const readout { drivingaid::compute( drivingaid::from_movers( - *mover, + auto const readout { drivingaid::compute( drivingaid::from_vehicles( + *physics, *vehicledriver->Controlling(), drivingaid::cab_controls { train->ggLocalBrake.SubModel != nullptr, @@ -98,7 +98,7 @@ drivingaid_panel::update() { if( is_expanded ) { // grade std::string gradetext; - auto const reverser { ( mover->DirActive > 0 ? 1 : -1 ) }; + auto const reverser { ( physics->DirActive > 0 ? 1 : -1 ) }; if( auto const grade { controlled->VectorFront().y * 100 * ( controlled->DirectionGet() == reverser ? 1 : -1 ) * reverser }; std::abs( grade ) >= 0.25 ) { std::snprintf( m_buffer.data(), m_buffer.size(), @@ -122,7 +122,7 @@ drivingaid_panel::update() { std::snprintf( m_buffer.data(), m_buffer.size(), STR_C(" Speed: %d km/h (limit %d km/h%s)%s"), - static_cast( std::floor( mover->Vel ) ), + static_cast( std::floor( physics->Vel ) ), speedlimit, nextspeedlimittext.c_str(), gradetext.c_str() ); @@ -134,9 +134,9 @@ drivingaid_panel::update() { STR_C("Throttle: %3d+%d %c%s"), readout.throttle_first, readout.throttle_second, - mover->SpeedCtrlUnit.IsActive ? 'T' : - mover->DirActive > 0 ? 'D' : - mover->DirActive < 0 ? 'R' : + physics->SpeedCtrlUnit.IsActive ? 'T' : + physics->DirActive > 0 ? 'D' : + physics->DirActive < 0 ? 'R' : 'N', expandedtext.c_str()); @@ -149,8 +149,8 @@ drivingaid_panel::update() { std::snprintf ( m_buffer.data(), m_buffer.size(), STR_C(" Pressure: %.2f kPa (train pipe: %.2f kPa)"), - mover->BrakePress * 100, - mover->PipePress * 100 ); + physics->BrakePress * 100, + physics->PipePress * 100 ); expandedtext = m_buffer.data(); } if( readout.ed_percent ) { @@ -167,7 +167,7 @@ drivingaid_panel::update() { STR_C("Brakes: %5.1f+%-2.0f%c%s"), readout.brake_first, readout.local_brake, - mover->SlippingWheels ? '!' : ' ', + physics->SlippingWheels ? '!' : ' ', expandedtext.c_str() ); } else { @@ -176,7 +176,7 @@ drivingaid_panel::update() { m_buffer.data(), m_buffer.size(), STR_C("Brakes: %5.1f%c%s"), readout.brake_first, - mover->SlippingWheels ? '!' : ' ', + physics->SlippingWheels ? '!' : ' ', expandedtext.c_str() ); } @@ -206,9 +206,9 @@ drivingaid_panel::update() { } } std::string textline = - mover->SecuritySystem.is_vigilance_blinking() && (train != nullptr ? train->fBlinkTimer > 0 : true) ? STR("!ALERTER! ") : " "; + physics->SecuritySystem.is_vigilance_blinking() && (train != nullptr ? train->fBlinkTimer > 0 : true) ? STR("!ALERTER! ") : " "; textline += - mover->SecuritySystem.is_cabsignal_blinking() ? STR("!SHP!") : " "; + physics->SecuritySystem.is_cabsignal_blinking() ? STR("!SHP!") : " "; text_lines.emplace_back( textline + " " + expandedtext, Global.UITextColor ); } @@ -386,11 +386,11 @@ timetable_panel::update() { if( false == owner->is_dmu() && false == owner->is_emu() ) { //odejmij lokomotywy czynne, a przynajmniej aktualną - consistmass -= owner->pVehicle->MoverParameters->TotalMass; + consistmass -= owner->pVehicle->physics->TotalMass; // subtract potential other half of a two-part vehicle - if( auto const *previous { owner->pVehicle->Prev( Coupling::permanent ) }; previous != nullptr ) { consistmass -= previous->MoverParameters->TotalMass; } + if( auto const *previous { owner->pVehicle->Prev( Coupling::permanent ) }; previous != nullptr ) { consistmass -= previous->physics->TotalMass; } auto const *next { owner->pVehicle->Next( Coupling::permanent ) }; - if( next != nullptr ) { consistmass -= next->MoverParameters->TotalMass; } + if( next != nullptr ) { consistmass -= next->physics->TotalMass; } } std::snprintf( m_buffer.data(), m_buffer.size(), @@ -452,7 +452,7 @@ timetable_panel::update() { || tableline->is_maintenance // maintenance stop, always valid || time.wHour * 60 + time.wMinute + time.wSecond * 0.0167 >= static_cast(tableline->Dh * 60) + tableline->Dm ) ) }; auto const loadchangeinprogress { ( static_cast(std::ceil(-1.0 * owner->fStopTime)) > 0 ) }; - auto const isatpassengerstop { true == owner->IsAtPassengerStop && vehicle->MoverParameters->Vel < 1.0 }; + auto const isatpassengerstop { true == owner->IsAtPassengerStop && vehicle->physics->Vel < 1.0 }; auto const traveltime { ( i < 2 ? " " : tableline->Ah >= 0 ? to_minutes_str( static_cast(CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Ah, tableline->Am )), false, 3 ) : @@ -537,8 +537,8 @@ void debug_panel::update() m_input.vehicle = false == FreeFlyModeFlag ? m_input.controlled : m_input.camera->m_owner != nullptr ? m_input.camera->m_owner : std::get(simulation::Region->find_vehicle(m_input.camera->Pos, 20, false, false)); // w trybie latania lokalizujemy wg mapy - m_input.mover = - m_input.vehicle != nullptr ? m_input.vehicle->MoverParameters : nullptr; + m_input.physics = + m_input.vehicle != nullptr ? m_input.vehicle->physics : nullptr; m_input.mechanik = m_input.vehicle != nullptr ? m_input.vehicle->Mechanik : nullptr; // header section @@ -618,7 +618,7 @@ debug_panel::render() { } // sections ImGui::Separator(); - if (true == render_section( "Vehicle", m_vehiclelines ) && DebugModeFlag && m_input.mover && false == m_input.mover->DamageFlag.Empty() && true == ImGui::Button( "Stop and repair consist" )) { + if (true == render_section( "Vehicle", m_vehiclelines ) && DebugModeFlag && m_input.physics && false == m_input.physics->DamageFlag.Empty() && true == ImGui::Button( "Stop and repair consist" )) { command_relay commandrelay; commandrelay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name()); } @@ -788,25 +788,25 @@ void debug_panel::update_section_vehicle( std::vector &Output ) { if( m_input.vehicle == nullptr ) { return; } - if( m_input.mover == nullptr ) { return; } + if( m_input.physics == nullptr ) { return; } auto const &vehicle { *m_input.vehicle }; - auto const &mover { *m_input.mover }; + auto const &physics { *m_input.physics }; auto const isowned { /* ( vehicle.Mechanik == nullptr ) && */ vehicle.ctOwner != nullptr && vehicle.ctOwner->Vehicle() != m_input.vehicle }; - auto const isdieselenginepowered { mover.EngineType == TEngineType::DieselElectric || mover.EngineType == TEngineType::DieselEngine }; - auto const isdieselinshuntmode { mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric }; + auto const isdieselenginepowered { physics.EngineType == TEngineType::DieselElectric || physics.EngineType == TEngineType::DieselEngine }; + auto const isdieselinshuntmode { physics.ShuntMode && physics.EngineType == TEngineType::DieselElectric }; std::snprintf( m_buffer.data(), m_buffer.size(), STR_C("Name: %s%s\nLoad: %.0f %s\nStatus: %s%s\nCouplers:\n front: %s\n rear: %s"), - mover.Name.c_str(), + physics.Name.c_str(), std::string( isowned ? STR(", owned by: ") + vehicle.ctOwner->OwnerName() : "" ).c_str(), - mover.LoadAmount, - mover.LoadType.name.c_str(), - mover.EngineDescription( 0 ).c_str(), + physics.LoadAmount, + physics.LoadType.name.c_str(), + physics.EngineDescription( 0 ).c_str(), // TODO: put wheel flat reporting in the enginedescription() - std::string( mover.WheelFlat > 0.01 ? " Flat: " + to_string( mover.WheelFlat, 1 ) + " mm" : "" ).c_str(), + std::string( physics.WheelFlat > 0.01 ? " Flat: " + to_string( physics.WheelFlat, 1 ) + " mm" : "" ).c_str(), update_vehicle_coupler( VehicleEnd::front ).c_str(), update_vehicle_coupler( VehicleEnd::rear ).c_str() ); @@ -816,71 +816,71 @@ debug_panel::update_section_vehicle( std::vector &Output ) { m_buffer.data(), m_buffer.size(), STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s[%.0f]%s%.0f@%.0f :: %.0f@%.0f%s[%.0f]%s%.0f@%.0f"), // devices - mover.Battery ? 'B' : '.', - mover.PantsValve.is_active ? '+' : '.', - mover.Pantographs[VehicleEnd::rear].valve.is_active ? 'O' : - mover.Pantographs[VehicleEnd::rear].valve.is_enabled ? 'o' : + physics.Battery ? 'B' : '.', + physics.PantsValve.is_active ? '+' : '.', + physics.Pantographs[VehicleEnd::rear].valve.is_active ? 'O' : + physics.Pantographs[VehicleEnd::rear].valve.is_enabled ? 'o' : '.', - mover.Pantographs[VehicleEnd::front].valve.is_active ? 'P' : - mover.Pantographs[VehicleEnd::front].valve.is_enabled ? 'p' : + physics.Pantographs[VehicleEnd::front].valve.is_active ? 'P' : + physics.Pantographs[VehicleEnd::front].valve.is_enabled ? 'p' : '.', - mover.PantPressLockActive ? '!' : - mover.PantPressSwitchActive ? '*' : + physics.PantPressLockActive ? '!' : + physics.PantPressSwitchActive ? '*' : '.', - mover.WaterPump.is_active ? 'W' : - false == mover.WaterPump.breaker ? '-' : - mover.WaterPump.is_enabled ? 'w' : + physics.WaterPump.is_active ? 'W' : + false == physics.WaterPump.breaker ? '-' : + physics.WaterPump.is_enabled ? 'w' : '.', - mover.WaterHeater.is_damaged ? '!' : - mover.WaterHeater.is_active ? 'H' : - false == mover.WaterHeater.breaker ? '-' : - mover.WaterHeater.is_enabled ? 'h' : + physics.WaterHeater.is_damaged ? '!' : + physics.WaterHeater.is_active ? 'H' : + false == physics.WaterHeater.breaker ? '-' : + physics.WaterHeater.is_enabled ? 'h' : '.', - mover.FuelPump.is_active ? 'F' : - mover.FuelPump.is_enabled ? 'f' : + physics.FuelPump.is_active ? 'F' : + physics.FuelPump.is_enabled ? 'f' : '.', - mover.OilPump.is_active ? 'O' : - mover.OilPump.is_enabled ? 'o' : + physics.OilPump.is_active ? 'O' : + physics.OilPump.is_enabled ? 'o' : '.', - mover.Mains ? 'M' : '.', - mover.FuseFlag ? '!' : '.', - mover.ConverterFlag ? 'X' : - false == mover.ConverterAllowLocal ? '-' : - mover.ConverterAllow ? 'x' : + physics.Mains ? 'M' : '.', + physics.FuseFlag ? '!' : '.', + physics.ConverterFlag ? 'X' : + false == physics.ConverterAllowLocal ? '-' : + physics.ConverterAllow ? 'x' : '.', - mover.ConvOvldFlag ? '!' : '.', - mover.CompressorFlag ? 'C' : - false == mover.CompressorAllowLocal ? '-' : - mover.CompressorAllow || (mover.CompressorStart == start_t::automatic && mover.CompressorSpeed > 0.0) ? 'c' : + physics.ConvOvldFlag ? '!' : '.', + physics.CompressorFlag ? 'C' : + false == physics.CompressorAllowLocal ? '-' : + physics.CompressorAllow || (physics.CompressorStart == start_t::automatic && physics.CompressorSpeed > 0.0) ? 'c' : '.', - mover.CompressorGovernorLock ? '!' : '.', - mover.StLinSwitchOff ? '-' : - mover.ControlPressureSwitch ? '!' : - mover.StLinFlag ? '+' : + physics.CompressorGovernorLock ? '!' : '.', + physics.StLinSwitchOff ? '-' : + physics.ControlPressureSwitch ? '!' : + physics.StLinFlag ? '+' : '.', - mover.Heating ? 'H' : - mover.HeatingAllow ? 'h' : + physics.Heating ? 'H' : + physics.HeatingAllow ? 'h' : '.', - mover.Hamulec->Releaser() ? '^' : '.', - std::string( m_input.mechanik ? STR(" R") + ( mover.Radio && mover.RadioFuse ? std::to_string( m_input.mechanik->iRadioChannel ) : "-" ) : "" ).c_str(), - std::string( isdieselenginepowered ? STR(" oil pressure: ") + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(), + physics.Hamulec->Releaser() ? '^' : '.', + std::string( m_input.mechanik ? STR(" R") + ( physics.Radio && physics.RadioFuse ? std::to_string( m_input.mechanik->iRadioChannel ) : "-" ) : "" ).c_str(), + std::string( isdieselenginepowered ? STR(" oil pressure: ") + to_string( physics.OilPump.pressure, 2 ) : "" ).c_str(), // power transfers // 3000v - mover.Couplers[ VehicleEnd::front ].power_high.voltage, - mover.Couplers[ VehicleEnd::front ].power_high.current, - std::string( mover.Couplers[ VehicleEnd::front ].power_high.is_local ? ":" : ":=" ).c_str(), - mover.EngineVoltage, - std::string( mover.Couplers[ VehicleEnd::rear ].power_high.is_local ? ":" : "=:" ).c_str(), - mover.Couplers[ VehicleEnd::rear ].power_high.voltage, - mover.Couplers[ VehicleEnd::rear ].power_high.current, + physics.Couplers[ VehicleEnd::front ].power_high.voltage, + physics.Couplers[ VehicleEnd::front ].power_high.current, + std::string( physics.Couplers[ VehicleEnd::front ].power_high.is_local ? ":" : ":=" ).c_str(), + physics.EngineVoltage, + std::string( physics.Couplers[ VehicleEnd::rear ].power_high.is_local ? ":" : "=:" ).c_str(), + physics.Couplers[ VehicleEnd::rear ].power_high.voltage, + physics.Couplers[ VehicleEnd::rear ].power_high.current, // 110v - mover.Couplers[ VehicleEnd::front ].power_110v.voltage, - mover.Couplers[ VehicleEnd::front ].power_110v.current, - std::string( mover.Couplers[ VehicleEnd::front ].power_110v.is_local ? ":" : ":=" ).c_str(), - mover.PowerCircuits[ 1 ].first, - std::string( mover.Couplers[ VehicleEnd::rear ].power_110v.is_local ? ":" : "=:" ).c_str(), - mover.Couplers[ VehicleEnd::rear ].power_110v.voltage, - mover.Couplers[ VehicleEnd::rear ].power_110v.current ); + physics.Couplers[ VehicleEnd::front ].power_110v.voltage, + physics.Couplers[ VehicleEnd::front ].power_110v.current, + std::string( physics.Couplers[ VehicleEnd::front ].power_110v.is_local ? ":" : ":=" ).c_str(), + physics.PowerCircuits[ 1 ].first, + std::string( physics.Couplers[ VehicleEnd::rear ].power_110v.is_local ? ":" : "=:" ).c_str(), + physics.Couplers[ VehicleEnd::rear ].power_110v.voltage, + physics.Couplers[ VehicleEnd::rear ].power_110v.current ); Output.emplace_back( m_buffer.data(), Global.UITextColor ); @@ -888,20 +888,20 @@ debug_panel::update_section_vehicle( std::vector &Output ) { m_buffer.data(), m_buffer.size(), STR_C("Controllers:\n master: %d(%d), secondary: %s\nEngine output: %.1f, current: %.0f\nRevolutions:\n engine: %.0f, motors: %.0f\n engine fans: %.0f, motor fans: %.0f+%.0f, cooling fans: %.0f+%.0f"), // controllers - mover.MainCtrlPos, - mover.MainCtrlActualPos, - std::string( isdieselinshuntmode ? to_string( mover.AnPos, 2 ) + STR(" (shunt mode)") : std::to_string( mover.ScndCtrlPos ) + "(" + std::to_string( mover.ScndCtrlActualPos ) + ")" ).c_str(), + physics.MainCtrlPos, + physics.MainCtrlActualPos, + std::string( isdieselinshuntmode ? to_string( physics.AnPos, 2 ) + STR(" (shunt mode)") : std::to_string( physics.ScndCtrlPos ) + "(" + std::to_string( physics.ScndCtrlActualPos ) + ")" ).c_str(), // engine - mover.EnginePower, - std::abs( mover.TrainType == train_type::emu ? mover.ShowCurrent( 0 ) : mover.Im ), + physics.EnginePower, + std::abs( physics.TrainType == train_type::emu ? physics.ShowCurrent( 0 ) : physics.Im ), // revolutions - std::abs( mover.enrot ) * 60, - std::abs( mover.nrot ) * mover.Transmision.Ratio * 60, - mover.RventRot * 60, - std::abs( mover.MotorBlowers[VehicleEnd::front].revolutions ), - std::abs( mover.MotorBlowers[VehicleEnd::rear].revolutions ), - mover.diesel.heat.rpmw, - mover.diesel.heat.rpmw2 ); + std::abs( physics.enrot ) * 60, + std::abs( physics.nrot ) * physics.Transmision.Ratio * 60, + physics.RventRot * 60, + std::abs( physics.MotorBlowers[VehicleEnd::front].revolutions ), + std::abs( physics.MotorBlowers[VehicleEnd::rear].revolutions ), + physics.diesel.heat.rpmw, + physics.diesel.heat.rpmw2 ); std::string textline { m_buffer.data() }; @@ -909,11 +909,11 @@ debug_panel::update_section_vehicle( std::vector &Output ) { std::snprintf( m_buffer.data(), m_buffer.size(), STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"), - mover.diesel.heat.Ts, - mover.diesel.heat.To, - mover.diesel.heat.temperatura1, - mover.WaterCircuitsLink ? '-' : '|', - mover.diesel.heat.temperatura2 ); + physics.diesel.heat.Ts, + physics.diesel.heat.To, + physics.diesel.heat.temperatura1, + physics.WaterCircuitsLink ? '-' : '|', + physics.diesel.heat.temperatura2 ); textline += m_buffer.data(); } @@ -923,36 +923,36 @@ debug_panel::update_section_vehicle( std::vector &Output ) { m_buffer.data(), m_buffer.size(), STR_C("Brakes:\n train: %.2f (mode: %d, delay: %s, load flag: %d)\n independent: %.2f (%.2f), manual: %.2f, spring: %.2f\nBrake cylinder pressures:\n train: %.2f, independent: %.2f, status: 0x%.2x\nPipe pressures:\n brake: %.2f (hat: %.2f), main: %.2f, control: %.2f\nTank pressures:\n auxiliary: %.2f, main: %.2f, control: %.2f"), // brakes - mover.fBrakeCtrlPos, - mover.BrakeOpModeFlag, + physics.fBrakeCtrlPos, + physics.BrakeOpModeFlag, update_vehicle_brake().c_str(), - mover.LoadFlag, - mover.LocalBrakePosA, - mover.LocalBrakePosAEIM, - static_cast(mover.ManualBrakePos) / static_cast(ManualBrakePosNo), - mover.SpringBrake.Activate ? 1.f : 0.f, + physics.LoadFlag, + physics.LocalBrakePosA, + physics.LocalBrakePosAEIM, + static_cast(physics.ManualBrakePos) / static_cast(ManualBrakePosNo), + physics.SpringBrake.Activate ? 1.f : 0.f, // cylinders - mover.BrakePress, - mover.LocBrakePress, - mover.Hamulec->GetBrakeStatus(), + physics.BrakePress, + physics.LocBrakePress, + physics.Hamulec->GetBrakeStatus(), // pipes - mover.PipePress, - mover.BrakeCtrlPos2, - mover.ScndPipePress, - mover.CntrlPipePress, + physics.PipePress, + physics.BrakeCtrlPos2, + physics.ScndPipePress, + physics.CntrlPipePress, // tanks - mover.Hamulec->GetBRP(), - mover.Compressor, - mover.Hamulec->GetCRP() ); + physics.Hamulec->GetBRP(), + physics.Compressor, + physics.Hamulec->GetCRP() ); textline = m_buffer.data(); - if( mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { + if( physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { std::snprintf( m_buffer.data(), m_buffer.size(), STR_C(" pantograph: %.2f%cMT"), - mover.PantPress, - mover.bPantKurek3 ? '-' : '|' ); + physics.PantPress, + physics.bPantKurek3 ? '-' : '|' ); textline += m_buffer.data(); } @@ -962,17 +962,17 @@ debug_panel::update_section_vehicle( std::vector &Output ) { m_buffer.data(), m_buffer.size(), STR_C("Forces:\n tractive: %.1f, brake: %.1f, drag: %.2f%s\nAcceleration:\n tangential: %.2f, normal: %.2f (path radius: %s)\nVelocity: %.2f, distance traveled: %.2f\nPosition: [%.2f, %.2f, %.2f]"), // forces - mover.Ft * 0.001f * ( mover.CabOccupied ? mover.CabOccupied : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabOccupied : 1 ) + 0.001f, - mover.Fb * 0.001f, - mover.FrictionForce() * 0.001f, - mover.SlippingWheels ? " (!)" : "", + physics.Ft * 0.001f * ( physics.CabOccupied ? physics.CabOccupied : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabOccupied : 1 ) + 0.001f, + physics.Fb * 0.001f, + physics.FrictionForce() * 0.001f, + physics.SlippingWheels ? " (!)" : "", // acceleration - mover.AccSVBased, - mover.AccN + 0.001f, - std::string( std::abs( mover.RunningShape.R ) > 15000.0 ? "~0" : to_string( mover.RunningShape.R, 0 ) ).c_str(), + physics.AccSVBased, + physics.AccN + 0.001f, + std::string( std::abs( physics.RunningShape.R ) > 15000.0 ? "~0" : to_string( physics.RunningShape.R, 0 ) ).c_str(), // velocity vehicle.GetVelocity(), - mover.DistCounter, + physics.DistCounter, // position vehicle.GetPosition().x, vehicle.GetPosition().y, @@ -980,9 +980,9 @@ debug_panel::update_section_vehicle( std::vector &Output ) { Output.emplace_back( m_buffer.data(), Global.UITextColor ); - if( mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { + if( physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { std::snprintf(m_buffer.data(), m_buffer.size(), STR_C("Power use:\n drawn: %.1f kWh\n returned: %.1f kWh\n balance: %.1f kWh"), - mover.EnergyMeter.first, -mover.EnergyMeter.second, mover.EnergyMeter.first + mover.EnergyMeter.second); + physics.EnergyMeter.first, -physics.EnergyMeter.second, physics.EnergyMeter.first + physics.EnergyMeter.second); textline = m_buffer.data(); if( DebugTractionFlag ) { for( int i = 0; i < vehicle.iAnimType[ ANIM_PANTS ]; ++i ) { // pętla po wszystkich pantografach @@ -1007,11 +1007,11 @@ debug_panel::update_section_vehicle( std::vector &Output ) { if (!std::isnan(last_time)) { double dt = Timer::GetTime() - last_time; - AccN_jerk_graph.update(static_cast((mover.AccN - last_AccN) / dt)); - AccN_acc_graph.update(static_cast(mover.AccN)); + AccN_jerk_graph.update(static_cast((physics.AccN - last_AccN) / dt)); + AccN_acc_graph.update(static_cast(physics.AccN)); } - last_AccN = static_cast(mover.AccN); + last_AccN = static_cast(physics.AccN); last_time = Timer::GetTime(); } @@ -1034,14 +1034,14 @@ void debug_panel::graph_data::render() { std::string debug_panel::update_vehicle_coupler( VehicleEnd const Side ) { - // NOTE: mover and vehicle are guaranteed to be valid by the caller - auto const &mover { *m_input.mover }; + // NOTE: physics and vehicle are guaranteed to be valid by the caller + auto const &physics { *m_input.physics }; - std::string const controltype{ ( mover.Couplers[ Side ].control_type.empty() ? "[*]" : "[" + mover.Couplers[ Side ].control_type + "]" ) }; + std::string const controltype{ ( physics.Couplers[ Side ].control_type.empty() ? "[*]" : "[" + physics.Couplers[ Side ].control_type + "]" ) }; std::string couplerstatus { STR("none") }; - std::string const adapterstatus { ( mover.Couplers[ Side ].adapter_type == TCouplerType::NoCoupler ? "" : "[A]" ) }; + std::string const adapterstatus { ( physics.Couplers[ Side ].adapter_type == TCouplerType::NoCoupler ? "" : "[A]" ) }; - auto const *connected { m_input.vehicle->MoverParameters->Neighbours[ Side ].vehicle }; + auto const *connected { m_input.vehicle->physics->Neighbours[ Side ].vehicle }; if( connected == nullptr ) { @@ -1054,16 +1054,16 @@ debug_panel::update_vehicle_coupler( VehicleEnd const Side ) { controltype.c_str(), connected->name().c_str(), adapterstatus.c_str(), - mover.Couplers[ Side ].CouplingFlag, - mover.Neighbours[ Side ].distance ); + physics.Couplers[ Side ].CouplingFlag, + physics.Neighbours[ Side ].distance ); return { m_buffer.data() }; } std::string debug_panel::update_vehicle_brake() const { - // NOTE: mover is guaranteed to be valid by the caller - auto const &mover { *m_input.mover }; + // NOTE: physics is guaranteed to be valid by the caller + auto const &physics { *m_input.physics }; std::string brakedelay; @@ -1074,7 +1074,7 @@ debug_panel::update_vehicle_brake() const { { bdelay_M, "+Mg" } }; for( auto const &[delayflag, delayname] : delays ) { - if( ( mover.BrakeDelayFlag & delayflag ) == delayflag ) { + if( ( physics.BrakeDelayFlag & delayflag ) == delayflag ) { brakedelay += delayname; } } @@ -1086,17 +1086,17 @@ void debug_panel::update_section_engine( std::vector &Output ) const { if( m_input.vehicle == nullptr ) { return; } - if( m_input.mover == nullptr ) { return; } + if( m_input.physics == nullptr ) { return; } auto const &vehicle{ *m_input.vehicle }; - auto const &mover{ *m_input.mover }; + auto const &physics{ *m_input.physics }; // induction motor data - if( mover.EngineType == TEngineType::ElectricInductionMotor ) { + if( physics.EngineType == TEngineType::ElectricInductionMotor ) { Output.emplace_back( " eimc: eimv: press:", Global.UITextColor ); - auto const config{ mover.inductionMotor.ConfigListing() }; - auto const state{ mover.inductionMotor.StateListing() }; + auto const config{ physics.inductionMotor.ConfigListing() }; + auto const state{ physics.inductionMotor.StateListing() }; for( int i = 0; i <= 20; ++i ) { std::string parameters = @@ -1117,29 +1117,29 @@ debug_panel::update_section_engine( std::vector &Output ) const { Output.emplace_back( parameters, Global.UITextColor ); } - Output.emplace_back( "Inverter:\n frequency: " + to_string( mover.inductionMotor.inverterFrequency, 2 ), Global.UITextColor ); + Output.emplace_back( "Inverter:\n frequency: " + to_string( physics.inductionMotor.inverterFrequency, 2 ), Global.UITextColor ); } // diesel engine data - if( mover.EngineType == TEngineType::DieselEngine ) { + if( physics.EngineType == TEngineType::DieselEngine ) { double fuel_mean = 0.0; - if (mover.DistCounter > 0.5) { - fuel_mean = 100 * mover.diesel.fuelConsumedTotal / mover.DistCounter; + if (physics.DistCounter > 0.5) { + fuel_mean = 100 * physics.diesel.fuelConsumedTotal / physics.DistCounter; } std::string parameterstext = "param value"; std::vector< std::pair > const paramvalues { - { " rpm: ", mover.enrot * 60.0 }, - { "efill: ", mover.diesel.fill }, - { "etorq: ", mover.diesel.torque }, - { "power: ", mover.diesel.power }, - { "f_act: ", mover.diesel.fuelConsumptionActual }, - { "f_tot: ", mover.diesel.fuelConsumedTotal }, + { " rpm: ", physics.enrot * 60.0 }, + { "efill: ", physics.diesel.fill }, + { "etorq: ", physics.diesel.torque }, + { "power: ", physics.diesel.power }, + { "f_act: ", physics.diesel.fuelConsumptionActual }, + { "f_tot: ", physics.diesel.fuelConsumedTotal }, { "fmean: ", fuel_mean }, - { "creal: ", mover.diesel.clutchPressure }, - { "cdesi: ", mover.diesel.clutchState }, - { "cdelt: ", mover.diesel.clutchSlip }, - { "gears: ", mover.diesel.automaticGearShift} }; + { "creal: ", physics.diesel.clutchPressure }, + { "cdesi: ", physics.diesel.clutchState }, + { "cdelt: ", physics.diesel.clutchSlip }, + { "gears: ", physics.diesel.automaticGearShift} }; for( auto const &[parametername, parametervalue] : paramvalues ) { parameterstext += "\n" + parametername + to_string( parametervalue, 2, 9 ); } @@ -1147,15 +1147,15 @@ debug_panel::update_section_engine( std::vector &Output ) const { parameterstext = "hydro value"; std::vector< std::pair > const hydrovalues { - { "hTCnI: ", mover.torqueConverter.revolutionsIn }, - { "hTCnO: ", mover.torqueConverter.revolutionsOut }, - { "hTCTM: ", mover.torqueConverter.torqueRatio }, - { "hTCTI: ", mover.torqueConverter.torqueIn }, - { "hTCTO: ", mover.torqueConverter.torqueOut }, - { "hTCfl: ", mover.torqueConverter.fill }, - { "hRtFl: ", mover.retarder.fill } , - { " hRtn: ", mover.retarder.revolutions } , - { "hRtTq: ", mover.retarder.torque } + { "hTCnI: ", physics.torqueConverter.revolutionsIn }, + { "hTCnO: ", physics.torqueConverter.revolutionsOut }, + { "hTCTM: ", physics.torqueConverter.torqueRatio }, + { "hTCTI: ", physics.torqueConverter.torqueIn }, + { "hTCTO: ", physics.torqueConverter.torqueOut }, + { "hTCfl: ", physics.torqueConverter.fill }, + { "hRtFl: ", physics.retarder.fill } , + { " hRtn: ", physics.retarder.revolutions } , + { "hRtTq: ", physics.retarder.torque } }; for( auto const &[parametername, parametervalue] : hydrovalues ) { @@ -1168,10 +1168,10 @@ debug_panel::update_section_engine( std::vector &Output ) const { void debug_panel::update_section_ai( std::vector &Output ) const { - if( m_input.mover == nullptr ) { return; } + if( m_input.physics == nullptr ) { return; } if( m_input.mechanik == nullptr ) { return; } - auto const &mover{ *m_input.mover }; + auto const &physics{ *m_input.physics }; auto const &mechanik{ *m_input.mechanik }; // biezaca komenda dla AI @@ -1220,14 +1220,14 @@ debug_panel::update_section_ai( std::vector &Output ) const { textline = "Velocity:\n desired: " + to_string( mechanik.VelDesired, 0 ) + ", next: " + to_string( mechanik.VelNext, 0 ) - + "\n current: " + to_string( mover.Vel + 0.001f, 2 ); + + "\n current: " + to_string( physics.Vel + 0.001f, 2 ); std::vector< std::pair< double, std::string > > const restrictions{ { mechanik.VelSignalLast, "signal" }, { mechanik.VelLimitLast, "limit" }, { mechanik.VelRoad, "road" }, { mechanik.VelRestricted, "restricted" }, - { mover.RunningTrack.Velmax, "track" } }; + { physics.RunningTrack.Velmax, "track" } }; std::string restrictionstext; for( auto const &[restrictionspeed, restrictionsource] : restrictions ) { @@ -1609,16 +1609,16 @@ debug_panel::update_section_coupler( std::vector &Output ) { if( m_input.camera == nullptr ) { return; } auto const &camera { m_input.camera->Pos }; auto const *vehicle { std::get( simulation::Region->find_vehicle( camera, coupler_pick_radius, false, true ) ) }; - if( vehicle == nullptr || vehicle->MoverParameters == nullptr ) { + if( vehicle == nullptr || vehicle->physics == nullptr ) { Output.emplace_back( std::format( "No coupler within {:.0f} m of the camera", coupler_pick_radius ), Global.UITextColor ); return; } auto const nearerfront { glm::distance( vehicle->CouplerPosition( VehicleEnd::front ), camera ) <= glm::distance( vehicle->CouplerPosition( VehicleEnd::rear ), camera ) }; m_coupler = { vehicle, nearerfront ? VehicleEnd::front : VehicleEnd::rear }; - auto const &mover { *vehicle->MoverParameters }; - auto const &coupler { mover.Couplers[ m_coupler.end ] }; - auto const &neighbour { mover.Neighbours[ m_coupler.end ] }; + auto const &physics { *vehicle->physics }; + auto const &coupler { physics.Couplers[ m_coupler.end ] }; + auto const &neighbour { physics.Neighbours[ m_coupler.end ] }; auto const &state { coupler.physics_state }; Output.emplace_back( @@ -1627,9 +1627,9 @@ debug_panel::update_section_coupler( std::vector &Output ) { Output.emplace_back( std::format( "Model: {} (couplerphysics {}, vehicle {}covered), crash damage {}", - mover.coupler_physics_at( m_coupler.end ) ? "physical" : "legacy", + physics.coupler_physics_at( m_coupler.end ) ? "physical" : "legacy", coupler_physics_setting(), - mover.CouplerPhysics ? "" : "not ", + physics.CouplerPhysics ? "" : "not ", Global.crash_damage ? "on" : "off" ), Global.UITextColor ); if( neighbour.vehicle != nullptr ) { @@ -1665,10 +1665,10 @@ debug_panel::render_section_coupler() { ImGui::Checkbox( "Crash damage", &Global.crash_damage ); ImGui::Checkbox( "Apply to the other end of the pair too", &m_couplerbothends ); - auto &mover { *m_coupler.vehicle->MoverParameters }; - auto &coupler { mover.Couplers[ m_coupler.end ] }; - auto const &neighbour { mover.Neighbours[ m_coupler.end ] }; - auto *othercoupler { neighbour.vehicle != nullptr ? &neighbour.vehicle->MoverParameters->Couplers[ neighbour.vehicle_end ] : nullptr }; + auto &physics { *m_coupler.vehicle->physics }; + auto &coupler { physics.Couplers[ m_coupler.end ] }; + auto const &neighbour { physics.Neighbours[ m_coupler.end ] }; + auto *othercoupler { neighbour.vehicle != nullptr ? &neighbour.vehicle->physics->Couplers[ neighbour.vehicle_end ] : nullptr }; if( auto parameters { coupler.physics }; edit_coupler_parameters( parameters ) ) { coupler.physics = parameters; @@ -1740,7 +1740,7 @@ bool debug_panel::render_section_developer() const ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "These settings may crash your simulator!"); if (ImGui::Button("Reload current vehicle .fiz") == true) { - m_input.vehicle->MoverParameters->reload_FIZ(); // reload fiz + m_input.vehicle->physics->reload_FIZ(); // reload fiz } ImGui::PopStyleColor(); return true; diff --git a/application/driveruipanels.h b/application/driveruipanels.h index c35ff12d6..4d685806d 100644 --- a/application/driveruipanels.h +++ b/application/driveruipanels.h @@ -80,7 +80,7 @@ private: TDynamicObject const *controlled; TCamera const *camera; TDynamicObject const *vehicle; - TMoverParameters *mover; + physics::Vehicle *physics; TController const *mechanik; }; // methods diff --git a/application/editormode.cpp b/application/editormode.cpp index 1f8b2d224..f6507f9c3 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -20,7 +20,7 @@ http://mozilla.org/MPL/2.0/. #include "application/editorgestures.h" #include "scene/scenenodegroups.h" #include "application/editoruilayer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #ifndef _WIN32 #include @@ -7598,7 +7598,7 @@ void editor_mode::enter() auto const *vehicle = Camera.m_owner; if (vehicle) { - const int cab = vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied; + const int cab = vehicle->physics->CabOccupied == 0 ? 1 : vehicle->physics->CabOccupied; const glm::dvec3 left = vehicle->VectorLeft() * (double)cab; Camera.Pos = glm::dvec3(Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z) + left * vehicle->GetWidth() + glm::dvec3(1.25f * left.x, 1.6f, 1.25f * left.z); Camera.m_owner = nullptr; diff --git a/application/editormodejoints.cpp b/application/editormodejoints.cpp index 12c1e4357..9a3bf5bf6 100644 --- a/application/editormodejoints.cpp +++ b/application/editormodejoints.cpp @@ -490,30 +490,30 @@ bool joints_tool::joint_fix(joint_issue &Issue, std::vectoreType == tt_Normal && editor_track::can_edit_geometry(*Track, reason) && scene::Layers.editable(Track); }; - TTrack *mover{nullptr}; + TTrack *physics{nullptr}; editor_track::point_ref moved; TTrack *fixed{nullptr}; editor_track::point_ref held; if (movable(Issue.track)) { - mover = Issue.track; + physics = Issue.track; moved = Issue.point; fixed = Issue.other; held = Issue.theirs; } else if (movable(Issue.other) && (Issue.type != kind::gap || false == editor_track::is_connected(*Issue.other, Issue.theirs))) { - mover = Issue.other; + physics = Issue.other; moved = Issue.theirs; fixed = Issue.track; held = Issue.point; } - if (mover == nullptr) + if (physics == nullptr) return false; - if (std::none_of(States.begin(), States.end(), [&](auto const &Entry) { return Entry.first == mover; })) - States.emplace_back(mover, editor_track::capture(*mover)); - if (std::find(Changed.begin(), Changed.end(), mover) == Changed.end()) - Changed.push_back(mover); + if (std::none_of(States.begin(), States.end(), [&](auto const &Entry) { return Entry.first == physics; })) + States.emplace_back(physics, editor_track::capture(*physics)); + if (std::find(Changed.begin(), Changed.end(), physics) == Changed.end()) + Changed.push_back(physics); editor_track::snap_target target; target.track = fixed; target.point = held; @@ -524,14 +524,14 @@ bool joints_tool::joint_fix(joint_issue &Issue, std::vectorm_paths[moved.path]}; + auto &path{physics->m_paths[moved.path]}; auto const roll{static_cast(roll_into(*fixed, held))}; if (at_start(moved)) path.rolls[0] = -roll; diff --git a/application/editormodeselftestscene.cpp b/application/editormodeselftestscene.cpp index 2868b22db..93387ff72 100644 --- a/application/editormodeselftestscene.cpp +++ b/application/editormodeselftestscene.cpp @@ -47,7 +47,7 @@ http://mozilla.org/MPL/2.0/. #include #include #include "application/editormodeselftest.h" -#include "physics/mover.h" +#include "physics/vehicle.h" editor_mode::selftest_result editor_mode::selftest_scene(std::string const &command, std::istringstream &words) { @@ -267,7 +267,7 @@ editor_mode::selftest_result editor_mode::selftest_scene(std::string const &comm auto const head{vehicle->HeadPosition()}; auto const front{vehicle->VectorFront()}; auto const coupler = [&](int const End) { - auto const &coupler{vehicle->MoverParameters->Couplers[End]}; + auto const &coupler{vehicle->physics->Couplers[End]}; return coupler.Connected != nullptr ? coupler.Connected->Name + "/" + std::to_string(coupler.CouplingFlag.Bits()) : std::string{"-"}; }; WriteLog(format("SELFTEST vehicle %s head %.2f %.2f front %.2f %.2f dir %d coupler0 %s coupler1 %s", vehicle->name().c_str(), head.x, head.z, front.x, front.z, vehicle->iDirection, coupler(0).c_str(), coupler(1).c_str())); diff --git a/audio/sound.cpp b/audio/sound.cpp index 6e5b8ab28..a9a249ce5 100644 --- a/audio/sound.cpp +++ b/audio/sound.cpp @@ -17,7 +17,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "simulation/simulation.h" #include "audio/audiorenderer_extra.h" -#include "physics/mover.h" +#include "physics/vehicle.h" // constructors sound_source::sound_source( sound_placement const Placement, float const Range ) : @@ -978,7 +978,7 @@ sound_source::update_soundproofing() { listenervehicle ? 3 : // external view 4 ) : // free roam view - listenervehicle->MoverParameters->CabOccupied ) }; // some internal view so we can be sure listener isn't a nullptr + listenervehicle->physics->CabOccupied ) }; // some internal view so we can be sure listener isn't a nullptr // location-based gain factor: std::uintptr_t soundproofingstamp = reinterpret_cast( listenervehicle ) diff --git a/directoryDescription.md b/directoryDescription.md index 51ba37f32..a26eeed9a 100644 --- a/directoryDescription.md +++ b/directoryDescription.md @@ -2,7 +2,7 @@ # File structure | Directory| Description| |--|--| -| physics/ | Vehicle physics: the mover, brakes, couplers, collisions, derailment | +| physics/ | Vehicle physics: the physics, brakes, couplers, collisions, derailment | | gl/ | OpenGL Abstraction Layer| | network/ | Multiplayer Support | launcher/ | Scenario/Vehicle Selection (built in starter)| diff --git a/input/drivermouseinput.cpp b/input/drivermouseinput.cpp index 468a51dc4..087365c77 100644 --- a/input/drivermouseinput.cpp +++ b/input/drivermouseinput.cpp @@ -21,7 +21,7 @@ http://mozilla.org/MPL/2.0/. #include "application/uilayer.h" #include "utilities/Logs.h" #include "utilities/utilities.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" auto const EU07_CONTROLLER_MOUSESLIDERSIZE{ 0.6 }; @@ -34,7 +34,7 @@ mouse_slider::bind( user_command const &Command ) { m_universaldrag.reset(); auto const *train { simulation::Train }; - TMoverParameters const *vehicle { nullptr }; + physics::Vehicle const *vehicle { nullptr }; switch( m_command ) { using enum user_command; case jointcontrollerset: diff --git a/input/messaging.cpp b/input/messaging.cpp index 0f1530199..4c17eedf1 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -19,7 +19,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/Driver.h" #include "world/mtable.h" #include "utilities/Logs.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #ifdef _WIN32 extern "C" @@ -188,7 +188,7 @@ OnCommandGet(multiplayer::DaneRozkaz const *pRozkaz) d->Damage( pRozkaz->cString[ 0 ] ); d = d->Prev(); // w drugą stronę też } - WyslijUszkodzenia( lookup->asName, static_cast(lookup->MoverParameters->EngDmgFlag) ); // zwrot informacji o pojeździe + WyslijUszkodzenia( lookup->asName, static_cast(lookup->physics->EngDmgFlag) ); // zwrot informacji o pojeździe } break; default: @@ -273,40 +273,40 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle) size_t j = Vehicle->asName.length(); r.iPar[0] = i; // ilość danych liczbowych r.fPar[1] = Global.fTimeAngleDeg / 360.0; // aktualny czas (1.0=doba) - r.fPar[2] = Vehicle->MoverParameters->Loc.X; // pozycja X - r.fPar[3] = Vehicle->MoverParameters->Loc.Y; // pozycja Y - r.fPar[4] = Vehicle->MoverParameters->Loc.Z; // pozycja Z - r.fPar[5] = Vehicle->MoverParameters->V; // prędkość ruchu X - r.fPar[6] = Vehicle->MoverParameters->nrot * M_PI * - Vehicle->MoverParameters->WheelDiameter; // prędkość obrotowa kóŁ + r.fPar[2] = Vehicle->physics->Loc.X; // pozycja X + r.fPar[3] = Vehicle->physics->Loc.Y; // pozycja Y + r.fPar[4] = Vehicle->physics->Loc.Z; // pozycja Z + r.fPar[5] = Vehicle->physics->V; // prędkość ruchu X + r.fPar[6] = Vehicle->physics->nrot * M_PI * + Vehicle->physics->WheelDiameter; // prędkość obrotowa kóŁ r.fPar[7] = 0; // prędkość ruchu Z - r.fPar[8] = Vehicle->MoverParameters->AccS; // przyspieszenie X - r.fPar[9] = Vehicle->MoverParameters->AccN; // przyspieszenie Y //na razie nie - r.fPar[10] = Vehicle->MoverParameters->AccVert; // przyspieszenie Z - r.fPar[11] = Vehicle->MoverParameters->DistCounter; // przejechana odległość w km - r.fPar[12] = Vehicle->MoverParameters->PipePress; // ciśnienie w PG - r.fPar[13] = Vehicle->MoverParameters->ScndPipePress; // ciśnienie w PZ - r.fPar[14] = Vehicle->MoverParameters->BrakePress; // ciśnienie w CH - r.fPar[15] = Vehicle->MoverParameters->Compressor; // ciśnienie w ZG - r.fPar[16] = Vehicle->MoverParameters->Itot; // Prąd całkowity - r.iPar[17] = Vehicle->MoverParameters->MainCtrlPos; // Pozycja NJ - r.iPar[18] = Vehicle->MoverParameters->ScndCtrlPos; // Pozycja NB - r.iPar[19] = Vehicle->MoverParameters->MainCtrlActualPos; // Pozycja jezdna - r.iPar[20] = Vehicle->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania - r.iPar[21] = Vehicle->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania - r.iPar[22] = Vehicle->MoverParameters->ResistorsFlag * 1 - + Vehicle->MoverParameters->ConverterFlag * 2 - + Vehicle->MoverParameters->CompressorFlag * 4 - + Vehicle->MoverParameters->Mains * 8 + r.fPar[8] = Vehicle->physics->AccS; // przyspieszenie X + r.fPar[9] = Vehicle->physics->AccN; // przyspieszenie Y //na razie nie + r.fPar[10] = Vehicle->physics->AccVert; // przyspieszenie Z + r.fPar[11] = Vehicle->physics->DistCounter; // przejechana odległość w km + r.fPar[12] = Vehicle->physics->PipePress; // ciśnienie w PG + r.fPar[13] = Vehicle->physics->ScndPipePress; // ciśnienie w PZ + r.fPar[14] = Vehicle->physics->BrakePress; // ciśnienie w CH + r.fPar[15] = Vehicle->physics->Compressor; // ciśnienie w ZG + r.fPar[16] = Vehicle->physics->Itot; // Prąd całkowity + r.iPar[17] = Vehicle->physics->MainCtrlPos; // Pozycja NJ + r.iPar[18] = Vehicle->physics->ScndCtrlPos; // Pozycja NB + r.iPar[19] = Vehicle->physics->MainCtrlActualPos; // Pozycja jezdna + r.iPar[20] = Vehicle->physics->ScndCtrlActualPos; // Pozycja bocznikowania + r.iPar[21] = Vehicle->physics->ScndCtrlActualPos; // Pozycja bocznikowania + r.iPar[22] = Vehicle->physics->ResistorsFlag * 1 + + Vehicle->physics->ConverterFlag * 2 + + Vehicle->physics->CompressorFlag * 4 + + Vehicle->physics->Mains * 8 #ifdef EU07_USEOLDDOORCODE - + Vehicle->MoverParameters->DoorLeftOpened * 16 - + Vehicle->MoverParameters->DoorRightOpened * 32 + + Vehicle->physics->DoorLeftOpened * 16 + + Vehicle->physics->DoorRightOpened * 32 #else - + ( false == Vehicle->MoverParameters->Doors.instances[VehicleSide::left].is_closed ) * 16 - + ( false == Vehicle->MoverParameters->Doors.instances[VehicleSide::right].is_closed ) * 32 + + ( false == Vehicle->physics->Doors.instances[VehicleSide::left].is_closed ) * 16 + + ( false == Vehicle->physics->Doors.instances[VehicleSide::right].is_closed ) * 32 #endif - + Vehicle->MoverParameters->FuseFlag * 64 - + Vehicle->MoverParameters->DepartureSignal * 128; + + Vehicle->physics->FuseFlag * 64 + + Vehicle->physics->DepartureSignal * 128; // WriteLog("Zapisalem stare"); // WriteLog("Mam patykow "+IntToStr(t->DynamicObject->iAnimType[ANIM_PANTS])); for (int p = 0; p < 4; p++) @@ -326,10 +326,10 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle) // WriteLog("Zapisalem pantografy"); for (int p = 0; p < 3; p++) r.fPar[27 + p] = - Vehicle->MoverParameters->ShowCurrent(p + 1); // amperomierze kolejnych grup + Vehicle->physics->ShowCurrent(p + 1); // amperomierze kolejnych grup // WriteLog("zapisalem prady"); - r.iPar[30] = Vehicle->MoverParameters->WarningSignal; // trabienie - r.fPar[31] = Vehicle->MoverParameters->PantographVoltage; // napiecie WN + r.iPar[30] = Vehicle->physics->WarningSignal; // trabienie + r.fPar[31] = Vehicle->physics->PantographVoltage; // napiecie WN // WriteLog("Parametry gotowe"); i <<= 2; // ilość bajtów r.cString[i] = char(j); // na końcu nazwa, żeby jakoś zidentyfikować diff --git a/physics/brakes.cpp b/physics/brakes.cpp index 65d38663f..7cd66b1d5 100644 --- a/physics/brakes.cpp +++ b/physics/brakes.cpp @@ -15,7 +15,7 @@ Copyright (C) 2007-2014 Maciej Cierniak #include "stdafx.h" #include "physics/brakes.h" #include -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/utilities.h" //---FUNKCJE OGOLNE--- diff --git a/physics/brakes.h b/physics/brakes.h index dd07f0630..4fb4b7f9f 100644 --- a/physics/brakes.h +++ b/physics/brakes.h @@ -25,7 +25,7 @@ ESt3, ESt3AL2, ESt4R, LSt, FV4a, FD1, EP2, prosty westinghouse duzo wersji żeliwa KE Tarcze od 152A -Magnetyki (implementacja w mover.pas) +Magnetyki (implementacja w physics.pas) Matrosow 394 H14K1 (zasadniczy), H1405 (pomocniczy), St113 (ep) Knorr/West EP - żeby był diff --git a/physics/collision.h b/physics/collision.h index 62d16669e..9b9258169 100644 --- a/physics/collision.h +++ b/physics/collision.h @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "physics/derailment.h" // what a collision of two vehicles does to them past their buffers (physics.collisions new in eu07.ini, see -// TMoverParameters::CollisionDetect()), as plain functions of the vehicles and the hit: +// physics::Vehicle::CollisionDetect()), as plain functions of the vehicles and the hit: // // crush: once the buffers of the pair are pressed all the way, the underframes carry the rest of the hit, up to the // force the weaker end gives at. only the energy the hit brings past what the buffers of EN 15551 of both ends take diff --git a/physics/components/body.cpp b/physics/components/body.cpp index 698f19d98..f3da81add 100644 --- a/physics/components/body.cpp +++ b/physics/components/body.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the vehicle as a body: construction, the forces on it, its movement along the track, adhesion and sand #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -43,7 +43,7 @@ namespace // friction of its weight, and the forces of the vehicles coupled to it act on it as on any other: the train behind it // pushes it on, and it holds the train back. alone it stops as the legacy model has it. the legacy model stops it // whatever pushes it, and the train behind it stopped at once against it, in a hit no train had -bool legacy_derailed_slides(TMoverParameters const &Vehicle) +bool legacy_derailed_slides(physics::Vehicle const &Vehicle) { return Global.collisions == global_settings::collision_model::physical && TestFlag(Vehicle.CategoryFlag, 1) && Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) && Vehicle.Derailed == derailment::outcome::none; @@ -67,7 +67,7 @@ int DirF(VehicleEnd CouplerN) // ************************************************************************************************* // główny konstruktor // ************************************************************************************************* -TMoverParameters::TMoverParameters(double VelInitial, std::string const &TypeNameInit, std::string const &NameInit, int Cab) : TypeName(TypeNameInit), Name(NameInit), CabOccupied(Cab) +physics::Vehicle::Vehicle(double VelInitial, std::string const &TypeNameInit, std::string const &NameInit, int Cab) : TypeName(TypeNameInit), Name(NameInit), CabOccupied(Cab) { WriteLog("------------------------------------------------------"); WriteLog("init default physic values for " + NameInit + ", [" + TypeNameInit + "]"); @@ -166,10 +166,10 @@ TMoverParameters::TMoverParameters(double VelInitial, std::string const &TypeNam RunningTraction.TractionResistivity = 1.0; }; -void TMoverParameters::change_train_velocity(double const Change) +void physics::Vehicle::change_train_velocity(double const Change) { // the vehicles coupled to this one in a line, each with the direction of its axis to the axis of this one - std::vector> train{{this, 1}}; + std::vector> train{{this, 1}}; for (std::size_t i = 0; i < train.size(); ++i) { auto const [vehicle, direction] = train[i]; @@ -191,7 +191,7 @@ void TMoverParameters::change_train_velocity(double const Change) // ************************************************************************************************* // Oblicza przemieszczenie taboru // ************************************************************************************************* -double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam const &Track, TTractionParam const &ElectricTraction, TLocation const &NewLoc, TRotation const &NewRot) +double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam const &Track, TTractionParam const &ElectricTraction, TLocation const &NewLoc, TRotation const &NewRot) { if (!DamageFlag.HasAll(VehicleDamage::derailed)) @@ -335,9 +335,9 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap // Oblicza przemieszczenie taboru - uproszczona wersja // ************************************************************************************************* -double TMoverParameters::FastComputeMovement(double dt, const TTrackShape & /*Shape*/, TTrackParam & /*Track*/, TLocation const &NewLoc, TRotation const &NewRot) +double physics::Vehicle::FastComputeMovement(double dt, const TTrackShape & /*Shape*/, TTrackParam & /*Track*/, TLocation const &NewLoc, TRotation const &NewRot) { - // T_MoverParameters::FastComputeMovement(dt, Shape, Track, NewLoc, NewRot); + // physics::Vehicle::FastComputeMovement(dt, Shape, Track, NewLoc, NewRot); Loc = NewLoc; Rot = NewRot; @@ -406,7 +406,7 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape & /*Sh }; // updates shared between 'fast' and regular movement computation methods -void TMoverParameters::compute_movement_(double const Deltatime) +void physics::Vehicle::compute_movement_(double const Deltatime) { // sprawdzanie i ewentualnie wykonywanie->kasowanie poleceń @@ -534,7 +534,7 @@ void TMoverParameters::compute_movement_(double const Deltatime) // Q: 20160710 // Siła napędzająca drezynę po naciśnięciu wajhy // ************************************************************************************************* -bool TMoverParameters::AddPulseForce(int Multipler) +bool physics::Vehicle::AddPulseForce(int Multipler) { bool APF; if (EngineType == TEngineType::WheelsDriven && EnginePowerSource.SourceType == TPowerSource::InternalSource && EnginePowerSource.PowerType == TPowerType::BioPower) @@ -561,7 +561,7 @@ bool TMoverParameters::AddPulseForce(int Multipler) // yB: 20190909 // sypanie piasku reczne // ************************************************************************************************* -bool TMoverParameters::SandboxManual(bool const State, range_t const Notify) +bool physics::Vehicle::SandboxManual(bool const State, range_t const Notify) { bool result{false}; @@ -593,7 +593,7 @@ bool TMoverParameters::SandboxManual(bool const State, range_t const Notify) // yB: 20190909 // sypanie piasku automatyczne // ************************************************************************************************* -bool TMoverParameters::SandboxAuto(bool const State, range_t const Notify) +bool physics::Vehicle::SandboxAuto(bool const State, range_t const Notify) { bool result{false}; if (bool NewState = State && SandDoseAutoAllow; SandDoseAuto != NewState) @@ -624,7 +624,7 @@ bool TMoverParameters::SandboxAuto(bool const State, range_t const Notify) // Q: 20160713 // sypanie piasku // ************************************************************************************************* -bool TMoverParameters::Sandbox(bool const State, range_t const Notify) +bool physics::Vehicle::Sandbox(bool const State, range_t const Notify) { bool result{false}; @@ -671,7 +671,7 @@ bool TMoverParameters::Sandbox(bool const State, range_t const Notify) // yB: 20190909 // włączenie / wyłączenie automatycznej piasecznicy // ************************************************************************************************* -bool TMoverParameters::SandboxAutoAllow(bool State) +bool physics::Vehicle::SandboxAutoAllow(bool State) { // SendCtrlToNext(VehicleCommand::sandboxAutoAllow, int(State), CabActive, Coupling::control); @@ -688,7 +688,7 @@ bool TMoverParameters::SandboxAutoAllow(bool State) // Q: 20160713 // Obliczenie stałych potrzebnych do dalszych obliczeń // ************************************************************************************************* -void TMoverParameters::ComputeConstans(void) +void physics::Vehicle::ComputeConstans(void) { double BearingF; double RollF; @@ -750,7 +750,7 @@ void TMoverParameters::ComputeConstans(void) // Q: 20160713 // Oblicza masę ładunku // ************************************************************************************************* -void TMoverParameters::ComputeMass() +void physics::Vehicle::ComputeMass() { // Ra: na razie tak, ale nie wszędzie masy wirujące się wliczają TotalMass = Mass + Mred; @@ -781,7 +781,7 @@ void TMoverParameters::ComputeMass() // Obliczanie wypadkowej siły z wszystkich działających sił // ************************************************************************************************* // TBD, TODO: move some of the calculations out of the method, they're relevant to more than just force calculations -void TMoverParameters::ComputeTotalForce(double dt) +void physics::Vehicle::ComputeTotalForce(double dt) { Vel = std::abs(V) * 3.6; // prędkość w km/h @@ -798,10 +798,10 @@ void TMoverParameters::ComputeTotalForce(double dt) auto const vehicleisactive{CabActive != 0 || Vel > 0.0001 || accelerating() || LastSwitchingTime < 5 || is_multiple_unit()}; auto const movingvehicleahead{Neighbours[VehicleEnd::front].vehicle != nullptr && - (Neighbours[VehicleEnd::front].vehicle->MoverParameters->Vel > 0.0001 || Neighbours[VehicleEnd::front].vehicle->MoverParameters->accelerating())}; + (Neighbours[VehicleEnd::front].vehicle->physics->Vel > 0.0001 || Neighbours[VehicleEnd::front].vehicle->physics->accelerating())}; auto const movingvehiclebehind{Neighbours[VehicleEnd::rear].vehicle != nullptr && - (Neighbours[VehicleEnd::rear].vehicle->MoverParameters->Vel > 0.0001 || Neighbours[VehicleEnd::rear].vehicle->MoverParameters->accelerating())}; + (Neighbours[VehicleEnd::rear].vehicle->physics->Vel > 0.0001 || Neighbours[VehicleEnd::rear].vehicle->physics->accelerating())}; auto const calculatephysics{vehicleisactive || movingvehicleahead || movingvehiclebehind}; @@ -924,7 +924,7 @@ void TMoverParameters::ComputeTotalForce(double dt) if (Neighbours[end].vehicle != nullptr) { // the velocities before the step, the forces of all the vehicles come before their movement - Couplers[end].closing = -CouplerVelocityDifference(end, *Neighbours[end].vehicle->MoverParameters, Neighbours[end].FacingEnd()) * DirF(end); + Couplers[end].closing = -CouplerVelocityDifference(end, *Neighbours[end].vehicle->physics, Neighbours[end].FacingEnd()) * DirF(end); Couplers[end].CForce = CouplerForce(end, dt); FTrain += Couplers[end].CForce; // what the buffers of the pair take in, for the budget of the crush (physics.collisions new and monitor) @@ -946,7 +946,7 @@ void TMoverParameters::ComputeTotalForce(double dt) FTotal = FTrain - Sign(V) * FStand; } -double TMoverParameters::BrakeForceR(double ratio, double velocity) const +double physics::Vehicle::BrakeForceR(double ratio, double velocity) const { double press = 0; ratio = Hamulec->GetBrakeRatio(ratio); @@ -976,7 +976,7 @@ double TMoverParameters::BrakeForceR(double ratio, double velocity) const return BrakeForceP(press * ratio, velocity); } -double TMoverParameters::BrakeForceP(double press, double velocity) const +double physics::Vehicle::BrakeForceP(double press, double velocity) const { double BFP = 0; double K = ((press * P2FTrans - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj) * BrakeRigEff; @@ -989,7 +989,7 @@ double TMoverParameters::BrakeForceP(double press, double velocity) const // Q: 20160713 // oblicza siłę na styku koła i szyny // ************************************************************************************************* -double TMoverParameters::BrakeForce(TTrackParam const & /*Track*/) +double physics::Vehicle::BrakeForce(TTrackParam const & /*Track*/) { double K{0}; @@ -1062,7 +1062,7 @@ double TMoverParameters::BrakeForce(TTrackParam const & /*Track*/) // Q: 20160713 // Obliczanie siły tarcia // ************************************************************************************************* -double TMoverParameters::FrictionForce() const +double physics::Vehicle::FrictionForce() const { double FF = 0; // ABu 240205: chyba juz ekstremalnie zoptymalizowana funkcja liczaca sily tarcia @@ -1077,7 +1077,7 @@ double TMoverParameters::FrictionForce() const // Q: 20160713 // Oblicza przyczepność // ************************************************************************************************* -double TMoverParameters::Adhesive(double staticfriction) const +double physics::Vehicle::Adhesive(double staticfriction) const { double adhesion = 0.0; const double adh_factor = 0.25; // współczynnik określający, jak bardzo spada tarcie przy poślizgu @@ -1132,7 +1132,7 @@ double TMoverParameters::Adhesive(double staticfriction) const // Q: 20160713 // Obliczenie predkości obrotowej kół??? // ************************************************************************************************* -double TMoverParameters::ComputeRotatingWheel(double WForce, double dt, double n) const +double physics::Vehicle::ComputeRotatingWheel(double WForce, double dt, double n) const { double newn = 0; double eps = 0; @@ -1152,7 +1152,7 @@ double TMoverParameters::ComputeRotatingWheel(double WForce, double dt, double n // Q: 20160713 // Przesuwa pojazd o podaną wartość w bok względem toru (dla samochodów) // ************************************************************************************************* -bool TMoverParameters::ChangeOffsetH(double DeltaOffset) +bool physics::Vehicle::ChangeOffsetH(double DeltaOffset) { bool COH = false; if (TestFlag(CategoryFlag, 2) && TestFlag(RunningTrack.CategoryFlag, 2)) @@ -1174,7 +1174,7 @@ bool TMoverParameters::ChangeOffsetH(double DeltaOffset) // Q: 20160713 // Testuje zmienną (narazie tylko 0) i na podstawie uszkodzenia zwraca informację tekstową // ************************************************************************************************* -std::string TMoverParameters::EngineDescription(int what) const +std::string physics::Vehicle::EngineDescription(int what) const { std::string outstr{"OK"}; if (what == 0) @@ -1238,7 +1238,7 @@ std::string TMoverParameters::EngineDescription(int what) const // ************************************************************************************************* // whether the vehicle accelerates, for the test which turns the physics off in vehicles standing still // ************************************************************************************************* -bool TMoverParameters::accelerating() const +bool physics::Vehicle::accelerating() const { if (std::abs(AccS) <= 0.0001) return false; @@ -1251,7 +1251,7 @@ bool TMoverParameters::accelerating() const return false == held; } -void TMoverParameters::wake_for_brake() +void physics::Vehicle::wake_for_brake() { if (Global.physics_sleepheld) { @@ -1268,7 +1268,7 @@ void TMoverParameters::wake_for_brake() // which the cylinder gives no force: a release ends with the vehicle asleep and no force left. a cylinder holding its // pressure, or settling within that, leaves the vehicle asleep // ************************************************************************************************* -bool TMoverParameters::brakes_changed_asleep() const +bool physics::Vehicle::brakes_changed_asleep() const { if (PhysicActivation) return false; @@ -1280,7 +1280,7 @@ bool TMoverParameters::brakes_changed_asleep() const // ************************************************************************************************* // Kasowanie zmiennych pracy fizyki // ************************************************************************************************* -bool TMoverParameters::switch_physics(bool const State, wake_cause const Cause) // DO PRZETLUMACZENIA NA KONCU +bool physics::Vehicle::switch_physics(bool const State, wake_cause const Cause) // DO PRZETLUMACZENIA NA KONCU { if (PhysicActivation == State) { diff --git a/physics/components/cab.cpp b/physics/components/cab.cpp index 2accee006..0ac0324ce 100644 --- a/physics/components/cab.cpp +++ b/physics/components/cab.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the cab: activation, the direction, the horns, the pullee mode #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -30,7 +30,7 @@ http://mozilla.org/MPL/2.0/. #include "physics/components/internal.h" -bool TMoverParameters::DirectionForward() +bool physics::Vehicle::DirectionForward() { if (false == EIMDirectionChangeAllow()) { @@ -49,7 +49,7 @@ bool TMoverParameters::DirectionForward() return false; }; -bool TMoverParameters::ChangeCab(int direction) +bool physics::Vehicle::ChangeCab(int direction) { // zmiana kabiny i resetowanie ustawien if (std::abs(CabOccupied + direction) < 2) { @@ -69,7 +69,7 @@ bool TMoverParameters::ChangeCab(int direction) return false; }; -int TMoverParameters::SoundingHorns(int const Signal) const +int physics::Vehicle::SoundingHorns(int const Signal) const { auto const supplied{[this](horn_supply const Supply) { if (Supply == horn_supply::electric) @@ -101,7 +101,7 @@ int TMoverParameters::SoundingHorns(int const Signal) const // Q: 20160710 // załączenie rozrządu // ************************************************************************************************* -bool TMoverParameters::CabActivisation(bool const Enforce) +bool physics::Vehicle::CabActivisation(bool const Enforce) { bool OK = false; @@ -127,7 +127,7 @@ bool TMoverParameters::CabActivisation(bool const Enforce) return OK; } -bool TMoverParameters::CabActivisationAuto(bool const Enforce) +bool physics::Vehicle::CabActivisationAuto(bool const Enforce) { bool OK = AutomaticCabActivation ? CabActivisation(Enforce) : false; return OK; @@ -137,7 +137,7 @@ bool TMoverParameters::CabActivisationAuto(bool const Enforce) // Q: 20160710 // wyłączenie rozrządu // ************************************************************************************************* -bool TMoverParameters::CabDeactivisation(bool const Enforce) +bool physics::Vehicle::CabDeactivisation(bool const Enforce) { bool OK = false; @@ -174,7 +174,7 @@ bool TMoverParameters::CabDeactivisation(bool const Enforce) return OK; } -bool TMoverParameters::CabDeactivisationAuto(bool const Enforce) +bool physics::Vehicle::CabDeactivisationAuto(bool const Enforce) { bool OK = AutomaticCabActivation ? CabDeactivisation(Enforce) : false; return OK; @@ -192,7 +192,7 @@ bool TMoverParameters::CabDeactivisationAuto(bool const Enforce) // entering it also lets go of the hand brake and of the spring brake switch. // returns whether the mode changed; a vehicle driven from can't enter it // ************************************************************************************************* -bool TMoverParameters::PulleeModeSwitch(bool const State) +bool physics::Vehicle::PulleeModeSwitch(bool const State) { if (PulleeMode == State || (State && CabActive != 0)) { @@ -213,7 +213,7 @@ bool TMoverParameters::PulleeModeSwitch(bool const State) // Q: 20160710 // kierunek do tyłu // ************************************************************************************************* -bool TMoverParameters::DirectionBackward(void) +bool physics::Vehicle::DirectionBackward(void) { if (false == EIMDirectionChangeAllow()) { @@ -238,7 +238,7 @@ bool TMoverParameters::DirectionBackward(void) return false; } -bool TMoverParameters::EIMDirectionChangeAllow(void) const +bool physics::Vehicle::EIMDirectionChangeAllow(void) const { bool OK = false; /* diff --git a/physics/components/collisions.cpp b/physics/components/collisions.cpp index db73aa29a..eeb711535 100644 --- a/physics/components/collisions.cpp +++ b/physics/components/collisions.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // collisions of the ends, their crush and repair, derailment and putting back on the rails #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -55,7 +55,7 @@ namespace { // a derailed vehicle tears its brake hoses: the brake pipe vents and the rest of the train brakes in emergency -void tear_brake_hoses(TMoverParameters &Vehicle) +void tear_brake_hoses(physics::Vehicle &Vehicle) { if (std::any_of(std::begin(Vehicle.Couplers), std::end(Vehicle.Couplers), [](auto const &Coupler) { return Coupler.CouplingFlag.HasAll(Coupling::brakeHose); })) { @@ -69,7 +69,7 @@ void tear_brake_hoses(TMoverParameters &Vehicle) // Q: 20160716 // Wykrywanie kolizji // ************************************************************************************************* -void TMoverParameters::CollisionDetect(VehicleEnd const End, double const dt) +void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt) { if (Neighbours[End].vehicle == nullptr) { @@ -77,7 +77,7 @@ void TMoverParameters::CollisionDetect(VehicleEnd const End, double const dt) } // shouldn't normally happen but, eh auto const &thiscoupler{Couplers[End]}; - auto *othervehicle{Neighbours[End].vehicle->MoverParameters}; + auto *othervehicle{Neighbours[End].vehicle->physics}; auto const otherend{Neighbours[End].FacingEnd()}; auto const &othercoupler{othervehicle->Couplers[otherend]}; @@ -170,7 +170,7 @@ void TMoverParameters::CollisionDetect(VehicleEnd const End, double const dt) // derailed the legacy way a vehicle is a wall, off the rails by the new criteria it slides on and takes the hit. with // the crush, the vehicles coupled to the wall push it on (crush_hit()) auto const coupled{thiscoupler.CouplingFlag != Coupling::none}; - auto const wall = [crushing, coupled](TMoverParameters const &Vehicle) { + auto const wall = [crushing, coupled](physics::Vehicle const &Vehicle) { return Vehicle.DamageFlag.HasAll(VehicleDamage::derailed) && (false == crushing || (Vehicle.Derailed == derailment::outcome::none && false == coupled)); }; if (false == wall(*this)) @@ -188,7 +188,7 @@ void TMoverParameters::CollisionDetect(VehicleEnd const End, double const dt) } } -void TMoverParameters::damage_coupler(VehicleEnd const End) +void physics::Vehicle::damage_coupler(VehicleEnd const End) { auto &thiscoupler{Couplers[End]}; @@ -232,7 +232,7 @@ void TMoverParameters::damage_coupler(VehicleEnd const End) // ************************************************************************************************* // physics.collisions new: the collisions past the buffers, see collision.h // ************************************************************************************************* -collision::vehicle_kind TMoverParameters::collision_kind() const +collision::vehicle_kind physics::Vehicle::collision_kind() const { auto const powered{EngineType != TEngineType::None && EngineType != TEngineType::Dumb}; auto const unit{is_multiple_unit()}; @@ -241,18 +241,18 @@ collision::vehicle_kind TMoverParameters::collision_kind() const return collision::kind_of(powered, unit || passengers || (false == powered && HeatingPower > 0.0), false); } -collision::crush_curve TMoverParameters::crush_curve_at(VehicleEnd const End) const +collision::crush_curve physics::Vehicle::crush_curve_at(VehicleEnd const End) const { return collision::crush_of(Couplers[End].collision, collision_kind()); } -double TMoverParameters::buffer_height_at(VehicleEnd const End) const +double physics::Vehicle::buffer_height_at(VehicleEnd const End) const { auto const loadshare{MaxLoad > 0.f ? LoadAmount / MaxLoad : 0.0}; return collision::buffer_height(Couplers[End].collision, collision_kind(), loadshare); } -void TMoverParameters::derail_in_collision(DerailReason const Reason, std::string const &Why) +void physics::Vehicle::derail_in_collision(DerailReason const Reason, std::string const &Why) { if (false == DamageFlag.Set(VehicleDamage::derailed)) { @@ -330,10 +330,10 @@ void record_hit(TCoupling &Coupler, double const Force, double const Duration) } // namespace -bool TMoverParameters::crush_hit(VehicleEnd const End, double const dt) +bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt) { auto &thiscoupler{Couplers[End]}; - auto *othervehicle{Neighbours[End].vehicle->MoverParameters}; + auto *othervehicle{Neighbours[End].vehicle->physics}; auto const otherend{Neighbours[End].FacingEnd()}; auto &othercoupler{othervehicle->Couplers[otherend]}; @@ -491,7 +491,7 @@ bool TMoverParameters::crush_hit(VehicleEnd const End, double const dt) secondcurve.force(othercoupler.crush) / 1000.0, hit.force / 1000.0, springs / 1000.0, input.start_velocity * 3.6, kinetic / 1000.0, thiscoupler.contact.absorbed() / 1000.0, capacity / 1000.0, thiscoupler.contact.crush_work() / 1000.0); }; - auto const crushed = [&](TMoverParameters const &Vehicle, VehicleEnd const crushedEnd, double const Before, double const After) { + auto const crushed = [&](physics::Vehicle const &Vehicle, VehicleEnd const crushedEnd, double const Before, double const After) { if (Before < collision::crush_mark && After >= collision::crush_mark) { ErrorLog(std::format("Bad driving: {} and {} collided at {:.0f} km/h, the {} end of {} crushed ({})", Name, othervehicle->Name, closing * 3.6, end_name(crushedEnd), Vehicle.Name, pair())); @@ -530,7 +530,7 @@ bool TMoverParameters::crush_hit(VehicleEnd const End, double const dt) // the end crushed deep enough lets one vehicle climb onto the other one auto const climbing{climbing_of(thiscoupler.crush, othercoupler.crush)}; auto const climbed{collision::override_of(climbing)}; - auto const why = [&](TMoverParameters const &Climber, TMoverParameters const &Other) { + auto const why = [&](physics::Vehicle const &Climber, physics::Vehicle const &Other) { return std::format("{} rode up onto {} at {:.0f} km/h, the ends crushed by {:.2f} m, buffers at {:.0f} / {:.0f} mm, anticlimbers {} ({})", Climber.Name, Other.Name, closing * 3.6, thiscoupler.crush + othercoupler.crush, climbing.height1 * 1000.0, climbing.height2 * 1000.0, climbing.anticlimbers ? "yes" : "no", pair()); }; @@ -545,7 +545,7 @@ bool TMoverParameters::crush_hit(VehicleEnd const End, double const dt) return true; } -void TMoverParameters::check_pushed_off(double const dt, double const Distance) +void physics::Vehicle::check_pushed_off(double const dt, double const Distance) { if (Global.collisions != global_settings::collision_model::physical || false == Global.crash_damage || DamageFlag.HasAll(VehicleDamage::derailed) || false == TestFlag(CategoryFlag, 1) || DebugModeFlag) @@ -576,7 +576,7 @@ void TMoverParameters::check_pushed_off(double const dt, double const Distance) } auto const &coupler{Couplers[end]}; collision::pushed_end pushed; - pushed.other_length = other->MoverParameters->Dim.L; + pushed.other_length = other->physics->Dim.L; pushed.crush = coupler.crush; // the steady push of the springs over the step, or the peak of a hit for as long as it lasted: the flange climbs // over the distance the wheels rolled meanwhile, a wheel lifted off the rail goes in a short time, rolling or not @@ -635,7 +635,7 @@ void restore_end(TCoupling &Coupler) // the coupler as good as new, its end with it (the crush that tore the draw gear off), the vehicle without the coupler // damage (and the emergency braking of the torn brake hose) once neither of its couplers is broken -void repair(TMoverParameters &Vehicle, TCoupling &Coupler) +void repair(physics::Vehicle &Vehicle, TCoupling &Coupler) { Coupler.broken = false; Coupler.stretch_duration = 0.f; @@ -652,7 +652,7 @@ void repair(TMoverParameters &Vehicle, TCoupling &Coupler) } // namespace -bool TMoverParameters::repair_coupler(VehicleEnd const End) +bool physics::Vehicle::repair_coupler(VehicleEnd const End) { auto &thiscoupler{Couplers[End]}; if (false == thiscoupler.broken) @@ -672,7 +672,7 @@ bool TMoverParameters::repair_coupler(VehicleEnd const End) static_assert(derailment::track_damage::railwear == dtrack_railwear && derailment::track_damage::freerail == dtrack_freerail && derailment::track_damage::thinrail == dtrack_thinrail && derailment::track_damage::railbend == dtrack_railbend); -double TMoverParameters::centre_of_gravity() const +double physics::Vehicle::centre_of_gravity() const { auto const kind{EngineType == TEngineType::None ? derailment::vehicle_class::unpowered : derailment::vehicle_class::powered}; auto const empty{CentreOfGravity > 0.0 ? CentreOfGravity : derailment::default_centre_of_gravity(Dim.H, kind)}; @@ -681,7 +681,7 @@ double TMoverParameters::centre_of_gravity() const return derailment::loaded_centre_of_gravity(empty, Mass, loadmass, loadshare, Floor, Dim.H); } -void TMoverParameters::check_derailment(TTrackShape const &Shape, TTrackParam const &Track, double const Distance) +void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam const &Track, double const Distance) { if (DamageFlag.HasAll(VehicleDamage::derailed) || false == TestFlag(CategoryFlag, 1) || DebugModeFlag) { @@ -703,7 +703,7 @@ void TMoverParameters::check_derailment(TTrackShape const &Shape, TTrackParam co } // the force of the coupling, or of the buffers touching, along this vehicle: forwards at the front pulls vehicle.ends[NumberOf(end)].compression = (end == VehicleEnd::front ? -1.0 : 1.0) * Couplers[end].CForce; - vehicle.ends[NumberOf(end)].other_length = other->MoverParameters->Dim.L; + vehicle.ends[NumberOf(end)].other_length = other->physics->Dim.L; } derailment::track_state track; track.radius = Shape.R; @@ -734,7 +734,7 @@ void TMoverParameters::check_derailment(TTrackShape const &Shape, TTrackParam co WriteLog("derailment monitor: " + Name + " " + derailment::report(verdict, vehicle, track, V, Track.Name != nullptr ? *Track.Name : std::string{})); } -void TMoverParameters::derail(derailment::verdict const &Verdict, derailment::vehicle_state const &Vehicle, derailment::track_state const &Track, std::string const *TrackName) +void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::vehicle_state const &Vehicle, derailment::track_state const &Track, std::string const *TrackName) { if (false == DamageFlag.Set(VehicleDamage::derailed)) { @@ -757,7 +757,7 @@ void TMoverParameters::derail(derailment::verdict const &Verdict, derailment::ve } } -void TMoverParameters::rerail() +void physics::Vehicle::rerail() { DamageFlag.Clear(VehicleDamage::derailed); Derailed = derailment::outcome::none; @@ -785,7 +785,7 @@ void TMoverParameters::rerail() switch_physics(true, wake_cause::command); } -void TMoverParameters::repair_damage() +void physics::Vehicle::repair_damage() { DamageFlag = {}; EngDmgFlag = 0; @@ -799,7 +799,7 @@ void TMoverParameters::repair_damage() rerail(); } -void TMoverParameters::Derail(DerailReason const Reason) +void physics::Vehicle::Derail(DerailReason const Reason) { if (DamageFlag.Set(VehicleDamage::derailed)) { @@ -844,19 +844,19 @@ void TMoverParameters::Derail(DerailReason const Reason) else if (Reason == WRONG_TRACK_TYPE) ErrorLog("Bad dynamic: " + Name + " derailed due to wrong track type"); // błąd w scenerii else if (Reason == COLLISION) - WriteLog("Bad driving: " + Name + " derailed"); // This reason also generates its own message in `TMoverParameters::CollisionDetect()` + WriteLog("Bad driving: " + Name + " derailed"); // This reason also generates its own message in `physics::Vehicle::CollisionDetect()` else if (Reason == TRAILED_SWITCH) ErrorLog("Bad driving: " + Name + " derailed trailing through a switch with a movable nose set the other way"); } } -bool TMoverParameters::leaves_track() const +bool physics::Vehicle::leaves_track() const { return Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1) && DamageFlag.HasAll(VehicleDamage::derailed) && Derailed != derailment::outcome::none && false == OffTrack.active(); } -void TMoverParameters::pull_off(int const Side, double const Acceleration, std::string const &Why) +void physics::Vehicle::pull_off(int const Side, double const Acceleration, std::string const &Why) { if (Global.derailment != global_settings::derailment_model::physical || false == DamageFlag.Set(VehicleDamage::derailed)) { diff --git a/physics/components/commands.cpp b/physics/components/commands.cpp index 1477b3c37..22d1b8558 100644 --- a/physics/components/commands.cpp +++ b/physics/components/commands.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the commands passed between the vehicles of a train #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -34,7 +34,7 @@ http://mozilla.org/MPL/2.0/. // Q: 20160714 // Wstawia komendę z parametrem, od sprzęgu i w lokalizacji do pojazdu // ************************************************************************************************* -void TMoverParameters::PutCommand(std::string const &NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation) +void physics::Vehicle::PutCommand(std::string const &NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation) { auto const parsed{ParseVehicleCommand(NewCommand)}; CommandIn.Command = parsed.command; @@ -50,7 +50,7 @@ void TMoverParameters::PutCommand(std::string const &NewCommand, double NewValue // Q: 20160714 // Ustawienie komendy wraz z parametrami // ************************************************************************************************* -bool TMoverParameters::SetInternalCommand(VehicleCommand const NewCommand, double NewValue1, double NewValue2, CouplingSet const Couplertype) +bool physics::Vehicle::SetInternalCommand(VehicleCommand const NewCommand, double NewValue1, double NewValue2, CouplingSet const Couplertype) { bool SIC; if (CommandIn.Command == NewCommand && CommandIn.Argument.empty() && CommandIn.Value1 == NewValue1 && CommandIn.Value2 == NewValue2 && CommandIn.couplings == Couplertype) @@ -74,7 +74,7 @@ bool TMoverParameters::SetInternalCommand(VehicleCommand const NewCommand, doubl // Q: 20160714 // wysyłanie komendy w kierunku dir (1=przód, -1=tył) do kolejnego pojazdu (jednego) // ************************************************************************************************* -bool TMoverParameters::SendCtrlToNext(VehicleCommand const CtrlCommand, double const ctrlvalue, double const dir, CouplingSet const Couplertype) +bool physics::Vehicle::SendCtrlToNext(VehicleCommand const CtrlCommand, double const ctrlvalue, double const dir, CouplingSet const Couplertype) { bool OK; int d; // numer sprzęgu w kierunku którego wysyłamy @@ -114,7 +114,7 @@ bool TMoverParameters::SendCtrlToNext(VehicleCommand const CtrlCommand, double c // Komenda musi być zdefiniowana tutaj, a jeśli się wywołuje funkcję, to ona nie może // sama przesyłać do kolejnych pojazdów. Należy też się zastanowić, czy dla uzyskania // jakiejś zmiany (np. IncMainCtrl) lepiej wywołać funkcję, czy od razu wysłać komendę. -bool TMoverParameters::RunCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, std::string_view const Argument) +bool physics::Vehicle::RunCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, std::string_view const Argument) { // the group of the command sets OK; a command none of them knows isn't done if (bool OK{false}; RunControllerCommand(Command, CValue1, CValue2, Couplertype, OK) || RunRelaysCommand(Command, CValue1, CValue2, Couplertype, OK) || @@ -134,7 +134,7 @@ bool TMoverParameters::RunCommand(VehicleCommand const Command, double CValue1, } // RunCommand() for the controllers; returns whether the command is one of them -bool TMoverParameters::RunControllerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunControllerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::mainController) { @@ -183,7 +183,7 @@ bool TMoverParameters::RunControllerCommand(VehicleCommand const Command, double } // RunCommand() for the direction, the automatic start and the current relays; returns whether the command is one of them -bool TMoverParameters::RunRelaysCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunRelaysCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::direction) { @@ -217,7 +217,7 @@ bool TMoverParameters::RunRelaysCommand(VehicleCommand const Command, double CVa } // RunCommand() for the cab and the speed control; returns whether the command is one of them -bool TMoverParameters::RunCabCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunCabCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::cabActivation) { @@ -268,7 +268,7 @@ bool TMoverParameters::RunCabCommand(VehicleCommand const Command, double CValue } // RunCommand() for the train brake, the releaser and the emergency brake; returns whether the command is one of them -bool TMoverParameters::RunBrakeCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunBrakeCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::brake) // youBy - jak sie EP hamuje, to trza sygnal wyslac... { @@ -308,7 +308,7 @@ bool TMoverParameters::RunBrakeCommand(VehicleCommand const Command, double CVal } // RunCommand() for the brake delays, the spring brake, the sand and the cab signalling; returns whether the command is one of them -bool TMoverParameters::RunBrakeEquipmentCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunBrakeEquipmentCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::brakeDelay) { @@ -355,7 +355,7 @@ bool TMoverParameters::RunBrakeEquipmentCommand(VehicleCommand const Command, do } // RunCommand() for the heating, the converter, the battery and the compressor; returns whether the command is one of them -bool TMoverParameters::RunAuxiliariesCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunAuxiliariesCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::heatingSwitch) { @@ -403,7 +403,7 @@ bool TMoverParameters::RunAuxiliariesCommand(VehicleCommand const Command, doubl } // RunCommand() for the water, fuel and oil pumps and the water heater; returns whether the command is one of them -bool TMoverParameters::RunPumpsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunPumpsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::waterPumpBreakerSwitch) { @@ -514,7 +514,7 @@ bool TMoverParameters::RunPumpsCommand(VehicleCommand const Command, double CVal } // RunCommand() for the motor blowers and the compartment lights; returns whether the command is one of them -bool TMoverParameters::RunBlowersCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunBlowersCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::motorBlowersFrontSwitch) { @@ -580,7 +580,7 @@ bool TMoverParameters::RunBlowersCommand(VehicleCommand const Command, double CV } // RunCommand() for the line breaker, the relays and the pantographs; returns whether the command is one of them -bool TMoverParameters::RunPowerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunPowerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::mainSwitch) { @@ -634,7 +634,7 @@ bool TMoverParameters::RunPowerCommand(VehicleCommand const Command, double CVal } // RunCommand() for the doors and the departure signal; returns whether the command is one of them -bool TMoverParameters::RunDoorsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) +bool physics::Vehicle::RunDoorsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK) { if (Command == VehicleCommand::doorPermit) { @@ -675,7 +675,7 @@ bool TMoverParameters::RunDoorsCommand(VehicleCommand const Command, double CVal // the doors' permits, on the sides the command names: CValue1 the sides, negative to take the permit back, CValue2 the // direction the command comes from -void TMoverParameters::DoorPermitCommand(double const CValue1, double const CValue2) +void physics::Vehicle::DoorPermitCommand(double const CValue1, double const CValue2) { auto const leftside{CValue2 > 0 ? 1 : 2}; if (auto const rightside{3 - leftside}; std::abs(static_cast(CValue1)) & rightside) @@ -689,7 +689,7 @@ void TMoverParameters::DoorPermitCommand(double const CValue1, double const CVal } // the doors opened or closed from afar on the sides the command names, unless they're only worked locally -void TMoverParameters::DoorRemoteCommand(bool const Open, double const CValue1, double const CValue2) +void physics::Vehicle::DoorRemoteCommand(bool const Open, double const CValue1, double const CValue2) { using enum control_t; if (auto const doorcontrol{Open ? Doors.open_control : Doors.close_control}; @@ -731,7 +731,7 @@ bool setOrClear(DamageSet &damage, int const number) } // namespace // RunCommand() for the load and the damage; returns whether the command is one of them -bool TMoverParameters::RunLoadCommand(VehicleCommand const Command, double CValue1, double CValue2, std::string_view const Argument, bool &OK) +bool physics::Vehicle::RunLoadCommand(VehicleCommand const Command, double CValue1, double CValue2, std::string_view const Argument, bool &OK) { if (Command == VehicleCommand::load) { @@ -794,7 +794,7 @@ bool TMoverParameters::RunLoadCommand(VehicleCommand const Command, double CValu // Q: 20160714 // Uruchamia funkcję RunCommand aż do skutku. Jeśli będzie pozytywny to kasuje komendę. // ************************************************************************************************* -bool TMoverParameters::RunInternalCommand() +bool physics::Vehicle::RunInternalCommand() { bool OK; diff --git a/physics/components/controllers.cpp b/physics/components/controllers.cpp index d5e41b2c3..902eecc4b 100644 --- a/physics/components/controllers.cpp +++ b/physics/components/controllers.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the master and the secondary controllers, the automatic relay and the camshaft, the integrated controller, the speed control #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -40,7 +40,7 @@ http://mozilla.org/MPL/2.0/. // zwiększenie nastawinika // ************************************************************************************************* -bool TMoverParameters::IncMainCtrl(int CtrlSpeed) +bool physics::Vehicle::IncMainCtrl(int CtrlSpeed) { // basic fail conditions: if (MainCtrlPosNo <= 0 || CabActive == 0) @@ -107,14 +107,14 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed) } // a notch up, as the kind of the engine takes it; returns whether the controller moved -bool TMoverParameters::IncMainCtrlByEngine(int const CtrlSpeed) +bool physics::Vehicle::IncMainCtrlByEngine(int const CtrlSpeed) { return Drive().IncreaseMainController(*this, CtrlSpeed); } // a notch up of the series motors' controller: CtrlSpeed over 1 runs it to the first position without resistors; // returns whether it moved as asked -bool TMoverParameters::IncMainCtrlSeriesMotor(int const CtrlSpeed) +bool physics::Vehicle::IncMainCtrlSeriesMotor(int const CtrlSpeed) { bool OK = false; if (DirActive == 0) @@ -179,7 +179,7 @@ bool TMoverParameters::IncMainCtrlSeriesMotor(int const CtrlSpeed) // Q: 20160710 // zmniejszenie nastawnika // ***************************************************************************** -bool TMoverParameters::DecMainCtrl(int CtrlSpeed) +bool physics::Vehicle::DecMainCtrl(int CtrlSpeed) { bool OK = false; // basic fail conditions: @@ -236,13 +236,13 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed) } // a notch down, as the kind of the engine takes it; returns whether the controller moved -bool TMoverParameters::DecMainCtrlByEngine(int const CtrlSpeed) +bool physics::Vehicle::DecMainCtrlByEngine(int const CtrlSpeed) { return Drive().DecreaseMainController(*this, CtrlSpeed); } // a notch down of the series motors' controller: CtrlSpeed over 1 runs it down to the first position without resistors -bool TMoverParameters::DecMainCtrlSeriesMotor(int const CtrlSpeed) +bool physics::Vehicle::DecMainCtrlSeriesMotor(int const CtrlSpeed) { bool OK = false; if (CtrlSpeed == 1) /*and (ScndCtrlPos=0)*/ @@ -267,25 +267,25 @@ bool TMoverParameters::DecMainCtrlSeriesMotor(int const CtrlSpeed) return OK; } -bool TMoverParameters::IsMainCtrlActualNoPowerPos() const +bool physics::Vehicle::IsMainCtrlActualNoPowerPos() const { // TODO: wrap controller pieces into a class for potential specializations, similar to brake subsystems return MainCtrlActualPos <= MainCtrlNoPowerPos(); } -bool TMoverParameters::IsMainCtrlNoPowerPos() const +bool physics::Vehicle::IsMainCtrlNoPowerPos() const { // TODO: wrap controller pieces into a class for potential specializations, similar to brake subsystems return MainCtrlPos <= MainCtrlNoPowerPos(); } -bool TMoverParameters::IsMainCtrlMaxPowerPos() const +bool physics::Vehicle::IsMainCtrlMaxPowerPos() const { // TODO: wrap controller pieces into a class for potential specializations, similar to brake subsystems return MainCtrlPos == MainCtrlPosNo; } -int TMoverParameters::MainCtrlNoPowerPos() const +int physics::Vehicle::MainCtrlNoPowerPos() const { switch (EIMCtrlType) @@ -309,35 +309,35 @@ int TMoverParameters::MainCtrlNoPowerPos() const } } -int TMoverParameters::MainCtrlActualPowerPos() const +int physics::Vehicle::MainCtrlActualPowerPos() const { return MainCtrlActualPos - MainCtrlNoPowerPos(); } -int TMoverParameters::MainCtrlPowerPos() const +int physics::Vehicle::MainCtrlPowerPos() const { return MainCtrlPos - MainCtrlNoPowerPos(); } -int TMoverParameters::EIMCtrlEmergencyPositions() const +int physics::Vehicle::EIMCtrlEmergencyPositions() const { return (EIMCtrlType == 2 && EIMCtrlMainEmergency) ? 1 : 0; } -bool TMoverParameters::IsMainCtrlEmergencyPos() const +bool physics::Vehicle::IsMainCtrlEmergencyPos() const { return MainCtrlPos < EIMCtrlEmergencyPositions(); } -int TMoverParameters::MainCtrlPosForCoupled() const +int physics::Vehicle::MainCtrlPosForCoupled() const { // the emergency brake itself reaches the train through the brake pipe, vented by the vehicle driven from return std::max(0, MainCtrlPos - EIMCtrlEmergencyPositions()); } -int TMoverParameters::MainCtrlPosFromCoupled(int const Position) const +int physics::Vehicle::MainCtrlPosFromCoupled(int const Position) const { return Position + EIMCtrlEmergencyPositions(); } @@ -346,7 +346,7 @@ int TMoverParameters::MainCtrlPosFromCoupled(int const Position) const // Q: 20160710 // zwiększenie bocznika // ************************************************************************************************* -bool TMoverParameters::IncScndCtrl(int CtrlSpeed) +bool physics::Vehicle::IncScndCtrl(int CtrlSpeed) { bool OK = false; @@ -419,7 +419,7 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed) // Q: 20160710 // zmniejszenie bocznika // ************************************************************************************************* -bool TMoverParameters::DecScndCtrl(int CtrlSpeed) +bool physics::Vehicle::DecScndCtrl(int CtrlSpeed) { bool OK = false; @@ -480,13 +480,13 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed) return OK; } -bool TMoverParameters::IsScndCtrlLockedByMainCtrl() const +bool physics::Vehicle::IsScndCtrlLockedByMainCtrl() const { // ET21, ET22, EP09: the field shunting engages only on the resistance-free positions of the master controller (eu07/maszyna#402) return ScndCtrlResistiveLock && (IsMainCtrlNoPowerPos() || RList[MainCtrlPos].R >= 0.01); } -void TMoverParameters::ScndCtrlResistiveLockCheck() +void physics::Vehicle::ScndCtrlResistiveLockCheck() { // the shunt controller, locked in both directions on zero and the resistive positions, would otherwise stay engaged there once the // master controller is taken back (or set from elsewhere, e.g. by the AI or another vehicle of the consist) with the shunt on @@ -496,20 +496,20 @@ void TMoverParameters::ScndCtrlResistiveLockCheck() } } -int TMoverParameters::GetVirtualScndPos() const +int physics::Vehicle::GetVirtualScndPos() const { if (TrainType == train_type::et42 && DynamicBrakeFlag && !ScndCtrlPos) return -1; return ScndCtrlPos; } -bool TMoverParameters::IsScndCtrlNoPowerPos() const +bool physics::Vehicle::IsScndCtrlNoPowerPos() const { // TODO: refine the check on account of potential electric series vehicles with speed control return ScndCtrlPos == 0 || true == SpeedCtrl; } -bool TMoverParameters::IsScndCtrlMaxPowerPos() const +bool physics::Vehicle::IsScndCtrlMaxPowerPos() const { // TODO: refine the check on account of potential electric series vehicles with speed control return ScndCtrlPos == ScndCtrlPosNo || true == SpeedCtrl; @@ -519,7 +519,7 @@ bool TMoverParameters::IsScndCtrlMaxPowerPos() const // Q: 20160713 // Włączenie / wyłączenie automatycznego rozruchu // ************************************************************************************************* -bool TMoverParameters::AutoRelaySwitch(bool State) +bool physics::Vehicle::AutoRelaySwitch(bool State) { bool ARS; if (AutoRelayType == 2 && AutoRelayFlag != State) @@ -539,7 +539,7 @@ bool TMoverParameters::AutoRelaySwitch(bool State) // Sprawdzenie warunków pracy automatycznego rozruchu // ************************************************************************************************* -bool TMoverParameters::AutoRelayCheck(void) +bool physics::Vehicle::AutoRelayCheck(void) { bool OK = false; // b:int; @@ -592,7 +592,7 @@ bool TMoverParameters::AutoRelayCheck(void) } // a step of the shunt field on a position without resistors, up or down to the second controller -bool TMoverParameters::AutoRelayShuntStep(bool const ARFASI2) +bool physics::Vehicle::AutoRelayShuntStep(bool const ARFASI2) { bool OK = false; // scnd bez samoczynnego rozruchu @@ -620,7 +620,7 @@ bool TMoverParameters::AutoRelayShuntStep(bool const ARFASI2) } // a step of the main controller's relays, up or down to its position, or the shunt field off on the resistors -bool TMoverParameters::AutoRelayMainStep(bool const ARFASI) +bool physics::Vehicle::AutoRelayMainStep(bool const ARFASI) { bool OK = false; // running backwards, the motors don't get joined in more branches than allowed (the series connection @@ -654,7 +654,7 @@ bool TMoverParameters::AutoRelayMainStep(bool const ARFASI) // a step of the main relays up to the controller's position, at once to the parallel position without resistors // on a fast serial circuit (303E); returns whether the relays moved, never into parallel with the overload relay high -bool TMoverParameters::AutoRelayMainUp(bool const ARFASI) +bool physics::Vehicle::AutoRelayMainUp(bool const ARFASI) { bool OK = false; // prevent switch to parallel mode if motor overload relay is set to high threshold mode @@ -690,7 +690,7 @@ bool TMoverParameters::AutoRelayMainUp(bool const ARFASI) // a notch up of the main relays after their delay, through the group switch of the ET22, and the sounds of the // parallel positions; returns whether they moved -bool TMoverParameters::AutoRelayMainNotchUp() +bool physics::Vehicle::AutoRelayMainNotchUp() { bool OK = false; // WriteLog("LRT = " + FloatToStr(LastRelayTime) + ", " + @@ -739,7 +739,7 @@ bool TMoverParameters::AutoRelayMainNotchUp() } // a step of the main relays down to the controller's position; returns whether they moved -bool TMoverParameters::AutoRelayMainDown() +bool physics::Vehicle::AutoRelayMainDown() { bool OK = false; if (RList[MainCtrlPos].R == 0 && MainCtrlPos > 0 && !(MainCtrlPos == MainCtrlPosNo) && FastSerialCircuit == 1) @@ -771,7 +771,7 @@ bool TMoverParameters::AutoRelayMainDown() } // the line contactors closed at the first position, or, open, the camshaft run back to zero -bool TMoverParameters::AutoRelayLineContactorsStep(bool const motorconnectorsoff) +bool physics::Vehicle::AutoRelayLineContactorsStep(bool const motorconnectorsoff) { bool OK = false; // ybARC - zalaczenie stycznikow liniowych @@ -802,7 +802,7 @@ bool TMoverParameters::AutoRelayLineContactorsStep(bool const motorconnectorsoff // the camshaft, the line contactors open, run back to its zero position a step at a time, or at once without one; // returns whether it moved -bool TMoverParameters::CamshaftRunDown() +bool physics::Vehicle::CamshaftRunDown() { bool OK = false; @@ -850,7 +850,7 @@ bool TMoverParameters::CamshaftRunDown() } // the one way camshaft of the EN57 run on to its end and round to zero; returns whether it moved -bool TMoverParameters::CamshaftRunDownEMU() +bool physics::Vehicle::CamshaftRunDownEMU() { bool OK = false; // EN57 wal jednokierunkowy calosciowy @@ -889,7 +889,7 @@ bool TMoverParameters::CamshaftRunDownEMU() return OK; } -bool TMoverParameters::MotorConnectorsCheck() +bool physics::Vehicle::MotorConnectorsCheck() { // hunter-111211: wylacznik cisnieniowy @@ -910,7 +910,7 @@ bool TMoverParameters::MotorConnectorsCheck() return false == connectorsoff && LineContactorsInterlockReleased(); } -bool TMoverParameters::LineContactorsInterlockReleased() const +bool physics::Vehicle::LineContactorsInterlockReleased() const { switch (LineContactorsInterlock) { @@ -990,7 +990,7 @@ double stepped_uc_value(double const Current, double const Ramped, TUniversalCtr } // namespace -void TMoverParameters::CheckEIMIC(double dt) +void physics::Vehicle::CheckEIMIC(double dt) { double offset = EIMCtrlAdditionalZeros ? 1.0 : 0.0; double multiplier = (EIMCtrlEmergency ? 1.0 : 0.0) + offset; @@ -1034,7 +1034,7 @@ void TMoverParameters::CheckEIMIC(double dt) } // the controller (EIMCtrlType 0): the position of the main controller, or the analog one, or the brake asked -void TMoverParameters::EIMICFromController(double const brakeDemand, double const offset, double const multiplier) +void physics::Vehicle::EIMICFromController(double const brakeDemand, double const offset, double const multiplier) { eimic = brakeDemand > 0.01 ? -brakeDemand : eimic_analog > 0.01 ? eimic_analog : (double)MainCtrlPos / (double)MainCtrlPosNo; if (EIMCtrlAdditionalZeros || EIMCtrlEmergency) @@ -1049,7 +1049,7 @@ void TMoverParameters::EIMICFromController(double const brakeDemand, double cons } // EIMCtrlType 1: the positions B+ to TMax move the value at a steady pace -void TMoverParameters::EIMICFromSteps(double dt) +void physics::Vehicle::EIMICFromSteps(double dt) { switch (MainCtrlPos) { @@ -1085,7 +1085,7 @@ void TMoverParameters::EIMICFromSteps(double dt) // EIMCtrlType 2: the positions 0 to 4 move the value towards -1, 0 or 1, from the controller's delay on; the // emergency brake position below them, where the controller has one, brakes in full at once -void TMoverParameters::EIMICFromFourPositions(double dt) +void physics::Vehicle::EIMICFromFourPositions(double dt) { if (IsMainCtrlEmergencyPos()) { @@ -1129,7 +1129,7 @@ void TMoverParameters::EIMICFromFourPositions(double dt) } // EIMCtrlType 3: the universal controller of UniCtrlList, with the train brake built in or not -void TMoverParameters::EIMICFromUniversalController(double dt, double const brakeDemand) +void physics::Vehicle::EIMICFromUniversalController(double dt, double const brakeDemand) { if (UniCtrlIntegratedBrakePNCtrl) { @@ -1166,7 +1166,7 @@ void TMoverParameters::EIMICFromUniversalController(double dt, double const brak // the train brake built into the universal controller: the handle set to the controller's position, or the // controller, at a brake handle moved alone, to the nearest position of the handle's -void TMoverParameters::UniversalControllerTrainBrake() +void physics::Vehicle::UniversalControllerTrainBrake() { if (UniCtrlList[MainCtrlPos].mode != BrakeCtrlPos && MainCtrlActualPos == MainCtrlPos) // there was no move of controller, but brake only { @@ -1187,7 +1187,7 @@ void TMoverParameters::UniversalControllerTrainBrake() } // the local brake of the TRAXX locomotives, by time: released, held or applied, which cuts the drive off -void TMoverParameters::EIMICTraxxLocalBrake(double dt) +void physics::Vehicle::EIMICTraxxLocalBrake(double dt) { if (LocalBrakeRatio() < 0.4) // pozycja 0, odhamowywanie { @@ -1210,7 +1210,7 @@ void TMoverParameters::EIMICTraxxLocalBrake(double dt) } // the value limited by the power, the spring brake, the pipe lock, the direction and the doors' permits -void TMoverParameters::EIMICLimit() +void physics::Vehicle::EIMICLimit() { auto const eimicpowerenabled{(MainCircuitPowered() || Power == 0.0) && (!SpringBrake.IsActive || !SpringBrakeCutsOffDrive) && !LockPipe && DirAbsolute != 0}; auto const eimicdoorenabled{(SpringBrake.IsActive && ReleaseParkingBySpringBrakeWhenDoorIsOpen)}; @@ -1236,7 +1236,7 @@ void TMoverParameters::EIMICLimit() eimic = safe_clamp(eimic, -1.0, eimicpowerenabled ? eimic_max : 0.0); } -void TMoverParameters::CheckSpeedCtrl(double dt) +void physics::Vehicle::CheckSpeedCtrl(double dt) { if (EIMCtrlType == 0) { @@ -1301,7 +1301,7 @@ void TMoverParameters::CheckSpeedCtrl(double dt) // the PI regulator of the speed control: the power asked of the drive, or its brake intervention, from the error of // the speed; accfactor, the most power it may ask -void TMoverParameters::SpeedCtrlRegulator(double dt, double const accfactor) +void physics::Vehicle::SpeedCtrlRegulator(double dt, double const accfactor) { if (SpeedCtrlUnit.ManualStateOverride && eimic > 0.0009) eimic = 1.0; @@ -1339,18 +1339,18 @@ void TMoverParameters::SpeedCtrlRegulator(double dt, double const accfactor) } } -bool TMoverParameters::IsSpeedCtrlSeparate() const +bool physics::Vehicle::IsSpeedCtrlSeparate() const { // no secondary controller, or one of these engines', which shunts the field of the traction motors (eu07/maszyna#69) return SpeedCtrl && (ScndCtrlPosNo == 0 || EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric); } -bool TMoverParameters::IsSpeedCtrlEngaged() const +bool physics::Vehicle::IsSpeedCtrlEngaged() const { return IsSpeedCtrlSeparate() ? SpeedCtrlUnit.IsActive : ScndCtrlPos > 0; } -bool TMoverParameters::SpeedCtrlSwitch(bool const State) +bool physics::Vehicle::SpeedCtrlSwitch(bool const State) { if (false == IsSpeedCtrlSeparate()) { @@ -1377,7 +1377,7 @@ bool TMoverParameters::SpeedCtrlSwitch(bool const State) return wasactive; } -void TMoverParameters::SpeedCtrlButton(int button) +void physics::Vehicle::SpeedCtrlButton(int button) { if (SpeedCtrl && IsSpeedCtrlEngaged()) { @@ -1385,7 +1385,7 @@ void TMoverParameters::SpeedCtrlButton(int button) } } -void TMoverParameters::SpeedCtrlInc() +void physics::Vehicle::SpeedCtrlInc() { if (SpeedCtrl && IsSpeedCtrlEngaged()) { @@ -1394,7 +1394,7 @@ void TMoverParameters::SpeedCtrlInc() } } -void TMoverParameters::SpeedCtrlDec() +void physics::Vehicle::SpeedCtrlDec() { if (SpeedCtrl && IsSpeedCtrlEngaged()) { @@ -1403,7 +1403,7 @@ void TMoverParameters::SpeedCtrlDec() } } -bool TMoverParameters::SpeedCtrlPowerInc() +bool physics::Vehicle::SpeedCtrlPowerInc() { if (!(SpeedCtrl && IsSpeedCtrlEngaged())) return false; @@ -1415,7 +1415,7 @@ bool TMoverParameters::SpeedCtrlPowerInc() return true; } -bool TMoverParameters::SpeedCtrlPowerDec() +bool physics::Vehicle::SpeedCtrlPowerDec() { if (!(SpeedCtrl && IsSpeedCtrlEngaged())) return false; diff --git a/physics/components/couplers.cpp b/physics/components/couplers.cpp index 7bf797524..6de010fff 100644 --- a/physics/components/couplers.cpp +++ b/physics/components/couplers.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // attaching and detaching, the forces in the couplers and the automatic coupling #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -29,23 +29,23 @@ http://mozilla.org/MPL/2.0/. #include #include "physics/components/internal.h" -// Ra: tu należy przenosić funcje z mover.pas, które nie są z niego wywoływane. -// Jeśli jakieś zmienne nie są używane w mover.pas, też można je przenosić. +// Ra: tu należy przenosić funcje z physics.pas, które nie są z niego wywoływane. +// Jeśli jakieś zmienne nie są używane w physics.pas, też można je przenosić. // Przeniesienie wszystkiego na raz zrobiło by zbyt wielki chaos do ogarnięcia. const double dEpsilon = 0.01; // 1cm (zależy od typu sprzęgu...) -double TMoverParameters::Distance(const TLocation &Loc1, const TLocation &Loc2, const TDimension &Dim1, const TDimension &Dim2) +double physics::Vehicle::Distance(const TLocation &Loc1, const TLocation &Loc2, const TDimension &Dim1, const TDimension &Dim2) { // zwraca odległość pomiędzy pojazdami (Loc1) i (Loc2) z uwzględnieneim ich długości (kule!) return hypot(Loc2.X - Loc1.X, Loc1.Y - Loc2.Y) - 0.5 * (Dim2.L + Dim1.L); }; -double TMoverParameters::CouplerDist(TMoverParameters const *Left, TMoverParameters const *Right) +double physics::Vehicle::CouplerDist(physics::Vehicle const *Left, physics::Vehicle const *Right) { // obliczenie odległości pomiędzy sprzęgami (kula!) return Distance(Left->Loc, Right->Loc, Left->Dim, Right->Dim); // odległość pomiędzy sprzęgami (kula!) }; -bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *ConnectTo, CouplingSet CouplingType, bool Enforce, bool Audible) +bool physics::Vehicle::Attach(int ConnectNo, int ConnectToNr, physics::Vehicle *ConnectTo, CouplingSet CouplingType, bool Enforce, bool Audible) { // łączenie do swojego sprzęgu (ConnectNo) pojazdu (ConnectTo) stroną (ConnectToNr) // Ra: zwykle wykonywane dwukrotnie, dla każdego pojazdu oddzielnie // Ra: trzeba by odróżnić wymóg dociśnięcia od uszkodzenia sprzęgu przy podczepianiu AI do składu @@ -119,7 +119,7 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters * return true; } -int TMoverParameters::DettachStatus(int ConnectNo) +int physics::Vehicle::DettachStatus(int ConnectNo) { // Ra: sprawdzenie, czy odległość jest dobra do rozłączania // powinny być 3 informacje: =0 sprzęg już rozłączony, <0 da się rozłączyć. >0 nie da się rozłączyć if (!Couplers[ConnectNo].Connected) @@ -134,7 +134,7 @@ int TMoverParameters::DettachStatus(int ConnectNo) return Neighbours[ConnectNo].distance > 0.2 ? -Couplers[ConnectNo].CouplingFlag.Bits() : Couplers[ConnectNo].CouplingFlag.Bits(); }; -bool TMoverParameters::Dettach(int ConnectNo) +bool physics::Vehicle::Dettach(int ConnectNo) { // rozlaczanie auto &thiscoupler{Couplers[ConnectNo]}; @@ -183,21 +183,21 @@ bool TMoverParameters::Dettach(int ConnectNo) // ************************************************************************************************* // prędkość zbliżania się stykających się końców pojazdów przy zderzeniu, w km/h // ************************************************************************************************* -double TMoverParameters::CollisionVelocity(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd) const +double physics::Vehicle::CollisionVelocity(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const { auto const velocitydifference{CouplerVelocityDifference(End, Other, OtherEnd)}; // the front end closes in on the other vehicle when this one moves forward faster, the rear end when it's slower return (End == VehicleEnd::front ? velocitydifference : -velocitydifference) * 3.6; // m/s -> km/h } -double TMoverParameters::CouplerVelocityDifference(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd) const +double physics::Vehicle::CouplerVelocityDifference(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const { // V runs along the vehicle's own axis, towards its front; the other vehicle's velocity is turned around when the // vehicles face each other (touch with the same ends) return V - Other.V * DirPatch(End, OtherEnd); } -bool TMoverParameters::AutomaticCouplingSafe(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd) const +bool physics::Vehicle::AutomaticCouplingSafe(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const { return false == Global.crash_damage || CollisionVelocity(End, Other, OtherEnd) <= SafeCollisionVelocity; } @@ -230,7 +230,7 @@ traction_kind traction_of(TEngineType const Engine) } // namespace -bool TMoverParameters::ControlCouplingAllowed(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd) const +bool physics::Vehicle::ControlCouplingAllowed(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const { if (false == Global.control_coupling_engine_check) { @@ -246,7 +246,7 @@ bool TMoverParameters::ControlCouplingAllowed(VehicleEnd const End, TMoverParame return traction == traction_kind::none || othertraction == traction_kind::none || traction == othertraction; } -CouplingSet TMoverParameters::CompatibleCoupling(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd, CouplingSet const CouplingType) const +CouplingSet physics::Vehicle::CompatibleCoupling(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd, CouplingSet const CouplingType) const { if (false == CouplingType.HasAny(Coupling::control) || CouplingType.HasAny(Coupling::permanent) || ControlCouplingAllowed(End, Other, OtherEnd)) { @@ -259,7 +259,7 @@ CouplingSet TMoverParameters::CompatibleCoupling(VehicleEnd const End, TMoverPar // Q: 20160713 // Obliczanie sił dzialających na sprzęgach // ************************************************************************************************* -double TMoverParameters::CouplerForce(VehicleEnd const End, double dt) +double physics::Vehicle::CouplerForce(VehicleEnd const End, double dt) { if (coupler_physics_at(End)) { @@ -267,7 +267,7 @@ double TMoverParameters::CouplerForce(VehicleEnd const End, double dt) } auto &thiscoupler{Couplers[End]}; - auto *othervehicle{Neighbours[End].vehicle->MoverParameters}; + auto *othervehicle{Neighbours[End].vehicle->physics}; auto const otherend{Neighbours[End].FacingEnd()}; auto const &othercoupler{othervehicle->Couplers[otherend]}; @@ -385,7 +385,7 @@ double TMoverParameters::CouplerForce(VehicleEnd const End, double dt) } // a coupler stretched with more than its strength for over a second breaks, the more likely the longer, with crash damage on -void TMoverParameters::CouplerStretchCheck(VehicleEnd const End, double const CF, double dt) +void physics::Vehicle::CouplerStretchCheck(VehicleEnd const End, double const CF, double dt) { auto &thiscoupler{Couplers[End]}; if (std::abs(CF) > thiscoupler.FmaxC) @@ -405,7 +405,7 @@ void TMoverParameters::CouplerStretchCheck(VehicleEnd const End, double const CF } } -bool TMoverParameters::coupler_physics_at(VehicleEnd const End) const +bool physics::Vehicle::coupler_physics_at(VehicleEnd const End) const { if (false == Global.coupler_physics) { @@ -417,10 +417,10 @@ bool TMoverParameters::coupler_physics_at(VehicleEnd const End) const } // either vehicle of the pair covered takes the pair in, so both of them compute it the same way auto const *other{Neighbours[End].vehicle}; - return other != nullptr && other->MoverParameters->CouplerPhysics; + return other != nullptr && other->physics->CouplerPhysics; } -void TMoverParameters::automatic_coupling(VehicleEnd const End, TMoverParameters &Other, VehicleEnd const OtherEnd) +void physics::Vehicle::automatic_coupling(VehicleEnd const End, physics::Vehicle &Other, VehicleEnd const OtherEnd) { auto &thiscoupler{Couplers[End]}; auto &othercoupler{Other.Couplers[OtherEnd]}; @@ -490,10 +490,10 @@ int coupler_sounds(coupler_sound_input const &Input) } // namespace -double TMoverParameters::coupler_force_physical(VehicleEnd const End, double const dt) +double physics::Vehicle::coupler_force_physical(VehicleEnd const End, double const dt) { auto &thiscoupler{Couplers[End]}; - auto *othervehicle{Neighbours[End].vehicle->MoverParameters}; + auto *othervehicle{Neighbours[End].vehicle->physics}; auto const otherend{Neighbours[End].FacingEnd()}; auto &othercoupler{othervehicle->Couplers[otherend]}; auto &state{thiscoupler.physics_state}; @@ -547,7 +547,7 @@ double TMoverParameters::coupler_force_physical(VehicleEnd const End, double con return force; } -bool TMoverParameters::coupler_stop_hit(VehicleEnd const End, TMoverParameters &Other, VehicleEnd const OtherEnd) +bool physics::Vehicle::coupler_stop_hit(VehicleEnd const End, physics::Vehicle &Other, VehicleEnd const OtherEnd) { auto &thiscoupler{Couplers[End]}; auto &othercoupler{Other.Couplers[OtherEnd]}; diff --git a/physics/components/diesel.cpp b/physics/components/diesel.cpp index aee5d8e21..034a11793 100644 --- a/physics/components/diesel.cpp +++ b/physics/components/diesel.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the diesel engine: its revolutions, the gearbox, the clutch, the hydraulic transmission, its heat and pumps #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -31,23 +31,23 @@ http://mozilla.org/MPL/2.0/. #include "physics/components/drive.h" -double TMoverParameters::EngineRPMRatio() const +double physics::Vehicle::EngineRPMRatio() const { return Drive().EngineRpmRatio(*this); } -double TMoverParameters::EngineIdleRPM() const +double physics::Vehicle::EngineIdleRPM() const { return Drive().EngineIdleRpm(*this); } -double TMoverParameters::EngineMaxRPM() const +double physics::Vehicle::EngineMaxRPM() const { return Drive().EngineMaxRpm(*this); } // water pump status check -void TMoverParameters::WaterPumpCheck(double const /*Timestep*/) +void physics::Vehicle::WaterPumpCheck(double const /*Timestep*/) { // NOTE: breaker override with start type is sm42 specific hack, replace with ability to define the presence of the breaker WaterPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && true == WaterPump.breaker && false == WaterPump.is_disabled && @@ -55,7 +55,7 @@ void TMoverParameters::WaterPumpCheck(double const /*Timestep*/) } // water heater status check -void TMoverParameters::WaterHeaterCheck(double const /*Timestep*/) +void physics::Vehicle::WaterHeaterCheck(double const /*Timestep*/) { WaterHeater.is_active = false == WaterHeater.is_damaged && true == (Power24vIsAvailable || Power110vIsAvailable) && true == WaterHeater.is_enabled && true == WaterHeater.breaker && @@ -70,7 +70,7 @@ void TMoverParameters::WaterHeaterCheck(double const /*Timestep*/) } // fuel pump status update -void TMoverParameters::FuelPumpCheck(double const /*Timestep*/) +void physics::Vehicle::FuelPumpCheck(double const /*Timestep*/) { using enum start_t; @@ -82,7 +82,7 @@ void TMoverParameters::FuelPumpCheck(double const /*Timestep*/) } // oil pump status update -void TMoverParameters::OilPumpCheck(double const Timestep) +void physics::Vehicle::OilPumpCheck(double const Timestep) { OilPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && false == Mains && false == OilPump.is_disabled && @@ -110,7 +110,7 @@ void TMoverParameters::OilPumpCheck(double const Timestep) } // water pump breaker state toggle -bool TMoverParameters::WaterPumpBreakerSwitch(bool State, range_t const Notify) +bool physics::Vehicle::WaterPumpBreakerSwitch(bool State, range_t const Notify) { /* if( FuelPump.start_type == start::automatic ) { @@ -131,7 +131,7 @@ bool TMoverParameters::WaterPumpBreakerSwitch(bool State, range_t const Notify) } // water pump state toggle -bool TMoverParameters::WaterPumpSwitch(bool State, range_t const Notify) +bool physics::Vehicle::WaterPumpSwitch(bool State, range_t const Notify) { if (WaterPump.start_type == start_t::battery) @@ -153,7 +153,7 @@ bool TMoverParameters::WaterPumpSwitch(bool State, range_t const Notify) } // water pump state toggle -bool TMoverParameters::WaterPumpSwitchOff(bool State, range_t const Notify) +bool physics::Vehicle::WaterPumpSwitchOff(bool State, range_t const Notify) { if (WaterPump.start_type == start_t::battery) @@ -175,7 +175,7 @@ bool TMoverParameters::WaterPumpSwitchOff(bool State, range_t const Notify) } // water heater breaker state toggle -bool TMoverParameters::WaterHeaterBreakerSwitch(bool State, range_t const Notify) +bool physics::Vehicle::WaterHeaterBreakerSwitch(bool State, range_t const Notify) { /* if( FuelPump.start_type == start::automatic ) { @@ -196,7 +196,7 @@ bool TMoverParameters::WaterHeaterBreakerSwitch(bool State, range_t const Notify } // water heater state toggle -bool TMoverParameters::WaterHeaterSwitch(bool State, range_t const Notify) +bool physics::Vehicle::WaterHeaterSwitch(bool State, range_t const Notify) { /* if( FuelPump.start_type == start::automatic ) { @@ -217,7 +217,7 @@ bool TMoverParameters::WaterHeaterSwitch(bool State, range_t const Notify) } // water circuits link state toggle -bool TMoverParameters::WaterCircuitsLinkSwitch(bool State, range_t const Notify) +bool physics::Vehicle::WaterCircuitsLinkSwitch(bool State, range_t const Notify) { if (false == diesel.heat.auxiliary_water_circuit) @@ -239,7 +239,7 @@ bool TMoverParameters::WaterCircuitsLinkSwitch(bool State, range_t const Notify) } // fuel pump state toggle -bool TMoverParameters::FuelPumpSwitch(bool State, range_t const Notify) +bool physics::Vehicle::FuelPumpSwitch(bool State, range_t const Notify) { if (FuelPump.start_type == start_t::automatic) @@ -260,7 +260,7 @@ bool TMoverParameters::FuelPumpSwitch(bool State, range_t const Notify) return FuelPump.is_enabled != initialstate; } -bool TMoverParameters::FuelPumpSwitchOff(bool State, range_t const Notify) +bool physics::Vehicle::FuelPumpSwitchOff(bool State, range_t const Notify) { if (FuelPump.start_type == start_t::automatic) @@ -282,7 +282,7 @@ bool TMoverParameters::FuelPumpSwitchOff(bool State, range_t const Notify) } // oil pump state toggle -bool TMoverParameters::OilPumpSwitch(bool State, range_t const Notify) +bool physics::Vehicle::OilPumpSwitch(bool State, range_t const Notify) { if (OilPump.start_type == start_t::automatic) @@ -303,7 +303,7 @@ bool TMoverParameters::OilPumpSwitch(bool State, range_t const Notify) return OilPump.is_enabled != initialstate; } -bool TMoverParameters::OilPumpSwitchOff(bool State, range_t const Notify) +bool physics::Vehicle::OilPumpSwitchOff(bool State, range_t const Notify) { if (OilPump.start_type == start_t::automatic) @@ -326,13 +326,13 @@ bool TMoverParameters::OilPumpSwitchOff(bool State, range_t const Notify) // the revolutions of the engine; returns those a diesel-electric engine aims at [1/s], 0 for the others. // for a diesel engine, the ratio of the transmission and the engine's moment -double TMoverParameters::UpdateEngineRevolutions(double dt, double &dtrans, double &dmoment) +double physics::Vehicle::UpdateEngineRevolutions(double dt, double &dtrans, double &dmoment) { return Drive().UpdateEngineRevolutions(*this, dt, dtrans, dmoment); } // the revolutions a diesel-electric's engine aims at [1/s], by the controller and the heating; the fill shown by the smoke -double TMoverParameters::DieselElectricTargetRevolutions() +double physics::Vehicle::DieselElectricTargetRevolutions() { double tmp; @@ -351,7 +351,7 @@ double TMoverParameters::DieselElectricTargetRevolutions() return tmp; } -void TMoverParameters::DieselEngineTractionForce(double dt, double const dmoment, double const dtrans) +void physics::Vehicle::DieselEngineTractionForce(double dt, double const dmoment, double const dtrans) { Mw = dmoment * dtrans * Transmision.Efficiency; // dmoment i dtrans policzone przy okazji enginerotation if (retarder.present && retarder.placement == 0) @@ -362,7 +362,7 @@ void TMoverParameters::DieselEngineTractionForce(double dt, double const dmoment } // tmp: the revolutions the engine aims at [1/s], see UpdateEngineRevolutions() -void TMoverParameters::DieselElectricTractionForce(double tmp) +void physics::Vehicle::DieselElectricTractionForce(double tmp) { double PosRatio; // tmpV:=V*CabActive*DirActive; @@ -446,7 +446,7 @@ void TMoverParameters::DieselElectricTractionForce(double tmp) // the tractive force of a diesel-electric shunting, by the generator's table SST and the shunting controller AnPos; // tmp, the power the generator gives -void TMoverParameters::DieselElectricShuntForce(double const tmpV, double &tmp) +void physics::Vehicle::DieselElectricShuntForce(double const tmpV, double &tmp) { if (true == StLinFlag) { @@ -465,7 +465,7 @@ void TMoverParameters::DieselElectricShuntForce(double const tmpV, double &tmp) // the tractive force of a diesel-electric set by the integrated controller, at the speed tmpV; the generator's // voltage and current limits too. returns the power the generator gives -double TMoverParameters::DieselElectricDigitalForce(double const tmpV, double &tempUmax, double &tempImax) +double physics::Vehicle::DieselElectricDigitalForce(double const tmpV, double &tempUmax, double &tempImax) { auto eimic_positive = std::max(0.0, eimic_real); auto const rpmratio{EngineRPMRatio()}; @@ -481,7 +481,7 @@ double TMoverParameters::DieselElectricDigitalForce(double const tmpV, double &t // the tractive force of a diesel-electric at the speed tmpV: on the straight part of its characteristic under the speed // Vhyp gives at the power LinePower, at the share Ratio of it, on the hyperbola of the power HyperbolaPower over it -double TMoverParameters::DieselElectricForce(double const tmpV, double const LinePower, double const Ratio, double const HyperbolaPower) const +double physics::Vehicle::DieselElectricForce(double const tmpV, double const LinePower, double const Ratio, double const HyperbolaPower) const { if (tmpV < Vhyp * LinePower / DElist[MainCtrlPosNo].GenPower) { @@ -494,7 +494,7 @@ double TMoverParameters::DieselElectricForce(double const tmpV, double const Lin } // in the shunting mode, the generator's power limited to tmp, the power the engine gives -void TMoverParameters::DieselElectricShuntPower(double const tmp) +void physics::Vehicle::DieselElectricShuntPower(double const tmp) { EnginePower = EngineVoltage * Im / 1000.0; if (EnginePower > tmp) @@ -509,7 +509,7 @@ void TMoverParameters::DieselElectricShuntPower(double const tmp) } // the generator's current limited to tempImax and its voltage by its characteristic, under tempUmax and the power tmp -void TMoverParameters::DieselElectricGenerator(double const tmp, double const tempUmax, double const tempImax) +void physics::Vehicle::DieselElectricGenerator(double const tmp, double const tempUmax, double const tempImax) { if (abs(Im) > tempImax) { // nie ma nadmiarowego, tylko Imax i zwarcie na pradnicy @@ -555,7 +555,7 @@ void TMoverParameters::DieselElectricGenerator(double const tmp, double const te } // the current of a diesel-electric vehicle's traction motors giving the moment [N m] of one motor -double TMoverParameters::dieselelectric_motor_current(double const Moment) const +double physics::Vehicle::dieselelectric_motor_current(double const Moment) const { // with MotorParam[ScndCtrlPos] do if (abs(Moment) > motor_param(ScndCtrlPos).fi) @@ -565,7 +565,7 @@ double TMoverParameters::dieselelectric_motor_current(double const Moment) const } // the effort of a diesel-electric vehicle's dynamic brake the driver asks for, 0..1 -double TMoverParameters::dieselelectric_dynamic_brake_demand() const +double physics::Vehicle::dieselelectric_dynamic_brake_demand() const { switch (DEDynamicBrake.source) { @@ -582,7 +582,7 @@ double TMoverParameters::dieselelectric_dynamic_brake_demand() const // (the current), above the speed where the resistors' power takes over, the power; under EDBrakeV1 it fades, down to // nothing at EDBrakeV0. a brake of direct current motors, whose force grows with the speed (the voltage they generate // into the resistors), fades from 0 to the speed of its whole force; an inverter's only at the stop -double TMoverParameters::dieselelectric_dynamic_brake_limit() const +double physics::Vehicle::dieselelectric_dynamic_brake_limit() const { auto const &brake{DEDynamicBrake}; auto limit{brake.max_force}; @@ -605,7 +605,7 @@ double TMoverParameters::dieselelectric_dynamic_brake_limit() const // is the share of the most at the speed. the motors brake while the engine runs (it excites them, or keeps the // control of the inverters going), with the direction set, the overload relay closed, no power asked for and the // wheels rolling; otherwise there's no brake at once -void TMoverParameters::update_dieselelectric_dynamic_brake(double const dt) +void physics::Vehicle::update_dieselelectric_dynamic_brake(double const dt) { auto &brake{DEDynamicBrake}; auto const nopower{brake.source == diesel_electric_dynamic_brake::control::controller ? eimic_real <= 0.0 : IsMainCtrlNoPowerPos()}; @@ -630,7 +630,7 @@ void TMoverParameters::update_dieselelectric_dynamic_brake(double const dt) // work as generators into the resistors, the ammeter shows their current, the main generator gives nothing. near the // stop no more than what stops the vehicle within the step dt: with no fade (EDBrakeV0 = EDBrakeV1 = 0) the whole force // would turn round each time the speed crosses zero, and in FTrain it never lets the stop of ComputeMovement() catch it -void TMoverParameters::apply_dieselelectric_dynamic_brake(double const dt) +void physics::Vehicle::apply_dieselelectric_dynamic_brake(double const dt) { auto const force{dt > 0.0 ? std::min(DEDynamicBrake.force, TotalMass * std::abs(V) / dt) : DEDynamicBrake.force}; Ft = V > 0.0 ? -force : V < 0.0 ? force : 0.0; @@ -646,7 +646,7 @@ void TMoverParameters::apply_dieselelectric_dynamic_brake(double const dt) // Q: 20160715 // Zmienia parametr do którego dąży sprzęgło // ************************************************************************************************* -bool TMoverParameters::dizel_EngageSwitch(double state) +bool physics::Vehicle::dizel_EngageSwitch(double state) { if (EngineType == TEngineType::DieselEngine && state <= 1 && state >= 0 && state != diesel.clutchState) { @@ -661,7 +661,7 @@ bool TMoverParameters::dizel_EngageSwitch(double state) // Q: 20160715 // Zmienia parametr do którego dąży sprzęgło // ************************************************************************************************* -bool TMoverParameters::dizel_EngageChange(double dt) +bool physics::Vehicle::dizel_EngageChange(double dt) { double engagespeed = 0; // OK:boolean; bool DEC; @@ -695,7 +695,7 @@ bool TMoverParameters::dizel_EngageChange(double dt) // Q: 20160715 // Automatyczna zmiana biegów gdy prędkość przekroczy widełki // ************************************************************************************************* -bool TMoverParameters::dizel_AutoGearCheck(void) +bool physics::Vehicle::dizel_AutoGearCheck(void) { auto OK{false}; @@ -718,7 +718,7 @@ bool TMoverParameters::dizel_AutoGearCheck(void) } // the automatic gearbox: a gear up over VelUp, down under VelDown, changed once the clutch is out; returns whether it acted -bool TMoverParameters::dizel_GearShiftCheck(double const VelUp, double const VelDown) +bool physics::Vehicle::dizel_GearShiftCheck(double const VelUp, double const VelDown) { auto OK{false}; if (RList[MainCtrlPos].Mn == 0 && !torqueConverter.present) @@ -746,7 +746,7 @@ bool TMoverParameters::dizel_GearShiftCheck(double const VelUp, double const Vel } // a gear up asked over VelUp, down under VelDown, where the gearbox shifts by itself; returns whether one is -bool TMoverParameters::dizel_GearShiftRequest(double const VelUp, double const VelDown) +bool physics::Vehicle::dizel_GearShiftRequest(double const VelUp, double const VelDown) { auto OK{false}; if (motor_param(ScndCtrlActualPos).AutoSwitch && diesel.automaticGearShift == 0) // sprawdz czy zmienic biegi @@ -774,7 +774,7 @@ bool TMoverParameters::dizel_GearShiftRequest(double const VelUp, double const V } // the pressure in the clutch's cylinder, by the controller's position or the integrated controller -void TMoverParameters::dizel_ClutchCheck() +void physics::Vehicle::dizel_ClutchCheck() { if (EIMCtrlType > 0) // sterowanie komputerowe { @@ -791,7 +791,7 @@ void TMoverParameters::dizel_ClutchCheck() } // the clutch by the controller's position: half or fully in, fully over the speed of the full engagement -void TMoverParameters::dizel_ClutchByController() +void physics::Vehicle::dizel_ClutchByController() { switch (RList[MainCtrlPos].Mn) { @@ -828,7 +828,7 @@ void TMoverParameters::dizel_ClutchByController() } // the clutch of the integrated controller: in with the converter filled or the power asked, half in for the retarder -void TMoverParameters::dizel_ClutchByIntegratedController() +void physics::Vehicle::dizel_ClutchByIntegratedController() { if (diesel.automaticGearShift == 0) { @@ -844,7 +844,7 @@ void TMoverParameters::dizel_ClutchByIntegratedController() } // performs diesel engine startup procedure; potentially clears startup switch; returns: true if the engine can be started, false otherwise -bool TMoverParameters::dizel_StartupCheck() +bool physics::Vehicle::dizel_StartupCheck() { auto engineisready{true}; // make inital optimistic presumption, then watch the reality crush it @@ -884,7 +884,7 @@ bool TMoverParameters::dizel_StartupCheck() // Q: 20160715 // Aktualizacja stanu silnika // ************************************************************************************************* -bool TMoverParameters::dizel_Update(double dt) +bool physics::Vehicle::dizel_Update(double dt) { WaterPumpCheck(dt); @@ -944,7 +944,7 @@ bool TMoverParameters::dizel_Update(double dt) // Q: 20160715 // oblicza napelnienie, uzwglednia regulator obrotow // ************************************************************************************************* -double TMoverParameters::dizel_fillcheck(int mcp, double dt) +double physics::Vehicle::dizel_fillcheck(int mcp, double dt) { auto realfill{0.0}; @@ -981,7 +981,7 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt) } // the fill set by the integrated controller, and the idle and top revolutions the governor keeps to -double TMoverParameters::dizel_DigitalFill(double dt) +double physics::Vehicle::dizel_DigitalFill(double dt) { double realfill; realfill = std::max(0.0, std::min(eimic_real, 1 - motor_param(ScndCtrlActualPos).Isat)); @@ -1008,7 +1008,7 @@ double TMoverParameters::dizel_DigitalFill(double dt) } // the fill cut off over the revolutions the governor allows at the controller's position, or full under the idle ones -double TMoverParameters::dizel_GovernorFill(int const mcp, double realfill) const +double physics::Vehicle::dizel_GovernorFill(int const mcp, double realfill) const { auto nreg{0.0}; if (EIMCtrlType > 0) @@ -1024,7 +1024,7 @@ double TMoverParameters::dizel_GovernorFill(int const mcp, double realfill) cons // the revolutions the governor allows at the controller's position, the gearbox and the speed; the fill cut off at // a position the governor doesn't know -double TMoverParameters::dizel_GovernorRevolutions(int const mcp, double &realfill) const +double physics::Vehicle::dizel_GovernorRevolutions(int const mcp, double &realfill) const { auto nreg{0.0}; switch (RList[MainCtrlPos].Mn) @@ -1068,7 +1068,7 @@ double TMoverParameters::dizel_GovernorRevolutions(int const mcp, double &realfi // Q: 20160715 // Oblicza moment siły wytwarzany przez silnik spalinowy // ************************************************************************************************* -double TMoverParameters::dizel_Momentum(double Fill, double n, double dt) +double physics::Vehicle::dizel_Momentum(double Fill, double n, double dt) { // liczy moment sily wytwarzany przez silnik spalinowy} double Moment = 0; double enMoment = 0; @@ -1197,7 +1197,7 @@ double TMoverParameters::dizel_Momentum(double Fill, double n, double dt) } // the torque converter filled and emptied, and its lockup clutch engaged and released, by the power and the speed -void TMoverParameters::hydro_TCFillCheck(double dt) +void physics::Vehicle::hydro_TCFillCheck(double dt) { if (torqueConverter.present) // jesli przetwornik momentu { @@ -1234,7 +1234,7 @@ void TMoverParameters::hydro_TCFillCheck(double dt) } // the torque converter's moments on its input and output shafts, by their revolutions and its fill -void TMoverParameters::hydro_TCTorque() +void physics::Vehicle::hydro_TCTorque() { double HydroTorque = 0; HydroTorque += torqueConverter.revolutionsIn * torqueConverter.revolutionsIn * torqueConverter.torqueInIn; @@ -1264,7 +1264,7 @@ void TMoverParameters::hydro_TCTorque() } } -double TMoverParameters::dizel_MomentumRetarder(double n, double dt) +double physics::Vehicle::dizel_MomentumRetarder(double n, double dt) { double RetarderRequest = Mains ? std::max(0.0, -eimic_real) : 0; if (retarder.withIndividual) @@ -1312,7 +1312,7 @@ double TMoverParameters::dizel_MomentumRetarder(double n, double dt) } // sets component temperatures to specified value -void TMoverParameters::dizel_HeatSet(float const Value) +void physics::Vehicle::dizel_HeatSet(float const Value) { // TODO: don't include ambient temperature, pull it from environment data instead @@ -1330,7 +1330,7 @@ void TMoverParameters::dizel_HeatSet(float const Value) // calculates diesel engine temperature and heat transfers // adapted from scripts written by adamst // NOTE: originally executed twice per second -void TMoverParameters::dizel_Heat(double const dt) +void physics::Vehicle::dizel_Heat(double const dt) { auto const qs{44700.0}; diff --git a/physics/components/doors.cpp b/physics/components/doors.cpp index 216279bef..2e90c2a88 100644 --- a/physics/components/doors.cpp +++ b/physics/components/doors.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the doors and the exchange of the load #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -30,7 +30,7 @@ http://mozilla.org/MPL/2.0/. #include "physics/components/internal.h" -bool TMoverParameters::AssignLoad(std::string const &Loadname, float const Amount) +bool physics::Vehicle::AssignLoad(std::string const &Loadname, float const Amount) { if (Loadname == "pantstate") @@ -104,7 +104,7 @@ bool TMoverParameters::AssignLoad(std::string const &Loadname, float const Amoun // Q: 20160713 // Test zakończenia załadunku / rozładunku // ************************************************************************************************* -bool TMoverParameters::LoadingDone(double const LSpeed, std::string_view Loadname) +bool physics::Vehicle::LoadingDone(double const LSpeed, std::string_view Loadname) { if (LSpeed == 0.0) @@ -170,7 +170,7 @@ bool TMoverParameters::LoadingDone(double const LSpeed, std::string_view Loadnam return LoadStatus >= 4; } -bool TMoverParameters::ChangeDoorPermitPreset(int const Change, range_t const Notify) +bool physics::Vehicle::ChangeDoorPermitPreset(int const Change, range_t const Notify) { auto const initialstate{Doors.permit_preset}; @@ -190,7 +190,7 @@ bool TMoverParameters::ChangeDoorPermitPreset(int const Change, range_t const No return Doors.permit_preset != initialstate; } -bool TMoverParameters::PermitDoorStep(bool const State, range_t const Notify) +bool physics::Vehicle::PermitDoorStep(bool const State, range_t const Notify) { auto const initialstate{Doors.step_enabled}; @@ -205,7 +205,7 @@ bool TMoverParameters::PermitDoorStep(bool const State, range_t const Notify) return Doors.step_enabled != initialstate; } -bool TMoverParameters::PermitDoors(VehicleSide const Door, bool const State, range_t const Notify) +bool physics::Vehicle::PermitDoors(VehicleSide const Door, bool const State, range_t const Notify) { bool const initialstate{Doors.instances[Door].open_permit}; @@ -226,7 +226,7 @@ bool TMoverParameters::PermitDoors(VehicleSide const Door, bool const State, ran return Doors.instances[Door].open_permit != initialstate; } -void TMoverParameters::PermitDoors_(VehicleSide const Door, bool const State) +void physics::Vehicle::PermitDoors_(VehicleSide const Door, bool const State) { if (State && State != Doors.instances[Door].open_permit) @@ -236,7 +236,7 @@ void TMoverParameters::PermitDoors_(VehicleSide const Door, bool const State) Doors.instances[Door].open_permit = State; } -bool TMoverParameters::ChangeDoorControlMode(bool const State, range_t const Notify) +bool physics::Vehicle::ChangeDoorControlMode(bool const State, range_t const Notify) { auto const initialstate{Doors.remote_only}; @@ -259,7 +259,7 @@ bool TMoverParameters::ChangeDoorControlMode(bool const State, range_t const Not return Doors.remote_only != initialstate; } -bool TMoverParameters::OperateDoors(VehicleSide const Door, bool const State, range_t const Notify) +bool physics::Vehicle::OperateDoors(VehicleSide const Door, bool const State, range_t const Notify) { auto &door{Doors.instances[Door]}; @@ -303,7 +303,7 @@ bool TMoverParameters::OperateDoors(VehicleSide const Door, bool const State, ra } // toggle door lock -bool TMoverParameters::LockDoors(bool const State, range_t const Notify) +bool physics::Vehicle::LockDoors(bool const State, range_t const Notify) { auto const initialstate{Doors.lock_enabled}; @@ -319,7 +319,7 @@ bool TMoverParameters::LockDoors(bool const State, range_t const Notify) } // toggles departure warning -bool TMoverParameters::signal_departure(bool const State, range_t const Notify) +bool physics::Vehicle::signal_departure(bool const State, range_t const Notify) { if (DepartureSignal == State) @@ -341,7 +341,7 @@ bool TMoverParameters::signal_departure(bool const State, range_t const Notify) // state of the door closure signalling (SOD) of this vehicle: open while a door isn't fully closed, released while // the closed doors can be opened (a permit given, or, for doors that need none, no lock engaged), locked otherwise. // doors the crew doesn't close (autonomous) aren't signalled, the same as for the door lights of the consist -door_closure_t TMoverParameters::door_closure() const +door_closure_t physics::Vehicle::door_closure() const { if (Doors.range == 0.f || Doors.close_control == control_t::autonomous) { @@ -362,7 +362,7 @@ door_closure_t TMoverParameters::door_closure() const return door_closure_t::released; } -bool TMoverParameters::door_closure_lamp_lit(door_closure_t const Consist, bool const BlinkLit) const +bool physics::Vehicle::door_closure_lamp_lit(door_closure_t const Consist, bool const BlinkLit) const { return Doors.closure_signal ? door_closure_lamp(Consist, BlinkLit) : Doors.is_locked; } @@ -381,7 +381,7 @@ bool door_closure_lamp(door_closure_t const State, bool const BlinkLit) } // automatic door controller update -void TMoverParameters::update_doors(double const Deltatime) +void physics::Vehicle::update_doors(double const Deltatime) { if (Doors.range == 0.f) @@ -429,7 +429,7 @@ void TMoverParameters::update_doors(double const Deltatime) } // the permit, the state and the requests of a door, and whether it and its step open or close -void TMoverParameters::update_door_requests(basic_door &door, bool const localopencontrol, bool const remoteopencontrol, bool const localclosecontrol, bool const remoteclosecontrol) +void physics::Vehicle::update_door_requests(basic_door &door, bool const localopencontrol, bool const remoteopencontrol, bool const localclosecontrol, bool const remoteclosecontrol) { // revoke permit if... door.open_permit = true == door.open_permit // ...we already have one... @@ -462,7 +462,7 @@ void TMoverParameters::update_door_requests(basic_door &door, bool const localop } // whether the door is asked to open, by the passengers, from afar or by itself -bool TMoverParameters::door_open_request(basic_door const &door, bool const localopencontrol, bool const remoteopencontrol) const +bool physics::Vehicle::door_open_request(basic_door const &door, bool const localopencontrol, bool const remoteopencontrol) const { auto const autoopenrequest{Doors.open_control == control_t::autonomous && (false == Doors.permit_needed || door.open_permit)}; return (localopencontrol && door.local_open) || (remoteopencontrol && door.remote_open) || (autoopenrequest && false == door.is_open); @@ -470,7 +470,7 @@ bool TMoverParameters::door_open_request(basic_door const &door, bool const loca // whether the door is asked to close, by the passengers, from afar, or by itself: over the speed, after its time or // with its permit taken back -bool TMoverParameters::door_close_request(basic_door const &door, bool const localclosecontrol, bool const remoteclosecontrol) const +bool physics::Vehicle::door_close_request(basic_door const &door, bool const localclosecontrol, bool const remoteclosecontrol) const { auto const autocloserequest{(Doors.auto_velocity != -1.f && Vel > Doors.auto_velocity) || (door.auto_timer != -1.f && door.auto_timer <= 0.f) || (Doors.permit_needed && false == door.open_permit)}; @@ -478,7 +478,7 @@ bool TMoverParameters::door_close_request(basic_door const &door, bool const loc } // whether the doors have the voltage they work on -bool TMoverParameters::doors_powered() const +bool physics::Vehicle::doors_powered() const { if (Doors.voltage == 0) { @@ -493,7 +493,7 @@ bool TMoverParameters::doors_powered() const // whether the unfolded step folds: without the permission to stay out, or with the door closing, once it's about to // close or closed -bool TMoverParameters::door_step_folding(basic_door const &door) const +bool physics::Vehicle::door_step_folding(basic_door const &door) const { auto const unfolded{door.step_position > 0.f}; auto const mayfold{false == Doors.step_enabled || (Doors.permit_needed ? false == door.open_permit : door.is_closing)}; @@ -502,7 +502,7 @@ bool TMoverParameters::door_step_folding(basic_door const &door) const // how long the opening door stays open: the time of the doors, for the passengers' opening and, if it counts, the // opening from afar; none otherwise -float TMoverParameters::door_open_duration(basic_door const &door, bool const localopencontrol, bool const remoteopencontrol) const +float physics::Vehicle::door_open_duration(basic_door const &door, bool const localopencontrol, bool const remoteopencontrol) const { if (localopencontrol && door.local_open) { @@ -516,7 +516,7 @@ float TMoverParameters::door_open_duration(basic_door const &door, bool const lo } // a door and its step moved as they open or close -void TMoverParameters::move_door(basic_door &door, double const Deltatime) +void physics::Vehicle::move_door(basic_door &door, double const Deltatime) { // doors if (true == door.is_opening) @@ -568,7 +568,7 @@ void TMoverParameters::move_door(basic_door &door, double const Deltatime) } // the timers of the open doors which close after a while, kept running while the load is exchanged -void TMoverParameters::update_door_timers(double const Deltatime) +void physics::Vehicle::update_door_timers(double const Deltatime) { // update door timers if the door close after defined time for (auto &door : Doors.instances) diff --git a/physics/components/drive.cpp b/physics/components/drive.cpp index 2b24c0d6e..537bba01d 100644 --- a/physics/components/drive.cpp +++ b/physics/components/drive.cpp @@ -16,88 +16,88 @@ http://mozilla.org/MPL/2.0/. #include #include -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/utilities.h" // the defaults: a drive with no engine model and no engine of revolutions does nothing in the steps -double TractionDrive::UpdateEnginePower(TMoverParameters & /*vehicle*/) const +double TractionDrive::UpdateEnginePower(physics::Vehicle & /*vehicle*/) const { return 0.0; } -void TractionDrive::BeforeTractionForce(TMoverParameters & /*vehicle*/, double /*dt*/) const +void TractionDrive::BeforeTractionForce(physics::Vehicle & /*vehicle*/, double /*dt*/) const { // nothing before the force } -void TractionDrive::UpdateTractionForce(TMoverParameters & /*vehicle*/, DriveStep const & /*step*/) const +void TractionDrive::UpdateTractionForce(physics::Vehicle & /*vehicle*/, DriveStep const & /*step*/) const { // no force } -void TractionDrive::AfterTractionForce(TMoverParameters & /*vehicle*/) const +void TractionDrive::AfterTractionForce(physics::Vehicle & /*vehicle*/) const { // nothing after the force } -void TractionDrive::UpdateVentilators(TMoverParameters & /*vehicle*/, double /*dt*/) const +void TractionDrive::UpdateVentilators(physics::Vehicle & /*vehicle*/, double /*dt*/) const { // no ventilators } -double TractionDrive::ShowCurrent(TMoverParameters const &vehicle, int const ammeter) const +double TractionDrive::ShowCurrent(physics::Vehicle const &vehicle, int const ammeter) const { return vehicle.ShowCurrentP(ammeter); } -double TractionDrive::EngineRpmRatio(TMoverParameters const & /*vehicle*/) const +double TractionDrive::EngineRpmRatio(physics::Vehicle const & /*vehicle*/) const { return 1.0; } -double TractionDrive::EngineIdleRpm(TMoverParameters const & /*vehicle*/) const +double TractionDrive::EngineIdleRpm(physics::Vehicle const & /*vehicle*/) const { return std::numeric_limits::max(); } -double TractionDrive::EngineMaxRpm(TMoverParameters const & /*vehicle*/) const +double TractionDrive::EngineMaxRpm(physics::Vehicle const & /*vehicle*/) const { return std::numeric_limits::max(); } -double TractionDrive::UpdateEngineRevolutions(TMoverParameters &vehicle, double /*dt*/, double & /*transmission*/, double & /*moment*/) const +double TractionDrive::UpdateEngineRevolutions(physics::Vehicle &vehicle, double /*dt*/, double & /*transmission*/, double & /*moment*/) const { vehicle.enrot = vehicle.Transmision.Ratio * vehicle.nrot; return 0.0; } -bool TractionDrive::IncreaseMainController(TMoverParameters & /*vehicle*/, int /*speed*/) const +bool TractionDrive::IncreaseMainController(physics::Vehicle & /*vehicle*/, int /*speed*/) const { return false; } -bool TractionDrive::DecreaseMainController(TMoverParameters & /*vehicle*/, int /*speed*/) const +bool TractionDrive::DecreaseMainController(physics::Vehicle & /*vehicle*/, int /*speed*/) const { return false; } -bool TractionDrive::MainsPowerAvailable(TMoverParameters const & /*vehicle*/) const +bool TractionDrive::MainsPowerAvailable(physics::Vehicle const & /*vehicle*/) const { return true; } -void TractionDrive::CheckVoltageRelays(TMoverParameters & /*vehicle*/) const +void TractionDrive::CheckVoltageRelays(physics::Vehicle & /*vehicle*/) const { // no voltage relays } -bool TractionDrive::UpdateEngine(TMoverParameters & /*vehicle*/, double /*dt*/) const +bool TractionDrive::UpdateEngine(physics::Vehicle & /*vehicle*/, double /*dt*/) const { return false; } -void TractionDrive::UpdateEngineVoltage(TMoverParameters &vehicle, double /*dt*/) const +void TractionDrive::UpdateEngineVoltage(physics::Vehicle &vehicle, double /*dt*/) const { vehicle.EngineVoltage = vehicle.Power > 1.0 ? vehicle.TractionSupplyVoltage() : 0.0; } @@ -106,7 +106,7 @@ namespace { // the radiator fans of a diesel engine follow their demanded revolutions while the engine runs, and run down without it -void updateRadiatorFans(TMoverParameters &vehicle, double const dt) +void updateRadiatorFans(physics::Vehicle &vehicle, double const dt) { auto &heat{vehicle.diesel.heat}; if (true == vehicle.Mains) @@ -123,14 +123,14 @@ void updateRadiatorFans(TMoverParameters &vehicle, double const dt) // the line breaker of the drives fed from the line: closed ahead of the pantographs it runs on the low voltage circuits, // else it needs the voltage of the source -bool linePowerAvailable(TMoverParameters const &vehicle) +bool linePowerAvailable(physics::Vehicle const &vehicle) { return vehicle.PantographsRequireMains ? vehicle.Power24vIsAvailable || vehicle.Power110vIsAvailable : vehicle.EnginePowerSourceVoltage() > 0.5 * vehicle.EnginePowerSource.MaxVoltage; } // a notch of the master controller of the drives without steps of their own (no engine, Dumb, diesel-electric, // induction): one position at a time, the speed control let go when the position leaves the one it holds -bool increaseNotch(TMoverParameters &vehicle, int const speed) +bool increaseNotch(physics::Vehicle &vehicle, int const speed) { if (speed > 1) { @@ -145,7 +145,7 @@ bool increaseNotch(TMoverParameters &vehicle, int const speed) return true; } -bool decreaseNotch(TMoverParameters &vehicle, int const speed) +bool decreaseNotch(physics::Vehicle &vehicle, int const speed) { if (speed == 1) { @@ -168,11 +168,11 @@ bool decreaseNotch(TMoverParameters &vehicle, int const speed) class NoEngineDrive final : public TractionDrive { public: - bool IncreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool IncreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return increaseNotch(vehicle, speed); } - bool DecreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool DecreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return decreaseNotch(vehicle, speed); } @@ -187,25 +187,25 @@ class UnmodelledDrive final : public TractionDrive class DumbDrive final : public TractionDrive { public: - double UpdateEnginePower(TMoverParameters &vehicle) const override + double UpdateEnginePower(physics::Vehicle &vehicle) const override { auto const posRatio{(vehicle.MainCtrlPos + vehicle.ScndCtrlPos) / (vehicle.MainCtrlPosNo + vehicle.ScndCtrlPosNo + 0.01)}; vehicle.EnginePower = /*1000.0 **/ vehicle.Power * posRatio; return posRatio; } - void UpdateTractionForce(TMoverParameters &vehicle, DriveStep const &step) const override + void UpdateTractionForce(physics::Vehicle &vehicle, DriveStep const &step) const override { vehicle.DumbTractionForce(step.posRatio); } - bool MainsPowerAvailable(TMoverParameters const &vehicle) const override + bool MainsPowerAvailable(physics::Vehicle const &vehicle) const override { return vehicle.Power24vIsAvailable; } - bool IncreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool IncreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return increaseNotch(vehicle, speed); } - bool DecreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool DecreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return decreaseNotch(vehicle, speed); } @@ -215,11 +215,11 @@ public: class WheelsDrivenDrive final : public TractionDrive { public: - void UpdateTractionForce(TMoverParameters &vehicle, DriveStep const &step) const override + void UpdateTractionForce(physics::Vehicle &vehicle, DriveStep const &step) const override { vehicle.WheelsDrivenTractionForce(step.dt); } - bool IncreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool IncreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return vehicle.AddPulseForce(speed); } @@ -229,19 +229,19 @@ public: class SeriesMotorDrive final : public TractionDrive { public: - void UpdateTractionForce(TMoverParameters &vehicle, DriveStep const &step) const override + void UpdateTractionForce(physics::Vehicle &vehicle, DriveStep const &step) const override { vehicle.SeriesMotorTractionForce(step.dt); } - bool IncreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool IncreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return vehicle.IncMainCtrlSeriesMotor(speed); } - bool DecreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool DecreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return vehicle.DecMainCtrlSeriesMotor(speed); } - void UpdateVentilators(TMoverParameters &vehicle, double const dt) const override + void UpdateVentilators(physics::Vehicle &vehicle, double const dt) const override { if (vehicle.MainCircuitPowered()) { @@ -252,11 +252,11 @@ public: vehicle.RventRot *= std::max(0.0, 1.0 - vehicle.RVentSpeed * dt); } } - bool MainsPowerAvailable(TMoverParameters const &vehicle) const override + bool MainsPowerAvailable(physics::Vehicle const &vehicle) const override { return linePowerAvailable(vehicle); } - void CheckVoltageRelays(TMoverParameters &vehicle) const override + void CheckVoltageRelays(physics::Vehicle &vehicle) const override { // update the state of voltage relays auto const voltage{std::max(vehicle.GetTrainsetHighVoltage(), vehicle.PantographVoltage)}; @@ -274,12 +274,12 @@ public: vehicle.EventFlag |= true == vehicle.Mains && ((false == vehicle.NoVoltRelay && false == vehicle.PantographsRequireMains) || false == vehicle.OvervoltageRelay) && vehicle.MainSwitch(false, vehicle.TrainType == train_type::emu ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide } - bool UpdateEngine(TMoverParameters &vehicle, double /*dt*/) const override + bool UpdateEngine(physics::Vehicle &vehicle, double /*dt*/) const override { // automatyczny rozruch return vehicle.AutoRelayCheck(); } - void UpdateEngineVoltage(TMoverParameters &vehicle, double const dt) const override + void UpdateEngineVoltage(physics::Vehicle &vehicle, double const dt) const override { vehicle.LastRelayTime += dt; // potem ulepszyc! pantogtrafy! @@ -300,19 +300,19 @@ public: class InductionMotorDrive final : public TractionDrive { public: - void UpdateTractionForce(TMoverParameters &vehicle, DriveStep const &step) const override + void UpdateTractionForce(physics::Vehicle &vehicle, DriveStep const &step) const override { vehicle.InductionMotorTractionForce(step.dt); } - bool IncreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool IncreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return increaseNotch(vehicle, speed); } - bool DecreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool DecreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return decreaseNotch(vehicle, speed); } - double ShowCurrent(TMoverParameters const &vehicle, int const ammeter) const override + double ShowCurrent(physics::Vehicle const &vehicle, int const ammeter) const override { switch (ammeter) { // do asynchronicznych @@ -324,11 +324,11 @@ public: return vehicle.ShowCurrentP(ammeter); } } - bool MainsPowerAvailable(TMoverParameters const &vehicle) const override + bool MainsPowerAvailable(physics::Vehicle const &vehicle) const override { return linePowerAvailable(vehicle); } - void CheckVoltageRelays(TMoverParameters &vehicle) const override + void CheckVoltageRelays(physics::Vehicle &vehicle) const override { // TODO: check if we can use instead the code for electricseriesmotor // nie wchodzić w funkcję bez potrzeby @@ -346,7 +346,7 @@ public: class DieselMechanicalDrive final : public TractionDrive { public: - double UpdateEnginePower(TMoverParameters &vehicle) const override + double UpdateEnginePower(physics::Vehicle &vehicle) const override { vehicle.diesel.power = vehicle.Mm * vehicle.enrot * (2.0 * M_PI / 1000.0); vehicle.EnginePower = (vehicle.diesel.standingMoment + vehicle.Mm) * vehicle.enrot * (2.0 * M_PI / 1000.0); @@ -357,11 +357,11 @@ public: } return 0.0; } - void UpdateTractionForce(TMoverParameters &vehicle, DriveStep const &step) const override + void UpdateTractionForce(physics::Vehicle &vehicle, DriveStep const &step) const override { vehicle.DieselEngineTractionForce(step.dt, step.moment, step.transmission); } - double UpdateEngineRevolutions(TMoverParameters &vehicle, double const dt, double &transmission, double &moment) const override + double UpdateEngineRevolutions(physics::Vehicle &vehicle, double const dt, double &transmission, double &moment) const override { if (vehicle.ShuntMode) // dodatkowa przekładnia np. dla 2Ls150 transmission = vehicle.AnPos * vehicle.Transmision.Ratio * vehicle.motor_param(vehicle.ScndCtrlActualPos).mIsat; @@ -371,7 +371,7 @@ public: moment = vehicle.dizel_Momentum(vehicle.diesel.fill, transmission * vehicle.nrot * vehicle.DirActive, dt); // oblicza tez enrot return 0.0; } - bool IncreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool IncreaseMainController(physics::Vehicle &vehicle, int const speed) const override { if (speed > 1) { @@ -387,7 +387,7 @@ public: vehicle.CompressorAllow = vehicle.MainCtrlPowerPos() > 0; return true; } - bool DecreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool DecreaseMainController(physics::Vehicle &vehicle, int const speed) const override { if (speed == 1) { @@ -402,28 +402,28 @@ public: } return false; } - void UpdateVentilators(TMoverParameters &vehicle, double const dt) const override + void UpdateVentilators(physics::Vehicle &vehicle, double const dt) const override { // NOTE: we update only radiator fans, as vehicles with diesel engine don't have other ventilators updateRadiatorFans(vehicle, dt); } - double EngineRpmRatio(TMoverParameters const &vehicle) const override + double EngineRpmRatio(physics::Vehicle const &vehicle) const override { return std::clamp(std::abs(vehicle.enrot) / vehicle.nmax, 0.0, 1.0); } - double EngineIdleRpm(TMoverParameters const &vehicle) const override + double EngineIdleRpm(physics::Vehicle const &vehicle) const override { return vehicle.diesel.minRevolutions * 60; } - double EngineMaxRpm(TMoverParameters const &vehicle) const override + double EngineMaxRpm(physics::Vehicle const &vehicle) const override { return vehicle.diesel.maxRevolutions * 60; } - bool MainsPowerAvailable(TMoverParameters const &vehicle) const override + bool MainsPowerAvailable(physics::Vehicle const &vehicle) const override { return vehicle.Power24vIsAvailable; } - bool UpdateEngine(TMoverParameters &vehicle, double const dt) const override + bool UpdateEngine(physics::Vehicle &vehicle, double const dt) const override { return vehicle.dizel_Update(dt); } @@ -433,19 +433,19 @@ public: class DieselElectricDrive final : public TractionDrive { public: - double UpdateEnginePower(TMoverParameters &vehicle) const override + double UpdateEnginePower(physics::Vehicle &vehicle) const override { vehicle.EnginePower = 0; // the actual calculation is done in two steps later in the method return 0.0; } - void BeforeTractionForce(TMoverParameters &vehicle, double const dt) const override + void BeforeTractionForce(physics::Vehicle &vehicle, double const dt) const override { - if (vehicle.DEDynamicBrake.source != TMoverParameters::diesel_electric_dynamic_brake::control::none) + if (vehicle.DEDynamicBrake.source != physics::Vehicle::diesel_electric_dynamic_brake::control::none) { vehicle.update_dieselelectric_dynamic_brake(dt); } } - void UpdateTractionForce(TMoverParameters &vehicle, DriveStep const &step) const override + void UpdateTractionForce(physics::Vehicle &vehicle, DriveStep const &step) const override { vehicle.DieselElectricTractionForce(step.revolutions); if (vehicle.DEDynamicBrake.level > 0.0) @@ -454,7 +454,7 @@ public: vehicle.apply_dieselelectric_dynamic_brake(step.dt); } } - double UpdateEngineRevolutions(TMoverParameters &vehicle, double const dt, double & /*transmission*/, double & /*moment*/) const override + double UpdateEngineRevolutions(physics::Vehicle &vehicle, double const dt, double & /*transmission*/, double & /*moment*/) const override { double target{0.0}; if (true == vehicle.Mains && true == vehicle.FuelPump.is_active) @@ -478,20 +478,20 @@ public: } return target; } - bool IncreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool IncreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return increaseNotch(vehicle, speed); } - bool DecreaseMainController(TMoverParameters &vehicle, int const speed) const override + bool DecreaseMainController(physics::Vehicle &vehicle, int const speed) const override { return decreaseNotch(vehicle, speed); } - void AfterTractionForce(TMoverParameters &vehicle) const override + void AfterTractionForce(physics::Vehicle &vehicle) const override { // rough approximation of extra effort to overcome friction etc vehicle.EnginePower += EngineRpmRatio(vehicle) * 0.15 * vehicle.DElist[vehicle.MainCtrlPosNo].GenPower; } - void UpdateVentilators(TMoverParameters &vehicle, double const dt) const override + void UpdateVentilators(physics::Vehicle &vehicle, double const dt) const override { // NOTE: for this type RventRot is the speed of motor blowers; we also update radiator fans while at it if (true == vehicle.Mains) @@ -505,34 +505,34 @@ public: } updateRadiatorFans(vehicle, dt); } - double ShowCurrent(TMoverParameters const &vehicle, int const /*ammeter*/) const override + double ShowCurrent(physics::Vehicle const &vehicle, int const /*ammeter*/) const override { return std::fabs(vehicle.Im); } - double EngineRpmRatio(TMoverParameters const &vehicle) const override + double EngineRpmRatio(physics::Vehicle const &vehicle) const override { return std::clamp(60.0 * std::abs(vehicle.enrot) / vehicle.DElist[vehicle.MainCtrlPosNo].RPM, 0.0, 1.0); } - double EngineIdleRpm(TMoverParameters const &vehicle) const override + double EngineIdleRpm(physics::Vehicle const &vehicle) const override { return vehicle.DElist[vehicle.MainCtrlNoPowerPos()].RPM; } - double EngineMaxRpm(TMoverParameters const &vehicle) const override + double EngineMaxRpm(physics::Vehicle const &vehicle) const override { return vehicle.DElist[vehicle.MainCtrlPosNo].RPM; } - bool MainsPowerAvailable(TMoverParameters const &vehicle) const override + bool MainsPowerAvailable(physics::Vehicle const &vehicle) const override { return vehicle.Power24vIsAvailable; } - void CheckVoltageRelays(TMoverParameters &vehicle) const override + void CheckVoltageRelays(physics::Vehicle &vehicle) const override { // TODO: move this to the auto relay check when the electric engine code paths are unified vehicle.StLinFlag |= vehicle.Mains && false == vehicle.StLinFlag && vehicle.MainCtrlPowerPos() == 1; vehicle.StLinFlag &= vehicle.MotorConnectorsCheck(); vehicle.StLinFlag &= vehicle.MainCtrlPowerPos() > 0; } - bool UpdateEngine(TMoverParameters &vehicle, double const dt) const override + bool UpdateEngine(physics::Vehicle &vehicle, double const dt) const override { return vehicle.dizel_Update(dt); } diff --git a/physics/components/drive.h b/physics/components/drive.h index b9f715b78..ac8dc9c70 100644 --- a/physics/components/drive.h +++ b/physics/components/drive.h @@ -9,13 +9,13 @@ http://mozilla.org/MPL/2.0/. // the drive of a vehicle, by the kind of its engine (EngineType, the Engine section of the .fiz): what each kind of // drive does in the step of the vehicle, in place of a switch on the engine type in each of those places. the drives -// hold no state of their own yet (it is in TMoverParameters): there is one of each kind, shared by the vehicles +// hold no state of their own yet (it is in physics::Vehicle): there is one of each kind, shared by the vehicles #pragma once #include "physics/vehicletypes.h" -class TMoverParameters; +namespace physics { class Vehicle; } // what the step of the traction gives the drive struct DriveStep @@ -33,38 +33,38 @@ public: virtual ~TractionDrive() = default; // the power of the engine for the controller positions; returns the share of the positions (Dumb), 0 for the others - virtual double UpdateEnginePower(TMoverParameters &vehicle) const; + virtual double UpdateEnginePower(physics::Vehicle &vehicle) const; // before the traction force, whether the reverser is set or not - virtual void BeforeTractionForce(TMoverParameters &vehicle, double dt) const; + virtual void BeforeTractionForce(physics::Vehicle &vehicle, double dt) const; // the traction force of the step (Ft), the reverser set - virtual void UpdateTractionForce(TMoverParameters &vehicle, DriveStep const &step) const; + virtual void UpdateTractionForce(physics::Vehicle &vehicle, DriveStep const &step) const; // after the traction force, whether the reverser is set or not - virtual void AfterTractionForce(TMoverParameters &vehicle) const; + virtual void AfterTractionForce(physics::Vehicle &vehicle) const; // the blowers of the starting resistors and the fans of the radiators - virtual void UpdateVentilators(TMoverParameters &vehicle, double dt) const; + virtual void UpdateVentilators(physics::Vehicle &vehicle, double dt) const; // the current the given ammeter of the cab shows - virtual double ShowCurrent(TMoverParameters const &vehicle, int ammeter) const; + virtual double ShowCurrent(physics::Vehicle const &vehicle, int ammeter) const; // the revolutions of the engine against the most it gives at the present controller position, 0..1; 1 with no // engine of revolutions - virtual double EngineRpmRatio(TMoverParameters const &vehicle) const; + virtual double EngineRpmRatio(physics::Vehicle const &vehicle) const; // the revolutions of the engine idling and at most [rpm]; the largest double with no engine of revolutions - virtual double EngineIdleRpm(TMoverParameters const &vehicle) const; - virtual double EngineMaxRpm(TMoverParameters const &vehicle) const; + virtual double EngineIdleRpm(physics::Vehicle const &vehicle) const; + virtual double EngineMaxRpm(physics::Vehicle const &vehicle) const; // the revolutions of the engine in the step (enrot); returns the revolutions a diesel-electric engine aims for, 0 for // the others. a diesel engine with a mechanical transmission gives its ratio and its moment through the references - virtual double UpdateEngineRevolutions(TMoverParameters &vehicle, double dt, double &transmission, double &moment) const; + virtual double UpdateEngineRevolutions(physics::Vehicle &vehicle, double dt, double &transmission, double &moment) const; // a notch up and down of the master controller, as the kind of the engine takes it; return whether it moved - virtual bool IncreaseMainController(TMoverParameters &vehicle, int speed) const; - virtual bool DecreaseMainController(TMoverParameters &vehicle, int speed) const; + virtual bool IncreaseMainController(physics::Vehicle &vehicle, int speed) const; + virtual bool DecreaseMainController(physics::Vehicle &vehicle, int speed) const; // whether the line breaker has the power it needs to close, before the genset of a dual-mode vehicle has its say - virtual bool MainsPowerAvailable(TMoverParameters const &vehicle) const; + virtual bool MainsPowerAvailable(physics::Vehicle const &vehicle) const; // the relays that open the line breaker at a voltage out of range, or the line contactors - virtual void CheckVoltageRelays(TMoverParameters &vehicle) const; + virtual void CheckVoltageRelays(physics::Vehicle &vehicle) const; // the engine in the step of the vehicle: the automatic start of the series motors, the diesel engine; returns // whether a relay clicked - virtual bool UpdateEngine(TMoverParameters &vehicle, double dt) const; + virtual bool UpdateEngine(physics::Vehicle &vehicle, double dt) const; // the voltage of the traction motors in the step (EngineVoltage) - virtual void UpdateEngineVoltage(TMoverParameters &vehicle, double dt) const; + virtual void UpdateEngineVoltage(physics::Vehicle &vehicle, double dt) const; }; // the drive of the given kind of engine diff --git a/physics/components/electrics.cpp b/physics/components/electrics.cpp index 7cdb75bd1..ebab2cbf0 100644 --- a/physics/components/electrics.cpp +++ b/physics/components/electrics.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the power supply: the batteries, the main switch, the pantographs, the converter, heating, lights, the genset #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -32,7 +32,7 @@ http://mozilla.org/MPL/2.0/. // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze nie tak -void TMoverParameters::UpdatePantVolume(double dt) +void physics::Vehicle::UpdatePantVolume(double dt) { // check the pantograph compressor while at it // TODO: move the check to a separate method @@ -82,7 +82,7 @@ void TMoverParameters::UpdatePantVolume(double dt) // the pantographs' pressure switch: low, it opens the line breaker (or locks the converter of a unit) once; // primed again over 4.6 bar, where the pantographs' compressor stops at 4.8 -void TMoverParameters::PantPressureSwitchCheck() +void physics::Vehicle::PantPressureSwitchCheck() { if (PantPress < EnginePowerSource.CollectorParameters.MinPress) { @@ -115,7 +115,7 @@ void TMoverParameters::PantPressureSwitchCheck() // the pantographs' pressure switch tripped by the low pressure: the line breaker opened, unless the voltage comes from // elsewhere, or the converter of a unit locked; spent until primed again -void TMoverParameters::PantPressureSwitchTrip() +void physics::Vehicle::PantPressureSwitchTrip() { // opuszczenie pantografów przy niskim ciśnieniu if (TrainType != train_type::emu) @@ -140,7 +140,7 @@ void TMoverParameters::PantPressureSwitchTrip() PantPressSwitchActive = false; } -void TMoverParameters::UpdateBatteryVoltage(double dt) +void physics::Vehicle::UpdateBatteryVoltage(double dt) { // przeliczenie obciążenia baterii using enum TEngineType; if (BatteryVoltage > 0 && EngineType != DieselEngine && EngineType != WheelsDriven && NominalBatteryVoltage > 0) @@ -167,7 +167,7 @@ void TMoverParameters::UpdateBatteryVoltage(double dt) }; // the drop of the battery's voltage in dt, by what draws from it, or its rise by the converter charging it -double TMoverParameters::BatteryDrain(double dt, bool const converteractive) const +double physics::Vehicle::BatteryDrain(double dt, bool const converteractive) const { if (NominalBatteryVoltage / BatteryVoltage < 1.22 && Battery) { // 110V @@ -185,7 +185,7 @@ double TMoverParameters::BatteryDrain(double dt, bool const converteractive) con } // the drain of a battery at its voltage, the converter charging it -double TMoverParameters::BatteryDrainCharged(double dt, bool const converteractive) const +double physics::Vehicle::BatteryDrainCharged(double dt, bool const converteractive) const { double sn1; double sn2; @@ -216,7 +216,7 @@ double TMoverParameters::BatteryDrainCharged(double dt, bool const converteracti } // the drain of a battery run down to 90 V, the converter charging it -double TMoverParameters::BatteryDrainLow(double dt, bool const converteractive) const +double physics::Vehicle::BatteryDrainLow(double dt, bool const converteractive) const { double sn1; double sn2; @@ -247,7 +247,7 @@ double TMoverParameters::BatteryDrainLow(double dt, bool const converteractive) } // the drain of a battery switched off, very slow -double TMoverParameters::BatteryDrainSwitchedOff(double dt) const +double physics::Vehicle::BatteryDrainSwitchedOff(double dt) const { double sn1; double sn2; @@ -265,7 +265,7 @@ double TMoverParameters::BatteryDrainSwitchedOff(double dt) const return sn1 + sn2 + sn3 + sn4 + sn5; } -void TMoverParameters::MainsCheck(double const Deltatime) +void physics::Vehicle::MainsCheck(double const Deltatime) { // if( MainsInitTime == 0.0 ) { return; } @@ -328,7 +328,7 @@ void TMoverParameters::MainsCheck(double const Deltatime) } } -void TMoverParameters::LowVoltagePowerCheck(double const /*Deltatime*/) +void physics::Vehicle::LowVoltagePowerCheck(double const /*Deltatime*/) { auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable}; @@ -345,7 +345,7 @@ void TMoverParameters::LowVoltagePowerCheck(double const /*Deltatime*/) } } -void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, Coupling const kind) +void physics::Vehicle::PowerCouplersCheck(double const /*Deltatime*/, Coupling const kind) { if (kind != Coupling::highVoltage && kind != Coupling::power110v && kind != Coupling::power24v) { @@ -366,7 +366,7 @@ void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, Coupling c } // the current the vehicle draws from the circuit of the power coupling given -double *TMoverParameters::PowerCircuitCurrent(Coupling const kind) +double *physics::Vehicle::PowerCircuitCurrent(Coupling const kind) { switch (kind) { @@ -382,7 +382,7 @@ double *TMoverParameters::PowerCircuitCurrent(Coupling const kind) } // the voltage of the vehicle's own source for the coupling given; notes the low voltage circuits' too -double TMoverParameters::LocalPowerVoltage(Coupling const kind) +double physics::Vehicle::LocalPowerVoltage(Coupling const kind) { auto localvoltage{0.0}; @@ -461,7 +461,7 @@ double TMoverParameters::LocalPowerVoltage(Coupling const kind) } // the voltage passed through the vehicle to the coupler at its other end, from the coupled vehicle or its own source -void TMoverParameters::PowerCouplersVoltage(Coupling const kind, double const abslocalvoltage, bool const localpowersource) +void physics::Vehicle::PowerCouplersVoltage(Coupling const kind, double const abslocalvoltage, bool const localpowersource) { if (Couplers[VehicleEnd::front].power(kind) == nullptr) { @@ -537,7 +537,7 @@ void TMoverParameters::PowerCouplersVoltage(Coupling const kind, double const ab } // the current drawn through the couplers, shared by their voltages, or added to the vehicle's own -void TMoverParameters::PowerCouplersCurrent(Coupling const kind, bool const localpowersource) +void physics::Vehicle::PowerCouplersCurrent(Coupling const kind, bool const localpowersource) { auto const *frontcoupling{Couplers[VehicleEnd::front].power(kind)}; auto const *rearcoupling{Couplers[VehicleEnd::rear].power(kind)}; @@ -588,7 +588,7 @@ void TMoverParameters::PowerCouplersCurrent(Coupling const kind, bool const loca } // sprawdzanie przetwornicy -void TMoverParameters::ConverterCheck(double const Timestep) +void physics::Vehicle::ConverterCheck(double const Timestep) { // TODO: move other converter checks here, to have it all in one place for potential device object if (ConverterStart != start_t::disabled && ConverterOverloadRelayOffWhenMainIsOff) @@ -648,7 +648,7 @@ void TMoverParameters::ConverterCheck(double const Timestep) }; // heating system status check -void TMoverParameters::HeatingCheck(double const /*Timestep*/) +void physics::Vehicle::HeatingCheck(double const /*Timestep*/) { // update heating devices @@ -725,7 +725,7 @@ void TMoverParameters::HeatingCheck(double const /*Timestep*/) } } -void TMoverParameters::PantographsCheck(double const /*Timestep*/) +void physics::Vehicle::PantographsCheck(double const /*Timestep*/) { using enum start_t; @@ -767,7 +767,7 @@ void TMoverParameters::PantographsCheck(double const /*Timestep*/) // the genset of a dual-mode vehicle: started on request with the battery on, it cranks for start_time, then runs at // idle and up to full revolutions with the traction demand; stopped, it coasts down. regulated voltage from idle up -void TMoverParameters::GensetCheck(double const Deltatime) +void physics::Vehicle::GensetCheck(double const Deltatime) { if (false == Genset.fitted()) { @@ -822,7 +822,7 @@ void TMoverParameters::GensetCheck(double const Deltatime) } } -void TMoverParameters::LightsCheck(double const /*Timestep*/) +void physics::Vehicle::LightsCheck(double const /*Timestep*/) { auto &light{CompartmentLights}; @@ -844,7 +844,7 @@ void TMoverParameters::LightsCheck(double const /*Timestep*/) // Q: 20160710 // włączenie / wyłączenie baterii // ************************************************************************************************* -bool TMoverParameters::BatterySwitch(bool State, range_t const Notify) +bool physics::Vehicle::BatterySwitch(bool State, range_t const Notify) { using enum range_t; if (PulleeMode && State) @@ -870,7 +870,7 @@ bool TMoverParameters::BatterySwitch(bool State, range_t const Notify) return Battery != initialstate; } -bool TMoverParameters::CompartmentLightsSwitch(bool State, range_t const Notify) +bool physics::Vehicle::CompartmentLightsSwitch(bool State, range_t const Notify) { if (CompartmentLights.start_type == start_t::automatic) @@ -892,7 +892,7 @@ bool TMoverParameters::CompartmentLightsSwitch(bool State, range_t const Notify) } // water pump state toggle -bool TMoverParameters::CompartmentLightsSwitchOff(bool State, range_t const Notify) +bool physics::Vehicle::CompartmentLightsSwitchOff(bool State, range_t const Notify) { if (CompartmentLights.start_type == start_t::automatic) @@ -917,7 +917,7 @@ bool TMoverParameters::CompartmentLightsSwitchOff(bool State, range_t const Noti // Q: 20160713 // włączenie / wyłączenie obwodu głownego // ************************************************************************************************* -bool TMoverParameters::MainSwitch(bool const State, range_t const Notify) +bool physics::Vehicle::MainSwitch(bool const State, range_t const Notify) { bool const initialstate{Mains || diesel.startupRequested}; @@ -934,7 +934,7 @@ bool TMoverParameters::MainSwitch(bool const State, range_t const Notify) return (Mains || diesel.startupRequested) != initialstate; } -void TMoverParameters::MainSwitch_(bool const State) +void physics::Vehicle::MainSwitch_(bool const State) { if (Mains == State || MainCtrlPosNo == 0) @@ -978,7 +978,7 @@ void TMoverParameters::MainSwitch_(bool const State) } } -bool TMoverParameters::MainSwitchCheck() const +bool physics::Vehicle::MainSwitchCheck() const { using enum TEngineType; @@ -1004,7 +1004,7 @@ bool TMoverParameters::MainSwitchCheck() const // Q: 20160713 // włączenie / wyłączenie przetwornicy // ************************************************************************************************* -bool TMoverParameters::ConverterSwitch(bool State, range_t const Notify) +bool physics::Vehicle::ConverterSwitch(bool State, range_t const Notify) { auto const initialstate{ConverterAllow}; @@ -1022,7 +1022,7 @@ bool TMoverParameters::ConverterSwitch(bool State, range_t const Notify) return ConverterAllow != initialstate; } -bool TMoverParameters::HeatingSwitch(bool const State, range_t const Notify) +bool physics::Vehicle::HeatingSwitch(bool const State, range_t const Notify) { bool const initialstate{HeatingAllow}; @@ -1039,7 +1039,7 @@ bool TMoverParameters::HeatingSwitch(bool const State, range_t const Notify) return HeatingAllow != initialstate; } -void TMoverParameters::HeatingSwitch_(bool const State) +void physics::Vehicle::HeatingSwitch_(bool const State) { // TBD, TODO: activation dependencies? @@ -1048,7 +1048,7 @@ void TMoverParameters::HeatingSwitch_(bool const State) // the start request of the genset of a dual-mode vehicle; one which starts on its own ignores it, but passes it on to // the cars behind, which may start theirs on request -bool TMoverParameters::GensetSwitch(bool const State, range_t const Notify) +bool physics::Vehicle::GensetSwitch(bool const State, range_t const Notify) { auto const initialstate{Genset.is_enabled}; @@ -1067,26 +1067,26 @@ bool TMoverParameters::GensetSwitch(bool const State, range_t const Notify) // the voltage of the vehicle's own source the traction selector picks: the catenary through the pantographs, or the // genset of a dual-mode vehicle -double TMoverParameters::TractionSourceVoltage() const +double physics::Vehicle::TractionSourceVoltage() const { return GensetSelected() ? Genset.voltage : PantographVoltage; } // the voltage the traction circuit gets: from the vehicle's own source, or through the train's high voltage line -double TMoverParameters::TractionSupplyVoltage() const +double physics::Vehicle::TractionSupplyVoltage() const { return std::max(GetTrainsetHighVoltage(), TractionSourceVoltage()); } // below it the undervoltage trip opens the line breaker -double TMoverParameters::TractionSupplyMinVoltage() const +double physics::Vehicle::TractionSupplyMinVoltage() const { return GensetSelected() ? 0.5 * Genset.voltage_nominal : EnginePowerSource.CollectorParameters.MinV; } // the power the traction may take [kW, at the wheels]: the genset's share at its present revolutions on the genset, // no limit otherwise -double TMoverParameters::GensetTractionPowerLimit() const +double physics::Vehicle::GensetTractionPowerLimit() const { return GensetSelected() ? Genset.available_power() * Genset.traction_share : std::numeric_limits::max(); } @@ -1094,7 +1094,7 @@ double TMoverParameters::GensetTractionPowerLimit() const // the current the vehicle draws through its pantographs [A], if they touch the wire: the traction's (none while // braking on the resistors) and the heating's. on the genset the genset feeds the traction circuit, so only a heating // fed straight from the pantographs is left -double TMoverParameters::CatenaryCurrent() const +double physics::Vehicle::CatenaryCurrent() const { if (GensetSelected()) { @@ -1104,7 +1104,7 @@ double TMoverParameters::CatenaryCurrent() const } // returns voltage of defined main engine power source -double TMoverParameters::EnginePowerSourceVoltage() const +double physics::Vehicle::EnginePowerSourceVoltage() const { return EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? TractionSupplyVoltage() : @@ -1114,7 +1114,7 @@ double TMoverParameters::EnginePowerSourceVoltage() const // whether the main circuit feeds what runs on it: the converter, a compressor, the heating, the motor and resistor // blowers, the traction motors -bool TMoverParameters::MainCircuitPowered() const +bool physics::Vehicle::MainCircuitPowered() const { if (false == Mains) { @@ -1131,7 +1131,7 @@ bool TMoverParameters::MainCircuitPowered() const return EnginePowerSourceVoltage() >= TractionSupplyMinVoltage(); } -bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t const Notify) +bool physics::Vehicle::OperatePantographsValve(operation_t const State, range_t const Notify) { if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0) @@ -1191,7 +1191,7 @@ bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t return true; } -bool TMoverParameters::OperatePantographValve(VehicleEnd const End, operation_t const State, range_t const Notify) +bool physics::Vehicle::OperatePantographValve(VehicleEnd const End, operation_t const State, range_t const Notify) { if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0) @@ -1255,7 +1255,7 @@ bool TMoverParameters::OperatePantographValve(VehicleEnd const End, operation_t return true; } -bool TMoverParameters::DropAllPantographs(bool const State, range_t const Notify) +bool physics::Vehicle::DropAllPantographs(bool const State, range_t const Notify) { auto const initialstate{PantAllDown}; @@ -1274,7 +1274,7 @@ bool TMoverParameters::DropAllPantographs(bool const State, range_t const Notify // Q: 20160709 // Funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT // ************************************************************************************************* -double TMoverParameters::GetTrainsetVoltage(CouplingSet const couplings) const +double physics::Vehicle::GetTrainsetVoltage(CouplingSet const couplings) const { // ABu: funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT // TBD, TODO: call once per vehicle update, return cached results? ByEnd voltages{0.0, 0.0}; @@ -1301,13 +1301,13 @@ double TMoverParameters::GetTrainsetVoltage(CouplingSet const couplings) const return std::max(voltages[VehicleEnd::front], voltages[VehicleEnd::rear]); } -double TMoverParameters::GetTrainsetHighVoltage() const +double physics::Vehicle::GetTrainsetHighVoltage() const { return std::max(GetTrainsetVoltage(Coupling::highVoltage), HeatingAllow ? GetTrainsetVoltage(Coupling::heating) : 0.0); } -int TMoverParameters::clampDimmerPosition(int const Position) const +int physics::Vehicle::clampDimmerPosition(int const Position) const { if (dimPositions.empty()) { @@ -1316,7 +1316,7 @@ int TMoverParameters::clampDimmerPosition(int const Position) const return std::clamp(Position, 0, static_cast(dimPositions.size()) - 1); } -TMoverParameters::dimPosition TMoverParameters::currentDimPosition() const +physics::Vehicle::dimPosition physics::Vehicle::currentDimPosition() const { if (modernDimmerPosition < 0 || modernDimmerPosition >= static_cast(dimPositions.size())) { @@ -1325,7 +1325,7 @@ TMoverParameters::dimPosition TMoverParameters::currentDimPosition() const return dimPositions[modernDimmerPosition]; } -bool TMoverParameters::stepDimmerPosition(int const Step) +bool physics::Vehicle::stepDimmerPosition(int const Step) { if (dimPositions.empty()) { @@ -1353,7 +1353,7 @@ bool TMoverParameters::stepDimmerPosition(int const Step) return true; } -std::optional TMoverParameters::LightsPresetCabLight(int const Position) const +std::optional physics::Vehicle::LightsPresetCabLight(int const Position) const { if (Position < 1 || Position > static_cast(LightsCabLight.size())) { diff --git a/physics/components/fizparser.cpp b/physics/components/fizparser.cpp index ebc791caa..5d7f3fc63 100644 --- a/physics/components/fizparser.cpp +++ b/physics/components/fizparser.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // reading the vehicle definition (.fiz): the parser and its tables #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -75,7 +75,7 @@ static bool is_valid_mpt_index(int const Index) return false; } -bool TMoverParameters::readMPT0(std::string const &line) +bool physics::Vehicle::readMPT0(std::string const &line) { // TBD, TODO: split into separate functions similar to readMPT if more varied schemes appear? @@ -112,7 +112,7 @@ bool TMoverParameters::readMPT0(std::string const &line) return true; } -bool TMoverParameters::readMPT(std::string const &line) +bool physics::Vehicle::readMPT(std::string const &line) { ++LISTLINE; @@ -139,7 +139,7 @@ bool TMoverParameters::readMPT(std::string const &line) } } -bool TMoverParameters::readMPTElectricSeries(std::string const &line) +bool physics::Vehicle::readMPTElectricSeries(std::string const &line) { cParser parser(line); @@ -168,7 +168,7 @@ bool TMoverParameters::readMPTElectricSeries(std::string const &line) return true; } -bool TMoverParameters::readMPTDieselElectric(std::string const &line) +bool physics::Vehicle::readMPTDieselElectric(std::string const &line) { cParser parser(line); @@ -188,7 +188,7 @@ bool TMoverParameters::readMPTDieselElectric(std::string const &line) return true; } -bool TMoverParameters::readMPTDieselEngine(std::string const &line) +bool physics::Vehicle::readMPTDieselEngine(std::string const &line) { cParser parser(line); @@ -217,7 +217,7 @@ bool TMoverParameters::readMPTDieselEngine(std::string const &line) return true; } -bool TMoverParameters::readBPT(std::string const &line) +bool physics::Vehicle::readBPT(std::string const &line) { cParser parser(line); @@ -248,7 +248,7 @@ bool TMoverParameters::readBPT(std::string const &line) return true; } -bool TMoverParameters::readRList(std::string const &Input) +bool physics::Vehicle::readRList(std::string const &Input) { cParser parser(Input); @@ -278,7 +278,7 @@ bool TMoverParameters::readRList(std::string const &Input) return true; } -bool TMoverParameters::readUCList(std::string const &line) +bool physics::Vehicle::readUCList(std::string const &line) { cParser parser(line); @@ -296,7 +296,7 @@ bool TMoverParameters::readUCList(std::string const &line) return true; } -bool TMoverParameters::readDList(std::string const &line) +bool physics::Vehicle::readDList(std::string const &line) { cParser parser(line); @@ -312,7 +312,7 @@ bool TMoverParameters::readDList(std::string const &line) return true; } -bool TMoverParameters::readDMList(std::string const &line) +bool physics::Vehicle::readDMList(std::string const &line) { cParser parser(line); @@ -332,7 +332,7 @@ bool TMoverParameters::readDMList(std::string const &line) return true; } -bool TMoverParameters::readV2NMAXList(std::string const &line) +bool physics::Vehicle::readV2NMAXList(std::string const &line) { cParser parser(line); @@ -352,7 +352,7 @@ bool TMoverParameters::readV2NMAXList(std::string const &line) return true; } -bool TMoverParameters::readHTCList(std::string const &line) +bool physics::Vehicle::readHTCList(std::string const &line) { cParser parser(line); @@ -372,7 +372,7 @@ bool TMoverParameters::readHTCList(std::string const &line) return true; } -bool TMoverParameters::readPmaxList(std::string const &line) +bool physics::Vehicle::readPmaxList(std::string const &line) { cParser parser(line); @@ -392,7 +392,7 @@ bool TMoverParameters::readPmaxList(std::string const &line) return true; } -bool TMoverParameters::readFFList(std::string const &line) +bool physics::Vehicle::readFFList(std::string const &line) { cParser parser(line); @@ -412,7 +412,7 @@ bool TMoverParameters::readFFList(std::string const &line) return true; } -bool TMoverParameters::readFFEDList(std::string const &line) +bool physics::Vehicle::readFFEDList(std::string const &line) { cParser parser(line); @@ -433,7 +433,7 @@ bool TMoverParameters::readFFEDList(std::string const &line) } // parsowanie wiperList -bool TMoverParameters::readWiperList(std::string const &line) +bool physics::Vehicle::readWiperList(std::string const &line) { cParser parser(line); if (false == parser.getTokens(4, false)) @@ -451,7 +451,7 @@ bool TMoverParameters::readWiperList(std::string const &line) return true; } -bool TMoverParameters::readDimmerList(std::string const &line) +bool physics::Vehicle::readDimmerList(std::string const &line) { cParser parser(line); if (false == parser.getTokens(3, false)) @@ -468,7 +468,7 @@ bool TMoverParameters::readDimmerList(std::string const &line) } // parsowanie WWList -bool TMoverParameters::readWWList(std::string const &line) +bool physics::Vehicle::readWWList(std::string const &line) { cParser parser(line); @@ -496,7 +496,7 @@ bool TMoverParameters::readWWList(std::string const &line) return true; } -bool TMoverParameters::readLightsList(std::string const &Input) +bool physics::Vehicle::readLightsList(std::string const &Input) { cParser parser(Input); @@ -530,7 +530,7 @@ bool TMoverParameters::readLightsList(std::string const &Input) return true; } -bool TMoverParameters::readCompressorList(std::string const &Input) +bool physics::Vehicle::readCompressorList(std::string const &Input) { cParser parser(Input); @@ -554,7 +554,7 @@ bool TMoverParameters::readCompressorList(std::string const &Input) // ************************************************************************************************* // Q: 20160719 // ************************************************************************************************* -void TMoverParameters::BrakeValveDecode(std::string const &Valve) +void physics::Vehicle::BrakeValveDecode(std::string const &Valve) { using enum TBrakeValve; @@ -599,7 +599,7 @@ void TMoverParameters::BrakeValveDecode(std::string const &Valve) // ************************************************************************************************* // Q: 20160719 // ************************************************************************************************* -void TMoverParameters::BrakeSubsystemDecode() +void physics::Vehicle::BrakeSubsystemDecode() { using enum TBrakeSubSystem; BrakeSubsystem = ss_None; @@ -641,7 +641,7 @@ void TMoverParameters::BrakeSubsystemDecode() // TDynamicObject::Init() // Po niej wykonywana jest CreateBrakeSys(), ktora jest odpowiednikiem CheckLocomotiveParameters() // ************************************************************************************************* -bool TMoverParameters::LoadFIZ(std::string const &chkpath) +bool physics::Vehicle::LoadFIZ(std::string const &chkpath) { chkPath = chkpath; // assign class path for reloading @@ -668,14 +668,14 @@ bool TMoverParameters::LoadFIZ(std::string const &chkpath) } // reads the vehicle definition from text in the .fiz format, e.g. one made up by a unit test -bool TMoverParameters::LoadFIZ_Text(std::string const &Text) +bool physics::Vehicle::LoadFIZ_Text(std::string const &Text) { ConversionError = 666; cParser fizparser(Text, cParser::buffer_TEXT); return LoadFIZ_Parse(fizparser); } -bool TMoverParameters::LoadFIZ_Parse(cParser &fizparser) +bool physics::Vehicle::LoadFIZ_Parse(cParser &fizparser) { LISTLINE = 0; startBPT = false; @@ -764,7 +764,7 @@ bool TMoverParameters::LoadFIZ_Parse(cParser &fizparser) } // the end of the table being read; returns whether the line is one -bool TMoverParameters::LoadFIZ_TableEnd(std::string const &inputline) const +bool physics::Vehicle::LoadFIZ_TableEnd(std::string const &inputline) const { // checking if table parsing should be switched off goes first... if (issection("END-MPT", inputline)) @@ -859,7 +859,7 @@ bool TMoverParameters::LoadFIZ_TableEnd(std::string const &inputline) const } // a section of the definition giving values, kept in fizlines by its name; returns whether the line is one -bool TMoverParameters::LoadFIZ_Section(std::string const &inputline, std::map> &fizlines) +bool physics::Vehicle::LoadFIZ_Section(std::string const &inputline, std::map> &fizlines) { // ...then all recognized sections... if (issection("Param.", inputline)) @@ -1074,7 +1074,7 @@ bool TMoverParameters::LoadFIZ_Section(std::string const &inputline, std::map> &fizlines) +bool physics::Vehicle::LoadFIZ_TableSection(std::string const &inputline, std::map> &fizlines) { if (issection("MotorParamTable:", inputline)) { @@ -1231,7 +1231,7 @@ bool TMoverParameters::LoadFIZ_TableSection(std::string const &inputline, std::m } // a row of the table being read -void TMoverParameters::LoadFIZ_TableRow(std::string const &inputline) +void physics::Vehicle::LoadFIZ_TableRow(std::string const &inputline) { // ...and finally, table parsers. // NOTE: once table parsing is enabled it lasts until switched off, when another section is recognized @@ -1321,7 +1321,7 @@ void TMoverParameters::LoadFIZ_TableRow(std::string const &inputline) } } -bool TMoverParameters::reload_FIZ() +bool physics::Vehicle::reload_FIZ() { WriteLog("[DEV] Reloading FIZ for " + Name); // pause simulation diff --git a/physics/components/fizsections.cpp b/physics/components/fizsections.cpp index d3de6cc60..a58837090 100644 --- a/physics/components/fizsections.cpp +++ b/physics/components/fizsections.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // reading the vehicle definition (.fiz): the sections and their keywords #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -54,7 +54,7 @@ int s2NNW(std::string s) return NNW; } -void TMoverParameters::LoadFIZ_Param(std::string const &line) +void physics::Vehicle::LoadFIZ_Param(std::string const &line) { extract_value(Mass, "M", line, "0"); @@ -106,7 +106,7 @@ void TMoverParameters::LoadFIZ_Param(std::string const &line) } } -void TMoverParameters::LoadFIZ_Load(std::string const &line) +void physics::Vehicle::LoadFIZ_Load(std::string const &line) { auto const acceptedloads{Split(extract_value("LoadAccepted", line), ',')}; @@ -138,7 +138,7 @@ void TMoverParameters::LoadFIZ_Load(std::string const &line) extract_value(UnLoadSpeed, "UnLoadSpeed", line, ""); } -void TMoverParameters::LoadFIZ_Headlights(std::string const &line) +void physics::Vehicle::LoadFIZ_Headlights(std::string const &line) { extract_value(refR, "LampRed", line, ""); extract_value(refG, "LampGreen", line, ""); @@ -150,7 +150,7 @@ void TMoverParameters::LoadFIZ_Headlights(std::string const &line) extract_value(highMultiplier, "HighBeamMultiplier", line, ""); } -void TMoverParameters::LoadFIZ_Dimensions(std::string const &line) +void physics::Vehicle::LoadFIZ_Dimensions(std::string const &line) { extract_value(Dim.L, "L", line, ""); @@ -173,7 +173,7 @@ void TMoverParameters::LoadFIZ_Dimensions(std::string const &line) extract_value(Floor, "Floor", line, ""); } -void TMoverParameters::LoadFIZ_Wheels(std::string const &line) +void physics::Vehicle::LoadFIZ_Wheels(std::string const &line) { extract_value(WheelDiameter, "D", line, ""); @@ -206,7 +206,7 @@ void TMoverParameters::LoadFIZ_Wheels(std::string const &line) } } -void TMoverParameters::LoadFIZ_Brake(std::string const &line) +void physics::Vehicle::LoadFIZ_Brake(std::string const &line) { extract_value(BrakeValveParams, "BrakeValve", line, ""); @@ -353,7 +353,7 @@ void TMoverParameters::LoadFIZ_Brake(std::string const &line) } } -void TMoverParameters::LoadFIZ_Doors(std::string const &line) +void physics::Vehicle::LoadFIZ_Doors(std::string const &line) { std::map> doorcontrols{ @@ -552,7 +552,7 @@ collision::end_definition collision_definition(std::string const &Line) } // namespace -void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Index) +void physics::Vehicle::LoadFIZ_BuffCoupl(std::string const &line, int const Index) { TCoupling *thiscoupler; @@ -669,13 +669,13 @@ void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Inde } } -void TMoverParameters::LoadFIZ_TurboPos(std::string const &Input) +void physics::Vehicle::LoadFIZ_TurboPos(std::string const &Input) { extract_value(TurboTest, "TurboPos", Input, ""); } -void TMoverParameters::LoadFIZ_Cntrl(std::string const &line) +void physics::Vehicle::LoadFIZ_Cntrl(std::string const &line) { LoadFIZ_CntrlBrakes(line); @@ -684,7 +684,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line) } // Cntrl.: the brake system, the handles, the brake delays and the local and manual brakes -void TMoverParameters::LoadFIZ_CntrlBrakes(std::string const &line) +void physics::Vehicle::LoadFIZ_CntrlBrakes(std::string const &line) { { using enum TBrakeSystem; @@ -709,7 +709,7 @@ void TMoverParameters::LoadFIZ_CntrlBrakes(std::string const &line) } // Cntrl.: of a vehicle with a train brake, its positions, delays, modes, handles, load weighing and anti-slip brake -void TMoverParameters::LoadFIZ_CntrlTrainBrake(std::string const &line) +void physics::Vehicle::LoadFIZ_CntrlTrainBrake(std::string const &line) { using enum TBrakeHandle; @@ -777,7 +777,7 @@ void TMoverParameters::LoadFIZ_CntrlTrainBrake(std::string const &line) } // Cntrl.: the kind of the anti-slip brake, by hand or automatic only for a vehicle with a brake handle -void TMoverParameters::LoadFIZ_CntrlAntiSlipBrake(std::string_view const asb) +void physics::Vehicle::LoadFIZ_CntrlAntiSlipBrake(std::string_view const asb) { if (asb == "yes") { @@ -794,7 +794,7 @@ void TMoverParameters::LoadFIZ_CntrlAntiSlipBrake(std::string_view const asb) } // Cntrl.: the controllers, their delays, the cab and the switches of the driver's desk -void TMoverParameters::LoadFIZ_CntrlControllers(std::string const &line) +void physics::Vehicle::LoadFIZ_CntrlControllers(std::string const &line) { // maksymalna predkosc dostepna na tarczce predkosciomierza extract_value(maxTachoSpeed, "MaxTachoSpeed", line, ""); @@ -901,7 +901,7 @@ void TMoverParameters::LoadFIZ_CntrlControllers(std::string const &line) } // Cntrl.: how the devices start (MainStart, BatteryStart, ...) and their relays -void TMoverParameters::LoadFIZ_CntrlStarts(std::string const &line) +void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) { using enum start_t; std::map> starts{{"Disabled", disabled}, {"Manual", manual}, {"Automatic", automatic}, {"Mixed", manualwithautofallback}, @@ -1017,7 +1017,7 @@ void TMoverParameters::LoadFIZ_CntrlStarts(std::string const &line) } } -void TMoverParameters::LoadFIZ_Blending(std::string const &line) +void physics::Vehicle::LoadFIZ_Blending(std::string const &line) { extract_value(MED_Vmax, "MED_Vmax", line, std::to_string(Vmax)); @@ -1032,7 +1032,7 @@ void TMoverParameters::LoadFIZ_Blending(std::string const &line) extract_value(MED_ED_Delay2, "MED_ScndDelayED", line, ""); } -void TMoverParameters::LoadFIZ_DCEMUED(std::string const &line) +void physics::Vehicle::LoadFIZ_DCEMUED(std::string const &line) { extract_value(DCEMUED_CC, "CouplerCheck", line, "0"); @@ -1041,7 +1041,7 @@ void TMoverParameters::LoadFIZ_DCEMUED(std::string const &line) extract_value(DCEMUED_EP_delay, "EP_delay", line, "0"); } -void TMoverParameters::LoadFIZ_SpringBrake(std::string const &line) +void physics::Vehicle::LoadFIZ_SpringBrake(std::string const &line) { double vol{1.0}; @@ -1065,7 +1065,7 @@ void TMoverParameters::LoadFIZ_SpringBrake(std::string const &line) SpringBrake.IsReady = true; } -void TMoverParameters::LoadFIZ_Light(std::string const &line) +void physics::Vehicle::LoadFIZ_Light(std::string const &line) { LightPowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("Light", line)); @@ -1079,7 +1079,7 @@ void TMoverParameters::LoadFIZ_Light(std::string const &line) NominalBatteryVoltage = static_cast(BatteryVoltage); } -void TMoverParameters::LoadFIZ_Clima(std::string const &line) +void physics::Vehicle::LoadFIZ_Clima(std::string const &line) { HeatingPowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("Heating", line)); @@ -1088,7 +1088,7 @@ void TMoverParameters::LoadFIZ_Clima(std::string const &line) LoadFIZ_PowerParamsDecode(AlterHeatPowerSource, "AlterH", line); } -void TMoverParameters::LoadFIZ_Power(std::string const &Line) +void physics::Vehicle::LoadFIZ_Power(std::string const &Line) { EnginePowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("EnginePower", Line)); @@ -1115,7 +1115,7 @@ void TMoverParameters::LoadFIZ_Power(std::string const &Line) } // the genset of a dual-mode vehicle (eu07/maszyna#536), on the Power: line; all optional, no genset without GensetPower -void TMoverParameters::LoadFIZ_Genset(std::string const &Line) +void physics::Vehicle::LoadFIZ_Genset(std::string const &Line) { extract_value(Genset.power, "GensetPower", Line, ""); if (false == Genset.fitted()) @@ -1139,7 +1139,7 @@ void TMoverParameters::LoadFIZ_Genset(std::string const &Line) Genset.traction_share = std::clamp(Genset.traction_share, 0.0, 1.0); } -void TMoverParameters::LoadFIZ_SpeedControl(std::string const &Line) +void physics::Vehicle::LoadFIZ_SpeedControl(std::string const &Line) { // speed control extract_value(SpeedCtrl, "SpeedCtrl", Line, ""); @@ -1178,7 +1178,7 @@ void TMoverParameters::LoadFIZ_SpeedControl(std::string const &Line) extract_value(SpeedCtrlUnit.PowerDownSpeed, "PowerDownSpeed", Line, ""); } -void TMoverParameters::LoadFIZ_Engine(std::string const &Input) +void physics::Vehicle::LoadFIZ_Engine(std::string const &Input) { EngineType = LoadFIZ_EngineDecode(extract_value("EngineType", Input)); @@ -1267,7 +1267,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input) } // Engine: of a diesel engine, its revolutions, gears, hydraulic transmission and retarder -void TMoverParameters::LoadFIZ_EngineDiesel(std::string const &Input) +void physics::Vehicle::LoadFIZ_EngineDiesel(std::string const &Input) { extract_value(diesel.minRevolutions, "nmin", Input, ""); @@ -1347,7 +1347,7 @@ void TMoverParameters::LoadFIZ_EngineDiesel(std::string const &Input) } // Engine: of a diesel-electric -void TMoverParameters::LoadFIZ_EngineDieselElectric(std::string const &Input) +void physics::Vehicle::LoadFIZ_EngineDieselElectric(std::string const &Input) { extract_value(Ftmax, "Ftmax", Input, ""); @@ -1374,7 +1374,7 @@ void TMoverParameters::LoadFIZ_EngineDieselElectric(std::string const &Input) } // Engine: of an induction motor drive -void TMoverParameters::LoadFIZ_EngineInductionMotor(std::string const &Input) +void physics::Vehicle::LoadFIZ_EngineInductionMotor(std::string const &Input) { RVentnmax = 1.0; @@ -1426,7 +1426,7 @@ void TMoverParameters::LoadFIZ_EngineInductionMotor(std::string const &Input) } // Engine: what both kinds of diesels have, their heat among it -void TMoverParameters::LoadFIZ_EngineDieselShared(std::string const &Input) +void physics::Vehicle::LoadFIZ_EngineDieselShared(std::string const &Input) { // oil pump extract_value(OilPump.pressure_minimum, "OilMinPressure", Input, ""); @@ -1464,7 +1464,7 @@ void TMoverParameters::LoadFIZ_EngineDieselShared(std::string const &Input) diesel.heat.powerfactor = 1235 / pf; } -void TMoverParameters::LoadFIZ_Switches(std::string const &Input) +void physics::Vehicle::LoadFIZ_Switches(std::string const &Input) { extract_value(PantSwitchType, "Pantograph", Input, ""); @@ -1488,7 +1488,7 @@ void TMoverParameters::LoadFIZ_Switches(std::string const &Input) } } -void TMoverParameters::LoadFIZ_MotorParamTable(std::string const &Input) +void physics::Vehicle::LoadFIZ_MotorParamTable(std::string const &Input) { switch (EngineType) @@ -1510,7 +1510,7 @@ void TMoverParameters::LoadFIZ_MotorParamTable(std::string const &Input) } } -void TMoverParameters::LoadFIZ_Circuit(std::string const &Input) +void physics::Vehicle::LoadFIZ_Circuit(std::string const &Input) { extract_value(CircuitRes, "CircuitRes", Input, ""); @@ -1530,7 +1530,7 @@ void TMoverParameters::LoadFIZ_Circuit(std::string const &Input) extract_value(TUHEX_Stages, "TUHEX_Stages", Input, "0"); } -void TMoverParameters::LoadFIZ_AI(std::string const &Input) +void physics::Vehicle::LoadFIZ_AI(std::string const &Input) { extract_value(AIHintPantstate, "Pantstate", Input, ""); @@ -1539,7 +1539,7 @@ void TMoverParameters::LoadFIZ_AI(std::string const &Input) extract_value(AIHintLocalBrakeAccFactor, "LocalBrakeAccFactor", Input, ""); } -void TMoverParameters::LoadFIZ_RList(std::string const &Input) +void physics::Vehicle::LoadFIZ_RList(std::string const &Input) { extract_value(RlistSize, "Size", Input, ""); @@ -1570,7 +1570,7 @@ void TMoverParameters::LoadFIZ_RList(std::string const &Input) } // the dynamic brake of a diesel-electric vehicle, from its Engine section: none without EDBrake -void TMoverParameters::LoadFIZ_DieselElectricDynamicBrake(std::string const &Input) +void physics::Vehicle::LoadFIZ_DieselElectricDynamicBrake(std::string const &Input) { using enum diesel_electric_dynamic_brake::control; std::map> const sources{{"Controller", controller}, {"Lever", lever}}; @@ -1598,7 +1598,7 @@ void TMoverParameters::LoadFIZ_DieselElectricDynamicBrake(std::string const &Inp } } -void TMoverParameters::LoadFIZ_UCList(std::string const &Input) +void physics::Vehicle::LoadFIZ_UCList(std::string const &Input) { extract_value(UniCtrlListSize, "Size", Input, ""); @@ -1609,7 +1609,7 @@ void TMoverParameters::LoadFIZ_UCList(std::string const &Input) UniCtrlValStep = std::max(UniCtrlValStep, 0.0); } -void TMoverParameters::LoadFIZ_DList(std::string const &Input) +void physics::Vehicle::LoadFIZ_DList(std::string const &Input) { extract_value(diesel.maxMoment, "Mmax", Input, ""); @@ -1633,30 +1633,30 @@ void TMoverParameters::LoadFIZ_DList(std::string const &Input) diesel.fuelConsumption = diesel.nominalFuelConsumptionRate * dizel_max_energy / fuel_density / diesel.maxRevolutions; } -void TMoverParameters::LoadFIZ_FFList(std::string const &Input) +void physics::Vehicle::LoadFIZ_FFList(std::string const &Input) { extract_value(FFListSize, "Size", Input, ""); } -void TMoverParameters::LoadFIZ_FFEDList(std::string const &Input) +void physics::Vehicle::LoadFIZ_FFEDList(std::string const &Input) { extract_value(FFEDListSize, "Size", Input, ""); } -void TMoverParameters::LoadFIZ_WiperList(std::string const &Input) +void physics::Vehicle::LoadFIZ_WiperList(std::string const &Input) { extract_value(WiperListSize, "Size", Input, ""); extract_value(WiperAngle, "Angle", Input, ""); extract_value(WiperDefaultPos, "Default", Input, ""); } -void TMoverParameters::LoadFIZ_DimmerList(std::string const &Input) +void physics::Vehicle::LoadFIZ_DimmerList(std::string const &Input) { // extract_value(modernWpierListSize, "Size", Input, ""); extract_value(modernDimmerCanCycle, "Cycle", Input, ""); extract_value(modernDimmerDefaultPosition, "DefaultPos", Input, ""); } -void TMoverParameters::LoadFIZ_LightsList(std::string const &Input) +void physics::Vehicle::LoadFIZ_LightsList(std::string const &Input) { extract_value(LightsPosNo, "Size", Input, ""); @@ -1664,7 +1664,7 @@ void TMoverParameters::LoadFIZ_LightsList(std::string const &Input) extract_value(LightsDefPos, "Default", Input, ""); } -void TMoverParameters::LoadFIZ_CompressorList(std::string const &Input) +void physics::Vehicle::LoadFIZ_CompressorList(std::string const &Input) { extract_value(CompressorListPosNo, "Size", Input, ""); @@ -1672,7 +1672,7 @@ void TMoverParameters::LoadFIZ_CompressorList(std::string const &Input) extract_value(CompressorListDefPos, "Default", Input, ""); } -void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const &Prefix, std::string const &Line) +void physics::Vehicle::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const &Prefix, std::string const &Line) { switch (Powerparameters.SourceType) @@ -1693,7 +1693,7 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete } case TPowerSource::Generator: { - // prime mover for the generator + // prime physics for the generator auto &generatorparameters{Powerparameters.EngineGenerator}; if (auto const enginetype{LoadFIZ_EngineDecode(extract_value(Prefix + "GeneratorEngine", Line))}; enginetype == TEngineType::Main) @@ -1792,7 +1792,7 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete } } -TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Powertype) const +TPowerType physics::Vehicle::LoadFIZ_PowerDecode(std::string const &Powertype) const { using enum TPowerType; @@ -1802,7 +1802,7 @@ TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Powertype) c return lookup != powertypes.end() ? lookup->second : NoPower; } -TPowerSource TMoverParameters::LoadFIZ_SourceDecode(std::string const &Source) const +TPowerSource physics::Vehicle::LoadFIZ_SourceDecode(std::string const &Source) const { using enum TPowerSource; @@ -1815,7 +1815,7 @@ TPowerSource TMoverParameters::LoadFIZ_SourceDecode(std::string const &Source) c return lookup != powersources.end() ? lookup->second : NotDefined; } -TEngineType TMoverParameters::LoadFIZ_EngineDecode(std::string const &Engine) const +TEngineType physics::Vehicle::LoadFIZ_EngineDecode(std::string const &Engine) const { using enum TEngineType; diff --git a/physics/components/internal.h b/physics/components/internal.h index baf916278..4cdcbe668 100644 --- a/physics/components/internal.h +++ b/physics/components/internal.h @@ -11,7 +11,7 @@ http://mozilla.org/MPL/2.0/. #pragma once -#include "physics/mover.h" +#include "physics/vehicle.h" const double CouplerTune = 0.1; // skalowanie tlumiennosci diff --git a/physics/components/pneumatics.cpp b/physics/components/pneumatics.cpp index 8a7f0555a..4ba3c0276 100644 --- a/physics/components/pneumatics.cpp +++ b/physics/components/pneumatics.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the brakes and the air: the brake controls, the pipes, the valves, the compressor, the spring brake #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -32,7 +32,7 @@ http://mozilla.org/MPL/2.0/. // Nastawianie hamulców -void TMoverParameters::BrakeLevelSet(double b) +void physics::Vehicle::BrakeLevelSet(double b) { // ustawienie pozycji hamulca na wartość (b) w zakresie od -2 do BrakeCtrlPosNo // jedyny dopuszczalny sposób przestawienia hamulca zasadniczego if (fBrakeCtrlPos == b) @@ -47,10 +47,10 @@ void TMoverParameters::BrakeLevelSet(double b) auto x = static_cast(std::floor(fBrakeCtrlPos)); // jeśli odwołujemy się do BrakeCtrlPos w pośrednich, to musi być // obcięte a nie zaokrągone while (x > BrakeCtrlPos && BrakeCtrlPos < BrakeCtrlPosNo) // jeśli zwiększyło się o 1 - if (!IncBrakeLevelOld()) // T_MoverParameters:: + if (!IncBrakeLevelOld()) // physics::Vehicle:: break; // wyjście awaryjne while (x < BrakeCtrlPos && BrakeCtrlPos >= -1) // jeśli zmniejszyło się o 1 - if (!DecBrakeLevelOld()) // T_MoverParameters:: + if (!DecBrakeLevelOld()) // physics::Vehicle:: break; BrakePressureActual = BrakePressureTable[BrakeCtrlPos]; // skopiowanie pozycji /* @@ -73,19 +73,19 @@ void TMoverParameters::BrakeLevelSet(double b) */ }; -bool TMoverParameters::BrakeLevelAdd(double b) +bool physics::Vehicle::BrakeLevelAdd(double b) { // dodanie wartości (b) do pozycji hamulca (w tym ujemnej) // zwraca false, gdy po dodaniu było by poza zakresem BrakeLevelSet(fBrakeCtrlPos + b); return b > 0.0 ? fBrakeCtrlPos < BrakeCtrlPosNo : BrakeCtrlPos > -1.0; // true, jeśli można kontynuować }; -bool TMoverParameters::IncBrakeLevel() +bool physics::Vehicle::IncBrakeLevel() { // nowa wersja na użytek AI, false gdy osiągnięto pozycję BrakeCtrlPosNo return BrakeLevelAdd(1.0); }; -bool TMoverParameters::DecBrakeLevel() +bool physics::Vehicle::DecBrakeLevel() { return BrakeLevelAdd(-1.0); }; // nowa wersja na użytek AI, false gdy osiągnięto pozycję -1 @@ -133,7 +133,7 @@ ZN //masa // Q: 20160714 // Oblicza iloraz aktualnej pozycji do maksymalnej hamulca pomocnicznego // ***************************************************************************** -double TMoverParameters::LocalBrakeRatio(void) const +double physics::Vehicle::LocalBrakeRatio(void) const { double LBR; if (BrakeHandle == TBrakeHandle::MHZ_EN57) @@ -157,7 +157,7 @@ double TMoverParameters::LocalBrakeRatio(void) const // Q: 20160714 // Oblicza iloraz aktualnej pozycji do maksymalnej hamulca ręcznego // ***************************************************************************** -double TMoverParameters::ManualBrakeRatio(void) const +double physics::Vehicle::ManualBrakeRatio(void) const { double MBR; @@ -172,7 +172,7 @@ double TMoverParameters::ManualBrakeRatio(void) const // Q: 20160713 // Zwraca objętość // ***************************************************************************** -double TMoverParameters::BrakeVP(void) const +double physics::Vehicle::BrakeVP(void) const { if (BrakeVVolume > 0) return Volume / (10.0 * BrakeVVolume); @@ -184,7 +184,7 @@ double TMoverParameters::BrakeVP(void) const // Q: 20160713 // Zwraca iloraz różnicy między przewodem kontrolnym i głównym oraz DeltaPipePress // ***************************************************************************** -double TMoverParameters::RealPipeRatio(void) const +double physics::Vehicle::RealPipeRatio(void) const { double rpp; @@ -199,7 +199,7 @@ double TMoverParameters::RealPipeRatio(void) const // Q: 20160713 // Zwraca iloraz ciśnienia w przewodzie do DeltaPipePress // ***************************************************************************** -double TMoverParameters::PipeRatio(void) const +double physics::Vehicle::PipeRatio(void) const { double pr; @@ -227,7 +227,7 @@ double TMoverParameters::PipeRatio(void) const // Q: 20160710 // włączenie / wyłączenie hamulca elektro-pneumatycznego // ************************************************************************************************* -bool TMoverParameters::EpFuseSwitch(bool State) +bool physics::Vehicle::EpFuseSwitch(bool State) { if (EpFuse != State) { @@ -244,7 +244,7 @@ bool TMoverParameters::EpFuseSwitch(bool State) // yB: 20190906 // włączenie / wyłączenie hamulca sprezynowego // ************************************************************************************************* -bool TMoverParameters::SpringBrakeActivate(bool State) +bool physics::Vehicle::SpringBrakeActivate(bool State) { if (Power24vIsAvailable || Power110vIsAvailable) { @@ -264,7 +264,7 @@ bool TMoverParameters::SpringBrakeActivate(bool State) // yB: 20190906 // włączenie / wyłączenie odciecia hamulca sprezynowego // ************************************************************************************************* -bool TMoverParameters::SpringBrakeShutOff(bool State) +bool physics::Vehicle::SpringBrakeShutOff(bool State) { if (SpringBrake.ShuttOff != State) { @@ -279,7 +279,7 @@ bool TMoverParameters::SpringBrakeShutOff(bool State) // yB: 20190906 // wyluzowanie hamulca sprezynowego // ************************************************************************************************* -bool TMoverParameters::SpringBrakeRelease() +bool physics::Vehicle::SpringBrakeRelease() { if (SpringBrake.IsReady && SpringBrake.Cylinder->P() < SpringBrake.MinForcePressure) { @@ -295,7 +295,7 @@ bool TMoverParameters::SpringBrakeRelease() // Q: 20160710 // załączenie przycisku przeciwpoślizgowego // ************************************************************************************************* -bool TMoverParameters::AntiSlippingButton(void) +bool physics::Vehicle::AntiSlippingButton(void) { // NOTE: disabled the sandbox part, it's already controlled by another part of the AI routine return AntiSlippingBrake() /*|| Sandbox(true)*/; @@ -305,7 +305,7 @@ bool TMoverParameters::AntiSlippingButton(void) // Q: 20160713 // włączenie / wyłączenie sprężarki // ************************************************************************************************* -bool TMoverParameters::CompressorSwitch(bool State, range_t const Notify) +bool physics::Vehicle::CompressorSwitch(bool State, range_t const Notify) { if (CompressorStart != start_t::manual) @@ -329,7 +329,7 @@ bool TMoverParameters::CompressorSwitch(bool State, range_t const Notify) return CompressorAllow != initialstate; } -bool TMoverParameters::ChangeCompressorPreset(int const State, range_t const Notify) +bool physics::Vehicle::ChangeCompressorPreset(int const State, range_t const Notify) { auto const initialstate{CompressorListPos}; @@ -348,7 +348,7 @@ bool TMoverParameters::ChangeCompressorPreset(int const State, range_t const Not // Q: 20160711 // zwiększenie nastawy hamulca // ************************************************************************************************* -bool TMoverParameters::IncBrakeLevelOld(void) +bool physics::Vehicle::IncBrakeLevelOld(void) { bool IBLO = false; @@ -375,7 +375,7 @@ bool TMoverParameters::IncBrakeLevelOld(void) // Q: 20160711 // zmniejszenie nastawy hamulca // ***************************************************************************** -bool TMoverParameters::DecBrakeLevelOld(void) +bool physics::Vehicle::DecBrakeLevelOld(void) { bool DBLO = false; @@ -401,7 +401,7 @@ bool TMoverParameters::DecBrakeLevelOld(void) // Q: 20160711 // zwiększenie nastawy hamulca pomocnicznego // ************************************************************************************************* -bool TMoverParameters::IncLocalBrakeLevel(float const CtrlSpeed) +bool physics::Vehicle::IncLocalBrakeLevel(float const CtrlSpeed) { bool IBL; if (LocalBrakePosA < 1.0 /*and (BrakeCtrlPos<1)*/) @@ -420,7 +420,7 @@ bool TMoverParameters::IncLocalBrakeLevel(float const CtrlSpeed) // Q: 20160711 // zmniejszenie nastawy hamulca pomocniczego // ************************************************************************************************* -bool TMoverParameters::DecLocalBrakeLevel(float const CtrlSpeed) +bool physics::Vehicle::DecLocalBrakeLevel(float const CtrlSpeed) { bool DBL; if (LocalBrakePosA > 0) @@ -439,7 +439,7 @@ bool TMoverParameters::DecLocalBrakeLevel(float const CtrlSpeed) // Q: 20160711 // zwiększenie nastawy hamulca ręcznego // ************************************************************************************************* -bool TMoverParameters::IncManualBrakeLevel(int CtrlSpeed) +bool physics::Vehicle::IncManualBrakeLevel(int CtrlSpeed) { bool IMBL; if (ManualBrakePos < ManualBrakePosNo) /*and (BrakeCtrlPos<1)*/ @@ -462,7 +462,7 @@ bool TMoverParameters::IncManualBrakeLevel(int CtrlSpeed) // Q: 20160711 // zmniejszenie nastawy hamulca ręcznego // ************************************************************************************************* -bool TMoverParameters::DecManualBrakeLevel(int CtrlSpeed) +bool physics::Vehicle::DecManualBrakeLevel(int CtrlSpeed) { bool DMBL; if (ManualBrakePos > 0) @@ -480,7 +480,7 @@ bool TMoverParameters::DecManualBrakeLevel(int CtrlSpeed) return DMBL; } -bool TMoverParameters::AlarmChainSwitch(bool const State) +bool physics::Vehicle::AlarmChainSwitch(bool const State) { if (AlarmChainFlag != State) @@ -496,7 +496,7 @@ bool TMoverParameters::AlarmChainSwitch(bool const State) // Q: 20160710 // hamowanie przeciwpoślizgowe // ************************************************************************************************* -bool TMoverParameters::AntiSlippingBrake(void) +bool physics::Vehicle::AntiSlippingBrake(void) { bool ASB = false; // Ra: przeniesione z końca if (ASBType == 1) @@ -512,7 +512,7 @@ bool TMoverParameters::AntiSlippingBrake(void) // Q: 20160711 // włączenie / wyłączenie odluźniacza // ************************************************************************************************* -bool TMoverParameters::BrakeReleaser(int state) +bool physics::Vehicle::BrakeReleaser(int state) { bool OK = true; // false tylko jeśli nie uda się wysłać, GF 20161124 if (state != 0) @@ -536,7 +536,7 @@ bool TMoverParameters::BrakeReleaser(int state) // yB: 20160711 // włączenie / wyłączenie uniwersalnego przycisku hamulcowego // ************************************************************************************************* -bool TMoverParameters::UniversalBrakeButton(int button, int state) +bool physics::Vehicle::UniversalBrakeButton(int button, int state) { bool OK = true; // false tylko jeśli nie uda się wysłać, GF 20161124 UniversalBrakeButtonActive[button] = state > 0; @@ -566,7 +566,7 @@ bool TMoverParameters::UniversalBrakeButton(int button, int state) // Q: 20160711 // włączenie / wyłączenie hamulca elektro-pneumatycznego // ************************************************************************************************* -bool TMoverParameters::SwitchEPBrake(int state) +bool physics::Vehicle::SwitchEPBrake(int state) { bool OK; @@ -586,7 +586,7 @@ bool TMoverParameters::SwitchEPBrake(int state) return OK; } -bool TMoverParameters::EPBrakeControlPowered() const +bool physics::Vehicle::EPBrakeControlPowered() const { return Power24vIsAvailable && DirActive != 0 && EpFuse; } @@ -595,7 +595,7 @@ bool TMoverParameters::EPBrakeControlPowered() const // Q: 20160711 // zwiększenie ciśnienia hamowania // ************************************************************************************************* -bool TMoverParameters::IncBrakePress(double &brake, double PressLimit, double dp) +bool physics::Vehicle::IncBrakePress(double &brake, double PressLimit, double dp) { bool IBP; // if (DynamicBrakeType<>dbrake_switch) and (DynamicBrakeType<>dbrake_none) and @@ -624,7 +624,7 @@ bool TMoverParameters::IncBrakePress(double &brake, double PressLimit, double dp // Q: 20160711 // zmniejszenie ciśnienia hamowania // ************************************************************************************************* -bool TMoverParameters::DecBrakePress(double &brake, double PressLimit, double dp) +bool physics::Vehicle::DecBrakePress(double &brake, double PressLimit, double dp) { bool DBP; @@ -650,7 +650,7 @@ bool TMoverParameters::DecBrakePress(double &brake, double PressLimit, double dp // Q: 20160711 // przełączenie nastawy hamulca O/P/T // ************************************************************************************************* -bool TMoverParameters::BrakeDelaySwitch(int BDS) +bool physics::Vehicle::BrakeDelaySwitch(int BDS) { bool rBDS; if (Hamulec->SetBDF(BDS)) @@ -672,7 +672,7 @@ bool TMoverParameters::BrakeDelaySwitch(int BDS) // Q: 20160712 // zwiększenie przełożenia hamulca // ************************************************************************************************* -bool TMoverParameters::IncBrakeMult(void) +bool physics::Vehicle::IncBrakeMult(void) { bool IBM; @@ -696,7 +696,7 @@ bool TMoverParameters::IncBrakeMult(void) // Q: 20160712 // zmniejszenie przełożenia hamulca // ************************************************************************************************* -bool TMoverParameters::DecBrakeMult(void) +bool physics::Vehicle::DecBrakeMult(void) { bool DBM; if (LoadFlag > 1 && MBPM < 2) @@ -719,7 +719,7 @@ bool TMoverParameters::DecBrakeMult(void) // Q: 20160712 // zaktualizowanie ciśnienia w hamulcach // ************************************************************************************************* -void TMoverParameters::UpdateBrakePressure(double dt) +void physics::Vehicle::UpdateBrakePressure(double dt) { // const double LBDelay = 5.0; // stala czasowa hamulca // double Rate, Speed, dp, sm; @@ -745,7 +745,7 @@ void TMoverParameters::UpdateBrakePressure(double dt) // Q: 20160712 // Obliczanie pracy sprężarki // ************************************************************************************************* -void TMoverParameters::CompressorCheck(double dt) +void physics::Vehicle::CompressorCheck(double dt) { if (CompressorSpeed == 0.0) @@ -891,7 +891,7 @@ void TMoverParameters::CompressorCheck(double dt) // Q: 20160712 // aktualizacja ciśnienia w przewodzie głównym // ************************************************************************************************* -void TMoverParameters::UpdatePipePressure(double dt) +void physics::Vehicle::UpdatePipePressure(double dt) { if (PipePress > 1.0) { @@ -900,7 +900,7 @@ void TMoverParameters::UpdatePipePressure(double dt) } // double dV; - // TMoverParameters *c; // T_MoverParameters + // physics::Vehicle *c; // physics::Vehicle double temp; // int b; @@ -976,7 +976,7 @@ void TMoverParameters::UpdatePipePressure(double dt) } // the flow of the local brake valve, by the handle, the TRAXX's timed one, the integrated controller or the parking -void TMoverParameters::UpdateLocalBrakeValve(double dt) +void physics::Vehicle::UpdateLocalBrakeValve(double dt) { // the local brake of a vehicle prepared for hauling (PulleeMode) is held released, whatever asks for it if (EngineType != TEngineType::ElectricInductionMotor) @@ -1016,7 +1016,7 @@ void TMoverParameters::UpdateLocalBrakeValve(double dt) } // the lock of the brake pipe and the flow of the driver's handle, from the main reservoir or into the air -void TMoverParameters::UpdateMainValve(double dt) +void physics::Vehicle::UpdateMainValve(double dt) { auto const temp{MainValveSupply()}; Handle->SetReductor(BrakeCtrlPos2); @@ -1056,7 +1056,7 @@ void TMoverParameters::UpdateMainValve(double dt) } // the pressure the driver's handle is fed from: the main pipe's, or the brake pipe's own with the pipe locked -double TMoverParameters::MainValveSupply() +double physics::Vehicle::MainValveSupply() { LockPipe = PipePress < (LockPipe ? LockPipeOff : LockPipeOn); bool lock_new = (LockPipe && !UnlockPipe && BrakeCtrlPosR > HandleUnlock) || (EmergencyCutsOffHandle && EmergencyValveFlow > 0); // new simple codition based on .fiz @@ -1071,7 +1071,7 @@ double TMoverParameters::MainValveSupply() } // the position the driver's handle works at: its own, or the one the speed control's brake intervention sets -double TMoverParameters::MainValveHandlePosition() const +double physics::Vehicle::MainValveHandlePosition() const { double pos = BrakeCtrlPosR; if (SpeedCtrlUnit.IsActive && SpeedCtrlUnit.BrakeIntervention && !SpeedCtrlUnit.Standby && BrakeCtrlPos != Handle->GetPos(bh_EB)) @@ -1085,7 +1085,7 @@ double TMoverParameters::MainValveHandlePosition() const return pos; } -void TMoverParameters::UpdateEmergencyValve(double dt) +void physics::Vehicle::UpdateEmergencyValve(double dt) { // ulepszony hamulec bezp. EmergencyValveFlow = 0.0; @@ -1107,7 +1107,7 @@ void TMoverParameters::UpdateEmergencyValve(double dt) } // what the distributor valve gets of the local brake and the load, by its kind -void TMoverParameters::UpdateDistributorSettings() +void physics::Vehicle::UpdateDistributorSettings() { switch (BrakeValve) { @@ -1218,7 +1218,7 @@ void TMoverParameters::UpdateDistributorSettings() } // the ep brake of the FVel6 and FVE408 handles, passed along the unit -void TMoverParameters::UpdateEPBrake() +void physics::Vehicle::UpdateEPBrake() { if (EPBrakeControlPowered()) // tu powinien byc jeszcze bezpiecznik EP i baterie - // temp = (Handle as TFVel6).GetCP @@ -1244,7 +1244,7 @@ void TMoverParameters::UpdateEPBrake() // Q: 20160713 // Aktualizacja ciśnienia w przewodzie zasilającym // ************************************************************************************************* -void TMoverParameters::UpdateScndPipePressure(double dt) +void physics::Vehicle::UpdateScndPipePressure(double dt) { if (ScndPipePress > 1.0) { @@ -1281,7 +1281,7 @@ void TMoverParameters::UpdateScndPipePressure(double dt) // yB: 20190906 // Aktualizacja ciśnienia w hamulcu sprezynowym // ************************************************************************************************* -void TMoverParameters::UpdateSpringBrake(double /*dt*/) +void physics::Vehicle::UpdateSpringBrake(double /*dt*/) { double BP = SpringBrake.PNBrakeConnection ? BrakePress : 0; double MSP = SpringBrake.ShuttOff ? 0 : SpringBrake.MaxSetPressure; @@ -1326,7 +1326,7 @@ bool pipe_wakes(double const Flow, double const Pressure, TReservoir const &Pipe // the pressure in the pipe of a coupled vehicle the flow to it goes by. the pressure the vehicle keeps is the one of its last step: // with Global.physics_pipewake one asleep can take air for a long time without waking, and the flow, going by that pressure, would // carry on past the pressure of the vehicle it comes from. so of one asleep, the pressure with what has flown in since -double neighbour_pipe_pressure(TMoverParameters const &Neighbour, double const Pressure, TReservoir const &Pipe) +double neighbour_pipe_pressure(physics::Vehicle const &Neighbour, double const Pressure, TReservoir const &Pipe) { if ((Global.physics_pipewake <= 0.f) || Neighbour.PhysicActivation) return Pressure; @@ -1339,10 +1339,10 @@ double neighbour_pipe_pressure(TMoverParameters const &Neighbour, double const P // Q: 20160715 // oblicza i zwraca przepływ powietrza pomiędzy pojazdami // ************************************************************************************************* -double TMoverParameters::GetDVc(double dt) +double physics::Vehicle::GetDVc(double dt) { - // T_MoverParameters *c; - TMoverParameters *c; + // physics::Vehicle *c; + physics::Vehicle *c; double dv1; double dv2; // , dV; @@ -1384,10 +1384,10 @@ double TMoverParameters::GetDVc(double dt) // the air the main reservoir hoses carry between the vehicle's pipe and the neighbours' in dt: the neighbours' // share is sent to them, the vehicle's own returned // ************************************************************************************************* -double TMoverParameters::GetScndDVc(double dt) +double physics::Vehicle::GetScndDVc(double dt) { const double Spz = 0.5067; - TMoverParameters *c; + physics::Vehicle *c; double dv1 = 0; double dv2 = 0; @@ -1421,35 +1421,35 @@ namespace { -// a pipe along the train, whose air the hoses between the vehicles carry (TMoverParameters::UpdatePipeCouplers()) +// a pipe along the train, whose air the hoses between the vehicles carry (physics::Vehicle::UpdatePipeCouplers()) struct train_pipe { - std::shared_ptr TMoverParameters::*reservoir; - double TMoverParameters::*pressure; - bool TMoverParameters::*pending; // the vehicle stepped the pipe, the exchange through its hoses is yet to come + std::shared_ptr physics::Vehicle::*reservoir; + double physics::Vehicle::*pressure; + bool physics::Vehicle::*pending; // the vehicle stepped the pipe, the exchange through its hoses is yet to come CouplingSet hose; // the coupling of the pipe's hose - double (TMoverParameters::*exchange)(double); // the air the hoses carry in a step, the neighbours' share sent to them - double (*area)(TMoverParameters const &); // the cross-section of the hose, as the exchange takes it + double (physics::Vehicle::*exchange)(double); // the air the hoses carry in a step, the neighbours' share sent to them + double (*area)(physics::Vehicle const &); // the cross-section of the hose, as the exchange takes it }; // the brake pipe, GetDVc() -train_pipe const brake_pipe{&TMoverParameters::Pipe, - &TMoverParameters::PipePress, - &TMoverParameters::PipeCouplersPending, +train_pipe const brake_pipe{&physics::Vehicle::Pipe, + &physics::Vehicle::PipePress, + &physics::Vehicle::PipeCouplersPending, Coupling::brakeHose, - &TMoverParameters::GetDVc, - [](TMoverParameters const &Vehicle) { return Vehicle.Spg / (1.0 + 0.015 / Vehicle.Spg * Vehicle.Dim.L); }}; + &physics::Vehicle::GetDVc, + [](physics::Vehicle const &Vehicle) { return Vehicle.Spg / (1.0 + 0.015 / Vehicle.Spg * Vehicle.Dim.L); }}; // the main reservoir pipe, GetScndDVc() -train_pipe const main_reservoir_pipe{&TMoverParameters::Pipe2, - &TMoverParameters::ScndPipePress, - &TMoverParameters::ScndPipeCouplersPending, +train_pipe const main_reservoir_pipe{&physics::Vehicle::Pipe2, + &physics::Vehicle::ScndPipePress, + &physics::Vehicle::ScndPipeCouplersPending, Coupling::mainHose, - &TMoverParameters::GetScndDVc, - [](TMoverParameters const &) { return 0.5067 * 0.75; }}; + &physics::Vehicle::GetScndDVc, + [](physics::Vehicle const &) { return 0.5067 * 0.75; }}; // the number of sub-steps of dt the air exchange through the hoses of the vehicle's pipe needs: in one, the air a // hose carries stays below what evens out the pipes on its ends -int hose_substeps(TMoverParameters const &Vehicle, train_pipe const &Pipe, double const dt) +int hose_substeps(physics::Vehicle const &Vehicle, train_pipe const &Pipe, double const dt) { auto substeps{1}; auto const area{Pipe.area(Vehicle)}; @@ -1474,12 +1474,12 @@ int hose_substeps(TMoverParameters const &Vehicle, train_pipe const &Pipe, doubl // the vehicles of the list which stepped the pipe, each with the number of the train it is in: the ones joined by the hoses // of the pipe, directly, numbered in the order of their first vehicle in the list. a vehicle which didn't step the pipe // (its physics sleeps) takes the air sent to it without passing it on, so it ends a train -std::vector hose_trains(std::vector const &Vehicles, train_pipe const &Pipe) +std::vector hose_trains(std::vector const &Vehicles, train_pipe const &Pipe) { auto constexpr none{std::numeric_limits::max()}; std::vector trains(Vehicles.size(), none); // the vehicles by their address, for finding the neighbours in the list - std::vector> byaddress; + std::vector> byaddress; byaddress.reserve(Vehicles.size()); for (std::size_t index = 0; index < Vehicles.size(); ++index) { @@ -1489,8 +1489,8 @@ std::vector hose_trains(std::vector const &Vehi } } std::ranges::sort(byaddress); - auto const find = [&byaddress](TMoverParameters const *Vehicle) { - auto const found{std::ranges::lower_bound(byaddress, Vehicle, std::less<>{}, &std::pair::first)}; + auto const find = [&byaddress](physics::Vehicle const *Vehicle) { + auto const found{std::ranges::lower_bound(byaddress, Vehicle, std::less<>{}, &std::pair::first)}; return (found != byaddress.end() && found->first == Vehicle) ? found->second : none; }; std::size_t count{0}; @@ -1530,7 +1530,7 @@ std::vector hose_trains(std::vector const &Vehi // its vehicles one after another, as the step of the vehicles does. the air of a train stays in it, so a train comes out // the same whichever other vehicles are exchanged in the same call: all of them, or the ones of a group of // vehicle_table::update_steps_parallel() -void exchange_through_hoses(std::vector const &Vehicles, train_pipe const &Pipe, double const dt) +void exchange_through_hoses(std::vector const &Vehicles, train_pipe const &Pipe, double const dt) { auto const trains{hose_trains(Vehicles, Pipe)}; std::vector substeps; @@ -1581,7 +1581,7 @@ void exchange_through_hoses(std::vector const &Vehicles, tra // pipes overshoot each other in turns and the distributors see the pressure up to 0.28 bar off what's in the pipe // (eu07/maszyna#368) // ************************************************************************************************* -int TMoverParameters::PipeCouplersSubsteps(double const dt) const +int physics::Vehicle::PipeCouplersSubsteps(double const dt) const { return hose_substeps(*this, brake_pipe, dt); } @@ -1592,7 +1592,7 @@ int TMoverParameters::PipeCouplersSubsteps(double const dt) const // the vehicles' own main reservoirs feeding the pipe in the same step, the pipes of the middle vehicles of a // multiple unit or of locomotives in multiple traction kept jumping 0.8 bar to and fro between the steps // ************************************************************************************************* -int TMoverParameters::ScndPipeCouplersSubsteps(double const dt) const +int physics::Vehicle::ScndPipeCouplersSubsteps(double const dt) const { return hose_substeps(*this, main_reservoir_pipe, dt); } @@ -1601,13 +1601,13 @@ int TMoverParameters::ScndPipeCouplersSubsteps(double const dt) const // the air exchange through the brake and the main reservoir hoses of the vehicles which stepped their pipes // (UpdatePipePressure(), UpdateScndPipePressure()) since the last call, each pipe in its own sub-steps // ************************************************************************************************* -void TMoverParameters::UpdatePipeCouplers(std::vector const &Vehicles, double const dt) +void physics::Vehicle::UpdatePipeCouplers(std::vector const &Vehicles, double const dt) { exchange_through_hoses(Vehicles, brake_pipe, dt); exchange_through_hoses(Vehicles, main_reservoir_pipe, dt); } -bool TMoverParameters::UpdateStopBrakeRelease(double const Demand, double const Dt) +bool physics::Vehicle::UpdateStopBrakeRelease(double const Demand, double const Dt) { if (Demand <= 0.0) { diff --git a/physics/components/securitysystem.cpp b/physics/components/securitysystem.cpp index 3b94ca658..ed943661c 100644 --- a/physics/components/securitysystem.cpp +++ b/physics/components/securitysystem.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the security system (vigilance, cab signalling, radio-stop) #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -234,7 +234,7 @@ void TSecuritySystem::load(std::string const &line, double Vmax) // zbicie czuwaka / SHP // ***************************************************************************** // hunter-091012: rozbicie alarmow, dodanie testu czuwaka -void TMoverParameters::SecuritySystemReset(void) // zbijanie czuwaka/SHP +void physics::Vehicle::SecuritySystemReset(void) // zbijanie czuwaka/SHP { // reset all, used by AI SecuritySystem.acknowledge_press(); @@ -246,7 +246,7 @@ void TMoverParameters::SecuritySystemReset(void) // zbijanie czuwaka/SHP // Q: 20160711 // sprawdzanie stanu CA/SHP // ************************************************************************************************* -void TMoverParameters::SecuritySystemCheck(double dt) +void physics::Vehicle::SecuritySystemCheck(double dt) { bool isPower = Power24vIsAvailable || Power110vIsAvailable; // the shunt mode of the SM42 switches its vigilance device (CA) off, on the vehicles with AwareOffInShuntMode=Yes (eu07/maszyna#457) @@ -263,7 +263,7 @@ void TMoverParameters::SecuritySystemCheck(double dt) // Q: 20160711 // włączenie / wyłączenie hamowania awaryjnego // ************************************************************************************************* -bool TMoverParameters::RadiostopSwitch(bool Switch) +bool physics::Vehicle::RadiostopSwitch(bool Switch) { bool EBS; if (BrakeSystem != TBrakeSystem::Individual && BrakeCtrlPosNo > 0) diff --git a/physics/components/setup.cpp b/physics/components/setup.cpp index 086e37ddc..f5c8944bd 100644 --- a/physics/components/setup.cpp +++ b/physics/components/setup.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // setting the vehicle up after reading its definition: the checks, the brake valves, the handles and the pipes #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -34,7 +34,7 @@ http://mozilla.org/MPL/2.0/. // Q: 20160717 // ************************************************************************************************* -bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/) +bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/) { WriteLog("check locomotive parameters..."); bool OK = true; @@ -152,13 +152,13 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/) { IncBrakeMult(); IncBrakeMult(); - DecBrakeMult(); // TODO: przeinesiono do mover.cpp + DecBrakeMult(); // TODO: przeinesiono do physics.cpp if (LoadAmount < MaxLoad * 0.35) DecBrakeMult(); } else { - IncBrakeMult(); // TODO: przeinesiono do mover.cpp + IncBrakeMult(); // TODO: przeinesiono do physics.cpp if (LoadAmount >= MaxLoad * 0.55) IncBrakeMult(); } @@ -219,7 +219,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/) } // the distributor valve of the vehicle's kind -void TMoverParameters::CreateBrakeValve() +void physics::Vehicle::CreateBrakeValve() { switch (BrakeValve) { @@ -318,7 +318,7 @@ void TMoverParameters::CreateBrakeValve() } // the driver's handle and the local brake handle of the vehicle's kinds -void TMoverParameters::CreateBrakeHandles() +void physics::Vehicle::CreateBrakeHandles() { switch (BrakeHandle) { @@ -384,7 +384,7 @@ void TMoverParameters::CreateBrakeHandles() } // the brake pipe, the main pipe and the spring brake's cylinder -void TMoverParameters::CreateBrakePipes() +void physics::Vehicle::CreateBrakePipes() { if (true == TestFlag(BrakeDelays, bdelay_G) && (false == TestFlag(BrakeDelays, bdelay_R) || Power > 1.0)) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy Spg = 0.792; @@ -404,7 +404,7 @@ void TMoverParameters::CreateBrakePipes() } // the pressure of the main pipe at the start: the main reservoir's, or HosePressure fed through a main hose, or none -double TMoverParameters::InitialScndPipePress(double const HosePressure) const +double physics::Vehicle::InitialScndPipePress(double const HosePressure) const { if (VeselVolume > 0.0) { @@ -418,7 +418,7 @@ double TMoverParameters::InitialScndPipePress(double const HosePressure) const } // the air and the controls of a vehicle ready to depart -void TMoverParameters::SetReadyToDepart() +void physics::Vehicle::SetReadyToDepart() { WriteLog("Ready to depart"); CompressedVolume = VeselVolume * MinCompressor * 9.8 / 10.0; @@ -445,7 +445,7 @@ void TMoverParameters::SetReadyToDepart() } // the air and the brakes of a vehicle standing braked -void TMoverParameters::SetBraked() +void physics::Vehicle::SetBraked() { WriteLog("Braked"); Volume = BrakeVVolume * MaxBrakePress[3]; diff --git a/physics/components/traction.cpp b/physics/components/traction.cpp index de089e04b..62b45c2c2 100644 --- a/physics/components/traction.cpp +++ b/physics/components/traction.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. // the traction motors and their forces for each kind of drive, the relays, the fuses, the dynamic brake #include "stdafx.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include "physics/oerlikonest.h" #include "utilities/Globals.h" @@ -59,7 +59,7 @@ double TableInterpolation(std::map &Map, double Parameter) // Q: 20160716 // Obliczanie natężenie prądu w silnikach // ************************************************************************************************* -double TMoverParameters::Current(double n, double U) +double physics::Vehicle::Current(double n, double U) { // wazna funkcja - liczy prad plynacy przez silniki polaczone szeregowo lub rownolegle // w zaleznosci od polozenia nastawnikow MainCtrl i ScndCtrl oraz predkosci obrotowej n @@ -130,7 +130,7 @@ double TMoverParameters::Current(double n, double U) } // the automatic dynamic brake of the series motors (EP09, the units) on or off, and the distributor told of it -void TMoverParameters::UpdateSeriesMotorDynamicBrakeFlag() +void physics::Vehicle::UpdateSeriesMotorDynamicBrakeFlag() { // i dzialanie hamulca ED w EP09 if (DynamicBrakeType == dbrake_automatic && TrainType != train_type::emu) @@ -165,7 +165,7 @@ void TMoverParameters::UpdateSeriesMotorDynamicBrakeFlag() // the current of the series motors connected, at the revolutions n and the voltage U, through the resistance R of // Mn motors in series -double TMoverParameters::SeriesMotorCurrent(double const n, double const U, double const R, double const Mn) const +double physics::Vehicle::SeriesMotorCurrent(double const n, double const U, double const R, double const Mn) const { double MotorCurrent{0.0}; double Rz; @@ -210,7 +210,7 @@ double TMoverParameters::SeriesMotorCurrent(double const n, double const U, doub // the current of the series motors driving, at the revolutions n, the voltage U and the resistance Rz of Mn motors in // series, by the motor parameters of the shunt field SP -double TMoverParameters::SeriesMotorDrivingCurrent(double const n, double const U, double const Rz, double const Mn, int const SP) const +double physics::Vehicle::SeriesMotorDrivingCurrent(double const n, double const U, double const Rz, double const Mn, int const SP) const { double MotorCurrent; double Delta; @@ -240,7 +240,7 @@ double TMoverParameters::SeriesMotorDrivingCurrent(double const n, double const } // the line breaker opened, and the motors damaged, by too high revolutions or current -void TMoverParameters::MotorFailuresCheck(double const n) +void physics::Vehicle::MotorFailuresCheck(double const n) { double MotorCurrent; // awarie @@ -260,7 +260,7 @@ void TMoverParameters::MotorFailuresCheck(double const n) } // rozruch wysoki (true) albo niski (false) -bool TMoverParameters::CurrentSwitch(bool const State) +bool physics::Vehicle::CurrentSwitch(bool const State) { // TBD, TODO: split off shunt mode toggle into a separate command? It doesn't make much sense to have these two together like that // the diesels with a shunt mode have no motor overload relay threshold to switch, the switch sets their shunt mode alone. @@ -288,13 +288,13 @@ bool TMoverParameters::CurrentSwitch(bool const State) return false; }; -bool TMoverParameters::IsMotorOverloadRelayHighThresholdOn() const +bool physics::Vehicle::IsMotorOverloadRelayHighThresholdOn() const { return ImaxHi > ImaxLo && Imax > ImaxLo; } -double TMoverParameters::ShowEngineRotation(int VehN) const +double physics::Vehicle::ShowEngineRotation(int VehN) const { // Zwraca wartość prędkości obrotowej silnika wybranego pojazdu. Do 3 pojazdów (3×SN61). int b; switch (VehN) @@ -317,7 +317,7 @@ double TMoverParameters::ShowEngineRotation(int VehN) const return 0.0; }; -void TMoverParameters::MotorBlowersCheck(double const Timestep) +void physics::Vehicle::MotorBlowersCheck(double const Timestep) { // activation check for (auto &blower : MotorBlowers) @@ -376,7 +376,7 @@ void TMoverParameters::MotorBlowersCheck(double const Timestep) } } -bool TMoverParameters::MotorBlowerPowerIsAvailable(cooling_fan const &Blower) const +bool physics::Vehicle::MotorBlowerPowerIsAvailable(cooling_fan const &Blower) const { switch (Blower.start_type) { @@ -389,12 +389,12 @@ bool TMoverParameters::MotorBlowerPowerIsAvailable(cooling_fan const &Blower) co } } -double TMoverParameters::ShowCurrent(int AmpN) const +double physics::Vehicle::ShowCurrent(int AmpN) const { // Odczyt poboru prądu na podanym amperomierzu return Drive().ShowCurrent(*this, AmpN); }; -bool TMoverParameters::MotorBlowersSwitch(bool State, VehicleEnd const Side, range_t const Notify) +bool physics::Vehicle::MotorBlowersSwitch(bool State, VehicleEnd const Side, range_t const Notify) { auto &fan{MotorBlowers[Side]}; @@ -418,7 +418,7 @@ bool TMoverParameters::MotorBlowersSwitch(bool State, VehicleEnd const Side, ran return fan.is_enabled != initialstate; } -bool TMoverParameters::MotorBlowersSwitchOff(bool State, VehicleEnd const Side, range_t const Notify) +bool physics::Vehicle::MotorBlowersSwitchOff(bool State, VehicleEnd const Side, range_t const Notify) { auto &fan{MotorBlowers[Side]}; @@ -443,7 +443,7 @@ bool TMoverParameters::MotorBlowersSwitchOff(bool State, VehicleEnd const Side, } // the traction selector of a dual-mode vehicle: moves only with the line breaker open, and only where a genset is -bool TMoverParameters::TractionModeSwitch(traction_mode const Mode, range_t const Notify) +bool physics::Vehicle::TractionModeSwitch(traction_mode const Mode, range_t const Notify) { auto const initialstate{TractionMode}; // refused with the line breaker closed, and then not passed on either, so the train stays on one source @@ -466,7 +466,7 @@ bool TMoverParameters::TractionModeSwitch(traction_mode const Mode, range_t cons // zwiększenie nastawy nastawnika hamulca elektrodynamicznego (DynamicBrakeCtrl) // uzywane gdy SplitEDPneumaticBrake = true // ************************************************************************************************* -bool TMoverParameters::IncDynamicBrakeLevel(float const CtrlSpeed) +bool physics::Vehicle::IncDynamicBrakeLevel(float const CtrlSpeed) { if (false == SplitEDPneumaticBrake) return false; @@ -483,7 +483,7 @@ bool TMoverParameters::IncDynamicBrakeLevel(float const CtrlSpeed) // ************************************************************************************************* // zmniejszenie nastawy nastawnika hamulca elektrodynamicznego (DynamicBrakeCtrl) // ************************************************************************************************* -bool TMoverParameters::DecDynamicBrakeLevel(float const CtrlSpeed) +bool physics::Vehicle::DecDynamicBrakeLevel(float const CtrlSpeed) { if (false == SplitEDPneumaticBrake) return false; @@ -500,7 +500,7 @@ bool TMoverParameters::DecDynamicBrakeLevel(float const CtrlSpeed) // ************************************************************************************************* // bezposrednie ustawienie nastawnika hamulca elektrodynamicznego (DynamicBrakeCtrl) // ************************************************************************************************* -bool TMoverParameters::DynamicBrakeLevelSet(double Position) +bool physics::Vehicle::DynamicBrakeLevelSet(double Position) { if (false == SplitEDPneumaticBrake) return false; @@ -512,7 +512,7 @@ bool TMoverParameters::DynamicBrakeLevelSet(double Position) // odczyt nastawy nastawnika hamulca elektrodynamicznego (DynamicBrakeCtrl) // zwraca 0 jezeli SplitEDPneumaticBrake nie jest aktywne (dla zachowania starej logiki) // ************************************************************************************************* -double TMoverParameters::DynamicBrakeRatio(void) const +double physics::Vehicle::DynamicBrakeRatio(void) const { if (false == SplitEDPneumaticBrake) return 0.0; @@ -522,7 +522,7 @@ double TMoverParameters::DynamicBrakeRatio(void) const // ************************************************************************************************* // czy hamulec ED jest aktualnie dostepny w oknie predkosci Vh0..Vh1 // ************************************************************************************************* -bool TMoverParameters::DynamicBrakeAvailable(void) const +bool physics::Vehicle::DynamicBrakeAvailable(void) const { double const vh0{inductionMotor.braking.offSpeed}; if (double const vh1{inductionMotor.braking.fullSpeed}; vh1 <= 0.001) @@ -538,7 +538,7 @@ bool TMoverParameters::DynamicBrakeAvailable(void) const // Q: 20160713 // reczne przelaczanie hamulca elektrodynamicznego // ************************************************************************************************* -bool TMoverParameters::DynamicBrakeSwitch(bool Switch) +bool physics::Vehicle::DynamicBrakeSwitch(bool Switch) { bool DBS; @@ -566,7 +566,7 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch) // Q: 20160714 // oblicza sile trakcyjna lokomotywy (dla elektrowozu tez calkowity prad) // ************************************************************************************************* -double TMoverParameters::TractionForce(double dt) +double physics::Vehicle::TractionForce(double dt) { Ft = 0; double dtrans{0.0}; @@ -600,13 +600,13 @@ double TMoverParameters::TractionForce(double dt) } // the starting resistors' blowers, and the diesels' radiator fans -void TMoverParameters::UpdateVentilators(double dt) +void physics::Vehicle::UpdateVentilators(double dt) { Drive().UpdateVentilators(*this, dt); } // the starting resistors' blowers of the series motors with the line breaker closed, worked by hand or by the current -void TMoverParameters::UpdateResistorBlowers(double dt) +void physics::Vehicle::UpdateResistorBlowers(double dt) { switch (RVentType) { @@ -655,18 +655,18 @@ void TMoverParameters::UpdateResistorBlowers(double dt) } // the power of a dumb or diesel engine; returns the ratio of the power a dumb engine is set to -double TMoverParameters::UpdateEnginePower() +double physics::Vehicle::UpdateEnginePower() { return Drive().UpdateEnginePower(*this); } // the line breaker opened by a voltage out of the motors' range, and the line contactors of a diesel-electric -void TMoverParameters::VoltageRelaysCheck() +void physics::Vehicle::VoltageRelaysCheck() { Drive().CheckVoltageRelays(*this); } -void TMoverParameters::DumbTractionForce(double const PosRatio) +void physics::Vehicle::DumbTractionForce(double const PosRatio) { if (Mains && CabActive != 0) { @@ -686,7 +686,7 @@ void TMoverParameters::DumbTractionForce(double const PosRatio) } } -void TMoverParameters::WheelsDrivenTractionForce(double dt) +void physics::Vehicle::WheelsDrivenTractionForce(double dt) { if (EnginePowerSource.SourceType == TPowerSource::InternalSource && EnginePowerSource.PowerType == TPowerType::BioPower) Ft = Sign(sin(eAngle)) * PulseForce * Transmision.Ratio; @@ -700,7 +700,7 @@ void TMoverParameters::WheelsDrivenTractionForce(double dt) EnginePower = Ft * (1.0 + Vel); } -void TMoverParameters::SeriesMotorTractionForce(double dt) +void physics::Vehicle::SeriesMotorTractionForce(double dt) { // enrot:=Transmision.Ratio*nrot; // yB: szereg dwoch sekcji w ET42 @@ -712,7 +712,7 @@ void TMoverParameters::SeriesMotorTractionForce(double dt) { if (Imax == ImaxHi) EngineVoltage = EngineVoltage * 2; - if (DynamicBrakeFlag && abs(Im) > 300) // przeiesione do mover.cpp + if (DynamicBrakeFlag && abs(Im) > 300) // przeiesione do physics.cpp FuseOff(); } if (DynamicBrakeType == dbrake_automatic && DynamicBrakeFlag) @@ -742,7 +742,7 @@ void TMoverParameters::SeriesMotorTractionForce(double dt) } // the automatic dynamic brake of the series motors: the excitation current, by the stages of the ep brake (TUHEX) -void TMoverParameters::SeriesMotorDynamicBrake(double dt) +void physics::Vehicle::SeriesMotorDynamicBrake(double dt) { if (TUHEX_Stages > 0) // hamowanie wielostopniowe, nadpisuje wartości domyślne { @@ -794,7 +794,7 @@ void TMoverParameters::SeriesMotorDynamicBrake(double dt) // the shunt field relays of a diesel-electric, each kind its own conditions on the current, the speed or the // power (tmp, the power the engine gives) -void TMoverParameters::ShuntFieldRelaysCheck(double const tmpV, double const PosRatio, double const tmp) +void physics::Vehicle::ShuntFieldRelaysCheck(double const tmpV, double const PosRatio, double const tmp) { auto const shuntfieldstate{ScndCtrlPos}; @@ -861,7 +861,7 @@ void TMoverParameters::ShuntFieldRelaysCheck(double const tmpV, double const Pos } // the relays of type 2: up by the speed while the engine has power to spare (tmp, the power it gives), down by the current -void TMoverParameters::ShuntFieldRelaysType2(double const tmp) +void physics::Vehicle::ShuntFieldRelaysType2(double const tmp) { if (ScndCtrlPos < ScndCtrlPosNo && MPTRelay[ScndCtrlPos].Iup < Vel && EnginePower < tmp * 0.99) { @@ -874,7 +874,7 @@ void TMoverParameters::ShuntFieldRelaysType2(double const tmp) } // the relays of type 41: up by the speed tmpV at full power, the engine slowed down, down by the current -void TMoverParameters::ShuntFieldRelaysType41(double const tmpV) +void physics::Vehicle::ShuntFieldRelaysType41(double const tmpV) { if (ScndCtrlPos < ScndCtrlPosNo && MainCtrlPos == MainCtrlPosNo && tmpV * 3.6 > MPTRelay[ScndCtrlPos].Iup) { @@ -888,7 +888,7 @@ void TMoverParameters::ShuntFieldRelaysType41(double const tmpV) } // the relays of type 45, by the current and the speed: up from the 11th position, at most two under it, none under the 8th -void TMoverParameters::ShuntFieldRelaysType45() +void physics::Vehicle::ShuntFieldRelaysType45() { if (ScndCtrlPos < ScndCtrlPosNo && MainCtrlPos >= 11) { @@ -943,7 +943,7 @@ void TMoverParameters::ShuntFieldRelaysType45() // the relays of type 46, by the current and the speed: up from the 12th position, down under it below 50 km/h, at most two // under the 11th, none under the 8th -void TMoverParameters::ShuntFieldRelaysType46() +void physics::Vehicle::ShuntFieldRelaysType46() { // wzrastanie if (MainCtrlPos >= 12 && ScndCtrlPos < ScndCtrlPosNo) @@ -966,7 +966,7 @@ void TMoverParameters::ShuntFieldRelaysType46() } // a relay of type 46 down: an even one by the current, an odd one by the current and the speed -void TMoverParameters::ShuntFieldRelaysType46Down() +void physics::Vehicle::ShuntFieldRelaysType46Down() { // above 50 km/h already active shunt field can be maintained until lower controller setting if (ScndCtrlPos % 2 == 0) @@ -986,7 +986,7 @@ void TMoverParameters::ShuntFieldRelaysType46Down() } // a relay of type 46 up: an even one by the current, an odd one by the current and the speed -void TMoverParameters::ShuntFieldRelaysType46Up() +void physics::Vehicle::ShuntFieldRelaysType46Up() { if (ScndCtrlPos % 2 == 0) { @@ -1004,7 +1004,7 @@ void TMoverParameters::ShuntFieldRelaysType46Up() } } -void TMoverParameters::InductionMotorTractionForce(double dt) +void physics::Vehicle::InductionMotorTractionForce(double dt) { if (MainCircuitPowered() && !SecuritySystem.is_engine_blocked()) { @@ -1053,7 +1053,7 @@ void TMoverParameters::InductionMotorTractionForce(double dt) } // the speed control (tempomat) of an induction motor drive, set by its second controller -void TMoverParameters::InductionMotorSpeedControl(double dt) +void physics::Vehicle::InductionMotorSpeedControl(double dt) { // tempomat if (ScndCtrlPosNo == 4 && SpeedCtrlTypeTime) @@ -1067,7 +1067,7 @@ void TMoverParameters::InductionMotorSpeedControl(double dt) } // the speed control set by the position of the second controller, after it's been held for its delay -void TMoverParameters::SpeedControlByPosition(double dt) +void physics::Vehicle::SpeedControlByPosition(double dt) { if (ScndCtrlPos != NewSpeed) { @@ -1093,7 +1093,7 @@ void TMoverParameters::SpeedControlByPosition(double dt) // the speed control of a four position second controller, by time: the speed set down or up by 10 km/h a step, held, // or off and at the top -void TMoverParameters::SpeedControlByTime(double dt) +void physics::Vehicle::SpeedControlByTime(double dt) { SpeedCtrlUnit.IsActive = SpeedCtrlValue > 0; switch (ScndCtrlPos) @@ -1141,7 +1141,7 @@ void TMoverParameters::SpeedControlByTime(double dt) // whether the induction motors brake, and the share of the electrodynamic and the pneumatic brake; sets the // force asked of the motors (PosRatio) and how fast the drive follows it (tmp) -void TMoverParameters::InductionMotorBrakeBlending(double const ActiveInverters, double &PosRatio, double &tmp) +void physics::Vehicle::InductionMotorBrakeBlending(double const ActiveInverters, double &PosRatio, double &tmp) { InductionMotorDynamicBrakeFlag(); auto const edBCP{Hamulec->GetEDBCP() * inductionMotor.braking.cylinderPressureGain}; // stala napedu @@ -1171,7 +1171,7 @@ void TMoverParameters::InductionMotorBrakeBlending(double const ActiveInverters, // the electrodynamic brake of the induction motors on: with the doors open or permitted, by the train brake, the local // brake or its own controller; off without them -void TMoverParameters::InductionMotorDynamicBrakeFlag() +void physics::Vehicle::InductionMotorDynamicBrakeFlag() { double const edBCP = Hamulec->GetEDBCP(); auto const localbrakeactive{CabOccupied != 0 && LocHandle->GetCP() > 0.25}; @@ -1193,7 +1193,7 @@ void TMoverParameters::InductionMotorDynamicBrakeFlag() // the share of the electrodynamic brake (negative), and the distributor told how much of the air to let out; none // when the air brake cuts the electrodynamic one off, or an inverter is out -double TMoverParameters::InductionMotorBrakeRatio(double const ActiveInverters, double const edBCP) +double physics::Vehicle::InductionMotorBrakeRatio(double const ActiveInverters, double const edBCP) { double PosRatio; // ustalanie współczynnika blendingu do luzowania hamulca PN @@ -1238,7 +1238,7 @@ double TMoverParameters::InductionMotorBrakeRatio(double const ActiveInverters, } // the model of the induction motors and their inverters: voltage, frequency, currents, moment and force -void TMoverParameters::InductionMotorDrive(double dt) +void physics::Vehicle::InductionMotorDrive(double dt) { double tmp; if (DynamicBrakeFlag) @@ -1315,7 +1315,7 @@ void TMoverParameters::InductionMotorDrive(double dt) // the force the motors give at full and at the setting (inductionMotor.forceShare), braking within the power and the force of the // electrodynamic brake, driving within the power and the starting force -void TMoverParameters::InductionMotorForceLimits() +void physics::Vehicle::InductionMotorForceLimits() { if (inductionMotor.forceShare < 0) { @@ -1344,7 +1344,7 @@ void TMoverParameters::InductionMotorForceLimits() } // the frequency of the inverters at the motors' slip frequency, from the list of the drive or of its brake -void TMoverParameters::UpdateInverterFrequency() +void physics::Vehicle::UpdateInverterFrequency() { auto const tmpV{std::abs(inductionMotor.state.supplyFrequency)}; auto const useFFEDList = FFEDListSize > 0 && DynamicBrakeFlag; @@ -1367,7 +1367,7 @@ void TMoverParameters::UpdateInverterFrequency() } // the induction motor drive without power, or blocked by the security system -void TMoverParameters::InductionMotorOff() +void physics::Vehicle::InductionMotorOff() { for (auto &inv : inductionMotor.inverters) { @@ -1393,7 +1393,7 @@ void TMoverParameters::InductionMotorOff() // Q: 20160713 // Sprawdzenie bezpiecznika nadmiarowego // ************************************************************************************************* -bool TMoverParameters::FuseFlagCheck(void) const +bool physics::Vehicle::FuseFlagCheck(void) const { bool FFC; @@ -1412,7 +1412,7 @@ bool TMoverParameters::FuseFlagCheck(void) const // Q: 20160713 // Załączenie bezpiecznika nadmiarowego // ************************************************************************************************* -bool TMoverParameters::FuseOn(range_t const Notify) +bool physics::Vehicle::FuseOn(range_t const Notify) { auto const result{RelayReset(relay_t::maincircuitground | relay_t::tractionnmotoroverload, Notify)}; @@ -1423,7 +1423,7 @@ bool TMoverParameters::FuseOn(range_t const Notify) // Q: 20160713 // Wyłączenie bezpiecznika nadmiarowego // ************************************************************************************************* -void TMoverParameters::FuseOff(void) +void physics::Vehicle::FuseOff(void) { if (!FuseFlag) { @@ -1434,7 +1434,7 @@ void TMoverParameters::FuseOff(void) } // resets relays assigned to specified customizable reset button -bool TMoverParameters::UniversalResetButton(int const Button, range_t const Notify) +bool physics::Vehicle::UniversalResetButton(int const Button, range_t const Notify) { if (auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable}; false == lowvoltagepower) @@ -1454,7 +1454,7 @@ bool TMoverParameters::UniversalResetButton(int const Button, range_t const Noti } // resets state of specified relays -bool TMoverParameters::RelayReset(int const Relays, range_t const Notify) +bool physics::Vehicle::RelayReset(int const Relays, range_t const Notify) { auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable}; @@ -1507,7 +1507,7 @@ bool TMoverParameters::RelayReset(int const Relays, range_t const Notify) // Q: 20160713 // Przeliczenie prędkości liniowej na obrotową // ************************************************************************************************* -double TMoverParameters::v2n(void) +double physics::Vehicle::v2n(void) { // przelicza predkosc liniowa na obrotowa const double dmgn = 0.5; @@ -1534,7 +1534,7 @@ double TMoverParameters::v2n(void) // Q: 20160714 // Oblicza moment siły wytwarzany przez silnik // ************************************************************************************************* -double TMoverParameters::Momentum(double I) const +double physics::Vehicle::Momentum(double I) const { // liczy moment sily wytwarzany przez silnik elektryczny} int SP; @@ -1551,7 +1551,7 @@ double TMoverParameters::Momentum(double I) const // Q: 20160714 // Oblicza moment siły do sterowania wzbudzeniem // ************************************************************************************************* -double TMoverParameters::MomentumF(double I, double Iw, int SCP) const +double physics::Vehicle::MomentumF(double I, double Iw, int SCP) const { // umozliwia dokladne sterowanie wzbudzeniem @@ -1562,7 +1562,7 @@ double TMoverParameters::MomentumF(double I, double Iw, int SCP) const // Q: 20160713 // Odłączenie uszkodzonych silników // ************************************************************************************************* -bool TMoverParameters::CutOffEngine(void) +bool physics::Vehicle::CutOffEngine(void) { bool COE = false; // Ra: wartość domyślna, sprawdzić to trzeba if (NPoweredAxles > 0 && CabActive == 0 && EngineType == TEngineType::ElectricSeriesMotor && DamageFlag.Clear(VehicleDamage::engine)) @@ -1577,7 +1577,7 @@ bool TMoverParameters::CutOffEngine(void) // Q: 20160713 // Przełączenie wysoki / niski prąd rozruchu // ************************************************************************************************* -bool TMoverParameters::MaxCurrentSwitch(bool State, range_t const Notify) +bool physics::Vehicle::MaxCurrentSwitch(bool State, range_t const Notify) { auto const initialstate{MotorOverloadRelayHighThreshold}; @@ -1595,7 +1595,7 @@ bool TMoverParameters::MaxCurrentSwitch(bool State, range_t const Notify) // Q: 20160713 // Przełączenie wysoki / niski prąd rozruchu automatycznego // ************************************************************************************************* -bool TMoverParameters::MinCurrentSwitch(bool State) +bool physics::Vehicle::MinCurrentSwitch(bool State) { bool MCS = false; if ((EngineType == TEngineType::ElectricSeriesMotor && IminHi > IminLo) || (TrainType == train_type::emu && EngineType != TEngineType::ElectricInductionMotor)) @@ -1623,7 +1623,7 @@ bool TMoverParameters::MinCurrentSwitch(bool State) // Q: 20160713 // Sprawdzenie wskaźnika jazdy na oporach // ************************************************************************************************* -bool TMoverParameters::ResistorsFlagCheck(void) const +bool physics::Vehicle::ResistorsFlagCheck(void) const { bool RFC = false; @@ -1642,7 +1642,7 @@ bool TMoverParameters::ResistorsFlagCheck(void) const // Q: 20160714 // Zwraca wartość natężenia prądu na wybranym amperomierzu. Podfunkcja do ShowCurrent. // ************************************************************************************************* -double TMoverParameters::ShowCurrentP(int AmpN) const +double physics::Vehicle::ShowCurrentP(int AmpN) const { int Bn; bool Grupowy; @@ -1677,7 +1677,7 @@ double TMoverParameters::ShowCurrentP(int AmpN) const } // the drive of the kind of engine of the vehicle -TractionDrive const &TMoverParameters::Drive() const +TractionDrive const &physics::Vehicle::Drive() const { return DriveOf(EngineType); } diff --git a/physics/couplerphysics.h b/physics/couplerphysics.h index 8d7f9b06e..d7278cf63 100644 --- a/physics/couplerphysics.h +++ b/physics/couplerphysics.h @@ -4,7 +4,7 @@ #include // the physical model of the coupling of two vehicles, used with couplerphysics set in eu07.ini (the legacy model of -// TMoverParameters::CouplerForce() otherwise). each vehicle end brings its buffers and its draw gear: progressive +// physics::Vehicle::CouplerForce() otherwise). each vehicle end brings its buffers and its draw gear: progressive // springs with friction hysteresis, pressed in series against those of the other end. the coupling has play (slack) // in tension, or pulls the buffers in when its screw is tightened, and its steel link stretches for good past its // yield force and breaks at its ultimate one, under a steady pull or the jerk of a run-out of the slack diff --git a/physics/derailment.h b/physics/derailment.h index e25e027cc..d0b095b0d 100644 --- a/physics/derailment.h +++ b/physics/derailment.h @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. // the criteria of a vehicle leaving the rails, as plain functions of what the vehicle and the track under it are // like, so the collisions and the buckled track can use them as well as the speed in a curve does -// (physics.derailment new in eu07.ini, see TMoverParameters::check_derailment()). two ways off the rails: +// (physics.derailment new in eu07.ini, see physics::Vehicle::check_derailment()). two ways off the rails: // // overturning: the lateral acceleration the cant doesn't balance, a = v^2 / R - g * sin(cant), takes the load off the // inner wheels; the unloading ratio D = dQ / Q = 2 / s * a / g * (h + s_flex * (h - h_c)) reaches 1 when they lift. @@ -112,7 +112,7 @@ struct vehicle_state { std::array ends{}; }; -// the dtrack_* flags of the track (mover.h) the criteria look at +// the dtrack_* flags of the track (vehicle.h) the criteria look at namespace track_damage { inline constexpr int railwear{2}; inline constexpr int freerail{4}; diff --git a/physics/mover.h b/physics/vehicle.h similarity index 98% rename from physics/mover.h rename to physics/vehicle.h index 439574ce6..1b2f5c8d8 100644 --- a/physics/mover.h +++ b/physics/vehicle.h @@ -28,6 +28,10 @@ http://mozilla.org/MPL/2.0/. class TractionDrive; class cParser; +namespace physics +{ +class Vehicle; +} /* MaSzyna EU07 locomotive simulator Copyright (C) 2001-2004 Maciej Czapkiewicz and others @@ -202,8 +206,8 @@ enum class TPowerSource struct engine_generator { // ld inputs - /// Pointer to the prime-mover revolutions [rev/s]. - double *engine_revolutions; // revs per second of the prime mover + /// Pointer to the prime-physics revolutions [rev/s]. + double *engine_revolutions; // revs per second of the prime physics // config /// Minimum working rev rate [rev/s]. double revolutions_min; // min working revolutions rate, in revs per second @@ -227,7 +231,7 @@ struct TAccumulator double MaxCapacity; /// Source used to recharge the battery. TPowerSource RechargeSource; - // inline _mover__1() { + // inline _vehicle__1() { // MaxCapacity = 0.0; // RechargeSource = NotDefined; // } @@ -240,7 +244,7 @@ struct TPowerCable TPowerType PowerTrans; /// Steam pressure (when SteamPower is transmitted) [bar]. double SteamPressure; - // inline _mover__2() { + // inline _vehicle__2() { // SteamPressure = 0.0; // PowerTrans = NoPower; // } @@ -488,7 +492,7 @@ struct TCoupling /*zmienne*/ bool AutomaticCouplingAllowed{true}; // whether automatic coupling can be currently performed CouplingSet CouplingFlag; // what the coupling joins; none: the vehicles only see each other - class TMoverParameters *Connected = nullptr; /*co jest podlaczone*/ + class physics::Vehicle *Connected = nullptr; /*co jest podlaczone*/ int ConnectedNr = 0; // Ra: od której strony podłączony do (Connected): 0=przód, 1=tył // the end of the vehicle connected to, while there is one VehicleEnd ConnectedEnd() const @@ -604,7 +608,10 @@ struct speed_control double PowerDownSpeed = 1000; }; -class TMoverParameters +namespace physics +{ + +class Vehicle { // Ra: wrapper na kod pascalowy, przejmujący jego funkcje Q: 20160824 - juz nie wrapper a klasa bazowa :) private: // types @@ -1303,7 +1310,7 @@ class TMoverParameters bool PantAllDown{false}; double PantFrontVolt = 0.0; // pantograf pod napieciem? 'Winger 160404 double PantRearVolt = 0.0; - // TODO converter parameters, for when we start cleaning up mover parameters + // TODO converter parameters, for when we start cleaning up physics parameters start_t ConverterStart{start_t::manual}; // whether converter is started manually, or by other means float ConverterStartDelay{0.0f}; // delay (in seconds) before the converter is started, once its activation conditions are met double ConverterStartDelayTimer{0.0}; // helper, for tracking whether converter start delay passed @@ -1599,11 +1606,11 @@ class TMoverParameters bool AIHintPantUpIfIdle{true}; // whether raise both pantographs if idling for a while double AIHintLocalBrakeAccFactor{1.05}; // suggested acceleration weight for local brake operation - TMoverParameters(double VelInitial, std::string const &TypeNameInit, std::string const &NameInit, int Cab); + Vehicle(double VelInitial, std::string const &TypeNameInit, std::string const &NameInit, int Cab); // obsługa sprzęgów - static double CouplerDist(TMoverParameters const *Left, TMoverParameters const *Right); + static double CouplerDist(physics::Vehicle const *Left, physics::Vehicle const *Right); static double Distance(const TLocation &Loc1, const TLocation &Loc2, const TDimension &Dim1, const TDimension &Dim2); - bool Attach(int ConnectNo, int ConnectToNr, TMoverParameters *ConnectTo, CouplingSet CouplingType, bool Enforce = false, bool Audible = true); + bool Attach(int ConnectNo, int ConnectToNr, physics::Vehicle *ConnectTo, CouplingSet CouplingType, bool Enforce = false, bool Audible = true); int DettachStatus(int ConnectNo); int DettachStatus(VehicleEnd const ConnectNo) { @@ -1611,7 +1618,7 @@ class TMoverParameters } bool Dettach(int ConnectNo); // the same by the ends, where they are known to be ends - bool Attach(VehicleEnd const ConnectNo, VehicleEnd const ConnectToNr, TMoverParameters *ConnectTo, CouplingSet CouplingType, bool Enforce = false, bool Audible = true) + bool Attach(VehicleEnd const ConnectNo, VehicleEnd const ConnectToNr, physics::Vehicle *ConnectTo, CouplingSet CouplingType, bool Enforce = false, bool Audible = true) { return Attach(NumberOf(ConnectNo), NumberOf(ConnectToNr), ConnectTo, CouplingType, Enforce, Audible); } @@ -1873,7 +1880,7 @@ class TMoverParameters double GetScndDVc(double dt); int ScndPipeCouplersSubsteps(double dt) const; // the air exchange through the brake and main reservoir hoses, after the vehicles stepped - static void UpdatePipeCouplers(std::vector const &Vehicles, double dt); + static void UpdatePipeCouplers(std::vector const &Vehicles, double dt); /*funkcje obliczajace sily*/ void ComputeConstans(void); // ABu: wczesniejsze wyznaczenie stalych dla liczenia sil @@ -1936,30 +1943,30 @@ class TMoverParameters double coupler_force_physical(VehicleEnd const End, double const dt); // with the physical model: whether the vehicles at the end hit the stop of their springs at the last update and // still close in on it, so that they collide; a hit hard enough breaks the coupling or crushes the buffers - bool coupler_stop_hit(VehicleEnd const End, TMoverParameters &Other, VehicleEnd const OtherEnd); + bool coupler_stop_hit(VehicleEnd const End, physics::Vehicle &Other, VehicleEnd const OtherEnd); // couples the automatic couplers of the end and of the other vehicle pressed against each other, unless the hit // is too fast for them to catch - void automatic_coupling(VehicleEnd const End, TMoverParameters &Other, VehicleEnd const OtherEnd); + void automatic_coupling(VehicleEnd const End, physics::Vehicle &Other, VehicleEnd const OtherEnd); void CollisionDetect(VehicleEnd const End, double const dt); // closing speed of a collision [km/h] above which the vehicles involved may derail, adjusted for their mass ratio static constexpr double SafeCollisionVelocity{15.0}; // closing speed [km/h] of the End of this vehicle and the OtherEnd of the other vehicle it touches, along the coupler // axis: the sum of the speeds in a head-on collision, the difference in a rear-end one, negative when they part - double CollisionVelocity(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd) const; + double CollisionVelocity(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const; // velocity [m/s] of this vehicle relative to the other vehicle it touches with its End and the OtherEnd of the // other one, along this vehicle's axis - double CouplerVelocityDifference(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd) const; + double CouplerVelocityDifference(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const; // whether the automatic couplers at the End of this vehicle and the OtherEnd of the other one can catch each other on // contact, rather than the vehicles colliding (with crash damage enabled, only at a closing speed which doesn't derail them) - bool AutomaticCouplingSafe(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd) const; + bool AutomaticCouplingSafe(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const; // whether the control coupling (multiple-unit control) can join the End of this vehicle and the OtherEnd of the other // one: not between an electric and a diesel traction vehicle, unless both couplers name the same control system // (ControlType). Vehicles without own traction (cars, control trailers) take any. Global.control_coupling_engine_check // off allows it always (eu07/maszyna#520) - bool ControlCouplingAllowed(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd) const; + bool ControlCouplingAllowed(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const; // the CouplingType to join the End of this vehicle and the OtherEnd of the other one with, without the control coupling // when ControlCouplingAllowed() rules it out. a permanent coupling (of the vehicles of one unit) is kept whole - CouplingSet CompatibleCoupling(VehicleEnd const End, TMoverParameters const &Other, VehicleEnd const OtherEnd, CouplingSet const CouplingType) const; + CouplingSet CompatibleCoupling(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd, CouplingSet const CouplingType) const; // the horns of the Signal (WarningSignal bits) which have the air or the voltage they need to sound int SoundingHorns(int const Signal) const; // whether the signal lamps of the main circuit (line contactors, ground relay, motor overload relays) can light: @@ -2308,6 +2315,8 @@ class TMoverParameters void BrakeSubsystemDecode(); // Q 20160719 }; +} // namespace physics + // double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2); namespace simulation diff --git a/rendering/common/locallights.cpp b/rendering/common/locallights.cpp index 5f04155cf..524dbb6e4 100644 --- a/rendering/common/locallights.cpp +++ b/rendering/common/locallights.cpp @@ -29,7 +29,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/Train.h" #include "simulation/simulation.h" #include "rendering/geometrybank.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace { @@ -374,7 +374,7 @@ void gfx::local_lights::gather_vehicle(TDynamicObject *Vehicle, glm::dvec3 const { auto const &name{section.compartment->pName}; cabsection &= (name.size() >= 4) && name.starts_with("cab"); - auto const level{section.light_level * (cabsection ? 1.f : Vehicle->MoverParameters->CompartmentLights.intensity)}; + auto const level{section.light_level * (cabsection ? 1.f : Vehicle->physics->CompartmentLights.intensity)}; if ((level <= 0.f) || (Global.fLuminance > section.compartment->fLight) || (section.compartment->iVisible == 0)) { continue; diff --git a/rendering/common/localshadows.cpp b/rendering/common/localshadows.cpp index 49ce195ce..7e0d780c1 100644 --- a/rendering/common/localshadows.cpp +++ b/rendering/common/localshadows.cpp @@ -18,7 +18,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "vehicle/Train.h" #include "rendering/common/skyocclusion.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace gfx { @@ -584,7 +584,7 @@ std::vector const &local_shadows::pick_headli if (std::max(beam.r, std::max(beam.g, beam.b)) <= 0.f) continue; // the part of the beam the shadows are cast in: from the end of the vehicle to the reach ahead of it - auto const &dimensions{light.owner->MoverParameters->Dim}; + auto const &dimensions{light.owner->physics->Dim}; auto const radius{range * 0.5 + std::max(dimensions.W, dimensions.H) + 2.0}; auto const centre{light.position + glm::dvec3{light.direction} * (range * 0.5 + 2.0)}; if (glm::length(centre - camera) - radius > range) diff --git a/rendering/common/scenewalk.cpp b/rendering/common/scenewalk.cpp index cb1b5621f..de01564f4 100644 --- a/rendering/common/scenewalk.cpp +++ b/rendering/common/scenewalk.cpp @@ -30,7 +30,7 @@ http://mozilla.org/MPL/2.0/. #include "model/AnimModel.h" #include "model/Model3d.h" #include "rendering/common/skyocclusion.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -295,8 +295,8 @@ bool scene_walk::Render_coupler_adapter( TDynamicObject *Dynamic, float const Sq auto const position { glm::dvec3 { 0.f, - Dynamic->MoverParameters->Couplers[ End ].adapter_height, - ( Dynamic->MoverParameters->Couplers[ End ].adapter_length + Dynamic->MoverParameters->Dim.L * 0.5 ) * ( End == VehicleEnd::front ? 1 : -1 ) } }; + Dynamic->physics->Couplers[ End ].adapter_height, + ( Dynamic->physics->Couplers[ End ].adapter_length + Dynamic->physics->Dim.L * 0.5 ) * ( End == VehicleEnd::front ? 1 : -1 ) } }; auto const angle { glm::vec3{ 0, diff --git a/rendering/common/screenreflections.cpp b/rendering/common/screenreflections.cpp index 0976305b5..e519b21ff 100644 --- a/rendering/common/screenreflections.cpp +++ b/rendering/common/screenreflections.cpp @@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "gl/ubo.h" #include "utilities/Globals.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace { @@ -60,7 +60,7 @@ void gfx::screen_reflections::begin_frame(glm::mat4 const &Projection, glm::dmat { m_reprojectioncab = glm::mat4{m_history.projection * glm::dmat4{m_history.view} * m_history.cab * glm::inverse(m_current.cab) * toworld}; // the vehicle stands on the origin of its model, along z, up to its height - auto const &dimensions{Cab->MoverParameters->Dim}; + auto const &dimensions{Cab->physics->Dim}; glm::dvec3 const lower{-0.5 * dimensions.W - CAB_BOX_MARGIN, -CAB_BOX_MARGIN, -0.5 * dimensions.L - CAB_BOX_MARGIN}; glm::dvec3 const upper{0.5 * dimensions.W + CAB_BOX_MARGIN, dimensions.H + CAB_BOX_MARGIN, 0.5 * dimensions.L + CAB_BOX_MARGIN}; auto const centre{0.5 * (lower + upper)}; diff --git a/rendering/common/windscreenwater.cpp b/rendering/common/windscreenwater.cpp index 78d3a2edc..619b6bf33 100644 --- a/rendering/common/windscreenwater.cpp +++ b/rendering/common/windscreenwater.cpp @@ -19,7 +19,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "vehicle/DynObj.h" #include "vehicle/Train.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace gfx { @@ -340,7 +340,7 @@ void windscreen_water::update(double const Seconds) // the blades of the wipers of the vehicle, as the glasses read them (the channels of the mask follow the wipers of the cab // the vehicle is driven from) glm::vec4 blades{-1.f}; - if (auto const cabactive{vehicle->MoverParameters->CabActive}; cabactive != 0) + if (auto const cabactive{vehicle->physics->CabActive}; cabactive != 0) { auto const count{static_cast(vehicle->dWiperPos.size())}; for (int i = 0; i < 4; ++i) @@ -356,7 +356,7 @@ void windscreen_water::update(double const Seconds) auto const toworld{glm::dmat3{vehicle->mMatrix}}; auto const tomodel{glm::inverse(toworld)}; auto const up{glm::normalize(glm::vec3{tomodel * glm::dvec3{0.0, 1.0, 0.0}})}; - auto const air{glm::vec3{tomodel * (glm::dvec3{simulation::Environment.wind()} * WIND_SHARE - vehicle->VectorFront() * vehicle->MoverParameters->V)}}; + auto const air{glm::vec3{tomodel * (glm::dvec3{simulation::Environment.wind()} * WIND_SHARE - vehicle->VectorFront() * vehicle->physics->V)}}; auto const heavy{std::clamp(Global.Overcast - 1.f, 0.f, 1.f)}; auto const snow{Global.Weather == "snow:"}; auto const fall{snow ? SNOW_FALL : RAIN_FALL}; diff --git a/rendering/lightarray.cpp b/rendering/lightarray.cpp index eef1c6a2f..8e9b561ff 100644 --- a/rendering/lightarray.cpp +++ b/rendering/lightarray.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "rendering/lightarray.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" void light_array::insert( TDynamicObject const *Owner ) { @@ -52,11 +52,11 @@ light_array::update() { light.direction.z = -light.direction.z; } // determine intensity of this light set - if( ( true == light.owner->MoverParameters->Power24vIsAvailable ) - || ( true == light.owner->MoverParameters->Power110vIsAvailable ) ) { + if( ( true == light.owner->physics->Power24vIsAvailable ) + || ( true == light.owner->physics->Power110vIsAvailable ) ) { // with power on, the intensity depends on the state of activated switches // first we cross-check the list of enabled lights with the lights installed in the vehicle... - auto const lights { light.owner->MoverParameters->iLights[ light.index ] & light.owner->LightList( static_cast( light.index ) ) }; + auto const lights { light.owner->physics->iLights[ light.index ] & light.owner->LightList( static_cast( light.index ) ) }; // ...then check their individual state light.count = 0 + ( ( lights & light::headlight_left ) ? 1 : 0 ) @@ -71,13 +71,13 @@ light_array::update() { light.intensity = std::max(0.0f, std::log((float)light.count + 1.0f)); if (light.owner->DimHeadlights && !light.owner->HighBeamLights && isEnabled) // tylko przyciemnione - light.intensity *= static_cast(light.owner->MoverParameters->dimMultiplier); + light.intensity *= static_cast(light.owner->physics->dimMultiplier); else if (!light.owner->DimHeadlights && !light.owner->HighBeamLights && isEnabled) // normalne - light.intensity *= static_cast(light.owner->MoverParameters->normMultiplier); + light.intensity *= static_cast(light.owner->physics->normMultiplier); else if (light.owner->DimHeadlights && light.owner->HighBeamLights && isEnabled) // przyciemnione dlugie - light.intensity *= static_cast(light.owner->MoverParameters->highDimMultiplier); + light.intensity *= static_cast(light.owner->physics->highDimMultiplier); else if (!light.owner->DimHeadlights && light.owner->HighBeamLights && isEnabled) // dlugie zwykle - light.intensity *= static_cast(light.owner->MoverParameters->highMultiplier); + light.intensity *= static_cast(light.owner->physics->highMultiplier); else if (!isEnabled) { light.intensity = 0.0f; @@ -90,19 +90,19 @@ light_array::update() { ( ( lights & light::headlight_right | light::highbeamlight_right) ? 1.f : 0.f ) }; light.color = { - static_cast(light.owner->MoverParameters->refR) / 255.0f, - static_cast(light.owner->MoverParameters->refG) / 255.0f, - static_cast(light.owner->MoverParameters->refB) / 255.0f + static_cast(light.owner->physics->refR) / 255.0f, + static_cast(light.owner->physics->refG) / 255.0f, + static_cast(light.owner->physics->refB) / 255.0f }; if (light.owner->DimHeadlights && !light.owner->HighBeamLights) // tylko przyciemnione - light.state *= light.owner->MoverParameters->dimMultiplier; + light.state *= light.owner->physics->dimMultiplier; else if (!light.owner->DimHeadlights && !light.owner->HighBeamLights) // normalne - light.state *= light.owner->MoverParameters->normMultiplier; + light.state *= light.owner->physics->normMultiplier; else if (light.owner->DimHeadlights && light.owner->HighBeamLights) // przyciemnione dlugie - light.state *= light.owner->MoverParameters->highDimMultiplier; + light.state *= light.owner->physics->highDimMultiplier; else if (!light.owner->DimHeadlights && light.owner->HighBeamLights) // dlugie zwykle - light.state *= light.owner->MoverParameters->highMultiplier; + light.state *= light.owner->physics->highMultiplier; else if (!isEnabled) { light.state = glm::vec3{0.f}; diff --git a/rendering/opengl46/opengl46renderer.cpp b/rendering/opengl46/opengl46renderer.cpp index f2e611859..e1b65aa44 100644 --- a/rendering/opengl46/opengl46renderer.cpp +++ b/rendering/opengl46/opengl46renderer.cpp @@ -29,7 +29,7 @@ http://mozilla.org/MPL/2.0/. #include "rendering/opengl46/opengl46geometrybank.h" #include "rendering/screenshot.h" #include "rendering/editoroverlay.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include @@ -1682,16 +1682,16 @@ void opengl46_renderer::Render_pass(viewport_config &vp, rendermode const Mode) // vehicle (V is along the front of the vehicle) glm::dvec3 air{glm::dvec3{simulation::Environment.wind()} * 0.5}; if (TDynamicObject const *owner = Global.pCamera.m_owner) - air -= owner->VectorFront() * owner->MoverParameters->V; + air -= owner->VectorFront() * owner->physics->V; scene_ubs.rain_wind = glm::vec4{glm::vec3{air}, 0.f}; } - if (TDynamicObject const *owner = Global.pCamera.m_owner; owner && !!owner->MoverParameters->CabActive) + if (TDynamicObject const *owner = Global.pCamera.m_owner; owner && !!owner->physics->CabActive) { for (int i = 0; i < 4; ++i) { if (i < owner->dWiperPos.size()) { - int index = owner->MoverParameters->CabActive > 0 ? i : static_cast(owner->dWiperPos.size() - 1) - i; + int index = owner->physics->CabActive > 0 ? i : static_cast(owner->dWiperPos.size() - 1) - i; scene_ubs.wiper_pos[i] = owner->dWiperPos[index]; if (owner->dWiperPos[index] > 0. && owner->wiperDirection[index]) { @@ -6761,7 +6761,7 @@ void opengl46_renderer::Render_lamp_shadow(std::size_t const Slot, bool const Ve void opengl46_renderer::Headlight_Projector(light_array::light_record const &Light, glm::dvec3 &Position, glm::mat3 &Rotation, glm::mat4 &Projection, float &Near, float &Fieldofview) { - auto const &ownerdimensions{Light.owner->MoverParameters->Dim}; + auto const &ownerdimensions{Light.owner->physics->Dim}; auto const up{static_cast(Light.owner->VectorUp())}; auto const size{static_cast(std::max(ownerdimensions.W, ownerdimensions.H) * 1.0)}; // ensure square ratio auto const cone{5.f}; diff --git a/rendering/particles.cpp b/rendering/particles.cpp index 391dd1903..c0245be12 100644 --- a/rendering/particles.cpp +++ b/rendering/particles.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "simulation/simulationenvironment.h" #include "utilities/Logs.h" #include "vehicle/smoke.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" @@ -176,7 +176,7 @@ smoke_source::accumulate_spawns( double const Timedelta, bool const Onlydespawn if( m_ownertype == owner_type::vehicle ) { - auto const &mover { *m_owner.vehicle->MoverParameters }; + auto const &physics { *m_owner.vehicle->physics }; // NOTE: the smoke keeps the colour of its template, cold engine or not. a grey for a cold engine was once meant // here, but the line compared instead of assigning; made an assignment, it set 128 on the 0-1 scale of the // emitter colour, so the smoke turned pure white, glowing at night, and never changed back @@ -185,7 +185,7 @@ smoke_source::accumulate_spawns( double const Timedelta, bool const Onlydespawn m_spawncount = ( ( true == spawning ) ? smoke::vehicle_spawn_count( - mover, m_owner.vehicle->bEnabled, + physics, m_owner.vehicle->bEnabled, { m_spawncount, m_spawnrate, Global.SmokeFidelity, static_cast( m_max_particles ) }, Timedelta ) : 0.f ); @@ -346,19 +346,19 @@ smoke_source::launch_scales( float &Velocity, float &Opacity ) const { Opacity = 1.f; if( m_ownertype != owner_type::vehicle ) { return; } - Opacity = static_cast(m_owner.vehicle->MoverParameters->diesel.fill); - if (m_owner.vehicle->MoverParameters->EngineType == TEngineType::DieselElectric) + Opacity = static_cast(m_owner.vehicle->physics->diesel.fill); + if (m_owner.vehicle->physics->EngineType == TEngineType::DieselElectric) { - if (m_owner.vehicle->MoverParameters->diesel.spinningUp == true) + if (m_owner.vehicle->physics->diesel.spinningUp == true) { - Velocity = static_cast(0.38*(((m_owner.vehicle->MoverParameters->enrot)/2)*0.5)); // / m_owner.vehicle->MoverParameters->diesel.fill *0.01)) ; + Velocity = static_cast(0.38*(((m_owner.vehicle->physics->enrot)/2)*0.5)); // / m_owner.vehicle->physics->diesel.fill *0.01)) ; } else { - Velocity = static_cast((((m_owner.vehicle->MoverParameters->enrot)/60)*0.6) * (m_owner.vehicle->MoverParameters->EnginePower *0.03)); // / m_owner.vehicle->MoverParameters->diesel.fill *0.01)) ; - //Particle.velocity *= m_owner.vehicle->GetVelocity(); // / m_owner.vehicle->MoverParameters->diesel.fill *0.01)) ; + Velocity = static_cast((((m_owner.vehicle->physics->enrot)/60)*0.6) * (m_owner.vehicle->physics->EnginePower *0.03)); // / m_owner.vehicle->physics->diesel.fill *0.01)) ; + //Particle.velocity *= m_owner.vehicle->GetVelocity(); // / m_owner.vehicle->physics->diesel.fill *0.01)) ; } } diff --git a/rendering/vulkan14/vulkan14frame.cpp b/rendering/vulkan14/vulkan14frame.cpp index 12f3cf9b0..6963dbd85 100644 --- a/rendering/vulkan14/vulkan14frame.cpp +++ b/rendering/vulkan14/vulkan14frame.cpp @@ -32,7 +32,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "utilities/utilities.h" #include "utilities/color.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include @@ -1569,16 +1569,16 @@ void vulkan14_renderer::render_viewport(std::size_t const Index) // vehicle (V is along the front of the vehicle) glm::dvec3 air{glm::dvec3{simulation::Environment.wind()} * 0.5}; if (TDynamicObject const *owner = Global.pCamera.m_owner) - air -= owner->VectorFront() * owner->MoverParameters->V; + air -= owner->VectorFront() * owner->physics->V; scene_ubs.rain_wind = glm::vec4{glm::vec3{air}, 0.f}; } - if (TDynamicObject const *owner = Global.pCamera.m_owner; owner && !!owner->MoverParameters->CabActive) + if (TDynamicObject const *owner = Global.pCamera.m_owner; owner && !!owner->physics->CabActive) { for (int i = 0; i < 4; ++i) { if (i < owner->dWiperPos.size()) { - int index = owner->MoverParameters->CabActive > 0 ? i : static_cast(owner->dWiperPos.size() - 1) - i; + int index = owner->physics->CabActive > 0 ? i : static_cast(owner->dWiperPos.size() - 1) - i; scene_ubs.wiper_pos[i] = owner->dWiperPos[index]; if (owner->dWiperPos[index] > 0. && owner->wiperDirection[index]) { @@ -4159,7 +4159,7 @@ void vulkan14_renderer::write_local_light(gl::light_element &Light, gfx::local_l void vulkan14_renderer::headlight_projector(light_array::light_record const &Light, glm::dvec3 &Position, glm::mat3 &Rotation, glm::mat4 &Projection, float &Near, float &Fieldofview) { - auto const &ownerdimensions{Light.owner->MoverParameters->Dim}; + auto const &ownerdimensions{Light.owner->physics->Dim}; auto const up{static_cast(Light.owner->VectorUp())}; auto const size{static_cast(std::max(ownerdimensions.W, ownerdimensions.H) * 1.0)}; auto const cone{5.f}; diff --git a/scene/scene.cpp b/scene/scene.cpp index 3f67b4d31..03b10d8f1 100644 --- a/scene/scene.cpp +++ b/scene/scene.cpp @@ -24,7 +24,7 @@ http://mozilla.org/MPL/2.0/. #include "rendering/renderer.h" #include "widgets/map_objects.h" #include "vehicle/aiwire.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #include @@ -131,12 +131,12 @@ basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex // i do tego jeszcze wejdzie pod ślizg if( fHorizontal <= 0.0 ) { // 0.635 dla AKP-1 AKP-4E - Vehicle->MoverParameters->DamageFlag.Set(VehicleDamage::pantograph); + Vehicle->physics->DamageFlag.Set(VehicleDamage::pantograph); pantograph->PantWys = -1.0; // ujemna liczba oznacza połamanie pantograph->hvPowerWire = nullptr; // bo inaczej się zasila w nieskończoność z połamanego - if( Vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { + if( Vehicle->physics->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { // liczba pantografów teraz będzie mniejsza - --Vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo; + --Vehicle->physics->EnginePowerSource.CollectorParameters.CollectorsNo; } ErrorLog( "Bad traction: " + Vehicle->name() + " broke pantograph at " + to_string( pantographposition ), logtype::traction ); diff --git a/scripting/lua.cpp b/scripting/lua.cpp index 27224605f..93e542742 100644 --- a/scripting/lua.cpp +++ b/scripting/lua.cpp @@ -7,7 +7,7 @@ #include "simulation/simulation.h" #include "scripting/luasandbox.h" #include "utilities/utilities.h" -#include "physics/mover.h" +#include "physics/vehicle.h" lua::lua() { @@ -351,7 +351,7 @@ int lua::scriptapi_dynobj_putvalues(lua_State *L) if (dyn->Mechanik) dyn->Mechanik->PutCommand(str, num1, num2, loc); else - dyn->MoverParameters->PutCommand(str, num1, num2, loc); + dyn->physics->PutCommand(str, num1, num2, loc); return 0; } diff --git a/simulation/blackboxrecorder.cpp b/simulation/blackboxrecorder.cpp index be6fc0000..9f8a44378 100644 --- a/simulation/blackboxrecorder.cpp +++ b/simulation/blackboxrecorder.cpp @@ -26,7 +26,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/physicslog.h" #include "utilities/utilities.h" #include "world/stationnames.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include @@ -70,7 +70,7 @@ blackbox::driver driver_of(TDynamicObject const &Vehicle) { } // the switches of the user's train: those of its own vehicle, and those of the one with the motors it drives -std::uint32_t devices_of(TMoverParameters const &Occupied, TMoverParameters const &Controlling) { +std::uint32_t devices_of(physics::Vehicle const &Occupied, physics::Vehicle const &Controlling) { namespace device = blackbox::cab_devices; auto const on{[](bool const State, std::uint32_t const Bit) { return State ? Bit : 0u; }}; return on(Occupied.Battery || Controlling.Battery, device::battery) | on(Controlling.Mains, device::main_breaker) | @@ -90,8 +90,8 @@ std::uint32_t devices_of(TMoverParameters const &Occupied, TMoverParameters cons on(Controlling.diesel.heat.engine_is_hot, device::engine_hot) | on(Controlling.SpeedCtrl && Controlling.SpeedCtrlUnit.IsActive, device::speed_control); } -std::uint8_t engine_of(TMoverParameters const &Mover) { - switch (Mover.EngineType) { +std::uint8_t engine_of(physics::Vehicle const &Physics) { + switch (Physics.EngineType) { case TEngineType::ElectricSeriesMotor: return blackbox::engines::electric; case TEngineType::ElectricInductionMotor: @@ -109,10 +109,10 @@ std::uint8_t engine_of(TMoverParameters const &Mover) { // the lights at an end of the train: of its head or of its tail, at the end of that vehicle turned away from the rest std::uint16_t outward_lights(TDynamicObject const *Vehicle, bool const Head) { - if (Vehicle == nullptr || Vehicle->MoverParameters == nullptr) + if (Vehicle == nullptr || Vehicle->physics == nullptr) return 0; auto const along{Vehicle->iDirection > 0}; - return static_cast(Vehicle->MoverParameters->iLights[Head == along ? VehicleEnd::front : VehicleEnd::rear]); + return static_cast(Vehicle->physics->iLights[Head == along ? VehicleEnd::front : VehicleEnd::rear]); } // the lamps the vehicle has at that end: the driver checks a pattern against those of it there are @@ -206,9 +206,9 @@ bool coupled(TDynamicObject const *From, TDynamicObject const *To) { auto side{start}; // going on away from the first vehicle: through the coupler opposite the one each was reached by for (int step = 0; step < 1000 && vehicle != nullptr; ++step) { - auto const *mover{vehicle->MoverParameters}; - auto const &neighbour{mover->Neighbours[side]}; - if (mover->Couplers[side].CouplingFlag.Empty() || neighbour.vehicle == nullptr) + auto const *physics{vehicle->physics}; + auto const &neighbour{physics->Neighbours[side]}; + if (physics->Couplers[side].CouplingFlag.Empty() || neighbour.vehicle == nullptr) break; if (neighbour.vehicle == To) return true; @@ -225,7 +225,7 @@ blackbox::vehicle_state state_of(TDynamicObject const &Vehicle, std::uint32_t co state.position = glm::vec3{Vehicle.GetPosition()}; auto const front{Vehicle.VectorFront()}; state.heading = static_cast(std::atan2(front.x, front.z)); - state.speed_kmh = static_cast(Vehicle.MoverParameters->V * 3.6); + state.speed_kmh = static_cast(Vehicle.physics->V * 3.6); state.driving = driver_of(Vehicle); return state; } @@ -415,7 +415,7 @@ void blackbox_recorder::write_cab() { if (train == nullptr || train->Dynamic() == nullptr) return; auto const *vehicle{train->Dynamic()}; - auto const *occupied{vehicle->MoverParameters}; + auto const *occupied{vehicle->physics}; // the one which drives the consist, as the driving aid tells it auto const *owner{vehicle->ctOwner != nullptr ? vehicle->ctOwner : vehicle->Mechanik}; auto const *controlling{owner != nullptr ? owner->Controlling() : occupied}; @@ -431,7 +431,7 @@ void blackbox_recorder::write_cab() { // the vehicle itself, if none in the unit is powered auto const *powered{train->Dynamic()->FindPowered()}; auto const facing{powered->DirectionGet() * vehicle->DirectionGet()}; - sample.wheel_speed_kmh = static_cast(facing * M_PI * powered->MoverParameters->WheelDiameter * powered->MoverParameters->nrot * 3.6); + sample.wheel_speed_kmh = static_cast(facing * M_PI * powered->physics->WheelDiameter * powered->physics->nrot * 3.6); sample.acceleration = static_cast(controlling->AccS); sample.lateral_acceleration = static_cast(occupied->AccN); if (owner != nullptr && owner->is_train()) { @@ -494,8 +494,8 @@ void blackbox_recorder::write_cab() { // the brakes of the whole train: the highest of its cylinders, from the head to the tail auto brakes{occupied->BrakePress}; for (auto const *each{owner != nullptr ? owner->Vehicle(VehicleEnd::front) : nullptr}; each != nullptr; each = each->Next()) - if (each->MoverParameters != nullptr) - brakes = std::max(brakes, each->MoverParameters->BrakePress); + if (each->physics != nullptr) + brakes = std::max(brakes, each->physics->BrakePress); sample.consist_brake_cylinder = static_cast(brakes); m_writer->cab(sample); } @@ -528,7 +528,7 @@ void blackbox_recorder::look_around(bool const Keyframe) { auto *train{simulation::Train}; auto const uservehicle{train != nullptr && train->Dynamic() != nullptr ? vehicle_id(train->Dynamic()) : blackbox::no_vehicle}; auto const userincab{uservehicle != blackbox::no_vehicle && false == FreeFlyModeFlag}; - auto const usercab{uservehicle != blackbox::no_vehicle ? static_cast(train->Dynamic()->MoverParameters->CabOccupied) : std::int8_t{0}}; + auto const usercab{uservehicle != blackbox::no_vehicle ? static_cast(train->Dynamic()->physics->CabOccupied) : std::int8_t{0}}; if (false == m_userknown || uservehicle != m_uservehicle || userincab != m_userincab || usercab != m_usercab) { m_writer->user_vehicle(m_time, uservehicle, userincab, usercab); m_uservehicle = uservehicle; @@ -582,7 +582,7 @@ void blackbox_recorder::look_at_derailments() { for (auto *vehicle : simulation::Vehicles.sequence()) { if (false == vehicle->bEnabled) continue; - auto const &motion{vehicle->MoverParameters->OffTrack}; + auto const &motion{vehicle->physics->OffTrack}; auto const id{vehicle_id(vehicle)}; auto &entry{m_vehicles[vehicle]}; if (false == motion.active()) { @@ -598,7 +598,7 @@ void blackbox_recorder::look_at_derailments() { state.cause = cause_of(motion.reason()); state.position = vehicle->GetPosition(); state.heading = static_cast(std::atan2(vehicle->VectorFront().x, vehicle->VectorFront().z)); - state.speed_kmh = static_cast(vehicle->MoverParameters->V * 3.6); + state.speed_kmh = static_cast(vehicle->physics->V * 3.6); state.offset = static_cast(vehicle->off_track_offset()); state.roll = static_cast(motion.roll()); state.travelled = static_cast(motion.travelled()); @@ -617,12 +617,12 @@ void blackbox_recorder::look_at_couplers() { if (false == vehicle->bEnabled) continue; auto &entry{m_vehicles[vehicle]}; - auto const *mover{vehicle->MoverParameters}; + auto const *physics{vehicle->physics}; for (int side = 0; side < 2; ++side) { - auto const flags{mover->Couplers[side].CouplingFlag}; + auto const flags{physics->Couplers[side].CouplingFlag}; // a neighbour not coupled is only seen on the same track - auto const *other{false == flags.Empty() ? mover->Neighbours[side].vehicle : nullptr}; - coupler_entry const now{other, other != nullptr ? mover->Neighbours[side].vehicle_end : 0, other != nullptr ? flags.Bits() : 0}; + auto const *other{false == flags.Empty() ? physics->Neighbours[side].vehicle : nullptr}; + coupler_entry const now{other, other != nullptr ? physics->Neighbours[side].vehicle_end : 0, other != nullptr ? flags.Bits() : 0}; auto &last{entry.couplers[side]}; auto const changed{now.other != last.other || now.other_side != last.other_side || now.flags != last.flags}; auto const before{last}; @@ -764,11 +764,11 @@ std::uint32_t blackbox_recorder::vehicle_id(TDynamicObject const *Vehicle) { auto &entry{m_vehicles[Vehicle]}; entry.id = m_nextvehicle++; - auto const *mover{Vehicle->MoverParameters}; + auto const *physics{Vehicle->physics}; auto const *driver{Vehicle->Mechanik}; auto const train{driver != nullptr && driver->TrainName() != "none" ? driver->TrainName() : std::string{}}; - m_writer->vehicle({entry.id, text_of(Vehicle->name()), text_of(mover->TypeName), text_of(train), static_cast(mover->Dim.L), static_cast(mover->Dim.W), - static_cast(mover->CategoryFlag)}); + m_writer->vehicle({entry.id, text_of(Vehicle->name()), text_of(physics->TypeName), text_of(train), static_cast(physics->Dim.L), static_cast(physics->Dim.W), + static_cast(physics->CategoryFlag)}); return entry.id; } diff --git a/simulation/simulation.cpp b/simulation/simulation.cpp index ab3ec3a56..82ae73792 100644 --- a/simulation/simulation.cpp +++ b/simulation/simulation.cpp @@ -37,7 +37,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "vehicle/Driver.h" #include "world/catenary_scene.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace simulation { @@ -244,13 +244,13 @@ void state_manager::process_commands() { TDynamicObject *vehicle = found_vehicle; while (vehicle) { - vehicle->MoverParameters->Hamulec->Releaser(commanddata.action != GLFW_RELEASE ? 1 : 0); + vehicle->physics->Hamulec->Releaser(commanddata.action != GLFW_RELEASE ? 1 : 0); vehicle = vehicle->Next(); } vehicle = found_vehicle; while (vehicle) { - vehicle->MoverParameters->Hamulec->Releaser(commanddata.action != GLFW_RELEASE ? 1 : 0); + vehicle->physics->Hamulec->Releaser(commanddata.action != GLFW_RELEASE ? 1 : 0); vehicle = vehicle->Prev(); } } @@ -436,11 +436,11 @@ void state_manager::process_commands() { while (vehicle) { // no damage, back on the rails with the state of the derailment cleared - vehicle->MoverParameters->repair_damage(); - vehicle->MoverParameters->V = 0.000001; // HACK: force vehicle position re-calculation - vehicle->MoverParameters->DistCounter = 0.0; - vehicle->MoverParameters->OffsetTrackH = 0.0; - vehicle->MoverParameters->OffsetTrackV = 0.0; + vehicle->physics->repair_damage(); + vehicle->physics->V = 0.000001; // HACK: force vehicle position re-calculation + vehicle->physics->DistCounter = 0.0; + vehicle->physics->OffsetTrackH = 0.0; + vehicle->physics->OffsetTrackV = 0.0; // pantographs for( auto idx = 0; idx < vehicle->iAnimType[ ANIM_PANTS ]; ++idx ) { @@ -461,13 +461,13 @@ void state_manager::process_commands() { if (commanddata.command == user_command::repaircoupler) { if (auto *vehicle{simulation::Vehicles.find(commanddata.payload)}; vehicle != nullptr) { - vehicle->MoverParameters->repair_coupler(EndOf(static_cast(commanddata.param1)) == VehicleEnd::rear ? VehicleEnd::rear : VehicleEnd::front); + vehicle->physics->repair_coupler(EndOf(static_cast(commanddata.param1)) == VehicleEnd::rear ? VehicleEnd::rear : VehicleEnd::front); } } if (commanddata.command == user_command::fillcompressor) { TDynamicObject *vehicle = simulation::Vehicles.find(commanddata.payload); - vehicle->MoverParameters->CompressedVolume = 8.0f * vehicle->MoverParameters->VeselVolume; + vehicle->physics->CompressedVolume = 8.0f * vehicle->physics->VeselVolume; } if (commanddata.command == user_command::dynamicmove) { @@ -497,7 +497,7 @@ void state_manager::process_commands() { double offset = 0.0; while (vehicle) { - offset += vehicle->MoverParameters->Dim.L; + offset += vehicle->physics->Dim.L; vehicle->place_on_track(track, offset, false); vehicle = vehicle->Prev(); } @@ -510,7 +510,7 @@ void state_manager::process_commands() { if (commanddata.command == user_command::pullalarmchain) { TDynamicObject *vehicle = simulation::Vehicles.find(commanddata.payload); if (vehicle) - vehicle->MoverParameters->AlarmChainSwitch(true); + vehicle->physics->AlarmChainSwitch(true); } if (commanddata.command == user_command::sendaicommand) { diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index a12113496..848e1d655 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -37,7 +37,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "utilities/utilities.h" #include "editor/editorTerrainStreamer.hpp" -#include "physics/mover.h" +#include "physics/vehicle.h" #include @@ -47,7 +47,7 @@ namespace { double vehicle_length( std::string const &Folder, std::string const &Type ) { - TMoverParameters probe( 0.0, Type, Type, 0 ); + physics::Vehicle probe( 0.0, Type, Type, 0 ); return probe.LoadFIZ( paths::dynamic + Folder + "/" ) ? probe.Dim.L : 0.0; } @@ -579,7 +579,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch ErrorLog( "Bad scenario: duplicate vehicle name \"" + vehicle->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } - if( vehicle->MoverParameters->CategoryFlag == 1 // trains only + if( vehicle->physics->CategoryFlag == 1 // trains only && ( (vehicle->LightList(VehicleEnd::front) & (light::headlight_left | light::headlight_right | light::headlight_upper)) != 0 || (vehicle->LightList(VehicleEnd::rear) & (light::headlight_left | light::headlight_right | light::headlight_upper)) != 0 ) ) { simulation::Lights.insert( vehicle ); @@ -1692,7 +1692,7 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra } // automatically establish permanent connections for couplers which specify them in their definitions if( coupling != 0 - && vehicle->MoverParameters->Couplers[(offset == -1.0 ? VehicleEnd::front : VehicleEnd::rear)].AllowedFlag & Coupling::permanent ) { + && vehicle->physics->Couplers[(offset == -1.0 ? VehicleEnd::front : VehicleEnd::rear)].AllowedFlag & Coupling::permanent ) { coupling = ( CouplingSet::FromBits( coupling ) | Coupling::permanent ).Bits(); } if( true == Scratchpad.trainset.is_open ) { diff --git a/tests/unit/COVERAGE.md b/tests/unit/COVERAGE.md index 7299267c9..9757288a3 100644 --- a/tests/unit/COVERAGE.md +++ b/tests/unit/COVERAGE.md @@ -1,6 +1,6 @@ # Coverage of the simulation core by the unit tests -These tests characterise the physics of the vehicles (`physics/mover.cpp`, `brakes.cpp`, `oerlikonest.cpp`, `friction.cpp`). They exist to show that refactors of those files, such as splitting `TractionForce` or `RunCommand`, leave the behaviour as it was. This page lists: +These tests characterise the physics of the vehicles (`physics/physics.cpp`, `brakes.cpp`, `oerlikonest.cpp`, `friction.cpp`). They exist to show that refactors of those files, such as splitting `TractionForce` or `RunCommand`, leave the behaviour as it was. This page lists: - what the tests reach; - what nothing in the game ever runs; @@ -14,7 +14,7 @@ Coverage was measured on Windows with MSVC's SanitizerCoverage (`/fsanitize-cove | File | Blocks run, at the start | Now | |---|---|---| -| `mover.cpp` | 8.9% | 80.7% (3323 of 4118) | +| `physics.cpp` | 8.9% | 80.7% (3323 of 4118) | | `brakes.cpp` | 30% | 76.3% (649 of 851) | | `oerlikonest.cpp` | 58% | 87.4% (118 of 135) | | `friction.cpp` | 9% | 90.9% (10 of 11) | @@ -35,7 +35,7 @@ Nothing creates these objects or calls these functions anywhere in the game, whi - **Base implementations always overridden:** `TFricMat::GetFC` (every material, the default P10 too, has its own) and `TPrzekladnik::Update` (every relay has its own). - **Functions without callers:** - In `brakes.cpp`: `PF_old`, `TBrake::GetBCF`, `TDriverHandle::OvrldButton`, `TReservoir::pa` and `TBrakeCyl::pa`. - - In `mover.cpp`: `BrakeVP`, `PipeRatio`, `RealPipeRatio`, `IncBrakeLevel`, `DecBrakeLevel`, `IncBrakePress`, `DecBrakePress` and `MainCtrlActualPowerPos`. (`GetExternalCommand` was removed.) + - In `physics.cpp`: `BrakeVP`, `PipeRatio`, `RealPipeRatio`, `IncBrakeLevel`, `DecBrakeLevel`, `IncBrakePress`, `DecBrakePress` and `MainCtrlActualPowerPos`. (`GetExternalCommand` was removed.) - **Inverter failures** of the induction motor drives (`inverter::Failure_Drive`, `Failure_Const`, `Activate`): nothing ever sets them. The cab only shows them. The branches reading them in `TractionForce` can't be reached. ## Code only data no game vehicle has would run @@ -153,7 +153,7 @@ The tests are written for the first two columns, and for what the game doesn't c **Code nothing in the game runs** (checked against the whole source tree): -- **The PLC as a whole.** A vehicle has one (`TMoverParameters::m_plc`) and runs it in every step (`m_plc.update()`), but nothing calls `load()`, so its program is always empty; nothing calls `find_or_insert()`, `input()` or `output()` either, so no file of the game data can be a program for it. Of `ladderlogic.cpp` the game runs the 9 lines of an update without timers and without operations. The tests run the rest with programs made up for them. +- **The PLC as a whole.** A vehicle has one (`physics::Vehicle::m_plc`) and runs it in every step (`m_plc.update()`), but nothing calls `load()`, so its program is always empty; nothing calls `find_or_insert()`, `input()` or `output()` either, so no file of the game data can be a program for it. Of `ladderlogic.cpp` the game runs the 9 lines of an update without timers and without operations. The tests run the rest with programs made up for them. - **In `parser.cpp`:** `countTokens()` with its `count()`, and `addCommentStyle()`. No caller gives the separators as a null pointer either, which `updateCharClasses()` allows for. - **In `utilities.cpp`:** `generate_uuid_v4()`, `FuzzyLogicAI()` and `last_modified()`. In `utilities.h`: `BorlandTime()`. @@ -163,9 +163,9 @@ The tests are written for the first two columns, and for what the game doesn't c The tests record the behaviour as it is. The following points may deserve a look by someone who knows how the real vehicles behave. -- **`Random(10) - Random(10)` (`mover.cpp`, the noise of the control pipe pressure `CntrlPipePress`):** the order the two calls were evaluated in isn't specified. MSVC Release, MSVC Debug and GCC gave different traces, a control pipe pressure mirrored around 5 bar, which failed 32 tests on the Linux CI. Fixed: the draws are sequenced in the order of MSVC Release, which the golden traces were recorded with. +- **`Random(10) - Random(10)` (`physics.cpp`, the noise of the control pipe pressure `CntrlPipePress`):** the order the two calls were evaluated in isn't specified. MSVC Release, MSVC Debug and GCC gave different traces, a control pipe pressure mirrored around 5 bar, which failed 32 tests on the Linux CI. Fixed: the draws are sequenced in the order of MSVC Release, which the golden traces were recorded with. - **`TCommand::Location` isn't initialised** in a new vehicle. The game always sets it through `PutCommand()`, but a test calling `RunCommand()` directly got different results run to run. -- **`CompressorList` is `int[4][9]`** (`mover.h`), though its factors are fractions: 0.9 is read as 0. No game vehicle has the list yet. +- **`CompressorList` is `int[4][9]`** (`vehicle.h`), though its factors are fractions: 0.9 is read as 0. No game vehicle has the list yet. - **A train whose pipe leaks under 2.75 bar before its start-up can't be released:** - Where this happens: an FV4a handle and an LSt valve, for example 4 minutes standing with wagons, waiting for a hot engine. - The cause: the pipe gets cut off the main reservoir (`lock_old` in `UpdatePipePressure`). The AI presses its unlock button only for the lock set by `LPOn` and `LPOff` (`control_main_pipe`). diff --git a/tests/unit/README.md b/tests/unit/README.md index 80deab5e4..301717221 100644 --- a/tests/unit/README.md +++ b/tests/unit/README.md @@ -68,7 +68,7 @@ TEST_CASE("brakes: service braking stops a heavier wagon too") { physics iterations a frame. With a cab (`vehicle{definition, 0.0, "name", 1}`) it has a driver. - `consist` (`consist.h`) couples vehicles into a train and steps them together, coupler forces, air, control and power passing between them. The physics reaches a neighbour through its - `TDynamicObject`, for its `MoverParameters` only; the tests have a stand-in of it with just that. + `TDynamicObject`, for its `physics` only; the tests have a stand-in of it with just that. - `drive.h` has the driver's part, made of the AI's steps: `start_up()` (battery, pumps, pantographs, line breaker, converter, compressor), `drive()` (running, acknowledging the vigilance), `release_brakes()`, `drive_cycle()` (a whole run from start-up to a stop). diff --git a/tests/unit/consist.cpp b/tests/unit/consist.cpp index 2c17ca5b8..0d6dbb5bf 100644 --- a/tests/unit/consist.cpp +++ b/tests/unit/consist.cpp @@ -10,23 +10,23 @@ consist::~consist() = default; vehicle &consist::add(definition const &Definition, int Cab, CouplingSet const couplings, double Velocity, double Gap) { auto added{std::make_unique(Definition, Velocity, std::format("test{}", m_vehicles.size()), Cab)}; - auto &mover{added->mover()}; + auto &physics{added->physics()}; std::vector object(sizeof(TDynamicObject)); - reinterpret_cast(object.data())->MoverParameters = &mover; // NOSONAR see m_objects + reinterpret_cast(object.data())->physics = &physics; // NOSONAR see m_objects auto position{0.0}; if (false == m_vehicles.empty()) { - auto &last{m_vehicles.back()->mover()}; - position = m_positions.back() - 0.5 * (last.Dim.L + mover.Dim.L) - Gap; - mover.Loc = TLocation{position, 0.0, 0.0}; + auto &last{m_vehicles.back()->physics()}; + position = m_positions.back() - 0.5 * (last.Dim.L + physics.Dim.L) - Gap; + physics.Loc = TLocation{position, 0.0, 0.0}; if (false == couplings.Empty()) { - last.Attach(VehicleEnd::rear, VehicleEnd::front, &mover, couplings, true, false); - mover.Attach(VehicleEnd::front, VehicleEnd::rear, &last, couplings, true, false); + last.Attach(VehicleEnd::rear, VehicleEnd::front, &physics, couplings, true, false); + physics.Attach(VehicleEnd::front, VehicleEnd::rear, &last, couplings, true, false); } } else { - mover.Loc = TLocation{position, 0.0, 0.0}; + physics.Loc = TLocation{position, 0.0, 0.0}; } m_vehicles.push_back(std::move(added)); m_positions.push_back(position); @@ -38,20 +38,20 @@ vehicle &consist::add(definition const &Definition, int Cab, CouplingSet const c void consist::update_neighbours() { // TDynamicObject::update_neighbours(), for vehicles coupled in a line for (std::size_t i = 0; i < m_vehicles.size(); ++i) { - auto &mover{m_vehicles[i]->mover()}; + auto &physics{m_vehicles[i]->physics()}; for (auto const end : VehicleEnds) { - auto &neighbour{mover.Neighbours[end]}; + auto &neighbour{physics.Neighbours[end]}; auto const other{end == VehicleEnd::front ? static_cast(i) - 1 : static_cast(i) + 1}; if (other < 0 || other >= static_cast(m_vehicles.size())) { neighbour = neighbour_data(); continue; } - auto const &othermover{m_vehicles[other]->mover()}; + auto const &otherPhysics{m_vehicles[other]->physics()}; auto const otherend{Opposite(end)}; - auto const distance{TMoverParameters::CouplerDist(&mover, &othermover) - mover.Couplers[end].adapter_length - - othermover.Couplers[otherend].adapter_length}; + auto const distance{physics::Vehicle::CouplerDist(&physics, &otherPhysics) - physics.Couplers[end].adapter_length - + otherPhysics.Couplers[otherend].adapter_length}; // a vehicle not coupled is a collision source when it's within the range the game scans - if (mover.Couplers[end].Connected == nullptr && distance > std::max(10.0, std::abs(mover.V)) + 40.0) { + if (physics.Couplers[end].Connected == nullptr && distance > std::max(10.0, std::abs(physics.V)) + 40.0) { neighbour = neighbour_data(); continue; } @@ -84,8 +84,8 @@ void consist::step(track const &Track, double Dt) { auto pipe{0.0}; auto length{0.0}; for (auto const &vehicle : m_vehicles) { - pipe += vehicle->mover().PipePress * vehicle->mover().Dim.L; - length += vehicle->mover().Dim.L; + pipe += vehicle->physics().PipePress * vehicle->physics().Dim.L; + length += vehicle->physics().Dim.L; } pipe /= length; for (std::size_t i = 0; i < m_vehicles.size(); ++i) { @@ -96,11 +96,11 @@ void consist::step(track const &Track, double Dt) { void consist::update_brake_pipes(double Dt) const { // vehicle_table::update_brake_pipes() - std::vector movers; + std::vector vehicles; for (auto const &vehicle : m_vehicles) { - movers.push_back(&vehicle->mover()); + vehicles.push_back(&vehicle->physics()); } - TMoverParameters::UpdatePipeCouplers(movers, Dt); + physics::Vehicle::UpdatePipeCouplers(vehicles, Dt); } void consist::run(double Seconds, track const &Track, double Dt) { @@ -111,7 +111,7 @@ void consist::run(double Seconds, track const &Track, double Dt) { } double consist::gap(std::size_t Index) const { - return TMoverParameters::CouplerDist(&m_vehicles[Index]->mover(), &m_vehicles[Index + 1]->mover()); + return physics::Vehicle::CouplerDist(&m_vehicles[Index]->physics(), &m_vehicles[Index + 1]->physics()); } } // namespace test diff --git a/tests/unit/consist.h b/tests/unit/consist.h index eb330e787..73daa6294 100644 --- a/tests/unit/consist.h +++ b/tests/unit/consist.h @@ -49,7 +49,7 @@ private: std::vector> m_vehicles; std::vector m_positions; // of the vehicles' middles along the track - // the physics reaches a neighbouring vehicle through its TDynamicObject, for its MoverParameters alone. + // the physics reaches a neighbouring vehicle through its TDynamicObject, for its physics alone. // the game's object can't be made without the rest of the game, so it's a stand-in: storage of its size // with that one member set, never constructed, which only the physics ever looks into std::vector> m_objects; diff --git a/tests/unit/drive.cpp b/tests/unit/drive.cpp index 03785730e..ea60924f5 100644 --- a/tests/unit/drive.cpp +++ b/tests/unit/drive.cpp @@ -15,40 +15,40 @@ void mark(trace *Trace, std::string const &Event) { } } -bool is_powered(TMoverParameters const &Vehicle) { +bool is_powered(physics::Vehicle const &Vehicle) { using enum TEngineType; auto const type{Vehicle.EngineType}; return Vehicle.Power > 1.0 && (type == ElectricSeriesMotor || type == ElectricInductionMotor || type == DieselEngine || type == DieselElectric); } driven driving(vehicle &Vehicle) { - return {Vehicle.mover(), Vehicle.mover(), Vehicle.mover(), [&Vehicle](double Seconds, track const &Track) { Vehicle.run(Seconds, Track); }}; + return {Vehicle.physics(), Vehicle.physics(), Vehicle.physics(), [&Vehicle](double Seconds, track const &Track) { Vehicle.run(Seconds, Track); }}; } driven driving(consist &Consist) { - // the AI's mvControlling and mvPantographUnit: the first vehicle with an engine, and with pantographs - auto *controlling{&Consist[0].mover()}; - auto *pantographs{&Consist[0].mover()}; + // the AI's mvControlling and pantographUnit: the first vehicle with an engine, and with pantographs + auto *controlling{&Consist[0].physics()}; + auto *pantographs{&Consist[0].physics()}; for (auto i = Consist.size(); i-- > 0;) { - auto &mover{Consist[i].mover()}; - if (is_powered(mover)) { - controlling = &mover; + auto &physics{Consist[i].physics()}; + if (is_powered(physics)) { + controlling = &physics; } - if (mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector && mover.EnginePowerSource.CollectorParameters.CollectorsNo > 0) { - pantographs = &mover; + if (physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector && physics.EnginePowerSource.CollectorParameters.CollectorsNo > 0) { + pantographs = &physics; } } - return {Consist[0].mover(), *controlling, *pantographs, [&Consist](double Seconds, track const &Track) { Consist.run(Seconds, Track); }}; + return {Consist[0].physics(), *controlling, *pantographs, [&Consist](double Seconds, track const &Track) { Consist.run(Seconds, Track); }}; } namespace { -void attend(TMoverParameters &Mover) { - if (Mover.SecuritySystem.is_cabsignal_blinking() && Mover.SecuritySystem.has_separate_acknowledge()) { - Mover.SecuritySystem.cabsignal_reset(); +void attend(physics::Vehicle &Physics) { + if (Physics.SecuritySystem.is_cabsignal_blinking() && Physics.SecuritySystem.has_separate_acknowledge()) { + Physics.SecuritySystem.cabsignal_reset(); } - if (Mover.SecuritySystem.is_blinking()) { - Mover.SecuritySystemReset(); + if (Physics.SecuritySystem.is_blinking()) { + Physics.SecuritySystemReset(); } } @@ -62,7 +62,7 @@ void drive(driven Driven, track const &Track, double Seconds) { } } -void release_brakes(TMoverParameters &Cab) { +void release_brakes(physics::Vehicle &Cab) { Cab.BrakeLevelSet(Cab.Handle->GetPos(bh_RP)); Cab.DecLocalBrakeLevel(LocalBrakePosNo); Cab.DecManualBrakeLevel(ManualBrakePosNo); @@ -85,12 +85,12 @@ void release_brakes(TMoverParameters &Cab) { } bool is_ready(driven const &Driven) { - auto const &mover{Driven.controlling}; - auto const air{mover.VeselVolume <= 0.0 || mover.ScndPipePress >= 4.5}; + auto const &physics{Driven.controlling}; + auto const air{physics.VeselVolume <= 0.0 || physics.ScndPipePress >= 4.5}; // the converter feeds the 110 V circuits (the electrodynamic brake's control among them); the AI switches // it on once the line breaker is closed, so a train already charged with air isn't ready before it runs - auto const converter{mover.ConverterStart != start_t::manual || mover.ConverterFlag}; - return mover.Mains && air && converter; + auto const converter{physics.ConverterStart != start_t::manual || physics.ConverterFlag}; + return physics.Mains && air && converter; } namespace { @@ -140,7 +140,7 @@ void close_line_breaker(driven const &Driven) { // the converter, the compressor and the motor blowers, once the line breaker is closed; and the switch of the // field shunting of a diesel-electric that has one (AutoRelay=Optional with FieldShuntSwitch=Yes), as the AI does -void switch_auxiliaries_on(TMoverParameters &Cab) { +void switch_auxiliaries_on(physics::Vehicle &Cab) { Cab.ConverterSwitch(true); Cab.CompressorSwitch(true); for (auto const side : VehicleEnds) { diff --git a/tests/unit/drive.h b/tests/unit/drive.h index a1aed95be..dce224af9 100644 --- a/tests/unit/drive.h +++ b/tests/unit/drive.h @@ -15,12 +15,12 @@ class consist; // (Cab != 0): a lone one, or the first one of a consist, and drives the whole of it // what the driver drives: the vehicle with the driver in it, the vehicles the driver controls the engine and -// the pantographs of (the AI's mvOccupied, mvControlling, mvPantographUnit; all the same one in a lone +// the pantographs of (the AI's occupied, mvControlling, pantographUnit; all the same one in a lone // vehicle or a locomotive), and the way to run the whole of it struct driven { - TMoverParameters &cab; - TMoverParameters &controlling; - TMoverParameters &pantographs; + physics::Vehicle &cab; + physics::Vehicle &controlling; + physics::Vehicle &pantographs; std::function run; }; driven driving(vehicle &Vehicle); @@ -37,13 +37,13 @@ void drive(driven Driven, track const &Track, double Seconds); // releases every brake the driver has a hand on: the train brake to running, the independent brake, the // hand brake and the spring brake; and the hand and spring brakes of the vehicles coupled to the cab's -void release_brakes(TMoverParameters &Cab); +void release_brakes(physics::Vehicle &Cab); // whether the vehicle is ready to run: line breaker closed (or the engine running), air in the main reservoir bool is_ready(driven const &Driven); // whether the vehicle drives itself -bool is_powered(TMoverParameters const &Vehicle); +bool is_powered(physics::Vehicle const &Vehicle); // a trace mark, when there's a trace void mark(trace *Trace, std::string const &Event); diff --git a/tests/unit/figures.cpp b/tests/unit/figures.cpp index 96f5a3d74..949a53061 100644 --- a/tests/unit/figures.cpp +++ b/tests/unit/figures.cpp @@ -59,7 +59,7 @@ constexpr double pipe_back{4.9}; } // namespace -void figures::sample(double Time, TMoverParameters const &Vehicle) { +void figures::sample(double Time, physics::Vehicle const &Vehicle) { auto &part{m_parts.back()}; auto const speed{Vehicle.V * 3.6}; auto const pipe{Vehicle.PipePress}; diff --git a/tests/unit/figures.h b/tests/unit/figures.h index 576852dbb..793eaecb8 100644 --- a/tests/unit/figures.h +++ b/tests/unit/figures.h @@ -3,7 +3,7 @@ #include #include -#include "physics/mover.h" +#include "physics/vehicle.h" namespace test { @@ -26,7 +26,7 @@ namespace test { class figures { public: // called on every step of the vehicle - void sample(double Time, TMoverParameters const &Vehicle); + void sample(double Time, physics::Vehicle const &Vehicle); // a part of the run starts with the event void mark(std::string const &Event); diff --git a/tests/unit/fiz.h b/tests/unit/fiz.h index 1e65049fc..5deec2c5f 100644 --- a/tests/unit/fiz.h +++ b/tests/unit/fiz.h @@ -6,7 +6,7 @@ class cParser; -// what the game's vehicle loader (TMoverParameters::LoadFIZ_Parse) makes of the lines of a vehicle definition, +// what the game's vehicle loader (physics::Vehicle::LoadFIZ_Parse) makes of the lines of a vehicle definition, // for the test definitions to give it the same and for checking they do namespace test::fiz { diff --git a/tests/unit/golden.cpp b/tests/unit/golden.cpp index da6a3ce8c..aff0890f7 100644 --- a/tests/unit/golden.cpp +++ b/tests/unit/golden.cpp @@ -266,7 +266,7 @@ bool same(std::string const &Recorded, std::string const &Now, bool const Exact) trace::trace(std::string Name, std::vector Channels, int Every, bool Figures) : m_name(std::move(Name)), m_channels(std::move(Channels)), m_every(Every), m_keep_figures(Figures) {} -void trace::sample(double Time, TMoverParameters const &Vehicle) { +void trace::sample(double Time, physics::Vehicle const &Vehicle) { // the invariants on every step, the first time each is broken for (auto const &invariant : invariants()) { if (std::ranges::find(m_broken, invariant.name) != m_broken.end()) { diff --git a/tests/unit/golden.h b/tests/unit/golden.h index d53acfa8d..a4714a925 100644 --- a/tests/unit/golden.h +++ b/tests/unit/golden.h @@ -5,7 +5,7 @@ #include #include -#include "physics/mover.h" +#include "physics/vehicle.h" #include "figures.h" #include "invariants.h" @@ -14,7 +14,7 @@ namespace test { // one value of the vehicle a trace follows struct channel { std::string name; - std::function value; + std::function value; }; // sets of channels for the usual subjects of a test, which can be put together @@ -55,7 +55,7 @@ public: trace(std::string Name, std::vector Channels, int Every = 10, bool Figures = true); // called by the vehicle after every step - void sample(double Time, TMoverParameters const &Vehicle); + void sample(double Time, physics::Vehicle const &Vehicle); // adds an event of the test to the trace, so a difference can be told apart from the moment of the action void mark(std::string const &Event); diff --git a/tests/unit/invariants.cpp b/tests/unit/invariants.cpp index e742fce41..d2e938d94 100644 --- a/tests/unit/invariants.cpp +++ b/tests/unit/invariants.cpp @@ -18,11 +18,11 @@ std::string values(std::initializer_list> Values return result; } -bool electric(TMoverParameters const &M) { +bool electric(physics::Vehicle const &M) { return M.EngineType == TEngineType::ElectricSeriesMotor || M.EngineType == TEngineType::ElectricInductionMotor; } -double max_brake_press(TMoverParameters const &M) { +double max_brake_press(physics::Vehicle const &M) { auto result{0.0}; for (auto const press : M.MaxBrakePress) { result = std::max(result, press); diff --git a/tests/unit/invariants.h b/tests/unit/invariants.h index 83e10e7d9..59550633d 100644 --- a/tests/unit/invariants.h +++ b/tests/unit/invariants.h @@ -5,7 +5,7 @@ #include #include -#include "physics/mover.h" +#include "physics/vehicle.h" namespace test { @@ -23,9 +23,9 @@ struct snapshot { struct invariant { std::string name; // Before is null at the first step of a trace - std::function holds; + std::function holds; // the values the rule looks at, shown when it's broken - std::function explain; + std::function explain; }; std::vector const &invariants(); diff --git a/tests/unit/scenario.cpp b/tests/unit/scenario.cpp index 9dfee124f..b26300a35 100644 --- a/tests/unit/scenario.cpp +++ b/tests/unit/scenario.cpp @@ -11,7 +11,7 @@ namespace { // switch is on when the controller leaves zero doesn't close its line contactors until the controller is back at zero bool start_cut_off(consist &Train) { for (std::size_t i = 0; i < Train.size(); ++i) { - if (Train[i].mover().ControlPressureSwitch) { + if (Train[i].physics().ControlPressureSwitch) { return true; } } diff --git a/tests/unit/scenario.h b/tests/unit/scenario.h index 29a9f5592..195e6fc3a 100644 --- a/tests/unit/scenario.h +++ b/tests/unit/scenario.h @@ -28,8 +28,8 @@ public: scenario &add(std::string const &Path, int Cab = 0, CouplingSet couplings = consist::full_coupling, double Velocity = 0.0, double Gap = 0.0); consist &train() { return m_train; } - TMoverParameters &vehicle(std::size_t Index) { return m_train[Index].mover(); } - TMoverParameters &cab() { return m_train[0].mover(); } + physics::Vehicle &vehicle(std::size_t Index) { return m_train[Index].physics(); } + physics::Vehicle &cab() { return m_train[0].physics(); } driven driver() { return driving(m_train); } track &line() { return m_track; } diff --git a/tests/unit/test_brake_pipe.cpp b/tests/unit/test_brake_pipe.cpp index 7f6b8257e..e7f9a3dd7 100644 --- a/tests/unit/test_brake_pipe.cpp +++ b/tests/unit/test_brake_pipe.cpp @@ -1,12 +1,12 @@ #include "stdafx.h" #include "doctest.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "physics/brakes.h" #include "consist.h" #include "vehicle.h" -// the air exchange through the brake hoses between the vehicles of a train (TMoverParameters::UpdatePipeCouplers()). +// the air exchange through the brake hoses between the vehicles of a train (physics::Vehicle::UpdatePipeCouplers()). // taken in one explicit step of 0.01 s, the hose between two short freight wagons carried twice the air which evens // out their pipes: the pipes overshot each other in turns, and an ESt3 distributor saw the pipe pressure up to // 0.28 bar off what was in it, lapped at the first stage of braking and kept the AI's train from leaving @@ -70,7 +70,7 @@ TEST_CASE("brake pipe: the distributors of a standing freight train see the pres train.run(300.0); for (std::size_t i = 1; i < train.size(); ++i) { CAPTURE(i); - auto &wagon{train[i].mover()}; + auto &wagon{train[i].physics()}; // the distributor's valve chamber follows the pressure the distributor works with: the pipe's own CHECK(std::abs(wagon.Hamulec->GetVRP() - wagon.PipePress) < 0.005); CHECK(wagon.PipePress > 4.9); @@ -105,7 +105,7 @@ TEST_CASE("brake pipe: a passenger train, whose exchange was stable in one step, train.run(300.0); for (std::size_t i = 1; i < train.size(); ++i) { CAPTURE(i); - auto &car{train[i].mover()}; + auto &car{train[i].physics()}; CHECK(std::abs(car.Hamulec->GetVRP() - car.PipePress) < 0.005); CHECK((car.Hamulec->GetBrakeStatus() & (b_on | b_hld)) == 0); CHECK(car.BrakePress < 0.1); diff --git a/tests/unit/test_brake_setting.cpp b/tests/unit/test_brake_setting.cpp index ce9d09075..a8d5fb0af 100644 --- a/tests/unit/test_brake_setting.cpp +++ b/tests/unit/test_brake_setting.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "doctest.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "physics/brakes.h" #include "vehicle.h" #include "vehicle/brakesetting.h" @@ -209,18 +209,18 @@ void charge_and_apply(test::vehicle &Vehicle) { // running it as a train or shunting it, standing or on the run int inspect_heavy_train(test::vehicle &Vehicle, bool const Train = as_train, bool const Standstill = standstill) { auto consist{train(locomotive(), 30, freight_wagon(15.0, 80.0))}; - consist.emplace_back(brake_setting::describe(Vehicle.mover(), false)); + consist.emplace_back(brake_setting::describe(Vehicle.physics(), false)); auto const setting{brake_setting::choose(consist, Train).back()}; - brake_setting::apply(Vehicle.mover(), setting, Standstill); + brake_setting::apply(Vehicle.physics(), setting, Standstill); return setting; } // the same on a light train, which runs on P int inspect_light_train(test::vehicle &Vehicle) { auto consist{train(locomotive(), 4, freight_wagon())}; - consist.emplace_back(brake_setting::describe(Vehicle.mover(), false)); + consist.emplace_back(brake_setting::describe(Vehicle.physics(), false)); auto const setting{brake_setting::choose(consist, as_train).back()}; - brake_setting::apply(Vehicle.mover(), setting, standstill); + brake_setting::apply(Vehicle.physics(), setting, standstill); return setting; } @@ -229,13 +229,13 @@ int inspect_light_train(test::vehicle &Vehicle) { bool inspection_pending(std::vector const &Vehicles, bool const Train, bool const Standstill) { auto consist{train(locomotive(), 30, freight_wagon(15.0, 80.0))}; for (auto *vehicle : Vehicles) { - consist.emplace_back(brake_setting::describe(vehicle->mover(), false)); + consist.emplace_back(brake_setting::describe(vehicle->physics(), false)); } auto const settings{brake_setting::choose(consist, Train)}; auto setting{settings.end() - static_cast(Vehicles.size())}; auto pending{false}; for (auto *vehicle : Vehicles) { - if (brake_setting::apply(vehicle->mover(), *setting++, Standstill)) { + if (brake_setting::apply(vehicle->physics(), *setting++, Standstill)) { pending = true; } } @@ -251,7 +251,7 @@ TEST_CASE("brake setting: the inspector cuts the brake out in a train on G and p // made up into a heavy train on G: the brake is cut out and released REQUIRE(inspect_heavy_train(car) == brake_setting::cut_out); - CHECK(brake_setting::is_cut_out(car.mover())); + CHECK(brake_setting::is_cut_out(car.physics())); CHECK(car->BrakeCutOutByInspector); car.run(30.0); CHECK(car->BrakePress < 0.1); @@ -265,13 +265,13 @@ TEST_CASE("brake setting: the inspector cuts the brake out in a train on G and p car.run(20.0); CHECK(car->BrakePress < 0.1); // to the inspector looking at the train again it's a car like any other, and the train needs it cut out still - CHECK(false == brake_setting::describe(car.mover(), false).cut_out); + CHECK(false == brake_setting::describe(car.physics(), false).cut_out); REQUIRE(inspect_heavy_train(car) == brake_setting::cut_out); CHECK(car->BrakeCutOutByInspector); // made up into a light train: the brake is back on P, charges and brakes again CHECK(inspect_light_train(car) == P); - CHECK(false == brake_setting::is_cut_out(car.mover())); + CHECK(false == brake_setting::is_cut_out(car.physics())); CHECK(false == car->BrakeCutOutByInspector); CHECK(car->BrakeDelayFlag == P); // the reservoirs emptied when it was cut out take some five minutes to charge from the brake pipe @@ -288,14 +288,14 @@ TEST_CASE("brake setting: the inspector never puts back a brake cut out for anot // cut out the way the scenery's '0' does it car->Hamulec->ForceEmptiness(); car->Hamulec->SetBrakeStatus(car->Hamulec->GetBrakeStatus() | b_dmg); - CHECK(brake_setting::describe(car.mover(), false).cut_out); + CHECK(brake_setting::describe(car.physics(), false).cut_out); // a train on G wants it cut out anyway: it isn't the inspector's to put back CHECK(inspect_heavy_train(car) == brake_setting::cut_out); CHECK(false == car->BrakeCutOutByInspector); // a train on P would want it working: it stays cut out CHECK(inspect_light_train(car) == P); - CHECK(brake_setting::is_cut_out(car.mover())); + CHECK(brake_setting::is_cut_out(car.physics())); charge_and_apply(car); CHECK(car->BrakePress < 0.1); @@ -310,7 +310,7 @@ TEST_CASE("brake setting: the inspector never puts back a brake cut out for anot CHECK(false == other->BrakeCutOutByInspector); other->Hamulec->SetBrakeStatus(other->Hamulec->GetBrakeStatus() | b_dmg); CHECK(inspect_light_train(other) == P); - CHECK(brake_setting::is_cut_out(other.mover())); + CHECK(brake_setting::is_cut_out(other.physics())); } TEST_CASE("brake setting: shunting puts back a brake the inspector cut out, and cuts none out") { @@ -318,7 +318,7 @@ TEST_CASE("brake setting: shunting puts back a brake the inspector cut out, and charge_and_apply(car); // shunted in a heavy consist: nothing is cut out, the car is on P and brakes CHECK(inspect_heavy_train(car, shunting) == P); - CHECK(false == brake_setting::is_cut_out(car.mover())); + CHECK(false == brake_setting::is_cut_out(car.physics())); CHECK(car->BrakeDelayFlag == P); CHECK(car->BrakePress > 1.0); @@ -326,7 +326,7 @@ TEST_CASE("brake setting: shunting puts back a brake the inspector cut out, and REQUIRE(inspect_heavy_train(car) == brake_setting::cut_out); REQUIRE(car->BrakeCutOutByInspector); CHECK(inspect_heavy_train(car, shunting) == P); - CHECK(false == brake_setting::is_cut_out(car.mover())); + CHECK(false == brake_setting::is_cut_out(car.physics())); CHECK(false == car->BrakeCutOutByInspector); car.hold_brake_pipe(5.0); car.run(300.0); @@ -337,7 +337,7 @@ TEST_CASE("brake setting: shunting puts back a brake the inspector cut out, and test::vehicle other{passenger_car_definition()}; other->Hamulec->SetBrakeStatus(other->Hamulec->GetBrakeStatus() | b_dmg); CHECK(inspect_heavy_train(other, shunting) == P); - CHECK(brake_setting::is_cut_out(other.mover())); + CHECK(brake_setting::is_cut_out(other.physics())); } TEST_CASE("brake setting: the inspector doesn't cut a brake out on the run, it waits for a standstill") { @@ -347,20 +347,20 @@ TEST_CASE("brake setting: the inspector doesn't cut a brake out on the run, it w // the train checked on the run (the order changed mid-run): the car keeps its brake and its setting auto const setting{car->BrakeDelayFlag}; CHECK(inspect_heavy_train(car, as_train, moving) == brake_setting::cut_out); - CHECK(false == brake_setting::is_cut_out(car.mover())); + CHECK(false == brake_setting::is_cut_out(car.physics())); CHECK(false == car->BrakeCutOutByInspector); CHECK(car->BrakeDelayFlag == setting); car.run(5.0); CHECK(car->BrakePress > 1.0); // the next check, standing, cuts it out CHECK(inspect_heavy_train(car) == brake_setting::cut_out); - CHECK(brake_setting::is_cut_out(car.mover())); + CHECK(brake_setting::is_cut_out(car.physics())); CHECK(car->BrakeCutOutByInspector); // a brake cut out already stays cut out on the run, and one put back on the run is back CHECK(inspect_heavy_train(car, as_train, moving) == brake_setting::cut_out); CHECK(car->BrakeCutOutByInspector); CHECK(inspect_heavy_train(car, shunting, moving) == P); - CHECK(false == brake_setting::is_cut_out(car.mover())); + CHECK(false == brake_setting::is_cut_out(car.physics())); CHECK(false == car->BrakeCutOutByInspector); } @@ -378,8 +378,8 @@ TEST_CASE("brake setting: a cut-out skipped on the run is reported, and done at // moving: nothing is cut out, and the inspector tells it has to come back CHECK(inspection_pending(vehicles, as_train, brake_setting::at_standstill(3.0))); for (auto *vehicle : vehicles) { - CHECK(false == brake_setting::is_cut_out(vehicle->mover())); - CHECK(false == vehicle->mover().BrakeCutOutByInspector); + CHECK(false == brake_setting::is_cut_out(vehicle->physics())); + CHECK(false == vehicle->physics().BrakeCutOutByInspector); } CHECK(first->BrakeDelayFlag == setting); CHECK(wagon->BrakeDelayFlag == G); @@ -387,14 +387,14 @@ TEST_CASE("brake setting: a cut-out skipped on the run is reported, and done at CHECK(inspection_pending(vehicles, as_train, moving)); // the train stands (its brake pipe charging after the coupling): the cars get cut out, nothing is left CHECK(false == inspection_pending(vehicles, as_train, brake_setting::at_standstill(0.0))); - CHECK(brake_setting::is_cut_out(first.mover())); + CHECK(brake_setting::is_cut_out(first.physics())); CHECK(first->BrakeCutOutByInspector); - CHECK(brake_setting::is_cut_out(second.mover())); + CHECK(brake_setting::is_cut_out(second.physics())); CHECK(second->BrakeCutOutByInspector); - CHECK(false == brake_setting::is_cut_out(wagon.mover())); + CHECK(false == brake_setting::is_cut_out(wagon.physics())); // and nothing is pending when the train moves off CHECK(false == inspection_pending(vehicles, as_train, moving)); - CHECK(brake_setting::is_cut_out(first.mover())); + CHECK(brake_setting::is_cut_out(first.physics())); } TEST_CASE("brake setting: an inspection on the run with nothing to cut out leaves nothing pending") { @@ -405,7 +405,7 @@ TEST_CASE("brake setting: an inspection on the run with nothing to cut out leave // a car without G in a consist being shunted: it keeps its brake, on P test::vehicle car{passenger_car_definition()}; CHECK(false == inspection_pending({&car}, shunting, moving)); - CHECK(false == brake_setting::is_cut_out(car.mover())); + CHECK(false == brake_setting::is_cut_out(car.physics())); // a car whose brake is cut out already, for a reason of its own or by the inspector test::vehicle damaged{passenger_car_definition()}; damaged->Hamulec->SetBrakeStatus(damaged->Hamulec->GetBrakeStatus() | b_dmg); @@ -417,14 +417,14 @@ TEST_CASE("brake setting: an inspection on the run with nothing to cut out leave CHECK(false == inspection_pending({&done}, as_train, moving)); // a brake put back on the run (the train became a consist being shunted) leaves nothing either CHECK(false == inspection_pending({&done}, shunting, moving)); - CHECK(false == brake_setting::is_cut_out(done.mover())); + CHECK(false == brake_setting::is_cut_out(done.physics())); // a single vehicle's apply() tells the same test::vehicle single{passenger_car_definition()}; - CHECK(brake_setting::apply(single.mover(), brake_setting::cut_out, moving)); - CHECK(false == brake_setting::apply(single.mover(), P, moving)); - CHECK(false == brake_setting::apply(single.mover(), 0, moving)); - CHECK(false == brake_setting::apply(single.mover(), brake_setting::cut_out, standstill)); - CHECK(false == brake_setting::apply(single.mover(), brake_setting::cut_out, moving)); + CHECK(brake_setting::apply(single.physics(), brake_setting::cut_out, moving)); + CHECK(false == brake_setting::apply(single.physics(), P, moving)); + CHECK(false == brake_setting::apply(single.physics(), 0, moving)); + CHECK(false == brake_setting::apply(single.physics(), brake_setting::cut_out, standstill)); + CHECK(false == brake_setting::apply(single.physics(), brake_setting::cut_out, moving)); } TEST_CASE("brake setting: a train creeping to a stop counts as standing, one on the run or coupling doesn't") { @@ -443,13 +443,13 @@ TEST_CASE("brake setting: a train creeping to a stop counts as standing, one on test::vehicle creeping{passenger_car_definition()}; charge_and_apply(creeping); CHECK(inspect_heavy_train(creeping, as_train, brake_setting::at_standstill(0.9)) == brake_setting::cut_out); - CHECK(brake_setting::is_cut_out(creeping.mover())); + CHECK(brake_setting::is_cut_out(creeping.physics())); CHECK(creeping->BrakeCutOutByInspector); // checked at 30 km/h: the car keeps its brake test::vehicle running{passenger_car_definition()}; charge_and_apply(running); CHECK(inspect_heavy_train(running, as_train, brake_setting::at_standstill(30.0)) == brake_setting::cut_out); - CHECK(false == brake_setting::is_cut_out(running.mover())); + CHECK(false == brake_setting::is_cut_out(running.physics())); CHECK(false == running->BrakeCutOutByInspector); running.run(5.0); CHECK(running->BrakePress > 1.0); @@ -468,10 +468,10 @@ TEST_CASE("brake setting: a bank engine's run counts as a train, shunting doesn' test::vehicle car{passenger_car_definition()}; charge_and_apply(car); CHECK(inspect_heavy_train(car, brake_setting::runs_as_train(DriverOrder::bank)) == brake_setting::cut_out); - CHECK(brake_setting::is_cut_out(car.mover())); + CHECK(brake_setting::is_cut_out(car.physics())); // shunted: it's back on P CHECK(inspect_heavy_train(car, brake_setting::runs_as_train(DriverOrder::shunt)) == P); - CHECK(false == brake_setting::is_cut_out(car.mover())); + CHECK(false == brake_setting::is_cut_out(car.physics())); } TEST_CASE("brake setting: the AI looks at its train under the orders it drives it under, Connect included") { diff --git a/tests/unit/test_brakes.cpp b/tests/unit/test_brakes.cpp index 5c5246798..cb83e2f0e 100644 --- a/tests/unit/test_brakes.cpp +++ b/tests/unit/test_brakes.cpp @@ -107,7 +107,7 @@ TEST_CASE("brakes: a dead EN57 hauled with the brake hose alone charges from the train.add(definition::fiz("en57_v1/5bgaiii_led_spot")); // a unit standing dead: no air anywhere, nothing in its main reservoir pipe for (std::size_t i = 1; i < train.size(); ++i) { - auto &car{train[i].mover()}; + auto &car{train[i].physics()}; REQUIRE(car.BrakeValve == TBrakeValve::EP2); car.Hamulec->ForceEmptiness(); car.Pipe->CreatePress(0.0); @@ -120,7 +120,7 @@ TEST_CASE("brakes: a dead EN57 hauled with the brake hose alone charges from the train.run(900.0); for (std::size_t i = 1; i < train.size(); ++i) { CAPTURE(i); - auto &car{train[i].mover()}; + auto &car{train[i].physics()}; REQUIRE(car.ScndPipePress < 0.1); // no main reservoir pipe CHECK(car.Hamulec->GetBRP() > 4.8); CHECK(car.Hamulec->GetCRP() > 4.8); diff --git a/tests/unit/test_cab.cpp b/tests/unit/test_cab.cpp index ca58d6a65..14c5e163d 100644 --- a/tests/unit/test_cab.cpp +++ b/tests/unit/test_cab.cpp @@ -21,9 +21,9 @@ using namespace test::channels; TEST_CASE("cab: the engine rotation of up to three vehicles in multiple, on the tachometers of the SN61") { consist train; - auto &first{train.add(definition::fiz("sn61_v2/sn61"), 1).mover()}; - auto &second{train.add(definition::fiz("sn61_v2/sn61")).mover()}; - auto &third{train.add(definition::fiz("sn61_v2/sn61")).mover()}; + auto &first{train.add(definition::fiz("sn61_v2/sn61"), 1).physics()}; + auto &second{train.add(definition::fiz("sn61_v2/sn61")).physics()}; + auto &third{train.add(definition::fiz("sn61_v2/sn61")).physics()}; first.enrot = -10.0; second.enrot = 20.0; third.enrot = 30.0; @@ -37,15 +37,15 @@ TEST_CASE("cab: the engine rotation of up to three vehicles in multiple, on the CHECK(third.ShowEngineRotation(3) == doctest::Approx(10.0)); // no control cable, no reading consist apart; - auto const &alone{apart.add(definition::fiz("sn61_v2/sn61"), 1).mover()}; + auto const &alone{apart.add(definition::fiz("sn61_v2/sn61"), 1).physics()}; apart.add(definition::fiz("sn61_v2/sn61"), 0, Coupling::coupler | Coupling::brakeHose); CHECK(alone.ShowEngineRotation(2) == doctest::Approx(0.0)); } TEST_CASE("cab: the lamps of the overload relay and the starting resistors, read through the control cable") { consist unit; - auto &trailer{unit.add(definition::fiz("ed72_v1/5bs-ra"), 1).mover()}; - auto &motor{unit.add(definition::fiz("ed72_v1/6bs-sa")).mover()}; + auto &trailer{unit.add(definition::fiz("ed72_v1/5bs-ra"), 1).physics()}; + auto &motor{unit.add(definition::fiz("ed72_v1/6bs-sa")).physics()}; REQUIRE(trailer.Power < 0.01); REQUIRE(motor.Power > 0.01); CHECK_FALSE(trailer.FuseFlagCheck()); @@ -91,7 +91,7 @@ TEST_CASE("cab: the controller of the electrodynamic brake apart from the local CHECK_FALSE(eu47.IncDynamicBrakeLevel(1.f)); CHECK(eu47.DynamicBrakeRatio() == doctest::Approx(0.0)); - scenario.train()[0].mover().SplitEDPneumaticBrake = true; + scenario.train()[0].physics().SplitEDPneumaticBrake = true; REQUIRE(scenario.start_up()); REQUIRE(eu47.DynamicBrakeCtrlPosNo == 10); CHECK(eu47.DynamicBrakeAvailable()); diff --git a/tests/unit/test_camshaft.cpp b/tests/unit/test_camshaft.cpp index 940616a62..959c81d37 100644 --- a/tests/unit/test_camshaft.cpp +++ b/tests/unit/test_camshaft.cpp @@ -67,7 +67,7 @@ definition skoda() { // the locomotive running with the line contactors closed and the camshaft at Position, the master controller moved // to Controller, in the given direction; the time since the last step of the camshaft long enough for the next one -void running(TMoverParameters &Locomotive, int const Direction, int const Position, int const Controller) { +void running(physics::Vehicle &Locomotive, int const Direction, int const Position, int const Controller) { Locomotive.CabActive = 1; Locomotive.DirActive = Direction; Locomotive.Mains = true; @@ -81,7 +81,7 @@ void running(TMoverParameters &Locomotive, int const Direction, int const Positi // steps the camshaft as the physics does, each step once the delay since the previous one passed; returns where it // ended up -int run_camshaft(TMoverParameters &Locomotive, int const Steps) { +int run_camshaft(physics::Vehicle &Locomotive, int const Steps) { for (int step = 0; step < Steps; ++step) { Locomotive.LastRelayTime = 10.0; Locomotive.AutoRelayCheck(); @@ -93,43 +93,43 @@ int run_camshaft(TMoverParameters &Locomotive, int const Steps) { TEST_CASE("camshaft: running backwards, the camshaft goes back down from the last series position (eu07/maszyna#393)") { vehicle locomotive{skoda()}; - auto &mover{locomotive.mover()}; - REQUIRE(mover.HasCamshaft); - REQUIRE(mover.RlistSize == 43); - REQUIRE(mover.RList[22].Bn == 1); - REQUIRE(mover.RList[23].Bn == 2); + auto &physics{locomotive.physics()}; + REQUIRE(physics.HasCamshaft); + REQUIRE(physics.RlistSize == 43); + REQUIRE(physics.RList[22].Bn == 1); + REQUIRE(physics.RList[23].Bn == 2); SUBCASE("the controller turned back a few positions") { - running(mover, -1, 22, 15); - CHECK(run_camshaft(mover, 1) == 21); // it used to stay at 22 - CHECK(run_camshaft(mover, 10) == 15); + running(physics, -1, 22, 15); + CHECK(run_camshaft(physics, 1) == 21); // it used to stay at 22 + CHECK(run_camshaft(physics, 10) == 15); } SUBCASE("the controller turned back to zero: the camshaft runs down and the line contactors open") { - running(mover, -1, 22, 0); - run_camshaft(mover, 30); - CHECK(mover.MainCtrlActualPos == 0); - CHECK_FALSE(mover.StLinFlag); // the motors don't pull any more + running(physics, -1, 22, 0); + run_camshaft(physics, 30); + CHECK(physics.MainCtrlActualPos == 0); + CHECK_FALSE(physics.StLinFlag); // the motors don't pull any more } } TEST_CASE("camshaft: running backwards, the camshaft still doesn't go past the series connection") { vehicle locomotive{skoda()}; - auto &mover{locomotive.mover()}; - running(mover, -1, 20, 43); - CHECK(run_camshaft(mover, 10) == 22); + auto &physics{locomotive.physics()}; + running(physics, -1, 20, 43); + CHECK(run_camshaft(physics, 10) == 22); SUBCASE("unless more branches are allowed backwards") { - mover.BackwardsBranchesAllowed = 2; - CHECK(run_camshaft(mover, 20) == 34); + physics.BackwardsBranchesAllowed = 2; + CHECK(run_camshaft(physics, 20) == 34); } } TEST_CASE("camshaft: running forwards, the camshaft goes through all the connections and back") { vehicle locomotive{skoda()}; - auto &mover{locomotive.mover()}; - running(mover, 1, 20, 43); - CHECK(run_camshaft(mover, 30) == 43); + auto &physics{locomotive.physics()}; + running(physics, 1, 20, 43); + CHECK(run_camshaft(physics, 30) == 43); - mover.MainCtrlPos = 10; - CHECK(run_camshaft(mover, 40) == 10); + physics.MainCtrlPos = 10; + CHECK(run_camshaft(physics, 40) == 10); } diff --git a/tests/unit/test_cntrl.cpp b/tests/unit/test_cntrl.cpp index bff7759ea..425a2b07a 100644 --- a/tests/unit/test_cntrl.cpp +++ b/tests/unit/test_cntrl.cpp @@ -5,7 +5,7 @@ using test::definition; using test::vehicle; -// the Cntrl. section of the vehicle definition, as read by TMoverParameters::LoadFIZ_Cntrl() +// the Cntrl. section of the vehicle definition, as read by physics::Vehicle::LoadFIZ_Cntrl() TEST_CASE("cntrl: the brake delays of the settings come from BDelay1 to BDelay4") { vehicle wagon{definition::load("wagon").set("Cntrl", "BDelay1", 10.0).set("Cntrl", "BDelay2", 20.0).set("Cntrl", "BDelay3", 30.0).set("Cntrl", "BDelay4", 40.0)}; @@ -41,7 +41,7 @@ TEST_CASE("cntrl: the relays of a multiple unit start on their own, of other veh namespace { // the first position of the master controller after Position without the starting resistors in the circuit -int resistance_free_position(TMoverParameters const &Vehicle, int Position = 0) { +int resistance_free_position(physics::Vehicle const &Vehicle, int Position = 0) { for (auto position{Position + 1}; position <= Vehicle.MainCtrlPosNo; ++position) { if (Vehicle.RList[position].R < 0.01) { return position; @@ -65,7 +65,7 @@ TEST_CASE("cntrl: ScndCtrlResistiveLock keeps the field shunting off at zero and vehicle locked{definition::fiz(path).set("Cntrl", "ScndCtrlResistiveLock", "Yes"), 0.0, "test", 1}; REQUIRE(locked->ScndCtrlResistiveLock); REQUIRE(locked->ScndCtrlPosNo > 0); - auto const resistancefree{resistance_free_position(locked.mover())}; + auto const resistancefree{resistance_free_position(locked.physics())}; REQUIRE(resistancefree > 1); if (resistancefree <= 1) { continue; // not reached, the REQUIRE above ends the test; tells the static analysis the index below is in range @@ -88,7 +88,7 @@ TEST_CASE("cntrl: ScndCtrlResistiveLock keeps the field shunting off at zero and } } SUBCASE("every resistance-free position") { - for (auto position{resistancefree}; position > 0; position = resistance_free_position(locked.mover(), position)) { + for (auto position{resistancefree}; position > 0; position = resistance_free_position(locked.physics(), position)) { CAPTURE(position); controllers_at(locked, position); CHECK_FALSE(locked->IsScndCtrlLockedByMainCtrl()); @@ -142,7 +142,7 @@ TEST_CASE("cntrl: ScndCtrlResistiveLock keeps the field shunting off at zero and SUBCASE("the master controller moved up from a shunt step onto a resistive position drops the shunt") { // the last series position, followed by the resistive parallel ones auto lastseries{0}; - for (auto position{resistancefree}; position > 0 && position < locked->MainCtrlPosNo; position = resistance_free_position(locked.mover(), position)) { + for (auto position{resistancefree}; position > 0 && position < locked->MainCtrlPosNo; position = resistance_free_position(locked.physics(), position)) { if (locked->RList[position + 1].R >= 0.01) { lastseries = position; break; diff --git a/tests/unit/test_collisions.cpp b/tests/unit/test_collisions.cpp index bb0395df7..24dc4d545 100644 --- a/tests/unit/test_collisions.cpp +++ b/tests/unit/test_collisions.cpp @@ -4,7 +4,7 @@ #include "drive.h" #include "vehicle.h" #include "physics/collision.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include @@ -111,11 +111,11 @@ cl::crush_curve const locomotive_curve{cl::default_crush(cl::vehicle_kind::locom // ---- trains of real vehicles -bool derailed(TMoverParameters const &Vehicle) { +bool derailed(physics::Vehicle const &Vehicle) { return Vehicle.DamageFlag.HasAll(VehicleDamage::derailed); } -double crush_of(TMoverParameters const &Vehicle) { +double crush_of(physics::Vehicle const &Vehicle) { return std::max(Vehicle.Couplers[VehicleEnd::front].crush, Vehicle.Couplers[VehicleEnd::rear].crush); } @@ -170,7 +170,7 @@ crash_outcome freight_crash(double const Speed, double const Radius, double cons crash_outcome result; for (std::size_t i = 0; i < train.size(); ++i) { - auto const &vehicle{train[i].mover()}; + auto const &vehicle{train[i].physics()}; auto const name{i < standing ? std::format("standing {}", standing - 1 - i) : i == standing ? std::string{"locomotive"} : std::format("running {}", i - standing - 1)}; for (auto const end : VehicleEnds) { if (vehicle.Couplers[end].crush >= cl::crush_mark) { @@ -208,17 +208,17 @@ double locomotive_into_wagon(double const Speed, double const Dt) { } // the energy the crush of both ends of the pair took, by their curves [J] -double crush_energy(TMoverParameters const &First, VehicleEnd const FirstEnd, TMoverParameters const &Second, VehicleEnd const SecondEnd) { +double crush_energy(physics::Vehicle const &First, VehicleEnd const FirstEnd, physics::Vehicle const &Second, VehicleEnd const SecondEnd) { return First.crush_curve_at(FirstEnd).energy(0.0, First.Couplers[FirstEnd].crush) + Second.crush_curve_at(SecondEnd).energy(0.0, Second.Couplers[SecondEnd].crush); } // what the buffers of EN 15551 of the two ends take in [J] -double capacity_of(TMoverParameters const &First, VehicleEnd const FirstEnd, TMoverParameters const &Second, VehicleEnd const SecondEnd) { +double capacity_of(physics::Vehicle const &First, VehicleEnd const FirstEnd, physics::Vehicle const &Second, VehicleEnd const SecondEnd) { return cl::buffer_capacity(First.Couplers[FirstEnd].collision, First.collision_kind()) + cl::buffer_capacity(Second.Couplers[SecondEnd].collision, Second.collision_kind()); } // the kinetic energy of the relative motion of two vehicles closing in at the velocity [J] -double relative_energy(TMoverParameters const &First, TMoverParameters const &Second, double const Velocity) { +double relative_energy(physics::Vehicle const &First, physics::Vehicle const &Second, double const Velocity) { auto const mass{First.TotalMass * Second.TotalMass / (First.TotalMass + Second.TotalMass)}; return 0.5 * mass * Velocity * Velocity; } @@ -239,9 +239,9 @@ contact_outcome contact(definition const &Front, definition const &Back, double train.run(Seconds, {}, Dt); contact_outcome result; result.crush = front->Couplers[VehicleEnd::rear].crush + back->Couplers[VehicleEnd::front].crush; - result.energy = crush_energy(front.mover(), VehicleEnd::rear, back.mover(), VehicleEnd::front); - result.available = std::max(0.0, relative_energy(front.mover(), back.mover(), Speed * kmh) - capacity_of(front.mover(), VehicleEnd::rear, back.mover(), VehicleEnd::front)); - result.derailed = derailed(front.mover()) || derailed(back.mover()); + result.energy = crush_energy(front.physics(), VehicleEnd::rear, back.physics(), VehicleEnd::front); + result.available = std::max(0.0, relative_energy(front.physics(), back.physics(), Speed * kmh) - capacity_of(front.physics(), VehicleEnd::rear, back.physics(), VehicleEnd::front)); + result.derailed = derailed(front.physics()) || derailed(back.physics()); return result; } @@ -251,7 +251,7 @@ definition coach(double const Mass) { } // Y / Q of the leading wheel of the vehicle at the end pressed in by its coupling, as check_pushed_off() takes it -double pushed_ratio_of(TMoverParameters const &Vehicle, VehicleEnd const End, double const OtherLength, double const Radius) { +double pushed_ratio_of(physics::Vehicle const &Vehicle, VehicleEnd const End, double const OtherLength, double const Radius) { cl::pushed_vehicle pushed; pushed.mass = Vehicle.TotalMass - Vehicle.Mred; pushed.axles = Vehicle.NAxles > 0 ? Vehicle.NAxles : 4; @@ -580,9 +580,9 @@ TEST_CASE("collisions: a locomotive at its starting effort against a braked trai } train.run(30.0, line); auto &locomotive{train.add(definition::fiz("st44_v2/m62-1151"), 1, Coupling::none, 0.0, 0.0)}; - test::driven const driver{locomotive.mover(), locomotive.mover(), locomotive.mover(), [&train](double const Seconds, test::track const &Track) { train.run(Seconds, Track); }}; + test::driven const driver{locomotive.physics(), locomotive.physics(), locomotive.physics(), [&train](double const Seconds, test::track const &Track) { train.run(Seconds, Track); }}; REQUIRE(test::start_up(driver, line)); - test::release_brakes(locomotive.mover()); + test::release_brakes(locomotive.physics()); for (int i = 0; i < 3 && locomotive->DirActive <= 0; ++i) { locomotive->DirectionForward(); } @@ -592,7 +592,7 @@ TEST_CASE("collisions: a locomotive at its starting effort against a braked trai auto worst{0.0}; auto const watch = [&]() { pushed = std::max(pushed, -locomotive->Couplers[VehicleEnd::front].CForce); - worst = std::max(worst, pushed_ratio_of(empty.mover(), VehicleEnd::rear, locomotive->Dim.L, line.radius)); + worst = std::max(worst, pushed_ratio_of(empty.physics(), VehicleEnd::rear, locomotive->Dim.L, line.radius)); }; // the line contactors close at the first position, once their delay and the pressure switch let them locomotive->IncMainCtrl(1); @@ -612,7 +612,7 @@ TEST_CASE("collisions: a locomotive at its starting effort against a braked trai MESSAGE(std::format("ST44 pushing at up to {:.0f} kN, the empty 3WL at Y/Q {:.2f}, rolled {:.3f} m", pushed / 1000.0, worst, rolled)); REQUIRE(worst >= derailment::climbing_limit); CHECK(rolled < 0.5); - CHECK_FALSE(derailed(empty.mover())); + CHECK_FALSE(derailed(empty.physics())); CHECK(empty->CollisionDerail == NONE); } @@ -632,7 +632,7 @@ TEST_CASE("collisions: a locomotive running onto an empty wagon at 9 km/h doesn' for (int step = 0; step < 500; ++step) { train.step(curve); pushed = std::max(pushed, empty->Couplers[VehicleEnd::rear].CForce); - auto const ratio{pushed_ratio_of(empty.mover(), VehicleEnd::rear, locomotive->Dim.L, curve.radius)}; + auto const ratio{pushed_ratio_of(empty.physics(), VehicleEnd::rear, locomotive->Dim.L, curve.radius)}; worst = std::max(worst, ratio); over += ratio >= derailment::climbing_limit; } @@ -640,8 +640,8 @@ TEST_CASE("collisions: a locomotive running onto an empty wagon at 9 km/h doesn' empty.speed())); REQUIRE(worst >= derailment::climbing_limit); REQUIRE(over >= 5); - CHECK_FALSE(derailed(empty.mover())); - CHECK_FALSE(derailed(locomotive.mover())); + CHECK_FALSE(derailed(empty.physics())); + CHECK_FALSE(derailed(locomotive.physics())); } TEST_CASE("collisions: a train propelling an empty wagon into a braked one in a curve pushes it off as it rolls on") { @@ -668,7 +668,7 @@ TEST_CASE("collisions: a train propelling an empty wagon into a braked one in a } auto const start{empty->DistCounter}; train.run(10.0, curve); - MESSAGE(std::format("the empty 3WL: derailed {}, {}, rolled {:.2f} m", derailed(empty.mover()), empty->CollisionDerail == COLLISION_PUSHED_OFF ? "pushed off" : "not pushed off", + MESSAGE(std::format("the empty 3WL: derailed {}, {}, rolled {:.2f} m", derailed(empty.physics()), empty->CollisionDerail == COLLISION_PUSHED_OFF ? "pushed off" : "not pushed off", (empty->DistCounter - start) * 1000.0)); CHECK(empty->CollisionDerail == COLLISION_PUSHED_OFF); } @@ -685,16 +685,16 @@ TEST_CASE("collisions: a repaired vehicle has its ends rebuilt and is back on th auto &locomotive{train.add(definition::fiz("4e_v1/4e"), 0, Coupling::none, 30.0, 0.5)}; train.run(3.0); REQUIRE(wagon->Couplers[VehicleEnd::rear].crush + locomotive->Couplers[VehicleEnd::front].crush > cl::override_crush); - REQUIRE((derailed(wagon.mover()) || derailed(locomotive.mover()))); + REQUIRE((derailed(wagon.physics()) || derailed(locomotive.physics()))); for (auto *vehicle : {&wagon, &locomotive}) { - auto &mover{vehicle->mover()}; - mover.repair_damage(); - CHECK(mover.DamageFlag.Empty()); - CHECK(mover.Derailed == derailment::outcome::none); - CHECK(mover.CollisionDerail == NONE); - CHECK(mover.pushed_off_monitor.distance() == 0.0); - CHECK(mover.pushed_off_monitor.time() == 0.0); - for (auto const &coupler : mover.Couplers) { + auto &physics{vehicle->physics()}; + physics.repair_damage(); + CHECK(physics.DamageFlag.Empty()); + CHECK(physics.Derailed == derailment::outcome::none); + CHECK(physics.CollisionDerail == NONE); + CHECK(physics.pushed_off_monitor.distance() == 0.0); + CHECK(physics.pushed_off_monitor.time() == 0.0); + for (auto const &coupler : physics.Couplers) { CHECK(coupler.crush == 0.0); CHECK(coupler.contact.absorbed() == 0.0); CHECK(coupler.contact.crush_work() == 0.0); @@ -766,8 +766,8 @@ TEST_CASE("collisions: the legacy rule with physics.collisions old, the crush wi train.add(definition::fiz(front)); train.add(definition::fiz(back), 0, Coupling::none, speed, 20.0); train.run(10.0); - CHECK(derailed(train[0].mover()) == (physical ? frontout_new : frontout_old)); - CHECK(derailed(train[1].mover()) == (physical ? backout_new : backout_old)); + CHECK(derailed(train[0].physics()) == (physical ? frontout_new : frontout_old)); + CHECK(derailed(train[1].physics()) == (physical ? backout_new : backout_old)); auto const crush{train[0]->Couplers[VehicleEnd::rear].crush + train[1]->Couplers[VehicleEnd::front].crush}; if (physical) { MESSAGE(name, ": crush ", crush, " m"); @@ -853,13 +853,13 @@ TEST_CASE("collisions: automatic couplers hit too fast don't catch, the ends cru auto coupled{false}; auto fast{false}; // coupled while closing in faster than the couplers catch for (int i = 0; i < 1000; ++i) { - auto const closing{moving->CollisionVelocity(VehicleEnd::front, standing.mover(), VehicleEnd::rear)}; + auto const closing{moving->CollisionVelocity(VehicleEnd::front, standing.physics(), VehicleEnd::rear)}; pair.step(); - fast = fast || (pair.coupled() && false == coupled && closing > TMoverParameters::SafeCollisionVelocity); + fast = fast || (pair.coupled() && false == coupled && closing > physics::Vehicle::SafeCollisionVelocity); coupled = coupled || pair.coupled(); } auto const crush{moving->Couplers[VehicleEnd::front].crush + standing->Couplers[VehicleEnd::rear].crush}; - MESSAGE(speed, " km/h: crush ", crush, " m, derailed ", derailed(moving.mover()), " ", derailed(standing.mover()), ", coupled later ", coupled); + MESSAGE(speed, " km/h: crush ", crush, " m, derailed ", derailed(moving.physics()), " ", derailed(standing.physics()), ", coupled later ", coupled); CHECK_FALSE(fast); CHECK(crush > 0.0); // crushed past the draw gear, the coupler is gone; short of it, the wagons may roll together again slowly @@ -869,8 +869,8 @@ TEST_CASE("collisions: automatic couplers hit too fast don't catch, the ends cru CHECK((moving->Couplers[VehicleEnd::front].broken || standing->Couplers[VehicleEnd::rear].broken)); } // the two alike: neither climbs onto the other until the crush is deep enough for both to - CHECK(derailed(moving.mover()) == derailed(standing.mover())); - CHECK(derailed(moving.mover()) == (crush > cl::override_both)); + CHECK(derailed(moving.physics()) == derailed(standing.physics())); + CHECK(derailed(moving.physics()) == (crush > cl::override_both)); } } @@ -884,8 +884,8 @@ TEST_CASE("collisions: road vehicles keep the legacy rule") { road.add(definition::fiz("road/man/nl293")); road.add(definition::fiz("road/man/nl293"), 0, Coupling::none, 40.0, 5.0); road.run(5.0); - CHECK(derailed(road[0].mover())); - CHECK(derailed(road[1].mover())); + CHECK(derailed(road[0].physics())); + CHECK(derailed(road[1].physics())); CHECK(road[0]->Couplers[VehicleEnd::rear].crush == 0.0); CHECK(road[1]->CollisionDerail == NONE); CHECK(road[0]->crush_reports + road[1]->crush_reports == 0); @@ -899,7 +899,7 @@ TEST_CASE("collisions: a vehicle off the rails by the new model stays in the cha auto &wagon{train.add(definition::fiz("430w_v2/430w"))}; auto &locomotive{train.add(definition::fiz("4e_v1/4e"), 0, Coupling::none, 10.0, 0.5)}; wagon->derail_in_collision(COLLISION_PUSHED_OFF, "for the test"); - REQUIRE(derailed(wagon.mover())); + REQUIRE(derailed(wagon.physics())); auto const before{wagon->TotalMass * wagon->V + locomotive->TotalMass * locomotive->V}; // the hit is over within a second, the friction of the derailed wagon slows the pair down over it train.run(1.0); @@ -954,10 +954,10 @@ TEST_CASE("collisions: identical units built to EN 15227 at 36 km/h") { double inner; int derailed; bool higher; - } result{train[1]->Couplers[VehicleEnd::rear].crush + train[2]->Couplers[VehicleEnd::front].crush, std::max(crush_of(train[0].mover()), crush_of(train[3].mover())), 0, - derailed(train[2].mover())}; + } result{train[1]->Couplers[VehicleEnd::rear].crush + train[2]->Couplers[VehicleEnd::front].crush, std::max(crush_of(train[0].physics()), crush_of(train[3].physics())), 0, + derailed(train[2].physics())}; for (std::size_t i = 0; i < train.size(); ++i) { - result.derailed += derailed(train[i].mover()); + result.derailed += derailed(train[i].physics()); } return result; }; @@ -1204,7 +1204,7 @@ TEST_CASE("collisions: two coaches (36 t and 41.6 t) at 8 km/h don't crush, nor consist train; auto &wall{train.add(light)}; wall->Derail(END_OF_TRACK); - REQUIRE(derailed(wall.mover())); + REQUIRE(derailed(wall.physics())); auto &running{train.add(heavy, 0, Coupling::none, 5.0, gap)}; train.run(5.0); CHECK(wall->Couplers[VehicleEnd::rear].crush + running->Couplers[VehicleEnd::front].crush == 0.0); @@ -1232,9 +1232,9 @@ TEST_CASE("collisions: a locomotive pushing a standing braked train at full powe train.run(30.0, line); // the locomotive behind them, touching, driven forwards into them at full power auto &locomotive{train.add(definition::fiz(path), 1, Coupling::none, 0.0, 0.0)}; - test::driven const driver{locomotive.mover(), locomotive.mover(), locomotive.mover(), [&train](double const Seconds, test::track const &Track) { train.run(Seconds, Track); }}; + test::driven const driver{locomotive.physics(), locomotive.physics(), locomotive.physics(), [&train](double const Seconds, test::track const &Track) { train.run(Seconds, Track); }}; REQUIRE(test::start_up(driver, line)); - test::release_brakes(locomotive.mover()); + test::release_brakes(locomotive.physics()); for (int i = 0; i < 3 && locomotive->DirActive <= 0; ++i) { locomotive->DirectionForward(); } @@ -1265,8 +1265,8 @@ TEST_CASE("collisions: a locomotive pushing a standing braked train at full powe CHECK(seconds >= 55); for (std::size_t i = 0; i < train.size(); ++i) { CAPTURE(i); - CHECK(crush_of(train[i].mover()) == 0.0); - CHECK_FALSE(derailed(train[i].mover())); + CHECK(crush_of(train[i].physics()) == 0.0); + CHECK_FALSE(derailed(train[i].physics())); } } } @@ -1326,7 +1326,7 @@ struct train_damage { train_damage damage_of(consist &Train) { train_damage result; for (std::size_t i = 0; i < Train.size(); ++i) { - auto const &vehicle{Train[i].mover()}; + auto const &vehicle{Train[i].physics()}; result.crush = std::max(result.crush, crush_of(vehicle)); for (auto const end : VehicleEnds) { result.energy += vehicle.crush_curve_at(end).energy(0.0, vehicle.Couplers[end].crush); @@ -1382,7 +1382,7 @@ TEST_CASE("collisions: the cut of the speed of the legacy derailment is no hit i locomotive->Derail(reason); } train.step(); - REQUIRE(derailed(locomotive.mover())); + REQUIRE(derailed(locomotive.physics())); // the train loses the speed with it for (std::size_t i = 1; i < train.size(); ++i) { CAPTURE(i); @@ -1432,7 +1432,7 @@ TEST_CASE("collisions: the train behind a vehicle that ran off the end of the tr auto const kinetic{kinetic_of(train)}; train[0].damage_track(dtrack_norail); train.run(20.0); - REQUIRE(derailed(train[0].mover())); + REQUIRE(derailed(train[0].physics())); auto const damage{damage_of(train)}; INFO(damage.list); MESSAGE(std::format("{}: crush {:.3f} m, {:.0f} kJ of the {:.0f} kJ of the train", pushed ? "pushed" : "pulled", damage.crush, damage.energy / 1000.0, kinetic / 1000.0)); @@ -1442,7 +1442,7 @@ TEST_CASE("collisions: the train behind a vehicle that ran off the end of the tr CHECK(damage.broken == 0); for (std::size_t i = 1; i < train.size(); ++i) { CAPTURE(i); - CHECK_FALSE(derailed(train[i].mover())); + CHECK_FALSE(derailed(train[i].physics())); } } } diff --git a/tests/unit/test_commands.cpp b/tests/unit/test_commands.cpp index 2304de2d8..ac84c075e 100644 --- a/tests/unit/test_commands.cpp +++ b/tests/unit/test_commands.cpp @@ -244,13 +244,13 @@ TEST_CASE("commands: every command run on every real vehicle") { auto channels{state()}; channels.emplace_back("Done", [&done](auto const &) { return flag(done); }); test::trace trace{"commands/" + path, channels, 1, false}; - trace.sample(0.0, real.mover()); + trace.sample(0.0, real.physics()); for (std::size_t i = 0; i < commands.size(); ++i) { auto const &command{commands[i]}; trace.mark(std::format("{} {} {}", command.name, command.value1, command.value2)); auto const parsed{ParseVehicleCommand(command.name)}; done = real->RunCommand(parsed.command, command.value1, command.value2, Coupling::control, parsed.argument); - trace.sample(static_cast(i + 1), real.mover()); + trace.sample(static_cast(i + 1), real.physics()); } trace.check(); } @@ -261,7 +261,7 @@ namespace { // a switch of the cab, worked on the driven vehicle struct action { std::string name; - std::function work; + std::function work; }; // every switch sending its state to the rest of the train, each way and to each range, in the order a crew @@ -378,19 +378,19 @@ TEST_CASE("commands: every switch of the cab, sent to the next vehicle") { test::reseed_random(); vehicle driven{definition::fiz(path), 0.0, "driven", 1}; vehicle next{definition::fiz(path), 0.0, "next"}; - driven->Attach(VehicleEnd::rear, VehicleEnd::front, &next.mover(), test::consist::full_coupling, true, false); + driven->Attach(VehicleEnd::rear, VehicleEnd::front, &next.physics(), test::consist::full_coupling, true, false); auto done{false}; auto channels{state()}; for (auto const &channel : state()) { - channels.emplace_back("next." + channel.name, [&next, value = channel.value](auto const &) { return value(next.mover()); }); + channels.emplace_back("next." + channel.name, [&next, value = channel.value](auto const &) { return value(next.physics()); }); } channels.emplace_back("Done", [&done](auto const &) { return flag(done); }); test::trace trace{"switches/" + path, channels, 1, false}; - trace.sample(0.0, driven.mover()); + trace.sample(0.0, driven.physics()); for (std::size_t i = 0; i < actions.size(); ++i) { trace.mark(actions[i].name); - done = actions[i].work(driven.mover()); - trace.sample(static_cast(i + 1), driven.mover()); + done = actions[i].work(driven.physics()); + trace.sample(static_cast(i + 1), driven.physics()); } trace.check(); } @@ -422,17 +422,17 @@ TEST_CASE("commands: every switch of the cab, worked on a pair standing under th }); auto const own{channels.size()}; for (std::size_t i = 0; i < own; ++i) { - channels.emplace_back("next." + channels[i].name, [&pair, value = channels[i].value](auto const &) { return value(pair[1].mover()); }); + channels.emplace_back("next." + channels[i].name, [&pair, value = channels[i].value](auto const &) { return value(pair[1].physics()); }); } channels.emplace_back("Done", [&done](auto const &) { return flag(done); }); test::trace trace{"switches_live/" + path, channels, 1, false}; - trace.sample(0.0, pair[0].mover()); + trace.sample(0.0, pair[0].physics()); test::track const catenary{.voltage = test::catenary_3kv}; for (std::size_t i = 0; i < actions.size(); ++i) { trace.mark(actions[i].name); - done = actions[i].work(pair[0].mover()); + done = actions[i].work(pair[0].physics()); pair.run(2.0, catenary); - trace.sample(static_cast(i + 1), pair[0].mover()); + trace.sample(static_cast(i + 1), pair[0].physics()); } trace.check(); } @@ -449,8 +449,8 @@ struct train { vehicle last{definition::fiz("4e_v1/4e"), 0.0, "last"}; explicit train(CouplingSet const couplings) { - head->Attach(VehicleEnd::rear, VehicleEnd::rear, &middle.mover(), couplings, true, false); - middle->Attach(VehicleEnd::front, VehicleEnd::front, &last.mover(), couplings, true, false); + head->Attach(VehicleEnd::rear, VehicleEnd::rear, &middle.physics(), couplings, true, false); + middle->Attach(VehicleEnd::front, VehicleEnd::front, &last.physics(), couplings, true, false); } }; diff --git a/tests/unit/test_consist.cpp b/tests/unit/test_consist.cpp index da831c6a8..f3524f678 100644 --- a/tests/unit/test_consist.cpp +++ b/tests/unit/test_consist.cpp @@ -67,7 +67,7 @@ TEST_CASE("consist: every real electric unit driven whole from its front cab") { // the drive cycle marks the events in the trace it gets; the first car's carries them test::drive_cycle(test::driving(train), test::track{0.15, 0.0, test::catenary_3kv}, *traces.front()); // every unit runs off and is braked to a stop, but the EN57, which doesn't get ready (COVERAGE.md) - auto const &leading{train[0].mover()}; + auto const &leading{train[0].physics()}; CHECK((leading.DistCounter > 0.2 /* km */) != (std::string{unit.name} == "en57")); CHECK(leading.Vel < 0.5); for (auto const &trace : traces) { diff --git a/tests/unit/test_controls.cpp b/tests/unit/test_controls.cpp index 55ce1cc0e..c2f7bb9d5 100644 --- a/tests/unit/test_controls.cpp +++ b/tests/unit/test_controls.cpp @@ -69,16 +69,16 @@ bool released(scenario &Scenario, double Pressure = 0.1) { return true; } -bool open(TMoverParameters const &Vehicle, VehicleSide Side) { +bool open(physics::Vehicle const &Vehicle, VehicleSide Side) { return Vehicle.Doors.instances[Side].is_open; } // the leaf shut, whatever the step does (closed, is_closed, wants the step folded too) -bool shut(TMoverParameters const &Vehicle, VehicleSide Side) { +bool shut(physics::Vehicle const &Vehicle, VehicleSide Side) { return Vehicle.Doors.instances[Side].position <= 0.f; } -bool closed(TMoverParameters const &Vehicle, VehicleSide Side) { +bool closed(physics::Vehicle const &Vehicle, VehicleSide Side) { return Vehicle.Doors.instances[Side].is_closed; } diff --git a/tests/unit/test_coupler_physics.cpp b/tests/unit/test_coupler_physics.cpp index 60c760fb5..534104473 100644 --- a/tests/unit/test_coupler_physics.cpp +++ b/tests/unit/test_coupler_physics.cpp @@ -269,8 +269,8 @@ namespace { // couples the facing ends of the two vehicles, as the scenery does void join(vehicle &First, VehicleEnd FirstEnd, vehicle &Second, VehicleEnd SecondEnd, CouplingSet const couplings = Coupling::coupler) { - REQUIRE(First->Attach(FirstEnd, SecondEnd, &Second.mover(), couplings, true, false)); - REQUIRE(Second->Attach(SecondEnd, FirstEnd, &First.mover(), couplings, true, false)); + REQUIRE(First->Attach(FirstEnd, SecondEnd, &Second.physics(), couplings, true, false)); + REQUIRE(Second->Attach(SecondEnd, FirstEnd, &First.physics(), couplings, true, false)); } // the wagon of data/wagon.json with the given play of its screw couplings @@ -500,7 +500,7 @@ TEST_CASE("couplers: a broken coupler is repaired alone, with the one of the veh CHECK_FALSE(second->AlarmChainFlag); // repaired, not coupled: the vehicles are coupled again as usual CHECK(second->Couplers[VehicleEnd::rear].CouplingFlag == Coupling::none); - CHECK(second->Attach(VehicleEnd::rear, VehicleEnd::front, &third.mover(), Coupling::coupler, true, false)); + CHECK(second->Attach(VehicleEnd::rear, VehicleEnd::front, &third.physics(), Coupling::coupler, true, false)); } TEST_CASE("coupler physics: with couplerphysics yes, only the pairs with a vehicle covered take the physical model") { diff --git a/tests/unit/test_couplers.cpp b/tests/unit/test_couplers.cpp index c816bf19b..5cacb2c4b 100644 --- a/tests/unit/test_couplers.cpp +++ b/tests/unit/test_couplers.cpp @@ -74,9 +74,9 @@ TEST_CASE("couplers: automatic couplers catch a standing wagon hit at a walking REQUIRE(moving.speed() == doctest::Approx(10.0)); // the front of the moving wagon runs into the rear of the standing one - CHECK(moving->CollisionVelocity(VehicleEnd::front, standing.mover(), VehicleEnd::rear) == doctest::Approx(10.0)); - CHECK(moving->AutomaticCouplingSafe(VehicleEnd::front, standing.mover(), VehicleEnd::rear)); - CHECK(standing->AutomaticCouplingSafe(VehicleEnd::rear, moving.mover(), VehicleEnd::front)); + CHECK(moving->CollisionVelocity(VehicleEnd::front, standing.physics(), VehicleEnd::rear) == doctest::Approx(10.0)); + CHECK(moving->AutomaticCouplingSafe(VehicleEnd::front, standing.physics(), VehicleEnd::rear)); + CHECK(standing->AutomaticCouplingSafe(VehicleEnd::rear, moving.physics(), VehicleEnd::front)); } TEST_CASE("couplers: automatic couplers don't catch a wagon hit too fast, the wagons collide instead") { @@ -85,9 +85,9 @@ TEST_CASE("couplers: automatic couplers don't catch a wagon hit too fast, the wa auto standing{automatic_wagon(0.0, "standing")}; REQUIRE(moving.speed() == doctest::Approx(30.0)); - CHECK(moving->CollisionVelocity(VehicleEnd::front, standing.mover(), VehicleEnd::rear) > TMoverParameters::SafeCollisionVelocity); - CHECK_FALSE(moving->AutomaticCouplingSafe(VehicleEnd::front, standing.mover(), VehicleEnd::rear)); - CHECK_FALSE(standing->AutomaticCouplingSafe(VehicleEnd::rear, moving.mover(), VehicleEnd::front)); + CHECK(moving->CollisionVelocity(VehicleEnd::front, standing.physics(), VehicleEnd::rear) > physics::Vehicle::SafeCollisionVelocity); + CHECK_FALSE(moving->AutomaticCouplingSafe(VehicleEnd::front, standing.physics(), VehicleEnd::rear)); + CHECK_FALSE(standing->AutomaticCouplingSafe(VehicleEnd::rear, moving.physics(), VehicleEnd::front)); } TEST_CASE("couplers: automatic couplers catch a wagon running ahead only a little slower") { @@ -95,9 +95,9 @@ TEST_CASE("couplers: automatic couplers catch a wagon running ahead only a littl auto faster{automatic_wagon(60.0, "faster")}; auto slower{automatic_wagon(50.0, "slower")}; - CHECK(faster->CollisionVelocity(VehicleEnd::front, slower.mover(), VehicleEnd::rear) == doctest::Approx(10.0)); - CHECK(slower->CollisionVelocity(VehicleEnd::rear, faster.mover(), VehicleEnd::front) == doctest::Approx(10.0)); - CHECK(faster->AutomaticCouplingSafe(VehicleEnd::front, slower.mover(), VehicleEnd::rear)); + CHECK(faster->CollisionVelocity(VehicleEnd::front, slower.physics(), VehicleEnd::rear) == doctest::Approx(10.0)); + CHECK(slower->CollisionVelocity(VehicleEnd::rear, faster.physics(), VehicleEnd::front) == doctest::Approx(10.0)); + CHECK(faster->AutomaticCouplingSafe(VehicleEnd::front, slower.physics(), VehicleEnd::rear)); } TEST_CASE("couplers: without crash damage automatic couplers catch at any speed") { @@ -105,7 +105,7 @@ TEST_CASE("couplers: without crash damage automatic couplers catch at any speed" auto moving{automatic_wagon(30.0, "moving")}; auto standing{automatic_wagon(0.0, "standing")}; - CHECK(moving->AutomaticCouplingSafe(VehicleEnd::front, standing.mover(), VehicleEnd::rear)); + CHECK(moving->AutomaticCouplingSafe(VehicleEnd::front, standing.physics(), VehicleEnd::rear)); } // the closing speed used to treat the speed of each vehicle as a vector turned by half its heading, so for vehicles @@ -116,16 +116,16 @@ TEST_CASE("couplers: the closing speed of a rear-end collision is the difference auto slower{automatic_wagon(25.0, "slower")}; // running forwards, the front of the faster wagon hits the rear of the slower one - CHECK(faster->CollisionVelocity(VehicleEnd::front, slower.mover(), VehicleEnd::rear) == doctest::Approx(15.0)); - CHECK(slower->CollisionVelocity(VehicleEnd::rear, faster.mover(), VehicleEnd::front) == doctest::Approx(15.0)); + CHECK(faster->CollisionVelocity(VehicleEnd::front, slower.physics(), VehicleEnd::rear) == doctest::Approx(15.0)); + CHECK(slower->CollisionVelocity(VehicleEnd::rear, faster.physics(), VehicleEnd::front) == doctest::Approx(15.0)); // the wagons running ahead of each other are parting - CHECK(slower->CollisionVelocity(VehicleEnd::front, faster.mover(), VehicleEnd::rear) == doctest::Approx(-15.0)); + CHECK(slower->CollisionVelocity(VehicleEnd::front, faster.physics(), VehicleEnd::rear) == doctest::Approx(-15.0)); // backing up, the rear of the faster wagon hits the front of the slower one auto backingfaster{automatic_wagon(-40.0, "backing faster")}; auto backingslower{automatic_wagon(-25.0, "backing slower")}; - CHECK(backingfaster->CollisionVelocity(VehicleEnd::rear, backingslower.mover(), VehicleEnd::front) == doctest::Approx(15.0)); - CHECK(backingslower->CollisionVelocity(VehicleEnd::front, backingfaster.mover(), VehicleEnd::rear) == doctest::Approx(15.0)); + CHECK(backingfaster->CollisionVelocity(VehicleEnd::rear, backingslower.physics(), VehicleEnd::front) == doctest::Approx(15.0)); + CHECK(backingslower->CollisionVelocity(VehicleEnd::front, backingfaster.physics(), VehicleEnd::rear) == doctest::Approx(15.0)); } TEST_CASE("couplers: the closing speed of a head-on collision is the sum of the speeds") { @@ -134,27 +134,27 @@ TEST_CASE("couplers: the closing speed of a head-on collision is the sum of the auto second{automatic_wagon(10.0, "second")}; // both wagons run forwards, their fronts meet - CHECK(first->CollisionVelocity(VehicleEnd::front, second.mover(), VehicleEnd::front) == doctest::Approx(20.0)); - CHECK(second->CollisionVelocity(VehicleEnd::front, first.mover(), VehicleEnd::front) == doctest::Approx(20.0)); + CHECK(first->CollisionVelocity(VehicleEnd::front, second.physics(), VehicleEnd::front) == doctest::Approx(20.0)); + CHECK(second->CollisionVelocity(VehicleEnd::front, first.physics(), VehicleEnd::front) == doctest::Approx(20.0)); // 20 km/h is above the limit, the couplers don't catch (the old formula gave 14.1 km/h and coupled them) - CHECK(first->CollisionVelocity(VehicleEnd::front, second.mover(), VehicleEnd::front) > TMoverParameters::SafeCollisionVelocity); - CHECK_FALSE(first->AutomaticCouplingSafe(VehicleEnd::front, second.mover(), VehicleEnd::front)); - CHECK_FALSE(second->AutomaticCouplingSafe(VehicleEnd::front, first.mover(), VehicleEnd::front)); + CHECK(first->CollisionVelocity(VehicleEnd::front, second.physics(), VehicleEnd::front) > physics::Vehicle::SafeCollisionVelocity); + CHECK_FALSE(first->AutomaticCouplingSafe(VehicleEnd::front, second.physics(), VehicleEnd::front)); + CHECK_FALSE(second->AutomaticCouplingSafe(VehicleEnd::front, first.physics(), VehicleEnd::front)); // both wagons back up, their rears meet auto firstbacking{automatic_wagon(-10.0, "first backing")}; auto secondbacking{automatic_wagon(-10.0, "second backing")}; - CHECK(firstbacking->CollisionVelocity(VehicleEnd::rear, secondbacking.mover(), VehicleEnd::rear) == doctest::Approx(20.0)); + CHECK(firstbacking->CollisionVelocity(VehicleEnd::rear, secondbacking.physics(), VehicleEnd::rear) == doctest::Approx(20.0)); // running back to back, the wagons part - CHECK(first->CollisionVelocity(VehicleEnd::rear, second.mover(), VehicleEnd::rear) == doctest::Approx(-20.0)); - CHECK(first->AutomaticCouplingSafe(VehicleEnd::rear, second.mover(), VehicleEnd::rear)); + CHECK(first->CollisionVelocity(VehicleEnd::rear, second.physics(), VehicleEnd::rear) == doctest::Approx(-20.0)); + CHECK(first->AutomaticCouplingSafe(VehicleEnd::rear, second.physics(), VehicleEnd::rear)); // slow enough, the couplers catch auto slowfirst{automatic_wagon(5.0, "slow first")}; auto slowsecond{automatic_wagon(5.0, "slow second")}; - CHECK(slowfirst->CollisionVelocity(VehicleEnd::front, slowsecond.mover(), VehicleEnd::front) == doctest::Approx(10.0)); - CHECK(slowfirst->AutomaticCouplingSafe(VehicleEnd::front, slowsecond.mover(), VehicleEnd::front)); + CHECK(slowfirst->CollisionVelocity(VehicleEnd::front, slowsecond.physics(), VehicleEnd::front) == doctest::Approx(10.0)); + CHECK(slowfirst->AutomaticCouplingSafe(VehicleEnd::front, slowsecond.physics(), VehicleEnd::front)); } TEST_CASE("couplers: the closing speed of a hit on a standing vehicle is the speed of the moving one, whichever way it faces") { @@ -162,17 +162,17 @@ TEST_CASE("couplers: the closing speed of a hit on a standing vehicle is the spe auto standing{automatic_wagon(0.0, "standing")}; // the standing wagon faces away from the moving one - CHECK(moving->CollisionVelocity(VehicleEnd::front, standing.mover(), VehicleEnd::rear) == doctest::Approx(20.0)); - CHECK(standing->CollisionVelocity(VehicleEnd::rear, moving.mover(), VehicleEnd::front) == doctest::Approx(20.0)); + CHECK(moving->CollisionVelocity(VehicleEnd::front, standing.physics(), VehicleEnd::rear) == doctest::Approx(20.0)); + CHECK(standing->CollisionVelocity(VehicleEnd::rear, moving.physics(), VehicleEnd::front) == doctest::Approx(20.0)); // the standing wagon faces the moving one - CHECK(moving->CollisionVelocity(VehicleEnd::front, standing.mover(), VehicleEnd::front) == doctest::Approx(20.0)); - CHECK(standing->CollisionVelocity(VehicleEnd::front, moving.mover(), VehicleEnd::front) == doctest::Approx(20.0)); + CHECK(moving->CollisionVelocity(VehicleEnd::front, standing.physics(), VehicleEnd::front) == doctest::Approx(20.0)); + CHECK(standing->CollisionVelocity(VehicleEnd::front, moving.physics(), VehicleEnd::front) == doctest::Approx(20.0)); // the moving wagon backs up into the standing one auto backing{automatic_wagon(-20.0, "backing")}; - CHECK(backing->CollisionVelocity(VehicleEnd::rear, standing.mover(), VehicleEnd::front) == doctest::Approx(20.0)); - CHECK(backing->CollisionVelocity(VehicleEnd::rear, standing.mover(), VehicleEnd::rear) == doctest::Approx(20.0)); + CHECK(backing->CollisionVelocity(VehicleEnd::rear, standing.physics(), VehicleEnd::front) == doctest::Approx(20.0)); + CHECK(backing->CollisionVelocity(VehicleEnd::rear, standing.physics(), VehicleEnd::rear) == doctest::Approx(20.0)); // the moving wagon runs away from the standing one - CHECK(moving->CollisionVelocity(VehicleEnd::rear, standing.mover(), VehicleEnd::front) == doctest::Approx(-20.0)); + CHECK(moving->CollisionVelocity(VehicleEnd::rear, standing.physics(), VehicleEnd::front) == doctest::Approx(-20.0)); } // the coupling as the simulation runs it: two vehicles on a track, closing in on each other until the couplers (or @@ -183,14 +183,14 @@ TEST_CASE("couplers: automatic couplers catch right up to the safe closing speed auto standing{automatic_wagon(0.0, "standing")}; auto below{automatic_wagon(14.9, "below")}; - CHECK(below->CollisionVelocity(VehicleEnd::front, standing.mover(), VehicleEnd::rear) == doctest::Approx(14.9)); - CHECK(below->AutomaticCouplingSafe(VehicleEnd::front, standing.mover(), VehicleEnd::rear)); + CHECK(below->CollisionVelocity(VehicleEnd::front, standing.physics(), VehicleEnd::rear) == doctest::Approx(14.9)); + CHECK(below->AutomaticCouplingSafe(VehicleEnd::front, standing.physics(), VehicleEnd::rear)); auto above{automatic_wagon(15.1, "above")}; - CHECK(above->CollisionVelocity(VehicleEnd::front, standing.mover(), VehicleEnd::rear) == doctest::Approx(15.1)); - CHECK_FALSE(above->AutomaticCouplingSafe(VehicleEnd::front, standing.mover(), VehicleEnd::rear)); + CHECK(above->CollisionVelocity(VehicleEnd::front, standing.physics(), VehicleEnd::rear) == doctest::Approx(15.1)); + CHECK_FALSE(above->AutomaticCouplingSafe(VehicleEnd::front, standing.physics(), VehicleEnd::rear)); auto faster{automatic_wagon(15.5, "faster")}; - CHECK_FALSE(faster->AutomaticCouplingSafe(VehicleEnd::front, standing.mover(), VehicleEnd::rear)); + CHECK_FALSE(faster->AutomaticCouplingSafe(VehicleEnd::front, standing.physics(), VehicleEnd::rear)); } TEST_CASE("couplers: a wagon rolling slowly into a standing one couples with it") { @@ -204,7 +204,7 @@ TEST_CASE("couplers: a wagon rolling slowly into a standing one couples with it" REQUIRE(pair.coupled()); CHECK(moving->Couplers[VehicleEnd::front].CouplingFlag == (Coupling::coupler | Coupling::brakeHose)); CHECK(standing->Couplers[VehicleEnd::rear].CouplingFlag == (Coupling::coupler | Coupling::brakeHose)); - CHECK(moving->Couplers[VehicleEnd::front].Connected == &standing.mover()); + CHECK(moving->Couplers[VehicleEnd::front].Connected == &standing.physics()); CHECK_FALSE(derailed(moving)); CHECK_FALSE(derailed(standing)); // coupled, they run on together @@ -488,8 +488,8 @@ vehicle articulated_wagon(double Velocity, std::string const &Name) { // couples the facing ends of the two vehicles for good, as the scenery does for an articulated set void join(vehicle &First, VehicleEnd FirstEnd, vehicle &Second, VehicleEnd SecondEnd) { - REQUIRE(First->Attach(FirstEnd, SecondEnd, &Second.mover(), Coupling::coupler, true, false)); - REQUIRE(Second->Attach(SecondEnd, FirstEnd, &First.mover(), Coupling::coupler, true, false)); + REQUIRE(First->Attach(FirstEnd, SecondEnd, &Second.physics(), Coupling::coupler, true, false)); + REQUIRE(Second->Attach(SecondEnd, FirstEnd, &First.physics(), Coupling::coupler, true, false)); } } // namespace @@ -565,7 +565,7 @@ constexpr CouplingSet scenario_coupling{Coupling::coupler | Coupling::brakeHose // couples the rear of the first vehicle to the front of the second one the way the scenery does (forced, from the // first one only), returns the coupling the pair got CouplingSet scenario_couple(vehicle &First, vehicle &Second, CouplingSet const couplings = scenario_coupling) { - REQUIRE(First->Attach(VehicleEnd::rear, VehicleEnd::front, &Second.mover(), couplings, true, false)); + REQUIRE(First->Attach(VehicleEnd::rear, VehicleEnd::front, &Second.physics(), couplings, true, false)); CHECK(Second->Couplers[VehicleEnd::front].CouplingFlag == First->Couplers[VehicleEnd::rear].CouplingFlag); return First->Couplers[VehicleEnd::rear].CouplingFlag; } @@ -581,13 +581,13 @@ TEST_CASE("couplers: an electric and a diesel locomotive don't share their contr SUBCASE("a diesel-electric one with its own control system") { auto diesel{vehicle{definition::fiz("sm42_v1/6d1"), 0.0, "diesel"}}; REQUIRE(diesel->EngineType == TEngineType::DieselElectric); - CHECK_FALSE(electric->ControlCouplingAllowed(VehicleEnd::rear, diesel.mover(), VehicleEnd::front)); + CHECK_FALSE(electric->ControlCouplingAllowed(VehicleEnd::rear, diesel.physics(), VehicleEnd::front)); CHECK(scenario_couple(electric, diesel) == scenario_coupling.Without(Coupling::control)); } SUBCASE("a diesel-mechanical one without a control system named, either") { auto diesel{vehicle{definition::fiz("sm03_v1/sm03"), 0.0, "diesel"}}; REQUIRE(diesel->EngineType == TEngineType::DieselEngine); - CHECK_FALSE(diesel->ControlCouplingAllowed(VehicleEnd::front, electric.mover(), VehicleEnd::rear)); + CHECK_FALSE(diesel->ControlCouplingAllowed(VehicleEnd::front, electric.physics(), VehicleEnd::rear)); CHECK(scenario_couple(diesel, electric) == scenario_coupling.Without(Coupling::control)); } SUBCASE("unless both name the same control system") { @@ -603,7 +603,7 @@ TEST_CASE("couplers: an electric and a diesel locomotive don't share their contr SUBCASE("unless the check is turned off") { control_coupling_check_setting const off{false}; auto diesel{vehicle{definition::fiz("sm42_v1/6d1"), 0.0, "diesel"}}; - CHECK(electric->ControlCouplingAllowed(VehicleEnd::rear, diesel.mover(), VehicleEnd::front)); + CHECK(electric->ControlCouplingAllowed(VehicleEnd::rear, diesel.physics(), VehicleEnd::front)); CHECK(scenario_couple(electric, diesel) == scenario_coupling); } } @@ -664,8 +664,8 @@ TEST_CASE("couplers: the AI and the player get the coupling the vehicles can tak auto diesel{vehicle{definition::fiz("sm42_v1/6d1"), 0.0, "diesel"}}; auto other{vehicle{definition::fiz("ep09_v2/104e"), 0.0, "other"}}; - CHECK(electric->CompatibleCoupling(VehicleEnd::rear, diesel.mover(), VehicleEnd::front, scenario_coupling) == scenario_coupling.Without(Coupling::control)); - CHECK(electric->CompatibleCoupling(VehicleEnd::rear, other.mover(), VehicleEnd::front, scenario_coupling) == scenario_coupling); + CHECK(electric->CompatibleCoupling(VehicleEnd::rear, diesel.physics(), VehicleEnd::front, scenario_coupling) == scenario_coupling.Without(Coupling::control)); + CHECK(electric->CompatibleCoupling(VehicleEnd::rear, other.physics(), VehicleEnd::front, scenario_coupling) == scenario_coupling); // nothing to take away without the control connection asked for - CHECK(electric->CompatibleCoupling(VehicleEnd::rear, diesel.mover(), VehicleEnd::front, Coupling::coupler) == Coupling::coupler); + CHECK(electric->CompatibleCoupling(VehicleEnd::rear, diesel.physics(), VehicleEnd::front, Coupling::coupler) == Coupling::coupler); } diff --git a/tests/unit/test_couplers_trains.cpp b/tests/unit/test_couplers_trains.cpp index cdd4cd9a3..6eed2c6ac 100644 --- a/tests/unit/test_couplers_trains.cpp +++ b/tests/unit/test_couplers_trains.cpp @@ -33,9 +33,9 @@ private: TEST_CASE("couplers: coupled by hand, touching or apart, of the same kind or not") { consist train; - auto &locomotive{train.add(definition::fiz("4e_v1/4e")).mover()}; + auto &locomotive{train.add(definition::fiz("4e_v1/4e")).physics()}; // the wagon's buffers touch the locomotive's, the unit's car stands a metre away - auto &wagon{train.add(definition::fiz("3wl_v2/3wl"), 0, Coupling::none).mover()}; + auto &wagon{train.add(definition::fiz("3wl_v2/3wl"), 0, Coupling::none).physics()}; train.step(); // nothing to couple to, or nothing to couple @@ -86,8 +86,8 @@ TEST_CASE("couplers: a screw coupler uncoupled with the buffers apart, or with t }) { CAPTURE(name); consist train; - auto &locomotive{train.add(definition::fiz("4e_v1/4e")).mover()}; - auto &wagon{train.add(definition::fiz("3wl_v2/3wl"), 0, Coupling::none, 0.0, gap).mover()}; + auto &locomotive{train.add(definition::fiz("4e_v1/4e")).physics()}; + auto &wagon{train.add(definition::fiz("3wl_v2/3wl"), 0, Coupling::none, 0.0, gap).physics()}; REQUIRE(locomotive.Attach(VehicleEnd::rear, VehicleEnd::front, &wagon, couplingtype, true)); if (damaged) { locomotive.DamageFlag.Set(VehicleDamage::coupling); @@ -101,8 +101,8 @@ TEST_CASE("couplers: a screw coupler uncoupled with the buffers apart, or with t } // couplers of different kinds don't couple, unless forced consist train; - auto &locomotive{train.add(definition::fiz("4e_v1/4e")).mover()}; - auto &unit{train.add(definition::fiz("en57_v1/5bgb"), 0, Coupling::none).mover()}; + auto &locomotive{train.add(definition::fiz("4e_v1/4e")).physics()}; + auto &unit{train.add(definition::fiz("en57_v1/5bgb"), 0, Coupling::none).physics()}; train.step(); CHECK_FALSE(locomotive.Attach(VehicleEnd::rear, VehicleEnd::front, &unit, Coupling::coupler)); CHECK(locomotive.Attach(VehicleEnd::rear, VehicleEnd::front, &unit, Coupling::coupler, true)); @@ -141,8 +141,8 @@ TEST_CASE("couplers: automatic couplers coupling on contact") { TEST_CASE("couplers: a coupler broken, with its brake hose torn off") { consist train; - auto &locomotive{train.add(definition::fiz("4e_v1/4e")).mover()}; - auto &wagon{train.add(definition::fiz("3wl_v2/3wl")).mover()}; + auto &locomotive{train.add(definition::fiz("4e_v1/4e")).physics()}; + auto &wagon{train.add(definition::fiz("3wl_v2/3wl")).physics()}; REQUIRE(locomotive.Couplers[VehicleEnd::rear].Connected == &wagon); locomotive.damage_coupler(VehicleEnd::rear); CHECK(locomotive.DamageFlag.HasAll(VehicleDamage::coupling)); @@ -155,7 +155,7 @@ TEST_CASE("couplers: a coupler broken, with its brake hose torn off") { CHECK_FALSE(wagon.AlarmChainFlag); // articulated couplers don't break consist articulated; - auto &unit{articulated.add(definition::fiz("impuls_v1/31we-a_pr")).mover()}; + auto &unit{articulated.add(definition::fiz("impuls_v1/31we-a_pr")).physics()}; articulated.add(definition::fiz("impuls_v1/31we-b_pr")); unit.damage_coupler(VehicleEnd::rear); CHECK_FALSE(unit.DamageFlag.HasAll(VehicleDamage::coupling)); diff --git a/tests/unit/test_crew.cpp b/tests/unit/test_crew.cpp index 112560d61..3c1b17664 100644 --- a/tests/unit/test_crew.cpp +++ b/tests/unit/test_crew.cpp @@ -191,7 +191,7 @@ TEST_CASE("crew: a locomotive under power left by its driver stops and stays bra consist train; train.add(definition::fiz("4e_v1/4e"), 1); get_under_way(train, 20, 30.0); - auto &eu07{train[0].mover()}; + auto &eu07{train[0].physics()}; REQUIRE(train[0].speed() > 20.0); REQUIRE(eu07.MainCtrlPos > 0); REQUIRE(eu07.Mains); @@ -227,7 +227,7 @@ TEST_CASE("crew: what the AI held is let go when the driver leaves") { REQUIRE(cab->DepartureSignal); REQUIRE(cab->SandDose); - crew::secure(cab.mover(), cab.mover()); + crew::secure(cab.physics(), cab.physics()); CHECK(cab->WarningSignal == 0); CHECK_FALSE(cab->DepartureSignal); @@ -241,8 +241,8 @@ TEST_CASE("crew: a train left by its driver is braked through the whole of it") train.add(definition::fiz("11xa_v2/93a")); train.add(definition::fiz("11xa_v2/93a")); get_under_way(train, 20, 40.0); - auto &eu07{train[0].mover()}; - auto &last{train[2].mover()}; + auto &eu07{train[0].physics()}; + auto &last{train[2].physics()}; REQUIRE(train[0].speed() > 15.0); REQUIRE(last.BrakePress < 0.1); @@ -263,7 +263,7 @@ TEST_CASE("crew: a standing locomotive left by its driver is braked too") { auto driver{test::driving(train)}; REQUIRE(test::start_up(driver, line)); test::release_brakes(driver.cab); - auto &eu07{train[0].mover()}; + auto &eu07{train[0].physics()}; // the cylinders of a locomotive started up cold take their time to empty for (int i = 0; i < 180 && eu07.BrakePress >= 0.1; ++i) { test::drive(driver, line, 1.0); @@ -288,7 +288,7 @@ TEST_CASE("crew: the power an integrated handle asked for goes when the driver l impuls->eimic = 0.8; impuls->eimic_real = 0.8; - crew::secure(impuls.mover(), impuls.mover()); + crew::secure(impuls.physics(), impuls.physics()); CHECK(impuls->MainCtrlPos == impuls->MainCtrlNoPowerPos()); CHECK(impuls->eimic == 0.0); @@ -304,7 +304,7 @@ TEST_CASE("crew: a road vehicle left by its driver gets the brake the driver sto REQUIRE(bus->LocalBrakePosA == 0.0); bus->CabActivisation(); - crew::secure(bus.mover(), bus.mover()); + crew::secure(bus.physics(), bus.physics()); CHECK(bus->LocalBrakePosA == 1.0); CHECK(bus->MainCtrlPos == bus->MainCtrlNoPowerPos()); diff --git a/tests/unit/test_definition.cpp b/tests/unit/test_definition.cpp index 2f87906ae..4178da19d 100644 --- a/tests/unit/test_definition.cpp +++ b/tests/unit/test_definition.cpp @@ -59,7 +59,7 @@ TEST_CASE("definition: lines the loader skips or trims: comments, a hash anywher } crlf += c; } - TMoverParameters wagon(0.0, "wagon", "test", 0); + physics::Vehicle wagon(0.0, "wagon", "test", 0); REQUIRE(wagon.LoadFIZ_Text(crlf)); CHECK(wagon.Mass == doctest::Approx(42200.0)); CHECK(wagon.Vmax == doctest::Approx(120.0)); diff --git a/tests/unit/test_derail_motion.cpp b/tests/unit/test_derail_motion.cpp index 2256ea455..57f7f47c5 100644 --- a/tests/unit/test_derail_motion.cpp +++ b/tests/unit/test_derail_motion.cpp @@ -3,7 +3,7 @@ #include "vehicle.h" #include "vehicle/derailmotion.h" #include "physics/derailment.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include @@ -14,7 +14,7 @@ #include // a vehicle off the rails moving on the ground by itself (physics.derailment new): vehicle/derailmotion.h, and what -// the vehicle of TMoverParameters makes of it +// the vehicle of physics::Vehicle makes of it using test::definition; using test::vehicle; @@ -102,7 +102,7 @@ struct outcome { double lying_at{-1.0}; // the time it came to lie on its side, -1 never }; -// the vehicle slides as TMoverParameters drives it: its speed along the heading falls with the friction of the motion +// the vehicle slides as physics::Vehicle drives it: its speed along the heading falls with the friction of the motion // and the gravity of the grade under it, the distance of each step goes to the motion outcome slide(dm::start const &Start, dm::ground const &Ground, double const Dt = 0.01, dm::vehicle_shape const &Shape = eu07(), double const Seconds = 60.0) { dm::body body; @@ -522,7 +522,7 @@ struct car { double gap{0.0}; // of the coupling behind it }; -// the train of bodies off the track on level ground as TMoverParameters and TDynamicObject drive it: their buffers and +// the train of bodies off the track on level ground as physics::Vehicle and TDynamicObject drive it: their buffers and // couplings a spring of 2 MN/m with its damping, the longitudinal motion of each from the forces of its couplings along // its heading and the friction of its motion; the forces across turn them. Dt the step [s]; till all stop or 30 s std::vector run_train(std::vector> const &Starts, dm::vehicle_shape const &Shape, double const Dt = 0.01) { @@ -838,7 +838,7 @@ TEST_CASE("derail motion: the scatter") { namespace { -// a body off the track and the speed its vehicle goes with along its heading, as TMoverParameters keeps it +// a body off the track and the speed its vehicle goes with along its heading, as physics::Vehicle keeps it struct slider { dm::body body; double speed{0.0}; diff --git a/tests/unit/test_derailment_vehicle.cpp b/tests/unit/test_derailment_vehicle.cpp index 32feec44d..b6cadad19 100644 --- a/tests/unit/test_derailment_vehicle.cpp +++ b/tests/unit/test_derailment_vehicle.cpp @@ -2,13 +2,13 @@ #include "doctest.h" #include "vehicle.h" #include "physics/derailment.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include // a vehicle too fast in a curve with physics.derailment of eu07.ini: the criteria of physics/derailment.h checked by -// TMoverParameters::check_derailment(), and what the vehicle comes to off the rails +// physics::Vehicle::check_derailment(), and what the vehicle comes to off the rails using test::definition; using test::vehicle; diff --git a/tests/unit/test_door_wings.cpp b/tests/unit/test_door_wings.cpp index 9eff62441..b5249a739 100644 --- a/tests/unit/test_door_wings.cpp +++ b/tests/unit/test_door_wings.cpp @@ -5,7 +5,7 @@ #include "utilities/parser.h" // the poses of the animated door wings (eu07/maszyna#512): a wing of the main model and its namesake in the low -// poly interior get the same pose, worked out once from the door position of the mover +// poly interior get the same pose, worked out once from the door position of the physics TEST_CASE("door wings: only the door animations move wings") { CHECK(door_wings::is_wing(0x010)); // TAnim::TypeSet for the doors @@ -79,7 +79,7 @@ TEST_CASE("door wings: the kinds of animation are named as DoorOpenMethod of the // in any letter case CHECK(door_wings::type_from_name("plug") == door_wings::plug_type); CHECK(door_wings::type_from_name("SHIFT") == door_wings::shift_type); - // the same numbers as TMoverParameters::door_data::type + // the same numbers as physics::Vehicle::door_data::type CHECK(door_wings::shift_type == 1); CHECK(door_wings::rotate_type == 2); CHECK(door_wings::fold_type == 3); diff --git a/tests/unit/test_drivingaid.cpp b/tests/unit/test_drivingaid.cpp index 4413384f3..4cdacb0ec 100644 --- a/tests/unit/test_drivingaid.cpp +++ b/tests/unit/test_drivingaid.cpp @@ -27,16 +27,16 @@ constexpr drivingaid::cab_controls jointctrl_cab{false, true}; constexpr drivingaid::cab_controls elf_cab{false, false}; drivingaid::readout read(vehicle &Vehicle, drivingaid::cab_controls const &Cab) { - return drivingaid::compute(drivingaid::from_movers(Vehicle.mover(), Vehicle.mover(), Cab)); + return drivingaid::compute(drivingaid::from_vehicles(Vehicle.physics(), Vehicle.physics(), Cab)); } // what the panel showed before: the throttle and brakes numbers, and the local brake always -drivingaid::readout before(TMoverParameters const &Mover) { +drivingaid::readout before(physics::Vehicle const &Physics) { drivingaid::readout result; - result.throttle_first = Mover.EIMCtrlType > 0 ? std::max(0, static_cast(100.4 * Mover.eimic_real)) : Mover.MainCtrlPos; - result.throttle_second = Mover.EIMCtrlType > 0 ? Mover.MainCtrlPos : Mover.ScndCtrlPos; - result.brake_first = Mover.UniCtrlIntegratedBrakeCtrl ? std::max(0.0, -100.0 * Mover.eimic_real) : Mover.fBrakeCtrlPos; - result.local_brake = Mover.LocalBrakePosA * LocalBrakePosNo; + result.throttle_first = Physics.EIMCtrlType > 0 ? std::max(0, static_cast(100.4 * Physics.eimic_real)) : Physics.MainCtrlPos; + result.throttle_second = Physics.EIMCtrlType > 0 ? Physics.MainCtrlPos : Physics.ScndCtrlPos; + result.brake_first = Physics.UniCtrlIntegratedBrakeCtrl ? std::max(0.0, -100.0 * Physics.eimic_real) : Physics.fBrakeCtrlPos; + result.local_brake = Physics.LocalBrakePosA * LocalBrakePosNo; return result; } @@ -165,7 +165,7 @@ TEST_CASE("driving aid: every real vehicle with a local brake control shows the real->LocalBrakePosA = localbrake; real->eimic_real = eimic; auto const now{read(real, lever_cab)}; - auto const was{before(real.mover())}; + auto const was{before(real.physics())}; CHECK(now.throttle_first == was.throttle_first); CHECK(now.throttle_second == was.throttle_second); CHECK(now.brake_first == doctest::Approx(was.brake_first)); diff --git a/tests/unit/test_dynamic_brake_diesel.cpp b/tests/unit/test_dynamic_brake_diesel.cpp index ddebba682..085d77a9d 100644 --- a/tests/unit/test_dynamic_brake_diesel.cpp +++ b/tests/unit/test_dynamic_brake_diesel.cpp @@ -51,15 +51,15 @@ definition st44_braking() { } // the force of the brakes above at full effort at the speed of the vehicle -double br285_limit(TMoverParameters const &Vehicle) { +double br285_limit(physics::Vehicle const &Vehicle) { return std::min(150000.0, 2000000.0 / std::abs(Vehicle.V)) * std::clamp((Vehicle.Vel - 2.0) / 4.0, 0.0, 1.0); } -double st44_limit(TMoverParameters const &Vehicle) { +double st44_limit(physics::Vehicle const &Vehicle) { return std::min(120000.0, 1200000.0 / std::abs(Vehicle.V)) * std::clamp(Vehicle.Vel / 40.0, 0.0, 1.0); } // the controller of the BR285 down to the given position, a step a time -void controller_to(TMoverParameters &Locomotive, int Position) { +void controller_to(physics::Vehicle &Locomotive, int Position) { while (Locomotive.MainCtrlPos > Position && Locomotive.DecMainCtrl(1)) {} while (Locomotive.MainCtrlPos < Position && Locomotive.IncMainCtrl(1)) {} } @@ -71,7 +71,7 @@ TEST_CASE("diesel-electric dynamic brake: none without its definition") { for (auto const &path : test::real_vehicles()) { CAPTURE(path); test::vehicle vehicle{definition::fiz(path)}; - CHECK(vehicle->DEDynamicBrake.source == TMoverParameters::diesel_electric_dynamic_brake::control::none); + CHECK(vehicle->DEDynamicBrake.source == physics::Vehicle::diesel_electric_dynamic_brake::control::none); } scenario scenario{"dynamic brake/diesel electric/br285 without", motion() + traction() + dynamic_brake()}; scenario.add("br285_v1/br285", 1); @@ -99,7 +99,7 @@ TEST_CASE("diesel-electric dynamic brake: the BR285's controller") { scenario scenario{"dynamic brake/diesel electric/br285", motion() + traction() + brakes() + dynamic_brake()}; scenario.train().add(br285_braking(), 1); auto &locomotive{scenario.cab()}; - REQUIRE(locomotive.DEDynamicBrake.source == TMoverParameters::diesel_electric_dynamic_brake::control::controller); + REQUIRE(locomotive.DEDynamicBrake.source == physics::Vehicle::diesel_electric_dynamic_brake::control::controller); CHECK(locomotive.DEDynamicBrake.max_force == doctest::Approx(150000.0)); CHECK(locomotive.DEDynamicBrake.max_power == doctest::Approx(2000000.0)); REQUIRE(scenario.start_up()); @@ -164,7 +164,7 @@ TEST_CASE("diesel-electric dynamic brake: a resistor brake with its own lever") scenario scenario{"dynamic brake/diesel electric/st44 lever", motion() + traction() + brakes() + dynamic_brake()}; scenario.train().add(st44_braking(), 1); auto &locomotive{scenario.cab()}; - REQUIRE(locomotive.DEDynamicBrake.source == TMoverParameters::diesel_electric_dynamic_brake::control::lever); + REQUIRE(locomotive.DEDynamicBrake.source == physics::Vehicle::diesel_electric_dynamic_brake::control::lever); CHECK(locomotive.SplitEDPneumaticBrake); CHECK(locomotive.DynamicBrakeCtrlPosNo == 8); REQUIRE(scenario.start_up()); diff --git a/tests/unit/test_elf_controller.cpp b/tests/unit/test_elf_controller.cpp index d099c3303..945eee844 100644 --- a/tests/unit/test_elf_controller.cpp +++ b/tests/unit/test_elf_controller.cpp @@ -72,8 +72,8 @@ struct elf { cab().UniversalBrakeButton(0, 0); wait(30.0); } - TMoverParameters &cab() { return unit[0].mover(); } - TMoverParameters &car(std::size_t Index) { return unit[Index].mover(); } + physics::Vehicle &cab() { return unit[0].physics(); } + physics::Vehicle &car(std::size_t Index) { return unit[Index].physics(); } // the driver moves the controller notch by notch, which the cab sends on to the coupled vehicles void set_controller(int Position) { while (cab().MainCtrlPos < Position && cab().IncMainCtrl(1)) { @@ -94,62 +94,62 @@ TEST_CASE("elf controller: without EIMCtrlMainEmergency the positions stay as th elf unit{false}; REQUIRE(unit.ready); REQUIRE(unit.charged); - auto &mover{unit.cab()}; - CHECK_FALSE(mover.EIMCtrlMainEmergency); - CHECK(mover.EIMCtrlEmergencyPositions() == 0); - CHECK(mover.MainCtrlPosNo == 4); - CHECK(mover.MainCtrlNoPowerPos() == 3); - CHECK(mover.MainCtrlPos == 3); + auto &physics{unit.cab()}; + CHECK_FALSE(physics.EIMCtrlMainEmergency); + CHECK(physics.EIMCtrlEmergencyPositions() == 0); + CHECK(physics.MainCtrlPosNo == 4); + CHECK(physics.MainCtrlNoPowerPos() == 3); + CHECK(physics.MainCtrlPos == 3); // the lowest position brakes fully, without emptying the pipe - mover.MainCtrlPos = 0; - CHECK_FALSE(mover.IsMainCtrlEmergencyPos()); + physics.MainCtrlPos = 0; + CHECK_FALSE(physics.IsMainCtrlEmergencyPos()); unit.wait(10.0); - CHECK(mover.eimic == doctest::Approx(-1.0)); - CHECK(mover.PipePress > 4.5); + CHECK(physics.eimic == doctest::Approx(-1.0)); + CHECK(physics.PipePress > 4.5); } TEST_CASE("elf controller: EIMCtrlMainEmergency shifts the positions up by the emergency brake one") { elf unit{true}; REQUIRE(unit.ready); REQUIRE(unit.charged); - auto &mover{unit.cab()}; - CHECK(mover.EIMCtrlMainEmergency); - CHECK(mover.EIMCtrlEmergencyPositions() == 1); - CHECK(mover.MainCtrlPosNo == 5); - CHECK(mover.MainCtrlNoPowerPos() == 4); - CHECK(mover.MainCtrlPos == 4); - CHECK_FALSE(mover.IsMainCtrlEmergencyPos()); + auto &physics{unit.cab()}; + CHECK(physics.EIMCtrlMainEmergency); + CHECK(physics.EIMCtrlEmergencyPositions() == 1); + CHECK(physics.MainCtrlPosNo == 5); + CHECK(physics.MainCtrlNoPowerPos() == 4); + CHECK(physics.MainCtrlPos == 4); + CHECK_FALSE(physics.IsMainCtrlEmergencyPos()); SUBCASE("the neutral position neither drives nor brakes") { unit.wait(5.0); - CHECK(mover.eimic == doctest::Approx(0.0)); + CHECK(physics.eimic == doctest::Approx(0.0)); } SUBCASE("the full braking position, formerly 0, brakes fully without emptying the pipe") { - mover.MainCtrlPos = 1; + physics.MainCtrlPos = 1; unit.wait(10.0); - CHECK(mover.eimic == doctest::Approx(-1.0)); - CHECK(mover.PipePress > 4.5); + CHECK(physics.eimic == doctest::Approx(-1.0)); + CHECK(physics.PipePress > 4.5); } SUBCASE("the braking position, formerly 1, ramps the braking up") { - mover.MainCtrlPos = 2; + physics.MainCtrlPos = 2; unit.wait(1.0); - CHECK(mover.eimic < 0.0); - CHECK(mover.eimic > -1.0); - CHECK(mover.PipePress > 4.5); + CHECK(physics.eimic < 0.0); + CHECK(physics.eimic > -1.0); + CHECK(physics.PipePress > 4.5); } SUBCASE("the emergency brake position brakes fully at once and empties the pipe") { - mover.MainCtrlPos = 0; - CHECK(mover.IsMainCtrlEmergencyPos()); + physics.MainCtrlPos = 0; + CHECK(physics.IsMainCtrlEmergencyPos()); // a single step of the physics unit.unit.step(unit.line); - CHECK(mover.eimic == doctest::Approx(-1.0)); + CHECK(physics.eimic == doctest::Approx(-1.0)); unit.wait(10.0); - CHECK(mover.PipePress < 0.5); - CHECK(mover.BrakePress > 1.0); + CHECK(physics.PipePress < 0.5); + CHECK(physics.BrakePress > 1.0); // out of it the pipe charges again - mover.MainCtrlPos = mover.MainCtrlNoPowerPos(); - CHECK_FALSE(mover.IsMainCtrlEmergencyPos()); + physics.MainCtrlPos = physics.MainCtrlNoPowerPos(); + CHECK_FALSE(physics.IsMainCtrlEmergencyPos()); unit.recharge(); - CHECK(mover.PipePress > 4.5); + CHECK(physics.PipePress > 4.5); } } @@ -171,18 +171,18 @@ TEST_CASE("elf controller: the reverser works at the neutral shifted by EIMCtrlM // the key added to the old files, DirChangeMaxPos=3 in them elf unit{{data::emergency_old_layout}}; REQUIRE(unit.ready); - auto &mover{unit.cab()}; - REQUIRE(mover.MainCtrlPos == mover.MainCtrlNoPowerPos()); - REQUIRE(mover.DirActive == 1); - CHECK(mover.DirectionBackward()); - CHECK(mover.DirActive == 0); - CHECK(mover.DirectionForward()); - CHECK(mover.DirActive == 1); + auto &physics{unit.cab()}; + REQUIRE(physics.MainCtrlPos == physics.MainCtrlNoPowerPos()); + REQUIRE(physics.DirActive == 1); + CHECK(physics.DirectionBackward()); + CHECK(physics.DirActive == 0); + CHECK(physics.DirectionForward()); + CHECK(physics.DirActive == 1); // not in the power position - unit.set_controller(mover.MainCtrlNoPowerPos() + 1); - REQUIRE(mover.MainCtrlPos == 5); - CHECK_FALSE(mover.DirectionBackward()); - CHECK(mover.DirActive == 1); + unit.set_controller(physics.MainCtrlNoPowerPos() + 1); + REQUIRE(physics.MainCtrlPos == 5); + CHECK_FALSE(physics.DirectionBackward()); + CHECK(physics.DirActive == 1); } TEST_CASE("elf controller: the emergency brake position vents the pipe only from the vehicle driven from") { @@ -264,7 +264,7 @@ TEST_CASE("elf controller: EIMCtrlMainEmergency leaves the other controllers alo // the holding brake of the Elf (SBD) lets go only once power has been demanded for SBDReleaseDelay (eu07/maszyna#556): // the release waits the initial delay of the controller (IniCDelay) instead of going at the first percent of the // demand. TDynamicObject::Update() works the holding brake out, its MED isn't in the tests, so they do here what it -// does with it: TMoverParameters::UpdateStopBrakeRelease() of the cab with its demand after every step and, where the +// does with it: physics::Vehicle::UpdateStopBrakeRelease() of the cab with its demand after every step and, where the // brake matters, the brake's share of every car on its cylinders (LocalBrakePosAEIM) namespace { diff --git a/tests/unit/test_engine_start.cpp b/tests/unit/test_engine_start.cpp index a7aeff790..cf9aa4e42 100644 --- a/tests/unit/test_engine_start.cpp +++ b/tests/unit/test_engine_start.cpp @@ -27,7 +27,7 @@ definition sn61(bool const Joint = true) { // pressure built up, and the controller at the first position giving the engines fuel, which a mechanical diesel // starts at: everything but the engines ready to start void prepare(consist &Train) { - auto &cab{Train[0].mover()}; + auto &cab{Train[0].physics()}; cab.BatterySwitch(true); cab.CabActivisation(); cab.OilPumpSwitch(true); @@ -38,7 +38,7 @@ void prepare(consist &Train) { Train.run(20.0); } -bool running(TMoverParameters const &Vehicle) { +bool running(physics::Vehicle const &Vehicle) { return Vehicle.Mains && Vehicle.enrot > 0.5 * Vehicle.diesel.minRevolutions; } @@ -51,7 +51,7 @@ int steps(double const Seconds) { } // the switch of Engine held closed for Seconds, then let go, in steps of the train -void hold(consist &Train, engine_start::remote_switch &Switch, TMoverParameters *Engine, double const Seconds, bool const Closesonrelease = false) { +void hold(consist &Train, engine_start::remote_switch &Switch, physics::Vehicle *Engine, double const Seconds, bool const Closesonrelease = false) { for (auto step = 0; step < steps(Seconds); ++step) { Switch.update(Engine, true, false, dt, Closesonrelease); Train.step({}, dt); @@ -63,8 +63,8 @@ void hold(consist &Train, engine_start::remote_switch &Switch, TMoverParameters TEST_CASE("engine start: the joint start is the default, and JointEngineStart=No keeps the cab's switch to its vehicle") { consist train; - auto const &joint{train.add(sn61(), 1).mover()}; - auto const &separate{train.add(sn61(false)).mover()}; + auto const &joint{train.add(sn61(), 1).physics()}; + auto const &separate{train.add(sn61(false)).physics()}; CHECK(joint.JointEngineStart); CHECK_FALSE(separate.JointEngineStart); CHECK(joint.MainSwitchRange() == range_t::consist); @@ -73,9 +73,9 @@ TEST_CASE("engine start: the joint start is the default, and JointEngineStart=No TEST_CASE("engine start: the vehicles in multiple, counted from the cab's own one, those behind the cab first") { consist train; - auto &first{train.add(sn61(), 1).mover()}; - auto &second{train.add(sn61()).mover()}; - auto &third{train.add(sn61()).mover()}; + auto &first{train.add(sn61(), 1).physics()}; + auto &second{train.add(sn61()).physics()}; + auto &third{train.add(sn61()).physics()}; CHECK(engine_start::engine(first, first, 1) == &first); CHECK(engine_start::engine(first, first, 2) == &second); CHECK(engine_start::engine(first, first, 3) == &third); @@ -96,10 +96,10 @@ TEST_CASE("engine start: the vehicles in multiple, counted from the cab's own on TEST_CASE("engine start: only the vehicles with an engine and under control through the cable count") { consist train; - auto &first{train.add(sn61(), 1).mover()}; + auto &first{train.add(sn61(), 1).physics()}; // a vehicle without an engine between the railcars is passed over - auto &trailer{train.add(definition::fiz("ed72_v1/5bs-ra")).mover()}; - auto &second{train.add(sn61()).mover()}; + auto &trailer{train.add(definition::fiz("ed72_v1/5bs-ra")).physics()}; + auto &second{train.add(sn61()).physics()}; REQUIRE(trailer.Power < 0.01); CHECK(engine_start::engine(first, first, 2) == &second); // the vehicle with the cab doesn't drive itself: its engine is in the vehicle it controls, which isn't counted twice @@ -110,15 +110,15 @@ TEST_CASE("engine start: only the vehicles with an engine and under control thro // coupled without the control cable, the other railcar isn't under the cab's control consist apart; - auto &alone{apart.add(sn61(), 1).mover()}; + auto &alone{apart.add(sn61(), 1).physics()}; apart.add(sn61(), 0, Coupling::coupler | Coupling::brakeHose); CHECK(engine_start::engine(alone, alone, 2) == nullptr); } TEST_CASE("engine start: by default the cab's switch starts and stops the engines of all the vehicles in multiple") { consist train; - auto &first{train.add(sn61(), 1).mover()}; - auto const &second{train.add(sn61()).mover()}; + auto &first{train.add(sn61(), 1).physics()}; + auto const &second{train.add(sn61()).physics()}; prepare(train); REQUIRE_FALSE(first.Mains); REQUIRE_FALSE(second.Mains); @@ -134,9 +134,9 @@ TEST_CASE("engine start: by default the cab's switch starts and stops the engine TEST_CASE("engine start: with JointEngineStart=No each engine has its own switch") { consist train; - auto &first{train.add(sn61(false), 1).mover()}; - auto &second{train.add(sn61(false)).mover()}; - auto &third{train.add(sn61(false)).mover()}; + auto &first{train.add(sn61(false), 1).physics()}; + auto &second{train.add(sn61(false)).physics()}; + auto &third{train.add(sn61(false)).physics()}; prepare(train); // the cab's own switch starts its own engine only first.MainSwitch(true, first.MainSwitchRange()); @@ -177,7 +177,7 @@ TEST_CASE("engine start: with JointEngineStart=No each engine has its own switch TEST_CASE("engine start: the switch of another vehicle is held for the vehicle's delay, with the vehicle ready") { consist train; train.add(sn61(false).set("Cntrl", "IniCDelay", "2.0"), 1); - auto &second{train.add(sn61(false).set("Cntrl", "IniCDelay", "2.0")).mover()}; + auto &second{train.add(sn61(false).set("Cntrl", "IniCDelay", "2.0")).physics()}; REQUIRE(second.InitialCtrlDelay == doctest::Approx(2.0)); engine_start::remote_switch switchb; @@ -207,7 +207,7 @@ TEST_CASE("engine start: the switch of another vehicle is held for the vehicle's TEST_CASE("engine start: a switch closing on release, as an electric locomotive's impulse switch, waits to be let go") { consist train; train.add(sn61(false), 1); - auto &second{train.add(sn61(false).set("Cntrl", "IniCDelay", "1.0")).mover()}; + auto &second{train.add(sn61(false).set("Cntrl", "IniCDelay", "1.0")).physics()}; prepare(train); engine_start::remote_switch switchb; // held past the delay, the circuit stays open while the switch is held @@ -233,8 +233,8 @@ TEST_CASE("engine start: an engine stopping on its own stops the others only whe for (auto const joint : {true, false}) { CAPTURE(joint); consist train; - auto &first{train.add(sn61(joint), 1).mover()}; - auto const &second{train.add(sn61(joint)).mover()}; + auto &first{train.add(sn61(joint), 1).physics()}; + auto const &second{train.add(sn61(joint)).physics()}; prepare(train); engine_start::remote_switch switchb; first.MainSwitch(true, first.MainSwitchRange()); @@ -259,9 +259,9 @@ TEST_CASE("engine start: an engine stopped from its own switch doesn't stop the consist train; // the middle railcar keeps the joint start, as a .fiz without the key does. what a vehicle without the cab relays // goes on away from the cab, so it's the third one that would stop - auto &first{train.add(sn61(false), 1).mover()}; - auto &second{train.add(sn61()).mover()}; - auto &third{train.add(sn61(false)).mover()}; + auto &first{train.add(sn61(false), 1).physics()}; + auto &second{train.add(sn61()).physics()}; + auto &third{train.add(sn61(false)).physics()}; prepare(train); engine_start::remote_switch switchb; engine_start::remote_switch switchc; @@ -284,8 +284,8 @@ TEST_CASE("engine start: an engine stopped from its own switch doesn't stop the TEST_CASE("engine start: the stopped engine of the cab's vehicle doesn't stop the one started from its switch") { consist train; // the cab's railcar keeps the joint start, its engine stopped - auto &first{train.add(sn61(), 1).mover()}; - auto &second{train.add(sn61(false)).mover()}; + auto &first{train.add(sn61(), 1).physics()}; + auto &second{train.add(sn61(false)).physics()}; prepare(train); REQUIRE_FALSE(first.Mains); // mainb_on diff --git a/tests/unit/test_est3al2_relay.cpp b/tests/unit/test_est3al2_relay.cpp index be4adf244..5af02f313 100644 --- a/tests/unit/test_est3al2_relay.cpp +++ b/tests/unit/test_est3al2_relay.cpp @@ -68,7 +68,7 @@ times measure(int const Delay, int const Lever) { if (wagon->BrakeDelayFlag != Delay) { REQUIRE(wagon->BrakeDelaySwitch(Delay)); } - // an empty wagon starts with the lever at empty (TMoverParameters::CheckLocomotiveParameters) + // an empty wagon starts with the lever at empty (physics::Vehicle::CheckLocomotiveParameters) REQUIRE(wagon->LoadFlag == 1); while (wagon->LoadFlag < Lever) { REQUIRE(wagon->IncBrakeMult()); diff --git a/tests/unit/test_fcfuh_default.cpp b/tests/unit/test_fcfuh_default.cpp index f52a7cdd5..bd5120915 100644 --- a/tests/unit/test_fcfuh_default.cpp +++ b/tests/unit/test_fcfuh_default.cpp @@ -19,7 +19,7 @@ using test::vehicle; namespace { -// a figure read from a line the way TMoverParameters::LoadFIZ_EngineInductionMotor() reads fcfu +// a figure read from a line the way physics::Vehicle::LoadFIZ_EngineInductionMotor() reads fcfu double read_fcfu(std::string const &Text) { double fcfu{0.0}; extract_value(fcfu, "fcfu", "fcfu=" + Text, ""); diff --git a/tests/unit/test_feed_pipe.cpp b/tests/unit/test_feed_pipe.cpp index 2164d2784..21ff98e4d 100644 --- a/tests/unit/test_feed_pipe.cpp +++ b/tests/unit/test_feed_pipe.cpp @@ -1,12 +1,12 @@ #include "stdafx.h" #include "doctest.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "physics/brakes.h" #include "consist.h" #include "vehicle.h" -// the air exchange through the main reservoir hoses between the vehicles of a train (TMoverParameters::UpdatePipeCouplers()). +// the air exchange through the main reservoir hoses between the vehicles of a train (physics::Vehicle::UpdatePipeCouplers()). // taken in one explicit step of 0.01 s, a hose carried about 1.5 times the air which evens out the pipes on its ends, // and the vehicles' own main reservoirs fed the pipe in the same step: the pipes of the middle vehicles of a multiple // unit, or of locomotives in multiple traction, kept jumping 0.8 bar to and fro between the steps, with the main @@ -66,18 +66,18 @@ evening_out even_out(Builder Train, int const Count, double const Pressure, doub test::consist train; Train(train, Count); for (std::size_t i = 0; i < train.size(); ++i) { - auto &mover{train[i].mover()}; - REQUIRE(mover.VeselVolume > 0.0); + auto &physics{train[i].physics()}; + REQUIRE(physics.VeselVolume > 0.0); auto const pressure{i == 0 ? Pressure : Pressure - 1.0}; - mover.CompressedVolume = pressure * mover.VeselVolume; - mover.Compressor = pressure; - mover.Pipe2->CreatePress(pressure); - mover.Pipe2->Act(); - mover.ScndPipePress = pressure; + physics.CompressedVolume = pressure * physics.VeselVolume; + physics.Compressor = pressure; + physics.Pipe2->CreatePress(pressure); + physics.Pipe2->Act(); + physics.ScndPipePress = pressure; } evening_out result; - auto const &first{train[0].mover()}; - auto const &last{train[train.size() - 1].mover()}; + auto const &first{train[0].physics()}; + auto const &last{train[train.size() - 1].physics()}; std::vector previous(train.size()); std::vector change(train.size()); for (std::size_t i = 0; i < train.size(); ++i) { @@ -112,14 +112,14 @@ double charging_time(Builder Train, int const Count, double const Pressure, doub Train(train, Count); train[0].hold_main_reservoir(Pressure); for (std::size_t i = 1; i < train.size(); ++i) { - auto &mover{train[i].mover()}; - REQUIRE(mover.VeselVolume == 0.0); - mover.Pipe2->CreatePress(0.0); - mover.Pipe2->Act(); - mover.ScndPipePress = 0.0; + auto &physics{train[i].physics()}; + REQUIRE(physics.VeselVolume == 0.0); + physics.Pipe2->CreatePress(0.0); + physics.Pipe2->Act(); + physics.ScndPipePress = 0.0; } - auto const &first{train[0].mover()}; - auto const &last{train[train.size() - 1].mover()}; + auto const &first{train[0].physics()}; + auto const &last{train[train.size() - 1].physics()}; auto time{0.0}; while ((last.ScndPipePress < 1.0 || std::abs(last.ScndPipePress - first.ScndPipePress) > 0.2) && time < 60.0) { train.step({}, Dt); diff --git a/tests/unit/test_figures.cpp b/tests/unit/test_figures.cpp index c8b575d50..d40bc158b 100644 --- a/tests/unit/test_figures.cpp +++ b/tests/unit/test_figures.cpp @@ -15,24 +15,24 @@ using test::vehicle; TEST_CASE("figures: a run split into parts by the events, each from the last step of the part before") { vehicle eu07{definition::fiz("4e_v1/4e")}; test::figures figures; - auto &mover{eu07.mover()}; - mover.V = 10.0; - mover.PipePress = 5.0; - figures.sample(0.0, mover); + auto &physics{eu07.physics()}; + physics.V = 10.0; + physics.PipePress = 5.0; + figures.sample(0.0, physics); figures.mark("brake"); figures.mark("hard"); for (int i = 1; i <= 10; ++i) { - mover.V = 10.0 - i; - mover.DistCounter += 0.005; - mover.PipePress = 3.5; - mover.BrakePress = 0.4 * i; - figures.sample(i, mover); + physics.V = 10.0 - i; + physics.DistCounter += 0.005; + physics.PipePress = 3.5; + physics.BrakePress = 0.4 * i; + figures.sample(i, physics); } figures.mark("release"); - mover.PipePress = 4.0; - figures.sample(11.0, mover); - mover.PipePress = 5.0; - figures.sample(12.0, mover); + physics.PipePress = 4.0; + figures.sample(11.0, physics); + physics.PipePress = 5.0; + figures.sample(12.0, physics); auto const lines{figures.lines()}; auto const has{[&lines](std::string const &Line) { return std::ranges::find(lines, Line) != lines.end(); }}; diff --git a/tests/unit/test_fiz.cpp b/tests/unit/test_fiz.cpp index f25632dee..3e1b64760 100644 --- a/tests/unit/test_fiz.cpp +++ b/tests/unit/test_fiz.cpp @@ -23,7 +23,7 @@ TEST_CASE("fiz: every real vehicle loads and keeps its parameters") { test::reseed_random(); vehicle real{definition::fiz(path)}; test::trace trace{"fiz/" + path, test::channels::parameters(), 1}; - trace.sample(0.0, real.mover()); + trace.sample(0.0, real.physics()); // what every vehicle has, the rest of its parameters are in the golden trace CHECK(real->Mass > 0.0); CHECK(real->TotalMass >= real->Mass); diff --git a/tests/unit/test_gauge_scale.cpp b/tests/unit/test_gauge_scale.cpp index 04fa645bb..9e59e5114 100644 --- a/tests/unit/test_gauge_scale.cpp +++ b/tests/unit/test_gauge_scale.cpp @@ -84,7 +84,7 @@ TEST_CASE("main ctrl act: the marker of a diesel locomotive with a scaletable: f for (auto const *path : {"st44_v2/m62-1151", "sm42_v1/6d1", "su45_v2/301d"}) { CAPTURE(path); consist train; - auto &locomotive{train.add(definition::fiz(path), 1).mover()}; + auto &locomotive{train.add(definition::fiz(path), 1).physics()}; REQUIRE((locomotive.EngineType == TEngineType::DieselElectric || locomotive.EngineType == TEngineType::DieselEngine)); REQUIRE(locomotive.EIMCtrlType == 0); locomotive.MainCtrlPos = 5; @@ -101,7 +101,7 @@ TEST_CASE("main ctrl act: the marker of a diesel locomotive without a scaletable for (auto const *path : {"st44_v2/m62-1151", "sm42_v1/6d1", "su45_v2/301d"}) { CAPTURE(path); consist train; - auto &locomotive{train.add(definition::fiz(path), 1).mover()}; + auto &locomotive{train.add(definition::fiz(path), 1).physics()}; REQUIRE(locomotive.EIMCtrlType == 0); locomotive.MainCtrlPos = 5; locomotive.ScndCtrlPos = 1; @@ -117,7 +117,7 @@ TEST_CASE("main ctrl act: the marker of an electric locomotive shows its actual for (auto const scaletable : {false, true}) { CAPTURE(scaletable); consist train; - auto &locomotive{train.add(definition::fiz("et22_v3/201e-w"), 1).mover()}; + auto &locomotive{train.add(definition::fiz("et22_v3/201e-w"), 1).physics()}; locomotive.MainCtrlPos = 10; locomotive.MainCtrlActualPos = 3; locomotive.ScndCtrlPos = 2; diff --git a/tests/unit/test_genset.cpp b/tests/unit/test_genset.cpp index be52eab9a..cc9172a53 100644 --- a/tests/unit/test_genset.cpp +++ b/tests/unit/test_genset.cpp @@ -14,7 +14,7 @@ using test::consist; using test::definition; using test::track; using test::vehicle; -using traction_mode = TMoverParameters::traction_mode; +using traction_mode = physics::Vehicle::traction_mode; namespace { @@ -40,7 +40,7 @@ track const no_wire{0.15, 0.0, 0.0}; track const wire{0.15, 0.0, test::catenary_3kv}; // the battery, the cab and a direction, as the driver begins -void wake(TMoverParameters &Cab) { +void wake(physics::Vehicle &Cab) { Cab.BatterySwitch(true); Cab.CabActivisation(); for (int i = 0; i < 3 && Cab.DirActive <= 0; ++i) { @@ -49,7 +49,7 @@ void wake(TMoverParameters &Cab) { } // the vigilance and the cab signalling acknowledged, as test::drive() does once a second -void attend(TMoverParameters &Cab) { +void attend(physics::Vehicle &Cab) { if (Cab.SecuritySystem.is_cabsignal_blinking() && Cab.SecuritySystem.has_separate_acknowledge()) { Cab.SecuritySystem.cabsignal_reset(); } @@ -63,7 +63,7 @@ void run(vehicle &Vehicle, double const Seconds, track const &Track = no_wire) { } // the line breaker closed, which it does only with the controller at zero, and after the relays are reset -void close_line_breaker(TMoverParameters &Cab) { +void close_line_breaker(physics::Vehicle &Cab) { while (Cab.DecMainCtrl(2)) { // down to zero } @@ -75,7 +75,7 @@ void close_line_breaker(TMoverParameters &Cab) { // genset, the genset started, the line breaker closed once it runs, the converter and the compressor, the air, the // brakes released. one round of the driver's actions a second; returns whether the vehicle got ready bool start_on_genset(vehicle &Vehicle, track const &Track = no_wire, double const Seconds = 300.0) { - auto &cab{Vehicle.mover()}; + auto &cab{Vehicle.physics()}; for (auto second = 0; second < Seconds; ++second) { wake(cab); cab.TractionModeSwitch(traction_mode::genset); @@ -103,21 +103,21 @@ bool start_on_genset(vehicle &Vehicle, track const &Track = no_wire, double cons } // the main controller to its full power position -void notch_up(TMoverParameters &Cab) { +void notch_up(physics::Vehicle &Cab) { for (int i = 0; i < 60 && false == Cab.IsMainCtrlMaxPowerPos(); ++i) { Cab.IncMainCtrl(1); } } // the power at the wheels [kW] -double wheel_power(TMoverParameters const &Vehicle) { +double wheel_power(physics::Vehicle const &Vehicle) { return std::abs(Vehicle.Ft * Vehicle.V) / 1000.0; } // one step of 0.01 s, acknowledging the vigilance once a second void step(vehicle &Vehicle, long const Step, track const &Track = no_wire) { if (Step % 100 == 0) { - attend(Vehicle.mover()); + attend(Vehicle.physics()); } Vehicle.step(Track); } @@ -126,7 +126,7 @@ void step(vehicle &Vehicle, long const Step, track const &Track = no_wire) { TEST_CASE("genset: a vehicle without the keys has none and stays on the catenary") { vehicle dragon6{dragon(), 0.0, "plain", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; CHECK(cab.Genset.power == 0.0); CHECK_FALSE(cab.Genset.fitted()); CHECK_FALSE(cab.TractionModeSwitch(traction_mode::genset)); @@ -191,7 +191,7 @@ TEST_CASE("genset: the keys are ignored on other than induction motor vehicles") TEST_CASE("genset: the selector moves only with the line breaker open") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; REQUIRE(test::start_up(test::driving(dragon6), wire)); REQUIRE(cab.Mains); CHECK_FALSE(cab.TractionModeSwitch(traction_mode::genset)); @@ -208,7 +208,7 @@ TEST_CASE("genset: the selector moves only with the line breaker open") { TEST_CASE("genset: started, it closes the line breaker without a catenary") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; wake(cab); REQUIRE(cab.TractionModeSwitch(traction_mode::genset)); cab.GensetSwitch(true); @@ -240,7 +240,7 @@ TEST_CASE("genset: started, it closes the line breaker without a catenary") { TEST_CASE("genset: on the catenary position the genset feeds nothing") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; wake(cab); cab.GensetSwitch(true); run(dragon6, 20.0); @@ -258,7 +258,7 @@ TEST_CASE("genset: on the catenary position the genset feeds nothing") { TEST_CASE("genset: on the genset position the catenary feeds nothing") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; wake(cab); REQUIRE(cab.TractionModeSwitch(traction_mode::genset)); // the pantographs up under the wire, the genset stopped: the line breaker never closes @@ -273,7 +273,7 @@ TEST_CASE("genset: on the genset position the catenary feeds nothing") { TEST_CASE("genset: the power at the wheels stays within the genset's") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; REQUIRE(start_on_genset(dragon6)); notch_up(cab); auto peak{0.0}; @@ -301,7 +301,7 @@ TEST_CASE("genset: the power at the wheels stays within the genset's") { TEST_CASE("genset: the revolutions follow the demand, so the power builds up") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; REQUIRE(start_on_genset(dragon6)); // at idle with nothing asked of it CHECK(cab.Genset.revolutions == doctest::Approx(cab.Genset.revolutions_idle)); @@ -341,11 +341,11 @@ TEST_CASE("genset: running from the catenary is the same with the keys") { }; auto const record = [](values &Values) { return std::vector{ - {"Ft", [&Values](TMoverParameters const &Vehicle) { Values.force.push_back(Vehicle.Ft); return Vehicle.Ft; }}, - {"V", [&Values](TMoverParameters const &Vehicle) { Values.speed.push_back(Vehicle.V); return Vehicle.V; }}, - {"EngineVoltage", [&Values](TMoverParameters const &Vehicle) { Values.voltage.push_back(Vehicle.EngineVoltage); return Vehicle.EngineVoltage; }}, - {"Itot", [&Values](TMoverParameters const &Vehicle) { Values.current.push_back(Vehicle.Itot); return Vehicle.Itot; }}, - {"eimv_pr", [&Values](TMoverParameters const &Vehicle) { Values.demand.push_back(Vehicle.inductionMotor.forceShare); return Vehicle.inductionMotor.forceShare; }}, + {"Ft", [&Values](physics::Vehicle const &Vehicle) { Values.force.push_back(Vehicle.Ft); return Vehicle.Ft; }}, + {"V", [&Values](physics::Vehicle const &Vehicle) { Values.speed.push_back(Vehicle.V); return Vehicle.V; }}, + {"EngineVoltage", [&Values](physics::Vehicle const &Vehicle) { Values.voltage.push_back(Vehicle.EngineVoltage); return Vehicle.EngineVoltage; }}, + {"Itot", [&Values](physics::Vehicle const &Vehicle) { Values.current.push_back(Vehicle.Itot); return Vehicle.Itot; }}, + {"eimv_pr", [&Values](physics::Vehicle const &Vehicle) { Values.demand.push_back(Vehicle.inductionMotor.forceShare); return Vehicle.inductionMotor.forceShare; }}, }; }; auto const drive = [&record](definition const &Definition, values &Values) { @@ -377,7 +377,7 @@ TEST_CASE("genset: running from the catenary is the same with the keys") { TEST_CASE("genset: stopped, it opens the line breaker") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; REQUIRE(start_on_genset(dragon6)); REQUIRE(cab.Genset.revolutions == doctest::Approx(cab.Genset.revolutions_idle)); cab.GensetSwitch(false); @@ -404,7 +404,7 @@ TEST_CASE("genset: stopped, it opens the line breaker") { TEST_CASE("genset: automatic start follows the selector") { vehicle dragon6{dragon_genset().set("Cntrl", "GensetStart", "Automatic"), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; wake(cab); run(dragon6, 10.0); CHECK_FALSE(cab.Genset.is_cranking); @@ -425,7 +425,7 @@ TEST_CASE("genset: automatic start follows the selector") { TEST_CASE("genset: no battery, no start") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; cab.BatterySwitch(false); REQUIRE(cab.TractionModeSwitch(traction_mode::genset)); cab.GensetSwitch(true); @@ -443,7 +443,7 @@ TEST_CASE("genset: no battery, no start") { TEST_CASE("genset: the pantographs' pressure switch leaves the genset's line breaker alone") { SUBCASE("on the genset") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; REQUIRE(start_on_genset(dragon6)); cab.PantPressSwitchActive = true; cab.PantPress = 0.0; @@ -452,7 +452,7 @@ TEST_CASE("genset: the pantographs' pressure switch leaves the genset's line bre } SUBCASE("on the pantographs it opens the line breaker, the check the genset is spared") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; REQUIRE(test::start_up(test::driving(dragon6), wire)); REQUIRE(cab.Mains); // the pressure switch looks at the voltage through the couplers, not the pantographs' @@ -475,7 +475,7 @@ struct braking { // up to 60 km/h at full power, then braking with the train brake for 20 s, which the E6ACT blends with the // electrodynamic one braking brake_from_60(vehicle &Dragon, track const &Track) { - auto &cab{Dragon.mover()}; + auto &cab{Dragon.physics()}; notch_up(cab); for (auto step_count = 0L; step_count < 60000 && cab.Vel < 60.0; ++step_count) { step(Dragon, step_count, Track); @@ -513,7 +513,7 @@ TEST_CASE("genset: braking electrodynamically on the genset sends nothing back") SUBCASE("on the catenary the same braking feeds the line, the check the genset is spared") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; REQUIRE(test::start_up(test::driving(dragon6), wire)); - test::release_brakes(dragon6.mover()); + test::release_brakes(dragon6.physics()); run(dragon6, 5.0, wire); auto const braked{brake_from_60(dragon6, wire)}; REQUIRE(braked.electrodynamic); @@ -525,8 +525,8 @@ TEST_CASE("genset: braking electrodynamically on the genset sends nothing back") TEST_CASE("genset: one genset feeds the next car through the high voltage coupling") { // both able to join the control and the high voltage lines: 35 of the E6ACT, + control 4 + high voltage 8 consist train; - auto &first{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 1).mover()}; - auto &second{train.add(dragon().set("BuffCoupl", "AllowedFlag", 47)).mover()}; + auto &first{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 1).physics()}; + auto &second{train.add(dragon().set("BuffCoupl", "AllowedFlag", 47)).physics()}; REQUIRE(first.Couplers[VehicleEnd::rear].CouplingFlag.HasAny(Coupling::highVoltage)); wake(first); REQUIRE(first.TractionModeSwitch(traction_mode::genset)); @@ -555,8 +555,8 @@ TEST_CASE("genset: the selector command travels along the train") { // two locomotives in multiple: the control line, no permanent coupling auto const coupling{Coupling::coupler | Coupling::brakeHose | Coupling::mainHose | Coupling::control}; consist train; - auto &first{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 1).mover()}; - auto &second{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 0, coupling).mover()}; + auto &first{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 1).physics()}; + auto &second{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 0, coupling).physics()}; REQUIRE(first.Couplers[VehicleEnd::rear].CouplingFlag.HasAny(Coupling::control)); wake(first); train.run(1.0, no_wire); @@ -577,8 +577,8 @@ TEST_CASE("genset: the selector command travels along the train") { TEST_CASE("genset: a selector command refused with the line breaker closed isn't passed on") { auto const coupling{Coupling::coupler | Coupling::brakeHose | Coupling::mainHose | Coupling::control}; consist train; - auto &first{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 1).mover()}; - auto &second{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 0, coupling).mover()}; + auto &first{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 1).physics()}; + auto &second{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 0, coupling).physics()}; REQUIRE(test::start_up(test::driving(train), wire)); REQUIRE(first.Mains); // the second one's line breaker opened by itself, the lead's is closed @@ -597,8 +597,8 @@ TEST_CASE("genset: a selector command refused with the line breaker closed isn't TEST_CASE("genset: a lead which starts its genset on its own passes the start switch on") { auto const coupling{Coupling::coupler | Coupling::brakeHose | Coupling::mainHose | Coupling::control}; consist train; - auto &first{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47).set("Cntrl", "GensetStart", "Automatic"), 1).mover()}; - auto &second{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 0, coupling).mover()}; + auto &first{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47).set("Cntrl", "GensetStart", "Automatic"), 1).physics()}; + auto &second{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 0, coupling).physics()}; wake(first); train.run(1.0, no_wire); // ignored by the lead, so its cab switch doesn't move, but the car behind starts on it @@ -612,7 +612,7 @@ TEST_CASE("genset: a lead which starts its genset on its own passes the start sw TEST_CASE("genset: on the genset the pantographs carry no traction current") { SUBCASE("on the genset") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; REQUIRE(start_on_genset(dragon6)); notch_up(cab); run(dragon6, 10.0); @@ -627,7 +627,7 @@ TEST_CASE("genset: on the genset the pantographs carry no traction current") { } SUBCASE("on the catenary the traction current goes through them, the check the genset is spared") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; REQUIRE(test::start_up(test::driving(dragon6), wire)); test::release_brakes(cab); run(dragon6, 5.0, wire); @@ -644,7 +644,7 @@ TEST_CASE("genset: on the genset the pantographs carry no traction current") { TEST_CASE("genset: a scenery command reaches the selector") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; - auto &cab{dragon6.mover()}; + auto &cab{dragon6.physics()}; wake(cab); // as a scenery's PutValues event gives it, one at a time cab.PutCommand("TractionMode", 1, 0, cab.Loc); diff --git a/tests/unit/test_handover.cpp b/tests/unit/test_handover.cpp index 3cecb9b51..263054cf6 100644 --- a/tests/unit/test_handover.cpp +++ b/tests/unit/test_handover.cpp @@ -30,7 +30,7 @@ TEST_CASE("handover: the horn the AI was sounding goes quiet (eu07/maszyna#511)" SUBCASE("both tones") { cab->WarningSignal = 1 | 2; } REQUIRE(cab->WarningSignal != 0); - handover::release_ai_controls(cab.mover(), cab.mover()); + handover::release_ai_controls(cab.physics(), cab.physics()); CHECK(cab->WarningSignal == 0); } @@ -40,7 +40,7 @@ TEST_CASE("handover: sanding the AI started stops") { cab->Sandbox(true); // the way the AI sands, bypassing the sanding button REQUIRE(cab->SandDose); - handover::release_ai_controls(cab.mover(), cab.mover()); + handover::release_ai_controls(cab.physics(), cab.physics()); CHECK_FALSE(cab->SandDose); } @@ -54,7 +54,7 @@ TEST_CASE("handover: sanding the player or the automatic system asked for goes o } REQUIRE(cab->SandDose); - handover::release_ai_controls(cab.mover(), cab.mover()); + handover::release_ai_controls(cab.physics(), cab.physics()); CHECK(cab->SandDose); } @@ -64,7 +64,7 @@ TEST_CASE("handover: the departure signal the AI was giving stops") { cab->signal_departure(true); REQUIRE(cab->DepartureSignal); - handover::release_ai_controls(cab.mover(), cab.mover()); + handover::release_ai_controls(cab.physics(), cab.physics()); CHECK_FALSE(cab->DepartureSignal); } @@ -74,7 +74,7 @@ TEST_CASE("handover: the brake releaser the AI was holding lets go") { cab->BrakeReleaser(1); REQUIRE(cab->Hamulec->Releaser()); - handover::release_ai_controls(cab.mover(), cab.mover()); + handover::release_ai_controls(cab.physics(), cab.physics()); CHECK_FALSE(cab->Hamulec->Releaser()); } @@ -82,7 +82,7 @@ TEST_CASE("handover: the brake releaser the AI was holding lets go") { TEST_CASE("handover: nothing the AI didn't latch changes") { auto cab{cab_vehicle()}; - handover::release_ai_controls(cab.mover(), cab.mover()); + handover::release_ai_controls(cab.physics(), cab.physics()); CHECK(cab->WarningSignal == 0); CHECK_FALSE(cab->SandDose); @@ -95,17 +95,17 @@ TEST_CASE("handover: the light selector moves to the position giving the head li REQUIRE(cab->LightsPos == 1); // untouched selector: lights off SUBCASE("Pc1") { - CHECK(handover::light_selector_position(cab.mover(), NumberOf(VehicleEnd::front), pc1, allheadlights) == 2); + CHECK(handover::light_selector_position(cab.physics(), NumberOf(VehicleEnd::front), pc1, allheadlights) == 2); } SUBCASE("lights off") { - CHECK(handover::light_selector_position(cab.mover(), NumberOf(VehicleEnd::front), 0, allheadlights) == 1); + CHECK(handover::light_selector_position(cab.physics(), NumberOf(VehicleEnd::front), 0, allheadlights) == 1); } SUBCASE("vehicle without the upper headlight, which the AI's Pc1 can't light") { auto const inventory{allheadlights & ~light::headlight_upper}; - CHECK(handover::light_selector_position(cab.mover(), NumberOf(VehicleEnd::front), pc1 & inventory, inventory) == 2); + CHECK(handover::light_selector_position(cab.physics(), NumberOf(VehicleEnd::front), pc1 & inventory, inventory) == 2); } SUBCASE("no position matches: the selector stays") { - CHECK(handover::light_selector_position(cab.mover(), NumberOf(VehicleEnd::front), light::headlight_left, allheadlights) == 1); + CHECK(handover::light_selector_position(cab.physics(), NumberOf(VehicleEnd::front), light::headlight_left, allheadlights) == 1); } } @@ -118,12 +118,12 @@ TEST_CASE("handover: the light selector stays within its table") { std::fill(std::begin(table) + cab->LightsPosNo, std::end(table), 0); } cab->LightsPosNo = 100; - CHECK(handover::light_selector_position(cab.mover(), NumberOf(VehicleEnd::front), pc1, allheadlights) == 2); - CHECK(handover::light_selector_position(cab.mover(), NumberOf(VehicleEnd::front), light::headlight_left, allheadlights) == 1); + CHECK(handover::light_selector_position(cab.physics(), NumberOf(VehicleEnd::front), pc1, allheadlights) == 2); + CHECK(handover::light_selector_position(cab.physics(), NumberOf(VehicleEnd::front), light::headlight_left, allheadlights) == 1); } SUBCASE("table other than the front or rear one: the selector stays") { - CHECK(handover::light_selector_position(cab.mover(), -1, pc1, allheadlights) == 1); - CHECK(handover::light_selector_position(cab.mover(), 2, pc1, allheadlights) == 1); + CHECK(handover::light_selector_position(cab.physics(), -1, pc1, allheadlights) == 1); + CHECK(handover::light_selector_position(cab.physics(), 2, pc1, allheadlights) == 1); } } @@ -131,7 +131,7 @@ TEST_CASE("handover: the light selector already matching the lights stays") { auto cab{cab_vehicle()}; cab->LightsPos = 2; // Pc1 - CHECK(handover::light_selector_position(cab.mover(), NumberOf(VehicleEnd::front), pc1, allheadlights) == 2); + CHECK(handover::light_selector_position(cab.physics(), NumberOf(VehicleEnd::front), pc1, allheadlights) == 2); } TEST_CASE("handover: the headlight dimmer leaves the off position when the head lights are lit") { @@ -141,14 +141,14 @@ TEST_CASE("handover: the headlight dimmer leaves the off position when the head cab->modernDimmerPosition = 2; // off, left there by the player before the AI took over SUBCASE("to the default position") { - CHECK(handover::dimmer_position(cab.mover(), true) == 3); + CHECK(handover::dimmer_position(cab.physics(), true) == 3); } SUBCASE("to the first regular position, when the default one is off as well") { cab->modernDimmerDefaultPosition = 2; - CHECK(handover::dimmer_position(cab.mover(), true) == 3); + CHECK(handover::dimmer_position(cab.physics(), true) == 3); } SUBCASE("unless the head lights are off anyway") { - CHECK(handover::dimmer_position(cab.mover(), false) == 2); + CHECK(handover::dimmer_position(cab.physics(), false) == 2); } } @@ -157,7 +157,7 @@ TEST_CASE("handover: the headlight dimmer in any other position stays") { for (auto const position : {0, 1, 3, 4}) { CAPTURE(position); cab->modernDimmerPosition = position; - CHECK(handover::dimmer_position(cab.mover(), true) == position); + CHECK(handover::dimmer_position(cab.physics(), true) == position); } } @@ -165,5 +165,5 @@ TEST_CASE("handover: a vehicle without the modern dimmer keeps its dimmer state" vehicle wagon{definition::load("wagon")}; REQUIRE_FALSE(wagon->enableModernDimmer); - CHECK(handover::dimmer_position(wagon.mover(), true) == wagon->modernDimmerPosition); + CHECK(handover::dimmer_position(wagon.physics(), true) == wagon->modernDimmerPosition); } diff --git a/tests/unit/test_horn.cpp b/tests/unit/test_horn.cpp index 18e5c5322..7245d4267 100644 --- a/tests/unit/test_horn.cpp +++ b/tests/unit/test_horn.cpp @@ -108,9 +108,9 @@ TEST_CASE("horn: a vehicle without any air, a road vehicle say, sounds its pneum TEST_CASE("horn: a pneumatic horn sounds from the threshold pressure up") { auto vehicle{horn_vehicle(test::definition::load("wagon"))}; - vehicle->Compressor = TMoverParameters::HornMinPressure; + vehicle->Compressor = physics::Vehicle::HornMinPressure; CHECK(vehicle->SoundingHorns(horn::low) == horn::low); - vehicle->Compressor = TMoverParameters::HornMinPressure - 0.01; + vehicle->Compressor = physics::Vehicle::HornMinPressure - 0.01; CHECK(vehicle->SoundingHorns(horn::low) == 0); } diff --git a/tests/unit/test_invariants.cpp b/tests/unit/test_invariants.cpp index 36c511863..3abad65f6 100644 --- a/tests/unit/test_invariants.cpp +++ b/tests/unit/test_invariants.cpp @@ -12,13 +12,13 @@ using test::vehicle; TEST_CASE("invariants: a vehicle in an impossible state, reported once with its time and the last event") { vehicle eu07{definition::fiz("4e_v1/4e")}; test::trace trace{"invariants/self test", test::channels::brakes()}; - trace.sample(0.0, eu07.mover()); + trace.sample(0.0, eu07.physics()); CHECK(trace.violations().empty()); trace.mark("overfilled"); eu07->BrakePress = 50.0; - trace.sample(0.01, eu07.mover()); - trace.sample(0.02, eu07.mover()); + trace.sample(0.01, eu07.physics()); + trace.sample(0.02, eu07.physics()); REQUIRE(trace.violations().size() == 1); auto const &violation{trace.violations().front()}; CHECK(violation.find("brake cylinders") != std::string::npos); @@ -28,7 +28,7 @@ TEST_CASE("invariants: a vehicle in an impossible state, reported once with its eu07->BrakePress = 0.0; eu07->V = std::nan(""); - trace.sample(0.03, eu07.mover()); + trace.sample(0.03, eu07.physics()); CHECK(trace.violations().size() > 1); CHECK(trace.violations()[1].find("every value a number") != std::string::npos); } diff --git a/tests/unit/test_lights_preset_cablight.cpp b/tests/unit/test_lights_preset_cablight.cpp index fe079bfd4..e1dfcc827 100644 --- a/tests/unit/test_lights_preset_cablight.cpp +++ b/tests/unit/test_lights_preset_cablight.cpp @@ -87,7 +87,7 @@ TEST_CASE("lights preset cab light: a stray note after the two columns is not re auto const rowend{text.find('\n', row)}; REQUIRE(rowend != std::string::npos); text.insert(rowend, " / A"); - TMoverParameters wagon(0.0, "wagon", "test", 0); + physics::Vehicle wagon(0.0, "wagon", "test", 0); REQUIRE(wagon.LoadFIZ_Text(text)); REQUIRE(wagon.LightsPosNo == 2); CHECK(wagon.Lights[VehicleEnd::front][1] == 38); diff --git a/tests/unit/test_line_contactors_interlock.cpp b/tests/unit/test_line_contactors_interlock.cpp index 91274ad35..d8c484349 100644 --- a/tests/unit/test_line_contactors_interlock.cpp +++ b/tests/unit/test_line_contactors_interlock.cpp @@ -117,8 +117,8 @@ TEST_CASE("line contactors interlock: a blower starting with the speed needs to namespace { -bool blowers_run(TMoverParameters const &Mover) { - return Mover.MotorBlowers[VehicleEnd::front].is_active && Mover.MotorBlowers[VehicleEnd::rear].is_active; +bool blowers_run(physics::Vehicle const &Physics) { + return Physics.MotorBlowers[VehicleEnd::front].is_active && Physics.MotorBlowers[VehicleEnd::rear].is_active; } // the driver's first power position, held until the line contactors close (their delay, the pressure switch) @@ -153,34 +153,34 @@ TEST_CASE("line contactors interlock: with blowers starting with the speed the v .set("Engine", "MotorBlowersStartVelocity", 5.0) .set("Engine", "MotorBlowersSustainTime", 10.0), 0.0, "test", 1}; - auto &mover{eu07.mover()}; - REQUIRE(mover.LineContactorsInterlock == line_contactors_interlock::motor_blowers); - REQUIRE(mover.MotorBlowers[VehicleEnd::front].min_start_velocity == doctest::Approx(5.0)); - REQUIRE(mover.MotorBlowers[VehicleEnd::rear].sustain_time == doctest::Approx(10.0)); + auto &physics{eu07.physics()}; + REQUIRE(physics.LineContactorsInterlock == line_contactors_interlock::motor_blowers); + REQUIRE(physics.MotorBlowers[VehicleEnd::front].min_start_velocity == doctest::Approx(5.0)); + REQUIRE(physics.MotorBlowers[VehicleEnd::rear].sustain_time == doctest::Approx(10.0)); auto driven{test::driving(eu07)}; REQUIRE(test::start_up(driven, line)); release(driven); // standing, the blowers don't run; the line contactors close all the same and the motors take current REQUIRE(std::abs(eu07.speed()) < 0.1); - REQUIRE_FALSE(blowers_run(mover)); + REQUIRE_FALSE(blowers_run(physics)); CHECK(close_line_contactors(driven)); - CHECK(std::abs(mover.Im) > 0.5); + CHECK(std::abs(physics.Im) > 0.5); // the blowers come on once the vehicle moves for (int i = 0; i < 6; ++i) { - mover.IncMainCtrl(1); + physics.IncMainCtrl(1); test::drive(driven, line, 2.0); } for (int i = 0; i < 60 && eu07.speed() < 10.0; ++i) { test::drive(driven, line, 1.0); } REQUIRE(eu07.speed() >= 10.0); - CHECK(blowers_run(mover)); - CHECK(mover.StLinFlag); + CHECK(blowers_run(physics)); + CHECK(physics.StLinFlag); // a stop longer than the blowers keep running for - while (mover.DecMainCtrl(1)) { + while (physics.DecMainCtrl(1)) { // down to zero } driven.cab.BrakeLevelSet(driven.cab.Handle->GetPos(bh_FB)); @@ -189,22 +189,22 @@ TEST_CASE("line contactors interlock: with blowers starting with the speed the v } REQUIRE(std::abs(eu07.speed()) <= 0.1); test::drive(driven, line, 15.0); - REQUIRE_FALSE(blowers_run(mover)); - REQUIRE_FALSE(mover.StLinFlag); + REQUIRE_FALSE(blowers_run(physics)); + REQUIRE_FALSE(physics.StLinFlag); // and the vehicle starts again release(driven); CHECK(close_line_contactors(driven)); - CHECK(std::abs(mover.Im) > 0.5); + CHECK(std::abs(physics.Im) > 0.5); for (int i = 0; i < 6; ++i) { - mover.IncMainCtrl(1); + physics.IncMainCtrl(1); test::drive(driven, line, 2.0); } for (int i = 0; i < 60 && eu07.speed() < 10.0; ++i) { test::drive(driven, line, 1.0); } CHECK(eu07.speed() >= 10.0); - CHECK(blowers_run(mover)); + CHECK(blowers_run(physics)); } TEST_CASE("line contactors interlock: a blower starting with the speed, switched off on the way, opens the contactors") { @@ -214,31 +214,31 @@ TEST_CASE("line contactors interlock: a blower starting with the speed, switched .set("Engine", "MotorBlowersStartVelocity", 5.0) .set("Engine", "MotorBlowersSustainTime", 10.0), 0.0, "test", 1}; - auto &mover{eu07.mover()}; + auto &physics{eu07.physics()}; auto driven{test::driving(eu07)}; REQUIRE(test::start_up(driven, line)); release(driven); REQUIRE(close_line_contactors(driven)); // the switch of the rear blower: off, the contactors open and stay open, standing as well as later - REQUIRE(mover.MotorBlowersSwitchOff(true, VehicleEnd::rear)); + REQUIRE(physics.MotorBlowersSwitchOff(true, VehicleEnd::rear)); test::drive(driven, line, 2.0); - CHECK_FALSE(mover.StLinFlag); - CHECK(std::abs(mover.Im) < 0.5); - while (mover.DecMainCtrl(1)) { + CHECK_FALSE(physics.StLinFlag); + CHECK(std::abs(physics.Im) < 0.5); + while (physics.DecMainCtrl(1)) { // down to zero } test::drive(driven, line, 2.0); CHECK_FALSE(close_line_contactors(driven)); // back on, the vehicle starts - REQUIRE(mover.MotorBlowersSwitchOff(false, VehicleEnd::rear)); - while (mover.DecMainCtrl(1)) { + REQUIRE(physics.MotorBlowersSwitchOff(false, VehicleEnd::rear)); + while (physics.DecMainCtrl(1)) { // down to zero } test::drive(driven, line, 2.0); CHECK(close_line_contactors(driven)); - CHECK(std::abs(mover.Im) > 0.5); + CHECK(std::abs(physics.Im) > 0.5); } TEST_CASE("line contactors interlock: held by the local converter switch only where they wait for that converter") { @@ -262,8 +262,8 @@ TEST_CASE("line contactors interlock: the ET42 section with its fans switched of et42.add(definition::fiz("et42_v2/112e-b").set("Cntrl", "LineContactorsInterlock", "Converter")); auto driven{test::driving(et42)}; REQUIRE(test::start_up(driven, line)); - auto &front{et42[0].mover()}; - auto &rear{et42[1].mover()}; + auto &front{et42[0].physics()}; + auto &rear{et42[1].physics()}; REQUIRE(front.ConverterFlag); REQUIRE(rear.ConverterFlag); diff --git a/tests/unit/test_linebreaker.cpp b/tests/unit/test_linebreaker.cpp index 9b36b817f..6b132e08e 100644 --- a/tests/unit/test_linebreaker.cpp +++ b/tests/unit/test_linebreaker.cpp @@ -16,7 +16,7 @@ namespace { // the line breaker lever of the EP05 (main_sw), a single two-state lever, the way TTrain works it: the state // the cab keeps of the line breaker follows the vehicle, the breaker closes while the lever is on and can close struct lever { - TMoverParameters &mover; + physics::Vehicle &physics; state breaker{state::open}; // as TTrain::m_linebreakerstate bool on{false}; @@ -27,7 +27,7 @@ struct lever { break; case linebreaker::toggle::open: on = false; - if (breaker == state::closed && mover.MainSwitch(false)) { + if (breaker == state::closed && physics.MainSwitch(false)) { breaker = state::open; } break; @@ -37,14 +37,14 @@ struct lever { } // TTrain::Update() void update() { - if (breaker == state::open && mover.Mains) { + if (breaker == state::open && physics.Mains) { breaker = state::closed; } - if (breaker == state::closed && false == mover.Mains) { + if (breaker == state::closed && false == physics.Mains) { breaker = state::open; } - if (on && breaker == state::open && mover.MainSwitchCheck()) { - breaker = mover.MainSwitch(true) ? state::closed : state::open; + if (on && breaker == state::open && physics.MainSwitchCheck()) { + breaker = physics.MainSwitch(true) ? state::closed : state::open; } } }; @@ -67,7 +67,7 @@ TEST_CASE("line breaker: a press of the toggle closes an open breaker and opens TEST_CASE("line breaker: the EP05's lever goes off with the converter overload relay tripped (eu07/maszyna#394)") { consist train; - auto &ep05{train.add(definition::fiz("ep05_v2/ep05"), 1).mover()}; + auto &ep05{train.add(definition::fiz("ep05_v2/ep05"), 1).physics()}; test::track const line{0.15, 0.0, test::catenary_3kv}; auto const driver{test::driving(train)}; REQUIRE(test::start_up(driver, line)); diff --git a/tests/unit/test_motor_param_bounds.cpp b/tests/unit/test_motor_param_bounds.cpp index 5d44c7331..8226fad46 100644 --- a/tests/unit/test_motor_param_bounds.cpp +++ b/tests/unit/test_motor_param_bounds.cpp @@ -11,7 +11,7 @@ using test::vehicle; // the field shunting step a position of the master controller selects (RList, its sixth column ScndAct) indexes the // motor parameter table, MotorParam, which has MotorParametersArraySize + 1 entries. The loader takes ScndAct from the -// .fiz as it is, so the readers of the table (TMoverParameters::Momentum(), MomentumF(), TController::ESMVelocity()) +// .fiz as it is, so the readers of the table (physics::Vehicle::Momentum(), MomentumF(), TController::ESMVelocity()) // go through motor_param(), which keeps the index inside the table namespace { diff --git a/tests/unit/test_parser.cpp b/tests/unit/test_parser.cpp index ee82aca9a..58f3bb980 100644 --- a/tests/unit/test_parser.cpp +++ b/tests/unit/test_parser.cpp @@ -698,7 +698,7 @@ TEST_CASE("parser: read line by line, a line starting with include is the direct namespace { -// the lines of a file, read the way the vehicle's .fiz is (TMoverParameters::LoadFIZ_Parse): line by line while the +// the lines of a file, read the way the vehicle's .fiz is (physics::Vehicle::LoadFIZ_Parse): line by line while the // parser is ok std::string fiz_lines(cParser &Parser) { std::string joined; diff --git a/tests/unit/test_pullee.cpp b/tests/unit/test_pullee.cpp index dc5235c08..fb276eb97 100644 --- a/tests/unit/test_pullee.cpp +++ b/tests/unit/test_pullee.cpp @@ -11,7 +11,7 @@ using test::definition; using test::vehicle; // the pullee mode ("jazda ciągniona", MaSzyna-EU07/maszyna#64): a vehicle prepared for being hauled dead in a -// train, TMoverParameters::PulleeModeSwitch(). the trains here are an EU07 and the vehicle behind it, coupled with +// train, physics::Vehicle::PulleeModeSwitch(). the trains here are an EU07 and the vehicle behind it, coupled with // the hook and the brake hose alone, as with coupling 3 of a scenery. every test has both sides: what the vehicle // does as it is (unchanged by the mode being there), and what it does prepared for hauling. // pressures in bar, the brake pipe runs at 5.0 @@ -40,7 +40,7 @@ struct hauled_train { }; // no air in the main reservoir and the feed pipe, as after standing dead for some hours -void drain_feed_air(TMoverParameters &Vehicle) { +void drain_feed_air(physics::Vehicle &Vehicle) { Vehicle.Pipe2->CreatePress(0.0); Vehicle.Pipe2->Act(); Vehicle.CompressedVolume = 0.0; @@ -147,9 +147,9 @@ TEST_CASE("pullee: the spring brake of a dead locomotive without air stops the t CAPTURE(pullee); test::reseed_random(); hauled_train train{definition::fiz(path), 60.0, pullee}; - auto const &hauled{train.hauled.mover()}; + auto const &hauled{train.hauled.physics()}; REQUIRE(hauled.SpringBrake.MaxBrakeForce > 0.0); - drain_feed_air(train.hauled.mover()); + drain_feed_air(train.hauled.physics()); train.run(60.0); // no air came from anywhere: the cylinder of the spring brake is empty either way REQUIRE(hauled.SpringBrake.SBP < 0.1); @@ -171,7 +171,7 @@ TEST_CASE("pullee: a dead EU47 starts to drag once its main reservoir has leaked CAPTURE(pullee); test::reseed_random(); hauled_train train{definition::fiz("e186_v2/eu47"), 0.0, pullee}; - auto &hauled{train.hauled.mover()}; + auto &hauled{train.hauled.physics()}; // what the driver of the train does on its inspection, TController::AutoRewident() hauled.DecManualBrakeLevel(ManualBrakePosNo); hauled.SpringBrake.Activate = false; @@ -199,9 +199,9 @@ TEST_CASE("pullee: a vehicle prepared for hauling brakes and releases with the t CAPTURE(feedair); test::reseed_random(); hauled_train train{definition::fiz(path), 60.0, true}; - auto const &hauled{train.hauled.mover()}; + auto const &hauled{train.hauled.physics()}; if (false == feedair) { - drain_feed_air(train.hauled.mover()); + drain_feed_air(train.hauled.physics()); } train.run(30.0); CHECK(hauled.BrakePress < 0.1); @@ -227,10 +227,10 @@ TEST_CASE("pullee: the spring brake of an Impuls prepared for hauling doesn't ca CAPTURE(pullee); test::reseed_random(); hauled_train train{impuls, 60.0, pullee}; - auto const &hauled{train.hauled.mover()}; + auto const &hauled{train.hauled.physics()}; REQUIRE(hauled.InactiveCabFlag == 0); REQUIRE(hauled.SpringBrakeDriveEmergencyVel == doctest::Approx(2.0)); - drain_feed_air(train.hauled.mover()); + drain_feed_air(train.hauled.physics()); train.run(10.0); REQUIRE(hauled.Vel > 2.0); REQUIRE(hauled.SpringBrake.IsActive); @@ -415,8 +415,8 @@ TEST_CASE("pullee: every real vehicle prepared for hauling runs free behind a lo } test::reseed_random(); hauled_train train{definition::fiz(path), 60.0, true}; - auto const &hauled{train.hauled.mover()}; - drain_feed_air(train.hauled.mover()); + auto const &hauled{train.hauled.physics()}; + drain_feed_air(train.hauled.physics()); train.run(60.0); CHECK(hauled.EmergencyValveFlow == 0.0); CHECK(hauled.BrakePress < 0.1); @@ -436,7 +436,7 @@ TEST_CASE("pullee: every real vehicle standing braked releases once prepared for test::reseed_random(); // hand brakes on, spring brakes switched on, cylinders half full, the pipe at 3.5 hauled_train train{definition::fiz(path), 0.0, true}; - auto const &hauled{train.hauled.mover()}; + auto const &hauled{train.hauled.physics()}; CHECK(hauled.ManualBrakePos == 0); CHECK_FALSE(hauled.SpringBrake.Activate); CHECK_FALSE(hauled.Battery); diff --git a/tests/unit/test_queries.cpp b/tests/unit/test_queries.cpp index 490c57be4..871549e9b 100644 --- a/tests/unit/test_queries.cpp +++ b/tests/unit/test_queries.cpp @@ -51,7 +51,7 @@ TEST_CASE("queries: the damage of a vehicle as the driver's panel describes it") TEST_CASE("queries: the ammeters of a vehicle without power show the current of the ones it controls") { vehicle unpowered{definition::fiz("en57_v1/6ba_840")}; vehicle powered{definition::fiz("en57_v1/5bgb")}; - unpowered->Attach(VehicleEnd::rear, VehicleEnd::front, &powered.mover(), Coupling::control, true, false); + unpowered->Attach(VehicleEnd::rear, VehicleEnd::front, &powered.physics(), Coupling::control, true, false); powered->Power = 600.0; powered->Itot = 321.7; unpowered->Power = 0.0; diff --git a/tests/unit/test_smoke.cpp b/tests/unit/test_smoke.cpp index e8c31d87b..7f204927c 100644 --- a/tests/unit/test_smoke.cpp +++ b/tests/unit/test_smoke.cpp @@ -35,12 +35,12 @@ TEST_CASE("smoke: a vehicle taken off the tracks puffs no more (#90)") { vehicle->Im = 400.0; } // on the tracks the engine puffs - REQUIRE(smoke::vehicle_spawn_count(vehicle.mover(), true, source, update) >= 1.f); + REQUIRE(smoke::vehicle_spawn_count(vehicle.physics(), true, source, update) >= 1.f); // gone through a portal, the pending particles are dropped too auto pending{source}; pending.pending = 5.f; - CHECK(smoke::vehicle_spawn_count(vehicle.mover(), false, pending, update) == 0.f); + CHECK(smoke::vehicle_spawn_count(vehicle.physics(), false, pending, update) == 0.f); } TEST_CASE("smoke: a road vehicle back on the road from the pool puffs again") { @@ -48,11 +48,11 @@ TEST_CASE("smoke: a road vehicle back on the road from the pool puffs again") { // waiting in the pool, the count stays at zero update after update auto rate{source}; for (auto i{0}; i < 10; ++i) { - rate.pending = smoke::vehicle_spawn_count(vehicle.mover(), false, rate, update); + rate.pending = smoke::vehicle_spawn_count(vehicle.physics(), false, rate, update); } REQUIRE(rate.pending == 0.f); - CHECK(smoke::vehicle_spawn_count(vehicle.mover(), true, rate, update) >= 1.f); + CHECK(smoke::vehicle_spawn_count(vehicle.physics(), true, rate, update) >= 1.f); } TEST_CASE("smoke: the engine adds to the steady rate of the source") { @@ -61,18 +61,18 @@ TEST_CASE("smoke: the engine adds to the steady rate of the source") { auto const steady{source.rate * update}; // the rate of a source of the scenery vehicle->EnginePower = 0.0; - CHECK(smoke::vehicle_spawn_count(vehicle.mover(), true, source, update) == doctest::Approx(steady)); + CHECK(smoke::vehicle_spawn_count(vehicle.physics(), true, source, update) == doctest::Approx(steady)); vehicle->EnginePower = 400.0; - auto const working{smoke::vehicle_spawn_count(vehicle.mover(), true, source, update)}; + auto const working{smoke::vehicle_spawn_count(vehicle.physics(), true, source, update)}; CHECK(working > steady); // the faster the starting engine turns, the more it puffs vehicle->diesel.spinningUp = true; vehicle->enrot = 100.0; - auto const slow{smoke::vehicle_spawn_count(vehicle.mover(), true, source, update)}; + auto const slow{smoke::vehicle_spawn_count(vehicle.physics(), true, source, update)}; vehicle->enrot = 400.0; - CHECK(smoke::vehicle_spawn_count(vehicle.mover(), true, source, update) > slow); + CHECK(smoke::vehicle_spawn_count(vehicle.physics(), true, source, update) > slow); } TEST_CASE("smoke: the pending particles never outgrow the room of the source") { @@ -82,7 +82,7 @@ TEST_CASE("smoke: the pending particles never outgrow the room of the source") { auto rate{source}; rate.pending = 99.f; - CHECK(smoke::vehicle_spawn_count(vehicle.mover(), true, rate, 10.0) == rate.limit); + CHECK(smoke::vehicle_spawn_count(vehicle.physics(), true, rate, 10.0) == rate.limit); } TEST_CASE("smoke: an engine the starter turns lets out no smoke until it fires (#523)") { @@ -92,10 +92,10 @@ TEST_CASE("smoke: an engine the starter turns lets out no smoke until it fires ( pending.pending = 5.f; vehicle->diesel.firingCountdown = 0.5; - CHECK(smoke::vehicle_spawn_count(vehicle.mover(), true, pending, update) == 0.f); + CHECK(smoke::vehicle_spawn_count(vehicle.physics(), true, pending, update) == 0.f); vehicle->diesel.firingCountdown = 0.0; - CHECK(smoke::vehicle_spawn_count(vehicle.mover(), true, pending, update) >= 1.f); + CHECK(smoke::vehicle_spawn_count(vehicle.physics(), true, pending, update) >= 1.f); } namespace { @@ -123,12 +123,12 @@ TEST_CASE("smoke: a real diesel smokes only once its engine has fired, SmokeDela REQUIRE(start_engine(driven, track)); // the engine started less than a second ago: the starter still turns it CHECK(locomotive->diesel.firingCountdown > 0.5); - CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) == 0.f); + CHECK(smoke::vehicle_spawn_count(locomotive.physics(), true, source, update) == 0.f); // it has fired since test::drive(driven, track, 3.0); CHECK(locomotive->Mains); CHECK(locomotive->diesel.firingCountdown == 0.0); - CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) >= 1.f); + CHECK(smoke::vehicle_spawn_count(locomotive.physics(), true, source, update) >= 1.f); } { // a longer delay from the .fiz @@ -136,9 +136,9 @@ TEST_CASE("smoke: a real diesel smokes only once its engine has fired, SmokeDela auto const driven{test::driving(locomotive)}; REQUIRE(start_engine(driven, track)); test::drive(driven, track, 3.0); - CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) == 0.f); + CHECK(smoke::vehicle_spawn_count(locomotive.physics(), true, source, update) == 0.f); test::drive(driven, track, 3.0); - CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) >= 1.f); + CHECK(smoke::vehicle_spawn_count(locomotive.physics(), true, source, update) >= 1.f); } } } @@ -156,6 +156,6 @@ TEST_CASE("smoke: without SmokeDelay in its .fiz a diesel smokes as soon as the auto const driven{test::driving(locomotive)}; REQUIRE(start_engine(driven, track)); CHECK(locomotive->diesel.firingCountdown == 0.0); - CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) >= 1.f); + CHECK(smoke::vehicle_spawn_count(locomotive.physics(), true, source, update) >= 1.f); } } diff --git a/tests/unit/test_speed_control.cpp b/tests/unit/test_speed_control.cpp index 3f8a9a9ec..b54a6aa9c 100644 --- a/tests/unit/test_speed_control.cpp +++ b/tests/unit/test_speed_control.cpp @@ -32,7 +32,7 @@ constexpr int dg_lower{4}; constexpr int dg_hold{5}; constexpr int dg_raise{6}; -void move_to(TMoverParameters &Vehicle, int const Position) { +void move_to(physics::Vehicle &Vehicle, int const Position) { while (Vehicle.MainCtrlPos < Position && Vehicle.IncMainCtrl(1)) { // all the work is done in the condition } @@ -260,7 +260,7 @@ TEST_CASE("speed control apart: which vehicles' cruise control has a switch of i namespace { // Seconds of the scenario going on, a second at a time, counting the seconds with the field shunted and not -void count_shunting(scenario &Scenario, TMoverParameters const &Vehicle, int const Seconds, int &Shunted, int &Unshunted) { +void count_shunting(scenario &Scenario, physics::Vehicle const &Vehicle, int const Seconds, int &Shunted, int &Unshunted) { for (int second = 0; second < Seconds; ++second) { Scenario.wait(1.0); ++(Vehicle.ScndCtrlPos > 0 ? Shunted : Unshunted); diff --git a/tests/unit/test_timetable.cpp b/tests/unit/test_timetable.cpp index 1066edd29..dff4ec6e4 100644 --- a/tests/unit/test_timetable.cpp +++ b/tests/unit/test_timetable.cpp @@ -2,7 +2,7 @@ #include "doctest.h" #include "vehicle.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/utilities.h" #include "vehicle/timetableservice.h" #include "world/timetablereader.h" @@ -269,20 +269,20 @@ TEST_CASE("timetable: the AI opens the doors from the cab as the vehicle and the auto const notcentral{flags(no, unset, unset, unset)}; unit->Doors.open_control = control_t::driver; - CHECK(timetable::opens_doors(unit.mover(), {})); - CHECK(timetable::opens_doors(unit.mover(), notcentral)); // the driver's doors open only from the cab + CHECK(timetable::opens_doors(unit.physics(), {})); + CHECK(timetable::opens_doors(unit.physics(), notcentral)); // the driver's doors open only from the cab unit->Doors.open_control = control_t::conductor; - CHECK(timetable::opens_doors(unit.mover(), {})); + CHECK(timetable::opens_doors(unit.physics(), {})); // doors of mixed control are left to the passengers, unless the timetable has the driver open them all unit->Doors.open_control = control_t::mixed; - CHECK_FALSE(timetable::opens_doors(unit.mover(), {})); - CHECK_FALSE(timetable::opens_doors(unit.mover(), notcentral)); - CHECK(timetable::opens_doors(unit.mover(), central)); + CHECK_FALSE(timetable::opens_doors(unit.physics(), {})); + CHECK_FALSE(timetable::opens_doors(unit.physics(), notcentral)); + CHECK(timetable::opens_doors(unit.physics(), central)); // the passengers' own doors and the automatic ones can't be opened from the cab unit->Doors.open_control = control_t::passenger; - CHECK_FALSE(timetable::opens_doors(unit.mover(), central)); + CHECK_FALSE(timetable::opens_doors(unit.physics(), central)); unit->Doors.open_control = control_t::autonomous; - CHECK_FALSE(timetable::opens_doors(unit.mover(), central)); + CHECK_FALSE(timetable::opens_doors(unit.physics(), central)); } TEST_CASE("timetable: the doorsteps, the conductor and the brake test as the timetable says") { diff --git a/tests/unit/test_traction.cpp b/tests/unit/test_traction.cpp index 6a9bb544c..f3f2acefa 100644 --- a/tests/unit/test_traction.cpp +++ b/tests/unit/test_traction.cpp @@ -24,7 +24,7 @@ TEST_CASE("traction: every real powered vehicle started up, driven to full power CAPTURE(path); test::reseed_random(); vehicle real{definition::fiz(path), 0.0, "test", 1}; - if (false == test::is_powered(real.mover())) { + if (false == test::is_powered(real.physics())) { continue; } using namespace test::channels; diff --git a/tests/unit/test_wheelslip.cpp b/tests/unit/test_wheelslip.cpp index 9b39e82c6..842eb31e2 100644 --- a/tests/unit/test_wheelslip.cpp +++ b/tests/unit/test_wheelslip.cpp @@ -36,7 +36,7 @@ braking_result brake_to_stop_then_stand(vehicle &Coach, track const &Braking, tr } // namespace -// the engine doesn't let a stopped, braked vehicle slip (the Vel > 0.1 trap in TMoverParameters::ComputeTotalForce), +// the engine doesn't let a stopped, braked vehicle slip (the Vel > 0.1 trap in physics::Vehicle::ComputeTotalForce), // so a wagon which stopped in a skid should be no different from one which stopped without it. it used to stay // skidding instead, with its brakes capped by the sliding adhesion, and slid or crept away (eu07/maszyna#479) TEST_CASE("wheelslip: a wagon which stopped in a skid holds like one which stopped without it") { diff --git a/tests/unit/vehicle.cpp b/tests/unit/vehicle.cpp index fa9c99746..37bb1aab8 100644 --- a/tests/unit/vehicle.cpp +++ b/tests/unit/vehicle.cpp @@ -125,32 +125,32 @@ std::string definition::text() const { vehicle::vehicle(definition const &Definition, double Velocity, std::string const &Name, int Cab) : m_cab(Cab) { // the same steps as TDynamicObject::Init(), for a vehicle set the usual way round (iDirection 1) auto const typename_{Definition.type_name().empty() ? Name : Definition.type_name()}; - m_mover = std::make_unique(Velocity, typename_, Name, Cab); - if (false == m_mover->LoadFIZ_Text(Definition.text())) { + m_physics = std::make_unique(Velocity, typename_, Name, Cab); + if (false == m_physics->LoadFIZ_Text(Definition.text())) { throw definition_error("the test vehicle definition didn't load"); } - m_mover->AssignLoad("", 0.f); - m_mover->ComputeMass(); + m_physics->AssignLoad("", 0.f); + m_physics->ComputeMass(); auto const driveractive{Velocity != 0.0}; - if (false == m_mover->CheckLocomotiveParameters(driveractive, (Velocity > 0 ? 1 : -1) * Cab)) { + if (false == m_physics->CheckLocomotiveParameters(driveractive, (Velocity > 0 ? 1 : -1) * Cab)) { throw definition_error("parameters mismatch in the test vehicle definition"); } - m_mover->MainCtrlPos = m_mover->MainCtrlNoPowerPos(); - m_mover->LocalBrakePosA = 0.0; + m_physics->MainCtrlPos = m_physics->MainCtrlNoPowerPos(); + m_physics->LocalBrakePosA = 0.0; if (driveractive) { - m_mover->BrakeCtrlPos = static_cast(std::floor(m_mover->Handle->GetPos(Cab == 0 ? bh_NP : bh_RP))); + m_physics->BrakeCtrlPos = static_cast(std::floor(m_physics->Handle->GetPos(Cab == 0 ? bh_NP : bh_RP))); // a driver keeps a vehicle on standby on its independent brake - if (Cab != 0 && m_mover->LocalBrake != TLocalBrake::ManualBrake && Velocity < 1.0) { - m_mover->IncLocalBrakeLevel(LocalBrakePosNo); - if (m_mover->EIMCtrlEmergency) { - m_mover->DecLocalBrakeLevel(1); + if (Cab != 0 && m_physics->LocalBrake != TLocalBrake::ManualBrake && Velocity < 1.0) { + m_physics->IncLocalBrakeLevel(LocalBrakePosNo); + if (m_physics->EIMCtrlEmergency) { + m_physics->DecLocalBrakeLevel(1); } } } else { - m_mover->BrakeCtrlPos = static_cast(std::floor(m_mover->Handle->GetPos(bh_NP))); + m_physics->BrakeCtrlPos = static_cast(std::floor(m_physics->Handle->GetPos(bh_NP))); } - m_mover->BrakeLevelSet(m_mover->BrakeCtrlPos); + m_physics->BrakeLevelSet(m_physics->BrakeCtrlPos); } void vehicle::step(track const &Track, double Dt) { @@ -161,7 +161,7 @@ void vehicle::step(track const &Track, double Dt) { fast_move(Track, Dt, location); } forces(Dt); - move(Track, Dt, location, m_mover->PipePress); + move(Track, Dt, location, m_physics->PipePress); } namespace { @@ -175,7 +175,7 @@ TTrackShape shape_of(track const &Track) { return shape; } -TTrackParam parameters_of(track const &Track, TMoverParameters const &Mover) { +TTrackParam parameters_of(track const &Track, physics::Vehicle const &Physics) { TTrackParam param; param.Width = Track.width; param.friction = Track.friction; @@ -185,7 +185,7 @@ TTrackParam parameters_of(track const &Track, TMoverParameters const &Mover) { param.CategoryFlag = Track.category; } else { - param.CategoryFlag = Mover.CategoryFlag != 0 ? Mover.CategoryFlag : 1; + param.CategoryFlag = Physics.CategoryFlag != 0 ? Physics.CategoryFlag : 1; } return param; } @@ -194,71 +194,71 @@ TTrackParam parameters_of(track const &Track, TMoverParameters const &Mover) { double vehicle::fast_move(track const &Track, double Dt, TLocation const &Location) { // TDynamicObject::FastUpdate(), the iterations of a frame before the last one - auto param{parameters_of(Track, *m_mover)}; + auto param{parameters_of(Track, *m_physics)}; param.DamageFlag = m_trackdamage; - return m_mover->FastComputeMovement(Dt, shape_of(Track), param, Location, TRotation{0.0, 0.0, 0.0}); + return m_physics->FastComputeMovement(Dt, shape_of(Track), param, Location, TRotation{0.0, 0.0, 0.0}); } void vehicle::begin_step() { // the conditions the test keeps if (m_pipepressure >= 0.0) { - m_mover->Pipe->CreatePress(m_pipepressure); + m_physics->Pipe->CreatePress(m_pipepressure); } - if (m_reservoirpressure >= 0.0 && m_mover->VeselVolume > 0.0) { - m_mover->CompressedVolume = m_reservoirpressure * m_mover->VeselVolume; + if (m_reservoirpressure >= 0.0 && m_physics->VeselVolume > 0.0) { + m_physics->CompressedVolume = m_reservoirpressure * m_physics->VeselVolume; } // vehicle_table::update(), before the forces - m_mover->ComputeConstans(); + m_physics->ComputeConstans(); } void vehicle::forces(double Dt) { // TDynamicObject::UpdateForce() - m_mover->ComputeTotalForce(Dt); + m_physics->ComputeTotalForce(Dt); } double vehicle::move(track const &Track, double Dt, TLocation const &Location, double Trainpipe) { auto const shape{shape_of(Track)}; - auto param{parameters_of(Track, *m_mover)}; + auto param{parameters_of(Track, *m_physics)}; param.DamageFlag = m_trackdamage; TRotation const rotation{0.0, 0.0, 0.0}; // what TDynamicObject::Update() does before the movement. a raised pantograph touches the wire at once, // the game animates its rise - auto &mover{*m_mover}; - mover.PantFrontVolt = mover.Pantographs[VehicleEnd::front].is_active ? Track.voltage : 0.0; - mover.PantRearVolt = mover.Pantographs[VehicleEnd::rear].is_active ? Track.voltage : 0.0; + auto &physics{*m_physics}; + physics.PantFrontVolt = physics.Pantographs[VehicleEnd::front].is_active ? Track.voltage : 0.0; + physics.PantRearVolt = physics.Pantographs[VehicleEnd::rear].is_active ? Track.voltage : 0.0; TTractionParam traction; traction.TractionVoltage = - mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? std::max(std::abs(mover.PantRearVolt), std::abs(mover.PantFrontVolt)) : 0.95 * mover.EnginePowerSource.MaxVoltage; + physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? std::max(std::abs(physics.PantRearVolt), std::abs(physics.PantFrontVolt)) : 0.95 * physics.EnginePowerSource.MaxVoltage; traction.TractionFreq = 0; traction.TractionMaxCurrent = 7500; traction.TractionResistivity = 0.3; - mover.PantographVoltage = traction.TractionVoltage; + physics.PantographVoltage = traction.TractionVoltage; if (m_cab != 0) { using enum TEngineType; // the driver's own vehicle, which gets the average pressure of the train's brake pipe - mover.EqvtPipePress = Trainpipe; - if (auto const diesel{mover.EngineType == DieselEngine || mover.EngineType == DieselElectric}; diesel && mover.EIMCtrlType > 0) { - mover.CheckEIMIC(Dt); - if (mover.SpeedCtrl) { - mover.CheckSpeedCtrl(Dt); + physics.EqvtPipePress = Trainpipe; + if (auto const diesel{physics.EngineType == DieselEngine || physics.EngineType == DieselElectric}; diesel && physics.EIMCtrlType > 0) { + physics.CheckEIMIC(Dt); + if (physics.SpeedCtrl) { + physics.CheckSpeedCtrl(Dt); } - mover.eimic_real = std::min(mover.eimic, mover.eimicSpeedCtrl); + physics.eimic_real = std::min(physics.eimic, physics.eimicSpeedCtrl); } - if (mover.EngineType == ElectricInductionMotor) { + if (physics.EngineType == ElectricInductionMotor) { // the share of the electric and pneumatic brake over the train (TDynamicObject's MED) isn't here - mover.CheckEIMIC(Dt); - mover.CheckSpeedCtrl(Dt); - mover.eimic_real = std::min(mover.eimic, mover.eimicSpeedCtrl); + physics.CheckEIMIC(Dt); + physics.CheckSpeedCtrl(Dt); + physics.eimic_real = std::min(physics.eimic, physics.eimicSpeedCtrl); } } // the whole frame's time, of all its iterations auto const frame{Dt * Track.iterations}; - auto const distance{m_mover->ComputeMovement(Dt, frame, shape, param, traction, Location, rotation)}; + auto const distance{m_physics->ComputeMovement(Dt, frame, shape, param, traction, Location, rotation)}; m_time += frame; if (m_trace != nullptr) { - m_trace->sample(m_time, *m_mover); + m_trace->sample(m_time, *m_physics); } return distance; } @@ -271,7 +271,7 @@ void vehicle::run(double Seconds, track const &Track, double Dt) { } } -// the physics reaches the vehicle next to it through TDynamicObject::MoverParameters only (neighbour_data). the +// the physics reaches the vehicle next to it through TDynamicObject::physics only (neighbour_data). the // tests can't make a TDynamicObject, whose constructor and members come with the rest of the engine, so the // neighbour is a zeroed block of its size with just that pointer set: enough for the physics, which reads nothing // else of it, and never used as a whole object @@ -279,9 +279,9 @@ static_assert(alignof(TDynamicObject) <= __STDCPP_DEFAULT_NEW_ALIGNMENT__); namespace { -std::vector make_standin(TMoverParameters &Mover) { +std::vector make_standin(physics::Vehicle &Physics) { std::vector standin(sizeof(TDynamicObject)); // zeroed - reinterpret_cast(standin.data())->MoverParameters = &Mover; // NOSONAR see above + reinterpret_cast(standin.data())->physics = &Physics; // NOSONAR see above return standin; } @@ -292,17 +292,17 @@ TDynamicObject *as_neighbour(std::byte *Standin) { } // namespace pair::pair(vehicle &First, VehicleEnd FirstEnd, vehicle &Second, VehicleEnd SecondEnd, double Gap) { - auto const &first{First.mover()}; - auto const &second{Second.mover()}; + auto const &first{First.physics()}; + auto const &second{Second.physics()}; // the first vehicle in the middle, its FirstEnd towards the second one - m_vehicles[0] = {&First, FirstEnd, 0.0, FirstEnd == VehicleEnd::front ? 1.0 : -1.0, make_standin(First.mover())}; - m_vehicles[1] = {&Second, SecondEnd, 0.5 * first.Dim.L + Gap + 0.5 * second.Dim.L, SecondEnd == VehicleEnd::front ? -1.0 : 1.0, make_standin(Second.mover())}; + m_vehicles[0] = {&First, FirstEnd, 0.0, FirstEnd == VehicleEnd::front ? 1.0 : -1.0, make_standin(First.physics())}; + m_vehicles[1] = {&Second, SecondEnd, 0.5 * first.Dim.L + Gap + 0.5 * second.Dim.L, SecondEnd == VehicleEnd::front ? -1.0 : 1.0, make_standin(Second.physics())}; } pair::~pair() { for (auto const &placed : m_vehicles) { // the vehicles outlive the pair, they mustn't point at its stand-ins - for (auto &neighbour : placed.owner->mover().Neighbours) { + for (auto &neighbour : placed.owner->physics().Neighbours) { neighbour = neighbour_data(); } } @@ -311,19 +311,19 @@ pair::~pair() { void pair::find_neighbours() { // as TDynamicObject::update_neighbours() for (auto const &placed : m_vehicles) { - placed.owner->mover().Loc = TLocation{placed.position, 0.0, 0.0}; + placed.owner->physics().Loc = TLocation{placed.position, 0.0, 0.0}; } for (int i = 0; i < 2; ++i) { auto const &self{m_vehicles[i]}; auto &other{m_vehicles[1 - i]}; // its stand-in is what this one points at - auto &mover{self.owner->mover()}; - auto const &othermover{other.owner->mover()}; - auto &neighbour{mover.Neighbours[self.end]}; + auto &physics{self.owner->physics()}; + auto const &otherPhysics{other.owner->physics()}; + auto &neighbour{physics.Neighbours[self.end]}; neighbour.vehicle = as_neighbour(other.standin.data()); neighbour.vehicle_end = NumberOf(other.end); - neighbour.distance = static_cast(TMoverParameters::CouplerDist(&mover, &othermover) - mover.Couplers[self.end].adapter_length - - othermover.Couplers[other.end].adapter_length); - mover.Neighbours[Opposite(self.end)] = neighbour_data(); + neighbour.distance = static_cast(physics::Vehicle::CouplerDist(&physics, &otherPhysics) - physics.Couplers[self.end].adapter_length - + otherPhysics.Couplers[other.end].adapter_length); + physics.Neighbours[Opposite(self.end)] = neighbour_data(); } } @@ -334,11 +334,11 @@ void pair::step(track const &Track, double Dt) { placed.owner->forces(Dt); } for (auto &placed : m_vehicles) { - auto const &mover{placed.owner->mover()}; - placed.position += placed.heading * placed.owner->move(Track, Dt, TLocation{placed.position, 0.0, 0.0}, mover.PipePress); + auto const &physics{placed.owner->physics()}; + placed.position += placed.heading * placed.owner->move(Track, Dt, TLocation{placed.position, 0.0, 0.0}, physics.PipePress); } // vehicle_table::update_brake_pipes() - TMoverParameters::UpdatePipeCouplers({&m_vehicles[0].owner->mover(), &m_vehicles[1].owner->mover()}, Dt); + physics::Vehicle::UpdatePipeCouplers({&m_vehicles[0].owner->physics(), &m_vehicles[1].owner->physics()}, Dt); } void pair::run(double Seconds, track const &Track, double Dt) { @@ -350,13 +350,13 @@ void pair::run(double Seconds, track const &Track, double Dt) { } double pair::gap() const { - auto const &first{m_vehicles[0].owner->mover()}; - auto const &second{m_vehicles[1].owner->mover()}; + auto const &first{m_vehicles[0].owner->physics()}; + auto const &second{m_vehicles[1].owner->physics()}; return std::abs(m_vehicles[1].position - m_vehicles[0].position) - 0.5 * (first.Dim.L + second.Dim.L); } CouplingSet pair::coupling() const { - return m_vehicles[0].owner->mover().Couplers[m_vehicles[0].end].CouplingFlag; + return m_vehicles[0].owner->physics().Couplers[m_vehicles[0].end].CouplingFlag; } void reseed_random() { diff --git a/tests/unit/vehicle.h b/tests/unit/vehicle.h index f83c50b7e..51362d9c1 100644 --- a/tests/unit/vehicle.h +++ b/tests/unit/vehicle.h @@ -9,7 +9,7 @@ #include -#include "physics/mover.h" +#include "physics/vehicle.h" namespace test { @@ -87,8 +87,8 @@ class vehicle { public: explicit vehicle(definition const &Definition, double Velocity = 0.0, std::string const &Name = "test", int Cab = 0); - TMoverParameters &mover() { return *m_mover; } - TMoverParameters *operator->() { return m_mover.get(); } + physics::Vehicle &physics() { return *m_physics; } + physics::Vehicle *operator->() { return m_physics.get(); } // keeps the brake pipe at the given pressure [bar], as a locomotive coupled to the vehicle would; // a negative value leaves the pipe alone @@ -116,10 +116,10 @@ public: double move(track const &Track, double Dt, TLocation const &Location, double Trainpipe); // vehicle speed in kilometres per hour, negative when moving backwards - double speed() const { return m_mover->V * 3.6; } + double speed() const { return m_physics->V * 3.6; } private: - std::unique_ptr m_mover; + std::unique_ptr m_physics; int m_cab{0}; double m_pipepressure{-1.0}; double m_reservoirpressure{-1.0}; diff --git a/tools/rename/mover_to_physics.py b/tools/rename/mover_to_physics.py new file mode 100644 index 000000000..bc1b8885f --- /dev/null +++ b/tools/rename/mover_to_physics.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python3 +"""Renames the physics of a vehicle from TMoverParameters, "the mover", to physics::Vehicle. + +Run it from the root of the repository, on any branch, before merging a branch made before the rename into one +made after it (or the other way round): it turns the old names of the branch into the new ones, so the merge +doesn't conflict over them. Running it again changes nothing. + + python tools/rename/mover_to_physics.py # rename + python tools/rename/mover_to_physics.py --check # only list what it would change, exit 1 if anything + +What it renames, in the code and in the comments (never inside string literals, whose text the game shows, logs or +looks up): + + physics/mover.h physics/vehicle.h + TMoverParameters physics::Vehicle (the class is in namespace physics) + TDynamicObject::MoverParameters physics + mvOccupied, mvControlled occupied, controlled + mvSecond, mvThird secondUnit, thirdUnit + mvPantographUnit pantographUnit + mover, Mover, movers physics, Physics, vehicles (the locals and the parameters) + m_mover, othermover, ... m_physics, otherPhysics, ... + +The "movers" of the editor, the tracks a slide moves, keep their name (EDITOR_MOVERS below). + +One case is left to the hand: a member function of TDynamicObject whose local `mover` is its own `MoverParameters` +(`auto &mover { *MoverParameters };`) becomes `auto &physics { *physics };`, which the compiler stops at ("cannot be +used before it is initialized"). Drop the line and write `physics->` for `physics.` in the rest of the function. +""" + +import re +import subprocess +import sys +from pathlib import Path + +OLD_HEADER = "physics/mover.h" +NEW_HEADER = "physics/vehicle.h" +EXTENSIONS = (".cpp", ".h", ".hpp", ".inl", ".md", ".txt", ".cmake") +SKIP_PREFIXES = ("ref/", "build/", "tools/rename/") +# where a mover is a track moved by a slide of the editor, not the physics of a vehicle +EDITOR_MOVERS = {"application/editormode.h", "application/editormodeswitchslide.cpp"} + +# in the order they apply: the longer and the special forms first +RENAMES = [ + (r"\bmover\.h\b", "vehicle.h"), + (r"\bTMoverParameters::TMoverParameters\b", "physics::Vehicle::Vehicle"), + (r"\bTMoverParameters::~TMoverParameters\b", "physics::Vehicle::~Vehicle"), + (r"\bclass TMoverParameters;", "namespace physics { class Vehicle; }"), + (r"\bT_MoverParameters\b", "physics::Vehicle"), + (r"\bTMoverParameters\b", "physics::Vehicle"), + (r"\bMoverParameters\b", "physics"), + (r"\bmvOccupied\b", "occupied"), + (r"\bmvControlled\b", "controlled"), + (r"\bmvSecond\b", "secondUnit"), + (r"\bmvThird\b", "thirdUnit"), + (r"\bmvPantographUnit\b", "pantographUnit"), + (r"\bm_mover\b", "m_physics"), + (r"\bothermover\b", "otherPhysics"), + (r"\bcurrentMover\b", "currentPhysics"), + (r"\bfrom_movers\b", "from_vehicles"), + (r"\brenderMoverEventSounds\b", "renderPhysicsEventSounds"), + (r"\bmoverparam\b", "the physics"), + (r"\b_mover__(\d)\b", r"_vehicle__\1"), +] +LOCAL_RENAMES = [ + (r"\bmover's\b", "physics'"), + (r"\bmovers\b", "vehicles"), + (r"\bmover\b", "physics"), + (r"\bMover\b", "Physics"), +] + +# a comment, or a string or a character literal (raw strings included): the comments come first, so an apostrophe in +# one doesn't start a character literal +TOKEN = re.compile(r'//[^\n]*|/\*.*?\*/|R"([^()\\\s]{0,16})\(.*?\)\1"|"(?:\\.|[^"\\\n])*"|\'(?:\\.|[^\'\\\n])*\'', re.S) + + +def tracked_files(): + names = subprocess.run(["git", "ls-files"], capture_output=True, text=True, check=True).stdout.split("\n") + for name in names: + if not name or name.startswith(SKIP_PREFIXES): + continue + if name.endswith(EXTENSIONS) or Path(name).name == "CMakeLists.txt": + yield name + + +def rename_outside_literals(text, renames): + """applies the renames to the code and the comments, not to the string and character literals""" + out = [] + last = 0 + for token in TOKEN.finditer(text): + out.append(apply(text[last:token.start()], renames)) + is_comment = token.group(0).startswith(("//", "/*")) + out.append(apply(token.group(0), renames) if is_comment else token.group(0)) + last = token.end() + out.append(apply(text[last:], renames)) + return "".join(out) + + +def apply(chunk, renames): + for pattern, replacement in renames: + chunk = re.sub(pattern, replacement, chunk) + return chunk + + +def rename_file(name, text): + is_code = name.endswith((".cpp", ".h", ".hpp", ".inl")) + # the header where it is included or listed + text = text.replace('"' + OLD_HEADER + '"', '"' + NEW_HEADER + '"') + text = text.replace(OLD_HEADER, NEW_HEADER) + renames = RENAMES + ([] if name in EDITOR_MOVERS else LOCAL_RENAMES) + if is_code: + text = rename_outside_literals(text, renames) + else: + text = apply(text, renames) + if name == NEW_HEADER: + text = wrap_in_namespace(text) + return text + + +def wrap_in_namespace(text): + """puts the class of the physics of a vehicle into namespace physics, once""" + if "\nnamespace physics\n{\n\nclass Vehicle\n" in text.replace("\r\n", "\n"): + return text + nl = "\r\n" if "\r\n" in text else "\n" + head = "class physics::Vehicle" + nl + "{" + start = text.find(head) + if start < 0: + return text + # the end of the class: the brace that closes the one after its name, the braces of the comments and the literals + # not counted + depth = 0 + end = None + i = start + len(head) - 1 + while i < len(text): + token = TOKEN.match(text, i) + if token is not None: + i = token.end() + continue + if text[i] == "{": + depth += 1 + elif text[i] == "}": + depth -= 1 + if depth == 0: + end = text.index(";", i) + 1 + break + i += 1 + if end is None: + raise SystemExit("the end of class physics::Vehicle not found in " + NEW_HEADER) + body = text[start + len(head):end] + # inside the class it is just Vehicle: the constructor and the destructor + body = re.sub(r"(\n\s*)physics::Vehicle\(", r"\1Vehicle(", body) + body = re.sub(r"(\n\s*)~physics::Vehicle\(", r"\1~Vehicle(", body) + wrapped = "namespace physics" + nl + "{" + nl + nl + "class Vehicle" + nl + "{" + body + nl + nl + "} // namespace physics" + text = text[:start] + wrapped + text[end:] + # the types before the class point at it + forward = "namespace physics" + nl + "{" + nl + "class Vehicle;" + nl + "}" + nl + anchor = "class cParser;" + nl + if forward not in text and anchor in text: + text = text.replace(anchor, anchor + forward, 1) + return text + + +def main(): + check = "--check" in sys.argv + changed = [] + if Path(OLD_HEADER).exists(): + changed.append(OLD_HEADER + " -> " + NEW_HEADER) + if not check: + subprocess.run(["git", "mv", OLD_HEADER, NEW_HEADER], check=True) + for name in tracked_files(): + path = Path(name) + if not path.exists(): + continue + raw = path.read_bytes() + try: + text = raw.decode("utf-8") + except UnicodeDecodeError: + continue + renamed = rename_file(name, text) + if renamed != text: + changed.append(name) + if not check: + path.write_bytes(renamed.encode("utf-8")) + for name in changed: + print(name) + print(f"{len(changed)} file(s) {'to change' if check else 'changed'}") + return 1 if check and changed else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/utilities/Classes.h b/utilities/Classes.h index b8c470ec9..1291d8433 100644 --- a/utilities/Classes.h +++ b/utilities/Classes.h @@ -32,7 +32,7 @@ class TTraction; // drut class TTractionPowerSource; // zasilanie drutów class TCamera; class scenario_time; -class TMoverParameters; +namespace physics { class Vehicle; } class ui_layer; class editor_ui; class itemproperties_panel; diff --git a/utilities/Globals.h b/utilities/Globals.h index a98d5e60a..43dfcb9d6 100644 --- a/utilities/Globals.h +++ b/utilities/Globals.h @@ -147,7 +147,7 @@ struct global_settings { std::string Weather{ "cloudy:" }; // current weather std::string Period{}; // time of the day, based on sun position bool FullPhysics{ true }; // full calculations performed for each simulation step - bool physics_sleepheld{ false }; // vehicles standing still and held by their brakes let their physics sleep, see TMoverParameters::accelerating() + bool physics_sleepheld{ false }; // vehicles standing still and held by their brakes let their physics sleep, see physics::Vehicle::accelerating() bool physics_roadlod{ false }; // road vehicles far from the camera go by one step of the physics in a frame, see vehicle_table::update() float physics_pipewake{ 0.f }; // bar: air flowing along a pipe wakes the physics of a vehicle when it changes its pressure by more than this. 0: any flow does bool performance_multithreading{ true }; // work split over the logical cores of the machine (worker_pool), as many as each job is worth @@ -360,7 +360,7 @@ struct global_settings { enum class track_buckling_mode { off, scenery, automatic }; track_buckling_mode track_buckling = track_buckling_mode::scenery; // the physical model of the couplings (physics/couplerphysics.h): progressive buffers and draw gear with hysteresis, - // the play of the coupling, its yield and breaking; the legacy model of TMoverParameters::CouplerForce() without it. + // the play of the coupling, its yield and breaking; the legacy model of physics::Vehicle::CouplerForce() without it. // it covers the player's train and the trains it closes in on (vehicle_table::update_coupler_physics()), or every // train with coupler_physics_all bool coupler_physics = false; diff --git a/utilities/Timer.h b/utilities/Timer.h index 7976d51d2..3eed6eb15 100644 --- a/utilities/Timer.h +++ b/utilities/Timer.h @@ -88,7 +88,7 @@ private: float m_accumulator { 0.f }; }; -// what resets TMoverParameters::LastSwitchingTime, which keeps the physics of a vehicle on for 5 s: counted over a second, +// what resets physics::Vehicle::LastSwitchingTime, which keeps the physics of a vehicle on for 5 s: counted over a second, // with the vehicle which did it most often, for the debug panel class switching_counter { @@ -98,7 +98,7 @@ public: compressor_off, mains, diesel, - // switch_physics( true ) of a vehicle whose physics was off, by TMoverParameters::wake_cause, in its order + // switch_physics( true ) of a vehicle whose physics was off, by physics::Vehicle::wake_cause, in its order wake, wake_mainpipe, wake_scndpipe, @@ -213,12 +213,12 @@ struct subsystem_stopwatches { unsigned int largestgroup { 0 }; unsigned int maingroups { 0 }; // rail vehicles standing still (below 0.01 km/h) with the physics on, and what keeps it on by the test of - // TMoverParameters::ComputeTotalForce(); a vehicle can have several of these + // physics::Vehicle::ComputeTotalForce(); a vehicle can have several of these struct awake_reasons { unsigned int vehicles { 0 }; unsigned int cab { 0 }; // CabActive unsigned int speed { 0 }; // Vel above 0.0001 km/h - unsigned int acceleration { 0 }; // AccS above 0.0001 m/s2, and not held by the brakes (TMoverParameters::accelerating()) + unsigned int acceleration { 0 }; // AccS above 0.0001 m/s2, and not held by the brakes (physics::Vehicle::accelerating()) unsigned int switching { 0 }; // LastSwitchingTime below 5 s unsigned int multipleunit { 0 }; // EZT, DMU unsigned int neighbour { 0 }; // a neighbour moving or accelerating diff --git a/utilities/motiontelemetry.cpp b/utilities/motiontelemetry.cpp index ed2e9f8fe..e8995d716 100644 --- a/utilities/motiontelemetry.cpp +++ b/utilities/motiontelemetry.cpp @@ -6,7 +6,7 @@ #include "utilities/Timer.h" #include "vehicle/Driver.h" #include "simulation/simulation.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #ifdef _WIN32 #include diff --git a/utilities/translation.cpp b/utilities/translation.cpp index ec695b05b..0d007bbd8 100644 --- a/utilities/translation.cpp +++ b/utilities/translation.cpp @@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/translation.h" #include "utilities/Logs.h" #include "utilities/Globals.h" -#include "physics/mover.h" +#include "physics/vehicle.h" void locale::init() { diff --git a/utilities/uart.cpp b/utilities/uart.cpp index 902c95b5f..df6544776 100644 --- a/utilities/uart.cpp +++ b/utilities/uart.cpp @@ -9,7 +9,7 @@ #include "utilities/utilities.h" #include "simulation/simulationtime.h" #include "application/application.h" -#include "physics/mover.h" +#include "physics/vehicle.h" const char* const uart_baudrates_list[] = { "300", diff --git a/vehicle/Camera.cpp b/vehicle/Camera.cpp index 234483ee4..51b13e87e 100644 --- a/vehicle/Camera.cpp +++ b/vehicle/Camera.cpp @@ -17,7 +17,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "vehicle/Driver.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" //--------------------------------------------------------------------------- diff --git a/vehicle/Driver.h b/vehicle/Driver.h index 2cde64ee6..2ac5c89f8 100644 --- a/vehicle/Driver.h +++ b/vehicle/Driver.h @@ -244,11 +244,11 @@ public: bool primary() const { return drivingFlags.primary; }; inline - TMoverParameters const *Controlling() const { + physics::Vehicle const *Controlling() const { return mvControlling; } inline - TMoverParameters const *Occupied() const { - return mvOccupied; } + physics::Vehicle const *Occupied() const { + return occupied; } void DirectionInitial(); void DirectionChange(); inline @@ -310,7 +310,7 @@ private: void WaitingSet( double Seconds ); void DirectionForward( bool forward ); void ZeroDirection(); - int OrderDirectionChange( int newdir, TMoverParameters *Vehicle ); + int OrderDirectionChange( int newdir, physics::Vehicle *Vehicle ); void sync_consist_reversers(); void Lights( int head, int rear ); std::string StopReasonText() const; @@ -420,9 +420,9 @@ private: bool Psyche = false; int HelperState = 0; //stan pomocnika maszynisty TDynamicObject *pVehicle = nullptr; // pojazd w którym siedzi sterujący - TMoverParameters *mvControlling = nullptr; // jakim pojazdem steruje (może silnikowym w EZT) - TMoverParameters *mvOccupied = nullptr; // jakim pojazdem hamuje - TMoverParameters *mvPantographUnit = nullptr; //pantograph equipped vehicle in the occupied/controlled set + physics::Vehicle *mvControlling = nullptr; // jakim pojazdem steruje (może silnikowym w EZT) + physics::Vehicle *occupied = nullptr; // jakim pojazdem hamuje + physics::Vehicle *pantographUnit = nullptr; //pantograph equipped vehicle in the occupied/controlled set std::string VehicleName; ByEnd m_lighthints = { -1, -1 }; // suggested light patterns double AccPreferred = 0.0; // preferowane przyspieszenie (wg psychiki kierującego, zmniejszana przy wykryciu kolizji) diff --git a/vehicle/DynObj.h b/vehicle/DynObj.h index acf6c0461..e8eddd9d5 100644 --- a/vehicle/DynObj.h +++ b/vehicle/DynObj.h @@ -140,7 +140,7 @@ public: // destructor ~TAnim(); // methods - int TypeSet(int i, TMoverParameters currentMover, int fl = 0); // ustawienie typu + int TypeSet(int i, physics::Vehicle currentPhysics, int fl = 0); // ustawienie typu // members union { @@ -220,7 +220,7 @@ public: std::string asTrack; // nazwa toru początkowego; wywalić? std::string asDestination; // dokąd pojazd ma być kierowany "(stacja):(tor)" glm::dmat4 mMatrix; // macierz przekształcenia do renderowania modeli - TMoverParameters *MoverParameters; // parametry fizyki ruchu oraz przeliczanie + physics::Vehicle *physics; // parametry fizyki ruchu oraz przeliczanie TDynamicObject *NextConnected(); // pojazd podłączony od strony sprzęgu 1 (kabina -1) TDynamicObject *PrevConnected(); // pojazd podłączony od strony sprzęgu 0 (kabina 1) TDynamicObject *NextConnected() const; // pojazd podłączony od strony sprzęgu 1 (kabina -1) @@ -476,21 +476,21 @@ private: sound_source retarder { sound_placement::engine }; void position( glm::vec3 const Location ); - void render( TMoverParameters const &Vehicle, double const Deltatime ); + void render( physics::Vehicle const &Vehicle, double const Deltatime ); private: // the parts of render(), by subsystem - void renderPumpSounds( TMoverParameters const &Vehicle ); - void renderIgnitionSounds( TMoverParameters const &Vehicle ); - void renderEngineSounds( TMoverParameters const &Vehicle, double const Deltatime ); - void renderTurboSound( TMoverParameters const &Vehicle, double const Deltatime ); - void renderClutchSound( TMoverParameters const &Vehicle ); - void renderRetarderSound( TMoverParameters const &Vehicle ); - void renderTractionMotorSounds( TMoverParameters const &Vehicle, double const Deltatime ); - void renderMotorBlowerSounds( TMoverParameters const &Vehicle ); - void renderInverterSound( TMoverParameters const &Vehicle ); - void renderFanSounds( TMoverParameters const &Vehicle ); - void renderRelaySounds( TMoverParameters const &Vehicle ); - void renderTransmissionSound( TMoverParameters const &Vehicle ); + void renderPumpSounds( physics::Vehicle const &Vehicle ); + void renderIgnitionSounds( physics::Vehicle const &Vehicle ); + void renderEngineSounds( physics::Vehicle const &Vehicle, double const Deltatime ); + void renderTurboSound( physics::Vehicle const &Vehicle, double const Deltatime ); + void renderClutchSound( physics::Vehicle const &Vehicle ); + void renderRetarderSound( physics::Vehicle const &Vehicle ); + void renderTractionMotorSounds( physics::Vehicle const &Vehicle, double const Deltatime ); + void renderMotorBlowerSounds( physics::Vehicle const &Vehicle ); + void renderInverterSound( physics::Vehicle const &Vehicle ); + void renderFanSounds( physics::Vehicle const &Vehicle ); + void renderRelaySounds( physics::Vehicle const &Vehicle ); + void renderTransmissionSound( physics::Vehicle const &Vehicle ); }; // single source per door (pair) on the centreline struct doorspeaker_sounds { @@ -861,7 +861,7 @@ private: void renderWheelFlatSound(); void renderCurveSound(); void renderStartJoltSound(); - void renderMoverEventSounds(); + void renderPhysicsEventSounds(); void renderCouplerSounds(); void renderDerailmentSounds(); public: @@ -1142,7 +1142,7 @@ private: std::string m_overlappair; double m_overlapdue { 1.0 }; bool m_overlaplogged { false }; - std::vector m_brakepipes; // the vehicles of update_brake_pipes(), kept for the memory + std::vector m_brakepipes; // the vehicles of update_brake_pipes(), kept for the memory std::vector> m_offtrackterrains; // of off_track_terrain() }; diff --git a/vehicle/Train.h b/vehicle/Train.h index 7ef51c28d..ce5ea2def 100644 --- a/vehicle/Train.h +++ b/vehicle/Train.h @@ -248,7 +248,7 @@ class TTrain { return ggHornButton.SubModel != nullptr && ggHornLowButton.SubModel == nullptr && ggHornHighButton.SubModel == nullptr; } // locates nearest vehicle belonging to the consist TDynamicObject *find_nearest_consist_vehicle(bool freefly, glm::vec3 pos) const; - // mover master controller to specified position + // physics master controller to specified position void set_master_controller( double const Position ); // moves train brake lever to specified position, potentially emits switch sound if conditions are met void set_train_brake( double const Position ); @@ -263,7 +263,7 @@ class TTrain { // helper, common part of pantograh valves state update methods void update_pantograph_valves(); // the Index-th other vehicle in multiple whose engine the cab starts with its own switches (0: mainb_*, 1: mainc_*) - TMoverParameters *remote_engine( std::size_t const Index ) const; + physics::Vehicle *remote_engine( std::size_t const Index ) const; // the switches starting the engines of the other vehicles in multiple, for Deltatime seconds void update_remote_linebreakers( double const Deltatime ); // update function subroutines @@ -592,11 +592,11 @@ class TTrain { // members TDynamicObject *DynamicObject { nullptr }; // przestawia zmiana pojazdu [F5] - TMoverParameters *mvControlled { nullptr }; // człon, w którym sterujemy silnikiem - TMoverParameters *mvOccupied { nullptr }; // człon, w którym sterujemy hamulcem - TMoverParameters *mvSecond { nullptr }; // drugi człon (ET40, ET41, ET42, ukrotnienia) - TMoverParameters *mvThird { nullptr }; // trzeci człon (SN61) - TMoverParameters *mvPantographUnit { nullptr }; // nearest pantograph equipped unit + physics::Vehicle *controlled { nullptr }; // człon, w którym sterujemy silnikiem + physics::Vehicle *occupied { nullptr }; // człon, w którym sterujemy hamulcem + physics::Vehicle *secondUnit { nullptr }; // drugi człon (ET40, ET41, ET42, ukrotnienia) + physics::Vehicle *thirdUnit { nullptr }; // trzeci człon (SN61) + physics::Vehicle *pantographUnit { nullptr }; // nearest pantograph equipped unit // helper variable, to prevent immediate switch between closing and opening line breaker circuit linebreaker::state m_linebreakerstate { linebreaker::state::open }; static const commandhandler_map m_commandhandlers; @@ -1046,10 +1046,10 @@ private: inline auto &RadioChannel() { return Dynamic()->Mechanik->iRadioChannel; } inline TDynamicObject *Dynamic() { return DynamicObject; }; inline TDynamicObject const *Dynamic() const { return DynamicObject; }; - inline TMoverParameters *Controlled() { return mvControlled; }; - inline TMoverParameters const *Controlled() const { return mvControlled; }; - inline TMoverParameters *Occupied() { return mvOccupied; }; - inline TMoverParameters const *Occupied() const { return mvOccupied; }; + inline physics::Vehicle *Controlled() { return controlled; }; + inline physics::Vehicle const *Controlled() const { return controlled; }; + inline physics::Vehicle *Occupied() { return occupied; }; + inline physics::Vehicle const *Occupied() const { return occupied; }; void DynamicSet(TDynamicObject *d); void MoveToVehicle( TDynamicObject *target ); // checks whether specified point is within boundaries of the active cab diff --git a/vehicle/ai/consist.cpp b/vehicle/ai/consist.cpp index b0774eccf..c66e090f8 100644 --- a/vehicle/ai/consist.cpp +++ b/vehicle/ai/consist.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -55,28 +55,28 @@ void TController::Activation() { // jeśli jest ustalony kierunek auto *initialvehicle { pVehicle }; /* - auto const initiallocalbrakelevel { mvOccupied->LocalBrakePosA }; + auto const initiallocalbrakelevel { occupied->LocalBrakePosA }; */ - auto const initialspringbrakestate { mvOccupied->SpringBrake.Activate }; + auto const initialspringbrakestate { occupied->SpringBrake.Activate }; // switch off tempomat SpeedCntrl( 0.0 ); mvControlling->DecScndCtrl( 2 ); // reset controls ZeroSpeed(); ZeroDirection(); - mvOccupied->CabOccupied = mvOccupied->CabActive; // użytkownik moze zmienić CabOccupied wychodząc - mvOccupied->CabDeactivisation(); // tak jest w Train.cpp - if (pVehicle->MoverParameters->Couplers[iDirectionOrder < 0 ? VehicleEnd::rear : VehicleEnd::front].CouplingFlag.HasAll(Coupling::control)) { + occupied->CabOccupied = occupied->CabActive; // użytkownik moze zmienić CabOccupied wychodząc + occupied->CabDeactivisation(); // tak jest w Train.cpp + if (pVehicle->physics->Couplers[iDirectionOrder < 0 ? VehicleEnd::rear : VehicleEnd::front].CouplingFlag.HasAll(Coupling::control)) { ZeroLocalBrake(); if( initialspringbrakestate ) { - mvOccupied->SpringBrakeActivate( false ); + occupied->SpringBrakeActivate( false ); } // odcięcie na zaworze maszynisty, FVel6 po drugiej stronie nie luzuje - mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos(bh_NP) ); // odcięcie na zaworze maszynisty - BrakeLevelSet( mvOccupied->BrakeCtrlPos ); //ustawienie zmiennej GBH + occupied->BrakeLevelSet( occupied->Handle->GetPos(bh_NP) ); // odcięcie na zaworze maszynisty + BrakeLevelSet( occupied->BrakeCtrlPos ); //ustawienie zmiennej GBH } // przejście AI na drugą stronę EN57, ET41 itp. - // TODO: clean this up, there's lot of redundancy with TMoverParameters::ChangeCab() and TTrain::MoveToVehicle() + // TODO: clean this up, there's lot of redundancy with physics::Vehicle::ChangeCab() and TTrain::MoveToVehicle() { int movedirection { NumberOf( iDirection < 0 ? VehicleEnd::rear : VehicleEnd::front ) }; auto *targetvehicle { pVehicle->FirstFind( movedirection, Coupling::control ) }; @@ -84,7 +84,7 @@ void TController::Activation() auto *targetvehicledriver { targetvehicle->Mechanik }; // zapamiętanie tego, co ewentualnie tam siedzi, żeby w razie dwóch zamienić miejscami // move to the new vehicle targetvehicle->Mechanik = this; // na razie bilokacja - targetvehicle->MoverParameters->SetInternalCommand(VehicleCommand::none, 0, 0); // usunięcie ewentualnie zalegającej komendy (Change_direction?) + targetvehicle->physics->SetInternalCommand(VehicleCommand::none, 0, 0); // usunięcie ewentualnie zalegającej komendy (Change_direction?) if( targetvehicle->DirectionGet() != pVehicle->DirectionGet() ) { // jeśli są przeciwne do siebie to będziemy jechać w drugą stronę względem zasiedzianego pojazdu iDirection = -iDirection; @@ -93,9 +93,9 @@ void TController::Activation() pVehicle->Mechanik = targetvehicledriver; // wsadzamy tego, co ewentualnie był (podwójna trakcja) // NOTE: having caboccupied != 0 (by swapping in the driver from the target vehicle) may lead to dysfunctional brake // TODO: investigate and resolve if necessary - pVehicle->MoverParameters->CabOccupied = targetvehicle->MoverParameters->CabOccupied; + pVehicle->physics->CabOccupied = targetvehicle->physics->CabOccupied; if( pVehicle->Mechanik ) { // not guaranteed, as target vehicle can be empty - pVehicle->Mechanik->BrakeLevelSet( pVehicle->MoverParameters->BrakeCtrlPos ); + pVehicle->Mechanik->BrakeLevelSet( pVehicle->physics->BrakeCtrlPos ); } // finish driver swap pVehicle = targetvehicle; @@ -104,28 +104,28 @@ void TController::Activation() if (pVehicle != initialvehicle) { // jeśli zmieniony został pojazd prowadzony ControllingSet(); // utworzenie połączenia do sterowanego pojazdu (może się zmienić) - silnikowy dla EZT - if( mvOccupied->BrakeCtrlPosNo > 0 + if( occupied->BrakeCtrlPosNo > 0 && ( BrakeSystem == TBrakeSystem::Pneumatic || BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) { - mvOccupied->LimPipePress = mvOccupied->PipePress; - mvOccupied->ActFlowSpeed = 0; + occupied->LimPipePress = occupied->PipePress; + occupied->ActFlowSpeed = 0; } - BrakeLevelSet( mvOccupied->BrakeCtrlPos ); + BrakeLevelSet( occupied->BrakeCtrlPos ); } if( mvControlling->EngineType == TEngineType::DieselEngine && mvControlling->ShuntModeAllow ) { // dla 2Ls150 - przed ustawieniem kierunku - można zmienić tryb pracy mvControlling->CurrentSwitch(OrderCurrentGet().HasAny(DriverOrder::shunt | DriverOrder::looseShunt) || fMass > 224000.0); // do tego na wzniesieniu może nie dać rady na liniowym } // Ra: to przełączanie poniżej jest tu bez sensu - mvOccupied->CabOccupied = iDirection; // aktywacja kabiny w prowadzonym pojeżdzie (silnikowy może być odwrotnie?) - mvOccupied->CabActivisation(); // uruchomienie kabin w członach + occupied->CabOccupied = iDirection; // aktywacja kabiny w prowadzonym pojeżdzie (silnikowy może być odwrotnie?) + occupied->CabActivisation(); // uruchomienie kabin w członach DirectionForward(true); // nawrotnik do przodu - mvOccupied->SpringBrakeActivate( initialspringbrakestate ); + occupied->SpringBrakeActivate( initialspringbrakestate ); /* // NOTE: this won't restore local brake if the vehicle has integrated local brake control // TBD, TODO: fix or let the ai activate the brake again as part of its standard logic? if (initiallocalbrakelevel > 0.0) // hamowanie tylko jeśli był wcześniej zahamowany (bo możliwe, że jedzie!) - mvOccupied->LocalBrakePosA = initiallocalbrakelevel; // zahamuj jak wcześniej + occupied->LocalBrakePosA = initiallocalbrakelevel; // zahamuj jak wcześniej */ if( pVehicle != initialvehicle ) { auto *train { simulation::Trains.find( initialvehicle->name() ) }; @@ -144,7 +144,7 @@ void TController::AutoRewident() // 1. Zebranie informacji o składzie pociągu, od czoła do końca std::vector consist; for (auto const *d = pVehicles[0]; d != nullptr; d = d->Next()) { - consist.emplace_back(brake_setting::describe(*d->MoverParameters, d == pVehicle)); + consist.emplace_back(brake_setting::describe(*d->physics, d == pVehicle)); } // 2. Określenie typu pociągu i nastaw: by the brake instruction Cw-1 (eu07/maszyna#350), or as the releases before it did. // brakes are cut out (Cw-1 §19.9) only in a train (a bank engine's run included), not in a consist being shunted @@ -152,7 +152,7 @@ void TController::AutoRewident() auto const settings{Global.AIBrakeSettingCw1 ? brake_setting::choose(consist, train) : brake_setting::choose_legacy(consist)}; // and only at a standstill, the train creeping to a stop included: a check on the run (the order changed mid-run, or // the train was just formed by coupling, which the AI does above that speed) leaves them to reinspect_brakes() - auto const standstill{brake_setting::at_standstill(mvOccupied->Vel)}; + auto const standstill{brake_setting::at_standstill(occupied->Vel)}; auto reinspect{false}; // a light engine counts as a passenger train for the braking below auto const passengertrain{brake_setting::passenger(brake_setting::choose_train_setting(consist))}; @@ -164,21 +164,21 @@ void TController::AutoRewident() continue; } // the setting, a brake cut out in a train on G (Cw-1 §19.9) or put back when the train no longer needs it cut out - if (brake_setting::apply(*d->MoverParameters, *setting, standstill)) { + if (brake_setting::apply(*d->physics, *setting, standstill)) { // a brake to cut out, with the train moving: left for the next standstill reinspect = true; } // potentially release manual brake - d->MoverParameters->DecManualBrakeLevel( ManualBrakePosNo ); - d->MoverParameters->SpringBrake.Activate = false; + d->physics->DecManualBrakeLevel( ManualBrakePosNo ); + d->physics->SpringBrake.Activate = false; } BrakeReinspectionPending = reinspect; //ustawianie trybu pracy zadajnika hamulca, wystarczy raz po inicjalizacji AI if( true == AIControllFlag ) { // 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( ( mvOccupied->BrakeOpModes & i ) > 0 ) { - mvOccupied->BrakeOpModeFlag = i; + if( ( occupied->BrakeOpModes & i ) > 0 ) { + occupied->BrakeOpModeFlag = i; } } } @@ -204,20 +204,20 @@ 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) { - mvOccupied->EpFuseSwitch(BrakeSystem == TBrakeSystem::ElectroPneumatic); + occupied->EpFuseSwitch(BrakeSystem == TBrakeSystem::ElectroPneumatic); } if( OrderCurrentGet() & ( DriverOrder::obeyTrain | DriverOrder::bank ) ) { // 4. Przeliczanie siły hamowania - double const velstep = mvOccupied->Vmax * 0.5 / BrakeAccTableSize; + double const velstep = occupied->Vmax * 0.5 / BrakeAccTableSize; auto *d = pVehicles[0]; // pojazd na czele składu while (d) { // a vehicle with its brake cut out (by the inspector above or for a reason of its own) adds its mass only; // the inspector of the earlier releases counted its brake in - auto const brakes{false == Global.AIBrakeSettingCw1 || false == brake_setting::is_cut_out(*d->MoverParameters)}; + auto const brakes{false == Global.AIBrakeSettingCw1 || false == brake_setting::is_cut_out(*d->physics)}; for( int i = 0; i < BrakeAccTableSize && brakes; ++i ) { - fBrake_a0[ i + 1 ] += d->MoverParameters->BrakeForceR( 0.25, velstep*( 1 + 2 * i ) ); - fBrake_a1[ i + 1 ] += d->MoverParameters->BrakeForceR( 1.00, velstep*( 1 + 2 * i ) ); + fBrake_a0[ i + 1 ] += d->physics->BrakeForceR( 0.25, velstep*( 1 + 2 * i ) ); + fBrake_a1[ i + 1 ] += d->physics->BrakeForceR( 1.00, velstep*( 1 + 2 * i ) ); } d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } @@ -229,8 +229,8 @@ void TController::AutoRewident() fBrake_a1[i+1] /= 12 * fMass; } - IsPassengerTrain = is_train() && false == is_emu() && false == is_dmu() && (mvOccupied->BrakeDelayFlag & bdelay_G) == 0; - IsCargoTrain = is_train() && (mvOccupied->BrakeDelayFlag & bdelay_G) != 0; + IsPassengerTrain = is_train() && false == is_emu() && false == is_dmu() && (occupied->BrakeDelayFlag & bdelay_G) == 0; + IsCargoTrain = is_train() && (occupied->BrakeDelayFlag & bdelay_G) != 0; IsHeavyCargoTrain = true == IsCargoTrain && fBrake_a0[1] > 0.4 && iVehicles - ControlledEnginesCount > 0 && fMass / iVehicles > 50000; BrakingInitialLevel = IsHeavyCargoTrain ? 1.25 : IsCargoTrain ? 1.25 : 1.00; @@ -278,7 +278,7 @@ void TController::reinspect_brakes() BrakeReinspectionPending = false; return; } - if (brake_setting::at_standstill(mvOccupied->Vel)) { + if (brake_setting::at_standstill(occupied->Vel)) { // standing, the inspector leaves nothing for later: this clears the flag AutoRewident(); } @@ -286,10 +286,10 @@ void TController::reinspect_brakes() int TController::CheckDirection() { - int d = mvOccupied->DirAbsolute; // który sprzęg jest z przodu + int d = occupied->DirAbsolute; // który sprzęg jest z przodu if( !d ) { // jeśli nie ma ustalonego kierunku to jedziemy wg aktualnej kabiny - d = mvOccupied->CabActive; + d = occupied->CabActive; } return d; } @@ -319,13 +319,13 @@ bool TController::CheckVehicles(DriverOrders user) && p->Mechanik != this && p->Mechanik->drivingFlags.primary ) { // ale chodzi o inny pojazd, niż aktualnie sprawdzający // a tamten ma priorytet // TODO: take into account drivers' operating modes, one or more of them might be on banking duty - if (drivingFlags.primary && mvOccupied->DirAbsolute && mvOccupied->BrakeCtrlPos >= -1) + if (drivingFlags.primary && occupied->DirAbsolute && occupied->BrakeCtrlPos >= -1) { // jeśli rządzi i ma kierunek p->Mechanik->primary(false); // dezaktywuje tamtego p->Mechanik->ZeroLocalBrake(); - p->MoverParameters->BrakeLevelSet(p->MoverParameters->Handle->GetPos(bh_NP)); // odcięcie na zaworze maszynisty - p->Mechanik->BrakeLevelSet(p->MoverParameters->BrakeCtrlPos); // ustawienie zmiennej GBH + p->physics->BrakeLevelSet(p->physics->Handle->GetPos(bh_NP)); // odcięcie na zaworze maszynisty + p->Mechanik->BrakeLevelSet(p->physics->BrakeCtrlPos); // ustawienie zmiennej GBH } else { @@ -334,12 +334,12 @@ bool TController::CheckVehicles(DriverOrders user) } ++iVehicles; // jest jeden pojazd więcej pVehicles[VehicleEnd::rear] = p; // zapamiętanie ostatniego - fLength += p->MoverParameters->Dim.L; // dodanie długości pojazdu - fMass += p->MoverParameters->TotalMass; // dodanie masy łącznie z ładunkiem - fVelMax = min_speed( fVelMax, p->MoverParameters->Vmax ); // ustalenie maksymalnej prędkości dla składu + fLength += p->physics->Dim.L; // dodanie długości pojazdu + fMass += p->physics->TotalMass; // dodanie masy łącznie z ładunkiem + fVelMax = min_speed( fVelMax, p->physics->Vmax ); // ustalenie maksymalnej prędkości dla składu // reset oerlikon brakes consist flag as different type was detected - if( p->MoverParameters->BrakeSubsystem != TBrakeSubSystem::ss_ESt - && p->MoverParameters->BrakeSubsystem != TBrakeSubSystem::ss_LSt ) { + if( p->physics->BrakeSubsystem != TBrakeSubSystem::ss_ESt + && p->physics->BrakeSubsystem != TBrakeSubSystem::ss_LSt ) { drivingFlags.oerlikons = false; } p = p->Neighbour(dir); // pojazd podłączony od wskazanej strony @@ -357,7 +357,7 @@ bool TController::CheckVehicles(DriverOrders user) // establish ownership and vehicle order while (p) { - if (p->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) + if (p->physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { // jeśli pojazd posiada pantograf, to przydzielamy mu maskę, którą będzie informował o jeździe bezprądowej p->iOverheadMask = pantmask; pantmask = pantmask << 1; // przesunięcie bitów, max. 32 pojazdy z pantografami w składzie @@ -369,7 +369,7 @@ bool TController::CheckVehicles(DriverOrders user) } // with the order established the virtual train manager can do their work p = frontvehicle; - ControlledEnginesCount = p->MoverParameters->Power > 1.0 ? 1 : 0; + ControlledEnginesCount = p->physics->Power > 1.0 ? 1 : 0; auto hasheaters { false }; while (p) { @@ -377,16 +377,16 @@ bool TController::CheckVehicles(DriverOrders user) if( false == p->is_connected( pVehicle, Coupling::control ) ) { // NOTE: don't set battery in controllable vehicles, let the user/ai do it explicitly // HACK: wagony muszą mieć baterię załączoną do otwarcia drzwi... - p->MoverParameters->BatterySwitch( true ); + p->physics->BatterySwitch( true ); // enable heating and converter in carriages with can be heated - if( p->MoverParameters->HeatingPower > 0 ) { - p->MoverParameters->HeatingAllow = true; - p->MoverParameters->ConverterSwitch( true, range_t::local ); + if( p->physics->HeatingPower > 0 ) { + p->physics->HeatingAllow = true; + p->physics->ConverterSwitch( true, range_t::local ); hasheaters = true; } } else { - if( p->MoverParameters->Power > 1.0 ) { + if( p->physics->Power > 1.0 ) { ++ControlledEnginesCount; } } @@ -408,9 +408,9 @@ bool TController::CheckVehicles(DriverOrders user) sync_consist_reversers(); } // potentially sync compartment lighting state for the newly connected vehicles - if( mvOccupied->CompartmentLights.start_type == start_t::manual ) { - mvOccupied->CompartmentLightsSwitchOff( mvOccupied->CompartmentLights.is_disabled ); - mvOccupied->CompartmentLightsSwitch( mvOccupied->CompartmentLights.is_enabled ); + if( occupied->CompartmentLights.start_type == start_t::manual ) { + occupied->CompartmentLightsSwitchOff( occupied->CompartmentLights.is_disabled ); + occupied->CompartmentLightsSwitch( occupied->CompartmentLights.is_enabled ); } } @@ -451,7 +451,7 @@ bool TController::CheckVehicles(DriverOrders user) } // HACK: ensure vehicle lights are active from the beginning, if it had pre-activated battery - if( mvOccupied->LightsPosNo > 0 ) { + if( occupied->LightsPosNo > 0 ) { pVehicle->SetLights(); } if( iEngineActive ) { @@ -460,7 +460,7 @@ bool TController::CheckVehicles(DriverOrders user) // custom ai action for disconnect mode: switch off lights on disconnected vehicle(s) if( is_train() && true == OrderCurrentGet().HasAll(DriverOrder::disconnect) && AIControllFlag ) { // światła manewrowe (Tb1) tylko z przodu, aby nie pozostawić odczepionego ze światłem - if (mvOccupied->DirActive >= 0) + if (occupied->DirActive >= 0) { // jak ma kierunek do przodu pVehicles[VehicleEnd::rear]->RaLightsSet(-1, 0); } @@ -511,12 +511,12 @@ void TController::Lights(int head, int rear) void TController::DirectionInitial() { // ustawienie kierunku po wczytaniu trainset (może jechać na wstecznym - mvOccupied->CabActivisationAuto(); // załączenie rozrządu (wirtualne kabiny) - if (mvOccupied->Vel > EU07_AI_NOMOVEMENT) + occupied->CabActivisationAuto(); // załączenie rozrządu (wirtualne kabiny) + if (occupied->Vel > EU07_AI_NOMOVEMENT) { // jeśli na starcie jedzie iDirection = iDirectionOrder = - mvOccupied->V > 0 ? 1 : -1; // początkowa prędkość wymusza kierunek jazdy - DirectionForward(mvOccupied->V * mvOccupied->CabActive >= 0.0); // a dalej ustawienie nawrotnika + occupied->V > 0 ? 1 : -1; // początkowa prędkość wymusza kierunek jazdy + DirectionForward(occupied->V * occupied->CabActive >= 0.0); // a dalej ustawienie nawrotnika } CheckVehicles(); // sprawdzenie świateł oraz skrajnych pojazdów do skanowania }; @@ -530,7 +530,7 @@ void TController::DirectionChange() { } } -int TController::OrderDirectionChange(int newdir, TMoverParameters *Vehicle) +int TController::OrderDirectionChange(int newdir, physics::Vehicle *Vehicle) { // zmiana kierunku jazdy, niezależnie od kabiny int testd = newdir; if (Vehicle->Vel < 0.5) @@ -568,21 +568,21 @@ void TController::DirectionForward(bool forward) if( forward ) { // do przodu w obecnej kabinie - while( mvOccupied->DirActive <= 0 - && mvOccupied->DirectionForward() ) { + while( occupied->DirActive <= 0 + && occupied->DirectionForward() ) { // force scan table update iTableDirection = 0; } } else { // do tyłu w obecnej kabinie - while( mvOccupied->DirActive >= 0 - && mvOccupied->DirectionBackward() ) { + while( occupied->DirActive >= 0 + && occupied->DirectionBackward() ) { // force scan table update iTableDirection = 0; } } - if( mvOccupied->TrainType == train_type::sn61 ) { + if( occupied->TrainType == train_type::sn61 ) { // specjalnie dla SN61 żeby nie zgasł while( mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0 && mvControlling->IncMainCtrl(1) ) { @@ -593,39 +593,39 @@ void TController::DirectionForward(bool forward) void TController::ZeroDirection() { - while( mvOccupied->DirActive > 0 && mvOccupied->DirectionBackward() ) { ; } - while( mvOccupied->DirActive < 0 && mvOccupied->DirectionForward() ) { ; } + while( occupied->DirActive > 0 && occupied->DirectionBackward() ) { ; } + while( occupied->DirActive < 0 && occupied->DirectionForward() ) { ; } } void TController::sync_consist_reversers() { - auto const currentdirection { mvOccupied->DirActive }; - auto const fastforward { is_emu() && mvOccupied->EngineType != TEngineType::ElectricInductionMotor - && mvOccupied->Imin == mvOccupied->IminHi }; + auto const currentdirection { occupied->DirActive }; + auto const fastforward { is_emu() && occupied->EngineType != TEngineType::ElectricInductionMotor + && occupied->Imin == occupied->IminHi }; // move reverser all way in the opposite direction... for( auto idx = 0; idx < 3; ++idx ) { if( currentdirection >= 0 ) { - mvOccupied->DirectionBackward(); + occupied->DirectionBackward(); } else { - mvOccupied->DirectionForward(); + occupied->DirectionForward(); } } // ...then restore original setting - while( mvOccupied->DirActive != currentdirection ) { + while( occupied->DirActive != currentdirection ) { if( false == ( currentdirection >= 0 ? - mvOccupied->DirectionForward() : - mvOccupied->DirectionBackward() ) ) { + occupied->DirectionForward() : + occupied->DirectionBackward() ) ) { // sanity check for potential endless loop break; } } // potentially restore 'fast forward' setting if( currentdirection > 0 && true == fastforward ) { - mvOccupied->DirectionForward(); + occupied->DirectionForward(); } } @@ -665,12 +665,12 @@ void TController::ControllingSet() // a driver of no vehicle has nothing to control return; } - mvOccupied = pVehicle->MoverParameters; // domyślny skrót do obiektu parametrów - BrakeSystem = mvOccupied->BrakeSystem; // domyślny sposób hamowania - mvControlling = pVehicle->FindPowered()->MoverParameters; // poszukiwanie członu sterowanego + occupied = pVehicle->physics; // domyślny skrót do obiektu parametrów + BrakeSystem = occupied->BrakeSystem; // domyślny sposób hamowania + mvControlling = pVehicle->FindPowered()->physics; // poszukiwanie członu sterowanego { auto *lookup { pVehicle->FindPantographCarrier() }; - mvPantographUnit = lookup != nullptr ? lookup->MoverParameters : mvControlling; + pantographUnit = lookup != nullptr ? lookup->physics : mvControlling; } BrakeSystem = consist_brake_system(); }; @@ -680,30 +680,30 @@ TController::determine_consist_state() { // ABu-160305 testowanie gotowości do jazdy // Ra: przeniesione z DynObj, skład użytkownika też jest testowany, żeby mu przekazać, że ma odhamować - if (mvOccupied->CabActive == 0 && mvOccupied->Power24vIsAvailable) + if (occupied->CabActive == 0 && occupied->Power24vIsAvailable) { cue_action( driver_hint::cabactivation ); } - else if (!mvOccupied->AutomaticCabActivation - && ( mvOccupied->CabActive == -mvOccupied->CabOccupied || !mvOccupied->CabMaster || !mvOccupied->Power24vIsAvailable ) ) + else if (!occupied->AutomaticCabActivation + && ( occupied->CabActive == -occupied->CabOccupied || !occupied->CabMaster || !occupied->Power24vIsAvailable ) ) { cue_action( driver_hint::cabdeactivation ); } - int index = double(BrakeAccTableSize) * (mvOccupied->Vel / mvOccupied->Vmax); + int index = double(BrakeAccTableSize) * (occupied->Vel / occupied->Vmax); index = std::min(BrakeAccTableSize, std::max(1, index)); fBrake_a0[0] = fBrake_a0[index]; fBrake_a1[0] = fBrake_a1[index]; if (is_emu() || is_dmu()) { - auto Coeff = std::clamp( mvOccupied->Vel*0.015 , 0.5 , 1.0); + auto Coeff = std::clamp( occupied->Vel*0.015 , 0.5 , 1.0); fAccThreshold = fNominalAccThreshold * Coeff - fBrake_a0[BrakeAccTableSize] * (1.0 - Coeff); } Ready = true; // wstępnie gotowy fReady = 0.0; // założenie, że odhamowany - IsConsistBraked = mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic && false == ForcePNBrake ? mvOccupied->BrakePress > 2.0 : - mvOccupied->PipePress < std::max(3.9, mvOccupied->BrakePressureActual.PipePressureVal) + 0.1; + IsConsistBraked = occupied->BrakeSystem == TBrakeSystem::ElectroPneumatic && false == ForcePNBrake ? occupied->BrakePress > 2.0 : + occupied->PipePress < std::max(3.9, occupied->BrakePressureActual.PipePressureVal) + 0.1; fAccGravity = 0.0; // przyspieszenie wynikające z pochylenia IsAnyCouplerStretched = false; IsAnyDoorOnlyOpen[ VehicleSide::right ] = IsAnyDoorOnlyOpen[ VehicleSide::left ] = false; @@ -722,7 +722,7 @@ TController::determine_consist_state() { auto chargelevel { std::numeric_limits::max() }; // the lowest pipe or auxiliary reservoir pressure of a working brake while (p) { // sprawdzenie odhamowania wszystkich połączonych pojazdów - auto *vehicle { p->MoverParameters }; + auto *vehicle { p->physics }; auto const bp { std::max( 0.0, vehicle->BrakePress - ( vehicle->SpeedCtrlUnit.Parking ? vehicle->MaxBrakePress[ 0 ] * vehicle->StopBrakeDecc : 0.0 ) ) }; momentum += vehicle->TotalMass * vehicle->V * ( p->DirectionGet() == iDirection ? 1 : -1 ); mostapplied = std::max( bp, mostapplied ); @@ -749,9 +749,9 @@ 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 && mvOccupied->Vel < EU07_AI_NOMOVEMENT && !is_emu() && !is_dmu()) && BrakeCtrlPosition == gbh_RP // jest pozycja jazdy + if( bp >= 0.4 && (AIControllFlag || Global.AITrainman && occupied->Vel < EU07_AI_NOMOVEMENT && !is_emu() && !is_dmu()) && BrakeCtrlPosition == gbh_RP // jest pozycja jazdy && false == TestFlag(vehicle->Hamulec->GetBrakeStatus(), b_dmg) // brake isn't broken - && vehicle->PipePress - mvOccupied->Handle->GetRP() > -0.1 // jeśli ciśnienie jak dla jazdy + && vehicle->PipePress - occupied->Handle->GetRP() > -0.1 // jeśli ciśnienie jak dla jazdy && vehicle->Hamulec->GetCRP() > vehicle->PipePress + 0.12 ) { // wg UIC określone sztywno na 0.04 // za dużo w zbiorniku // indywidualne luzowanko @@ -778,7 +778,7 @@ TController::determine_consist_state() { || vehicle->Couplers[VehicleEnd::rear].stretch_duration > 0.0; // check door state { - auto const switchsides{ p->DirectionGet() != (iDirection == 0 ? mvOccupied->CabOccupied : iDirection) }; + auto const switchsides{ p->DirectionGet() != (iDirection == 0 ? occupied->CabOccupied : iDirection) }; auto const &rightdoor { vehicle->Doors.instances[ ( switchsides ? VehicleSide::left : VehicleSide::right ) ] }; auto const &leftdoor { vehicle->Doors.instances[ ( switchsides ? VehicleSide::right : VehicleSide::left ) ] }; if( vehicle->Doors.close_control != control_t::autonomous ) { @@ -821,7 +821,7 @@ TController::determine_consist_state() { pVehicle->for_each( Coupling::control, [this, &islocalconverterswitchoff]( TDynamicObject * Vehicle ) { - auto const *vehicle { Vehicle->MoverParameters }; + auto const *vehicle { Vehicle->physics }; islocalconverterswitchoff |= vehicle->LineContactorsHeldByLocalConverterSwitch(); IsAnyConverterOverloadRelayOpen |= vehicle->ConvOvldFlag; IsAnyMotorOverloadRelayOpen |= vehicle->FuseFlag; @@ -840,11 +840,11 @@ TController::determine_consist_state() { fAccGravity /= fMass; { auto absaccs { fAccGravity }; // Ra 2014-03: jesli skład stoi, to działa na niego składowa styczna grawitacji - if( mvOccupied->Vel > EU07_AI_NOMOVEMENT ) { + if( occupied->Vel > EU07_AI_NOMOVEMENT ) { absaccs = 0; auto *d = pVehicles[ VehicleEnd::front ]; // pojazd na czele składu while( d ) { - absaccs += d->MoverParameters->TotalMass * d->MoverParameters->AccS * ( d->DirectionGet() == iDirection ? 1 : -1 ); + absaccs += d->physics->TotalMass * d->physics->AccS * ( d->DirectionGet() == iDirection ? 1 : -1 ); d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } absaccs *= iDirection >= 0 ? 1 : -1; @@ -873,7 +873,7 @@ TController::determine_consist_state() { // reservoirs refill as the brake releases, and waiting for the last tenths of a bar there only delays the train and // those behind it. // and only the pneumatic brake: multiple units with the electro-pneumatic one start as before - if( mvOccupied->Vel > 1.0 ) { + if( occupied->Vel > 1.0 ) { // the start is made. a shunting engine coupling wagons moves at a walking pace: a higher speed would leave its // every start the first, waiting for each cut of wagons placed cold to charge bBrakeChargeStart = false; @@ -882,7 +882,7 @@ TController::determine_consist_state() { } auto const chargeable { ( BrakeSystem == TBrakeSystem::Pneumatic ) - && ( mvOccupied->Vel < EU07_AI_NOMOVEMENT ) + && ( occupied->Vel < EU07_AI_NOMOVEMENT ) && ( chargelevel < std::numeric_limits::max() ) }; if( chargeable && ( chargelevel < brake_charge::empty_level ) ) { bBrakeChargeStart = true; @@ -896,22 +896,22 @@ TController::determine_consist_state() { AIControllFlag ? BrakeCtrlPosition > 0.0 : // a human driver's handle, which BrakeCtrlPosition doesn't follow - mvOccupied->fBrakeCtrlPos > mvOccupied->Handle->GetPos( bh_RP ) + 0.2 }; + occupied->fBrakeCtrlPos > occupied->Handle->GetPos( bh_RP ) + 0.2 }; auto const reference { - brake_charge::reference( mvOccupied->PipePress, std::min( mvOccupied->Handle->GetRP(), 5.0 ), trainbrakeapplied ) }; + brake_charge::reference( occupied->PipePress, std::min( occupied->Handle->GetRP(), 5.0 ), trainbrakeapplied ) }; // air to charge with: the engine prepared, the main reservoir above what the pipe charges to, and the driver's // brake valve feeding the pipe at the head of the train. a train still being prepared from cold can't charge, // nor one whose pipe is locked (unlocked by control_releaser()): it waits without that counting as a stall, held // by its brakes as it can't release them either auto const supplied { iEngineActive - && ( std::max( mvControlling->Compressor, mvOccupied->Compressor ) > reference ) - && ( mvOccupied->PipePress >= reference - brake_charge::margin ) }; + && ( std::max( mvControlling->Compressor, occupied->Compressor ) > reference ) + && ( occupied->PipePress >= reference - brake_charge::margin ) }; auto const wasstalled { BrakeCharge.stalled }; IsConsistCharged = brake_charge::charged( BrakeCharge, chargelevel, reference, ElapsedTime, supplied ); if( BrakeCharge.stalled && ( false == wasstalled ) ) { WriteLog( - "AI: " + mvOccupied->Name + " stopped charging its brakes at " + to_string( chargelevel, 2 ) + "AI: " + occupied->Name + " stopped charging its brakes at " + to_string( chargelevel, 2 ) + " bar of " + to_string( reference, 2 ) + ", starting all the same" ); } if( false == IsConsistCharged ) { @@ -930,7 +930,7 @@ TController::determine_consist_state() { } auto const departblocked { AIControllFlag - && mvOccupied->Vel < EU07_AI_NOMOVEMENT + && occupied->Vel < EU07_AI_NOMOVEMENT && VelDesired > 0.0 && ( false == Ready || fReady > 0.4 ) }; if( false == departblocked ) { @@ -945,7 +945,7 @@ TController::determine_consist_state() { while( true == Ready && p != nullptr ) { - auto const *vehicle { p->MoverParameters }; + auto const *vehicle { p->physics }; if( has_diesel_engine() ) { diff --git a/vehicle/ai/controls.cpp b/vehicle/ai/controls.cpp index ac39a106a..37f4c7b1b 100644 --- a/vehicle/ai/controls.cpp +++ b/vehicle/ai/controls.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -59,23 +59,23 @@ TController::increase_train_brake() { d = pVehicles[0]; // pojazd na czele składu while (d) { // przeliczanie dodatkowego potrzebnego spadku ciśnienia - if( ( d->MoverParameters->Hamulec->GetBrakeStatus() & b_dmg ) == 0 ) { - pos_corr -= ( std::min( 5.0, d->MoverParameters->Hamulec->GetCRP() ) - 5.0 ) * d->MoverParameters->TotalMass; + if( ( d->physics->Hamulec->GetBrakeStatus() & b_dmg ) == 0 ) { + pos_corr -= ( std::min( 5.0, d->physics->Hamulec->GetCRP() ) - 5.0 ) * d->physics->TotalMass; } d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } pos_corr = pos_corr / fMass * 2.5; - if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a) + if (occupied->BrakeHandle == TBrakeHandle::FV4a) { - pos_corr += mvOccupied->Handle->GetCP()*0.2; + pos_corr += occupied->Handle->GetCP()*0.2; } - if( double const deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4.0 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition - 1 - pos_corr)*fBrake_a1[0]); + if( double const deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4.0 * (/*GBH occupied->BrakeCtrlPosR*/BrakeCtrlPosition - 1 - pos_corr)*fBrake_a1[0]); deltaAcc > brake_increase_margin() ) { - if( /*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.1 ) { - auto const OK { /*mvOccupied->*/BrakeLevelAdd( BrakingInitialLevel ) }; //GBH + if( /*GBH occupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.1 ) { + auto const OK { /*occupied->*/BrakeLevelAdd( BrakingInitialLevel ) }; //GBH // HACK: stronger braking to overcome SA134 engine behaviour if( is_dmu() && VelNext == 0.0 @@ -87,27 +87,27 @@ TController::increase_train_brake() { } return OK; } - auto const OK { /*mvOccupied->*/BrakeLevelAdd( BrakingLevelIncrease ) }; //GBH + auto const OK { /*occupied->*/BrakeLevelAdd( BrakingLevelIncrease ) }; //GBH // brake harder if the acceleration is much higher than desired /*if( ( deltaAcc > 2 * fBrake_a1[ 0 ] ) - && ( mvOccupied->BrakeCtrlPosR + BrakingLevelIncrease <= 5.0 ) ) { - mvOccupied->BrakeLevelAdd( BrakingLevelIncrease ); + && ( occupied->BrakeCtrlPosR + BrakingLevelIncrease <= 5.0 ) ) { + occupied->BrakeLevelAdd( BrakingLevelIncrease ); } GBH */ if( deltaAcc > 2 * fBrake_a1[0] && BrakeCtrlPosition + BrakingLevelIncrease <= 5.0 ) { - /*mvOccupied->*/BrakeLevelAdd( BrakingLevelIncrease ); + /*occupied->*/BrakeLevelAdd( BrakingLevelIncrease ); } return OK; } if( BrakeCtrlPosition > 0.0 && AccDesired < 0.0 // only while braking is asked for, not when called for a train slipping back while starting && ( fBrakeHeldTime > ( - mvOccupied->BrakeDelayFlag > bdelay_G ? - mvOccupied->BrakeDelay[ 1 ] : - mvOccupied->BrakeDelay[ 3 ] ) + occupied->BrakeDelayFlag > bdelay_G ? + occupied->BrakeDelay[ 1 ] : + occupied->BrakeDelay[ 3 ] ) // a train falling further behind needs no full fill time to be seen not to get enough || ( ( fShortfall > 0.02 ) - && ( fBrakeHeldTime > brake_response_horizon( mvOccupied, BrakeSystem, 1.0, fBrake_a0[ 0 ] ) ) ) ) ) { + && ( fBrakeHeldTime > brake_response_horizon( occupied, BrakeSystem, 1.0, fBrake_a0[ 0 ] ) ) ) ) ) { // the table says the present position is enough, but the brake has had its full fill // time since the handle last moved and the train is still not slowing down as asked: // believe the train rather than the table @@ -125,34 +125,34 @@ bool TController::IncBrake() BrakeSystem }; switch( bs ) { case TBrakeSystem::Individual: { - if( mvOccupied->LocalBrake == TLocalBrake::ManualBrake ) { - OK = mvOccupied->IncManualBrakeLevel( 1 + static_cast( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); + if( occupied->LocalBrake == TLocalBrake::ManualBrake ) { + OK = occupied->IncManualBrakeLevel( 1 + static_cast( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); } else { - OK = mvOccupied->IncLocalBrakeLevel( std::floor( 1.5 + std::abs( AccDesired ) ) ); + OK = occupied->IncLocalBrakeLevel( std::floor( 1.5 + std::abs( AccDesired ) ) ); } break; } case TBrakeSystem::Pneumatic: { - if (bs != mvOccupied->BrakeSystem) + if (bs != occupied->BrakeSystem) { - while (mvOccupied->BrakeOpModeFlag > bom_PN) + while (occupied->BrakeOpModeFlag > bom_PN) { - mvOccupied->BrakeOpModeFlag >>= 1; + occupied->BrakeOpModeFlag >>= 1; } } // NOTE: can't perform just test whether connected vehicle == nullptr, due to virtual couplers formed with nearby vehicles auto standalone { true }; - if( mvOccupied->TrainType == train_type::et41 - || mvOccupied->TrainType == train_type::et42 ) { + if( occupied->TrainType == train_type::et41 + || occupied->TrainType == train_type::et42 ) { // NOTE: we're doing simplified checks full of presuptions here. // they'll break if someone does strange thing like turning around the second unit - if( mvOccupied->Couplers[VehicleEnd::rear].CouplingFlag & Coupling::permanent - && mvOccupied->Couplers[VehicleEnd::rear].Connected->Couplers[VehicleEnd::rear].Connected != nullptr ) { + if( occupied->Couplers[VehicleEnd::rear].CouplingFlag & Coupling::permanent + && occupied->Couplers[VehicleEnd::rear].Connected->Couplers[VehicleEnd::rear].Connected != nullptr ) { standalone = false; } - if( mvOccupied->Couplers[VehicleEnd::front].CouplingFlag & Coupling::permanent - && mvOccupied->Couplers[VehicleEnd::front].Connected->Couplers[VehicleEnd::front].Connected != nullptr ) { + if( occupied->Couplers[VehicleEnd::front].CouplingFlag & Coupling::permanent + && occupied->Couplers[VehicleEnd::front].Connected->Couplers[VehicleEnd::front].Connected != nullptr ) { standalone = false; } } @@ -161,15 +161,15 @@ bool TController::IncBrake() standalone = false; } else if( OrderCurrentGet().HasAny(DriverOrder::looseShunt) - && mvOccupied->Vel - VelDesired < fVelPlus + fVelMinus ) { + && occupied->Vel - VelDesired < fVelPlus + fVelMinus ) { // try to reduce train brake use in loose shunting mode standalone = true; } else { /* standalone = - ( ( mvOccupied->Couplers[ 0 ].CouplingFlag.Empty() ) - && ( mvOccupied->Couplers[ 1 ].CouplingFlag.Empty() ) ); + ( ( occupied->Couplers[ 0 ].CouplingFlag.Empty() ) + && ( occupied->Couplers[ 1 ].CouplingFlag.Empty() ) ); */ if( pVehicles[ VehicleEnd::front ] != pVehicles[ VehicleEnd::rear ] ) { // more detailed version, will use manual braking also for coupled sets of controlled vehicles @@ -179,10 +179,10 @@ bool TController::IncBrake() // NOTE: we could simplify this by doing only check of the rear coupler, but this can be quite tricky in itself // TODO: add easier ways to access front/rear coupler taking into account vehicle's direction standalone = - (vehicle->MoverParameters->Couplers[VehicleEnd::front].Connected == nullptr || - (vehicle->MoverParameters->Couplers[VehicleEnd::front].CouplingFlag & Coupling::control && vehicle->MoverParameters->Couplers[VehicleEnd::front].Connected->Power > 1)) && - (vehicle->MoverParameters->Couplers[VehicleEnd::rear].Connected == nullptr || - (vehicle->MoverParameters->Couplers[VehicleEnd::rear].CouplingFlag & Coupling::control && vehicle->MoverParameters->Couplers[VehicleEnd::rear].Connected->Power > 1)); + (vehicle->physics->Couplers[VehicleEnd::front].Connected == nullptr || + (vehicle->physics->Couplers[VehicleEnd::front].CouplingFlag & Coupling::control && vehicle->physics->Couplers[VehicleEnd::front].Connected->Power > 1)) && + (vehicle->physics->Couplers[VehicleEnd::rear].Connected == nullptr || + (vehicle->physics->Couplers[VehicleEnd::rear].CouplingFlag & Coupling::control && vehicle->physics->Couplers[VehicleEnd::rear].Connected->Power > 1)); vehicle = vehicle->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } } @@ -195,14 +195,14 @@ bool TController::IncBrake() OK = IncBrakeEIM(); } else { - OK = mvOccupied->IncLocalBrakeLevel( + OK = occupied->IncLocalBrakeLevel( 1 + static_cast( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); // hamowanie lokalnym bo luzem jedzie } } else { - if( /*GBH mvOccupied->BrakeCtrlPos*/ BrakeCtrlPosition + 1 == gbh_MAX ) { + if( /*GBH occupied->BrakeCtrlPos*/ BrakeCtrlPosition + 1 == gbh_MAX ) { if (AccDesired < -1.5) // hamowanie nagle - OK = /*mvOccupied->*/BrakeLevelAdd(1.0); //GBH + OK = /*occupied->*/BrakeLevelAdd(1.0); //GBH else OK = false; } @@ -210,48 +210,48 @@ bool TController::IncBrake() OK = increase_train_brake(); } } - if( /*GBH mvOccupied->BrakeCtrlPos*/ - /*GBH mvOccupied->BrakeCtrlPos*/ BrakeCtrlPosition > 0 && mvOccupied->Hamulec->Releaser() ) { - mvOccupied->BrakeReleaser(0); + if( /*GBH occupied->BrakeCtrlPos*/ + /*GBH occupied->BrakeCtrlPos*/ BrakeCtrlPosition > 0 && occupied->Hamulec->Releaser() ) { + occupied->BrakeReleaser(0); } break; } case TBrakeSystem::ElectroPneumatic: { - while( mvOccupied->BrakeOpModeFlag << 1 <= mvOccupied->BrakeOpModes ) { - mvOccupied->BrakeOpModeFlag <<= 1; + while( occupied->BrakeOpModeFlag << 1 <= occupied->BrakeOpModes ) { + occupied->BrakeOpModeFlag <<= 1; } - if( mvOccupied->EngineType == TEngineType::ElectricInductionMotor ) { - if (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57) { - if (mvOccupied->BrakeCtrlPos < mvOccupied->Handle->GetPos(bh_FB)) - OK = mvOccupied->BrakeLevelAdd(1.0); + if( occupied->EngineType == TEngineType::ElectricInductionMotor ) { + if (occupied->BrakeHandle == TBrakeHandle::MHZ_EN57) { + if (occupied->BrakeCtrlPos < occupied->Handle->GetPos(bh_FB)) + OK = occupied->BrakeLevelAdd(1.0); } else { OK = IncBrakeEIM(); } } - else if( mvOccupied->Handle->TimeEP == false ) { - auto const initialbrakeposition { mvOccupied->fBrakeCtrlPos }; - auto const AccMax { std::min( fBrake_a0[ 0 ] + 12 * fBrake_a1[ 0 ], mvOccupied->MED_amax ) }; - mvOccupied->BrakeLevelSet( + else if( occupied->Handle->TimeEP == false ) { + auto const initialbrakeposition { occupied->fBrakeCtrlPos }; + auto const AccMax { std::min( fBrake_a0[ 0 ] + 12 * fBrake_a1[ 0 ], occupied->MED_amax ) }; + occupied->BrakeLevelSet( std::lerp( - mvOccupied->Handle->GetPos( bh_EPR ), - mvOccupied->Handle->GetPos( bh_EPB ), - std::clamp( -AccDesired / AccMax * mvOccupied->AIHintLocalBrakeAccFactor, 0.0, 1.0 ) ) ); - OK = mvOccupied->fBrakeCtrlPos != initialbrakeposition; + occupied->Handle->GetPos( bh_EPR ), + occupied->Handle->GetPos( bh_EPB ), + std::clamp( -AccDesired / AccMax * occupied->AIHintLocalBrakeAccFactor, 0.0, 1.0 ) ) ); + OK = occupied->fBrakeCtrlPos != initialbrakeposition; } - else if( mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos( bh_EPB ) ) { - mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPB ) ); - if( mvOccupied->Handle->GetPos( bh_EPR ) - mvOccupied->Handle->GetPos( bh_EPN ) < 0.1 ) - mvOccupied->SwitchEPBrake( 1 ); // to nie chce działać + else if( occupied->fBrakeCtrlPos != occupied->Handle->GetPos( bh_EPB ) ) { + occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_EPB ) ); + if( occupied->Handle->GetPos( bh_EPR ) - occupied->Handle->GetPos( bh_EPN ) < 0.1 ) + occupied->SwitchEPBrake( 1 ); // to nie chce działać OK = true; } - else if( ( mvOccupied->Handle->GetPos( bh_EPR ) - mvOccupied->Handle->GetPos( bh_EPN ) < 0.1 ) - && ( mvOccupied->EpForce <= 0.0 ) - && ( mvOccupied->EPBrakeControlPowered() ) ) { + else if( ( occupied->Handle->GetPos( bh_EPR ) - occupied->Handle->GetPos( bh_EPN ) < 0.1 ) + && ( occupied->EpForce <= 0.0 ) + && ( occupied->EPBrakeControlPowered() ) ) { // the handle already in the EP brake position, but the EP brake dropped out with the control's // supply (e.g. the EP fuse off in the running brake test): switch it on again - mvOccupied->SwitchEPBrake( 1 ); - OK = ( mvOccupied->EpForce > 0.0 ); + occupied->SwitchEPBrake( 1 ); + OK = ( occupied->EpForce > 0.0 ); } else OK = false; @@ -265,44 +265,44 @@ bool TController::IncBrake() bool TController::IncBrakeEIM() { // zwiększenie hamowania bool OK = false; - switch (mvOccupied->EIMCtrlType) + switch (occupied->EIMCtrlType) { case 0: { - if( mvOccupied->MED_amax != 9.81 ) { - auto const maxpos{mvOccupied->EIMCtrlEmergency ? 0.9 : 1.0 }; + if( occupied->MED_amax != 9.81 ) { + auto const maxpos{occupied->EIMCtrlEmergency ? 0.9 : 1.0 }; auto const brakelimit{ -2.2 * AccDesired / fMedAmax - 1.0}; //additional limit when hinted is too low - auto const brakehinted{ -1.0 * mvOccupied->AIHintLocalBrakeAccFactor * AccDesired / fMedAmax }; //preffered by AI + auto const brakehinted{ -1.0 * occupied->AIHintLocalBrakeAccFactor * AccDesired / fMedAmax }; //preffered by AI auto const brakeposition{ maxpos * std::clamp(std::max(brakelimit, brakehinted), 0.0, 1.0)}; - OK = brakeposition != mvOccupied->LocalBrakePosA; - mvOccupied->LocalBrakePosA = brakeposition; + OK = brakeposition != occupied->LocalBrakePosA; + occupied->LocalBrakePosA = brakeposition; } else { - OK = mvOccupied->IncLocalBrakeLevel( 1 ); + OK = occupied->IncLocalBrakeLevel( 1 ); } break; } case 1: { - OK = mvOccupied->MainCtrlPos > 0; + OK = occupied->MainCtrlPos > 0; if( OK ) - mvOccupied->MainCtrlPos = 0; + occupied->MainCtrlPos = 0; break; } case 2: { // the braking position, above the emergency brake one where the controller has it - auto const brakepos{1 + mvOccupied->EIMCtrlEmergencyPositions()}; - OK = mvOccupied->MainCtrlPos > brakepos; + auto const brakepos{1 + occupied->EIMCtrlEmergencyPositions()}; + OK = occupied->MainCtrlPos > brakepos; if( OK ) - mvOccupied->MainCtrlPos = brakepos; + occupied->MainCtrlPos = brakepos; break; } case 3: { - if( mvOccupied->UniCtrlIntegratedLocalBrakeCtrl ) { - OK = mvOccupied->MainCtrlPos > 0; + if( occupied->UniCtrlIntegratedLocalBrakeCtrl ) { + OK = occupied->MainCtrlPos > 0; if( OK ) - mvOccupied->MainCtrlPos = 0; + occupied->MainCtrlPos = 0; } else { - OK = mvOccupied->IncLocalBrakeLevel( 1 ); + OK = occupied->IncLocalBrakeLevel( 1 ); } break; } @@ -324,7 +324,7 @@ bool TController::DecBrake() { switch( bs ) { case TBrakeSystem::Individual: { auto const positionchange { 1 + std::floor( 0.5 + std::abs( AccDesired ) ) }; - OK = mvOccupied->LocalBrake == TLocalBrake::ManualBrake ? mvOccupied->DecManualBrakeLevel(positionchange) : mvOccupied->DecLocalBrakeLevel(positionchange); + OK = occupied->LocalBrake == TLocalBrake::ManualBrake ? occupied->DecManualBrakeLevel(positionchange) : occupied->DecLocalBrakeLevel(positionchange); break; } case TBrakeSystem::Pneumatic: { @@ -347,72 +347,72 @@ bool TController::DecBrake() { break; } if( brake_charge::holds_application( - bBrakeChargeHold, IsConsistCharged, mvOccupied->Vel < EU07_AI_NOMOVEMENT, BrakeCtrlPosition ) ) { + bBrakeChargeHold, IsConsistCharged, occupied->Vel < EU07_AI_NOMOVEMENT, BrakeCtrlPosition ) ) { // the order to go came while the train still charges: released now, the wagons let go as their // reservoirs fill and the train stands on a locomotive brake that doesn't hold it. the locomotive // brake stays on with it break; } - if (deltaAcc < 0 && /*GBH mvOccupied->BrakeCtrlPosR*/ BrakeCtrlPosition > 0) { - OK = /*mvOccupied->*/ BrakeLevelAdd(-0.25); - // if ((deltaAcc < 5 * fBrake_a1[0]) && (mvOccupied->BrakeCtrlPosR >= 1.2)) - // mvOccupied->BrakeLevelAdd(-1.0); - /* if (mvOccupied->BrakeCtrlPosR < 0.74) GBH */ + if (deltaAcc < 0 && /*GBH occupied->BrakeCtrlPosR*/ BrakeCtrlPosition > 0) { + OK = /*occupied->*/ BrakeLevelAdd(-0.25); + // if ((deltaAcc < 5 * fBrake_a1[0]) && (occupied->BrakeCtrlPosR >= 1.2)) + // occupied->BrakeLevelAdd(-1.0); + /* if (occupied->BrakeCtrlPosR < 0.74) GBH */ if (BrakeCtrlPosition < 0.74) - /*mvOccupied->*/ BrakeLevelSet(gbh_RP); + /*occupied->*/ BrakeLevelSet(gbh_RP); } // standing, the locomotive brake holds the train until its brakes are charged: off before, a train // released on a gradient rolls with no air to brake with. nor through DecBrakeEIM(), which takes it off // as well (the locomotive brake of a vehicle without the integrated handle) auto const holdlocomotive { ( false == IsConsistCharged ) - && ( mvOccupied->Vel < EU07_AI_NOMOVEMENT ) }; + && ( occupied->Vel < EU07_AI_NOMOVEMENT ) }; if( ( !OK ) && ( false == holdlocomotive ) ) { - OK = mvOccupied->DecLocalBrakeLevel(2); + OK = occupied->DecLocalBrakeLevel(2); } if( ( !OK ) && ( false == holdlocomotive ) ) { OK = DecBrakeEIM(); } /* // NOTE: disabled, duplicate of AI's behaviour in UpdateSituation() - if (mvOccupied->PipePress < 3.0) + if (occupied->PipePress < 3.0) Need_BrakeRelease = true; */ break; } case TBrakeSystem::ElectroPneumatic: { - if( mvOccupied->EngineType == TEngineType::ElectricInductionMotor ) { - if( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57 ) { - if( mvOccupied->BrakeCtrlPos > mvOccupied->Handle->GetPos( bh_RP ) ) { - OK = mvOccupied->BrakeLevelAdd( -1.0 ); + if( occupied->EngineType == TEngineType::ElectricInductionMotor ) { + if( occupied->BrakeHandle == TBrakeHandle::MHZ_EN57 ) { + if( occupied->BrakeCtrlPos > occupied->Handle->GetPos( bh_RP ) ) { + OK = occupied->BrakeLevelAdd( -1.0 ); } } else { OK = DecBrakeEIM(); } } - else if( mvOccupied->Handle->TimeEP == false ) { - auto const initialbrakeposition { mvOccupied->fBrakeCtrlPos }; - auto const AccMax { std::min( fBrake_a0[ 0 ] + 12 * fBrake_a1[ 0 ], mvOccupied->MED_amax ) }; - mvOccupied->BrakeLevelSet( + else if( occupied->Handle->TimeEP == false ) { + auto const initialbrakeposition { occupied->fBrakeCtrlPos }; + auto const AccMax { std::min( fBrake_a0[ 0 ] + 12 * fBrake_a1[ 0 ], occupied->MED_amax ) }; + occupied->BrakeLevelSet( std::lerp( - mvOccupied->Handle->GetPos( bh_EPR ), - mvOccupied->Handle->GetPos( bh_EPB ), - std::clamp( -AccDesired / AccMax * mvOccupied->AIHintLocalBrakeAccFactor, 0.0, 1.0 ) ) ); - OK = mvOccupied->fBrakeCtrlPos != initialbrakeposition; + occupied->Handle->GetPos( bh_EPR ), + occupied->Handle->GetPos( bh_EPB ), + std::clamp( -AccDesired / AccMax * occupied->AIHintLocalBrakeAccFactor, 0.0, 1.0 ) ) ); + OK = occupied->fBrakeCtrlPos != initialbrakeposition; } else { OK = false; - if (mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos(bh_EPR)) { - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPR)); + if (occupied->fBrakeCtrlPos != occupied->Handle->GetPos(bh_EPR)) { + occupied->BrakeLevelSet(occupied->Handle->GetPos(bh_EPR)); OK = true; } - if (mvOccupied->Handle->GetPos(bh_EPR) - mvOccupied->Handle->GetPos(bh_EPN) < 0.1) { - OK = OK || mvOccupied->SwitchEPBrake(1); + if (occupied->Handle->GetPos(bh_EPR) - occupied->Handle->GetPos(bh_EPN) < 0.1) { + OK = OK || occupied->SwitchEPBrake(1); } } if( !OK ) { - OK = mvOccupied->DecLocalBrakeLevel( 2 ); + OK = occupied->DecLocalBrakeLevel( 2 ); } break; } @@ -425,62 +425,62 @@ bool TController::DecBrake() { void TController::LapBrake() { - if( mvOccupied->Handle->TimeEP ) { - if( mvOccupied->Handle->GetPos( bh_EPR ) - mvOccupied->Handle->GetPos( bh_EPN ) < 0.1 ) { - mvOccupied->SwitchEPBrake( 0 ); + if( occupied->Handle->TimeEP ) { + if( occupied->Handle->GetPos( bh_EPR ) - occupied->Handle->GetPos( bh_EPN ) < 0.1 ) { + occupied->SwitchEPBrake( 0 ); } else { - mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPN ) ); + occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_EPN ) ); } } } void TController::ZeroLocalBrake() { - if( mvOccupied->UniCtrlIntegratedLocalBrakeCtrl ) { + if( occupied->UniCtrlIntegratedLocalBrakeCtrl ) { while( DecBrakeEIM() ) { ; } } else { - mvOccupied->DecLocalBrakeLevel( LocalBrakePosNo ); + occupied->DecLocalBrakeLevel( LocalBrakePosNo ); } } bool TController::DecBrakeEIM() { // zmniejszenie siły hamowania bool OK = false; - switch (mvOccupied->EIMCtrlType) + switch (occupied->EIMCtrlType) { case 0: { - if( mvOccupied->MED_amax != 9.81 ) { - auto const desiredacceleration { ( mvOccupied->Vel > EU07_AI_NOMOVEMENT ? AccDesired : std::max( 0.0, AccDesired ) ) }; - auto const brakeposition { std::clamp( -1.0 * mvOccupied->AIHintLocalBrakeAccFactor * desiredacceleration / mvOccupied->MED_amax, 0.0, 1.0 ) }; - OK = brakeposition != mvOccupied->LocalBrakePosA; - mvOccupied->LocalBrakePosA = brakeposition; + if( occupied->MED_amax != 9.81 ) { + auto const desiredacceleration { ( occupied->Vel > EU07_AI_NOMOVEMENT ? AccDesired : std::max( 0.0, AccDesired ) ) }; + auto const brakeposition { std::clamp( -1.0 * occupied->AIHintLocalBrakeAccFactor * desiredacceleration / occupied->MED_amax, 0.0, 1.0 ) }; + OK = brakeposition != occupied->LocalBrakePosA; + occupied->LocalBrakePosA = brakeposition; } else { - OK = mvOccupied->DecLocalBrakeLevel( 1 ); + OK = occupied->DecLocalBrakeLevel( 1 ); } break; } case 1: { - OK = mvOccupied->MainCtrlPos < 2; + OK = occupied->MainCtrlPos < 2; if( OK ) - mvOccupied->MainCtrlPos = 2; + occupied->MainCtrlPos = 2; break; } case 2: { - auto const neutralpos{mvOccupied->MainCtrlNoPowerPos()}; - OK = mvOccupied->MainCtrlPos < neutralpos; + auto const neutralpos{occupied->MainCtrlNoPowerPos()}; + OK = occupied->MainCtrlPos < neutralpos; if( OK ) - mvOccupied->MainCtrlPos = neutralpos; + occupied->MainCtrlPos = neutralpos; break; } case 3: { - OK = mvOccupied->MainCtrlPos < mvOccupied->MainCtrlMaxDirChangePos; + OK = occupied->MainCtrlPos < occupied->MainCtrlMaxDirChangePos; if( OK ) - mvOccupied->MainCtrlPos = mvOccupied->MainCtrlMaxDirChangePos; + occupied->MainCtrlPos = occupied->MainCtrlMaxDirChangePos; break; } } @@ -490,14 +490,14 @@ bool TController::DecBrakeEIM() bool TController::IncSpeed() { // zwiększenie prędkości; zwraca false, jeśli dalej się nie da zwiększać auto OK { false }; - switch (mvOccupied->EngineType) + switch (occupied->EngineType) { case TEngineType::None: // McZapkie-041003: wagon sterowniczy if (mvControlling->MainCtrlPosNo > 0) // jeśli ma czym kręcić drivingFlags.incSpeed = true; // ustawienie flagi jazdy return false; case TEngineType::ElectricSeriesMotor: - if (mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) // jeśli pantografujący + if (pantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) // jeśli pantografujący { if (fOverhead2 >= 0.0) // a jazda bezprądowa ustawiana eventami (albo opuszczenie) return false; // to nici z ruszania @@ -512,7 +512,7 @@ bool TController::IncSpeed() // youBy polecił dodać 2012-09-08 v367 // na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag) auto const usehighoverloadrelaythreshold{mvControlling->TrainType != train_type::et42 // ET42 uses these variables for different purpose. TODO: fix this - && mvControlling->ImaxHi > mvControlling->ImaxLo && mvOccupied->Vel < (mvControlling->IsMotorOverloadRelayHighThresholdOn() ? 30.0 : 20.0) && + && mvControlling->ImaxHi > mvControlling->ImaxLo && occupied->Vel < (mvControlling->IsMotorOverloadRelayHighThresholdOn() ? 30.0 : 20.0) && iVehicles - ControlledEnginesCount > 0 // && ( std::fabs( mvControlling->Im ) > 0.85 * mvControlling->Imax ) && mvControlling->Imax * mvControlling->EngineVoltage * ControlledEnginesCount / @@ -528,17 +528,17 @@ bool TController::IncSpeed() auto const sufficientacceleration{AbsAccS >= (IsHeavyCargoTrain ? 0.03 : IsCargoTrain ? 0.06 : 0.09)}; auto const seriesmodefieldshunting{mvControlling->ScndCtrlPos > 0 && mvControlling->RList[mvControlling->MainCtrlPos].Bn == 1}; auto const parallelmodefieldshunting{mvControlling->ScndCtrlPos > 0 && mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1}; - auto const minvoltage{(mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? mvPantographUnit->EnginePowerSource.CollectorParameters.MinV : 0.0)}; - auto const maxvoltage{(mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? mvPantographUnit->EnginePowerSource.CollectorParameters.MaxV : 0.0)}; + auto const minvoltage{(pantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? pantographUnit->EnginePowerSource.CollectorParameters.MinV : 0.0)}; + auto const maxvoltage{(pantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? pantographUnit->EnginePowerSource.CollectorParameters.MaxV : 0.0)}; auto const seriesmodevoltage{std::lerp(minvoltage, maxvoltage, IsHeavyCargoTrain ? 0.35 : 0.40)}; auto const useseriesmode = mvControlling->Imax > mvControlling->ImaxLo || true == usehighoverloadrelaythreshold || fVoltage < seriesmodevoltage || (true == sufficientacceleration && true == sufficienttractionforce && - mvOccupied->Vel <= (IsCargoTrain ? 40 : 30) + (seriesmodefieldshunting ? 5 : 0) - (fAccGravity < -0.025 ? 10 : 0)); + occupied->Vel <= (IsCargoTrain ? 40 : 30) + (seriesmodefieldshunting ? 5 : 0) - (fAccGravity < -0.025 ? 10 : 0)); // when not in series mode use the first available parallel mode configuration until 50/60 km/h for passenger/cargo train // (if there's only one parallel mode configuration it'll be used regardless of current speed) auto const usefieldshunting = mvControlling->StLinFlag && mvControlling->RList[mvControlling->MainCtrlPos].R < 0.01 && false == mvControlling->IsScndCtrlLockedByMainCtrl() && (useseriesmode ? mvControlling->RList[mvControlling->MainCtrlPos].Bn == 1 : - true == sufficientacceleration && true == sufficienttractionforce && mvOccupied->Vel <= (IsCargoTrain ? 60 : 50) + (parallelmodefieldshunting ? 5 : 0) ? + true == sufficientacceleration && true == sufficienttractionforce && occupied->Vel <= (IsCargoTrain ? 60 : 50) + (parallelmodefieldshunting ? 5 : 0) ? mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1 : mvControlling->MainCtrlPos == mvControlling->MainCtrlPosNo); @@ -655,7 +655,7 @@ bool TController::IncSpeed() } break; case TEngineType::ElectricInductionMotor: - if( !IsAnyMotorOverloadRelayOpen && (Ready || drivingFlags.press || mvOccupied->ShuntMode) ) { + if( !IsAnyMotorOverloadRelayOpen && (Ready || drivingFlags.press || occupied->ShuntMode) ) { //{(BrakePress<=0.01*MaxBrakePress)} OK = IncSpeedEIM(); if (mvControlling->SpeedCtrl && mvControlling->Mains) @@ -747,7 +747,7 @@ void TController::ZeroSpeed( bool const Enforce ) { bool TController::DecSpeed(bool force) { // zmniejszenie prędkości (ale nie hamowanie) bool OK = false; // domyślnie false, aby wyszło z pętli while - switch (mvOccupied->EngineType) + switch (occupied->EngineType) { case TEngineType::None: // McZapkie-041003: wagon sterowniczy drivingFlags.incSpeed = false; // usunięcie flagi jazdy @@ -908,7 +908,7 @@ void TController::SpeedSet() { if( false == AIControllFlag ) { return; } - switch (mvOccupied->EngineType) + switch (occupied->EngineType) { case TEngineType::None: { // McZapkie-041003: wagon sterowniczy if (mvControlling->MainCtrlPosNo > 0) @@ -930,8 +930,8 @@ void TController::SpeedSet() { if( fActionTime < 0.0 ) { break; } if( false == Ready ) { break; } - if( mvOccupied->DirActive > 0 ) { - mvOccupied->DirectionForward(); //żeby EN57 jechały na drugiej nastawie + if( occupied->DirActive > 0 ) { + occupied->DirectionForward(); //żeby EN57 jechały na drugiej nastawie } if( mvControlling->MainCtrlPos > 0 @@ -1013,7 +1013,7 @@ void TController::SpeedSet() { // else // gdy nie jedzie ambitnie pod górę { // sprawdzenie, czy rozruch wysoki jest potrzebny if( ( mvControlling->Imax > mvControlling->ImaxLo ) - && ( mvOccupied->Vel >= 30.0 ) ) { // jak się rozpędził + && ( occupied->Vel >= 30.0 ) ) { // jak się rozpędził // if (fAccGravity > -0.02) // a i pochylenie mnijsze niż 2‰ mvControlling->CurrentSwitch( false ); // rozruch wysoki wyłącz } @@ -1097,7 +1097,7 @@ void TController::SpeedCntrl(double DesiredSpeed) mvControlling->IncScndCtrl(1); mvControlling->RunCommand(VehicleCommand::speedControl, DesiredSpeed, mvControlling->CabActive); } - else if (mvControlling->ScndCtrlPosNo > 1 && !mvOccupied->SpeedCtrlTypeTime) + else if (mvControlling->ScndCtrlPosNo > 1 && !occupied->SpeedCtrlTypeTime) { int DesiredPos = 1 + mvControlling->ScndCtrlPosNo * ((DesiredSpeed - 1.0) / mvControlling->Vmax); while( mvControlling->ScndCtrlPos > DesiredPos && true == mvControlling->DecScndCtrl(1) ) { ; } // all work is done in the condition loop @@ -1115,47 +1115,47 @@ 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 == mvOccupied->CabActive ) { return; } + if( false == AIControllFlag || 0 == occupied->CabActive ) { return; } //1. Check the type of Main Brake Handle if( BrakeSystem == TBrakeSystem::Pneumatic || ForcePNBrake ) { - if (mvOccupied->Handle->Time) + if (occupied->Handle->Time) { - auto const pressuredifference { mvOccupied->Handle->GetCP() - ( mvOccupied->HighPipePress - BrakeCtrlPosition * 0.25*mvOccupied->DeltaPipePress ) }; + auto const pressuredifference { occupied->Handle->GetCP() - ( occupied->HighPipePress - BrakeCtrlPosition * 0.25*occupied->DeltaPipePress ) }; if (BrakeCtrlPosition > 0 && pressuredifference > 0.05) - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_FB)); + occupied->BrakeLevelSet(occupied->Handle->GetPos(bh_FB)); else if (BrakeCtrlPosition > 0 && pressuredifference < -0.05) - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP)); + occupied->BrakeLevelSet(occupied->Handle->GetPos(bh_RP)); else if (BrakeCtrlPosition == 0) - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP)); + occupied->BrakeLevelSet(occupied->Handle->GetPos(bh_RP)); else if (BrakeCtrlPosition == -1) - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_FS)); + occupied->BrakeLevelSet(occupied->Handle->GetPos(bh_FS)); else if (BrakeCtrlPosition == -2) - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_NP)); + occupied->BrakeLevelSet(occupied->Handle->GetPos(bh_NP)); } - if( mvOccupied->BrakeHandle == TBrakeHandle::FV4a ) { - mvOccupied->BrakeLevelSet( BrakeCtrlPosition ); + if( occupied->BrakeHandle == TBrakeHandle::FV4a ) { + occupied->BrakeLevelSet( BrakeCtrlPosition ); } - if( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P - || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57 ) { + if( occupied->BrakeHandle == TBrakeHandle::MHZ_K8P + || occupied->BrakeHandle == TBrakeHandle::MHZ_EN57 ) { if( BrakeCtrlPosition == 0 ) { - mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); + occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_RP ) ); } else if( BrakeCtrlPosition == -1 ) { - mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_FS ) ); + occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_FS ) ); } else if( BrakeCtrlPosition == -2 ) { - mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_NP ) ); + occupied->BrakeLevelSet( occupied->Handle->GetPos( bh_NP ) ); } else if( BrakeCtrlPosition > 4.5 ) { - mvOccupied->BrakeLevelSet( 10 ); + occupied->BrakeLevelSet( 10 ); } else if( BrakeCtrlPosition > 3.70 ) { - mvOccupied->BrakeLevelSet( 9 ); + occupied->BrakeLevelSet( 9 ); } else { - mvOccupied->BrakeLevelSet( round( ( BrakeCtrlPosition * 0.4 - 0.1 ) / 0.15 ) ); + occupied->BrakeLevelSet( round( ( BrakeCtrlPosition * 0.4 - 0.1 ) / 0.15 ) ); } } } @@ -1163,37 +1163,37 @@ void TController::SetTimeControllers() //3. Check the type od EIMCtrlType /* - if (mvOccupied->EIMCtrlType > 0) + if (occupied->EIMCtrlType > 0) { - if (mvOccupied->EIMCtrlType == 1) //traxx + if (occupied->EIMCtrlType == 1) //traxx { - if (mvOccupied->LocalBrakePosA > 0.95) mvOccupied->MainCtrlPos = 0; + if (occupied->LocalBrakePosA > 0.95) occupied->MainCtrlPos = 0; } - else if (mvOccupied->EIMCtrlType == 2) //elf + else if (occupied->EIMCtrlType == 2) //elf { - if (mvOccupied->LocalBrakePosA > 0.95) mvOccupied->MainCtrlPos = 1; + if (occupied->LocalBrakePosA > 0.95) occupied->MainCtrlPos = 1; } } */ - if( mvOccupied->UniCtrlIntegratedLocalBrakeCtrl - && mvOccupied->LocalBrakePosA > 0.95 ) { + if( occupied->UniCtrlIntegratedLocalBrakeCtrl + && occupied->LocalBrakePosA > 0.95 ) { while( IncBrakeEIM() ) { ; } } //4. Check Speed Control System - if (mvOccupied->EngineType == TEngineType::ElectricInductionMotor && mvOccupied->ScndCtrlPosNo > 1 && mvOccupied->SpeedCtrlTypeTime) + if (occupied->EngineType == TEngineType::ElectricInductionMotor && occupied->ScndCtrlPosNo > 1 && occupied->SpeedCtrlTypeTime) { double SpeedCntrlVel = ActualProximityDist > std::max(50.0, fMaxProximityDist) ? VelDesired : min_speed(VelDesired, VelNext); SpeedCntrlVel = 10 * std::floor(SpeedCntrlVel*0.1); - if (mvOccupied->ScndCtrlPosNo == 4) + if (occupied->ScndCtrlPosNo == 4) { - if (mvOccupied->NewSpeed + 0.1 < SpeedCntrlVel) - mvOccupied->ScndCtrlPos = 3; - if (mvOccupied->NewSpeed - 0.1 > SpeedCntrlVel) - mvOccupied->ScndCtrlPos = 1; + if (occupied->NewSpeed + 0.1 < SpeedCntrlVel) + occupied->ScndCtrlPos = 3; + if (occupied->NewSpeed - 0.1 > SpeedCntrlVel) + occupied->ScndCtrlPos = 1; } } //5. Check Main Controller in Dizels @@ -1254,7 +1254,7 @@ void TController::SetTimeControllers() while( mvControlling->MainCtrlPos < DesiredPos ) { mvControlling->IncMainCtrl( 1 ); } } if (BrakeCtrlPosition < 0.1) //jesli nie hamuje - mvOccupied->BrakeLevelSet(mvControlling->UniCtrlList[mvControlling->MainCtrlPos].mode); //zeby nie bruzdzilo machanie zespolonym + occupied->BrakeLevelSet(mvControlling->UniCtrlList[mvControlling->MainCtrlPos].mode); //zeby nie bruzdzilo machanie zespolonym } else //5.2. Analog direct controller @@ -1322,7 +1322,7 @@ void TController::SetTimeControllers() } //6.2. Setting buttons for (int i = 0; i < 3; i++) { - mvOccupied->UniversalBrakeButton(i, UniversalBrakeButtons & mvOccupied->UniversalBrakeButtonFlag[i]); + occupied->UniversalBrakeButton(i, UniversalBrakeButtons & occupied->UniversalBrakeButtonFlag[i]); } }; @@ -1332,38 +1332,38 @@ void TController::CheckTimeControllers() if( false == AIControllFlag || 0 == mvControlling->CabActive ) { return; } //1. Check the type of Main Brake Handle - if( BrakeSystem == TBrakeSystem::ElectroPneumatic && mvOccupied->Handle->TimeEP && !ForcePNBrake ) + if( BrakeSystem == TBrakeSystem::ElectroPneumatic && occupied->Handle->TimeEP && !ForcePNBrake ) { - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPN)); + occupied->BrakeLevelSet(occupied->Handle->GetPos(bh_EPN)); } - if( ( BrakeSystem == TBrakeSystem::Pneumatic || ForcePNBrake ) && mvOccupied->Handle->Time ) + if( ( BrakeSystem == TBrakeSystem::Pneumatic || ForcePNBrake ) && occupied->Handle->Time ) { if (BrakeCtrlPosition > 0) - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_MB)); + occupied->BrakeLevelSet(occupied->Handle->GetPos(bh_MB)); else - mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP)); + occupied->BrakeLevelSet(occupied->Handle->GetPos(bh_RP)); } //2. Check the type of Secondary Brake Handle //3. Check the type od EIMCtrlType - if (mvOccupied->EIMCtrlType > 0) + if (occupied->EIMCtrlType > 0) { - if (mvOccupied->EIMCtrlType == 1) //traxx + if (occupied->EIMCtrlType == 1) //traxx { - if (mvOccupied->MainCtrlPos > 3) mvOccupied->MainCtrlPos = 5; - if (mvOccupied->MainCtrlPos < 3) mvOccupied->MainCtrlPos = 1; + if (occupied->MainCtrlPos > 3) occupied->MainCtrlPos = 5; + if (occupied->MainCtrlPos < 3) occupied->MainCtrlPos = 1; } - else if (mvOccupied->EIMCtrlType == 2) //elf + else if (occupied->EIMCtrlType == 2) //elf { - auto const emergencypositions{mvOccupied->EIMCtrlEmergencyPositions()}; - if (mvOccupied->eimic > 0) mvOccupied->MainCtrlPos = 3 + emergencypositions; - if (mvOccupied->eimic < 0) mvOccupied->MainCtrlPos = 2 + emergencypositions; + auto const emergencypositions{occupied->EIMCtrlEmergencyPositions()}; + if (occupied->eimic > 0) occupied->MainCtrlPos = 3 + emergencypositions; + if (occupied->eimic < 0) occupied->MainCtrlPos = 2 + emergencypositions; } } //4. Check Speed Control System - if (mvOccupied->EngineType == TEngineType::ElectricInductionMotor && mvOccupied->ScndCtrlPosNo > 1 && mvOccupied->SpeedCtrlTypeTime && mvOccupied->ScndCtrlPosNo == 4) + if (occupied->EngineType == TEngineType::ElectricInductionMotor && occupied->ScndCtrlPosNo > 1 && occupied->SpeedCtrlTypeTime && occupied->ScndCtrlPosNo == 4) { - mvOccupied->ScndCtrlPos = 2; + occupied->ScndCtrlPos = 2; } //5. Check Main Controller in Dizels @@ -1384,7 +1384,7 @@ void TController::CheckTimeControllers() while (mvControlling->MainCtrlPos > NeutralPos) mvControlling->DecMainCtrl(1); if (DizelActualPercentage <= DizelPercentage_Speed && mvControlling->MainCtrlPos < NeutralPos) while (mvControlling->MainCtrlPos < NeutralPos) mvControlling->IncMainCtrl(1); - mvOccupied->BrakeLevelSet(mvControlling->UniCtrlList[mvControlling->MainCtrlPos].mode); //zeby nie bruzdzilo machanie zespolonym + occupied->BrakeLevelSet(mvControlling->UniCtrlList[mvControlling->MainCtrlPos].mode); //zeby nie bruzdzilo machanie zespolonym } } }; diff --git a/vehicle/ai/doors.cpp b/vehicle/ai/doors.cpp index 665c6de5f..e751dc938 100644 --- a/vehicle/ai/doors.cpp +++ b/vehicle/ai/doors.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -57,12 +57,12 @@ void TController::Doors( bool const Open, int const Side ) { auto const prawe = 3 - lewe; // doorsteps as the timetable asks, before the doors open (eu07/maszyna#95) if( auto const doorstep { timetable::doorstep( m_stopflags ) }; - doorstep.has_value() && mvOccupied->Doors.step_enabled != *doorstep ) { + doorstep.has_value() && occupied->Doors.step_enabled != *doorstep ) { cue_action( *doorstep ? driver_hint::doorstepon : driver_hint::doorstepoff ); } // grant door control permission if it's not automatic // TBD: stricter requirements? - if( true == pVehicle->MoverParameters->Doors.permit_needed ) { + if( true == pVehicle->physics->Doors.permit_needed ) { if( Side & prawe ) { cue_action( driver_hint::doorrightpermiton ); } @@ -73,7 +73,7 @@ void TController::Doors( bool const Open, int const Side ) { // consist-wide remote signals to open doors doors // NOTE: mixed controls are left up to passengers to open doors by themselves, unless the timetable has // the driver open all the doors - if( true == timetable::opens_doors( *pVehicle->MoverParameters, m_stopflags ) ) { + if( true == timetable::opens_doors( *pVehicle->physics, m_stopflags ) ) { if( Side & prawe ) { cue_action( driver_hint::doorrightopen ); } @@ -92,9 +92,9 @@ void TController::Doors( bool const Open, int const Side ) { return; } - if (mvOccupied->Doors.has_warning && !drivingFlags.departureWarned) + if (occupied->Doors.has_warning && !drivingFlags.departureWarned) { - if (!mvOccupied->DepartureSignal) + if (!occupied->DepartureSignal) { // Not warned yet, not warning yet - start the warning signal. cue_action( driver_hint::departuresignalon ); // załącenie bzyczka @@ -108,8 +108,8 @@ void TController::Doors( bool const Open, int const Side ) { return; } - if( true == doors_open() && (pVehicle->MoverParameters->Doors.close_control == control_t::conductor || pVehicle->MoverParameters->Doors.close_control == control_t::driver || - pVehicle->MoverParameters->Doors.close_control == control_t::mixed) ) { + if( true == doors_open() && (pVehicle->physics->Doors.close_control == control_t::conductor || pVehicle->physics->Doors.close_control == control_t::driver || + pVehicle->physics->Doors.close_control == control_t::mixed) ) { // consist-wide remote signals to close doors cue_action(driver_hint::doorrightclose); cue_action(driver_hint::doorleftclose); @@ -124,15 +124,15 @@ void TController::Doors( bool const Open, int const Side ) { 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 ) }; + vehicle->physics->Doors.auto_velocity == -1.f + && ( vehicle->physics->Doors.close_control == control_t::passenger + || vehicle->physics->Doors.close_control == control_t::mixed ) }; if( true == ismanualdoor && ( vehicle->LoadExchangeTime() == 0.f - || vehicle->MoverParameters->Vel > EU07_AI_MOVEMENT ) ) { - vehicle->MoverParameters->OperateDoors( VehicleSide::right, false, range_t::local ); - vehicle->MoverParameters->OperateDoors( VehicleSide::left, false, range_t::local ); + || vehicle->physics->Vel > EU07_AI_MOVEMENT ) ) { + vehicle->physics->OperateDoors( VehicleSide::right, false, range_t::local ); + vehicle->physics->OperateDoors( VehicleSide::left, false, range_t::local ); } vehicle = vehicle->Next(); // pojazd podłączony z tyłu (patrząc od czoła) } @@ -179,7 +179,7 @@ TController::control_doors() { if( false == doors_open() ) { return; } // jeżeli jedzie // nie zamykać drzwi przy drganiach, bo zatrzymanie na W4 akceptuje niewielkie prędkości - if( mvOccupied->Vel > EU07_AI_MOVEMENT ) { + if( occupied->Vel > EU07_AI_MOVEMENT ) { Doors( false ); return; } @@ -202,7 +202,7 @@ TController::check_departure() { // automatyczne ruszanie po odstaniu albo spod SBL if( VelSignal == 0.0 && WaitingTime > 0.0 - && mvOccupied->RunningTrack.Velmax != 0.0 ) { + && occupied->RunningTrack.Velmax != 0.0 ) { // jeśli stoi, a upłynął czas oczekiwania i tor ma niezerową prędkość if( OrderCurrentGet() & (DriverOrder::shunt | DriverOrder::looseShunt | DriverOrder::obeyTrain | DriverOrder::bank) && drivingFlags.stopHere ) { @@ -210,7 +210,7 @@ TController::check_departure() { WaitingTime = -WaitingExpireTime; } else { - if( mvOccupied->CategoryFlag & 1 ) { // jeśli pociąg + if( occupied->CategoryFlag & 1 ) { // jeśli pociąg PrepareDirection(); // zmieni ustawiony kierunek SetVelocity( 20, 20 ); // jak się nastał, to niech jedzie 20km/h WaitingTime = 0.0; @@ -226,7 +226,7 @@ TController::check_departure() { } } } - else if( VelSignal == 0.0 && VelNext > 0.0 && mvOccupied->Vel < 1.0 && (false == iCoupler.Empty() || ( false == drivingFlags.stopHere )) ) { + else if( VelSignal == 0.0 && VelNext > 0.0 && occupied->Vel < 1.0 && (false == iCoupler.Empty() || ( false == drivingFlags.stopHere )) ) { // Ra: tu jest coś nie tak, bo bez tego warunku ruszało w manewrowym !!!! SetVelocity(VelNext, VelNext, stopSem); // omijanie SBL } @@ -274,17 +274,17 @@ void TController::GuardOpenDoor() { if (drivingFlags.guardOpenDoor) { auto *vehicle{ pVehicles[VehicleEnd::front] }; - while (vehicle != nullptr && vehicle->MoverParameters->Doors.range == 0) { + while (vehicle != nullptr && vehicle->physics->Doors.range == 0) { vehicle = vehicle->Next(); } - if (vehicle != nullptr && vehicle->MoverParameters->Doors.range > 0) { + if (vehicle != nullptr && vehicle->physics->Doors.range > 0) { auto const lewe = vehicle->DirectionGet() > 0 ? 1 : 2; auto const prawe = 3 - lewe; if (m_lastexchangeplatforms & lewe) { - vehicle->MoverParameters->OperateDoors(VehicleSide::left, true, range_t::local); + vehicle->physics->OperateDoors(VehicleSide::left, true, range_t::local); } if (m_lastexchangeplatforms & prawe) { - vehicle->MoverParameters->OperateDoors(VehicleSide::right, true, range_t::local); + vehicle->physics->OperateDoors(VehicleSide::right, true, range_t::local); } } else { diff --git a/vehicle/ai/driver.cpp b/vehicle/ai/driver.cpp index 7ad7d61d3..c78c627b2 100644 --- a/vehicle/ai/driver.cpp +++ b/vehicle/ai/driver.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -66,9 +66,9 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, pVehicles[ VehicleEnd::rear ] = nullptr; } ControllingSet(); // utworzenie połączenia do sterowanego pojazdu - if( mvOccupied != nullptr ) { - iDirectionOrder = mvOccupied->CabActive; // 1=do przodu (w kierunku sprzęgu 0) - VehicleName = mvOccupied->Name; + if( occupied != nullptr ) { + iDirectionOrder = occupied->CabActive; // 1=do przodu (w kierunku sprzęgu 0) + VehicleName = occupied->Name; if( is_car() ) { // samochody: na podst. http://www.prawko-kwartnik.info/hamowanie.html // fDriverBraking=0.0065; //mnożone przez (v^2+40*v) [km/h] daje prawie drogę hamowania [m] @@ -89,7 +89,7 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, fAccThreshold = is_emu() ? -0.55 : is_dmu() ? -0.45 : -0.2; /* // HACK: emu with induction motors need to start their braking a bit sooner than the ones with series motors - if( ( mvOccupied->TrainType == train_type::emu ) + if( ( occupied->TrainType == train_type::emu ) && ( mvControlling->EngineType == TEngineType::ElectricInductionMotor ) ) { fAccThreshold += 0.10; } @@ -108,7 +108,7 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, drivingFlags.primary = true; // aktywnie prowadzące pojazd } - if( mvOccupied != nullptr ) { + if( occupied != nullptr ) { SetDriverPsyche(); // na końcu, bo wymaga ustawienia zmiennych } TableClear(); @@ -130,7 +130,7 @@ TController::~TController() TBrakeSystem TController::consist_brake_system() const { - if( mvOccupied->BrakeSystem != TBrakeSystem::ElectroPneumatic ) { return mvOccupied->BrakeSystem; } + if( occupied->BrakeSystem != TBrakeSystem::ElectroPneumatic ) { return occupied->BrakeSystem; } auto isepcapable = true; if( pVehicles[ VehicleEnd::front ] != pVehicles[ VehicleEnd::rear ] ) { @@ -140,10 +140,10 @@ TBrakeSystem TController::consist_brake_system() const { && vehicle != nullptr ) { // NOTE: we could simplify this by doing only check of the rear coupler, but this can be quite tricky in itself // TODO: add easier ways to access front/rear coupler taking into account vehicle's direction - isepcapable = (vehicle->MoverParameters->Couplers[VehicleEnd::front].Connected == nullptr || - (vehicle->MoverParameters->Couplers[VehicleEnd::front].CouplingFlag & Coupling::control && vehicle->MoverParameters->Couplers[VehicleEnd::front].Connected->Power > -1)) && - (vehicle->MoverParameters->Couplers[VehicleEnd::rear].Connected == nullptr || - (vehicle->MoverParameters->Couplers[VehicleEnd::rear].CouplingFlag & Coupling::control && vehicle->MoverParameters->Couplers[VehicleEnd::rear].Connected->Power > -1)); + isepcapable = (vehicle->physics->Couplers[VehicleEnd::front].Connected == nullptr || + (vehicle->physics->Couplers[VehicleEnd::front].CouplingFlag & Coupling::control && vehicle->physics->Couplers[VehicleEnd::front].Connected->Power > -1)) && + (vehicle->physics->Couplers[VehicleEnd::rear].Connected == nullptr || + (vehicle->physics->Couplers[VehicleEnd::rear].CouplingFlag & Coupling::control && vehicle->physics->Couplers[VehicleEnd::rear].Connected->Power > -1)); vehicle = vehicle->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } } @@ -216,7 +216,7 @@ blackbox::ai_reference TController::ai_reference() const { ai.acceleration = static_cast( AccDesired ); ai.braking_distance = static_cast( fBrakeDist ); ai.timetable_vmax_kmh = ( TrainParams.TTVmax > 0.0 ? static_cast( TrainParams.TTVmax ) : -1.0f ); - ai.track_vmax_kmh = static_cast( mvOccupied->RunningTrack.Velmax ); + ai.track_vmax_kmh = static_cast( occupied->RunningTrack.Velmax ); return ai; } @@ -261,7 +261,7 @@ void TController::SetVelocity(double NewVel, double NewVelNext, TStopReason r) && OrderCurrentGet().HasAny(DriverOrder::shunt | DriverOrder::looseShunt | DriverOrder::obeyTrain | DriverOrder::bank | DriverOrder::connect | DriverOrder::prepareEngine) // jeśli jedzie w dowolnym trybie && drivingFlags.startHorn // jezeli trąbienie włączone && ( false == drivingFlags.startHornDone && false == drivingFlags.connect ) // jeśli nie zatrąbione i nie jest to moment podłączania składu - && mvOccupied->Vel < 1.0 // jesli stoi (na razie, bo chyba powinien też, gdy hamuje przed semaforem) + && occupied->Vel < 1.0 // jesli stoi (na razie, bo chyba powinien też, gdy hamuje przed semaforem) && ( NewVel >= 1.0 || NewVel < 0.0 ) ) { // o ile prędkość jest znacząca zatrąb po odhamowaniu drivingFlags.startHornNow = true; } @@ -277,12 +277,12 @@ double TController::BrakeAccFactor() const if( fAccThreshold != 0.0 && AccDesired < 0.0 && ( ActualProximityDist > fMinProximityDist - || mvOccupied->Vel > VelDesired + fVelPlus ) ) { - Factor += fBrakeReaction * (/*mvOccupied->BrakeCtrlPosR*/ BrakeCtrlPosition < 0.5 ? 1.5 : 1) * mvOccupied->Vel / ( std::max( 0.0, ActualProximityDist ) + 1 ) * ( ( AccDesired - AbsAccS ) / fAccThreshold ); + || occupied->Vel > VelDesired + fVelPlus ) ) { + Factor += fBrakeReaction * (/*occupied->BrakeCtrlPosR*/ BrakeCtrlPosition < 0.5 ? 1.5 : 1) * occupied->Vel / ( std::max( 0.0, ActualProximityDist ) + 1 ) * ( ( AccDesired - AbsAccS ) / fAccThreshold ); } /* - if (mvOccupied->TrainType == train_type::dmu && mvOccupied->Vel > 40 && VelNext<40) - Factor *= 1 + 0.25 * ( (1600 - VelNext * VelNext) / (mvOccupied->Vel * mvOccupied->Vel) ); + if (occupied->TrainType == train_type::dmu && occupied->Vel > 40 && VelNext<40) + Factor *= 1 + 0.25 * ( (1600 - VelNext * VelNext) / (occupied->Vel * occupied->Vel) ); */ return Factor; } @@ -331,12 +331,12 @@ TController::Update( double const Timedelta ) { // NOTE: this section moved all cars to the edge of their respective roads // it may have some use eventually for collision avoidance, // but when enabled all the time it produces silly effect - if( mvOccupied->Vel > 1.0 ) { + if( occupied->Vel > 1.0 ) { // przy prowadzeniu samochodu trzeba każdą oś odsuwać oddzielnie, inaczej kicha wychodzi - if (mvOccupied->CategoryFlag & 2) // jeśli samochód - // if (fabs(mvOccupied->OffsetTrackH)Dim.W) //Ra: szerokość drogi tu powinna być? - if (!mvOccupied->ChangeOffsetH(-0.01 * mvOccupied->Vel * dt)) // ruch w poprzek drogi - mvOccupied->ChangeOffsetH(0.01 * mvOccupied->Vel * dt); // Ra: co to miało być, to nie wiem + if (occupied->CategoryFlag & 2) // jeśli samochód + // if (fabs(occupied->OffsetTrackH)Dim.W) //Ra: szerokość drogi tu powinna być? + if (!occupied->ChangeOffsetH(-0.01 * occupied->Vel * dt)) // ruch w poprzek drogi + occupied->ChangeOffsetH(0.01 * occupied->Vel * dt); // Ra: co to miało być, to nie wiem } */ update_hints(); @@ -348,7 +348,7 @@ TController::Update( double const Timedelta ) { auto const awarenessrange { std::max( 750.0, - mvOccupied->Vel > EU07_AI_MOVEMENT ? + occupied->Vel > EU07_AI_MOVEMENT ? 400 + fBrakeDist : 30.0 * fDriverDist ) }; // 1500m dla stojących pociągów; if( is_active() ) { @@ -405,7 +405,7 @@ void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck pVehicle->DimHeadlights = false; pVehicle->HighBeamLights = false; control_lights(); // reinicjalizacja swiatel - mvOccupied->CabActivisation(true); + occupied->CabActivisation(true); iDirection = 0; // kierunek jazdy trzeba dopiero zgadnąć TableClear(); // ponowne utworzenie tabelki, bo człowiek mógł pojechać niezgodnie z sygnałami if( action() != TAction::actSleep ) { @@ -419,18 +419,18 @@ void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck else { // jeśli nic nie robi OrderNext( DriverOrder::prepareEngine ); - if( pVehicle->MoverParameters->iLights[ ( mvOccupied->CabActive < 0 ? + if( pVehicle->physics->iLights[ ( occupied->CabActive < 0 ? VehicleEnd::rear : VehicleEnd::front ) ] & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) // któreś ze świateł zapalone? { // od wersji 357 oczekujemy podania komend dla AI przez scenerię /* - if( pVehicle->MoverParameters->iLights[ mvOccupied->CabActive < 0 ? VehicleEnd::rear : VehicleEnd::front ] & light::headlight_upper ) // górne światło zapalone + if( pVehicle->physics->iLights[ occupied->CabActive < 0 ? VehicleEnd::rear : VehicleEnd::front ] & light::headlight_upper ) // górne światło zapalone OrderNext( DriverOrder::obeyTrain ); // jazda pociągowa else OrderNext( DriverOrder::shunt ); // jazda manewrowa */ - if( mvOccupied->Vel >= 1.0 ) // jeśli jedzie (dla 0.1 ma stać) + if( occupied->Vel >= 1.0 ) // jeśli jedzie (dla 0.1 ma stać) drivingFlags.stopHere = false; // to ma nie czekać na sygnał, tylko jechać else drivingFlags.stopHere = true; // a jak stoi, to niech czeka @@ -446,7 +446,7 @@ void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck auto const aiwasdriving { AIControllFlag == 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( *mvOccupied, *mvControlling ); + handover::release_ai_controls( *occupied, *mvControlling ); fWarningDuration = 0.0; remove_hint( driver_hint::hornon ); // the AI sets the lights directly, leave the selector in matching position so it doesn't revert them later @@ -532,7 +532,7 @@ void TController::RouteSwitch(int d) if( ( d != 0 ) && ( iRouteWanted != d ) ) { // nowy kierunek iRouteWanted = d; // zapamiętanie - if( mvOccupied->CategoryFlag & 2 ) { + if( occupied->CategoryFlag & 2 ) { // jeśli samochód for( std::size_t i = 0; i < sSpeedTable.size(); ++i ) { // szukanie pierwszego skrzyżowania i resetowanie kierunku na nim @@ -559,14 +559,14 @@ void TController::RouteSwitch(int d) */ std::string TController::OwnerName() const { - return pVehicle ? pVehicle->MoverParameters->Name : "none"; + return pVehicle ? pVehicle->physics->Name : "none"; }; bool TController::is_train() const { - return TestFlag( mvOccupied->CategoryFlag, 1 ); } + return TestFlag( occupied->CategoryFlag, 1 ); } bool TController::is_car() const { - return TestFlag( mvOccupied->CategoryFlag, 2 ); } + return TestFlag( occupied->CategoryFlag, 2 ); } bool TController::is_emu() const { return mvControlling->TrainType == train_type::emu; } @@ -578,7 +578,7 @@ bool TController::has_diesel_engine() const { return mvControlling->EngineType == TEngineType::DieselElectric || mvControlling->EngineType == TEngineType::DieselEngine; } double TController::DirectionalVel() const { - return mvOccupied->Vel * sign( iDirection * mvOccupied->V ); } + return occupied->Vel * sign( iDirection * occupied->V ); } std::vector DrivingFlags::ActiveNames() const { std::vector> const flags { diff --git a/vehicle/ai/engine.cpp b/vehicle/ai/engine.cpp index 7c134e4b5..80e80e6f1 100644 --- a/vehicle/ai/engine.cpp +++ b/vehicle/ai/engine.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -55,7 +55,7 @@ void TController::close_line_breaker() // consist-wide ground relay reset cue_action( driver_hint::maincircuitgroundreset ); cue_action( driver_hint::tractionnmotoroverloadreset ); - if( mvOccupied->EngineType == TEngineType::DieselEngine ) { + if( occupied->EngineType == TEngineType::DieselEngine ) { // specjalnie dla SN61 żeby nie zgasł cue_action( driver_hint::mastercontrollersetidle ); } @@ -65,10 +65,10 @@ void TController::close_line_breaker() bool TController::PrepareEngine() { // odpalanie silnika // HACK: don't immediately activate inert vehicle in case the simulation is about to replace us with human driver - if( mvOccupied->Vel < 1.0 && fActionTime < 0.0 ) { return false; } + if( occupied->Vel < 1.0 && fActionTime < 0.0 ) { return false; } LastReactionTime = 0.0; - ReactionTime = mvOccupied->Vel < 5 ? PrepareTime : EasyReactionTime; // react faster with rolling start + ReactionTime = occupied->Vel < 5 ? PrepareTime : EasyReactionTime; // react faster with rolling start cue_action( driver_hint::batteryon ); cue_action( driver_hint::cabactivation); @@ -99,24 +99,24 @@ bool TController::PrepareEngine() 3.5 ) + 0.1 }; // leeway margin - if( mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector - && mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { + if( pantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector + && pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { // if our pantograph unit isn't a pantograph-devoid fallback - if (mvPantographUnit->PantPress < sufficientpantographpressure) { + if (pantographUnit->PantPress < sufficientpantographpressure) { // załączenie małej sprężarki - if( false == mvPantographUnit->PantAutoValve ) { + if( false == pantographUnit->PantAutoValve ) { // odłączenie zbiornika głównego, bo z nim nie da rady napompować cue_action( driver_hint::pantographairsourcesetauxiliary ); } cue_action( driver_hint::pantographcompressoron ); // załączenie sprężarki pantografów - if( mvPantographUnit->PantCompFlag ) { + if( pantographUnit->PantCompFlag ) { cue_action( driver_hint::waitpantographpressuretoolow ); } } else { // jeżeli jest wystarczające ciśnienie w pantografach - if( false == mvPantographUnit->bPantKurek3 - || mvPantographUnit->PantPress <= mvPantographUnit->ScndPipePress ) { // kurek przełączony albo główna już pompuje + if( false == pantographUnit->bPantKurek3 + || pantographUnit->PantPress <= pantographUnit->ScndPipePress ) { // kurek przełączony albo główna już pompuje cue_action( driver_hint::pantographcompressoroff ); // sprężarkę pantografów można już wyłączyć } } @@ -167,43 +167,43 @@ bool TController::PrepareEngine() cue_action( driver_hint::waitpressuretoolow ); } // enable motor blowers - if( mvOccupied->MotorBlowers[ VehicleEnd::front ].speed != 0 ) { + if( occupied->MotorBlowers[ VehicleEnd::front ].speed != 0 ) { cue_action( driver_hint::frontmotorblowerson ); } - if( mvOccupied->MotorBlowers[ VehicleEnd::rear ].speed != 0 ) { + if( occupied->MotorBlowers[ VehicleEnd::rear ].speed != 0 ) { cue_action( driver_hint::rearmotorblowerson ); } } control_field_shunting(); // sync virtual brake state with the 'real' one - if( mvOccupied->BrakeHandle != TBrakeHandle::NoHandle ) { + if( occupied->BrakeHandle != TBrakeHandle::NoHandle ) { std::unordered_map const brakepositions{ - { static_cast( mvOccupied->Handle->GetPos( bh_RP ) ), gbh_RP }, - { static_cast( mvOccupied->Handle->GetPos( bh_NP ) ), gbh_NP }, - { static_cast( mvOccupied->Handle->GetPos( bh_FS ) ), gbh_FS } }; - auto const lookup{ brakepositions.find( static_cast( mvOccupied->fBrakeCtrlPos ) ) }; + { static_cast( occupied->Handle->GetPos( bh_RP ) ), gbh_RP }, + { static_cast( occupied->Handle->GetPos( bh_NP ) ), gbh_NP }, + { static_cast( occupied->Handle->GetPos( bh_FS ) ), gbh_FS } }; + auto const lookup{ brakepositions.find( static_cast( occupied->fBrakeCtrlPos ) ) }; if( lookup != brakepositions.end() ) { BrakeLevelSet( lookup->second ); // GBH } } // set up train brake - if( mvOccupied->Vel < EU07_AI_NOMOVEMENT ) { + if( occupied->Vel < EU07_AI_NOMOVEMENT ) { // standing: the locomotive brake first, then the pipe is filled secure_standing_train(); } - else if( ( mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos( bh_RP ) ) - && ( ( false == mvOccupied->Handle->Time ) - || ( mvOccupied->Handle->GetCP() < mvOccupied->HighPipePress - 0.05 ) ) ) { + else if( ( occupied->fBrakeCtrlPos != occupied->Handle->GetPos( bh_RP ) ) + && ( ( false == occupied->Handle->Time ) + || ( occupied->Handle->GetCP() < occupied->HighPipePress - 0.05 ) ) ) { cue_action( driver_hint::trainbrakerelease ); } // sync spring brake state across consist cue_action( - mvOccupied->SpringBrake.Activate ? + occupied->SpringBrake.Activate ? driver_hint::springbrakeon : driver_hint::springbrakeoff ); } isready = false == IsAnyConverterOverloadRelayOpen - && mvOccupied->DirActive != 0 + && occupied->DirActive != 0 && false == IsAnyLineBreakerOpen && ( false == IsAnyConverterPresent || true == IsAnyConverterEnabled ) && ( false == IsAnyCompressorPresent || true == IsAnyCompressorEnabled ) @@ -234,18 +234,18 @@ TController::report_power_stall( bool const Poweravailable, double const Pantogr ai_power::state state; state.collector = mvControlling->EnginePowerSource.SourceType == TPowerSource::CurrentCollector; state.power = Poweravailable; - state.standing = mvOccupied->Vel < EU07_AI_NOMOVEMENT; - if( mvPantographUnit->PantPress >= Pantographpressure ) { + state.standing = occupied->Vel < EU07_AI_NOMOVEMENT; + if( pantographUnit->PantPress >= Pantographpressure ) { state.pantographs_up = - mvPantographUnit->Pantographs[ VehicleEnd::front ].is_active - || mvPantographUnit->Pantographs[ VehicleEnd::rear ].is_active; + pantographUnit->Pantographs[ VehicleEnd::front ].is_active + || pantographUnit->Pantographs[ VehicleEnd::rear ].is_active; } // the pantographs of the vehicle carrying them hold the wire they found above them if( auto const *carrier { pVehicle->FindPantographCarrier() }; - carrier != nullptr && carrier->MoverParameters == mvPantographUnit ) { - auto const pantographcount { std::min( carrier->iAnimType[ ANIM_PANTS ], static_cast( carrier->MoverParameters->Pantographs.size() ) ) }; + carrier != nullptr && carrier->physics == pantographUnit ) { + auto const pantographcount { std::min( carrier->iAnimType[ ANIM_PANTS ], static_cast( carrier->physics->Pantographs.size() ) ) }; for( auto index { 0 }; index < pantographcount; ++index ) { - if( true == carrier->MoverParameters->Pantographs[ index ].is_active + if( true == carrier->physics->Pantographs[ index ].is_active && carrier->pants[ index ].fParamPants->hvPowerWire != nullptr ) { state.wire = true; } @@ -261,7 +261,7 @@ TController::report_power_stall( bool const Poweravailable, double const Pantogr // wyłączanie silnika (test wyłączenia, a część wykonawcza tylko jeśli steruje komputer) bool TController::ReleaseEngine() { /* - if( mvOccupied->Vel > 0.01 ) { + if( occupied->Vel > 0.01 ) { VelDesired = 0.0; AccDesired = std::min( AccDesired, -1.25 ); // hamuj solidnie if( true == AIControllFlag ) { @@ -275,7 +275,7 @@ bool TController::ReleaseEngine() { } */ // don't bother with the rest until we're standing still - if( mvOccupied->Vel > EU07_AI_NOMOVEMENT ) { return false; } + if( occupied->Vel > EU07_AI_NOMOVEMENT ) { return false; } LastReactionTime = 0.0; ReactionTime = PrepareTime; @@ -325,8 +325,8 @@ bool TController::ReleaseEngine() { // activate parking brake // TBD: do it earlier? cue_action( driver_hint::springbrakeon ); - if( mvOccupied->LocalBrake == TLocalBrake::ManualBrake - || mvOccupied->MBrake == true ) { + if( occupied->LocalBrake == TLocalBrake::ManualBrake + || occupied->MBrake == true ) { cue_action( driver_hint::manualbrakon ); } // switch off remaining power @@ -335,11 +335,11 @@ bool TController::ReleaseEngine() { } auto const OK { - mvOccupied->DirActive == 0 + occupied->DirActive == 0 // && ( false == IsAnyCompressorEnabled ) // && ( false == IsAnyConverterEnabled ) && false == mvControlling->Mains - && false == mvOccupied->Power24vIsAvailable }; + && false == occupied->Power24vIsAvailable }; if (OK) { // jeśli się zatrzymał @@ -419,16 +419,16 @@ TController::PrepareDirection() { if( iDirection == 0 ) { // jeśli nie ma ustalonego kierunku - if( mvOccupied->Vel < EU07_AI_NOMOVEMENT ) { // ustalenie kierunku, gdy stoi - iDirection = mvOccupied->CabActive; // wg wybranej kabiny + if( occupied->Vel < EU07_AI_NOMOVEMENT ) { // ustalenie kierunku, gdy stoi + iDirection = occupied->CabActive; // wg wybranej kabiny /* if( iDirection == 0 ) { // jeśli nie ma ustalonego kierunku - if( mvOccupied->Couplers[ VehicleEnd::rear ].Connected == nullptr ) { + if( occupied->Couplers[ VehicleEnd::rear ].Connected == nullptr ) { // jeśli z tyłu nie ma nic iDirection = -1; // jazda w kierunku sprzęgu 1 } - if( mvOccupied->Couplers[ VehicleEnd::front ].Connected == nullptr ) { + if( occupied->Couplers[ VehicleEnd::front ].Connected == nullptr ) { // jeśli z przodu nie ma nic iDirection = 1; // jazda w kierunku sprzęgu 0 } @@ -437,7 +437,7 @@ TController::PrepareDirection() { } else { // ustalenie kierunku, gdy jedzie - iDirection = mvOccupied->V >= 0 ? 1 : // jazda w kierunku sprzęgu 0 + iDirection = occupied->V >= 0 ? 1 : // jazda w kierunku sprzęgu 0 -1; // jazda w kierunku sprzęgu 1 } } diff --git a/vehicle/ai/force.cpp b/vehicle/ai/force.cpp index 33db87ede..0914e3af0 100644 --- a/vehicle/ai/force.cpp +++ b/vehicle/ai/force.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -74,8 +74,8 @@ TController::control_tractive_and_braking_force() { control_motor_connectors(); // if the radio-stop was issued don't waste effort trying to fight it - if( true == mvOccupied->RadioStopFlag // radio-stop - && mvOccupied->Vel > EU07_AI_NOMOVEMENT ) { // and still moving + if( true == occupied->RadioStopFlag // radio-stop + && occupied->Vel > EU07_AI_NOMOVEMENT ) { // and still moving cue_action( driver_hint::mastercontrollersetzerospeed ); // just throttle down... return; // ...and don't touch any other controls } @@ -95,7 +95,7 @@ TController::control_tractive_and_braking_force() { control_braking_force(); #if LOGVELOCITY - WriteLog("BrakePos=" + AnsiString(mvOccupied->BrakeCtrlPos) + ", MainCtrl=" + + WriteLog("BrakePos=" + AnsiString(occupied->BrakeCtrlPos) + ", MainCtrl=" + AnsiString(mvControlling->MainCtrlPos)); #endif } @@ -148,7 +148,7 @@ void TController::control_tractive_force() { auto const velocity { DirectionalVel() }; // jeśli przyspieszenie pojazdu jest mniejsze niż żądane oraz... if( AccDesired > EU07_AI_NOACCELERATION // don't add power if not asked for actual speed-up - && (AbsAccS < AccDesired /*- std::min( 0.05, 0.01 * iDriverFailCount )*/ || mvOccupied->SpeedCtrlUnit.IsActive && velocity < mvOccupied->SpeedCtrlUnit.FullPowerVelocity) && + && (AbsAccS < AccDesired /*- std::min( 0.05, 0.01 * iDriverFailCount )*/ || occupied->SpeedCtrlUnit.IsActive && velocity < occupied->SpeedCtrlUnit.FullPowerVelocity) && false == drivingFlags.press && // starting uphill against the releasing brake, the power that holds the train is enough: the brake coming off // speeds the train up, more power only drags the brake and slips the wheels. nor is a notch past that taken @@ -247,7 +247,7 @@ void TController::control_uphill_start() { fUphillTractiveForce = 0.0; for( auto const *vehicle { pVehicles[ VehicleEnd::front ] }; vehicle != nullptr; vehicle = vehicle->Next() ) { // Ft is signed in the vehicle's own frame, and turned into the direction of travel as AbsAccS is - fUphillTractiveForce += std::max( 0.0, vehicle->MoverParameters->Ft * ( vehicle->DirectionGet() == iDirection ? 1 : -1 ) * ( iDirection >= 0 ? 1 : -1 ) ); + fUphillTractiveForce += std::max( 0.0, vehicle->physics->Ft * ( vehicle->DirectionGet() == iDirection ? 1 : -1 ) * ( iDirection >= 0 ? 1 : -1 ) ); } fUphillHoldingForce = fMass * -fAccGravity; bUphillBrakeTopUp = false; @@ -256,8 +256,8 @@ void TController::control_uphill_start() { if( bUphillBrakeTopUp ) { return; } - if( ( mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) - && ( mvOccupied->LocalBrakePosA > 0.0 ) ) { + if( ( occupied->LocalBrake != TLocalBrake::ManualBrake ) + && ( occupied->LocalBrakePosA > 0.0 ) ) { cue_action( driver_hint::independentbrakerelease ); } if( ( velocity > 1.0 ) @@ -287,8 +287,8 @@ bool TController::uphill_brake_top_up() { auto trainbrakeforce { 0.0 }; auto haswagons { false }; for( auto const *vehicle { pVehicles[ VehicleEnd::front ] }; vehicle != nullptr; vehicle = vehicle->Next() ) { - if( vehicle->MoverParameters->Power < 0.01 ) { - trainbrakeforce += vehicle->MoverParameters->Fb; + if( vehicle->physics->Power < 0.01 ) { + trainbrakeforce += vehicle->physics->Fb; haswagons = true; } } @@ -297,7 +297,7 @@ bool TController::uphill_brake_top_up() { } auto const action { uphill_start::brake_top_up( UphillTopUp, trainbrakeforce, fUphillHoldingForce, BrakeCtrlPosition, fBrakeHeldTime, - mvOccupied->BrakeDelay[ mvOccupied->BrakeDelayFlag > bdelay_G ? 1 : 3 ] ) }; + occupied->BrakeDelay[ occupied->BrakeDelayFlag > bdelay_G ? 1 : 3 ] ) }; if( action == uphill_start::top_up_action::none ) { return false; } @@ -334,7 +334,7 @@ void TController::secure_standing_train() { if( false == bHasRun ) { bBrakeChargeStart = true; } - if( mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) { + if( occupied->LocalBrake != TLocalBrake::ManualBrake ) { cue_action( driver_hint::independentbrakeapply ); } if( false == brake_charge::locomotive_brake_holds( locomotive_brake_force(), fMass * fAccGravity ) ) { @@ -356,13 +356,13 @@ void TController::secure_standing_train() { // no other, not on a second section or a locomotive in multiple control either, let alone one hauled dead double TController::locomotive_brake_force() const { - if( ( mvOccupied->LocalBrake == TLocalBrake::ManualBrake ) - || ( mvOccupied->MaxBrakePress[ 0 ] <= 0.0 ) ) { + if( ( occupied->LocalBrake == TLocalBrake::ManualBrake ) + || ( occupied->MaxBrakePress[ 0 ] <= 0.0 ) ) { return 0.0; } return brake_charge::locomotive_brake_force( - mvOccupied->BrakeForceP( mvOccupied->MaxBrakePress[ 0 ], 0.0 ), - mvOccupied->TotalMassxg ); + occupied->BrakeForceP( occupied->MaxBrakePress[ 0 ], 0.0 ), + occupied->TotalMassxg ); } void TController::increase_tractive_force() { @@ -370,7 +370,7 @@ void TController::increase_tractive_force() { if( fActionTime < 0.0 ) { return; } // gdy jest nakaz poczekać z jazdą, to nie ruszać if( IsAnyCouplerStretched ) { return; } // train is already stretched past its limits, don't pull even harder - if( mvOccupied->SpringBrake.Activate ) { + if( occupied->SpringBrake.Activate ) { cue_action( driver_hint::springbrakeoff ); } if( VelDesired > 0.0 // to prevent door shuffle on stop @@ -380,7 +380,7 @@ void TController::increase_tractive_force() { // Doors() call can potentially adjust fActionTime if( fActionTime < 0.0 ) { return; } } - if( true == mvOccupied->DepartureSignal ) { + if( true == occupied->DepartureSignal ) { cue_action( driver_hint::departuresignaloff ); } @@ -427,7 +427,7 @@ TController::uphill_brake_committed( double const Velocity ) const { ( BrakeSystem == TBrakeSystem::Pneumatic ) && ( BrakeCtrlPosition > 0.0 ) && ( fAccGravity < EU07_AI_UPHILLGRAVITY ) - && ( Velocity / 3.6 / -fAccGravity < brake_response_horizon( mvOccupied, BrakeSystem, -1.0, fBrake_a0[ 0 ] ) ) ); + && ( Velocity / 3.6 / -fAccGravity < brake_response_horizon( occupied, BrakeSystem, -1.0, fBrake_a0[ 0 ] ) ) ); } void TController::control_braking_force() { @@ -474,7 +474,7 @@ void TController::control_braking_force() { fAccGravity < 0.025 ? // HACK: when going downhill be more responsive to desired deceleration fAccThreshold : std::max( -0.2, fAccThreshold ) ) }; - auto const AccMax{ std::min(fBrake_a0[0] + 12 * fBrake_a1[0], mvOccupied->MED_amax) }; + auto const AccMax{ std::min(fBrake_a0[0] + 12 * fBrake_a1[0], occupied->MED_amax) }; auto const accmargin = AccMax > 1.1 * AccDesired && fAccGravity < 0.025 ? 0.05 : 0.0; if( ( AccDesired < accthreshold // jeśli hamować - u góry ustawia się hamowanie na fAccThreshold @@ -511,14 +511,14 @@ void TController::control_braking_force() { // TODO: check whether brake delay variable still has any purpose cue_action(driver_hint::brakingforceincrease, // Ra: ten czas należy zmniejszyć, jeśli czas dojazdu do zatrzymania jest mniejszy - (3.0 + 0.5 * ((mvOccupied->BrakeDelayFlag > bdelay_G ? mvOccupied->BrakeDelay[1] : mvOccupied->BrakeDelay[3]) - 3.0)) * 0.5); // Ra: tymczasowo, bo przeżyna S1 + (3.0 + 0.5 * ((occupied->BrakeDelayFlag > bdelay_G ? occupied->BrakeDelay[1] : occupied->BrakeDelay[3]) - 3.0)) * 0.5); // Ra: tymczasowo, bo przeżyna S1 } else if( ( BrakeSystem == TBrakeSystem::Pneumatic ) && ( AccDesired < 0.0 ) && ( BrakeCtrlPosition > 0.0 ) && ( fShortfall > 0.02 ) && ( iShortfallGrowth >= 2 ) - && ( fBrakeHeldTime > brake_response_horizon( mvOccupied, BrakeSystem, 1.0, fBrake_a0[ 0 ] ) ) ) { + && ( fBrakeHeldTime > brake_response_horizon( occupied, BrakeSystem, 1.0, fBrake_a0[ 0 ] ) ) ) { // the train has been falling further behind the demand for a while at a handle left alone for longer than // the brake takes to respond: a small step now, while it still is small, rather than the deep one the // margin above would allow only once the train is far behind @@ -533,20 +533,20 @@ void TController::control_braking_force() { && ( AIControllFlag || ( false == brake_charge::release_waits( IsConsistCharged, - mvOccupied->Vel < EU07_AI_NOMOVEMENT, - mvOccupied->fBrakeCtrlPos > mvOccupied->Handle->GetPos( bh_RP ) + 0.2 ) ) ) ) { // the human driver's handle + occupied->Vel < EU07_AI_NOMOVEMENT, + occupied->fBrakeCtrlPos > occupied->Handle->GetPos( bh_RP ) + 0.2 ) ) ) ) { // the human driver's handle // jak hamuje, to nie tykaj kranu za często // yB: luzuje hamulec dopiero przy różnicy opóźnień rzędu 0.2 // przy odłączaniu nie zwalniamy tu hamulca // sanity check to prevent unintended brake release on sharp slopes // TODO: check whether brake delay variable still has any purpose cue_action(driver_hint::brakingforcedecrease, - (mvOccupied->BrakeDelayFlag > bdelay_G ? mvOccupied->BrakeDelay[0] : mvOccupied->BrakeDelay[2]) / 3.0 * 0.5); // Ra: tymczasowo, bo przeżyna S1 + (occupied->BrakeDelayFlag > bdelay_G ? occupied->BrakeDelay[0] : occupied->BrakeDelay[2]) / 3.0 * 0.5); // Ra: tymczasowo, bo przeżyna S1 } // uphill, the locomotive brake acts at once while the train brake of a long train takes many seconds to apply: // put it on as the train comes to a stand, and at once if the train has started to roll back - if( ( mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) - && ( mvOccupied->LocalBrakePosA < 1.0 ) + if( ( occupied->LocalBrake != TLocalBrake::ManualBrake ) + && ( occupied->LocalBrakePosA < 1.0 ) && ( ( uphill_stop_hold() && ( std::abs( velocity ) < 3.0 ) // a train that has slowed down short of where it is to stop and is to pull up further does not get it && ( VelDesired <= std::abs( velocity ) + 0.5 ) @@ -556,13 +556,13 @@ void TController::control_braking_force() { } // stop-gap measure to ensure cars actually brake to stop even when above calculactions go awry // instead of releasing the brakes and creeping into obstacle at 1-2 km/h - if( is_car() && VelDesired == 0.0 && velocity > VelDesired && ActualProximityDist <= fMinProximityDist && mvOccupied->LocalBrakePosA < 0.01 ) { + if( is_car() && VelDesired == 0.0 && velocity > VelDesired && ActualProximityDist <= fMinProximityDist && occupied->LocalBrakePosA < 0.01 ) { cue_action(driver_hint::brakingforceincrease); } } // odhamowywanie składu po zatrzymaniu i zabezpieczanie lokomotywy - if( mvOccupied->Vel < EU07_AI_NOMOVEMENT + if( occupied->Vel < EU07_AI_NOMOVEMENT && ( VelDesired == 0.0 || AccDesired <= EU07_AI_NOACCELERATION ) ) { @@ -579,9 +579,9 @@ void TController::control_braking_force() { void TController::apply_independent_brake_only() { - if( mvOccupied->LocalBrake != TLocalBrake::ManualBrake ) { - if( false == mvOccupied->ShuntMode // no need for independent brake if autobrake is active - && is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2) ) { + if( occupied->LocalBrake != TLocalBrake::ManualBrake ) { + if( false == occupied->ShuntMode // no need for independent brake if autobrake is active + && is_equal(occupied->fBrakeCtrlPos, occupied->Handle->GetPos(bh_RP), 0.2) ) { cue_action( driver_hint::independentbrakeapply ); } else { @@ -592,27 +592,27 @@ void TController::apply_independent_brake_only() { void TController::control_releaser() { // HACK: don't immediately touch releaser in inert vehicle, in case the simulation is about to replace us with human driver - if( mvOccupied->Vel < 1.0 && fActionTime < 0.0 ) { return; } + if( occupied->Vel < 1.0 && fActionTime < 0.0 ) { return; } // TODO: combine all releaser handling in single decision tree instead of having bits all over the place // TODO: replace handle and system conditions with flag indicating releaser presence if( BrakeSystem != TBrakeSystem::Pneumatic ) { return; } auto const hasreleaser { false == (is_dmu() || is_emu()) // TODO: a more refined test than rejecting these types wholesale - && ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a - || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P - || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K5P - || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P - || mvOccupied->BrakeHandle == TBrakeHandle::M394 ) }; + && ( occupied->BrakeHandle == TBrakeHandle::FV4a + || occupied->BrakeHandle == TBrakeHandle::MHZ_6P + || occupied->BrakeHandle == TBrakeHandle::MHZ_K5P + || occupied->BrakeHandle == TBrakeHandle::MHZ_K8P + || occupied->BrakeHandle == TBrakeHandle::M394 ) }; if( false == hasreleaser ) { return; } brake_releaser::conditions state; state.acceleration_desired = AccDesired; - state.pipe_pressure = mvOccupied->PipePress; - state.cylinder_pressure = mvOccupied->BrakePress; - state.control_pressure = mvOccupied->Hamulec->GetCRP(); - state.velocity = mvOccupied->Vel; + state.pipe_pressure = occupied->PipePress; + state.cylinder_pressure = occupied->BrakePress; + state.control_pressure = occupied->Hamulec->GetCRP(); + state.velocity = occupied->Vel; state.uphill_start = bUphillStart; state.pressing = drivingFlags.press; // stage 3 of uncoupling (UpdateDisconnect), from the direction change until the coupler lets go @@ -624,29 +624,29 @@ void TController::control_releaser() { // a handle which has to be moved to unlock is left where it holds the train with the train brake state.charging_standing = bBrakeChargeStart - && ( mvOccupied->Vel < EU07_AI_NOMOVEMENT ) - && ( ( mvOccupied->HandleUnlock == -3 ) || ( BrakeCtrlPosition <= 0.0 ) ); + && ( occupied->Vel < EU07_AI_NOMOVEMENT ) + && ( ( occupied->HandleUnlock == -3 ) || ( BrakeCtrlPosition <= 0.0 ) ); auto const wanted { brake_releaser::decide( state ) }; auto const actuate { wanted.actuate }; auto isbrakehandleinrightposition { true }; // some vehicles require brake handle to be moved to specific position to fill up the brake pipe if( wanted.fill_pipe - && mvOccupied->HandleUnlock != -3 ) { + && occupied->HandleUnlock != -3 ) { cue_action( driver_hint::trainbrakesetpipeunlock ); - isbrakehandleinrightposition = ( BrakeCtrlPosition == mvOccupied->HandleUnlock ); + isbrakehandleinrightposition = ( BrakeCtrlPosition == occupied->HandleUnlock ); } if( actuate ) { // some vehicles may require master controller in neutral position cue_action( driver_hint::mastercontrollersetzerospeed ); - if( false == mvOccupied->Hamulec->Releaser() + if( false == occupied->Hamulec->Releaser() && isbrakehandleinrightposition ) { cue_action( driver_hint::releaseron ); } } else { - if( true == mvOccupied->Hamulec->Releaser() ) { + if( true == occupied->Hamulec->Releaser() ) { cue_action( driver_hint::releaseroff ); } } @@ -657,30 +657,30 @@ void TController::control_main_pipe() { // unlocking main pipe if( ( AccDesired > -0.03 // standing to charge before the first start, as in control_releaser() - || ( bBrakeChargeStart && ( mvOccupied->Vel < EU07_AI_NOMOVEMENT ) ) ) - && true == mvOccupied->LockPipe ) { + || ( bBrakeChargeStart && ( occupied->Vel < EU07_AI_NOMOVEMENT ) ) ) + && true == occupied->LockPipe ) { UniversalBrakeButtons |= TUniversalBrake::ub_UnlockPipe; } - else if (false == mvOccupied->LockPipe ) { + else if (false == occupied->LockPipe ) { UniversalBrakeButtons &= ~TUniversalBrake::ub_UnlockPipe; } // napełnianie uderzeniowe if( BrakeSystem != TBrakeSystem::Pneumatic ) { return; } - if( mvOccupied->BrakeHandle == TBrakeHandle::FV4a - || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P - || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K5P - || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P - || mvOccupied->BrakeHandle == TBrakeHandle::M394 ) { + if( occupied->BrakeHandle == TBrakeHandle::FV4a + || occupied->BrakeHandle == TBrakeHandle::MHZ_6P + || occupied->BrakeHandle == TBrakeHandle::MHZ_K5P + || occupied->BrakeHandle == TBrakeHandle::MHZ_K8P + || occupied->BrakeHandle == TBrakeHandle::M394 ) { auto const departblocked { is_departure_blocked( DepartBlockedFSDelay ) }; - if( (drivingFlags.oerlikons || true == IsCargoTrain || departblocked) && BrakeCtrlPosition == gbh_RP && AbsAccS < 0.03 && AccDesired > -0.03 && VelDesired - mvOccupied->Vel > 2.0 && fReady > 0.35 && - ( mvOccupied->EqvtPipePress < 4.5 || departblocked ) // don't charge with a risk of overcharging the main pipe - && mvOccupied->Compressor >= 7.5 // don't charge without sufficient pressure in the tank + if( (drivingFlags.oerlikons || true == IsCargoTrain || departblocked) && BrakeCtrlPosition == gbh_RP && AbsAccS < 0.03 && AccDesired > -0.03 && VelDesired - occupied->Vel > 2.0 && fReady > 0.35 && + ( occupied->EqvtPipePress < 4.5 || departblocked ) // don't charge with a risk of overcharging the main pipe + && occupied->Compressor >= 7.5 // don't charge without sufficient pressure in the tank && BrakeChargingCooldown >= 0.0 // don't charge while cooldown is active && (ActualProximityDist > 100.0 // don't charge if we're about to be braking soon - || min_speed(mvOccupied->Vel, VelNext) >= mvOccupied->Vel) ) { + || min_speed(occupied->Vel, VelNext) >= occupied->Vel) ) { BrakeLevelSet(gbh_FS); // don't charge the brakes too often, or we risk overcharging @@ -689,12 +689,12 @@ void TController::control_main_pipe() { update_brake_charging(); - if( ( mvOccupied->Compressor < 5.0 + if( ( occupied->Compressor < 5.0 || ( BrakeCtrlPosition < gbh_RP - && ( mvOccupied->EqvtPipePress > (fReady < 0.25 ? 5.1 : 5.2) || is_brake_charging_done() ) ) ) + && ( occupied->EqvtPipePress > (fReady < 0.25 ? 5.1 : 5.2) || is_brake_charging_done() ) ) ) // the light application a charging train stands on stays, as in DecBrake() && ( false == brake_charge::holds_application( - bBrakeChargeHold, IsConsistCharged, mvOccupied->Vel < EU07_AI_NOMOVEMENT, BrakeCtrlPosition ) ) ) { + bBrakeChargeHold, IsConsistCharged, occupied->Vel < EU07_AI_NOMOVEMENT, BrakeCtrlPosition ) ) ) { cue_action( driver_hint::trainbrakerelease ); } } @@ -712,8 +712,8 @@ void TController::update_brake_charging() { } for( auto const *vehicle { pVehicles[ VehicleEnd::front ] }; vehicle != nullptr; vehicle = vehicle->Next() ) { auto const isovercharged { - vehicle->MoverParameters != mvOccupied - && vehicle->MoverParameters->PipePress > FSOverchargePipePress }; + vehicle->physics != occupied + && vehicle->physics->PipePress > FSOverchargePipePress }; if( isovercharged ) { BrakeChargingPipeOverchargeStart.try_emplace( vehicle, ElapsedTime ); } @@ -733,7 +733,7 @@ double TController::consist_max_crp() const { auto result { 0.0 }; for( auto const *vehicle { pVehicles[ VehicleEnd::front ] }; vehicle != nullptr; vehicle = vehicle->Next() ) { - result = std::max( result, vehicle->MoverParameters->Hamulec->GetCRP() ); + result = std::max( result, vehicle->physics->Hamulec->GetCRP() ); } return result; } @@ -744,7 +744,7 @@ bool TController::is_brake_charging_done() const { return false; } return ElapsedTime - BrakeChargingStart > FSMaxTime - || consist_max_crp() > mvOccupied->HighPipePress + FSOverchargeCRP + || consist_max_crp() > occupied->HighPipePress + FSOverchargeCRP || std::ranges::any_of( BrakeChargingPipeOverchargeStart, [this]( auto const &Vehicle ) { return ElapsedTime - Vehicle.second > FSOverchargeTime; } ); @@ -753,7 +753,7 @@ bool TController::is_brake_charging_done() const { void TController::UpdateBrakingHelper() { - if (HelperState > 0 && -AccDesired < fBrake_a0[0] + 2 * fBrake_a1[0] && mvOccupied->Vel > EU07_AI_NOMOVEMENT) { + if (HelperState > 0 && -AccDesired < fBrake_a0[0] + 2 * fBrake_a1[0] && occupied->Vel > EU07_AI_NOMOVEMENT) { HelperState = 0; } diff --git a/vehicle/ai/internal.h b/vehicle/ai/internal.h index 379d139c3..f155cf57d 100644 --- a/vehicle/ai/internal.h +++ b/vehicle/ai/internal.h @@ -17,7 +17,7 @@ http://mozilla.org/MPL/2.0/. #pragma once #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -108,7 +108,7 @@ const double EasyReactionTime = 0.5; //[s] przebłyski świadomości dla zwykłe const double PrepareTime = 2.0; //[s] przebłyski świadomości przy odpalaniu -double brake_response_horizon( TMoverParameters const *Vehicle, TBrakeSystem const Brakesystem, double const Acceleration, double const Brakea0 ); +double brake_response_horizon( physics::Vehicle const *Vehicle, TBrakeSystem const Brakesystem, double const Acceleration, double const Brakea0 ); double uphill_stopping_distance( double const Velocity, double const Gravity ); diff --git a/vehicle/ai/obstacles.cpp b/vehicle/ai/obstacles.cpp index 4ddd60df1..28d8cf263 100644 --- a/vehicle/ai/obstacles.cpp +++ b/vehicle/ai/obstacles.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -153,7 +153,7 @@ void TController::SetProximityVelocity( double dist, double vel, glm::dvec3 cons dist-=10.0; }; if (dist<0.0) dist=0.0; - if ((vel<0)?true:dist>0.1*(MoverParameters->Vel*MoverParameters->Vel-vel*vel)+50) + if ((vel<0)?true:dist>0.1*(physics->Vel*physics->Vel-vel*vel)+50) {//jeśli jest dalej od umownej drogi hamowania */ PutCommand( "SetProximityVelocity", dist, vel, pos ); @@ -249,7 +249,7 @@ TCommandType TController::BackwardScan( double const Range ) // ruszać stop trzeba powtarzać, bo inaczej zatrąbi i pojedzie sam #if LOGBACKSCAN if (scandist > fMinProximityDist && - mvOccupied->Vel > EU07_AI_NOMOVEMENT && false == OrderCurrentGet().HasAny(DriverOrder::shunt | DriverOrder::looseShunt)) + occupied->Vel > EU07_AI_NOMOVEMENT && false == OrderCurrentGet().HasAny(DriverOrder::shunt | DriverOrder::looseShunt)) { WriteLog(edir); } @@ -268,12 +268,12 @@ TCommandType TController::BackwardScan( double const Range ) // jeśli powyżej było SetVelocity 0 0, to dociągamy pod S1 /* if ((scandist > fMinProximityDist) && - ((mvOccupied->Vel > EU07_AI_NOMOVEMENT) || (scanvel == 0.0))) + ((occupied->Vel > EU07_AI_NOMOVEMENT) || (scanvel == 0.0))) { // jeśli tarcza jest daleko, to: //- jesli pojazd jedzie, to informujemy o zmianie prędkości //- jeśli stoi, to z własnej inicjatywy może podjechać pod zamkniętą tarczę - if (mvOccupied->Vel > EU07_AI_NOMOVEMENT) // tylko jeśli jedzie + if (occupied->Vel > EU07_AI_NOMOVEMENT) // tylko jeśli jedzie { // Mechanik->PutCommand("SetProximityVelocity",scandist,scanvel,sl); #if LOGBACKSCAN // WriteLog(edir+"SetProximityVelocity "+AnsiString(scandist)+" @@ -292,7 +292,7 @@ TCommandType TController::BackwardScan( double const Range ) { // ustawiamy prędkość tylko wtedy, gdy ma ruszyć, albo stanąć albo ma stać pod // tarczą stop trzeba powtarzać, bo inaczej zatrąbi i pojedzie sam if - // ((MoverParameters->Vel==0.0)||(scanvel==0.0)) //jeśli jedzie lub ma stanąć/stać + // ((physics->Vel==0.0)||(scanvel==0.0)) //jeśli jedzie lub ma stanąć/stać { // nie dostanie komendy jeśli jedzie i ma jechać // PutCommand("ShuntVelocity",scanvel,e->Params[9].asMemCell->Value2(),&sl,stopSem); #if LOGBACKSCAN @@ -373,12 +373,12 @@ TController::scan_obstacles( double const Range ) { // HACK: vehicle order in the consist is based on intended travel direction // if our actual travel direction doesn't match that, we should be scanning from the other end of the consist // we cast to int to avoid getting confused by microstutters - auto *frontvehicle { pVehicles[ ( static_cast( mvOccupied->V ) * iDirection >= 0 ? VehicleEnd::front : VehicleEnd::rear ) ] }; + auto *frontvehicle { pVehicles[ ( static_cast( occupied->V ) * iDirection >= 0 ? VehicleEnd::front : VehicleEnd::rear ) ] }; int routescandirection; // for moving vehicle determine heading from velocity; for standing fall back on the set direction - if( std::abs(frontvehicle->MoverParameters->V) > 0.5 ? // ignore potential micro-stutters in oposite direction during "almost stop" - frontvehicle->MoverParameters->V > 0.0 : + if( std::abs(frontvehicle->physics->V) > 0.5 ? // ignore potential micro-stutters in oposite direction during "almost stop" + frontvehicle->physics->V > 0.0 : pVehicle->DirectionGet() == frontvehicle->DirectionGet() ? iDirection >= 0 : iDirection <= 0 ) { // towards coupler 0 routescandirection = NumberOf( VehicleEnd::front ); @@ -388,7 +388,7 @@ TController::scan_obstacles( double const Range ) { routescandirection = NumberOf( VehicleEnd::rear ); } /* - if( pVehicle->MoverParameters->CabOccupied < 0 ) { + if( pVehicle->physics->CabOccupied < 0 ) { // flip the scan direction in the rear cab routescandirection ^= routescandirection; } @@ -405,7 +405,7 @@ TController::scan_obstacles( double const Range ) { if( Obstacle.distance < ( is_car() ? 50 : 100 ) ) { // at short distances (re)calculate range between couplers directly - Obstacle.distance = TMoverParameters::CouplerDist( frontvehicle->MoverParameters, Obstacle.vehicle->MoverParameters ); + Obstacle.distance = physics::Vehicle::CouplerDist( frontvehicle->physics, Obstacle.vehicle->physics ); } } } @@ -446,7 +446,7 @@ TController::check_route_ahead( double const Range ) { break; } case TCommandType::cm_Command: { // komenda z komórki - if( OrderCurrentGet().Without(DriverOrder::shunt | DriverOrder::looseShunt | DriverOrder::obeyTrain | DriverOrder::bank).Empty() && mvOccupied->Vel < 0.1 ) { + if( OrderCurrentGet().Without(DriverOrder::shunt | DriverOrder::looseShunt | DriverOrder::obeyTrain | DriverOrder::bank).Empty() && occupied->Vel < 0.1 ) { // jedzie w dowolnym trybie albo Wait_for_orders // dopiero jak stanie /* diff --git a/vehicle/ai/orders.cpp b/vehicle/ai/orders.cpp index ce905afec..81980c17f 100644 --- a/vehicle/ai/orders.cpp +++ b/vehicle/ai/orders.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -155,7 +155,7 @@ void TController::OrdersClear() void TController::RecognizeCommand() { // odczytuje i wykonuje komendę przekazaną lokomotywie - TCommand *c = &mvOccupied->CommandIn; + TCommand *c = &occupied->CommandIn; PutCommand(c->Text, c->Value1, c->Value2, c->Location, stopComm); c->Command = VehicleCommand::none; c->Argument.clear(); @@ -167,7 +167,7 @@ void TController::PutCommand(std::string NewCommand, double NewValue1, double Ne // zamiana na współrzędne scenerii glm::dvec3 sl { -NewLocation.X, NewLocation.Z, NewLocation.Y }; if (!PutCommand(NewCommand, NewValue1, NewValue2, &sl, reason)) - mvOccupied->PutCommand(NewCommand, NewValue1, NewValue2, NewLocation); + occupied->PutCommand(NewCommand, NewValue1, NewValue2, NewLocation); } bool TController::PutCommand( std::string NewCommand, double NewValue1, double NewValue2, glm::dvec3 const *NewLocation, TStopReason reason ) @@ -176,8 +176,8 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N { // SHP wyzwalane jest przez człon z obsadą, ale obsługiwane przez silnikowy // nie jest to najlepiej zrobione, ale bez symulacji obwodów lepiej nie będzie // Ra 2014-04: jednak przeniosłem do rozrządczego - mvOccupied->PutCommand(NewCommand, NewValue1, NewValue2, mvOccupied->Loc); - mvOccupied->RunInternalCommand(); // rozpoznaj komende bo lokomotywa jej nie rozpoznaje + occupied->PutCommand(NewCommand, NewValue1, NewValue2, occupied->Loc); + occupied->RunInternalCommand(); // rozpoznaj komende bo lokomotywa jej nie rozpoznaje return true; // załatwione } @@ -192,7 +192,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if (NewCommand == "Emergency_brake") // wymuszenie zatrzymania, niezależnie kto prowadzi { // Ra: no nadal nie jest zbyt pięknie // SetVelocity(0, 0, reason); - mvOccupied->PutCommand("Emergency_brake", 1.0, 1.0, mvOccupied->Loc); + occupied->PutCommand("Emergency_brake", 1.0, 1.0, occupied->Loc); return true; // załatwione } @@ -224,14 +224,14 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if( true == AIControllFlag ) { // 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->MoverParameters->Doors.close_control == control_t::driver - || pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) { - pVehicle->MoverParameters->OperateDoors( VehicleSide::right, false ); - pVehicle->MoverParameters->OperateDoors( VehicleSide::left, false ); + if( pVehicle->physics->Doors.close_control == control_t::driver + || pVehicle->physics->Doors.close_control == control_t::mixed ) { + pVehicle->physics->OperateDoors( VehicleSide::right, false ); + pVehicle->physics->OperateDoors( VehicleSide::left, false ); } - if( pVehicle->MoverParameters->Doors.permit_needed ) { - pVehicle->MoverParameters->PermitDoors( VehicleSide::right, false ); - pVehicle->MoverParameters->PermitDoors( VehicleSide::left, false ); + if( pVehicle->physics->Doors.permit_needed ) { + pVehicle->physics->PermitDoors( VehicleSide::right, false ); + pVehicle->physics->PermitDoors( VehicleSide::left, false ); } } drivingFlags.doorOpened = false; @@ -301,16 +301,16 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N else if (!iDirectionOrder) {//jeśli nie ma kierunku, trzeba ustalić - if (mvOccupied->V!=0.0) - iDirectionOrder=mvOccupied->V>0?1:-1; + if (occupied->V!=0.0) + iDirectionOrder=occupied->V>0?1:-1; else - iDirectionOrder=mvOccupied->CabOccupied; + iDirectionOrder=occupied->CabOccupied; if (!iDirectionOrder) iDirectionOrder=1; } */ // jeśli wysyłane z Trainset, to wszystko jest już odpowiednio ustawione // if (!NewLocation) //jeśli wysyłane z Trainset - // if (mvOccupied->CabActive*mvOccupied->V*NewValue1<0) //jeśli zadana prędkość niezgodna z + // if (occupied->CabActive*occupied->V*NewValue1<0) //jeśli zadana prędkość niezgodna z // aktualnym kierunkiem jazdy // DirectionForward(false); //jedziemy do tyłu (nawrotnik do tyłu) // CheckVehicles(); //sprawdzenie składu, AI zapali światła @@ -434,7 +434,7 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N OrderNext(o); // to samo robić po zmianie else if (!o) // jeśli wcześniej było czekanie OrderNext(DriverOrder::shunt); // to dalej jazda manewrowa - if (mvOccupied->Vel >= EU07_AI_MOVEMENT) // jeśli jedzie + if (occupied->Vel >= EU07_AI_MOVEMENT) // jeśli jedzie drivingFlags.startHorn = false; // to bez trąbienia po ruszeniu z zatrzymania // Change_direction wykona się samo i następnie przejdzie do kolejnej komendy return true; @@ -505,13 +505,13 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N if( NewValue1 >= 0.0 ) { // jeśli ilość wagonów inna niż wszystkie będzie odczepianie, // ale jeśli wagony są z przodu, to trzeba najpierw zmienić kierunek - if( mvOccupied->Couplers[mvOccupied->DirAbsolute > 0 ? VehicleEnd::rear : VehicleEnd::front].Connected == nullptr // z tyłu nic - && mvOccupied->Couplers[mvOccupied->DirAbsolute > 0 ? VehicleEnd::front : VehicleEnd::rear].Connected != nullptr ) { // a z przodu skład + if( occupied->Couplers[occupied->DirAbsolute > 0 ? VehicleEnd::rear : VehicleEnd::front].Connected == nullptr // z tyłu nic + && occupied->Couplers[occupied->DirAbsolute > 0 ? VehicleEnd::front : VehicleEnd::rear].Connected != nullptr ) { // a z przodu skład iDirectionOrder = -iDirection; // zmiana na ciągnięcie OrderNext( DriverOrder::changeDirection ); // najpierw zmień kierunek (zastąpi Disconnect) OrderPush( DriverOrder::disconnect ); // a odczep już po zmianie kierunku } - else if( mvOccupied->Couplers[ mvOccupied->DirAbsolute > 0 ? VehicleEnd::rear : VehicleEnd::front ].Connected != nullptr ) { // z tyłu coś + else if( occupied->Couplers[ occupied->DirAbsolute > 0 ? VehicleEnd::rear : VehicleEnd::front ].Connected != nullptr ) { // z tyłu coś OrderNext( DriverOrder::disconnect ); // jak ciągnie, to tylko odczep (NewValue1) wagonów } else { @@ -881,14 +881,14 @@ TController::UpdateChangeDirection() { // TODO: rework into driver mode independent routine if( false == OrderCurrentGet().HasAll(DriverOrder::changeDirection) ) { return; } - if( true == AIControllFlag && mvOccupied->Vel < EU07_AI_NOMOVEMENT ) { + if( true == AIControllFlag && 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 // Change_direction (tylko dla AI) } // shared part of the routine, implement if direction matches what was requested - if( mvOccupied->Vel < EU07_AI_NOMOVEMENT + if( occupied->Vel < EU07_AI_NOMOVEMENT && iDirection == iDirectionOrder ) { // NOTE: we can't be sure there's a visible signal within scan range after direction change // which would normally overwrite the old limit, so we reset signal value manually here @@ -915,14 +915,14 @@ TController::UpdateLooseShunt() { if( autobrakerelease && Obstacle.distance < 1.0 && AccDesired > 0.1 - && mvOccupied->Vel < 1.0 ) { + && occupied->Vel < 1.0 ) { auto *vehicle { Obstacle.vehicle }; auto const direction { ( vehicle->Prev() != nullptr ? VehicleEnd::front : VehicleEnd::rear ) }; while( vehicle != nullptr ) { - if( vehicle->MoverParameters->BrakePress > 0.2 ) { - vehicle->MoverParameters->BrakeLevelSet( 0 ); // hamulec na zero, aby nie hamował - vehicle->MoverParameters->BrakeReleaser( 1 ); // wyluzuj pojazd, aby dało się dopychać + if( vehicle->physics->BrakePress > 0.2 ) { + vehicle->physics->BrakeLevelSet( 0 ); // hamulec na zero, aby nie hamował + vehicle->physics->BrakeReleaser( 1 ); // wyluzuj pojazd, aby dało się dopychać } // NOTE: we trust the consist to be arranged in a valid chain // TBD, TODO: traversal direction validation? @@ -952,7 +952,7 @@ TController::UpdateObeyTrain() { // jeśli nie przez radio tsGuardSignal.owner( pVehicle ); // place virtual conductor some distance away - tsGuardSignal.offset( { pVehicle->MoverParameters->Dim.W * -0.75f, 1.7f, std::min( -20.0, -0.2 * fLength ) } ); + tsGuardSignal.offset( { pVehicle->physics->Dim.W * -0.75f, 1.7f, std::min( -20.0, -0.2 * fLength ) } ); tsGuardSignal.play( sound_flags::exclusive ); // NOTE: we can't rely on is_playing() check as sound playback is based on distance from local camera fActionTime = -5.0; // niech trochę potrzyma @@ -961,7 +961,7 @@ TController::UpdateObeyTrain() { // radio message tsGuardSignal.owner( pVehicle ); /* - tsGuardSignal.offset( { 0.f, 2.f, pVehicle->MoverParameters->Dim.L * 0.4f * ( pVehicle->MoverParameters->CabOccupied < 0 ? -1 : 1 ) } ); + tsGuardSignal.offset( { 0.f, 2.f, pVehicle->physics->Dim.L * 0.4f * ( pVehicle->physics->CabOccupied < 0 ? -1 : 1 ) } ); tsGuardSignal.play( sound_flags::exclusive ); */ simulation::radio_message( &tsGuardSignal, iGuardRadio ); @@ -979,13 +979,13 @@ TController::UpdateConnect() { // sprzęgi sprawdzamy w pierwszej kolejności, bo jak połączony, to koniec auto *vehicle { iCouplingVehicle.value().first }; auto const couplingend { iCouplingVehicle.value().second }; - auto *vehicleparameters { vehicle->MoverParameters }; + auto *vehicleparameters { vehicle->physics }; auto const &neighbour { vehicleparameters->Neighbours[ couplingend ] }; // vehicles which can't share their control get coupled without the control connection (eu07/maszyna#520) auto expectedcoupling { iCoupler }; if( neighbour.vehicle != nullptr ) { auto const neighbourend { neighbour.vehicle_end != 2 ? neighbour.vehicle_end : vehicleparameters->Couplers[ couplingend ].ConnectedNr }; - expectedcoupling = vehicleparameters->CompatibleCoupling( EndOf( couplingend ), *neighbour.vehicle->MoverParameters, EndOf( neighbourend ), iCoupler ); + expectedcoupling = vehicleparameters->CompatibleCoupling( EndOf( couplingend ), *neighbour.vehicle->physics, EndOf( neighbourend ), iCoupler ); } if( vehicleparameters->Couplers[ couplingend ].CouplingFlag != expectedcoupling ) { if( neighbour.vehicle != nullptr && neighbour.distance < 10 ) { @@ -994,7 +994,7 @@ TController::UpdateConnect() { auto const &coupler{vehicleparameters->Couplers[couplingend]}; if (coupler.type() != TCouplerType::Automatic) { - auto const &othercoupler = neighbour.vehicle->MoverParameters->Couplers[(neighbour.vehicle_end != 2 ? neighbour.vehicle_end : coupler.ConnectedNr)]; + auto const &othercoupler = neighbour.vehicle->physics->Couplers[(neighbour.vehicle_end != 2 ? neighbour.vehicle_end : coupler.ConnectedNr)]; if (othercoupler.type() == TCouplerType::Automatic) { coupleriscompatible = false; @@ -1004,7 +1004,7 @@ TController::UpdateConnect() { // próba podczepienia if ((AIControllFlag || Global.AITrainman) && coupleriscompatible && neighbour.distance < 2) { - vehicleparameters->Attach(couplingend, neighbour.vehicle_end, neighbour.vehicle->MoverParameters, iCoupler); + vehicleparameters->Attach(couplingend, neighbour.vehicle_end, neighbour.vehicle->physics, iCoupler); } } } @@ -1039,7 +1039,7 @@ TController::unit_count( int const Threshold ) const { auto const decoupledend{ ( vehicle->DirectionGet() > 0 ? // numer sprzęgu od strony czoła składu VehicleEnd::rear : VehicleEnd::front ) }; - auto const coupling { vehicle->MoverParameters->Couplers[ decoupledend ].CouplingFlag }; + auto const coupling { vehicle->physics->Couplers[ decoupledend ].CouplingFlag }; if( coupling == Coupling::none ) { break; } @@ -1072,12 +1072,12 @@ TController::UpdateDisconnect() { if( drivingFlags.press && iDirection == iDirectionOrder ) { if( iVehicleCount >= 0 ) { // zmieni się po odczepieniu - WriteLog( "Uncoupling [" + mvOccupied->Name + "]: actuating and compressing buffers..." ); + WriteLog( "Uncoupling [" + occupied->Name + "]: actuating and compressing buffers..." ); cue_action( driver_hint::independentbrakerelease ); cue_action( driver_hint::bufferscompress ); } - WriteLog( "Uncoupling [" + mvOccupied->Name + "]: from " + ( mvOccupied->DirAbsolute > 0 ? "front" : "rear" ) ); + WriteLog( "Uncoupling [" + occupied->Name + "]: from " + ( occupied->DirAbsolute > 0 ? "front" : "rear" ) ); auto *decoupledvehicle { pVehicle }; // pojazd do odczepienia, w (pVehicle) siedzi AI int decoupledend; // numer sprzęgu, który sprawdzamy albo odczepiamy auto vehiclecount { iVehicleCount }; // ile wagonów ma zostać @@ -1087,11 +1087,11 @@ TController::UpdateDisconnect() { VehicleEnd::front : VehicleEnd::rear ); // jeżeli sprzęg zablokowany to liczymy człony jako jeden - if( decoupledvehicle->MoverParameters->Couplers[ decoupledend ].CouplingFlag & Coupling::permanent ) { + if( decoupledvehicle->physics->Couplers[ decoupledend ].CouplingFlag & Coupling::permanent ) { ++vehiclecount; } if( decoupledvehicle != pVehicle ) { - decoupledvehicle->MoverParameters->BrakeReleaser( 1 ); // wyluzuj pojazd, aby dało się dopychać + decoupledvehicle->physics->BrakeReleaser( 1 ); // wyluzuj pojazd, aby dało się dopychać } if( vehiclecount ) { // jeśli jeszcze nie koniec decoupledvehicle = decoupledvehicle->Prev(); // kolejny w stronę czoła składu (licząc od tyłu), bo dociskamy @@ -1102,7 +1102,7 @@ TController::UpdateDisconnect() { } while( vehiclecount-- ); if( decoupledvehicle == nullptr ) { // no target, or already just virtual coupling - WriteLog( "Uncoupling [" + mvOccupied->Name + "]: didn't find anything to disconnect" ); + WriteLog( "Uncoupling [" + occupied->Name + "]: didn't find anything to disconnect" ); iVehicleCount = -2; // odczepiono, co było do odczepienia } else { @@ -1110,18 +1110,18 @@ TController::UpdateDisconnect() { decoupledvehicle->Dettach( decoupledend ); } // tylko jeśli odepnie - if( decoupledvehicle->MoverParameters->Couplers[ decoupledend ].CouplingFlag == Coupling::none ) { - WriteLog( "Uncoupling [" + mvOccupied->Name + "]: uncoupled" ); + if( decoupledvehicle->physics->Couplers[ decoupledend ].CouplingFlag == Coupling::none ) { + WriteLog( "Uncoupling [" + occupied->Name + "]: uncoupled" ); iVehicleCount = -2; // update trainset state CheckVehicles( DriverOrder::disconnect ); // potentially remove coupler adapter /* - if( decoupledvehicle->MoverParameters->Couplers[ decoupledend ].has_adapter() ) { + if( decoupledvehicle->physics->Couplers[ decoupledend ].has_adapter() ) { decoupledvehicle->remove_coupler_adapter( decoupledend ); } */ - if( pVehicles[ VehicleEnd::front ]->MoverParameters->Couplers[ decoupledend ].has_adapter() ) { + if( pVehicles[ VehicleEnd::front ]->physics->Couplers[ decoupledend ].has_adapter() ) { cue_action( driver_hint::couplingadapterremove, decoupledend ); } } @@ -1134,16 +1134,16 @@ TController::UpdateDisconnect() { iDirectionBackup = iDirection; } if( false == IsConsistBraked ) { - WriteLog( "Uncoupling [" + mvOccupied->Name + "]: applying consist brakes..." ); + WriteLog( "Uncoupling [" + occupied->Name + "]: applying consist brakes..." ); cue_action( driver_hint::trainbrakeapply ); } // jeśli w miarę został zahamowany (ciśnienie mniejsze niż podane na pozycji 3, zwyle 0.37) else { - WriteLog( "Uncoupling [" + mvOccupied->Name + "]: direction change" ); + WriteLog( "Uncoupling [" + occupied->Name + "]: direction change" ); /* // TODO: test if this block is needed if( BrakeSystem == TBrakeSystem::ElectroPneumatic ) { // wyłączenie EP, gdy wystarczy (może nie być potrzebne, bo na początku jest) - mvOccupied->BrakeLevelSet( 0 ); + occupied->BrakeLevelSet( 0 ); } */ iDirectionOrder = -iDirection; // zmiana kierunku jazdy na przeciwny (dociskanie) @@ -1158,7 +1158,7 @@ TController::UpdateDisconnect() { iDirectionBackup.reset(); } if( iDirection != iDirectionOrder ) { - WriteLog( "Uncoupling [" + mvOccupied->Name + "]: second direction change" ); + WriteLog( "Uncoupling [" + occupied->Name + "]: second direction change" ); cue_action( driver_hint::mastercontrollersetreverserunlock ); cue_action( driver_hint::directionother ); // zmiana kierunku jazdy na właściwy } @@ -1178,7 +1178,7 @@ TController::handle_engine() { if( OrderCurrentGet() == DriverOrder::waitForOrders && false == iEngineActive // && ( false == AIControllFlag ) - && true == mvOccupied->Power24vIsAvailable ) { + && true == occupied->Power24vIsAvailable ) { OrderNext( DriverOrder::prepareEngine ); } // basic engine preparation diff --git a/vehicle/ai/physicslog.cpp b/vehicle/ai/physicslog.cpp index cc32e5738..3497fc827 100644 --- a/vehicle/ai/physicslog.cpp +++ b/vehicle/ai/physicslog.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -65,24 +65,24 @@ std::string TController::physicslog_line() const { std::ostringstream line; line << std::fixed << std::setprecision( 4 ) << ElapsedTime << " " - << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) << " " + << fabs(11.31 * occupied->WheelDiameter * occupied->nrot) << " " << mvControlling->AccS << " " - << mvOccupied->Couplers[1].Dist << " " - << mvOccupied->Couplers[1].CForce << " " - << mvOccupied->Ft << " " - << mvOccupied->Ff << " " - << mvOccupied->Fb << " " - << mvOccupied->BrakePress << " " - << mvOccupied->PipePress << " " + << occupied->Couplers[1].Dist << " " + << occupied->Couplers[1].CForce << " " + << occupied->Ft << " " + << occupied->Ff << " " + << occupied->Fb << " " + << occupied->BrakePress << " " + << occupied->PipePress << " " << mvControlling->Im << " " << int(mvControlling->MainCtrlPos) << " " << int(mvControlling->ScndCtrlPos) << " " - << mvOccupied->fBrakeCtrlPos << " " - << mvOccupied->LocalBrakePosA << " " + << occupied->fBrakeCtrlPos << " " + << occupied->LocalBrakePosA << " " << int(mvControlling->DirActive) << " " - << ( mvOccupied->CommandIn.Text.empty() ? "none" : mvOccupied->CommandIn.Text.c_str() ) << " " - << mvOccupied->CommandIn.Value1 << " " - << mvOccupied->CommandIn.Value2 << " " + << ( occupied->CommandIn.Text.empty() ? "none" : occupied->CommandIn.Text.c_str() ) << " " + << occupied->CommandIn.Value1 << " " + << occupied->CommandIn.Value2 << " " << int(mvControlling->SecuritySystem.is_blinking()) << " " << int(mvControlling->SlippingWheels) << " " << mvControlling->diesel.heat.Ts << " " @@ -90,7 +90,7 @@ std::string TController::physicslog_line() const { << mvControlling->diesel.heat.temperatura1 << " " << mvControlling->diesel.heat.temperatura2 << " " // vehicle speed [km/h], the second column is the wheel speed, which stays at 0 while the wheels are locked in a skid - << mvOccupied->V * 3.6 + << occupied->V * 3.6 << "\r\n"; return line.str(); } @@ -114,12 +114,12 @@ void TController::PhysicsLog() #endif #if LOGPRESS == 1 std::ostringstream line; - line << ElapsedTime << "\t" << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) + line << ElapsedTime << "\t" << fabs(11.31 * occupied->WheelDiameter * occupied->nrot) << "\t"; line << mvControlling->AccS << "\t"; - line << mvOccupied->PipePress << "\t" << mvOccupied->CntrlPipePress << "\t" - << mvOccupied->BrakePress << "\t"; - line << mvOccupied->Volume << "\t" << mvOccupied->Hamulec->GetCRP() << "\n"; + line << occupied->PipePress << "\t" << occupied->CntrlPipePress << "\t" + << occupied->BrakePress << "\t"; + line << occupied->Volume << "\t" << occupied->Hamulec->GetCRP() << "\n"; PhysicsLogs.append( VehicleName, line.str() ); #endif }; diff --git a/vehicle/ai/routescan.cpp b/vehicle/ai/routescan.cpp index aaf7f3988..fee849e3a 100644 --- a/vehicle/ai/routescan.cpp +++ b/vehicle/ai/routescan.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -211,7 +211,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) fTrackLength -= glm::length( pVehicle->AxlePositionGet() - pVehicle->RearPosition() - + pVehicle->VectorLeft() * pVehicle->MoverParameters->OffsetTrackH ); + + pVehicle->VectorLeft() * pVehicle->physics->OffsetTrackH ); // aktualna odległość ma być ujemna gdyż jesteśmy na końcu składu fCurrentDistance = -fLength - fTrackLength; fTrackLength = pTrack->Length(); //skasowanie zmian w zmiennej żeby poprawnie liczyło w dalszych krokach @@ -297,7 +297,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) typeid( *pEvent ) == typeid( road_order ) ? fCurrentDistance + ProjectEventOnTrack( pEvent, pTrack, fLastDir ) : GetDistanceToEvent( pTrack, pEvent, fLastDir, fCurrentDistance ) }; - if (newspeedpoint.Set(pEvent, eventdistance, fLength, OrderCurrentGet(), mvOccupied->Vel < EU07_AI_NOMOVEMENT)) + if (newspeedpoint.Set(pEvent, eventdistance, fLength, OrderCurrentGet(), occupied->Vel < EU07_AI_NOMOVEMENT)) { fDistance = newspeedpoint.fDist; // jeśli sygnał stop, to nie ma potrzeby dalej skanować @@ -498,7 +498,7 @@ void TController::TableCheck(double fDistance) sSpeedTable[i].ResetFlags(); // to nie ma go po co trzymać (odtykacz usunie ze środka) } } - else if (sSpeedTable[i].flags & SpeedPointFlag::event && false == sSpeedTable[i].flags.HasAny(SpeedPointFlag::pointSpeed) && sSpeedTable[i].fDist < (typeid(*sSpeedTable[i].evEvent) == typeid(putvalues_event) ? -fLength : 0) && mvOccupied->CategoryFlag == 2 && + else if (sSpeedTable[i].flags & SpeedPointFlag::event && false == sSpeedTable[i].flags.HasAny(SpeedPointFlag::pointSpeed) && sSpeedTable[i].fDist < (typeid(*sSpeedTable[i].evEvent) == typeid(putvalues_event) ? -fLength : 0) && occupied->CategoryFlag == 2 && sSpeedTable[i].fDist < -0.75) // jeśli event { // jeśli jest z tyłu @@ -566,7 +566,7 @@ void TController::CheckSignalPassed( TSpeedPos const &Point, bool const Passedbe { // not bSeenAhead: found already behind the head, the train stood across it or past it, it didn't pass it if( false == signal_passing::passed_now( Passedbefore, Point.flags.HasAll(SpeedPointFlag::elapsed), Point.bSeenAhead ) - || ( mvOccupied->CategoryFlag & 1 ) == 0 ) { // railway only + || ( occupied->CategoryFlag & 1 ) == 0 ) { // railway only return; } if( is_signal_at_stop( Point ) ) { @@ -580,7 +580,7 @@ void TController::CheckSignalPassed( TSpeedPos const &Point, bool const Passedbe simulation::Blackbox.signal_passed( pVehicles[ VehicleEnd::front ], *Point.evEvent, speedatsignal, Point.evEvent->input_value( 2 ), - mvOccupied->Vel, -Point.fDist, + occupied->Vel, -Point.fDist, passing_flags_of( Point, speedatsignal, false == OrderCurrentGet().HasAny( DriverOrder::shunt | DriverOrder::looseShunt ) ) ); } } @@ -617,7 +617,7 @@ TController::train_proximity_margins( bool const Passengerstop ) const { minproximity += 5.0; maxproximity += 5.0; } - if( mvOccupied->Vel < 0.1 ) { + if( occupied->Vel < 0.1 ) { // jak stanie za daleko, to niech nie dociąga paru metrów maxproximity = std::max( maxproximity, 50.0 ); } diff --git a/vehicle/ai/situation.cpp b/vehicle/ai/situation.cpp index 9ef52112f..9e79e913e 100644 --- a/vehicle/ai/situation.cpp +++ b/vehicle/ai/situation.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -56,14 +56,14 @@ TController::update_timers( double dt ) { WaitingTime += dt; fBrakeTime -= dt; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca fBrakeHeldTime += dt; - if( mvOccupied->fBrakeCtrlPos != mvOccupied->Handle->GetPos( bh_FS ) ) { + if( occupied->fBrakeCtrlPos != occupied->Handle->GetPos( bh_FS ) ) { // brake charging timeout starts after charging ends BrakeChargingCooldown += dt; } fStopTime += dt; // zliczanie czasu postoju, nie ruszy dopóki ujemne fActionTime += dt; // czas używany przy regulacji prędkości i zamykaniu drzwi LastReactionTime += dt; - if( mvOccupied->Vel < 0.05 + if( occupied->Vel < 0.05 && OrderCurrentGet().HasAny(DriverOrder::shunt | DriverOrder::looseShunt | DriverOrder::obeyTrain | DriverOrder::bank) ) { IdleTime += dt; } @@ -98,7 +98,7 @@ TController::control_wheelslip() { // a start that has slipped once keeps the sand on until the train is under way. with the sand off as soon as the // wheels grip again, the next notch slips again, and a heavy train on poor rails slips, grips and snatches over // and over, and may never get going (#187). a vehicle without sand starts as before - auto const velocity { std::abs( mvOccupied->Vel ) }; + auto const velocity { std::abs( occupied->Vel ) }; if( mvControlling->SlippingWheels && velocity < EU07_AI_SANDEDSTARTVELOCITY && false == mvControlling->IsMainCtrlNoPowerPos() @@ -140,10 +140,10 @@ TController::control_wheelslip() { void TController::control_pantographs() { - if( mvPantographUnit->EnginePowerSource.SourceType != TPowerSource::CurrentCollector ) { return; } + if( pantographUnit->EnginePowerSource.SourceType != TPowerSource::CurrentCollector ) { return; } - if( false == mvPantographUnit->PantAutoValve - && mvOccupied->ScndPipePress > 4.3 ) { + if( false == pantographUnit->PantAutoValve + && occupied->ScndPipePress > 4.3 ) { // gdy główna sprężarka bezpiecznie nabije ciśnienie to można przestawić kurek na zasilanie pantografów z głównej pneumatyki cue_action( driver_hint::pantographairsourcesetmain ); } @@ -160,7 +160,7 @@ TController::control_pantographs() { // or the vehicle isn't shunting auto const shuntpantographsetup { OrderCurrentGet().HasAny( DriverOrder::shunt | DriverOrder::looseShunt ) ? - mvOccupied->AIHintShuntPantstate : + occupied->AIHintShuntPantstate : 0 }; // raise/lower pantographs as needed @@ -169,7 +169,7 @@ TController::control_pantographs() { || is_emu() // special case || mvControlling->TrainType == train_type::et41 }; // special case - if( mvOccupied->Vel > EU07_AI_NOMOVEMENT ) { + if( occupied->Vel > EU07_AI_NOMOVEMENT ) { if( fOverhead2 >= 0.0 || iOverheadZero ) { // jeśli jazda bezprądowa albo z opuszczonym pantografem @@ -178,10 +178,10 @@ TController::control_pantographs() { if( fOverhead2 > 0.0 || iOverheadDown ) { // jazda z opuszczonymi pantografami - if( mvPantographUnit->Pantographs[ VehicleEnd::front ].is_active ) { + if( pantographUnit->Pantographs[ VehicleEnd::front ].is_active ) { cue_action( driver_hint::frontpantographvalveoff ); } - if( mvPantographUnit->Pantographs[ VehicleEnd::rear ].is_active ) { + if( pantographUnit->Pantographs[ VehicleEnd::rear ].is_active ) { cue_action( driver_hint::rearpantographvalveoff ); } } @@ -193,39 +193,39 @@ TController::control_pantographs() { // shunting with the pantograph setup the .fiz suggests for it control_pantographs_setup( shuntpantographsetup ); } - else if( mvOccupied->AIHintPantstate == 0 ) { + else if( occupied->AIHintPantstate == 0 ) { // jazda na tylnym if( iDirection >= 0 && useregularpantographlayout ) { // jak jedzie w kierunku sprzęgu 0 - if( mvPantographUnit->PantRearVolt == 0.0 + if( pantographUnit->PantRearVolt == 0.0 // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( mvPantographUnit->PantographVoltage == 0.0 - || mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { + && ( pantographUnit->PantographVoltage == 0.0 + || pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { cue_action( driver_hint::rearpantographvalveon ); } } else { // jak jedzie w kierunku sprzęgu 0 - if( mvPantographUnit->PantFrontVolt == 0.0 + if( pantographUnit->PantFrontVolt == 0.0 // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( mvPantographUnit->PantographVoltage == 0.0 - || mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { + && ( pantographUnit->PantographVoltage == 0.0 + || pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { cue_action( driver_hint::frontpantographvalveon ); } } - if( mvOccupied->Vel > 5 && mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) { + if( occupied->Vel > 5 && pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) { // opuszczenie przedniego po rozpędzeniu się o ile jest więcej niż jeden if (iDirection >= 0 && useregularpantographlayout) // jak jedzie w kierunku sprzęgu 0 { // poczekać na podniesienie tylnego - if (mvPantographUnit->PantFrontVolt != 0.0 && mvPantographUnit->PantRearVolt != 0.0) + if (pantographUnit->PantFrontVolt != 0.0 && pantographUnit->PantRearVolt != 0.0) { // czy jest napięcie zasilające na tylnym? cue_action(driver_hint::frontpantographvalveoff); // opuszcza od sprzęgu 0 } } else { // poczekać na podniesienie przedniego - if (mvPantographUnit->PantRearVolt != 0.0 && mvPantographUnit->PantFrontVolt != 0.0) + if (pantographUnit->PantRearVolt != 0.0 && pantographUnit->PantFrontVolt != 0.0) { // czy jest napięcie zasilające na przednim? cue_action(driver_hint::rearpantographvalveoff); // opuszcza od sprzęgu 1 } @@ -235,8 +235,8 @@ TController::control_pantographs() { } else { // use suggested pantograph setup - if( mvOccupied->Vel > 5 ) { - auto const pantographsetup{ mvOccupied->AIHintPantstate }; + if( occupied->Vel > 5 ) { + auto const pantographsetup{ occupied->AIHintPantstate }; cue_action( pantographsetup & 1 << 0 ? driver_hint::frontpantographvalveon : driver_hint::frontpantographvalveoff ); cue_action( @@ -253,7 +253,7 @@ TController::control_pantographs() { } } else { - if( !mvOccupied->AIHintPantUpIfIdle || IdleTime <= 45.0 || std::abs(fStopTime) <= 15.0 || mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo <= 1 ) + if( !occupied->AIHintPantUpIfIdle || IdleTime <= 45.0 || std::abs(fStopTime) <= 15.0 || pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo <= 1 ) { } else @@ -262,14 +262,14 @@ TController::control_pantographs() { if (iDirection >= 0 && useregularpantographlayout) { // jak jedzie w kierunku sprzęgu 0 - if (mvPantographUnit->PantFrontVolt == 0.0) + if (pantographUnit->PantFrontVolt == 0.0) { cue_action(driver_hint::frontpantographvalveon, 5); // discard the hint if speed exceeds 5 km/h } } else { - if (mvPantographUnit->PantRearVolt == 0.0) + if (pantographUnit->PantRearVolt == 0.0) { cue_action(driver_hint::rearpantographvalveon, 5); // discard the hint if speed exceeds 5 km/h } @@ -291,7 +291,7 @@ TController::control_pantographs_setup( int const Setup ) { if( rear ) { cue_action( driver_hint::rearpantographvalveon ); } - if( auto const setuplive { ( front && mvPantographUnit->PantFrontVolt != 0.0 ) || ( rear && mvPantographUnit->PantRearVolt != 0.0 ) }; + if( auto const setuplive { ( front && pantographUnit->PantFrontVolt != 0.0 ) || ( rear && pantographUnit->PantRearVolt != 0.0 ) }; false == setuplive ) { return; } @@ -308,16 +308,16 @@ TController::control_horns( double const Timedelta ) { // horn control if( fWarningDuration > 0.0 ) { // jeśli pozostało coś do wytrąbienia trąbienie trwa nadal - if( mvOccupied->WarningSignal == 0 ) { + if( occupied->WarningSignal == 0 ) { cue_action( driver_hint::hornon, 1 ); // low tone horn by default } } else { - if( mvOccupied->WarningSignal != 0 ) { + if( occupied->WarningSignal != 0 ) { cue_action( driver_hint::hornoff ); // a tu się kończy } } - if( mvOccupied->Vel > EU07_AI_MOVEMENT ) { + if( occupied->Vel > EU07_AI_MOVEMENT ) { // jesli jedzie, można odblokować trąbienie, bo się wtedy nie włączy drivingFlags.startHornDone = false; // zatrąbi dopiero jak następnym razem stanie drivingFlags.startHorn = true; // i trąbić przed następnym ruszeniem @@ -337,37 +337,37 @@ TController::control_horns( double const Timedelta ) { void TController::control_security_system( double const Timedelta ) { - if( mvOccupied->SecuritySystem.is_cabsignal_blinking() && mvOccupied->SecuritySystem.has_separate_acknowledge()) { + if( occupied->SecuritySystem.is_cabsignal_blinking() && occupied->SecuritySystem.has_separate_acknowledge()) { // jak zadziałało SHP if( false == is_emu() - && mvOccupied->DirActive == 0 ) { + && occupied->DirActive == 0 ) { cue_action( driver_hint::directionforward ); } cue_action( driver_hint::shpsystemreset ); // to skasuj if( BrakeCtrlPosition == 0 // TODO: verify whether it's 0 in all vehicle types && AccDesired > 0.0 - && mvOccupied->SecuritySystem.is_braking() ) { + && occupied->SecuritySystem.is_braking() ) { cue_action( driver_hint::trainbrakerelease ); } } - if( mvOccupied->SecuritySystem.is_blinking() ) { + if( occupied->SecuritySystem.is_blinking() ) { // jak zadziałało CA/SHP if( false == is_emu() - && mvOccupied->DirActive == 0 ) { + && occupied->DirActive == 0 ) { cue_action( driver_hint::directionforward ); } cue_action( driver_hint::securitysystemreset ); // to skasuj if( BrakeCtrlPosition == 0 // TODO: verify whether it's 0 in all vehicle types && AccDesired > 0.0 - && mvOccupied->SecuritySystem.is_braking() ) { + && occupied->SecuritySystem.is_braking() ) { cue_action( driver_hint::trainbrakerelease ); } } // basic emergency stop handling, while at it - if( true == mvOccupied->RadioStopFlag // radio-stop - && mvOccupied->Vel < 0.01 // and actual stop - && true == mvOccupied->Radio ) { // and we didn't touch the radio yet + if( true == occupied->RadioStopFlag // radio-stop + && occupied->Vel < 0.01 // and actual stop + && true == occupied->Radio ) { // and we didn't touch the radio yet // turning off the radio should reset the flag, during security system check if( m_radiocontroltime > 5.0 ) { // arbitrary delay between stop and disabling the radio cue_action( driver_hint::radiooff ); @@ -377,17 +377,17 @@ TController::control_security_system( double const Timedelta ) { } } if( iEngineActive - && ( false == mvOccupied->Radio || false == mvOccupied->RadioFuse ) - && false == mvOccupied->RadioStopFlag ) { + && ( false == occupied->Radio || false == occupied->RadioFuse ) + && false == occupied->RadioStopFlag ) { // otherwise if it's safe to do so, turn the radio back on // arbitrary 5 sec delay before switching radio back on m_radiocontroltime = std::min( m_radiocontroltime, 5.0 ); if( m_radiocontroltime < 0.0 ) { // hint at whichever of the two is open, the radio's switch or the cut-off in its power supply - if( false == mvOccupied->RadioFuse ) { + if( false == occupied->RadioFuse ) { cue_action( driver_hint::radiofuseon ); } - if( false == mvOccupied->Radio ) { + if( false == occupied->Radio ) { cue_action( driver_hint::radioon ); } } @@ -449,19 +449,19 @@ TController::control_handles() { void TController::sync_lights_selector() { - if( mvOccupied->LightsPosNo <= 0 ) { return; } + if( occupied->LightsPosNo <= 0 ) { return; } auto const *headvehicle { pVehicles[ VehicleEnd::front ] }; if( headvehicle == nullptr ) { return; } // same choice of the light table as in TDynamicObject::SetLights() - auto const lightstable { ( mvOccupied->CabOccupied * pVehicle->DirectionGet() >= 0 ? VehicleEnd::front : VehicleEnd::rear ) }; + auto const lightstable { ( occupied->CabOccupied * pVehicle->DirectionGet() >= 0 ? VehicleEnd::front : VehicleEnd::rear ) }; // same choice of the lit vehicle end as in TDynamicObject::RaLightsSet() auto const headend { ( headvehicle->iDirection > 0 ? VehicleEnd::front : VehicleEnd::rear ) }; auto const position { handover::light_selector_position( - *mvOccupied, NumberOf( lightstable ), headvehicle->MoverParameters->iLights[ headend ], headvehicle->LightList( headend ) ) }; - if( position == mvOccupied->LightsPos ) { return; } + *occupied, NumberOf( lightstable ), headvehicle->physics->iLights[ headend ], headvehicle->LightList( headend ) ) }; + if( position == occupied->LightsPos ) { return; } - mvOccupied->LightsPos = position; + occupied->LightsPos = position; // visual feedback auto *train { simulation::Trains.find( pVehicle->name() ) }; if( train != nullptr ) { @@ -474,24 +474,24 @@ TController::sync_lights_selector() { void TController::sync_lights_dimmer() { - if( mvOccupied->dimPositions.empty() ) { return; } + if( occupied->dimPositions.empty() ) { return; } auto const *headvehicle { pVehicles[ VehicleEnd::front ] }; auto const headend { ( headvehicle != nullptr && headvehicle->iDirection > 0 ? VehicleEnd::front : VehicleEnd::rear ) }; auto const headlightson { headvehicle != nullptr - && ( headvehicle->MoverParameters->iLights[ headend ] & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) != 0 }; + && ( headvehicle->physics->iLights[ headend ] & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) != 0 }; - auto const position { handover::dimmer_position( *mvOccupied, headlightson ) }; - if( position != mvOccupied->modernDimmerPosition ) { - mvOccupied->modernDimmerPosition = position; + auto const position { handover::dimmer_position( *occupied, headlightson ) }; + if( position != occupied->modernDimmerPosition ) { + occupied->modernDimmerPosition = position; // visual feedback auto *train { simulation::Trains.find( pVehicle->name() ) }; if( train != nullptr ) { train->ggModernLightDimSw.PutValue( static_cast( position ) ); } } - if( position < 0 || position >= static_cast( mvOccupied->dimPositions.size() ) ) { return; } // SetLightDimmings() doesn't check the range + if( position < 0 || position >= static_cast( occupied->dimPositions.size() ) ) { return; } // SetLightDimmings() doesn't check the range pVehicle->SetLightDimmings(); } @@ -540,9 +540,9 @@ TController::control_lights() { void TController::control_compartment_lights() { // compartment lights - if( mvOccupied->CompartmentLights.start_type != start_t::manual ) { return; } + if( occupied->CompartmentLights.start_type != start_t::manual ) { return; } - auto const currentlightstate { mvOccupied->CompartmentLights.is_enabled }; + auto const currentlightstate { occupied->CompartmentLights.is_enabled }; auto const lightlevel { Global.fLuminance * ConsistShade }; auto const desiredlightstate{ ( currentlightstate ? @@ -556,7 +556,7 @@ TController::control_compartment_lights() { void TController::UpdateCommand() { - if( mvOccupied->CommandIn.Command != VehicleCommand::none && false == mvOccupied->RunInternalCommand() ) { + if( occupied->CommandIn.Command != VehicleCommand::none && false == occupied->RunInternalCommand() ) { // rozpoznaj komende bo lokomotywa jej nie rozpoznaje RecognizeCommand(); // samo czyta komendę wstawioną do pojazdu? } @@ -566,7 +566,7 @@ void TController::UpdateNextStop() { if( fLastStopExpDist > 0.0 - && mvOccupied->DistCounter > fLastStopExpDist ) { + && occupied->DistCounter > fLastStopExpDist ) { // zaktualizować wyświetlanie rozkładu TrainParams.StationStart = TrainParams.StationIndex; fLastStopExpDist = -1.0; // usunąć licznik @@ -581,21 +581,21 @@ void TController::determine_braking_distance() { // przybliżona droga hamowania // NOTE: we're ensuring some minimal braking distance to reduce ai flipping states between starting and braking - auto const velceil { std::max( 2.0, std::ceil( mvOccupied->Vel ) ) }; + auto const velceil { std::max( 2.0, std::ceil( occupied->Vel ) ) }; fBrakeDist = fDriverBraking * velceil * ( 40.0 + velceil ); if( fMass > 1000000.0 ) { // korekta dla ciężkich, bo przeżynają - da to coś? fBrakeDist *= 2.0; } if( -fAccThreshold > 0.05 - && mvOccupied->CategoryFlag == 1 ) { + && occupied->CategoryFlag == 1 ) { fBrakeDist = velceil * velceil / 25.92 / -fAccThreshold; } - if( mvOccupied->BrakeDelayFlag == bdelay_G ) { + if( occupied->BrakeDelayFlag == bdelay_G ) { // dla nastawienia G koniecznie należy wydłużyć drogę na czas reakcji fBrakeDist += 2 * velceil; } - if( mvOccupied->Vel > 15.0 + if( occupied->Vel > 15.0 && mvControlling->EngineType == TEngineType::ElectricInductionMotor && is_emu() ) { // HACK: make the induction motor powered EMUs start braking slightly earlier @@ -702,8 +702,8 @@ TController::determine_proximity_ranges() { } // samochod (sokista też) else { - fMinProximityDist = std::max( 3.5, mvOccupied->Vel * 0.2 ); - fMaxProximityDist = std::max( 9.5, mvOccupied->Vel * 0.375 ); //[m] + fMinProximityDist = std::max( 3.5, occupied->Vel * 0.2 ); + fMaxProximityDist = std::max( 9.5, occupied->Vel * 0.375 ); //[m] if( Global.FrictionWeatherFactor < 1.f ) { // take into account weather conditions fMinProximityDist += 0.75; @@ -712,7 +712,7 @@ TController::determine_proximity_ranges() { // margines prędkości powodujący załączenie napędu fVelMinus = 2.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania - fVelPlus = std::min( 10.0, mvOccupied->Vel * 0.1 ); + fVelPlus = std::min( 10.0, occupied->Vel * 0.1 ); } break; } diff --git a/vehicle/ai/speed.cpp b/vehicle/ai/speed.cpp index 1e461e3f9..e213ef6d8 100644 --- a/vehicle/ai/speed.cpp +++ b/vehicle/ai/speed.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -62,10 +62,10 @@ TController::braking_distance_multiplier( float const Targetvelocity ) const { if( Targetvelocity < 5.f ) { // HACK: engaged automatic transmission means extra/earlier braking effort is needed for the last leg before full stop if( is_dmu() - && mvOccupied->Vel < 40.0 + && occupied->Vel < 40.0 && Targetvelocity == 0.f ) { auto const multiplier { std::clamp( 1.f + iVehicles * 0.5f, 2.f, 4.f ) }; - return std::lerp(multiplier, 1.f, static_cast(mvOccupied->Vel / 40.0)) * frictionmultiplier; + return std::lerp(multiplier, 1.f, static_cast(occupied->Vel / 40.0)) * frictionmultiplier; } // HACK: cargo trains or trains going downhill with high braking threshold need more distance to come to a full stop if( fBrake_a0[1] > 0.2 @@ -170,7 +170,7 @@ TController::hold_train_coming_to_stand_uphill() { || ( ( BrakeSystem == TBrakeSystem::Pneumatic ) // not for a train that is short of where it is to stop and is to pull up further && ( AccDesired <= 0.0 ) - && ( vel / 3.6 / -fAccGravity <= 0.5 * brake_response_horizon( mvOccupied, BrakeSystem, 1.0, fBrake_a0[ 0 ] ) ) ) ) { + && ( vel / 3.6 / -fAccGravity <= 0.5 * brake_response_horizon( occupied, BrakeSystem, 1.0, fBrake_a0[ 0 ] ) ) ) ) { // the gradient alone already slows the train down nearly this much; ask for enough on top of it that // the brake is applied for sure, not held back by the margin against small corrections AccDesired = std::min( AccDesired, fAccGravity - std::max( 0.15, fBrake_a0[ 0 ] ) - brake_increase_margin() ); @@ -284,7 +284,7 @@ TController::adjust_desired_speed_for_obstacles() { if( Obstacle.distance < 5000 ) { // mamy coś z przodu // prędkość pojazdu z przodu (zakładając, że jedzie w tę samą stronę!!!) - auto const k { Obstacle.vehicle->MoverParameters->Vel }; + auto const k { Obstacle.vehicle->physics->Vel }; if( k - vel < 5 ) { // porównanie modułów prędkości [km/h] @@ -298,7 +298,7 @@ TController::adjust_desired_speed_for_obstacles() { Obstacle.distance ); if( Obstacle.distance <= ( - mvOccupied->CategoryFlag & 2 ? + occupied->CategoryFlag & 2 ? 100.0 : // cars 250.0 ) ) { // others // regardless of driving mode at close distance take precaution measures: @@ -308,13 +308,13 @@ TController::adjust_desired_speed_for_obstacles() { VelDesired, std::max( k, - mvOccupied->CategoryFlag & 2 ? + occupied->CategoryFlag & 2 ? 40.0 : // cars 20.0 ) ); // others if( vel > VelDesired + fVelPlus ) { // if going too fast force some prompt braking AccPreferred = std::min( - mvOccupied->CategoryFlag & 2 ? -0.65 : // cars + occupied->CategoryFlag & 2 ? -0.65 : // cars -0.30, // others AccPreferred ); } @@ -343,7 +343,7 @@ TController::adjust_desired_speed_for_obstacles() { VelDesired = 0.0; } - if( mvOccupied->CategoryFlag & 1 + if( occupied->CategoryFlag & 1 && OrderCurrentGet() & DriverOrder::obeyTrain ) { // trains which move normally should try to stop at safe margin ActualProximityDist -= fDriverDist; @@ -353,14 +353,14 @@ TController::adjust_desired_speed_for_obstacles() { else { // jeśli oba jadą, to przyhamuj lekko i ogranicz prędkość if( Obstacle.distance < ( - mvOccupied->CategoryFlag & 2 ? + occupied->CategoryFlag & 2 ? fMaxProximityDist + 0.5 * vel : // cars 2.0 * fMaxProximityDist + 2.0 * vel ) ) { //others // jak tamten jedzie wolniej a jest w drodze hamowania AccPreferred = std::min( -0.9, AccPreferred ); VelNext = min_speed( std::round( k ) - 5.0, VelDesired ); if( Obstacle.distance <= ( - mvOccupied->CategoryFlag & 2 ? + occupied->CategoryFlag & 2 ? fMaxProximityDist : // cars 2.0 * fMaxProximityDist ) ) { //others // try to force speed change if obstacle is really close @@ -368,7 +368,7 @@ TController::adjust_desired_speed_for_obstacles() { } } } - ReactionTime = mvOccupied->Vel > EU07_AI_NOMOVEMENT ? 0.1 : // orientuj się, bo jest goraco + ReactionTime = occupied->Vel > EU07_AI_NOMOVEMENT ? 0.1 : // orientuj się, bo jest goraco 2.0; // we're already standing still, so take it easy } else { @@ -395,12 +395,12 @@ TController::adjust_desired_speed_for_limits() { VelDesired, VelSignal ); } - if( mvOccupied->RunningTrack.Velmax >= 0 ) { + if( occupied->RunningTrack.Velmax >= 0 ) { // ograniczenie prędkości z trajektorii ruchu VelDesired = min_speed( VelDesired, - mvOccupied->RunningTrack.Velmax ); // uwaga na ograniczenia szlakowej! + occupied->RunningTrack.Velmax ); // uwaga na ograniczenia szlakowej! } if( VelforDriver >= 0 ) { // tu jest zero przy zmianie kierunku jazdy @@ -414,7 +414,7 @@ TController::adjust_desired_speed_for_limits() { // recalculate potential load exchange duration check_load_exchange(); if( ExchangeTime > 0 - || mvOccupied->Vel > 2.0 ) { // HACK: force timer reset if the load exchange is cancelled due to departure + || occupied->Vel > 2.0 ) { // HACK: force timer reset if the load exchange is cancelled due to departure WaitingSet( ExchangeTime ); } if( fStopTime < 0 ) { @@ -423,7 +423,7 @@ TController::adjust_desired_speed_for_limits() { return; // speed limit can't get any lower } - if( OrderCurrentGet().HasAny(DriverOrder::shunt | DriverOrder::looseShunt | DriverOrder::obeyTrain | DriverOrder::bank) && drivingFlags.stopHere && mvOccupied->Vel < 0.01 && VelSignalNext == 0.0 ) { + if( OrderCurrentGet().HasAny(DriverOrder::shunt | DriverOrder::looseShunt | DriverOrder::obeyTrain | DriverOrder::bank) && drivingFlags.stopHere && occupied->Vel < 0.01 && VelSignalNext == 0.0 ) { // w Connect nie, bo moveStopHere odnosi się do stanu po połączeniu // jeśli ma czekać na wolną drogę, stoi a wyjazdu nie ma, to ma stać VelDesired = 0.0; @@ -441,7 +441,7 @@ TController::adjust_desired_speed_for_limits() { // its pneumatic brake takes to apply (while speeding up) or to release (while slowing down), which in G // is tens of seconds; never shorter than the look-ahead the AI has always used double -brake_response_horizon( TMoverParameters const *Vehicle, TBrakeSystem const Brakesystem, double const Acceleration, double const Brakea0 ) { +brake_response_horizon( physics::Vehicle const *Vehicle, TBrakeSystem const Brakesystem, double const Acceleration, double const Brakea0 ) { auto horizon { ( 1.0 - Brakea0 ) * 30.0 / 3.6 }; if( Brakesystem == TBrakeSystem::Pneumatic ) { @@ -477,7 +477,7 @@ TController::adjust_desired_speed_for_braking_curve( double const Vel ) { // allow to coast at reasonably low speed auto const brakingdistance { fBrakeDist * braking_distance_multiplier( VelNext ) }; if( auto const slowdowndistance { ( - mvOccupied->CategoryFlag == 2 ? // cars can stop on a dime, for bigger vehicles we enforce some minimal braking distance + occupied->CategoryFlag == 2 ? // cars can stop on a dime, for bigger vehicles we enforce some minimal braking distance brakingdistance : std::max( false == OrderCurrentGet().HasAny(DriverOrder::connect) ? 100.0 : 25.0, @@ -493,7 +493,7 @@ TController::adjust_desired_speed_for_braking_curve( double const Vel ) { VelNext * braking_distance_multiplier( static_cast( VelNext ) ) ); // both plans of a pneumatic brake are made from the brake table of the consist; with none (in shunting it isn't // worked out) the braking curve is the constant deceleration over the distance left, as before them - braking_curve::brake_table const braketable { fBrake_a0, fBrake_a1, BrakeAccTableSize, mvOccupied->Vmax }; + braking_curve::brake_table const braketable { fBrake_a0, fBrake_a1, BrakeAccTableSize, occupied->Vmax }; // making for a passenger stop only the time the brake takes to fill: the look-ahead the horizon // keeps as its floor was set for the stops at a signal, and a vehicle that brakes with its // independent brake, which leaves the train brake handle where it is, kept braking earlier @@ -506,11 +506,11 @@ TController::adjust_desired_speed_for_braking_curve( double const Vel ) { braking_curve::brake_acting( BrakeCtrlPosition, // IncLocalBrakeLevel() moves the independent brake handle on a vehicle without one too - ( mvOccupied->LocalBrake == TLocalBrake::PneumaticBrake || mvOccupied->LocalBrake == TLocalBrake::HydraulicBrake ) ? - mvOccupied->LocalBrakePosA : + ( occupied->LocalBrake == TLocalBrake::PneumaticBrake || occupied->LocalBrake == TLocalBrake::HydraulicBrake ) ? + occupied->LocalBrakePosA : 0.0 ), - brake_response_horizon( mvOccupied, BrakeSystem, AbsAccS, fBrake_a0[ 0 ] ), - brake_response_horizon( mvOccupied, BrakeSystem, 1.0, fillbrakea0 ) }; + brake_response_horizon( occupied, BrakeSystem, AbsAccS, fBrake_a0[ 0 ] ), + brake_response_horizon( occupied, BrakeSystem, 1.0, fillbrakea0 ) }; auto const deceleration { braking_curve::demand( approach, BrakeSystem == TBrakeSystem::Pneumatic ? &braketable : nullptr ) }; AccDesired = std::min( AccDesired, deceleration ); // najpierw hamuje mocniej, potem zluzuje if( Vel <= VelNext ) { @@ -535,7 +535,7 @@ TController::adjust_desired_speed_for_braking_curve( double const Vel ) { void TController::adjust_desired_speed_for_final_approach( double const Vel ) { - if( ( mvOccupied->CategoryFlag & 1 ) == 0 ) { + if( ( occupied->CategoryFlag & 1 ) == 0 ) { // for cars (and others) coast at low speed until we hit min proximity range VelDesired = min_speed( VelDesired, 5.0 ); return; @@ -564,7 +564,7 @@ TController::adjust_desired_speed_for_final_approach( double const Vel ) { // cast iron blocks grip harder as the train comes to a stand braking_curve::shaped_demand( Vel, VelNext, stoppingroom, fAccGravity, - { fBrake_a0, fBrake_a1, BrakeAccTableSize, mvOccupied->Vmax } ) : + { fBrake_a0, fBrake_a1, BrakeAccTableSize, occupied->Vmax } ) : ( VelNext * VelNext - Vel * Vel ) / ( 25.92 * stoppingroom ) ); if( ( fAccGravity < -0.025 ) && ( AccDesired >= fAccGravity - 0.001 ) // no brake needed at all @@ -653,7 +653,7 @@ TController::adjust_desired_speed_for_target_speed( double const Range ) { else { // jeśli daleko jechać nie można if( ActualProximityDist > ( - mvOccupied->CategoryFlag & 2 ? + occupied->CategoryFlag & 2 ? fMinProximityDist : // cars fMaxProximityDist ) ) { // trains and others // ale ma kawałek do sygnalizatora @@ -709,7 +709,7 @@ TController::adjust_desired_speed_for_current_speed() { // look ahead for as long as the brake takes to respond, since that is how long the // present acceleration will last whatever is done with the handle now; a pneumatic // brake applies and releases on its own time scale, which in G is tens of seconds - auto const horizon { brake_response_horizon( mvOccupied, BrakeSystem, AbsAccS, fBrake_a0[ 0 ] ) }; + auto const horizon { brake_response_horizon( occupied, BrakeSystem, AbsAccS, fBrake_a0[ 0 ] ) }; auto const speedestimate = vel + 3.6 * horizon * AbsAccS; // already below a lower limit ahead, the train has no business speeding up towards it auto holdlimit { VelDesired }; @@ -763,7 +763,7 @@ TController::adjust_desired_speed_for_current_speed() { } } // HACK: limit acceleration for cargo trains, to reduce probability of breaking couplers on sudden jolts - auto MaxAcc{ 0.5 * mvOccupied->Couplers[(mvOccupied->DirAbsolute >= 0 ? VehicleEnd::rear : VehicleEnd::front)].FmaxC / fMass }; + auto MaxAcc{ 0.5 * occupied->Couplers[(occupied->DirAbsolute >= 0 ? VehicleEnd::rear : VehicleEnd::front)].FmaxC / fMass }; if( iVehicles - ControlledEnginesCount > 0 ) { MaxAcc *= std::clamp( vel * 0.025, 0.2, 1.0 ); } @@ -821,7 +821,7 @@ TController::adjust_desired_speed_for_braking_test() { if( ( DynamicBrakeTest == 0 ) && ( false == timetable::makes_brake_test( TrainParams.run_flags() ) ) ) { return; } // the timetable says there's none (eu07/maszyna#95) if( false == is_train() ) { return; } // not applicable - if( mvOccupied->BrakeHandle == TBrakeHandle::FVel6 ) { return; } // leads to bugs in DecBrake, disable for now + if( occupied->BrakeHandle == 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? @@ -851,7 +851,7 @@ TController::adjust_desired_speed_for_braking_test() { VelDesired = DBT_VelocityBrake; if( ElapsedTime - DBT_BrakingTime > 1 ) { ForcePNBrake = true; - mvOccupied->EpFuseSwitch( false ); + occupied->EpFuseSwitch( false ); DynamicBrakeTest = 2; } break; @@ -883,7 +883,7 @@ TController::adjust_desired_speed_for_braking_test() { case 4: { if( Ready ) { if( BrakeSystem == TBrakeSystem::ElectroPneumatic ) { - mvOccupied->EpFuseSwitch( true ); + occupied->EpFuseSwitch( true ); } ForcePNBrake = false; DynamicBrakeTest = 5; diff --git a/vehicle/ai/speedpos.cpp b/vehicle/ai/speedpos.cpp index 0fb3b73b1..f783e4591 100644 --- a/vehicle/ai/speedpos.cpp +++ b/vehicle/ai/speedpos.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" diff --git a/vehicle/ai/speedtable.cpp b/vehicle/ai/speedtable.cpp index 12fa2f964..c778c3199 100644 --- a/vehicle/ai/speedtable.cpp +++ b/vehicle/ai/speedtable.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" @@ -78,7 +78,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN IsAtPassengerStop = false; bStopTargetIsPassengerStop = false; IsScheduledPassengerStopVisible = false; - mvOccupied->SecuritySystem.set_cabsignal_lock(false); + occupied->SecuritySystem.set_cabsignal_lock(false); // te flagi są ustawiane tutaj, w razie potrzeby drivingFlags.trackEnd = false; drivingFlags.switchFound = false; @@ -121,7 +121,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN && ( false == point.flags.HasAll(SpeedPointFlag::elapsed) || ispointlimit ) ) { // sygnał lub ograniczenie z przodu (+32=przejechane) // 2014-02: jeśli stoi, a ma do przejechania kawałek, to niech jedzie - if( mvOccupied->Vel < 0.01 + if( occupied->Vel < 0.01 && true == point.flags.HasAll(SpeedPointFlag::enabled | SpeedPointFlag::event | SpeedPointFlag::passengerStop) && false == IsAtPassengerStop ) { // ma podjechać bliżej - czy na pewno w tym miejscu taki warunek? @@ -130,8 +130,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN else { // przyspieszenie: ujemne, gdy trzeba hamować if( v >= 0.0 ) { - a = ( v * v - mvOccupied->Vel * mvOccupied->Vel ) / ( 25.92 * d ); - if( mvOccupied->Vel < v + a = ( v * v - occupied->Vel * occupied->Vel ) / ( 25.92 * d ); + if( occupied->Vel < v || v == 0.0 ) { // if we're going slower than the target velocity and there's enough room for safe stop, speed up auto const brakingdistance { 1.2 * fBrakeDist * braking_distance_multiplier( v ) }; @@ -174,7 +174,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN // event trzyma tylko jeśli VelNext=0, nawet po przejechaniu (nie powinno dotyczyć samochodów?) a = v > 0.0 ? fAcc : - mvOccupied->Vel < 0.01 ? + occupied->Vel < 0.01 ? 0.0 : // already standing still so no need to bother with brakes -2.0; // ruszanie albo hamowanie } @@ -184,7 +184,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN if( railwaytrackend ) { // if the railway track ends here set the velnext accordingly as well // TODO: test this with turntables and such - auto const stopatendacceleration = -1.0 * mvOccupied->Vel * mvOccupied->Vel / ( 25.92 * ( d + point.trTrack->Length() ) ); + auto const stopatendacceleration = -1.0 * occupied->Vel * occupied->Vel / ( 25.92 * ( d + point.trTrack->Length() ) ); if( stopatendacceleration < a ) { a = stopatendacceleration; v = 0.0; @@ -279,7 +279,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN //analiza spisanych z tabelki ograniczeń i nadpisanie aktualnego // if stopped at a valid passenger stop, hold there - if( true == IsAtPassengerStop && mvOccupied->Vel < 0.01 ) { + if( true == IsAtPassengerStop && occupied->Vel < 0.01 ) { fVelDes = 0.0; } else { @@ -350,7 +350,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub pVehicle->asName, TrainParams.TrainName, simulation::Time.data().wHour, simulation::Time.data().wMinute, asNextStop)); // informacja #endif // przy jakim dystansie (stanie licznika) ma przesunąć na następny postój - fLastStopExpDist = mvOccupied->DistCounter + 0.250 + 0.001 * fLength; + fLastStopExpDist = occupied->DistCounter + 0.250 + 0.001 * fLength; TrainParams.UpdateMTable( simulation::Time, asNextStop ); record_station( Point, blackbox::station_kinds::passed ); UpdateDelayFlag(); @@ -427,7 +427,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub //jeśli nie widzi następnego sygnału ustawia dotychczasową eSignNext = Point.evEvent; } - if( mvOccupied->Vel > EU07_AI_MOVEMENT ) { + if( occupied->Vel > EU07_AI_MOVEMENT ) { // jeśli jedzie (nie trzeba czekać, aż się drgania wytłumią - drzwi zamykane od 1.0) to będzie zatrzymanie Point.fVelNext = 0; // potentially announce pending stop @@ -517,7 +517,7 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub IsAtPassengerStop = false; record_station( Point, blackbox::station_kinds::ready ); // przy jakim dystansie (stanie licznika) ma przesunąć na następny postój - fLastStopExpDist = mvOccupied->DistCounter + 0.050 + 0.001 * fLength; + fLastStopExpDist = occupied->DistCounter + 0.050 + 0.001 * fLength; TrainParams.StationIndexInc(); // przejście do następnej asNextStop = TrainParams.NextStop(); // pobranie kolejnego miejsca zatrzymania #if LOGSTOPS @@ -619,7 +619,7 @@ bool TController::is_road_velocity_held( TSpeedPos const &Point ) const { return Point.flags.HasAll(SpeedPointFlag::roadSpeed) - && mvOccupied->CategoryFlag != 2 + && occupied->CategoryFlag != 2 && Point.fDist >= -fLength; } @@ -659,7 +659,7 @@ TController::TableUpdateRoadVelocity( TSpeedPos &Point ) { if( Point.fDist >= 0.0 ) { return false; } - if( mvOccupied->CategoryFlag == 2 ) { + if( occupied->CategoryFlag == 2 ) { VelRoad = Point.fVelNext; return false; } @@ -845,8 +845,8 @@ void TController::apply_point_limits( double &Velocity, double &Distance, double // the same as for a point of the speed table ahead auto const v { limit.velocity }; auto const d { limit.distance }; - auto a { ( v * v - mvOccupied->Vel * mvOccupied->Vel ) / ( 25.92 * d ) }; - if( mvOccupied->Vel < v ) { + auto a { ( v * v - occupied->Vel * occupied->Vel ) / ( 25.92 * d ) }; + if( occupied->Vel < v ) { auto const brakingdistance { 1.2 * fBrakeDist * braking_distance_multiplier( v ) }; if( brakingdistance > 0.0 ) { a = std::lerp( a, AccPreferred, std::clamp( ( d - brakingdistance ) / brakingdistance, 0.0, 1.0 ) ); @@ -869,7 +869,7 @@ double TController::point_limit_approach() const { // a point limit holds at its point and not a metre beyond, so the braking curve alone leaves a slow consist // coasting above it (the deceleration asked for is below what makes the driver brake). within the final // approach, and five seconds of the present speed before it, the speed is held down to it already - return fMaxProximityDist + mvOccupied->Vel / 3.6 * 5.0; + return fMaxProximityDist + occupied->Vel / 3.6 * 5.0; } glm::dvec3 TController::travel_direction() const { @@ -943,19 +943,19 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo case TCommandType::cm_SecuritySystemMagnet: { // NOTE: magnet induction calculation presumes the driver is located in the front vehicle // TBD, TODO: take into account actual position of controlled/occupied vehicle in the consist, whichever comes first - auto const magnetlocation { pVehicles[ VehicleEnd::front ]->MoverParameters->SecuritySystem.MagnetLocation }; + auto const magnetlocation { pVehicles[ VehicleEnd::front ]->physics->SecuritySystem.MagnetLocation }; auto const magnetrange { 1.0 }; auto const ismagnetpassed { Point.fDist < -( magnetlocation + magnetrange ) }; - if( Point.fDist < -magnetlocation && (mvOccupied->Vel > EU07_AI_NOMOVEMENT || false == ismagnetpassed) ) { + if( Point.fDist < -magnetlocation && (occupied->Vel > EU07_AI_NOMOVEMENT || false == ismagnetpassed) ) { // 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) - mvOccupied->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(!AIControllFlag); // 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 ) { Point.Clear(); - mvOccupied->SecuritySystem.set_cabsignal_lock(false); + occupied->SecuritySystem.set_cabsignal_lock(false); } return true; } @@ -986,7 +986,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo if( is_car() && Point.fVelNext != -1.0 && Point.fVelNext < 1.0 - && Point.fDist < -0.5 + std::min(fBrakeDist * 0.2, mvOccupied->Vel * 0.2) ) { + && Point.fDist < -0.5 + std::min(fBrakeDist * 0.2, occupied->Vel * 0.2) ) { Point.Clear(); return true; } @@ -1038,7 +1038,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo } else if ( Point.flags & SpeedPointFlag::stopOnAutomaticBlock) { // jeśli S1 na SBL - if( mvOccupied->Vel < 2.0 && Point.fDist < fMaxProximityDist && Obstacle.distance > 1000 ) { + if( occupied->Vel < 2.0 && Point.fDist < fMaxProximityDist && Obstacle.distance > 1000 ) { // stanąć nie musi, ale zwolnić przynajmniej // jest w maksymalnym zasięgu to można go pominąć (wziąć drugą prędkosć) // as long as there isn't any obstacle in arbitrary view range diff --git a/vehicle/brakesetting.cpp b/vehicle/brakesetting.cpp index 3b06835f9..42be6738c 100644 --- a/vehicle/brakesetting.cpp +++ b/vehicle/brakesetting.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/brakesetting.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "physics/brakes.h" #include "vehicle/Driver.h" @@ -248,11 +248,11 @@ std::vector choose_legacy(std::vector const &Consist) { return settings; } -bool is_cut_out(TMoverParameters const &Vehicle) { +bool is_cut_out(physics::Vehicle const &Vehicle) { return (Vehicle.Hamulec->GetBrakeStatus() & b_dmg) == b_dmg; } -vehicle describe(TMoverParameters const &Vehicle, bool const Driven) { +vehicle describe(physics::Vehicle const &Vehicle, bool const Driven) { vehicle described; described.delays = Vehicle.BrakeDelays; // a locomotive has Power > 1, though it may be a dead one at the end of the train @@ -264,7 +264,7 @@ vehicle describe(TMoverParameters const &Vehicle, bool const Driven) { return described; } -bool apply(TMoverParameters &Vehicle, int const Setting, bool const Standstill) { +bool apply(physics::Vehicle &Vehicle, int const Setting, bool const Standstill) { auto &brake{*Vehicle.Hamulec}; if (Vehicle.BrakeCutOutByInspector && false == is_cut_out(Vehicle)) { // someone put the brake back in the meantime, it's theirs now diff --git a/vehicle/brakesetting.h b/vehicle/brakesetting.h index 9bb46d9da..d54075110 100644 --- a/vehicle/brakesetting.h +++ b/vehicle/brakesetting.h @@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/driverorders.h" -class TMoverParameters; +namespace physics { class Vehicle; } // the brake setting (G/P/R/Mg) the virtual wagon inspector (TController::AutoRewident) chooses for every // vehicle of a train, by the rules of the brake instruction Cw-1 (Mw56), §18 and §19 (eu07/maszyna#350) @@ -89,11 +89,11 @@ bool at_standstill(double Velocity); std::vector choose_legacy(std::vector const &Consist); // the brake of the vehicle is cut out (b_dmg), whoever did it -bool is_cut_out(TMoverParameters const &Vehicle); +bool is_cut_out(physics::Vehicle const &Vehicle); // what choose() needs to know of the vehicle. a brake the inspector cut out itself doesn't count as // cut out: the inspector decides about it anew -vehicle describe(TMoverParameters const &Vehicle, bool Driven); +vehicle describe(physics::Vehicle const &Vehicle, bool Driven); // the inspector puts the vehicle on Setting, as choose() gives it. cut_out cuts the brake out the way // the scenery's '0' does: b_dmg, which cuts the distributor off the brake pipe (as the cab's cut-out, @@ -105,6 +105,6 @@ vehicle describe(TMoverParameters const &Vehicle, bool Driven); // setting as it is). A brake cut out by anyone else stays cut out. // Returns true when a cut-out was left for later because the train was moving: the inspector has to look // at the train again once it stands (TController::reinspect_brakes() does) -bool apply(TMoverParameters &Vehicle, int Setting, bool Standstill); +bool apply(physics::Vehicle &Vehicle, int Setting, bool Standstill); } // namespace brake_setting diff --git a/vehicle/cab/auxiliarycommands.cpp b/vehicle/cab/auxiliarycommands.cpp index 92685e888..0c9804c6c 100644 --- a/vehicle/cab/auxiliarycommands.cpp +++ b/vehicle/cab/auxiliarycommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -69,7 +69,7 @@ void TTrain::OnCommand_fuelpumptoggle(TTrain *Train, command_data const &Command return; } - if (false == Train->mvControlled->FuelPump.is_enabled) + if (false == Train->controlled->FuelPump.is_enabled) { // turn on OnCommand_fuelpumpenable(Train, Command); @@ -97,13 +97,13 @@ void TTrain::OnCommand_fuelpumpenable(TTrain *Train, command_data const &Command { // visual feedback Train->ggFuelPumpButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->FuelPumpSwitch(true); + Train->controlled->FuelPumpSwitch(true); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggFuelPumpButton.UpdateValue(0.0, Train->dsbSwitch); - Train->mvControlled->FuelPumpSwitch(false); + Train->controlled->FuelPumpSwitch(false); } } else @@ -113,8 +113,8 @@ void TTrain::OnCommand_fuelpumpenable(TTrain *Train, command_data const &Command { // visual feedback Train->ggFuelPumpButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->FuelPumpSwitch(true); - Train->mvControlled->FuelPumpSwitchOff(false); + Train->controlled->FuelPumpSwitch(true); + Train->controlled->FuelPumpSwitchOff(false); } } } @@ -140,8 +140,8 @@ void TTrain::OnCommand_fuelpumpdisable(TTrain *Train, command_data const &Comman { // visual feedback Train->ggFuelPumpButton.UpdateValue(0.0, Train->dsbSwitch); - Train->mvControlled->FuelPumpSwitch(false); - Train->mvControlled->FuelPumpSwitchOff(true); + Train->controlled->FuelPumpSwitch(false); + Train->controlled->FuelPumpSwitchOff(true); } } } @@ -168,7 +168,7 @@ void TTrain::OnCommand_oilpumptoggle(TTrain *Train, command_data const &Command) return; } - if (false == Train->mvControlled->OilPump.is_enabled) + if (false == Train->controlled->OilPump.is_enabled) { // turn on OnCommand_oilpumpenable(Train, Command); @@ -196,13 +196,13 @@ void TTrain::OnCommand_oilpumpenable(TTrain *Train, command_data const &Command) { // visual feedback Train->ggOilPumpButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->OilPumpSwitch(true); + Train->controlled->OilPumpSwitch(true); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggOilPumpButton.UpdateValue(0.0, Train->dsbSwitch); - Train->mvControlled->OilPumpSwitch(false); + Train->controlled->OilPumpSwitch(false); } } else @@ -212,8 +212,8 @@ void TTrain::OnCommand_oilpumpenable(TTrain *Train, command_data const &Command) { // visual feedback Train->ggOilPumpButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->OilPumpSwitch(true); - Train->mvControlled->OilPumpSwitchOff(false); + Train->controlled->OilPumpSwitch(true); + Train->controlled->OilPumpSwitchOff(false); } } } @@ -239,8 +239,8 @@ void TTrain::OnCommand_oilpumpdisable(TTrain *Train, command_data const &Command { // visual feedback Train->ggOilPumpButton.UpdateValue(0.0, Train->dsbSwitch); - Train->mvControlled->OilPumpSwitch(false); - Train->mvControlled->OilPumpSwitchOff(true); + Train->controlled->OilPumpSwitch(false); + Train->controlled->OilPumpSwitchOff(true); } } } @@ -252,7 +252,7 @@ void TTrain::OnCommand_oilfuelpumptoggle(TTrain *Train, command_data const &Comm return; } - auto *vehicle{Train->mvControlled}; + auto *vehicle{Train->controlled}; if (Train->ggOilFuelPumpButton.type() == TGaugeType::push) { // impulse switch, as the separate ones: held to start both pumps @@ -283,7 +283,7 @@ void TTrain::OnCommand_tractionmodetoggle(TTrain *Train, command_data const &Com { return; } - if (Train->mvControlled->GensetSelected()) + if (Train->controlled->GensetSelected()) { OnCommand_tractionmodecatenary(Train, Command); } @@ -300,8 +300,8 @@ void TTrain::OnCommand_tractionmodecatenary(TTrain *Train, command_data const &C return; } // refused with the line breaker closed: then the switch doesn't move - Train->mvControlled->TractionModeSwitch(TMoverParameters::traction_mode::catenary, range_t::consist); - if (false == Train->mvControlled->GensetSelected()) + Train->controlled->TractionModeSwitch(physics::Vehicle::traction_mode::catenary, range_t::consist); + if (false == Train->controlled->GensetSelected()) { Train->ggTractionModeSwitch.UpdateValue(0.0, Train->dsbSwitch); } @@ -314,8 +314,8 @@ void TTrain::OnCommand_tractionmodegenset(TTrain *Train, command_data const &Com return; } // refused with the line breaker closed, or without a genset: then the switch doesn't move - Train->mvControlled->TractionModeSwitch(TMoverParameters::traction_mode::genset, range_t::consist); - if (Train->mvControlled->GensetSelected()) + Train->controlled->TractionModeSwitch(physics::Vehicle::traction_mode::genset, range_t::consist); + if (Train->controlled->GensetSelected()) { Train->ggTractionModeSwitch.UpdateValue(1.0, Train->dsbSwitch); } @@ -328,7 +328,7 @@ void TTrain::OnCommand_gensettoggle(TTrain *Train, command_data const &Command) { return; } - if (false == Train->mvControlled->Genset.is_enabled) + if (false == Train->controlled->Genset.is_enabled) { OnCommand_gensetenable(Train, Command); } @@ -345,8 +345,8 @@ void TTrain::OnCommand_gensetenable(TTrain *Train, command_data const &Command) return; } // ignored by a genset which starts on its own: then the switch doesn't move - Train->mvControlled->GensetSwitch(true, range_t::consist); - if (Train->mvControlled->Genset.is_enabled) + Train->controlled->GensetSwitch(true, range_t::consist); + if (Train->controlled->Genset.is_enabled) { Train->ggGensetButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -358,8 +358,8 @@ void TTrain::OnCommand_gensetdisable(TTrain *Train, command_data const &Command) { return; } - Train->mvControlled->GensetSwitch(false, range_t::consist); - if (false == Train->mvControlled->Genset.is_enabled) + Train->controlled->GensetSwitch(false, range_t::consist); + if (false == Train->controlled->Genset.is_enabled) { Train->ggGensetButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -371,7 +371,7 @@ void TTrain::OnCommand_waterheaterbreakertoggle(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvControlled->WaterHeater.breaker) + if (false == Train->controlled->WaterHeater.breaker) { // turn on OnCommand_waterheaterbreakerclose(Train, Command); @@ -392,12 +392,12 @@ void TTrain::OnCommand_waterheaterbreakerclose(TTrain *Train, command_data const // visual feedback Train->ggWaterHeaterBreakerButton.UpdateValue(1.0, Train->dsbSwitch); - if (true == Train->mvControlled->WaterHeater.breaker) + if (true == Train->controlled->WaterHeater.breaker) { return; } // already enabled - Train->mvControlled->WaterHeaterBreakerSwitch(true); + Train->controlled->WaterHeaterBreakerSwitch(true); } } @@ -409,12 +409,12 @@ void TTrain::OnCommand_waterheaterbreakeropen(TTrain *Train, command_data const // visual feedback Train->ggWaterHeaterBreakerButton.UpdateValue(0.0, Train->dsbSwitch); - if (false == Train->mvControlled->WaterHeater.breaker) + if (false == Train->controlled->WaterHeater.breaker) { return; } // already enabled - Train->mvControlled->WaterHeaterBreakerSwitch(false); + Train->controlled->WaterHeaterBreakerSwitch(false); } } @@ -424,7 +424,7 @@ void TTrain::OnCommand_waterheatertoggle(TTrain *Train, command_data const &Comm if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvControlled->WaterHeater.is_enabled) + if (false == Train->controlled->WaterHeater.is_enabled) { // turn on OnCommand_waterheaterenable(Train, Command); @@ -445,12 +445,12 @@ void TTrain::OnCommand_waterheaterenable(TTrain *Train, command_data const &Comm // visual feedback Train->ggWaterHeaterButton.UpdateValue(1.0, Train->dsbSwitch); - if (true == Train->mvControlled->WaterHeater.is_enabled) + if (true == Train->controlled->WaterHeater.is_enabled) { return; } // already enabled - Train->mvControlled->WaterHeaterSwitch(true); + Train->controlled->WaterHeaterSwitch(true); } } @@ -462,12 +462,12 @@ void TTrain::OnCommand_waterheaterdisable(TTrain *Train, command_data const &Com // visual feedback Train->ggWaterHeaterButton.UpdateValue(0.0, Train->dsbSwitch); - if (false == Train->mvControlled->WaterHeater.is_enabled) + if (false == Train->controlled->WaterHeater.is_enabled) { return; } // already disabled - Train->mvControlled->WaterHeaterSwitch(false); + Train->controlled->WaterHeaterSwitch(false); } } @@ -477,7 +477,7 @@ void TTrain::OnCommand_waterpumpbreakertoggle(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvControlled->WaterPump.breaker) + if (false == Train->controlled->WaterPump.breaker) { // turn on OnCommand_waterpumpbreakerclose(Train, Command); @@ -498,12 +498,12 @@ void TTrain::OnCommand_waterpumpbreakerclose(TTrain *Train, command_data const & // visual feedback Train->ggWaterPumpBreakerButton.UpdateValue(1.0, Train->dsbSwitch); - if (true == Train->mvControlled->WaterPump.breaker) + if (true == Train->controlled->WaterPump.breaker) { return; } // already enabled - Train->mvControlled->WaterPumpBreakerSwitch(true); + Train->controlled->WaterPumpBreakerSwitch(true); } } @@ -515,12 +515,12 @@ void TTrain::OnCommand_waterpumpbreakeropen(TTrain *Train, command_data const &C // visual feedback Train->ggWaterPumpBreakerButton.UpdateValue(0.0, Train->dsbSwitch); - if (false == Train->mvControlled->WaterPump.breaker) + if (false == Train->controlled->WaterPump.breaker) { return; } // already enabled - Train->mvControlled->WaterPumpBreakerSwitch(false); + Train->controlled->WaterPumpBreakerSwitch(false); } } @@ -546,7 +546,7 @@ void TTrain::OnCommand_waterpumptoggle(TTrain *Train, command_data const &Comman return; } - if (false == Train->mvControlled->WaterPump.is_enabled) + if (false == Train->controlled->WaterPump.is_enabled) { // turn on OnCommand_waterpumpenable(Train, Command); @@ -574,13 +574,13 @@ void TTrain::OnCommand_waterpumpenable(TTrain *Train, command_data const &Comman { // visual feedback Train->ggWaterPumpButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->WaterPumpSwitch(true); + Train->controlled->WaterPumpSwitch(true); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggWaterPumpButton.UpdateValue(0.0, Train->dsbSwitch); - Train->mvControlled->WaterPumpSwitch(false); + Train->controlled->WaterPumpSwitch(false); } } else @@ -590,8 +590,8 @@ void TTrain::OnCommand_waterpumpenable(TTrain *Train, command_data const &Comman { // visual feedback Train->ggWaterPumpButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->WaterPumpSwitch(true); - Train->mvControlled->WaterPumpSwitchOff(false); + Train->controlled->WaterPumpSwitch(true); + Train->controlled->WaterPumpSwitchOff(false); } } } @@ -617,8 +617,8 @@ void TTrain::OnCommand_waterpumpdisable(TTrain *Train, command_data const &Comma { // visual feedback Train->ggWaterPumpButton.UpdateValue(0.0, Train->dsbSwitch); - Train->mvControlled->WaterPumpSwitch(false); - Train->mvControlled->WaterPumpSwitchOff(true); + Train->controlled->WaterPumpSwitch(false); + Train->controlled->WaterPumpSwitchOff(true); } } } @@ -629,7 +629,7 @@ void TTrain::OnCommand_watercircuitslinktoggle(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvControlled->WaterCircuitsLink) + if (false == Train->controlled->WaterCircuitsLink) { // turn on OnCommand_watercircuitslinkenable(Train, Command); @@ -650,12 +650,12 @@ void TTrain::OnCommand_watercircuitslinkenable(TTrain *Train, command_data const // visual feedback Train->ggWaterCircuitsLinkButton.UpdateValue(1.0, Train->dsbSwitch); - if (true == Train->mvControlled->WaterCircuitsLink) + if (true == Train->controlled->WaterCircuitsLink) { return; } // already enabled - Train->mvControlled->WaterCircuitsLinkSwitch(true); + Train->controlled->WaterCircuitsLinkSwitch(true); } } @@ -667,12 +667,12 @@ void TTrain::OnCommand_watercircuitslinkdisable(TTrain *Train, command_data cons // visual feedback Train->ggWaterCircuitsLinkButton.UpdateValue(0.0, Train->dsbSwitch); - if (false == Train->mvControlled->WaterCircuitsLink) + if (false == Train->controlled->WaterCircuitsLink) { return; } // already disabled - Train->mvControlled->WaterCircuitsLinkSwitch(false); + Train->controlled->WaterCircuitsLinkSwitch(false); } } @@ -682,9 +682,9 @@ 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->mvOccupied->ConvOvldFlag)}; + auto const overloadrelayisopen{(Train->Dynamic()->Mechanik != nullptr ? Train->Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : Train->occupied->ConvOvldFlag)}; - if (Train->mvOccupied->ConvSwitchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->mvOccupied->Power110vIsAvailable && false == overloadrelayisopen) + if (Train->occupied->ConvSwitchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->occupied->Power110vIsAvailable && false == overloadrelayisopen) { // turn on OnCommand_converterenable(Train, Command); @@ -698,7 +698,7 @@ void TTrain::OnCommand_convertertoggle(TTrain *Train, command_data const &Comman else if (Command.action == GLFW_RELEASE) { // on button release... - if (Train->mvOccupied->ConvSwitchType == "impulse") + if (Train->occupied->ConvSwitchType == "impulse") { // ...return switches to start position if applicable Train->ggConverterButton.UpdateValue(0.0, Train->dsbSwitch); @@ -717,10 +717,10 @@ void TTrain::OnCommand_converterenable(TTrain *Train, command_data const &Comman // impulse type switch has no effect if there's no power // NOTE: this is most likely setup wrong, but the whole thing is smoke and mirrors anyway - if (Train->mvOccupied->ConvSwitchType != "impulse" || Train->mvControlled->Mains) + if (Train->occupied->ConvSwitchType != "impulse" || Train->controlled->Mains) { // won't start if the line breaker button is still held - Train->mvOccupied->ConverterSwitch(true); + Train->occupied->ConverterSwitch(true); } } else if (Command.action == GLFW_RELEASE) @@ -742,7 +742,7 @@ void TTrain::OnCommand_converterdisable(TTrain *Train, command_data const &Comma Train->ggConverterOffButton.UpdateValue(1.0, Train->dsbSwitch); } - Train->mvOccupied->ConverterSwitch(false); + Train->occupied->ConverterSwitch(false); } else if (Command.action == GLFW_RELEASE) { @@ -754,7 +754,7 @@ void TTrain::OnCommand_converterdisable(TTrain *Train, command_data const &Comma void TTrain::OnCommand_convertertogglelocal(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->ConverterStart == start_t::automatic) + if (Train->occupied->ConverterStart == start_t::automatic) { // let the automatic thing do its automatic thing... return; @@ -767,20 +767,20 @@ void TTrain::OnCommand_convertertogglelocal(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvOccupied->ConverterAllowLocal && Train->ggConverterLocalButton.GetValue() < 0.5) + if (false == Train->occupied->ConverterAllowLocal && Train->ggConverterLocalButton.GetValue() < 0.5) { // turn on // visual feedback Train->ggConverterLocalButton.UpdateValue(1.0, Train->dsbSwitch); // effect - Train->mvOccupied->ConverterAllowLocal = true; + Train->occupied->ConverterAllowLocal = true; /* - if( true == Train->mvControlled->ConverterSwitch( true, range::local ) ) { + if( true == Train->controlled->ConverterSwitch( true, range::local ) ) { // side effects // control the compressor, if it's paired with the converter - if( Train->mvControlled->CompressorPower == 2 ) { + if( Train->controlled->CompressorPower == 2 ) { // hunter-091012: tak jest poprawnie - Train->mvControlled->CompressorSwitch( true, range::local ); + Train->controlled->CompressorSwitch( true, range::local ); } } */ @@ -791,19 +791,19 @@ void TTrain::OnCommand_convertertogglelocal(TTrain *Train, command_data const &C // visual feedback Train->ggConverterLocalButton.UpdateValue(0.0, Train->dsbSwitch); // effect - Train->mvOccupied->ConverterAllowLocal = false; + Train->occupied->ConverterAllowLocal = false; /* - if( true == Train->mvControlled->ConverterSwitch( false, range::local ) ) { + if( true == Train->controlled->ConverterSwitch( false, range::local ) ) { // side effects // control the compressor, if it's paired with the converter - if( Train->mvControlled->CompressorPower == 2 ) { + if( Train->controlled->CompressorPower == 2 ) { // hunter-091012: tak jest poprawnie - Train->mvControlled->CompressorSwitch( false, range::local ); + Train->controlled->CompressorSwitch( false, range::local ); } // if there's no (low voltage) power source left, drop pantographs - if( false == Train->mvControlled->Battery ) { - Train->mvControlled->PantFront( false, range::local ); - Train->mvControlled->PantRear( false, range::local ); + if( false == Train->controlled->Battery ) { + Train->controlled->PantFront( false, range::local ); + Train->controlled->PantRear( false, range::local ); } } */ @@ -828,7 +828,7 @@ void TTrain::OnCommand_converteroverloadrelayreset(TTrain *Train, command_data c // visual feedback Train->ggConverterFuseButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->RelayReset(relay_t::primaryconverteroverload); + Train->controlled->RelayReset(relay_t::primaryconverteroverload); } else if (Command.action == GLFW_RELEASE) { @@ -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->mvOccupied->CompressorAllow)}; + auto const compressorisenabled{(Train->Dynamic()->Mechanik ? Train->Dynamic()->Mechanik->IsAnyCompressorEnabled : Train->occupied->CompressorAllow)}; if (false == compressorisenabled) { @@ -860,7 +860,7 @@ void TTrain::OnCommand_compressortoggle(TTrain *Train, command_data const &Comma // disabled because we don't have yet support for compressor switch type definition else if( Command.action == GLFW_RELEASE ) { // on button release... - if( Train->mvOccupied->CompSwitchType == "impulse" ) { + if( Train->occupied->CompSwitchType == "impulse" ) { // ...return switches to start position if applicable Train->ggCompressorButton.UpdateValue( 0.0, Train->dsbSwitch ); Train->ggCompressorOffButton.UpdateValue( 0.0, Train->dsbSwitch ); @@ -879,10 +879,10 @@ void TTrain::OnCommand_compressorenable(TTrain *Train, command_data const &Comma // impulse type switch has no effect if there's no power // NOTE: this is most likely setup wrong, but the whole thing is smoke and mirrors anyway - // if( ( Train->mvOccupied->CompSwitchType != "impulse" ) - // || ( Train->mvControlled->Mains ) ) { + // if( ( Train->occupied->CompSwitchType != "impulse" ) + // || ( Train->controlled->Mains ) ) { - Train->mvOccupied->CompressorSwitch(true); + Train->occupied->CompressorSwitch(true); // } } else if (Command.action == GLFW_RELEASE) @@ -895,7 +895,7 @@ void TTrain::OnCommand_compressorenable(TTrain *Train, command_data const &Comma void TTrain::OnCommand_compressordisable(TTrain *Train, command_data const &Command) { - if (Train->mvControlled->CompressorPower >= 2) + if (Train->controlled->CompressorPower >= 2) { return; } @@ -909,7 +909,7 @@ void TTrain::OnCommand_compressordisable(TTrain *Train, command_data const &Comm Train->ggCompressorOffButton.UpdateValue( 1.0, Train->dsbSwitch ); } */ - Train->mvOccupied->CompressorSwitch(false); + Train->occupied->CompressorSwitch(false); } else if (Command.action == GLFW_RELEASE) { @@ -921,7 +921,7 @@ void TTrain::OnCommand_compressordisable(TTrain *Train, command_data const &Comm void TTrain::OnCommand_compressortogglelocal(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->CompressorPower >= 2) + if (Train->occupied->CompressorPower >= 2) { return; } @@ -933,13 +933,13 @@ void TTrain::OnCommand_compressortogglelocal(TTrain *Train, command_data const & if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvOccupied->CompressorAllowLocal) + if (false == Train->occupied->CompressorAllowLocal) { // turn on // visual feedback Train->ggCompressorLocalButton.UpdateValue(1.0, Train->dsbSwitch); // effect - Train->mvOccupied->CompressorAllowLocal = true; + Train->occupied->CompressorAllowLocal = true; } else { @@ -947,7 +947,7 @@ void TTrain::OnCommand_compressortogglelocal(TTrain *Train, command_data const & // visual feedback Train->ggCompressorLocalButton.UpdateValue(0.0, Train->dsbSwitch); // effect - Train->mvOccupied->CompressorAllowLocal = false; + Train->occupied->CompressorAllowLocal = false; } } } @@ -955,7 +955,7 @@ void TTrain::OnCommand_compressortogglelocal(TTrain *Train, command_data const & void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->CompressorListPosNo == 0) + if (Train->occupied->CompressorListPosNo == 0) { return; } @@ -967,14 +967,14 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data if (Train->ggCompressorListButton.type() == TGaugeType::push) { // impulse switch - if (Train->mvOccupied->CompressorListPosNo < Train->mvOccupied->CompressorListDefPos + 1) + if (Train->occupied->CompressorListPosNo < Train->occupied->CompressorListDefPos + 1) { return; } - Train->mvOccupied->ChangeCompressorPreset(Command.action == GLFW_PRESS ? Train->mvOccupied->CompressorListDefPos + 1 : Train->mvOccupied->CompressorListDefPos); + Train->occupied->ChangeCompressorPreset(Command.action == GLFW_PRESS ? Train->occupied->CompressorListDefPos + 1 : Train->occupied->CompressorListDefPos); // visual feedback - Train->ggCompressorListButton.UpdateValue(static_cast(Train->mvOccupied->CompressorListPos - 1), Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->CompressorListPos - 1), Train->dsbSwitch); } else { @@ -984,12 +984,12 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data return; } - if (Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo || true == Train->mvOccupied->CompressorListWrap) + if (Train->occupied->CompressorListPos < Train->occupied->CompressorListPosNo || true == Train->occupied->CompressorListWrap) { // active light preset is stored as value in range 1-LigthPosNo - Train->mvOccupied->ChangeCompressorPreset(Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo ? Train->mvOccupied->CompressorListPos + 1 : 1); // wrap mode + Train->occupied->ChangeCompressorPreset(Train->occupied->CompressorListPos < Train->occupied->CompressorListPosNo ? Train->occupied->CompressorListPos + 1 : 1); // wrap mode // visual feedback - Train->ggCompressorListButton.UpdateValue(static_cast(Train->mvOccupied->CompressorListPos - 1), Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->CompressorListPos - 1), Train->dsbSwitch); } } } @@ -997,7 +997,7 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->CompressorListPosNo == 0) + if (Train->occupied->CompressorListPosNo == 0) { return; } @@ -1012,15 +1012,15 @@ void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_d return; } - if (Train->mvOccupied->CompressorListPos > 1 || true == Train->mvOccupied->CompressorListWrap) + if (Train->occupied->CompressorListPos > 1 || true == Train->occupied->CompressorListWrap) { // active light preset is stored as value in range 1-LigthPosNo - Train->mvOccupied->ChangeCompressorPreset(Train->mvOccupied->CompressorListPos > 1 ? Train->mvOccupied->CompressorListPos - 1 : Train->mvOccupied->CompressorListPosNo); // wrap mode + Train->occupied->ChangeCompressorPreset(Train->occupied->CompressorListPos > 1 ? Train->occupied->CompressorListPos - 1 : Train->occupied->CompressorListPosNo); // wrap mode // visual feedback if (Train->ggCompressorListButton.SubModel != nullptr) { - Train->ggCompressorListButton.UpdateValue(static_cast(Train->mvOccupied->CompressorListPos - 1), Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->CompressorListPos - 1), Train->dsbSwitch); } } } @@ -1028,7 +1028,7 @@ void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_d void TTrain::OnCommand_compressorpresetactivatedefault(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->CompressorListPosNo == 0) + if (Train->occupied->CompressorListPosNo == 0) { return; } @@ -1037,12 +1037,12 @@ void TTrain::OnCommand_compressorpresetactivatedefault(TTrain *Train, command_da return; } // one change per key press - Train->mvOccupied->ChangeCompressorPreset(Train->mvOccupied->CompressorListDefPos); + Train->occupied->ChangeCompressorPreset(Train->occupied->CompressorListDefPos); // visual feedback if (Train->ggCompressorListButton.SubModel != nullptr) { - Train->ggCompressorListButton.UpdateValue(static_cast(Train->mvOccupied->CompressorListPos - 1), Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->CompressorListPos - 1), Train->dsbSwitch); } } @@ -1068,7 +1068,7 @@ void TTrain::OnCommand_motorblowerstogglefront(TTrain *Train, command_data const return; } - if (false == Train->mvControlled->MotorBlowers[VehicleEnd::front].is_enabled) + if (false == Train->controlled->MotorBlowers[VehicleEnd::front].is_enabled) { // turn on OnCommand_motorblowersenablefront(Train, Command); @@ -1096,13 +1096,13 @@ void TTrain::OnCommand_motorblowersenablefront(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersFrontButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(true, VehicleEnd::front); + Train->controlled->MotorBlowersSwitch(true, VehicleEnd::front); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggMotorBlowersFrontButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(false, VehicleEnd::front); + Train->controlled->MotorBlowersSwitch(false, VehicleEnd::front); } } else @@ -1112,8 +1112,8 @@ void TTrain::OnCommand_motorblowersenablefront(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersFrontButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(true, VehicleEnd::front); - Train->mvControlled->MotorBlowersSwitchOff(false, VehicleEnd::front); + Train->controlled->MotorBlowersSwitch(true, VehicleEnd::front); + Train->controlled->MotorBlowersSwitchOff(false, VehicleEnd::front); } } } @@ -1139,8 +1139,8 @@ void TTrain::OnCommand_motorblowersdisablefront(TTrain *Train, command_data cons { // visual feedback Train->ggMotorBlowersFrontButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(false, VehicleEnd::front); - Train->mvControlled->MotorBlowersSwitchOff(true, VehicleEnd::front); + Train->controlled->MotorBlowersSwitch(false, VehicleEnd::front); + Train->controlled->MotorBlowersSwitchOff(true, VehicleEnd::front); } } } @@ -1167,7 +1167,7 @@ void TTrain::OnCommand_motorblowerstogglerear(TTrain *Train, command_data const return; } - if (false == Train->mvControlled->MotorBlowers[VehicleEnd::rear].is_enabled) + if (false == Train->controlled->MotorBlowers[VehicleEnd::rear].is_enabled) { // turn on OnCommand_motorblowersenablerear(Train, Command); @@ -1195,13 +1195,13 @@ void TTrain::OnCommand_motorblowersenablerear(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(true, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitch(true, VehicleEnd::rear); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(false, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitch(false, VehicleEnd::rear); } } else @@ -1211,8 +1211,8 @@ void TTrain::OnCommand_motorblowersenablerear(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(true, VehicleEnd::rear); - Train->mvControlled->MotorBlowersSwitchOff(false, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitch(true, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitchOff(false, VehicleEnd::rear); } } } @@ -1238,8 +1238,8 @@ void TTrain::OnCommand_motorblowersdisablerear(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitch(false, VehicleEnd::rear); - Train->mvControlled->MotorBlowersSwitchOff(true, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitch(false, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitchOff(true, VehicleEnd::rear); } } } @@ -1259,15 +1259,15 @@ void TTrain::OnCommand_motorblowersdisableall(TTrain *Train, command_data const { // visual feedback Train->ggMotorBlowersAllOffButton.UpdateValue(1.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitchOff(true, VehicleEnd::front); - Train->mvControlled->MotorBlowersSwitchOff(true, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitchOff(true, VehicleEnd::front); + Train->controlled->MotorBlowersSwitchOff(true, VehicleEnd::rear); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggMotorBlowersAllOffButton.UpdateValue(0.f, Train->dsbSwitch); - Train->mvControlled->MotorBlowersSwitchOff(false, VehicleEnd::front); - Train->mvControlled->MotorBlowersSwitchOff(false, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitchOff(false, VehicleEnd::front); + Train->controlled->MotorBlowersSwitchOff(false, VehicleEnd::rear); } } else @@ -1279,16 +1279,16 @@ void TTrain::OnCommand_motorblowersdisableall(TTrain *Train, command_data const if (Train->ggMotorBlowersAllOffButton.GetDesiredValue() < 0.5f) { // switch is off, activate - Train->mvControlled->MotorBlowersSwitchOff(true, VehicleEnd::front); - Train->mvControlled->MotorBlowersSwitchOff(true, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitchOff(true, VehicleEnd::front); + Train->controlled->MotorBlowersSwitchOff(true, VehicleEnd::rear); // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(1.f, Train->dsbSwitch); } else { // deactivate - Train->mvControlled->MotorBlowersSwitchOff(false, VehicleEnd::front); - Train->mvControlled->MotorBlowersSwitchOff(false, VehicleEnd::rear); + Train->controlled->MotorBlowersSwitchOff(false, VehicleEnd::front); + Train->controlled->MotorBlowersSwitchOff(false, VehicleEnd::rear); // visual feedback Train->ggMotorBlowersRearButton.UpdateValue(0.f, Train->dsbSwitch); } @@ -1304,5 +1304,5 @@ void TTrain::OnCommand_coolingfanstoggle(TTrain *Train, command_data const &Comm return; } - Train->mvControlled->RVentForceOn = !Train->mvControlled->RVentForceOn; + Train->controlled->RVentForceOn = !Train->controlled->RVentForceOn; } diff --git a/vehicle/cab/brakecommands.cpp b/vehicle/cab/brakecommands.cpp index 6ebf453a2..f0f9cef39 100644 --- a/vehicle/cab/brakecommands.cpp +++ b/vehicle/cab/brakecommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -55,17 +55,17 @@ void TTrain::OnCommand_independentbrakeincrease(TTrain *Train, command_data cons // when SplitEDPneumaticBrake is active the local brake key always operates // the pneumatic local brake directly, never piggy-backing on the joint controller - auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; + auto const splitMode{Train->controlled->SplitEDPneumaticBrake}; auto const useStepped{Train->ggJointCtrl.SubModel != nullptr && !splitMode}; - if (Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake) + if (Train->occupied->LocalBrake != TLocalBrake::ManualBrake) { - if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->mvOccupied->MainCtrlPos > 0) + if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->occupied->MainCtrlPos > 0) { OnCommand_mastercontrollerdecrease(Train, Command); } else { - Train->mvOccupied->IncLocalBrakeLevel(useStepped ? 1 : static_cast(Global.brake_speed * Command.time_delta * LocalBrakePosNo)); + Train->occupied->IncLocalBrakeLevel(useStepped ? 1 : static_cast(Global.brake_speed * Command.time_delta * LocalBrakePosNo)); if (useStepped) { Train->m_mastercontrollerinuse = true; @@ -81,17 +81,17 @@ void TTrain::OnCommand_independentbrakeincreasefast(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { - auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; + auto const splitMode{Train->controlled->SplitEDPneumaticBrake}; auto const useJointAnim{Train->ggJointCtrl.SubModel != nullptr && !splitMode}; - if (Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake) + if (Train->occupied->LocalBrake != TLocalBrake::ManualBrake) { - if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->mvOccupied->MainCtrlPos > 0) + if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->occupied->MainCtrlPos > 0) { OnCommand_mastercontrollerdecreasefast(Train, Command); } else { - Train->mvOccupied->IncLocalBrakeLevel(LocalBrakePosNo); + Train->occupied->IncLocalBrakeLevel(LocalBrakePosNo); if (useJointAnim) { Train->m_mastercontrollerinuse = true; @@ -107,20 +107,20 @@ void TTrain::OnCommand_independentbrakedecrease(TTrain *Train, command_data cons if (Command.action != GLFW_RELEASE) { - auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; + auto const splitMode{Train->controlled->SplitEDPneumaticBrake}; auto const useStepped{Train->ggJointCtrl.SubModel != nullptr && !splitMode}; - if (Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake + if (Train->occupied->LocalBrake != TLocalBrake::ManualBrake // Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - odhamować jakoś trzeba // TODO: sort AI out so it doesn't do things it doesn't have equipment for - || Train->mvOccupied->LocalBrakePosA > 0) + || Train->occupied->LocalBrakePosA > 0) { - if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->mvOccupied->LocalBrakePosA == 0.0) + if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->occupied->LocalBrakePosA == 0.0) { OnCommand_mastercontrollerincrease(Train, Command); } else { - Train->mvOccupied->DecLocalBrakeLevel(useStepped ? 1 : static_cast(Global.brake_speed * Command.time_delta * LocalBrakePosNo)); + Train->occupied->DecLocalBrakeLevel(useStepped ? 1 : static_cast(Global.brake_speed * Command.time_delta * LocalBrakePosNo)); if (useStepped) { Train->m_mastercontrollerinuse = true; @@ -136,20 +136,20 @@ void TTrain::OnCommand_independentbrakedecreasefast(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { - auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; + auto const splitMode{Train->controlled->SplitEDPneumaticBrake}; auto const useJointAnim{Train->ggJointCtrl.SubModel != nullptr && !splitMode}; - if (Train->mvOccupied->LocalBrake != TLocalBrake::ManualBrake + if (Train->occupied->LocalBrake != TLocalBrake::ManualBrake // Ra 1014-06: AI potrafi zahamować pomocniczym mimo jego braku - odhamować jakoś trzeba // TODO: sort AI out so it doesn't do things it doesn't have equipment for - || Train->mvOccupied->LocalBrakePosA > 0) + || Train->occupied->LocalBrakePosA > 0) { - if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->mvOccupied->LocalBrakePosA == 0.0) + if (false == splitMode && Train->ggJointCtrl.SubModel != nullptr && Train->occupied->LocalBrakePosA == 0.0) { OnCommand_mastercontrollerincreasefast(Train, Command); } else { - Train->mvOccupied->DecLocalBrakeLevel(LocalBrakePosNo); + Train->occupied->DecLocalBrakeLevel(LocalBrakePosNo); if (useJointAnim) { Train->m_mastercontrollerinuse = true; @@ -165,10 +165,10 @@ void TTrain::OnCommand_independentbrakeset(TTrain *Train, command_data const &Co if (Command.action != GLFW_RELEASE) { - Train->mvOccupied->LocalBrakePosA = std::clamp(Command.param1, 0.0, 1.0); + Train->occupied->LocalBrakePosA = std::clamp(Command.param1, 0.0, 1.0); } /* - Train->mvControlled->LocalBrakePos = ( + Train->controlled->LocalBrakePos = ( std::round( interpolate( 0.0, @@ -186,10 +186,10 @@ void TTrain::OnCommand_independentbrakebailoff(TTrain *Train, command_data const { // TODO: check if this set of conditions can be simplified. // it'd be more flexible to have an attribute indicating whether bail off position is supported - if (Train->mvControlled->TrainType != train_type::emu && - (Train->mvControlled->EngineType == TEngineType::ElectricSeriesMotor || Train->mvControlled->EngineType == TEngineType::DieselElectric || - Train->mvControlled->EngineType == TEngineType::ElectricInductionMotor) && - Train->mvOccupied->BrakeCtrlPosNo > 0) + if (Train->controlled->TrainType != train_type::emu && + (Train->controlled->EngineType == TEngineType::ElectricSeriesMotor || Train->controlled->EngineType == TEngineType::DieselElectric || + Train->controlled->EngineType == TEngineType::ElectricInductionMotor) && + Train->occupied->BrakeCtrlPosNo > 0) { if (Command.action == GLFW_PRESS) @@ -198,7 +198,7 @@ void TTrain::OnCommand_independentbrakebailoff(TTrain *Train, command_data const // visual feedback Train->ggReleaserButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvOccupied->BrakeReleaser(1); + Train->occupied->BrakeReleaser(1); } else if (Command.action == GLFW_RELEASE) { @@ -206,7 +206,7 @@ void TTrain::OnCommand_independentbrakebailoff(TTrain *Train, command_data const // visual feedback Train->ggReleaserButton.UpdateValue(0.0, Train->dsbSwitch); - Train->mvOccupied->BrakeReleaser(0); + Train->occupied->BrakeReleaser(0); } } } @@ -219,12 +219,12 @@ void TTrain::OnCommand_independentbrakebailoff(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { // press or hold - vehicle->MoverParameters->BrakeReleaser(1); + vehicle->physics->BrakeReleaser(1); } else if (Command.action == GLFW_RELEASE) { // release - vehicle->MoverParameters->BrakeReleaser(0); + vehicle->physics->BrakeReleaser(0); } } } @@ -239,7 +239,7 @@ void TTrain::OnCommand_universalbrakebutton1(TTrain *Train, command_data const & // visual feedback Train->ggUniveralBrakeButton1.UpdateValue(1.0, Train->dsbSwitch); - Train->mvOccupied->UniversalBrakeButton(0, 1); + Train->occupied->UniversalBrakeButton(0, 1); } else if (Command.action == GLFW_RELEASE) { @@ -247,7 +247,7 @@ void TTrain::OnCommand_universalbrakebutton1(TTrain *Train, command_data const & // visual feedback Train->ggUniveralBrakeButton1.UpdateValue(0.0, Train->dsbSwitch); - Train->mvOccupied->UniversalBrakeButton(0, 0); + Train->occupied->UniversalBrakeButton(0, 0); } } @@ -260,7 +260,7 @@ void TTrain::OnCommand_universalbrakebutton2(TTrain *Train, command_data const & // visual feedback Train->ggUniveralBrakeButton2.UpdateValue(1.0, Train->dsbSwitch); - Train->mvOccupied->UniversalBrakeButton(1, 1); + Train->occupied->UniversalBrakeButton(1, 1); } else if (Command.action == GLFW_RELEASE) { @@ -268,7 +268,7 @@ void TTrain::OnCommand_universalbrakebutton2(TTrain *Train, command_data const & // visual feedback Train->ggUniveralBrakeButton2.UpdateValue(0.0, Train->dsbSwitch); - Train->mvOccupied->UniversalBrakeButton(1, 0); + Train->occupied->UniversalBrakeButton(1, 0); } } @@ -281,7 +281,7 @@ void TTrain::OnCommand_universalbrakebutton3(TTrain *Train, command_data const & // visual feedback Train->ggUniveralBrakeButton3.UpdateValue(1.0, Train->dsbSwitch); - Train->mvOccupied->UniversalBrakeButton(2, 1); + Train->occupied->UniversalBrakeButton(2, 1); } else if (Command.action == GLFW_RELEASE) { @@ -289,24 +289,24 @@ void TTrain::OnCommand_universalbrakebutton3(TTrain *Train, command_data const & // visual feedback Train->ggUniveralBrakeButton3.UpdateValue(0.0, Train->dsbSwitch); - Train->mvOccupied->UniversalBrakeButton(2, 0); + Train->occupied->UniversalBrakeButton(2, 0); } } void TTrain::OnCommand_trainbrakeincrease(TTrain *Train, command_data const &Command) { - if (Command.action == GLFW_REPEAT && Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a) - Train->mvOccupied->BrakeLevelAdd(Global.brake_speed * Command.time_delta * Train->mvOccupied->BrakeCtrlPosNo); - else if (Command.action == GLFW_PRESS && Train->mvOccupied->BrakeHandle != TBrakeHandle::FV4a) - Train->set_train_brake(Train->mvOccupied->fBrakeCtrlPos + Global.fBrakeStep); + if (Command.action == GLFW_REPEAT && Train->occupied->BrakeHandle == TBrakeHandle::FV4a) + Train->occupied->BrakeLevelAdd(Global.brake_speed * Command.time_delta * Train->occupied->BrakeCtrlPosNo); + else if (Command.action == GLFW_PRESS && Train->occupied->BrakeHandle != TBrakeHandle::FV4a) + Train->set_train_brake(Train->occupied->fBrakeCtrlPos + Global.fBrakeStep); } void TTrain::OnCommand_trainbrakedecrease(TTrain *Train, command_data const &Command) { - if (Command.action == GLFW_REPEAT && Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a) - Train->mvOccupied->BrakeLevelAdd(-Global.brake_speed * Command.time_delta * Train->mvOccupied->BrakeCtrlPosNo); - else if (Command.action == GLFW_PRESS && Train->mvOccupied->BrakeHandle != TBrakeHandle::FV4a) - Train->set_train_brake(Train->mvOccupied->fBrakeCtrlPos - Global.fBrakeStep); + if (Command.action == GLFW_REPEAT && Train->occupied->BrakeHandle == TBrakeHandle::FV4a) + Train->occupied->BrakeLevelAdd(-Global.brake_speed * Command.time_delta * Train->occupied->BrakeCtrlPosNo); + else if (Command.action == GLFW_PRESS && Train->occupied->BrakeHandle != TBrakeHandle::FV4a) + Train->set_train_brake(Train->occupied->fBrakeCtrlPos - Global.fBrakeStep); else if (Command.action == GLFW_RELEASE) { // release @@ -320,7 +320,7 @@ void TTrain::OnCommand_trainbrakeset(TTrain *Train, command_data const &Command) if (Command.action != GLFW_RELEASE) { // press or hold - Train->mvOccupied->BrakeLevelSet(std::lerp(Train->mvOccupied->Handle->GetPos(bh_MIN), Train->mvOccupied->Handle->GetPos(bh_MAX), std::clamp(Command.param1, 0.0, 1.0))); + Train->occupied->BrakeLevelSet(std::lerp(Train->occupied->Handle->GetPos(bh_MIN), Train->occupied->Handle->GetPos(bh_MAX), std::clamp(Command.param1, 0.0, 1.0))); } else { @@ -370,7 +370,7 @@ void TTrain::OnCommand_trainbrakeservice(TTrain *Train, command_data const &Comm if (Command.action == GLFW_PRESS) { - Train->set_train_brake(Train->mvOccupied->BrakeCtrlPosNo / 2 + (Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a ? 1 : 0)); + Train->set_train_brake(Train->occupied->BrakeCtrlPosNo / 2 + (Train->occupied->BrakeHandle == TBrakeHandle::FV4a ? 1 : 0)); } } @@ -380,7 +380,7 @@ void TTrain::OnCommand_trainbrakefullservice(TTrain *Train, command_data const & if (Command.action == GLFW_PRESS) { - Train->set_train_brake(Train->mvOccupied->BrakeCtrlPosNo - 1); + Train->set_train_brake(Train->occupied->BrakeCtrlPosNo - 1); } } @@ -390,7 +390,7 @@ void TTrain::OnCommand_trainbrakehandleoff(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { - Train->set_train_brake(Train->mvOccupied->Handle->GetPos(bh_NP)); + Train->set_train_brake(Train->occupied->Handle->GetPos(bh_NP)); } } @@ -400,11 +400,11 @@ void TTrain::OnCommand_trainbrakeemergency(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { - Train->set_train_brake(Train->mvOccupied->Handle->GetPos(bh_EB)); + Train->set_train_brake(Train->occupied->Handle->GetPos(bh_EB)); /* - if( Train->mvOccupied->BrakeCtrlPosNo <= 0.1 ) { + if( Train->occupied->BrakeCtrlPosNo <= 0.1 ) { // hamulec bezpieczeństwa dla wagonów - Train->mvOccupied->RadioStopFlag = true; + Train->occupied->RadioStopFlag = true; } */ } @@ -416,13 +416,13 @@ void TTrain::OnCommand_trainbrakebasepressureincrease(TTrain *Train, command_dat if (Command.action != GLFW_RELEASE) { - if (Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a) + if (Train->occupied->BrakeHandle == TBrakeHandle::FV4a) { - Train->mvOccupied->BrakeCtrlPos2 = std::clamp(Train->mvOccupied->BrakeCtrlPos2 - 0.01, -1.5, 2.0); + Train->occupied->BrakeCtrlPos2 = std::clamp(Train->occupied->BrakeCtrlPos2 - 0.01, -1.5, 2.0); } else { - Train->mvOccupied->BrakeLevelAdd(0.01); + Train->occupied->BrakeLevelAdd(0.01); } } } @@ -433,13 +433,13 @@ void TTrain::OnCommand_trainbrakebasepressuredecrease(TTrain *Train, command_dat if (Command.action != GLFW_RELEASE) { - if (Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a) + if (Train->occupied->BrakeHandle == TBrakeHandle::FV4a) { - Train->mvOccupied->BrakeCtrlPos2 = std::clamp(Train->mvOccupied->BrakeCtrlPos2 + 0.01, -1.5, 2.0); + Train->occupied->BrakeCtrlPos2 = std::clamp(Train->occupied->BrakeCtrlPos2 + 0.01, -1.5, 2.0); } else { - Train->mvOccupied->BrakeLevelAdd(-0.01); + Train->occupied->BrakeLevelAdd(-0.01); } } } @@ -450,7 +450,7 @@ void TTrain::OnCommand_trainbrakebasepressurereset(TTrain *Train, command_data c if (Command.action == GLFW_PRESS) { - Train->mvOccupied->BrakeCtrlPos2 = 0; + Train->occupied->BrakeCtrlPos2 = 0; } } @@ -466,9 +466,9 @@ void TTrain::OnCommand_trainbrakeoperationtoggle(TTrain *Train, command_data con return; } - vehicle->MoverParameters->Hamulec->SetBrakeStatus(vehicle->MoverParameters->Hamulec->GetBrakeStatus() ^ b_dmg); + vehicle->physics->Hamulec->SetBrakeStatus(vehicle->physics->Hamulec->GetBrakeStatus() ^ b_dmg); // the brake is the player's now, the wagon inspector won't put it back on its own - vehicle->MoverParameters->BrakeCutOutByInspector = false; + vehicle->physics->BrakeCutOutByInspector = false; } } @@ -484,10 +484,10 @@ void TTrain::OnCommand_manualbrakeincrease(TTrain *Train, command_data const &Co return; } - if (vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake || vehicle->MoverParameters->MBrake == true) + if (vehicle->physics->LocalBrake == TLocalBrake::ManualBrake || vehicle->physics->MBrake == true) { - vehicle->MoverParameters->IncManualBrakeLevel(1); + vehicle->physics->IncManualBrakeLevel(1); } } } @@ -504,10 +504,10 @@ void TTrain::OnCommand_manualbrakedecrease(TTrain *Train, command_data const &Co return; } - if (vehicle->MoverParameters->LocalBrake == TLocalBrake::ManualBrake || vehicle->MoverParameters->MBrake == true) + if (vehicle->physics->LocalBrake == TLocalBrake::ManualBrake || vehicle->physics->MBrake == true) { - vehicle->MoverParameters->DecManualBrakeLevel(1); + vehicle->physics->DecManualBrakeLevel(1); } } } @@ -518,7 +518,7 @@ void TTrain::OnCommand_alarmchaintoggle(TTrain *Train, command_data const &Comma if (Command.action == GLFW_PRESS) { - if (false == Train->mvOccupied->AlarmChainFlag) + if (false == Train->occupied->AlarmChainFlag) { OnCommand_alarmchainenable(Train, Command); } @@ -535,7 +535,7 @@ void TTrain::OnCommand_alarmchainenable(TTrain *Train, command_data const &Comma { // pull - Train->mvOccupied->AlarmChainSwitch(true); + Train->occupied->AlarmChainSwitch(true); // visual feedback Train->ggAlarmChain.UpdateValue(1.0); } @@ -547,7 +547,7 @@ void TTrain::OnCommand_alarmchaindisable(TTrain *Train, command_data const &Comm { // release - Train->mvOccupied->AlarmChainSwitch(false); + Train->occupied->AlarmChainSwitch(false); // visual feedback Train->ggAlarmChain.UpdateValue(0.0); } @@ -566,7 +566,7 @@ void TTrain::OnCommand_wheelspinbrakeactivate(TTrain *Train, command_data const return; } - if (Train->mvOccupied->BrakeSystem != TBrakeSystem::ElectroPneumatic) + if (Train->occupied->BrakeSystem != TBrakeSystem::ElectroPneumatic) { // standard behaviour if (Command.action == GLFW_PRESS) @@ -590,11 +590,11 @@ void TTrain::OnCommand_wheelspinbrakeactivate(TTrain *Train, command_data const // visual feedback Train->ggAntiSlipButton.UpdateValue(1.0, Train->dsbPneumaticSwitch); - // the EP fuse is the cab car's (Ctrl+Z switches mvOccupied's), checked by SwitchEPBrake with the rest of + // the EP fuse is the cab car's (Ctrl+Z switches occupied's), checked by SwitchEPBrake with the rest of // the control's supply - if (Train->mvOccupied->BrakeHandle == TBrakeHandle::St113) + if (Train->occupied->BrakeHandle == TBrakeHandle::St113) { - Train->mvOccupied->SwitchEPBrake(1); + Train->occupied->SwitchEPBrake(1); } } else if (Command.action == GLFW_RELEASE) @@ -602,7 +602,7 @@ void TTrain::OnCommand_wheelspinbrakeactivate(TTrain *Train, command_data const // visual feedback Train->ggAntiSlipButton.UpdateValue(0.0); - Train->mvOccupied->SwitchEPBrake(0); + Train->occupied->SwitchEPBrake(0); } } } @@ -625,14 +625,14 @@ void TTrain::OnCommand_sandboxactivate(TTrain *Train, command_data const &Comman // visual feedback Train->ggSandButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->SandboxManual(true); + Train->controlled->SandboxManual(true); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggSandButton.UpdateValue(0.0); - Train->mvControlled->SandboxManual(false); + Train->controlled->SandboxManual(false); } } @@ -642,7 +642,7 @@ void TTrain::OnCommand_autosandboxtoggle(TTrain *Train, command_data const &Comm if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvOccupied->SandDoseAutoAllow) + if (false == Train->occupied->SandDoseAutoAllow) { // turn on OnCommand_autosandboxactivate(Train, Command); @@ -660,7 +660,7 @@ void TTrain::OnCommand_autosandboxactivate(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SandboxAutoAllow(true); + Train->occupied->SandboxAutoAllow(true); Train->ggAutoSandButton.UpdateValue(1.0, Train->dsbSwitch); } }; @@ -670,7 +670,7 @@ void TTrain::OnCommand_autosandboxdeactivate(TTrain *Train, command_data const & if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SandboxAutoAllow(false); + Train->occupied->SandboxAutoAllow(false); Train->ggAutoSandButton.UpdateValue(0.0, Train->dsbSwitch); } }; @@ -681,7 +681,7 @@ void TTrain::OnCommand_epbrakecontrolenable(TTrain *Train, command_data const &C // command only works for bistable switch if (Command.action == GLFW_PRESS && istoggle) { - if (Train->mvOccupied->EpFuseSwitch(true)) + if (Train->occupied->EpFuseSwitch(true)) { // audio feedback if (Train->dsbPneumaticSwitch) @@ -699,7 +699,7 @@ void TTrain::OnCommand_epbrakecontroldisable(TTrain *Train, command_data const & // command only works for bistable switch if (Command.action == GLFW_PRESS && istoggle) { - if (Train->mvOccupied->EpFuseSwitch(false)) + if (Train->occupied->EpFuseSwitch(false)) { Train->ggEPFuseButton.UpdateValue(0.0f, Train->dsbSwitch); } @@ -722,11 +722,11 @@ void TTrain::OnCommand_epbrakecontroltoggle(TTrain *Train, command_data const &C if (istoggle) { // switch state - if (false == Train->mvOccupied->EpFuse) + if (false == Train->occupied->EpFuse) { // turn on // audio feedback - if (Train->mvOccupied->EpFuseSwitch(true) && Train->dsbPneumaticSwitch) + if (Train->occupied->EpFuseSwitch(true) && Train->dsbPneumaticSwitch) { Train->dsbPneumaticSwitch->play(); } @@ -734,21 +734,21 @@ void TTrain::OnCommand_epbrakecontroltoggle(TTrain *Train, command_data const &C else { // turn off - Train->mvOccupied->EpFuseSwitch(false); + Train->occupied->EpFuseSwitch(false); } } else if (ispush) { // potentially turn on // audio feedback - if (Train->mvOccupied->EpFuseSwitch(true) && Train->dsbPneumaticSwitch) + if (Train->occupied->EpFuseSwitch(true) && Train->dsbPneumaticSwitch) { Train->dsbPneumaticSwitch->play(); } } // visual feedback Train->ggEPFuseButton.UpdateValue(ispush ? 1.0f : // push or pushtoggle - Train->mvOccupied->EpFuse ? 1.0f : + Train->occupied->EpFuse ? 1.0f : 0.0f, // toggle Train->dsbSwitch); } @@ -763,12 +763,12 @@ void TTrain::OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_da { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (Command.action == GLFW_PRESS && (Train->mvOccupied->BrakeOpModeFlag << 1 & Train->mvOccupied->BrakeOpModes) != 0) + if (Command.action == GLFW_PRESS && (Train->occupied->BrakeOpModeFlag << 1 & Train->occupied->BrakeOpModes) != 0) { // next mode - Train->mvOccupied->BrakeOpModeFlag <<= 1; + Train->occupied->BrakeOpModeFlag <<= 1; // visual feedback - Train->ggBrakeOperationModeCtrl.UpdateValue(Train->mvOccupied->BrakeOpModeFlag > 0 ? static_cast(std::log2(Train->mvOccupied->BrakeOpModeFlag)) : 0); // audio fallback + Train->ggBrakeOperationModeCtrl.UpdateValue(Train->occupied->BrakeOpModeFlag > 0 ? static_cast(std::log2(Train->occupied->BrakeOpModeFlag)) : 0); // audio fallback } } @@ -776,12 +776,12 @@ void TTrain::OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_da { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (Command.action == GLFW_PRESS && (Train->mvOccupied->BrakeOpModeFlag >> 1 & Train->mvOccupied->BrakeOpModes) != 0) + if (Command.action == GLFW_PRESS && (Train->occupied->BrakeOpModeFlag >> 1 & Train->occupied->BrakeOpModes) != 0) { // previous mode - Train->mvOccupied->BrakeOpModeFlag >>= 1; + Train->occupied->BrakeOpModeFlag >>= 1; // visual feedback - Train->ggBrakeOperationModeCtrl.UpdateValue(Train->mvOccupied->BrakeOpModeFlag > 0 ? static_cast(std::log2(Train->mvOccupied->BrakeOpModeFlag)) : 0); + Train->ggBrakeOperationModeCtrl.UpdateValue(Train->occupied->BrakeOpModeFlag > 0 ? static_cast(std::log2(Train->occupied->BrakeOpModeFlag)) : 0); } } @@ -797,12 +797,12 @@ void TTrain::OnCommand_brakeactingspeedincrease(TTrain *Train, command_data cons return; } - if ((vehicle->MoverParameters->BrakeDelayFlag & bdelay_M) != 0) + if ((vehicle->physics->BrakeDelayFlag & bdelay_M) != 0) { // can't speed it up any more than this return; } - auto const fasterbrakesetting = vehicle->MoverParameters->BrakeDelayFlag < bdelay_R ? vehicle->MoverParameters->BrakeDelayFlag << 1 : vehicle->MoverParameters->BrakeDelayFlag | bdelay_M; + auto const fasterbrakesetting = vehicle->physics->BrakeDelayFlag < bdelay_R ? vehicle->physics->BrakeDelayFlag << 1 : vehicle->physics->BrakeDelayFlag | bdelay_M; Train->set_train_brake_speed(vehicle, fasterbrakesetting); } @@ -820,12 +820,12 @@ void TTrain::OnCommand_brakeactingspeeddecrease(TTrain *Train, command_data cons return; } - if (vehicle->MoverParameters->BrakeDelayFlag == bdelay_G) + if (vehicle->physics->BrakeDelayFlag == bdelay_G) { // can't slow it down any more than this return; } - auto const slowerbrakesetting = vehicle->MoverParameters->BrakeDelayFlag < bdelay_M ? vehicle->MoverParameters->BrakeDelayFlag >> 1 : vehicle->MoverParameters->BrakeDelayFlag ^ bdelay_M; + auto const slowerbrakesetting = vehicle->physics->BrakeDelayFlag < bdelay_M ? vehicle->physics->BrakeDelayFlag >> 1 : vehicle->physics->BrakeDelayFlag ^ bdelay_M; Train->set_train_brake_speed(vehicle, slowerbrakesetting); } @@ -887,7 +887,7 @@ void TTrain::OnCommand_brakeloadcompensationincrease(TTrain *Train, command_data auto *vehicle{Train->find_nearest_consist_vehicle(Command.freefly, Command.location)}; if (vehicle != nullptr) { - vehicle->MoverParameters->IncBrakeMult(); + vehicle->physics->IncBrakeMult(); } } } @@ -900,7 +900,7 @@ void TTrain::OnCommand_brakeloadcompensationdecrease(TTrain *Train, command_data auto *vehicle{Train->find_nearest_consist_vehicle(Command.freefly, Command.location)}; if (vehicle != nullptr) { - vehicle->MoverParameters->DecBrakeMult(); + vehicle->physics->DecBrakeMult(); } } } @@ -916,7 +916,7 @@ void TTrain::OnCommand_mubrakingindicatortoggle(TTrain *Train, command_data cons } return; } - if (Train->mvControlled->TrainType != train_type::emu) + if (Train->controlled->TrainType != train_type::emu) { // return; @@ -925,17 +925,17 @@ void TTrain::OnCommand_mubrakingindicatortoggle(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvControlled->Signalling) + if (false == Train->controlled->Signalling) { // turn on - Train->mvControlled->Signalling = true; + Train->controlled->Signalling = true; // visual feedback Train->ggSignallingButton.UpdateValue(1.0, Train->dsbSwitch); } else { // turn off - Train->mvControlled->Signalling = false; + Train->controlled->Signalling = false; // visual feedback Train->ggSignallingButton.UpdateValue(0.0, Train->dsbSwitch); } diff --git a/vehicle/cab/cab.cpp b/vehicle/cab/cab.cpp index bc5bc11a5..1d3192f30 100644 --- a/vehicle/cab/cab.cpp +++ b/vehicle/cab/cab.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include diff --git a/vehicle/cab/cabcommands.cpp b/vehicle/cab/cabcommands.cpp index 5b505ed85..25ac96377 100644 --- a/vehicle/cab/cabcommands.cpp +++ b/vehicle/cab/cabcommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -51,24 +51,24 @@ void TTrain::OnCommand_wiperswitchincrease(TTrain *Train, command_data const &Co { if (Command.action == GLFW_PRESS) { - Train->mvOccupied->wiperSwitchPos++; - if (Train->mvOccupied->wiperSwitchPos > Train->mvOccupied->WiperListSize - 1) - Train->mvOccupied->wiperSwitchPos = Train->mvOccupied->WiperListSize - 1; + Train->occupied->wiperSwitchPos++; + if (Train->occupied->wiperSwitchPos > Train->occupied->WiperListSize - 1) + Train->occupied->wiperSwitchPos = Train->occupied->WiperListSize - 1; // Visual feedback - Train->ggWiperSw.UpdateValue(static_cast(Train->mvOccupied->wiperSwitchPos), Train->dsbSwitch); + Train->ggWiperSw.UpdateValue(static_cast(Train->occupied->wiperSwitchPos), Train->dsbSwitch); } } void TTrain::OnCommand_wiperswitchdecrease(TTrain *Train, command_data const &Command) { if (Command.action == GLFW_PRESS) { - Train->mvOccupied->wiperSwitchPos--; - if (Train->mvOccupied->wiperSwitchPos < 0) - Train->mvOccupied->wiperSwitchPos = 0; + Train->occupied->wiperSwitchPos--; + if (Train->occupied->wiperSwitchPos < 0) + Train->occupied->wiperSwitchPos = 0; // visual feedback - Train->ggWiperSw.UpdateValue(static_cast(Train->mvOccupied->wiperSwitchPos), Train->dsbSwitch); + Train->ggWiperSw.UpdateValue(static_cast(Train->occupied->wiperSwitchPos), Train->dsbSwitch); } } @@ -80,13 +80,13 @@ void TTrain::OnCommand_reverserincrease(TTrain *Train, command_data const &Comma // HACK: master controller position isn't set in occupied vehicle in E(D)MUs // so we do a manual check in relevant vehicle here - if (false == Train->mvControlled->EIMDirectionChangeAllow()) + if (false == Train->controlled->EIMDirectionChangeAllow()) { return; } // aktualizacja skrajnych pojazdów w składzie - if (Train->mvOccupied->DirectionForward() && Train->mvOccupied->DirActive && Train->DynamicObject->Mechanik) + if (Train->occupied->DirectionForward() && Train->occupied->DirActive && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -102,13 +102,13 @@ void TTrain::OnCommand_reverserdecrease(TTrain *Train, command_data const &Comma // HACK: master controller position isn't set in occupied vehicle in E(D)MUs // so we do a manual check in relevant vehicle here - if (false == Train->mvControlled->EIMDirectionChangeAllow()) + if (false == Train->controlled->EIMDirectionChangeAllow()) { return; } // aktualizacja skrajnych pojazdów w składzie - if (Train->mvOccupied->DirectionBackward() && Train->mvOccupied->DirActive && Train->DynamicObject->Mechanik) + if (Train->occupied->DirectionBackward() && Train->occupied->DirActive && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -124,7 +124,7 @@ void TTrain::OnCommand_reverserforwardhigh(TTrain *Train, command_data const &Co // HACK: master controller position isn't set in occupied vehicle in E(D)MUs // so we do a manual check in relevant vehicle here - if (false == Train->mvControlled->EIMDirectionChangeAllow()) + if (false == Train->controlled->EIMDirectionChangeAllow()) { return; } @@ -132,15 +132,15 @@ void TTrain::OnCommand_reverserforwardhigh(TTrain *Train, command_data const &Co // HACK: try to move the reverser one position back, in case it's set to "high forward" OnCommand_reverserdecrease(Train, Command); - if (Train->mvOccupied->DirActive < 1) + if (Train->occupied->DirActive < 1) { - while (Train->mvOccupied->DirActive < 1 && true == Train->mvOccupied->DirectionForward()) + while (Train->occupied->DirActive < 1 && true == Train->occupied->DirectionForward()) { // all work is done in the header } // aktualizacja skrajnych pojazdów w składzie - if (Train->mvOccupied->DirActive == 1 && Train->DynamicObject->Mechanik) + if (Train->occupied->DirActive == 1 && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -158,7 +158,7 @@ void TTrain::OnCommand_reverserforward(TTrain *Train, command_data const &Comman // HACK: master controller position isn't set in occupied vehicle in E(D)MUs // so we do a manual check in relevant vehicle here - if (false == Train->mvControlled->EIMDirectionChangeAllow()) + if (false == Train->controlled->EIMDirectionChangeAllow()) { return; } @@ -168,15 +168,15 @@ void TTrain::OnCommand_reverserforward(TTrain *Train, command_data const &Comman // visual feedback Train->ggDirForwardButton.UpdateValue(1.0, Train->dsbSwitch); - if (Train->mvOccupied->DirActive == 0) + if (Train->occupied->DirActive == 0) { - while (Train->mvOccupied->DirActive < 1 && true == Train->mvOccupied->DirectionForward()) + while (Train->occupied->DirActive < 1 && true == Train->occupied->DirectionForward()) { // all work is done in the header } // aktualizacja skrajnych pojazdów w składzie - if (Train->mvOccupied->DirActive == 1 && Train->DynamicObject->Mechanik) + if (Train->occupied->DirActive == 1 && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -199,17 +199,17 @@ void TTrain::OnCommand_reverserneutral(TTrain *Train, command_data const &Comman // HACK: master controller position isn't set in occupied vehicle in E(D)MUs // so we do a manual check in relevant vehicle here - if (false == Train->mvControlled->EIMDirectionChangeAllow()) + if (false == Train->controlled->EIMDirectionChangeAllow()) { return; } // visual feedback Train->ggDirNeutralButton.UpdateValue(1.0, Train->dsbSwitch); - while (Train->mvOccupied->DirActive < 0 && true == Train->mvOccupied->DirectionForward()) + while (Train->occupied->DirActive < 0 && true == Train->occupied->DirectionForward()) { // all work is done in the header } - while (Train->mvOccupied->DirActive > 0 && true == Train->mvOccupied->DirectionBackward()) + while (Train->occupied->DirActive > 0 && true == Train->occupied->DirectionBackward()) { // all work is done in the header } @@ -230,20 +230,20 @@ void TTrain::OnCommand_reverserbackward(TTrain *Train, command_data const &Comma // HACK: master controller position isn't set in occupied vehicle in E(D)MUs // so we do a manual check in relevant vehicle here - if (false == Train->mvControlled->EIMDirectionChangeAllow()) + if (false == Train->controlled->EIMDirectionChangeAllow()) { return; } Train->ggDirBackwardButton.UpdateValue(1.0, Train->dsbSwitch); - if (Train->mvOccupied->DirActive == 0) + if (Train->occupied->DirActive == 0) { - while (Train->mvOccupied->DirActive > -1 && true == Train->mvOccupied->DirectionBackward()) + while (Train->occupied->DirActive > -1 && true == Train->occupied->DirectionBackward()) { // all work is done in the header } // aktualizacja skrajnych pojazdów w składzie - if (Train->mvOccupied->DirActive == -1 && Train->DynamicObject->Mechanik) + if (Train->occupied->DirActive == -1 && Train->DynamicObject->Mechanik) { Train->DynamicObject->Mechanik->DirectionChange(); @@ -265,16 +265,16 @@ void TTrain::OnCommand_alerteracknowledge(TTrain *Train, command_data const &Com // visual feedback Train->ggSecurityResetButton.UpdateValue(1.0, Train->dsbSwitch); - if (Train->mvOccupied->TrainType == train_type::emu || Train->mvOccupied->DirActive != 0) - Train->mvOccupied->SecuritySystem.acknowledge_press(); + if (Train->occupied->TrainType == train_type::emu || Train->occupied->DirActive != 0) + Train->occupied->SecuritySystem.acknowledge_press(); } else if (Command.action == GLFW_RELEASE) { // visual feedback Train->ggSecurityResetButton.UpdateValue(0.0); - if (Train->mvOccupied->TrainType == train_type::emu || Train->mvOccupied->DirActive != 0) - Train->mvOccupied->SecuritySystem.acknowledge_release(); + if (Train->occupied->TrainType == train_type::emu || Train->occupied->DirActive != 0) + Train->occupied->SecuritySystem.acknowledge_release(); } } @@ -283,9 +283,9 @@ void TTrain::OnCommand_cabsignalacknowledge(TTrain *Train, command_data const &C // TODO: visual feedback if (Command.action == GLFW_PRESS) { - if (Train->mvOccupied->SecuritySystem.has_separate_acknowledge()) + if (Train->occupied->SecuritySystem.has_separate_acknowledge()) { - Train->mvOccupied->SecuritySystem.cabsignal_reset(); + Train->occupied->SecuritySystem.cabsignal_reset(); Train->ggSHPResetButton.UpdateValue(1.0, Train->dsbSwitch); } } @@ -300,7 +300,7 @@ void TTrain::OnCommand_batterytoggle(TTrain *Train, command_data const &Command) if (Train->allowBatteryToggle || Command.action != GLFW_REPEAT) { // keep the switch from flipping back and forth if key is held down - if (false == Train->mvOccupied->Power24vIsAvailable) + if (false == Train->occupied->Power24vIsAvailable) { // turn on OnCommand_batteryenable(Train, Command); @@ -315,7 +315,7 @@ void TTrain::OnCommand_batterytoggle(TTrain *Train, command_data const &Command) void TTrain::OnCommand_batteryenable(TTrain *Train, command_data const &Command) { - if (!Train->mvOccupied->isBatteryButtonImpulse) + if (!Train->occupied->isBatteryButtonImpulse) { // regular button behavior if (Command.action == GLFW_PRESS) { @@ -323,10 +323,10 @@ void TTrain::OnCommand_batteryenable(TTrain *Train, command_data const &Command) Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch); Train->ggBatteryOnButton.UpdateValue(1.0f, Train->dsbSwitch); - Train->mvOccupied->BatterySwitch(true); + Train->occupied->BatterySwitch(true); Train->allowBatteryToggle = false; // side-effects - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { Train->Dynamic()->SetLights(); } @@ -346,20 +346,20 @@ void TTrain::OnCommand_batteryenable(TTrain *Train, command_data const &Command) { if (Command.action == GLFW_PRESS) { - if (Train->mvOccupied->shouldHoldBatteryButton) + if (Train->occupied->shouldHoldBatteryButton) { // jesli przycisk trzeba przytrzymac Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch); Train->ggBatteryOnButton.UpdateValue(1.0f, Train->dsbSwitch); - Train->fBatteryTimer = Train->mvOccupied->BatteryButtonHoldTime; // start timer + Train->fBatteryTimer = Train->occupied->BatteryButtonHoldTime; // start timer } else { // jesli przycisk dziala od razu - Train->mvOccupied->BatterySwitch(true); + Train->occupied->BatterySwitch(true); Train->allowBatteryToggle = false; // side-effects - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { Train->Dynamic()->SetLights(); } @@ -376,18 +376,18 @@ void TTrain::OnCommand_batteryenable(TTrain *Train, command_data const &Command) Train->ggBatteryOnButton.UpdateValue(0.0f, Train->dsbSwitch); Train->fBatteryTimer = -1.f; // Train->allowBatteryToggle = true; - Train->mvOccupied->batterySwAlreadyFired = false; + Train->occupied->batterySwAlreadyFired = false; } - else if (Command.action == GLFW_REPEAT && Train->mvOccupied->shouldHoldBatteryButton) + else if (Command.action == GLFW_REPEAT && Train->occupied->shouldHoldBatteryButton) { // trzymamy przycisk - if (Train->fBatteryTimer <= 0.0 && Train->mvOccupied->Battery == false && !Train->mvOccupied->batterySwAlreadyFired) + if (Train->fBatteryTimer <= 0.0 && Train->occupied->Battery == false && !Train->occupied->batterySwAlreadyFired) { - Train->mvOccupied->BatterySwitch(true); - Train->mvOccupied->batterySwAlreadyFired = true; + Train->occupied->BatterySwitch(true); + Train->occupied->batterySwAlreadyFired = true; // side-effects - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { Train->Dynamic()->SetLights(); } @@ -399,7 +399,7 @@ void TTrain::OnCommand_batteryenable(TTrain *Train, command_data const &Command) void TTrain::OnCommand_batterydisable(TTrain *Train, command_data const &Command) { - if (!Train->mvOccupied->isBatteryButtonImpulse) + if (!Train->occupied->isBatteryButtonImpulse) { // regular button behavior if (Command.action == GLFW_PRESS) { @@ -407,10 +407,10 @@ void TTrain::OnCommand_batterydisable(TTrain *Train, command_data const &Command Train->ggBatteryButton.UpdateValue(0.0f, Train->dsbSwitch); Train->ggBatteryOffButton.UpdateValue(1.0f, Train->dsbSwitch); - Train->mvOccupied->BatterySwitch(false); + Train->occupied->BatterySwitch(false); // side-effects - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { Train->Dynamic()->SetLights(); } @@ -429,21 +429,21 @@ void TTrain::OnCommand_batterydisable(TTrain *Train, command_data const &Command { if (Command.action == GLFW_PRESS) { - if (Train->mvOccupied->shouldHoldBatteryButton) + if (Train->occupied->shouldHoldBatteryButton) { // jesli przycisk trzeba przytrzymac Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch); Train->ggBatteryOffButton.UpdateValue(1.0f, Train->dsbSwitch); - Train->fBatteryTimer = Train->mvOccupied->BatteryButtonHoldTime; // start timer + Train->fBatteryTimer = Train->occupied->BatteryButtonHoldTime; // start timer } else { // jesli przycisk dziala od razu - Train->mvOccupied->BatterySwitch(false); + Train->occupied->BatterySwitch(false); Train->allowBatteryToggle = false; // side-effects - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { Train->Dynamic()->SetLights(); } @@ -458,18 +458,18 @@ void TTrain::OnCommand_batterydisable(TTrain *Train, command_data const &Command Train->ggBatteryButton.UpdateValue(0.0f, Train->dsbSwitch); Train->ggBatteryOffButton.UpdateValue(0.0f, Train->dsbSwitch); Train->allowBatteryToggle = true; - Train->mvOccupied->batterySwAlreadyFired = false; + Train->occupied->batterySwAlreadyFired = false; } - else if (Command.action == GLFW_REPEAT && Train->mvOccupied->shouldHoldBatteryButton) + else if (Command.action == GLFW_REPEAT && Train->occupied->shouldHoldBatteryButton) { // trzymamy przycisk - if (Train->fBatteryTimer <= 0.0 && Train->mvOccupied->Battery == true && !Train->mvOccupied->batterySwAlreadyFired) + if (Train->fBatteryTimer <= 0.0 && Train->occupied->Battery == true && !Train->occupied->batterySwAlreadyFired) { - Train->mvOccupied->BatterySwitch(false); - Train->mvOccupied->batterySwAlreadyFired = true; + Train->occupied->BatterySwitch(false); + Train->occupied->batterySwAlreadyFired = true; // side-effects - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { Train->Dynamic()->SetLights(); } @@ -485,7 +485,7 @@ void TTrain::OnCommand_cabactivationtoggle(TTrain *Train, command_data const &Co if (Command.action != GLFW_REPEAT) { // keep the switch from flipping back and forth if key is held down - if (0 == Train->mvOccupied->CabActive) + if (0 == Train->occupied->CabActive) { // turn on OnCommand_cabactivationenable(Train, Command); @@ -509,10 +509,10 @@ void TTrain::OnCommand_cabactivationenable(TTrain *Train, command_data const &Co Train->ggCabActivationButton.UpdateValue(1.0f, Train->dsbSwitch); } - Train->mvOccupied->CabActivisation(); + Train->occupied->CabActivisation(); // side-effects - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { Train->Dynamic()->SetLights(); } @@ -535,8 +535,8 @@ void TTrain::OnCommand_cabactivationdisable(TTrain *Train, command_data const &C Train->ggCabActivationButton.UpdateValue(0.0f, Train->dsbSwitch); } - Train->mvOccupied->CabDeactivisation(); - if (Train->mvOccupied->LightsPosNo > 0 && Train->mvOccupied->InactiveCabFlag & activation::redmarkers) + Train->occupied->CabDeactivisation(); + if (Train->occupied->LightsPosNo > 0 && Train->occupied->InactiveCabFlag & activation::redmarkers) { Train->Dynamic()->SetLights(); } @@ -556,21 +556,21 @@ void TTrain::OnCommand_cabchangeforward(TTrain *Train, command_data const &Comma if (auto const movedirection{1}; false == Train->CabChange(movedirection)) { auto const exitdirection{(movedirection > 0 ? VehicleEnd::front : VehicleEnd::rear)}; - if (Train->mvOccupied->Couplers[exitdirection].CouplingFlag.HasAll(Coupling::gangway)) + if (Train->occupied->Couplers[exitdirection].CouplingFlag.HasAll(Coupling::gangway)) { // przejscie do nastepnego pojazdu auto *targetvehicle = exitdirection == VehicleEnd::front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected(); - targetvehicle->MoverParameters->CabOccupied = Train->mvOccupied->Neighbours[exitdirection].vehicle_end ? -1 : 1; + targetvehicle->physics->CabOccupied = Train->occupied->Neighbours[exitdirection].vehicle_end ? -1 : 1; Train->MoveToVehicle(targetvehicle); } } // HACK: match consist door permit state with the preset in the active cab if (Train->ggDoorPermitPresetButton.SubModel != nullptr) { - Train->mvOccupied->ChangeDoorPermitPreset(0); + Train->occupied->ChangeDoorPermitPreset(0); } // HACK: update lights state - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { Train->DynamicObject->SetLights(); } @@ -586,21 +586,21 @@ void TTrain::OnCommand_cabchangebackward(TTrain *Train, command_data const &Comm { // current vehicle doesn't extend any farther in this direction, check if we there's one connected we can move to auto const exitdirection{(movedirection > 0 ? VehicleEnd::front : VehicleEnd::rear)}; - if (Train->mvOccupied->Couplers[exitdirection].CouplingFlag.HasAll(Coupling::gangway)) + if (Train->occupied->Couplers[exitdirection].CouplingFlag.HasAll(Coupling::gangway)) { // przejscie do nastepnego pojazdu auto *targetvehicle = exitdirection == VehicleEnd::front ? Train->DynamicObject->PrevConnected() : Train->DynamicObject->NextConnected(); - targetvehicle->MoverParameters->CabOccupied = Train->mvOccupied->Neighbours[exitdirection].vehicle_end ? -1 : 1; + targetvehicle->physics->CabOccupied = Train->occupied->Neighbours[exitdirection].vehicle_end ? -1 : 1; Train->MoveToVehicle(targetvehicle); } } // HACK: match consist door permit state with the preset in the active cab if (Train->ggDoorPermitPresetButton.SubModel != nullptr) { - Train->mvOccupied->ChangeDoorPermitPreset(0); + Train->occupied->ChangeDoorPermitPreset(0); } // HACK: update lights state - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { Train->DynamicObject->SetLights(); } @@ -638,13 +638,13 @@ void TTrain::OnCommand_vehicleboost(TTrain *Train, const command_data &Command) auto *vehicle{Train->DynamicObject}; while (vehicle) { - vehicle->MoverParameters->V += vehicle->DirectionGet() * boost; + vehicle->physics->V += vehicle->DirectionGet() * boost; vehicle = vehicle->Next(); // pozostałe też } vehicle = Train->DynamicObject->Prev(); while (vehicle) { - vehicle->MoverParameters->V += vehicle->DirectionGet() * boost; + vehicle->physics->V += vehicle->DirectionGet() * boost; vehicle = vehicle->Prev(); // w drugą stronę też } } diff --git a/vehicle/cab/commandtable.cpp b/vehicle/cab/commandtable.cpp index e0632a5fb..76908fcd5 100644 --- a/vehicle/cab/commandtable.cpp +++ b/vehicle/cab/commandtable.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include diff --git a/vehicle/cab/controllercommands.cpp b/vehicle/cab/controllercommands.cpp index 1d2445a29..06974960a 100644 --- a/vehicle/cab/controllercommands.cpp +++ b/vehicle/cab/controllercommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -87,37 +87,37 @@ void TTrain::OnCommand_jointcontrollerset(TTrain *Train, command_data const &Com if (Command.param1 >= 0.5) { Train->set_master_controller((Command.param1 * 2 - 1) * - (Train->mvControlled->CoupledCtrl ? Train->mvControlled->MainCtrlPosNo + Train->mvControlled->ScndCtrlPosNo : Train->mvControlled->MainCtrlPosNo)); + (Train->controlled->CoupledCtrl ? Train->controlled->MainCtrlPosNo + Train->controlled->ScndCtrlPosNo : Train->controlled->MainCtrlPosNo)); Train->m_mastercontrollerinuse = true; // when SplitEDPneumaticBrake is active the joint controller's negative range // commands the dedicated dynamic-brake lever instead of the local pneumatic brake - if (Train->mvControlled->SplitEDPneumaticBrake) + if (Train->controlled->SplitEDPneumaticBrake) { - Train->mvControlled->DynamicBrakeLevelSet(0.0); + Train->controlled->DynamicBrakeLevelSet(0.0); } else { - Train->mvOccupied->LocalBrakePosA = 0; + Train->occupied->LocalBrakePosA = 0; } } else { auto const negativeRange{std::clamp(1.0 - Command.param1 * 2, 0.0, 1.0)}; - if (Train->mvControlled->SplitEDPneumaticBrake) + if (Train->controlled->SplitEDPneumaticBrake) { // negative range of jointctrl drives only ED braking, local pneumatic brake stays untouched. // snap to DBPN discrete stops so the lever animates step-by-step - auto const stepCount{std::max(1, Train->mvControlled->DynamicBrakeCtrlPosNo)}; + auto const stepCount{std::max(1, Train->controlled->DynamicBrakeCtrlPosNo)}; auto const snapped{std::round(negativeRange * stepCount) / stepCount}; - Train->mvControlled->DynamicBrakeLevelSet(snapped); + Train->controlled->DynamicBrakeLevelSet(snapped); } else { - Train->mvOccupied->LocalBrakePosA = negativeRange; + Train->occupied->LocalBrakePosA = negativeRange; } - if (Train->mvControlled->MainCtrlPowerPos() > 0) + if (Train->controlled->MainCtrlPowerPos() > 0) { - Train->set_master_controller(Train->mvControlled->MainCtrlNoPowerPos()); + Train->set_master_controller(Train->controlled->MainCtrlNoPowerPos()); } } } @@ -135,10 +135,10 @@ void TTrain::OnCommand_mastercontrollerincrease(TTrain *Train, command_data cons if (Command.action != GLFW_RELEASE) { // on press or hold - auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; + auto const splitMode{Train->controlled->SplitEDPneumaticBrake}; // when SplitEDPneumaticBrake is true the joint controller's negative range maps // to the dedicated dynamic-brake lever (DynamicBrakeCtrl) rather than to LocalBrake - auto const negativeRangeActive{splitMode ? Train->mvControlled->DynamicBrakeCtrlPos > 0.0 : Train->mvOccupied->LocalBrakePosA > 0.0}; + auto const negativeRangeActive{splitMode ? Train->controlled->DynamicBrakeCtrlPos > 0.0 : Train->occupied->LocalBrakePosA > 0.0}; if (Train->ggJointCtrl.SubModel != nullptr && negativeRangeActive) { if (splitMode) @@ -153,7 +153,7 @@ void TTrain::OnCommand_mastercontrollerincrease(TTrain *Train, command_data cons } else { - Train->mvControlled->IncMainCtrl(1); + Train->controlled->IncMainCtrl(1); Train->m_mastercontrollerinuse = true; } } @@ -171,8 +171,8 @@ void TTrain::OnCommand_mastercontrollerincreasefast(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // on press or hold - auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - auto const negativeRangeActive{splitMode ? Train->mvControlled->DynamicBrakeCtrlPos > 0.0 : Train->mvOccupied->LocalBrakePosA > 0.0}; + auto const splitMode{Train->controlled->SplitEDPneumaticBrake}; + auto const negativeRangeActive{splitMode ? Train->controlled->DynamicBrakeCtrlPos > 0.0 : Train->occupied->LocalBrakePosA > 0.0}; if (Train->ggJointCtrl.SubModel != nullptr && negativeRangeActive) { if (splitMode) @@ -187,7 +187,7 @@ void TTrain::OnCommand_mastercontrollerincreasefast(TTrain *Train, command_data } else { - Train->mvControlled->IncMainCtrl(Train->mvControlled->MainCtrlPosNo); + Train->controlled->IncMainCtrl(Train->controlled->MainCtrlPosNo); Train->m_mastercontrollerinuse = true; } } @@ -205,8 +205,8 @@ void TTrain::OnCommand_mastercontrollerdecrease(TTrain *Train, command_data cons if (Command.action != GLFW_RELEASE) { // on press or hold - auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - if (Train->ggJointCtrl.SubModel != nullptr && Train->mvControlled->IsMainCtrlNoPowerPos()) + auto const splitMode{Train->controlled->SplitEDPneumaticBrake}; + if (Train->ggJointCtrl.SubModel != nullptr && Train->controlled->IsMainCtrlNoPowerPos()) { // negative range of jointctrl: ED brake when split, otherwise pneumatic local brake if (splitMode) @@ -221,7 +221,7 @@ void TTrain::OnCommand_mastercontrollerdecrease(TTrain *Train, command_data cons } else { - Train->mvControlled->DecMainCtrl(1); + Train->controlled->DecMainCtrl(1); Train->m_mastercontrollerinuse = true; } } @@ -239,8 +239,8 @@ void TTrain::OnCommand_mastercontrollerdecreasefast(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // on press or hold - auto const splitMode{Train->mvControlled->SplitEDPneumaticBrake}; - if (Train->ggJointCtrl.SubModel != nullptr && Train->mvControlled->IsMainCtrlNoPowerPos()) + auto const splitMode{Train->controlled->SplitEDPneumaticBrake}; + if (Train->ggJointCtrl.SubModel != nullptr && Train->controlled->IsMainCtrlNoPowerPos()) { if (splitMode) { @@ -254,7 +254,7 @@ void TTrain::OnCommand_mastercontrollerdecreasefast(TTrain *Train, command_data } else { - Train->mvControlled->DecMainCtrl(Train->mvControlled->MainCtrlPowerPos()); + Train->controlled->DecMainCtrl(Train->controlled->MainCtrlPowerPos()); Train->m_mastercontrollerinuse = true; } } @@ -288,13 +288,13 @@ void TTrain::OnCommand_DynamicBrakeControllerIncrease(TTrain *Train, command_dat { return; } - if (false == Train->mvControlled->SplitEDPneumaticBrake) + if (false == Train->controlled->SplitEDPneumaticBrake) { return; } // step exactly one stop (1 / DBPN) per command, matching the discrete behaviour of jointctrl - Train->mvControlled->IncDynamicBrakeLevel(1.0f); + Train->controlled->IncDynamicBrakeLevel(1.0f); } void TTrain::OnCommand_DynamicBrakeControllerIncreaseFast(TTrain *Train, command_data const &Command) @@ -303,12 +303,12 @@ void TTrain::OnCommand_DynamicBrakeControllerIncreaseFast(TTrain *Train, command { return; } - if (false == Train->mvControlled->SplitEDPneumaticBrake) + if (false == Train->controlled->SplitEDPneumaticBrake) { return; } - Train->mvControlled->IncDynamicBrakeLevel(static_cast(Train->mvControlled->DynamicBrakeCtrlPosNo)); + Train->controlled->IncDynamicBrakeLevel(static_cast(Train->controlled->DynamicBrakeCtrlPosNo)); } void TTrain::OnCommand_DynamicBrakeControllerDecrease(TTrain *Train, command_data const &Command) @@ -317,13 +317,13 @@ void TTrain::OnCommand_DynamicBrakeControllerDecrease(TTrain *Train, command_dat { return; } - if (false == Train->mvControlled->SplitEDPneumaticBrake) + if (false == Train->controlled->SplitEDPneumaticBrake) { return; } // step exactly one stop (1 / DBPN) per command, matching the discrete behaviour of jointctrl - Train->mvControlled->DecDynamicBrakeLevel(1.0f); + Train->controlled->DecDynamicBrakeLevel(1.0f); } void TTrain::OnCommand_DynamicBrakeControllerDecreaseFast(TTrain *Train, command_data const &Command) @@ -332,12 +332,12 @@ void TTrain::OnCommand_DynamicBrakeControllerDecreaseFast(TTrain *Train, command { return; } - if (false == Train->mvControlled->SplitEDPneumaticBrake) + if (false == Train->controlled->SplitEDPneumaticBrake) { return; } - Train->mvControlled->DecDynamicBrakeLevel(static_cast(Train->mvControlled->DynamicBrakeCtrlPosNo)); + Train->controlled->DecDynamicBrakeLevel(static_cast(Train->controlled->DynamicBrakeCtrlPosNo)); } void TTrain::OnCommand_DynamicBrakeControllerSet(TTrain *Train, command_data const &Command) @@ -346,26 +346,26 @@ void TTrain::OnCommand_DynamicBrakeControllerSet(TTrain *Train, command_data con { return; } - if (false == Train->mvControlled->SplitEDPneumaticBrake) + if (false == Train->controlled->SplitEDPneumaticBrake) { return; } // when input source uses raw 0..1 value, snap to nearest DBPN step auto const target{std::clamp(Command.param1, 0.0, 1.0)}; - auto const stepCount{std::max(1, Train->mvControlled->DynamicBrakeCtrlPosNo)}; + auto const stepCount{std::max(1, Train->controlled->DynamicBrakeCtrlPosNo)}; auto const snapped{std::round(target * stepCount) / stepCount}; - Train->mvControlled->DynamicBrakeLevelSet(snapped); + Train->controlled->DynamicBrakeLevelSet(snapped); } void TTrain::OnCommand_secondcontrollerincrease(TTrain *Train, command_data const &Command) { - if (Train->mvControlled->EngineType == TEngineType::DieselElectric && true == Train->mvControlled->ShuntModeAllow && true == Train->mvControlled->ShuntMode) + if (Train->controlled->EngineType == TEngineType::DieselElectric && true == Train->controlled->ShuntModeAllow && true == Train->controlled->ShuntMode) { if (Command.action != GLFW_RELEASE) { - Train->mvControlled->AnPos = std::clamp(Train->mvControlled->AnPos + 0.025, 0.0, 1.0); + Train->controlled->AnPos = std::clamp(Train->controlled->AnPos + 0.025, 0.0, 1.0); } } else @@ -377,7 +377,7 @@ void TTrain::OnCommand_secondcontrollerincrease(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // activate on press - Train->mvControlled->IncScndCtrl(1); + Train->controlled->IncScndCtrl(1); } } // toggle control type @@ -385,7 +385,7 @@ void TTrain::OnCommand_secondcontrollerincrease(TTrain *Train, command_data cons { if (Command.action != GLFW_RELEASE) { - Train->mvControlled->IncScndCtrl(1); + Train->controlled->IncScndCtrl(1); } } // HACK: potentially animate push or pushtoggle control @@ -396,7 +396,7 @@ void TTrain::OnCommand_secondcontrollerincrease(TTrain *Train, command_data cons Train->ggScndCtrl.UpdateValue(Command.action == GLFW_RELEASE ? neutralposition : activeposition, Train->dsbSwitch); } // potentially animate tempomat button, unless the cruise control has its own - if (Train->ggScndCtrlButton.is_push() && Train->mvControlled->ScndCtrlPos <= 1 && false == Train->mvControlled->IsSpeedCtrlSeparate()) + if (Train->ggScndCtrlButton.is_push() && Train->controlled->ScndCtrlPos <= 1 && false == Train->controlled->IsSpeedCtrlSeparate()) { Train->ggScndCtrlButton.UpdateValue(Command.action == GLFW_RELEASE ? 0.f : 1.f, Train->dsbSwitch); } @@ -409,13 +409,13 @@ void TTrain::OnCommand_secondcontrollerincreasefast(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // on press or hold - if (Train->mvControlled->EngineType == TEngineType::DieselElectric && true == Train->mvControlled->ShuntMode) + if (Train->controlled->EngineType == TEngineType::DieselElectric && true == Train->controlled->ShuntMode) { - Train->mvControlled->AnPos = 1.0; + Train->controlled->AnPos = 1.0; } else { - Train->mvControlled->IncScndCtrl(2); + Train->controlled->IncScndCtrl(2); } } } @@ -426,18 +426,18 @@ void TTrain::OnCommand_notchingrelaytoggle(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvOccupied->AutoRelayFlag) + if (false == Train->occupied->AutoRelayFlag) { // turn on - Train->mvOccupied->AutoRelaySwitch(true); + Train->occupied->AutoRelaySwitch(true); } else { // turn off - Train->mvOccupied->AutoRelaySwitch(false); + Train->occupied->AutoRelaySwitch(false); } // visual feedback - Train->ggAutoRelayButton.UpdateValue(Train->mvOccupied->AutoRelayFlag ? 1.f : 0.f, Train->dsbSwitch); + Train->ggAutoRelayButton.UpdateValue(Train->occupied->AutoRelayFlag ? 1.f : 0.f, Train->dsbSwitch); } } @@ -461,17 +461,17 @@ void TTrain::OnCommand_tempomattoggle(TTrain *Train, command_data const &Command return; } // glfw_press - if (false == Train->mvControlled->IsSpeedCtrlEngaged()) + if (false == Train->controlled->IsSpeedCtrlEngaged()) { // turn on if it's not active - Train->mvControlled->SpeedCtrlSwitch(true); + Train->controlled->SpeedCtrlSwitch(true); // visual feedback Train->ggScndCtrlButton.UpdateValue(1.0, Train->dsbSwitch); } else { // otherwise turn off - Train->mvControlled->SpeedCtrlSwitch(false); + Train->controlled->SpeedCtrlSwitch(false); // visual feedback if (Train->m_controlmapper.contains("tempomatoff_sw:")) { @@ -491,17 +491,17 @@ void TTrain::OnCommand_tempomattoggle(TTrain *Train, command_data const &Command return; } - if (false == Train->mvControlled->IsSpeedCtrlEngaged()) + if (false == Train->controlled->IsSpeedCtrlEngaged()) { // turn on - Train->mvControlled->SpeedCtrlSwitch(true); + Train->controlled->SpeedCtrlSwitch(true); // visual feedback Train->ggScndCtrlButton.UpdateValue(1.0, Train->dsbSwitch); } else { // turn off - Train->mvControlled->SpeedCtrlSwitch(false); + Train->controlled->SpeedCtrlSwitch(false); // visual feedback Train->ggScndCtrlButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -516,13 +516,13 @@ void TTrain::OnCommand_distancecounteractivate(TTrain *Train, command_data const // visual feedback Train->ggDistanceCounterButton.UpdateValue(1.0, Train->dsbSwitch); // activate or start anew - if (Train->mvOccupied->isDoubleClickForMeasureNeeded) + if (Train->occupied->isDoubleClickForMeasureNeeded) { // handler tempomatu dla podwojnego kliku if (Train->trainLenghtMeasureTimer >= 0.f) // jesli zdazylismy w czasie sekundy Train->m_distancecounter = 0.f; // rozpoczynamy pomiar else - Train->trainLenghtMeasureTimer = Train->mvOccupied->DistanceCounterDoublePressPeriod; // odpalamy zegarek od nowa + Train->trainLenghtMeasureTimer = Train->occupied->DistanceCounterDoublePressPeriod; // odpalamy zegarek od nowa } else { @@ -568,11 +568,11 @@ void TTrain::OnCommand_mucurrentindicatorothersourceactivate(TTrain *Train, comm void TTrain::OnCommand_secondcontrollerdecrease(TTrain *Train, command_data const &Command) { - if (Train->mvControlled->EngineType == TEngineType::DieselElectric && true == Train->mvControlled->ShuntMode) + if (Train->controlled->EngineType == TEngineType::DieselElectric && true == Train->controlled->ShuntMode) { if (Command.action != GLFW_RELEASE) { - Train->mvControlled->AnPos = std::clamp(Train->mvControlled->AnPos - 0.025, 0.0, 1.0); + Train->controlled->AnPos = std::clamp(Train->controlled->AnPos - 0.025, 0.0, 1.0); } } else @@ -585,7 +585,7 @@ void TTrain::OnCommand_secondcontrollerdecrease(TTrain *Train, command_data cons if (true == Train->ggScndCtrl.is_toggle() && Command.action == GLFW_PRESS) { // activate on press - Train->mvControlled->DecScndCtrl(1); + Train->controlled->DecScndCtrl(1); } } // toggle control type @@ -593,7 +593,7 @@ void TTrain::OnCommand_secondcontrollerdecrease(TTrain *Train, command_data cons { if (Command.action != GLFW_RELEASE) { - Train->mvControlled->DecScndCtrl(1); + Train->controlled->DecScndCtrl(1); } } // HACK: potentially animate push or pushtoggle control @@ -604,7 +604,7 @@ void TTrain::OnCommand_secondcontrollerdecrease(TTrain *Train, command_data cons Train->ggScndCtrl.UpdateValue(Command.action == GLFW_RELEASE ? neutralposition : activeposition, Train->dsbSwitch); } // potentially animate tempomat button, unless the cruise control has its own - if (Train->ggScndCtrlButton.is_push() && Train->mvControlled->ScndCtrlPos <= 1 && false == Train->mvControlled->IsSpeedCtrlSeparate()) + if (Train->ggScndCtrlButton.is_push() && Train->controlled->ScndCtrlPos <= 1 && false == Train->controlled->IsSpeedCtrlSeparate()) { if (Train->m_controlmapper.contains("tempomatoff_sw:")) { @@ -624,13 +624,13 @@ void TTrain::OnCommand_secondcontrollerdecreasefast(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // on press or hold - if (Train->mvControlled->EngineType == TEngineType::DieselElectric && true == Train->mvControlled->ShuntMode) + if (Train->controlled->EngineType == TEngineType::DieselElectric && true == Train->controlled->ShuntMode) { - Train->mvControlled->AnPos = 0.0; + Train->controlled->AnPos = 0.0; } else { - Train->mvControlled->DecScndCtrl(2); + Train->controlled->DecScndCtrl(2); } } } @@ -638,13 +638,13 @@ void TTrain::OnCommand_secondcontrollerdecreasefast(TTrain *Train, command_data void TTrain::OnCommand_secondcontrollerset(TTrain *Train, command_data const &Command) { - auto const targetposition{std::min(static_cast(Command.param1), Train->mvControlled->ScndCtrlPosNo)}; + auto const targetposition{std::min(static_cast(Command.param1), Train->controlled->ScndCtrlPosNo)}; // HACK: potentially animate push or pushtoggle control if (Train->ggScndCtrl.is_push()) { auto const activeposition{Train->ggScndCtrl.is_toggle() ? - (targetposition < Train->mvControlled->ScndCtrlPos ? 0.f : - targetposition > Train->mvControlled->ScndCtrlPos ? 1.f : + (targetposition < Train->controlled->ScndCtrlPos ? 0.f : + targetposition > Train->controlled->ScndCtrlPos ? 1.f : Train->ggScndCtrl.GetDesiredValue()) : // leave the control in its current position if it hits the limit targetposition == 0 ? 0.f : 1.f}; @@ -655,11 +655,11 @@ void TTrain::OnCommand_secondcontrollerset(TTrain *Train, command_data const &Co if (Command.action != GLFW_RELEASE) { // on press or hold - while (targetposition < Train->mvControlled->GetVirtualScndPos() && true == Train->mvControlled->DecScndCtrl(1)) + while (targetposition < Train->controlled->GetVirtualScndPos() && true == Train->controlled->DecScndCtrl(1)) { // all work is done in the header } - while (targetposition > Train->mvControlled->GetVirtualScndPos() && true == Train->mvControlled->IncScndCtrl(1)) + while (targetposition > Train->controlled->GetVirtualScndPos() && true == Train->controlled->IncScndCtrl(1)) { // all work is done in the header } diff --git a/vehicle/cab/couplingcommands.cpp b/vehicle/cab/couplingcommands.cpp index 4013fa0fd..6d4bfe1e9 100644 --- a/vehicle/cab/couplingcommands.cpp +++ b/vehicle/cab/couplingcommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -212,10 +212,10 @@ void TTrain::OnCommand_departureannounce(TTrain *Train, command_data const &Comm if (Command.action == GLFW_PRESS) { // only reacting to press, so the sound can loop uninterrupted - if (false == Train->mvOccupied->DepartureSignal) + if (false == Train->occupied->DepartureSignal) { // turn on - Train->mvOccupied->signal_departure(true); + Train->occupied->signal_departure(true); // visual feedback Train->ggDepartureSignalButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -223,7 +223,7 @@ void TTrain::OnCommand_departureannounce(TTrain *Train, command_data const &Comm else if (Command.action == GLFW_RELEASE) { // turn off - Train->mvOccupied->signal_departure(false); + Train->occupied->signal_departure(false); // visual feedback Train->ggDepartureSignalButton.UpdateValue(0.0, Train->dsbSwitch); } diff --git a/vehicle/cab/doorcommands.cpp b/vehicle/cab/doorcommands.cpp index 6205647c6..f801ad1dd 100644 --- a/vehicle/cab/doorcommands.cpp +++ b/vehicle/cab/doorcommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -62,11 +62,11 @@ void TTrain::OnCommand_doorlocktoggle(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { // only reacting to press, so the sound can loop uninterrupted - if (false == Train->mvOccupied->Doors.lock_enabled) + if (false == Train->occupied->Doors.lock_enabled) { // turn on // TODO: door lock command to send through consist - Train->mvOccupied->LockDoors(true); + Train->occupied->LockDoors(true); // visual feedback Train->ggDoorSignallingButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -74,7 +74,7 @@ void TTrain::OnCommand_doorlocktoggle(TTrain *Train, command_data const &Command { // turn off // TODO: door lock command to send through consist - Train->mvOccupied->LockDoors(false); + Train->occupied->LockDoors(false); // visual feedback Train->ggDoorSignallingButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -113,7 +113,7 @@ void TTrain::OnCommand_doortoggleleft(TTrain *Train, command_data const &Command if (true == (Train->ggDoorLeftButton.GetDesiredValue() > 0.5 || Train->ggDoorLeftOnButton.GetDesiredValue() > 0.5)) { // open - if (Train->mvOccupied->Doors.has_autowarning && Train->mvOccupied->DepartureSignal) + if (Train->occupied->Doors.has_autowarning && Train->occupied->DepartureSignal) { // complete closing the doors if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorLeftOffButton.SubModel == nullptr) @@ -163,7 +163,7 @@ void TTrain::OnCommand_doorpermitleft(TTrain *Train, command_data const &Command { return; } - if (false == Train->mvOccupied->Doors.permit_presets.empty()) + if (false == Train->occupied->Doors.permit_presets.empty()) { return; } @@ -176,18 +176,18 @@ void TTrain::OnCommand_doorpermitleft(TTrain *Train, command_data const &Command if (Train->ggDoorLeftPermitButton.is_push()) { // impulse switch - Train->mvOccupied->PermitDoors(side); + Train->occupied->PermitDoors(side); // visual feedback Train->ggDoorLeftPermitButton.UpdateValue(1.0, Train->dsbSwitch); // start potential timer for remote door control - Train->m_doorpermittimers[side] = Train->mvOccupied->DoorsOpenWithPermitAfter; + Train->m_doorpermittimers[side] = Train->occupied->DoorsOpenWithPermitAfter; } else { // two-state switch auto const newstate{!(Train->ggDoorLeftPermitButton.GetDesiredValue() > 0.5)}; - Train->mvOccupied->PermitDoors(side, newstate); + Train->occupied->PermitDoors(side, newstate); // visual feedback Train->ggDoorLeftPermitButton.UpdateValue(newstate ? 1.0 : 0.0, Train->dsbSwitch); } @@ -209,7 +209,7 @@ void TTrain::OnCommand_doorpermitright(TTrain *Train, command_data const &Comman { return; } - if (false == Train->mvOccupied->Doors.permit_presets.empty()) + if (false == Train->occupied->Doors.permit_presets.empty()) { return; } @@ -222,18 +222,18 @@ void TTrain::OnCommand_doorpermitright(TTrain *Train, command_data const &Comman if (Train->ggDoorRightPermitButton.type() == TGaugeType::push) { // impulse switch - Train->mvOccupied->PermitDoors(side); + Train->occupied->PermitDoors(side); // visual feedback Train->ggDoorRightPermitButton.UpdateValue(1.0, Train->dsbSwitch); // start potential timer for remote door control - Train->m_doorpermittimers[side] = Train->mvOccupied->DoorsOpenWithPermitAfter; + Train->m_doorpermittimers[side] = Train->occupied->DoorsOpenWithPermitAfter; } else { // two-state switch auto const newstate{!(Train->ggDoorRightPermitButton.GetDesiredValue() > 0.5)}; - Train->mvOccupied->PermitDoors(side, newstate); + Train->occupied->PermitDoors(side, newstate); // visual feedback Train->ggDoorRightPermitButton.UpdateValue(newstate ? 1.0 : 0.0, Train->dsbSwitch); } @@ -254,9 +254,9 @@ void TTrain::OnCommand_doorpermitpresetactivatenext(TTrain *Train, command_data if (Command.action == GLFW_PRESS) { - Train->mvOccupied->ChangeDoorPermitPreset(1); + Train->occupied->ChangeDoorPermitPreset(1); // visual feedback - Train->ggDoorPermitPresetButton.UpdateValue(static_cast(Train->mvOccupied->Doors.permit_preset), Train->dsbSwitch); + Train->ggDoorPermitPresetButton.UpdateValue(static_cast(Train->occupied->Doors.permit_preset), Train->dsbSwitch); } } @@ -266,9 +266,9 @@ void TTrain::OnCommand_doorpermitpresetactivateprevious(TTrain *Train, command_d if (Command.action == GLFW_PRESS) { - Train->mvOccupied->ChangeDoorPermitPreset(-1); + Train->occupied->ChangeDoorPermitPreset(-1); // visual feedback - Train->ggDoorPermitPresetButton.UpdateValue(static_cast(Train->mvOccupied->Doors.permit_preset), Train->dsbSwitch); + Train->ggDoorPermitPresetButton.UpdateValue(static_cast(Train->occupied->Doors.permit_preset), Train->dsbSwitch); } } @@ -276,7 +276,7 @@ void TTrain::OnCommand_dooropenleft(TTrain *Train, command_data const &Command) { - if (auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == control_t::driver || Train->mvOccupied->Doors.open_control == control_t::mixed}; false == remoteopencontrol) + if (auto const remoteopencontrol{Train->occupied->Doors.open_control == control_t::driver || Train->occupied->Doors.open_control == control_t::mixed}; false == remoteopencontrol) { return; } @@ -289,7 +289,7 @@ void TTrain::OnCommand_dooropenleft(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - Train->mvOccupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right, true); + Train->occupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right, true); // visual feedback if (Train->ggDoorLeftOnButton.SubModel != nullptr) { @@ -317,7 +317,7 @@ void TTrain::OnCommand_doorcloseleft(TTrain *Train, command_data const &Command) { - if (auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == control_t::driver || Train->mvOccupied->Doors.close_control == control_t::mixed}; false == remoteclosecontrol) + if (auto const remoteclosecontrol{Train->occupied->Doors.close_control == control_t::driver || Train->occupied->Doors.close_control == control_t::mixed}; false == remoteclosecontrol) { return; } @@ -331,15 +331,15 @@ void TTrain::OnCommand_doorcloseleft(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - if (Train->mvOccupied->Doors.has_autowarning) + if (Train->occupied->Doors.has_autowarning) { // automatic departure signal delays actual door closing until the button is released - Train->mvOccupied->signal_departure(true); + Train->occupied->signal_departure(true); } else { // TODO: move door opening/closing to the update, so the switch animation doesn't hinge on door working - Train->mvOccupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right, false); + Train->occupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right, false); } // visual feedback if (Train->ggDoorLeftOffButton.SubModel != nullptr) @@ -356,12 +356,12 @@ void TTrain::OnCommand_doorcloseleft(TTrain *Train, command_data const &Command) else if (Command.action == GLFW_RELEASE) { - if (Train->mvOccupied->Doors.has_autowarning) + if (Train->occupied->Doors.has_autowarning) { // automatic departure signal delays actual door closing until the button is released - Train->mvOccupied->signal_departure(false); + Train->occupied->signal_departure(false); // now we can actually close the door - Train->mvOccupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right, false); + Train->occupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right, false); } // visual feedback // dedicated closing buttons are presumed to be impulse switches and return automatically to neutral position @@ -402,7 +402,7 @@ void TTrain::OnCommand_doortoggleright(TTrain *Train, command_data const &Comman if (true == (Train->ggDoorRightButton.GetDesiredValue() > 0.5 || Train->ggDoorRightOnButton.GetDesiredValue() > 0.5)) { // open - if (Train->mvOccupied->Doors.has_autowarning && Train->mvOccupied->DepartureSignal) + if (Train->occupied->Doors.has_autowarning && Train->occupied->DepartureSignal) { // complete closing the doors if (Train->ggDoorAllOffButton.SubModel != nullptr && Train->ggDoorRightOffButton.SubModel == nullptr) @@ -449,7 +449,7 @@ void TTrain::OnCommand_dooropenright(TTrain *Train, command_data const &Command) { - if (auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == control_t::driver || Train->mvOccupied->Doors.open_control == control_t::mixed}; false == remoteopencontrol) + if (auto const remoteopencontrol{Train->occupied->Doors.open_control == control_t::driver || Train->occupied->Doors.open_control == control_t::mixed}; false == remoteopencontrol) { return; } @@ -463,7 +463,7 @@ void TTrain::OnCommand_dooropenright(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - Train->mvOccupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left, true); + Train->occupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left, true); // visual feedback if (Train->ggDoorRightOnButton.SubModel != nullptr) { @@ -491,7 +491,7 @@ void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command { - if (auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == control_t::driver || Train->mvOccupied->Doors.close_control == control_t::mixed}; false == remoteclosecontrol) + if (auto const remoteclosecontrol{Train->occupied->Doors.close_control == control_t::driver || Train->occupied->Doors.close_control == control_t::mixed}; false == remoteclosecontrol) { return; } @@ -505,14 +505,14 @@ void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { - if (Train->mvOccupied->Doors.has_autowarning) + if (Train->occupied->Doors.has_autowarning) { // automatic departure signal delays actual door closing until the button is released - Train->mvOccupied->signal_departure(true); + Train->occupied->signal_departure(true); } else { - Train->mvOccupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left, false); + Train->occupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left, false); } // visual feedback if (Train->ggDoorRightOffButton.SubModel != nullptr) @@ -529,12 +529,12 @@ void TTrain::OnCommand_doorcloseright(TTrain *Train, command_data const &Command else if (Command.action == GLFW_RELEASE) { - if (Train->mvOccupied->Doors.has_autowarning) + if (Train->occupied->Doors.has_autowarning) { // automatic departure signal delays actual door closing until the button is released - Train->mvOccupied->signal_departure(false); + Train->occupied->signal_departure(false); // now we can actually close the door - Train->mvOccupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left, false); + Train->occupied->OperateDoors(Train->cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left, false); } // visual feedback // dedicated closing buttons are presumed to be impulse switches and return automatically to neutral position @@ -547,7 +547,7 @@ void TTrain::OnCommand_dooropenall(TTrain *Train, command_data const &Command) { - if (auto const remoteopencontrol{Train->mvOccupied->Doors.open_control == control_t::driver || Train->mvOccupied->Doors.open_control == control_t::mixed}; false == remoteopencontrol) + if (auto const remoteopencontrol{Train->occupied->Doors.open_control == control_t::driver || Train->occupied->Doors.open_control == control_t::mixed}; false == remoteopencontrol) { return; } @@ -565,8 +565,8 @@ void TTrain::OnCommand_dooropenall(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - Train->mvOccupied->OperateDoors(VehicleSide::right, true); - Train->mvOccupied->OperateDoors(VehicleSide::left, true); + Train->occupied->OperateDoors(VehicleSide::right, true); + Train->occupied->OperateDoors(VehicleSide::left, true); // visual feedback Train->ggDoorAllOnButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -581,7 +581,7 @@ void TTrain::OnCommand_doorcloseall(TTrain *Train, command_data const &Command) { - if (auto const remoteclosecontrol{Train->mvOccupied->Doors.close_control == control_t::driver || Train->mvOccupied->Doors.close_control == control_t::mixed}; false == remoteclosecontrol) + if (auto const remoteclosecontrol{Train->occupied->Doors.close_control == control_t::driver || Train->occupied->Doors.close_control == control_t::mixed}; false == remoteclosecontrol) { return; } @@ -599,15 +599,15 @@ void TTrain::OnCommand_doorcloseall(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - if (Train->mvOccupied->Doors.has_autowarning) + if (Train->occupied->Doors.has_autowarning) { - Train->mvOccupied->signal_departure(true); + Train->occupied->signal_departure(true); } if (Train->ggDoorAllOffButton.type() != TGaugeType::push_delayed) { // delays the action until the button is released - Train->mvOccupied->OperateDoors(VehicleSide::right, false); - Train->mvOccupied->OperateDoors(VehicleSide::left, false); + Train->occupied->OperateDoors(VehicleSide::right, false); + Train->occupied->OperateDoors(VehicleSide::left, false); } // visual feedback Train->ggDoorLeftButton.UpdateValue(0.0, Train->dsbSwitch); @@ -617,15 +617,15 @@ void TTrain::OnCommand_doorcloseall(TTrain *Train, command_data const &Command) } else if (Command.action == GLFW_RELEASE) { - if (Train->mvOccupied->Doors.has_autowarning) + if (Train->occupied->Doors.has_autowarning) { - Train->mvOccupied->signal_departure(false); + Train->occupied->signal_departure(false); } if (Train->ggDoorAllOffButton.type() == TGaugeType::push_delayed) { // now we can actually close the door - Train->mvOccupied->OperateDoors(VehicleSide::right, false); - Train->mvOccupied->OperateDoors(VehicleSide::left, false); + Train->occupied->OperateDoors(VehicleSide::right, false); + Train->occupied->OperateDoors(VehicleSide::left, false); } // visual feedback if (Train->ggDoorAllOffButton.SubModel) @@ -641,11 +641,11 @@ void TTrain::OnCommand_doorsteptoggle(TTrain *Train, command_data const &Command // effect if (false == Train->ggDoorStepButton.is_delayed()) { - Train->mvOccupied->PermitDoorStep(false == Train->mvOccupied->Doors.step_enabled); + Train->occupied->PermitDoorStep(false == Train->occupied->Doors.step_enabled); } // visual feedback auto const isactive{(Train->ggDoorStepButton.is_push() // always press push button - || Train->mvOccupied->Doors.step_enabled)}; // for toggle buttons indicate item state + || Train->occupied->Doors.step_enabled)}; // for toggle buttons indicate item state Train->ggDoorStepButton.UpdateValue(isactive ? 1 : 0); } else if (Command.action == GLFW_RELEASE) @@ -653,7 +653,7 @@ void TTrain::OnCommand_doorsteptoggle(TTrain *Train, command_data const &Command // effect if (Train->ggDoorStepButton.is_delayed()) { - Train->mvOccupied->PermitDoorStep(false == Train->mvOccupied->Doors.step_enabled); + Train->occupied->PermitDoorStep(false == Train->occupied->Doors.step_enabled); } // visual feedback if (Train->ggDoorStepButton.is_push()) @@ -668,7 +668,7 @@ void TTrain::OnCommand_doormodetoggle(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { - Train->mvOccupied->ChangeDoorControlMode(false == Train->mvOccupied->Doors.remote_only); + Train->occupied->ChangeDoorControlMode(false == Train->occupied->Doors.remote_only); } } @@ -681,14 +681,14 @@ void TTrain::OnCommand_mirrorstoggle(TTrain *Train, command_data const &Command) } // only reacting to press, so the sound can loop uninterrupted - if (false == Train->mvOccupied->MirrorForbidden) + if (false == Train->occupied->MirrorForbidden) { // turn on - Train->mvOccupied->MirrorForbidden = true; + Train->occupied->MirrorForbidden = true; } else { // turn off - Train->mvOccupied->MirrorForbidden = false; + Train->occupied->MirrorForbidden = false; } } diff --git a/vehicle/cab/equipmentcommands.cpp b/vehicle/cab/equipmentcommands.cpp index fc0128325..4790ab17b 100644 --- a/vehicle/cab/equipmentcommands.cpp +++ b/vehicle/cab/equipmentcommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -62,7 +62,7 @@ void TTrain::OnCommand_heatingtoggle(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { // ignore repeats so the switch doesn't flip back and forth if key is held down - if (false == Train->mvControlled->HeatingAllow) + if (false == Train->controlled->HeatingAllow) { // turn on OnCommand_heatingenable(Train, Command); @@ -73,7 +73,7 @@ void TTrain::OnCommand_heatingtoggle(TTrain *Train, command_data const &Command) OnCommand_heatingdisable(Train, Command); } } - else if (Command.action == GLFW_RELEASE && (Train->ggTrainHeatingButton.type() == TGaugeType::push || Train->mvOccupied->HeatingSwitchImpulse)) + else if (Command.action == GLFW_RELEASE && (Train->ggTrainHeatingButton.type() == TGaugeType::push || Train->occupied->HeatingSwitchImpulse)) { // impulse switch // visual feedback @@ -87,11 +87,11 @@ void TTrain::OnCommand_heatingenable(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - Train->mvOccupied->HeatingSwitch(true); + Train->occupied->HeatingSwitch(true); // visual feedback Train->ggTrainHeatingButton.UpdateValue(1.0, Train->dsbSwitch); } - else if (Command.action == GLFW_RELEASE && Train->mvOccupied->HeatingSwitchImpulse) + else if (Command.action == GLFW_RELEASE && Train->occupied->HeatingSwitchImpulse) { // the switch springs back to the middle Train->ggTrainHeatingButton.UpdateValue(0.0, Train->dsbSwitch); @@ -104,10 +104,10 @@ void TTrain::OnCommand_heatingdisable(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { - Train->mvOccupied->HeatingSwitch(false); + Train->occupied->HeatingSwitch(false); // visual feedback: an impulse switch is pushed the other way, down auto position{0.0}; - if (Train->mvOccupied->HeatingSwitchImpulse) + if (Train->occupied->HeatingSwitchImpulse) { position = -1.0; } @@ -117,7 +117,7 @@ void TTrain::OnCommand_heatingdisable(TTrain *Train, command_data const &Command } Train->ggTrainHeatingButton.UpdateValue(position, Train->dsbSwitch); } - else if (Command.action == GLFW_RELEASE && Train->mvOccupied->HeatingSwitchImpulse) + else if (Command.action == GLFW_RELEASE && Train->occupied->HeatingSwitchImpulse) { Train->ggTrainHeatingButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -209,7 +209,7 @@ void TTrain::OnCommand_springbraketoggle(TTrain *Train, command_data const &Comm if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvOccupied->SpringBrake.Activate) + if (false == Train->occupied->SpringBrake.Activate) { // turn on OnCommand_springbrakeenable(Train, Command); @@ -234,7 +234,7 @@ void TTrain::OnCommand_springbrakeenable(TTrain *Train, command_data const &Comm if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SpringBrakeActivate(true); + Train->occupied->SpringBrakeActivate(true); // visual feedback Train->ggSpringBrakeOnButton.UpdateValue(1.0, Train->dsbSwitch); Train->ggSpringBrakeOffButton.UpdateValue(0.0, Train->dsbSwitch); @@ -252,7 +252,7 @@ void TTrain::OnCommand_springbrakedisable(TTrain *Train, command_data const &Com if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SpringBrakeActivate(false); + Train->occupied->SpringBrakeActivate(false); // visual feedback Train->ggSpringBrakeOffButton.UpdateValue(1.0, Train->dsbSwitch); Train->ggSpringBrakeOnButton.UpdateValue(0.0, Train->dsbSwitch); @@ -270,7 +270,7 @@ void TTrain::OnCommand_springbrakeshutofftoggle(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->mvOccupied->SpringBrake.ShuttOff) + if (false == Train->occupied->SpringBrake.ShuttOff) { // turn on OnCommand_springbrakeshutoffenable(Train, Command); @@ -288,7 +288,7 @@ void TTrain::OnCommand_springbrakeshutoffenable(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SpringBrakeShutOff(true); + Train->occupied->SpringBrakeShutOff(true); } }; @@ -297,7 +297,7 @@ void TTrain::OnCommand_springbrakeshutoffdisable(TTrain *Train, command_data con if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SpringBrakeShutOff(false); + Train->occupied->SpringBrakeShutOff(false); } }; @@ -311,7 +311,7 @@ void TTrain::OnCommand_springbrakerelease(TTrain *Train, command_data const &Com { return; } - Train->mvOccupied->SpringBrakeRelease(); + Train->occupied->SpringBrakeRelease(); } }; @@ -320,7 +320,7 @@ void TTrain::OnCommand_speedcontrolincrease(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SpeedCtrlInc(); + Train->occupied->SpeedCtrlInc(); // visual feedback Train->ggSpeedControlIncreaseButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -337,7 +337,7 @@ void TTrain::OnCommand_speedcontroldecrease(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SpeedCtrlDec(); + Train->occupied->SpeedCtrlDec(); // visual feedback Train->ggSpeedControlDecreaseButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -354,7 +354,7 @@ void TTrain::OnCommand_speedcontrolpowerincrease(TTrain *Train, command_data con if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SpeedCtrlPowerInc(); + Train->occupied->SpeedCtrlPowerInc(); // visual feedback Train->ggSpeedControlPowerIncreaseButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -371,7 +371,7 @@ void TTrain::OnCommand_speedcontrolpowerdecrease(TTrain *Train, command_data con if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SpeedCtrlPowerDec(); + Train->occupied->SpeedCtrlPowerDec(); // visual feedback Train->ggSpeedControlPowerDecreaseButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -391,7 +391,7 @@ void TTrain::OnCommand_speedcontrolbutton(TTrain *Train, command_data const &Com if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvOccupied->SpeedCtrlButton(itemindex); + Train->occupied->SpeedCtrlButton(itemindex); // visual feedback Train->ggSpeedCtrlButtons[itemindex].UpdateValue(1.0, Train->dsbSwitch); } @@ -412,21 +412,21 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; - auto const flag{CouplingSet::FromBits(Train->DynamicObject->MoverParameters->inductionMotor.inverterControlCouplings)}; - TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, flag); + bool kier = Train->DynamicObject->DirectionGet() * Train->occupied->CabOccupied > 0; + auto const flag{CouplingSet::FromBits(Train->DynamicObject->physics->inductionMotor.inverterControlCouplings)}; + TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->occupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, flag); while (p) { - if (p->MoverParameters->inductionMotor.traction.maxPower > 1) + if (p->physics->inductionMotor.traction.maxPower > 1) { - if (itemindex < p->MoverParameters->inductionMotor.inverterCount) + if (itemindex < p->physics->inductionMotor.inverterCount) { - p->MoverParameters->inductionMotor.inverters[itemindex].Activate = true; + p->physics->inductionMotor.inverters[itemindex].Activate = true; break; } else { - itemindex -= p->MoverParameters->inductionMotor.inverterCount; + itemindex -= p->physics->inductionMotor.inverterCount; } } p = kier ? p->Next(flag) : p->Prev(flag); @@ -451,21 +451,21 @@ void TTrain::OnCommand_inverterdisable(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 - bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; - auto const flag{CouplingSet::FromBits(Train->DynamicObject->MoverParameters->inductionMotor.inverterControlCouplings)}; - TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, flag); + bool kier = Train->DynamicObject->DirectionGet() * Train->occupied->CabOccupied > 0; + auto const flag{CouplingSet::FromBits(Train->DynamicObject->physics->inductionMotor.inverterControlCouplings)}; + TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->occupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, flag); while (p) { - if (p->MoverParameters->inductionMotor.traction.maxPower > 1) + if (p->physics->inductionMotor.traction.maxPower > 1) { - if (itemindex < p->MoverParameters->inductionMotor.inverterCount) + if (itemindex < p->physics->inductionMotor.inverterCount) { - p->MoverParameters->inductionMotor.inverters[itemindex].Activate = false; + p->physics->inductionMotor.inverters[itemindex].Activate = false; break; } else { - itemindex -= p->MoverParameters->inductionMotor.inverterCount; + itemindex -= p->physics->inductionMotor.inverterCount; } } p = kier ? p->Next(flag) : p->Prev(flag); @@ -490,23 +490,23 @@ void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - bool kier = Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0; - auto const flag{CouplingSet::FromBits(Train->DynamicObject->MoverParameters->inductionMotor.inverterControlCouplings)}; - TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, flag); + bool kier = Train->DynamicObject->DirectionGet() * Train->occupied->CabOccupied > 0; + auto const flag{CouplingSet::FromBits(Train->DynamicObject->physics->inductionMotor.inverterControlCouplings)}; + TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->occupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, flag); while (p) { - if (p->MoverParameters->inductionMotor.traction.maxPower > 1) + if (p->physics->inductionMotor.traction.maxPower > 1) { - if (itemindex < p->MoverParameters->inductionMotor.inverterCount) + if (itemindex < p->physics->inductionMotor.inverterCount) { - p->MoverParameters->inductionMotor.inverters[itemindex].Activate = !p->MoverParameters->inductionMotor.inverters[itemindex].Activate; + p->physics->inductionMotor.inverters[itemindex].Activate = !p->physics->inductionMotor.inverters[itemindex].Activate; // visual feedback - item.UpdateValue(p->MoverParameters->inductionMotor.inverters[itemindex].Activate ? 1.0 : 0.0, Train->dsbSwitch); + item.UpdateValue(p->physics->inductionMotor.inverters[itemindex].Activate ? 1.0 : 0.0, Train->dsbSwitch); break; } else { - itemindex -= p->MoverParameters->inductionMotor.inverterCount; + itemindex -= p->physics->inductionMotor.inverterCount; } } p = kier ? p->Next(flag) : p->Prev(flag); diff --git a/vehicle/cab/internal.h b/vehicle/cab/internal.h index 94bfcda9d..770c556bc 100644 --- a/vehicle/cab/internal.h +++ b/vehicle/cab/internal.h @@ -39,7 +39,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include diff --git a/vehicle/cab/lightcommands.cpp b/vehicle/cab/lightcommands.cpp index 5089e3f85..b8125cb40 100644 --- a/vehicle/cab/lightcommands.cpp +++ b/vehicle/cab/lightcommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -51,7 +51,7 @@ http://mozilla.org/MPL/2.0/. // the cab light switch (cablight_sw:) is bound to the light state and follows it by itself void TTrain::set_cab_light_from_lights_preset() { - auto const cablight{mvOccupied->LightsPresetCabLight(mvOccupied->LightsPos)}; + auto const cablight{occupied->LightsPresetCabLight(occupied->LightsPos)}; if (false == cablight.has_value()) { return; @@ -83,7 +83,7 @@ void TTrain::set_cab_light_from_lights_preset() void TTrain::OnCommand_lightspresetactivatenext(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo == 0) + if (Train->occupied->LightsPosNo == 0) { // no preset selector return; @@ -94,11 +94,11 @@ void TTrain::OnCommand_lightspresetactivatenext(TTrain *Train, command_data cons return; } - if (Train->mvOccupied->LightsPos < Train->mvOccupied->LightsPosNo || true == Train->mvOccupied->LightsWrap) + if (Train->occupied->LightsPos < Train->occupied->LightsPosNo || true == Train->occupied->LightsWrap) { // active light preset is stored as value in range 1-LigthPosNo - auto const restartcycle{Train->mvOccupied->LightsPos >= Train->mvOccupied->LightsPosNo}; - Train->mvOccupied->LightsPos = false == restartcycle ? Train->mvOccupied->LightsPos + 1 : 1; // wrap mode + auto const restartcycle{Train->occupied->LightsPos >= Train->occupied->LightsPosNo}; + Train->occupied->LightsPos = false == restartcycle ? Train->occupied->LightsPos + 1 : 1; // wrap mode Train->Dynamic()->SetLights(); Train->set_cab_light_from_lights_preset(); @@ -107,13 +107,13 @@ void TTrain::OnCommand_lightspresetactivatenext(TTrain *Train, command_data cons { if (false == restartcycle) { - Train->ggLightsButton.UpdateValue(static_cast(Train->mvOccupied->LightsPos - 1), Train->dsbSwitch); + Train->ggLightsButton.UpdateValue(static_cast(Train->occupied->LightsPos - 1), Train->dsbSwitch); } else { // past the last position to the first one: a knob turning all the way round turns on rather than // back across all the positions, and the position reached sounds (eu07/maszyna#464) - Train->ggLightsButton.UpdateValueWrapped(static_cast(Train->mvOccupied->LightsPos - 1), true, Train->mvOccupied->LightsPosNo, Train->dsbSwitch); + Train->ggLightsButton.UpdateValueWrapped(static_cast(Train->occupied->LightsPos - 1), true, Train->occupied->LightsPosNo, Train->dsbSwitch); } } } @@ -122,7 +122,7 @@ void TTrain::OnCommand_lightspresetactivatenext(TTrain *Train, command_data cons void TTrain::OnCommand_lightspresetactivateprevious(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo == 0) + if (Train->occupied->LightsPosNo == 0) { // no preset selector return; @@ -133,11 +133,11 @@ void TTrain::OnCommand_lightspresetactivateprevious(TTrain *Train, command_data return; } - if (Train->mvOccupied->LightsPos > 1 || true == Train->mvOccupied->LightsWrap) + if (Train->occupied->LightsPos > 1 || true == Train->occupied->LightsWrap) { // active light preset is stored as value in range 1-LigthPosNo - auto const restartcycle{Train->mvOccupied->LightsPos <= 1}; - Train->mvOccupied->LightsPos = false == restartcycle ? Train->mvOccupied->LightsPos - 1 : Train->mvOccupied->LightsPosNo; // wrap mode + auto const restartcycle{Train->occupied->LightsPos <= 1}; + Train->occupied->LightsPos = false == restartcycle ? Train->occupied->LightsPos - 1 : Train->occupied->LightsPosNo; // wrap mode Train->Dynamic()->SetLights(); Train->set_cab_light_from_lights_preset(); @@ -146,12 +146,12 @@ void TTrain::OnCommand_lightspresetactivateprevious(TTrain *Train, command_data { if (false == restartcycle) { - Train->ggLightsButton.UpdateValue(static_cast(Train->mvOccupied->LightsPos - 1), Train->dsbSwitch); + Train->ggLightsButton.UpdateValue(static_cast(Train->occupied->LightsPos - 1), Train->dsbSwitch); } else { // back past the first position to the last one, the same way (eu07/maszyna#464) - Train->ggLightsButton.UpdateValueWrapped(static_cast(Train->mvOccupied->LightsPos - 1), false, Train->mvOccupied->LightsPosNo, Train->dsbSwitch); + Train->ggLightsButton.UpdateValueWrapped(static_cast(Train->occupied->LightsPos - 1), false, Train->occupied->LightsPosNo, Train->dsbSwitch); } } } @@ -168,7 +168,7 @@ void TTrain::OnCommand_headlighttoggleleft(TTrain *Train, command_data const &Co if (Train->ggLeftEndLightButton.SubModel != nullptr || Train->ggLeftLightButton.SubModel == nullptr) { - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_left) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_left) == 0) { // turn on OnCommand_headlightenableleft(Train, Command); @@ -180,13 +180,13 @@ void TTrain::OnCommand_headlighttoggleleft(TTrain *Train, command_data const &Co } } else { // if the light is controlled by 3-way switch, handle both headlight and redmarker - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_left) == 0 && - (Train->mvOccupied->iLights[vehicleend] & light::redmarker_left) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_left) == 0 && + (Train->occupied->iLights[vehicleend] & light::redmarker_left) == 0) { // turn on OnCommand_headlightenableleft(Train, Command); } - else if (Train->mvOccupied->iLights[vehicleend] & light::headlight_left) + else if (Train->occupied->iLights[vehicleend] & light::headlight_left) { // switch to red OnCommand_redmarkerenableleft(Train, Command); @@ -203,16 +203,16 @@ void TTrain::OnCommand_headlighttoggleleft(TTrain *Train, command_data const &Co void TTrain::OnCommand_lightsset(TTrain *Train, command_data const &Command) { // set custom item in Lights inventory - Train->mvOccupied->Lights[VehicleEnd::front][17] = static_cast(Command.param1); - Train->mvOccupied->Lights[VehicleEnd::rear][17] = static_cast(Command.param2); - Train->mvOccupied->LightsPos = 18; // nasza custom pozycja + Train->occupied->Lights[VehicleEnd::front][17] = static_cast(Command.param1); + Train->occupied->Lights[VehicleEnd::rear][17] = static_cast(Command.param2); + Train->occupied->LightsPos = 18; // nasza custom pozycja Train->Dynamic()->SetLights(); } void TTrain::OnCommand_headlightenableleft(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -225,14 +225,14 @@ void TTrain::OnCommand_headlightenableleft(TTrain *Train, command_data const &Co // implementation auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_left) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_left) == 0) { - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_left; + Train->occupied->iLights[vehicleend] ^= light::headlight_left; } // if the light is controlled by 3-way switch, disable marker light if (Train->ggLeftEndLightButton.SubModel == nullptr) { - Train->mvOccupied->iLights[vehicleend] &= ~light::redmarker_left; + Train->occupied->iLights[vehicleend] &= ~light::redmarker_left; } } } @@ -240,7 +240,7 @@ void TTrain::OnCommand_headlightenableleft(TTrain *Train, command_data const &Co void TTrain::OnCommand_headlightdisableleft(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -251,12 +251,12 @@ void TTrain::OnCommand_headlightdisableleft(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_left) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_left) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_left; + Train->occupied->iLights[vehicleend] ^= light::headlight_left; // visual feedback Train->ggLeftLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -273,7 +273,7 @@ void TTrain::OnCommand_headlighttoggleright(TTrain *Train, command_data const &C if (Train->ggRightEndLightButton.SubModel != nullptr || Train->ggRightLightButton.SubModel == nullptr) { - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_right) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_right) == 0) { // turn on OnCommand_headlightenableright(Train, Command); @@ -285,13 +285,13 @@ void TTrain::OnCommand_headlighttoggleright(TTrain *Train, command_data const &C } } else { // if the light is controlled by 3-way switch, handle both headlight and redmarker - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_right) == 0 && - (Train->mvOccupied->iLights[vehicleend] & light::redmarker_right) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_right) == 0 && + (Train->occupied->iLights[vehicleend] & light::redmarker_right) == 0) { // turn on OnCommand_headlightenableright(Train, Command); } - else if (Train->mvOccupied->iLights[vehicleend] & light::headlight_right) + else if (Train->occupied->iLights[vehicleend] & light::headlight_right) { // switch to red OnCommand_redmarkerenableright(Train, Command); @@ -308,7 +308,7 @@ void TTrain::OnCommand_headlighttoggleright(TTrain *Train, command_data const &C void TTrain::OnCommand_headlightenableright(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -321,14 +321,14 @@ void TTrain::OnCommand_headlightenableright(TTrain *Train, command_data const &C // implementation auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_right) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_right) == 0) { - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_right; + Train->occupied->iLights[vehicleend] ^= light::headlight_right; } // if the light is controlled by 3-way switch, disable marker light if (Train->ggRightEndLightButton.SubModel == nullptr) { - Train->mvOccupied->iLights[vehicleend] &= ~light::redmarker_right; + Train->occupied->iLights[vehicleend] &= ~light::redmarker_right; } } } @@ -336,7 +336,7 @@ void TTrain::OnCommand_headlightenableright(TTrain *Train, command_data const &C void TTrain::OnCommand_headlightdisableright(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -347,12 +347,12 @@ void TTrain::OnCommand_headlightdisableright(TTrain *Train, command_data const & // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_right) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_right) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_right; + Train->occupied->iLights[vehicleend] ^= light::headlight_right; // visual feedback Train->ggRightLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -366,7 +366,7 @@ void TTrain::OnCommand_headlighttoggleupper(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_upper) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_upper) == 0) { // turn on OnCommand_headlightenableupper(Train, Command); @@ -382,7 +382,7 @@ void TTrain::OnCommand_headlighttoggleupper(TTrain *Train, command_data const &C void TTrain::OnCommand_headlightenableupper(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -393,12 +393,12 @@ void TTrain::OnCommand_headlightenableupper(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_upper) != 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_upper) != 0) { return; } // already enabled - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_upper; + Train->occupied->iLights[vehicleend] ^= light::headlight_upper; // visual feedback Train->ggUpperLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -407,7 +407,7 @@ void TTrain::OnCommand_headlightenableupper(TTrain *Train, command_data const &C void TTrain::OnCommand_headlightdisableupper(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -418,12 +418,12 @@ void TTrain::OnCommand_headlightdisableupper(TTrain *Train, command_data const & // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::headlight_upper) == 0) + if ((Train->occupied->iLights[vehicleend] & light::headlight_upper) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::headlight_upper; + Train->occupied->iLights[vehicleend] ^= light::headlight_upper; // visual feedback Train->ggUpperLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -437,7 +437,7 @@ void TTrain::OnCommand_redmarkertoggleleft(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_left) == 0) + if ((Train->occupied->iLights[vehicleend] & light::redmarker_left) == 0) { // turn on OnCommand_redmarkerenableleft(Train, Command); @@ -453,7 +453,7 @@ void TTrain::OnCommand_redmarkertoggleleft(TTrain *Train, command_data const &Co void TTrain::OnCommand_redmarkerenableleft(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -464,12 +464,12 @@ void TTrain::OnCommand_redmarkerenableleft(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_left) != 0) + if ((Train->occupied->iLights[vehicleend] & light::redmarker_left) != 0) { return; } // already enabled - Train->mvOccupied->iLights[vehicleend] ^= light::redmarker_left; + Train->occupied->iLights[vehicleend] ^= light::redmarker_left; // visual feedback if (Train->ggLeftEndLightButton.SubModel != nullptr) { @@ -481,7 +481,7 @@ void TTrain::OnCommand_redmarkerenableleft(TTrain *Train, command_data const &Co // this is crude, but for now will do Train->ggLeftLightButton.UpdateValue(-1.0, Train->dsbSwitch); // if the light is controlled by 3-way switch, disable the headlight - Train->mvOccupied->iLights[vehicleend] &= ~light::headlight_left; + Train->occupied->iLights[vehicleend] &= ~light::headlight_left; } } } @@ -489,7 +489,7 @@ void TTrain::OnCommand_redmarkerenableleft(TTrain *Train, command_data const &Co void TTrain::OnCommand_redmarkerdisableleft(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -500,12 +500,12 @@ void TTrain::OnCommand_redmarkerdisableleft(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_left) == 0) + if ((Train->occupied->iLights[vehicleend] & light::redmarker_left) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::redmarker_left; + Train->occupied->iLights[vehicleend] ^= light::redmarker_left; // visual feedback if (Train->ggLeftEndLightButton.SubModel != nullptr) { @@ -528,7 +528,7 @@ void TTrain::OnCommand_redmarkertoggleright(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_right) == 0) + if ((Train->occupied->iLights[vehicleend] & light::redmarker_right) == 0) { // turn on OnCommand_redmarkerenableright(Train, Command); @@ -544,7 +544,7 @@ void TTrain::OnCommand_redmarkertoggleright(TTrain *Train, command_data const &C void TTrain::OnCommand_redmarkerenableright(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -555,12 +555,12 @@ void TTrain::OnCommand_redmarkerenableright(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_right) != 0) + if ((Train->occupied->iLights[vehicleend] & light::redmarker_right) != 0) { return; } // already enabled - Train->mvOccupied->iLights[vehicleend] ^= light::redmarker_right; + Train->occupied->iLights[vehicleend] ^= light::redmarker_right; // visual feedback if (Train->ggRightEndLightButton.SubModel != nullptr) { @@ -572,7 +572,7 @@ void TTrain::OnCommand_redmarkerenableright(TTrain *Train, command_data const &C // this is crude, but for now will do Train->ggRightLightButton.UpdateValue(-1.0, Train->dsbSwitch); // if the light is controlled by 3-way switch, disable the headlight - Train->mvOccupied->iLights[vehicleend] &= ~light::headlight_right; + Train->occupied->iLights[vehicleend] &= ~light::headlight_right; } } } @@ -580,7 +580,7 @@ void TTrain::OnCommand_redmarkerenableright(TTrain *Train, command_data const &C void TTrain::OnCommand_redmarkerdisableright(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -591,12 +591,12 @@ void TTrain::OnCommand_redmarkerdisableright(TTrain *Train, command_data const & // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleend{Train->cab_to_end()}; - if ((Train->mvOccupied->iLights[vehicleend] & light::redmarker_right) == 0) + if ((Train->occupied->iLights[vehicleend] & light::redmarker_right) == 0) { return; } // already disabled - Train->mvOccupied->iLights[vehicleend] ^= light::redmarker_right; + Train->occupied->iLights[vehicleend] ^= light::redmarker_right; // visual feedback if (Train->ggRightEndLightButton.SubModel != nullptr) { @@ -614,7 +614,7 @@ void TTrain::OnCommand_redmarkerdisableright(TTrain *Train, command_data const & void TTrain::OnCommand_headlighttogglerearleft(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -625,7 +625,7 @@ void TTrain::OnCommand_headlighttogglerearleft(TTrain *Train, command_data const // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_right) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::headlight_right) == 0) { OnCommand_headlightenablerearleft(Train, Command); } @@ -638,7 +638,7 @@ void TTrain::OnCommand_headlighttogglerearleft(TTrain *Train, command_data const void TTrain::OnCommand_headlightenablerearleft(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -648,10 +648,10 @@ void TTrain::OnCommand_headlightenablerearleft(TTrain *Train, command_data const { auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; // already enabled - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_right) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::headlight_right) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_right; + Train->occupied->iLights[vehicleotherend] ^= light::headlight_right; // visual feedback Train->ggRearLeftLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -660,7 +660,7 @@ void TTrain::OnCommand_headlightenablerearleft(TTrain *Train, command_data const void TTrain::OnCommand_headlightdisablerearleft(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -669,13 +669,13 @@ void TTrain::OnCommand_headlightdisablerearleft(TTrain *Train, command_data cons { auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; // already disabled - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_right) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::headlight_right) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_right; + Train->occupied->iLights[vehicleotherend] ^= light::headlight_right; // visual feedback Train->ggRearLeftLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -688,7 +688,7 @@ void TTrain::OnCommand_headlighttogglerearright(TTrain *Train, command_data cons // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_left) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::headlight_left) == 0) { OnCommand_headlightenablerearright(Train, Command); } @@ -701,7 +701,7 @@ void TTrain::OnCommand_headlighttogglerearright(TTrain *Train, command_data cons void TTrain::OnCommand_headlightenablerearright(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -712,10 +712,10 @@ void TTrain::OnCommand_headlightenablerearright(TTrain *Train, command_data cons // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_left) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::headlight_left) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_left; + Train->occupied->iLights[vehicleotherend] ^= light::headlight_left; // visual feedback Train->ggRearRightLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -724,7 +724,7 @@ void TTrain::OnCommand_headlightenablerearright(TTrain *Train, command_data cons void TTrain::OnCommand_headlightdisablerearright(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -735,13 +735,13 @@ void TTrain::OnCommand_headlightdisablerearright(TTrain *Train, command_data con // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; // already disabled - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_left) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::headlight_left) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_left; + Train->occupied->iLights[vehicleotherend] ^= light::headlight_left; // visual feedback Train->ggRearRightLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -750,7 +750,7 @@ void TTrain::OnCommand_headlightdisablerearright(TTrain *Train, command_data con void TTrain::OnCommand_headlighttogglerearupper(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -760,7 +760,7 @@ void TTrain::OnCommand_headlighttogglerearupper(TTrain *Train, command_data cons { // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_upper) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::headlight_upper) == 0) { OnCommand_headlightenablerearupper(Train, Command); } @@ -774,7 +774,7 @@ void TTrain::OnCommand_headlighttogglerearupper(TTrain *Train, command_data cons void TTrain::OnCommand_headlightenablerearupper(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -784,10 +784,10 @@ void TTrain::OnCommand_headlightenablerearupper(TTrain *Train, command_data cons { // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_upper) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::headlight_upper) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_upper; + Train->occupied->iLights[vehicleotherend] ^= light::headlight_upper; // visual feedback Train->ggRearUpperLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -797,7 +797,7 @@ void TTrain::OnCommand_headlightenablerearupper(TTrain *Train, command_data cons void TTrain::OnCommand_headlightdisablerearupper(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -808,13 +808,13 @@ void TTrain::OnCommand_headlightdisablerearupper(TTrain *Train, command_data con // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; // already disabled? - if ((Train->mvOccupied->iLights[vehicleotherend] & light::headlight_upper) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::headlight_upper) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::headlight_upper; + Train->occupied->iLights[vehicleotherend] ^= light::headlight_upper; // visual feedback Train->ggRearUpperLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -822,14 +822,14 @@ void TTrain::OnCommand_headlightdisablerearupper(TTrain *Train, command_data con void TTrain::OnCommand_modernlightdimmerincrease(TTrain *Train, command_data const &Command) { - if (!Train->mvOccupied->enableModernDimmer) + if (!Train->occupied->enableModernDimmer) return; // if modern dimmer is disabled, skip entire command if (Command.action == GLFW_PRESS) { // update modern dimmer state - if (false == Train->mvOccupied->stepDimmerPosition(1)) + if (false == Train->occupied->stepDimmerPosition(1)) return; // już na maksimum i nie można cyklicznie - auto const dimPos = Train->mvOccupied->modernDimmerPosition; + auto const dimPos = Train->occupied->modernDimmerPosition; // update lightning // Train->Dynamic()->SetLights(); Train->Dynamic()->SetLightDimmings(); @@ -841,14 +841,14 @@ void TTrain::OnCommand_modernlightdimmerincrease(TTrain *Train, command_data con } void TTrain::OnCommand_modernlightdimmerdecrease(TTrain *Train, command_data const &Command) { - if (!Train->mvOccupied->enableModernDimmer) + if (!Train->occupied->enableModernDimmer) return; // jeśli dimmer jest wyłączony, olewamy if (Command.action == GLFW_PRESS) { - if (false == Train->mvOccupied->stepDimmerPosition(-1)) + if (false == Train->occupied->stepDimmerPosition(-1)) return; // już na minimum i nie można cyklicznie - auto const dimPos = Train->mvOccupied->modernDimmerPosition; + auto const dimPos = Train->occupied->modernDimmerPosition; // Train->Dynamic()->SetLights(); Train->Dynamic()->SetLightDimmings(); @@ -865,7 +865,7 @@ void TTrain::OnCommand_redmarkertogglerearleft(TTrain *Train, command_data const // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_right) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::redmarker_right) == 0) { OnCommand_redmarkerenablerearleft(Train, Command); } @@ -879,7 +879,7 @@ void TTrain::OnCommand_redmarkertogglerearleft(TTrain *Train, command_data const void TTrain::OnCommand_redmarkerenablerearleft(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -889,10 +889,10 @@ void TTrain::OnCommand_redmarkerenablerearleft(TTrain *Train, command_data const { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_right) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::redmarker_right) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::redmarker_right; + Train->occupied->iLights[vehicleotherend] ^= light::redmarker_right; // visual feedback Train->ggRearLeftEndLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -902,7 +902,7 @@ void TTrain::OnCommand_redmarkerenablerearleft(TTrain *Train, command_data const void TTrain::OnCommand_redmarkerdisablerearleft(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -912,12 +912,12 @@ void TTrain::OnCommand_redmarkerdisablerearleft(TTrain *Train, command_data cons { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_right) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::redmarker_right) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::redmarker_right; + Train->occupied->iLights[vehicleotherend] ^= light::redmarker_right; // visual feedback Train->ggRearLeftEndLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -926,7 +926,7 @@ void TTrain::OnCommand_redmarkerdisablerearleft(TTrain *Train, command_data cons void TTrain::OnCommand_redmarkertogglerearright(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -937,7 +937,7 @@ void TTrain::OnCommand_redmarkertogglerearright(TTrain *Train, command_data cons // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; // only reacting to press, so the switch doesn't flip back and forth if key is held down - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_left) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::redmarker_left) == 0) { OnCommand_redmarkerenablerearright(Train, Command); } @@ -951,7 +951,7 @@ void TTrain::OnCommand_redmarkertogglerearright(TTrain *Train, command_data cons void TTrain::OnCommand_redmarkerenablerearright(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -961,10 +961,10 @@ void TTrain::OnCommand_redmarkerenablerearright(TTrain *Train, command_data cons { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_left) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::redmarker_left) == 0) { // turn on - Train->mvOccupied->iLights[vehicleotherend] ^= light::redmarker_left; + Train->occupied->iLights[vehicleotherend] ^= light::redmarker_left; // visual feedback Train->ggRearRightEndLightButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -974,7 +974,7 @@ void TTrain::OnCommand_redmarkerenablerearright(TTrain *Train, command_data cons void TTrain::OnCommand_redmarkerdisablerearright(TTrain *Train, command_data const &Command) { - if (Train->mvOccupied->LightsPosNo > 0) + if (Train->occupied->LightsPosNo > 0) { // lights are controlled by preset selector return; @@ -984,12 +984,12 @@ void TTrain::OnCommand_redmarkerdisablerearright(TTrain *Train, command_data con { // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc auto const vehicleotherend{(Train->cab_to_end() == VehicleEnd::front ? VehicleEnd::rear : VehicleEnd::front)}; - if ((Train->mvOccupied->iLights[vehicleotherend] & light::redmarker_left) == 0) + if ((Train->occupied->iLights[vehicleotherend] & light::redmarker_left) == 0) { return; } // turn off - Train->mvOccupied->iLights[vehicleotherend] ^= light::redmarker_left; + Train->occupied->iLights[vehicleotherend] ^= light::redmarker_left; // visual feedback Train->ggRearRightEndLightButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -1014,10 +1014,10 @@ void TTrain::OnCommand_redmarkerstoggle(TTrain * /*Train*/, command_data const & auto const lightset{light::redmarker_left | light::redmarker_right}; - vehicle->MoverParameters->iLights[CouplNr] = - false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ? - vehicle->MoverParameters->iLights[CouplNr] |= lightset : // turn signals on - vehicle->MoverParameters->iLights[CouplNr] ^= lightset; // turn signals off + vehicle->physics->iLights[CouplNr] = + false == TestFlag(vehicle->physics->iLights[CouplNr], lightset) ? + vehicle->physics->iLights[CouplNr] |= lightset : // turn signals on + vehicle->physics->iLights[CouplNr] ^= lightset; // turn signals off } } @@ -1039,21 +1039,21 @@ void TTrain::OnCommand_endsignalstoggle(TTrain * /*Train*/, command_data const & auto const lightset{light::rearendsignals}; - vehicle->MoverParameters->iLights[CouplNr] = - false == TestFlag(vehicle->MoverParameters->iLights[CouplNr], lightset) ? - vehicle->MoverParameters->iLights[CouplNr] |= lightset : // turn signals on - vehicle->MoverParameters->iLights[CouplNr] ^= lightset; // turn signals off + vehicle->physics->iLights[CouplNr] = + false == TestFlag(vehicle->physics->iLights[CouplNr], lightset) ? + vehicle->physics->iLights[CouplNr] |= lightset : // turn signals on + vehicle->physics->iLights[CouplNr] ^= lightset; // turn signals off } } void TTrain::OnCommand_headlightsdimtoggle(TTrain *Train, command_data const &Command) { - if (Train->DynamicObject->MoverParameters->enableModernDimmer) + if (Train->DynamicObject->physics->enableModernDimmer) return; if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (Train->DynamicObject->MoverParameters->modernDimmerPosition == 0) + if (Train->DynamicObject->physics->modernDimmerPosition == 0) { // turn on OnCommand_headlightsdimenable(Train, Command); @@ -1069,7 +1069,7 @@ void TTrain::OnCommand_headlightsdimtoggle(TTrain *Train, command_data const &Co void TTrain::OnCommand_headlightsdimenable(TTrain *Train, command_data const &Command) { - if (Train->DynamicObject->MoverParameters->enableModernDimmer) + if (Train->DynamicObject->physics->enableModernDimmer) return; if (Command.action == GLFW_PRESS) { @@ -1089,7 +1089,7 @@ void TTrain::OnCommand_headlightsdimenable(TTrain *Train, command_data const &Co Train->DynamicObject->DimHeadlights = true; */ - Train->DynamicObject->MoverParameters->modernDimmerPosition = Train->DynamicObject->MoverParameters->clampDimmerPosition(1); // ustawiamy modern dimmer na flage przyciemnienia + Train->DynamicObject->physics->modernDimmerPosition = Train->DynamicObject->physics->clampDimmerPosition(1); // ustawiamy modern dimmer na flage przyciemnienia Train->DynamicObject->SetLightDimmings(); } } @@ -1097,7 +1097,7 @@ void TTrain::OnCommand_headlightsdimenable(TTrain *Train, command_data const &Co void TTrain::OnCommand_headlightsdimdisable(TTrain *Train, command_data const &Command) { - if (Train->DynamicObject->MoverParameters->enableModernDimmer) // nie wiem dlaczego to tak dziala ze jest odwrocona logika + if (Train->DynamicObject->physics->enableModernDimmer) // nie wiem dlaczego to tak dziala ze jest odwrocona logika return; if (Command.action == GLFW_PRESS) { @@ -1115,7 +1115,7 @@ void TTrain::OnCommand_headlightsdimdisable(TTrain *Train, command_data const &C Train->DynamicObject->DimHeadlights = false; */ - Train->DynamicObject->MoverParameters->modernDimmerPosition = 0; // ustawiamy modern dimmer na flage rozjasnienia + Train->DynamicObject->physics->modernDimmerPosition = 0; // ustawiamy modern dimmer na flage rozjasnienia Train->DynamicObject->SetLightDimmings(); } } @@ -1297,7 +1297,7 @@ void TTrain::OnCommand_compartmentlightstoggle(TTrain *Train, command_data const } // keep the switch from flipping back and forth if key is held down - if (false == Train->mvOccupied->CompartmentLights.is_active && false == Train->mvOccupied->CompartmentLights.is_enabled) + if (false == Train->occupied->CompartmentLights.is_active && false == Train->occupied->CompartmentLights.is_enabled) { // turn on OnCommand_compartmentlightsenable(Train, Command); @@ -1314,12 +1314,12 @@ void TTrain::OnCommand_compartmentlightsenable(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { - Train->mvOccupied->CompartmentLightsSwitch(true); + Train->occupied->CompartmentLightsSwitch(true); // withdraw the off request, unless a push type control in the cab withdraws it when released if (compartment_lights_switch::withdraws_other_request(Train->m_controlmapper.contains("compartmentlights_sw:"), Train->ggCompartmentLightsButton.is_toggle(), Train->m_controlmapper.contains("compartmentlightsoff_sw:"))) { - Train->mvOccupied->CompartmentLightsSwitchOff(false); + Train->occupied->CompartmentLightsSwitchOff(false); } // visual feedback if (Train->m_controlmapper.contains("compartmentlights_sw:")) @@ -1336,13 +1336,13 @@ void TTrain::OnCommand_compartmentlightsenable(TTrain *Train, command_data const if (Train->m_controlmapper.contains("compartmentlights_sw:") && Train->ggCompartmentLightsButton.type() == TGaugeType::push) { // return the switch to neutral position - Train->mvOccupied->CompartmentLightsSwitch(false); - Train->mvOccupied->CompartmentLightsSwitchOff(false); + Train->occupied->CompartmentLightsSwitch(false); + Train->occupied->CompartmentLightsSwitchOff(false); Train->ggCompartmentLightsButton.UpdateValue(0.5f); } if (Train->m_controlmapper.contains("compartmentlightson_sw:")) { - Train->mvOccupied->CompartmentLightsSwitch(false); + Train->occupied->CompartmentLightsSwitch(false); Train->ggCompartmentLightsOnButton.UpdateValue(0.0f, Train->dsbSwitch); } } @@ -1353,12 +1353,12 @@ void TTrain::OnCommand_compartmentlightsdisable(TTrain *Train, command_data cons if (Command.action == GLFW_PRESS) { - Train->mvOccupied->CompartmentLightsSwitchOff(true); + Train->occupied->CompartmentLightsSwitchOff(true); // withdraw the on request, unless a push type control in the cab withdraws it when released if (compartment_lights_switch::withdraws_other_request(Train->m_controlmapper.contains("compartmentlights_sw:"), Train->ggCompartmentLightsButton.is_toggle(), Train->m_controlmapper.contains("compartmentlightson_sw:"))) { - Train->mvOccupied->CompartmentLightsSwitch(false); + Train->occupied->CompartmentLightsSwitch(false); } // visual feedback if (Train->m_controlmapper.contains("compartmentlights_sw:")) @@ -1375,13 +1375,13 @@ void TTrain::OnCommand_compartmentlightsdisable(TTrain *Train, command_data cons if (Train->m_controlmapper.contains("compartmentlights_sw:") && Train->ggCompartmentLightsButton.type() == TGaugeType::push) { // return the switch to neutral position - Train->mvOccupied->CompartmentLightsSwitch(false); - Train->mvOccupied->CompartmentLightsSwitchOff(false); + Train->occupied->CompartmentLightsSwitch(false); + Train->occupied->CompartmentLightsSwitchOff(false); Train->ggCompartmentLightsButton.UpdateValue(0.5f); } if (Train->m_controlmapper.contains("compartmentlightsoff_sw:")) { - Train->mvOccupied->CompartmentLightsSwitchOff(false); + Train->occupied->CompartmentLightsSwitchOff(false); Train->ggCompartmentLightsOffButton.UpdateValue(0.0f, Train->dsbSwitch); } } diff --git a/vehicle/cab/pantographcommands.cpp b/vehicle/cab/pantographcommands.cpp index 2bf0f0d46..24a043416 100644 --- a/vehicle/cab/pantographcommands.cpp +++ b/vehicle/cab/pantographcommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -59,7 +59,7 @@ void TTrain::OnCommand_pantographtogglefront(TTrain *Train, command_data const & 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 &pantograph{Train->mvPantographUnit->Pantographs[VehicleEnd::front]}; + auto const &pantograph{Train->pantographUnit->Pantographs[VehicleEnd::front]}; auto const state{pantograph.valve.is_enabled || pantograph.is_active}; // fallback for impulse switches if (state) { @@ -73,10 +73,10 @@ void TTrain::OnCommand_pantographtogglefront(TTrain *Train, command_data const & else if (Command.action == GLFW_RELEASE) { // impulse switches return automatically to neutral position - if (Train->mvOccupied->PantSwitchType == "impulse") + if (Train->occupied->PantSwitchType == "impulse") { auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(VehicleEnd::front, operation_t::none, ismanual ? range_t::local : range_t::consist); + Train->occupied->OperatePantographValve(VehicleEnd::front, operation_t::none, ismanual ? range_t::local : range_t::consist); } } } @@ -93,7 +93,7 @@ void TTrain::OnCommand_pantographtogglerear(TTrain *Train, command_data const &C 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 &pantograph{Train->mvPantographUnit->Pantographs[VehicleEnd::rear]}; + auto const &pantograph{Train->pantographUnit->Pantographs[VehicleEnd::rear]}; auto const state{pantograph.valve.is_enabled || pantograph.is_active}; // fallback for impulse switches if (state) { @@ -107,10 +107,10 @@ void TTrain::OnCommand_pantographtogglerear(TTrain *Train, command_data const &C else if (Command.action == GLFW_RELEASE) { // impulse switches return automatically to neutral position - if (Train->mvOccupied->PantSwitchType == "impulse") + if (Train->occupied->PantSwitchType == "impulse") { auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(VehicleEnd::rear, operation_t::none, ismanual ? range_t::local : range_t::consist); + Train->occupied->OperatePantographValve(VehicleEnd::rear, operation_t::none, ismanual ? range_t::local : range_t::consist); } } } @@ -134,7 +134,7 @@ void TTrain::OnCommand_pantographraisefront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(VehicleEnd::front, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, + Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -163,7 +163,7 @@ void TTrain::OnCommand_pantographraiserear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(VehicleEnd::rear, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, + Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -182,7 +182,7 @@ void TTrain::OnCommand_pantographlowerfront(TTrain *Train, command_data const &C return; } // prevent operation without submodel outside of engine compartment - if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->mvOccupied->PantSwitchType == "impulse" ? "pantfrontoff_sw:" : "pantfront_sw:")) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->PantSwitchType == "impulse" ? "pantfrontoff_sw:" : "pantfront_sw:")) { return; } @@ -192,7 +192,7 @@ void TTrain::OnCommand_pantographlowerfront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(VehicleEnd::front, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, + Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -211,7 +211,7 @@ void TTrain::OnCommand_pantographlowerrear(TTrain *Train, command_data const &Co return; } - if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->mvOccupied->PantSwitchType == "impulse" ? "pantrearoff_sw:" : "pantrear_sw:")) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->PantSwitchType == "impulse" ? "pantrearoff_sw:" : "pantrear_sw:")) { return; } @@ -221,7 +221,7 @@ void TTrain::OnCommand_pantographlowerrear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->mvOccupied->OperatePantographValve(VehicleEnd::rear, Train->mvOccupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, + Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -254,15 +254,15 @@ void TTrain::OnCommand_pantographlowerall(TTrain *Train, command_data const &Com // two-state switch, only cares about press events if (Command.action == GLFW_PRESS) { - Train->mvPantographUnit->DropAllPantographs(false == Train->mvPantographUnit->PantAllDown); + Train->pantographUnit->DropAllPantographs(false == Train->pantographUnit->PantAllDown); // visual feedback - Train->ggPantAllDownButton.UpdateValue(Train->mvPantographUnit->PantAllDown ? 1.0 : 0.0, Train->dsbSwitch); + Train->ggPantAllDownButton.UpdateValue(Train->pantographUnit->PantAllDown ? 1.0 : 0.0, Train->dsbSwitch); } } else { // impulse switch - Train->mvControlled->DropAllPantographs(Command.action == GLFW_PRESS); + Train->controlled->DropAllPantographs(Command.action == GLFW_PRESS); // visual feedback Train->ggPantAllDownButton.UpdateValue(Command.action == GLFW_PRESS ? 1.0 : 0.0, Train->dsbSwitch); } @@ -315,7 +315,7 @@ void TTrain::OnCommand_pantographtoggleselected(TTrain *Train, command_data cons Train->change_pantograph_selection(-1); // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const state{Train->mvPantographUnit->PantsValve.is_enabled || Train->mvPantographUnit->PantsValve.is_active}; // fallback for impulse switches + auto const state{Train->pantographUnit->PantsValve.is_enabled || Train->pantographUnit->PantsValve.is_active}; // fallback for impulse switches if (state) { OnCommand_pantographlowerselected(Train, Command); @@ -333,13 +333,13 @@ void TTrain::OnCommand_pantographtoggleselected(TTrain *Train, command_data cons // two buttons setup if (Train->ggPantSelectedButton.type() != TGaugeType::toggle) { - Train->mvOccupied->OperatePantographsValve(operation_t::enable_off); + Train->occupied->OperatePantographsValve(operation_t::enable_off); // visual feedback Train->ggPantSelectedButton.UpdateValue(0.0, Train->dsbSwitch); } if (Train->ggPantSelectedDownButton.type() != TGaugeType::toggle) { - Train->mvOccupied->OperatePantographsValve(operation_t::disable_off); + Train->occupied->OperatePantographsValve(operation_t::disable_off); // visual feedback Train->ggPantSelectedDownButton.UpdateValue(0.0, Train->dsbSwitch); } @@ -350,7 +350,7 @@ void TTrain::OnCommand_pantographtoggleselected(TTrain *Train, command_data cons { // special case, just one impulse switch controlling both states // with neutral position mid-way - Train->mvOccupied->OperatePantographsValve(operation_t::none); + Train->occupied->OperatePantographsValve(operation_t::none); // visual feedback Train->ggPantSelectedButton.UpdateValue(0.5, Train->dsbSwitch); } @@ -369,7 +369,7 @@ void TTrain::OnCommand_pantographraiseselected(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { // raise selected - Train->mvOccupied->OperatePantographsValve(Train->ggPantSelectedButton.type() != TGaugeType::toggle ? operation_t::enable_on : operation_t::enable); + Train->occupied->OperatePantographsValve(Train->ggPantSelectedButton.type() != TGaugeType::toggle ? operation_t::enable_on : operation_t::enable); // visual feedback Train->ggPantSelectedButton.UpdateValue(1.0, Train->dsbSwitch); } @@ -391,7 +391,7 @@ void TTrain::OnCommand_pantographlowerselected(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { // lower selected - Train->mvOccupied->OperatePantographsValve(Train->ggPantSelectedDownButton.type() != TGaugeType::toggle ? operation_t::disable_on : operation_t::disable); + Train->occupied->OperatePantographsValve(Train->ggPantSelectedDownButton.type() != TGaugeType::toggle ? operation_t::disable_on : operation_t::disable); // visual feedback if (Train->m_controlmapper.contains("pantselectedoff_sw:")) { @@ -415,23 +415,23 @@ void TTrain::update_pantograph_valves() { using enum operation_t; - auto const &presets{mvOccupied->PantsPreset.first}; - auto const &selection{mvOccupied->PantsPreset.second[cab_to_end()]}; + auto const &presets{occupied->PantsPreset.first}; + auto const &selection{occupied->PantsPreset.second[cab_to_end()]}; auto const preset{presets[selection] - '0'}; auto const swapends{cab_to_end() != VehicleEnd::front}; // check desired states for both pantographs; value: whether the pantograph should be raised auto const frontstate{preset & (swapends ? 2 : 1)}; auto const rearstate{preset & (swapends ? 1 : 2)}; - mvOccupied->OperatePantographValve(VehicleEnd::front, frontstate ? enable : disable); - mvOccupied->OperatePantographValve(VehicleEnd::rear, rearstate ? enable : disable); + occupied->OperatePantographValve(VehicleEnd::front, frontstate ? enable : disable); + occupied->OperatePantographValve(VehicleEnd::rear, rearstate ? enable : disable); } void TTrain::change_pantograph_selection(int const Change) { - auto const &presets{mvOccupied->PantsPreset.first}; - auto &selection{mvOccupied->PantsPreset.second[cab_to_end()]}; + auto const &presets{occupied->PantsPreset.first}; + auto &selection{occupied->PantsPreset.second[cab_to_end()]}; auto const initialstate{selection}; selection = std::clamp(selection + Change, 0, std::max(static_cast(presets.size() - 1), 0)); @@ -500,8 +500,8 @@ void TTrain::OnCommand_pantographvalvesoff(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { // implement action - Train->mvOccupied->OperatePantographValve(VehicleEnd::front, operation_t::disable); - Train->mvOccupied->OperatePantographValve(VehicleEnd::rear, operation_t::disable); + Train->occupied->OperatePantographValve(VehicleEnd::front, operation_t::disable); + Train->occupied->OperatePantographValve(VehicleEnd::rear, operation_t::disable); // visual feedback if (hasSeparateSwitches) Train->ggPantValvesOff.UpdateValue(1.0, Train->dsbSwitch); @@ -525,7 +525,7 @@ void TTrain::OnCommand_pantographcompressorvalvetoggle(TTrain *Train, command_da if (Command.action == GLFW_PRESS) { // only react to press - if (Train->mvControlled->bPantKurek3 == false) + if (Train->controlled->bPantKurek3 == false) { // connect pantographs with primary tank OnCommand_pantographcompressorvalveenable(Train, Command); @@ -542,7 +542,7 @@ void TTrain::OnCommand_pantographcompressorvalveenable(TTrain *Train, command_da { - if (auto const valveispresent{Train->ggPantCompressorValve.SubModel != nullptr || (Train->mvOccupied == Train->mvPantographUnit && Train->iCabn == 0)}; false == valveispresent) + if (auto const valveispresent{Train->ggPantCompressorValve.SubModel != nullptr || (Train->occupied == Train->pantographUnit && Train->iCabn == 0)}; false == valveispresent) { // tylko w maszynowym, unless actual device is present return; @@ -552,7 +552,7 @@ void TTrain::OnCommand_pantographcompressorvalveenable(TTrain *Train, command_da { // only react to press // connect pantographs with primary tank - Train->mvControlled->bPantKurek3 = true; + Train->controlled->bPantKurek3 = true; // visual feedback: Train->ggPantCompressorValve.UpdateValue(0.0); } @@ -562,7 +562,7 @@ void TTrain::OnCommand_pantographcompressorvalvedisable(TTrain *Train, command_d { - if (auto const valveispresent{Train->ggPantCompressorValve.SubModel != nullptr || (Train->mvOccupied == Train->mvPantographUnit && Train->iCabn == 0)}; false == valveispresent) + if (auto const valveispresent{Train->ggPantCompressorValve.SubModel != nullptr || (Train->occupied == Train->pantographUnit && Train->iCabn == 0)}; false == valveispresent) { // tylko w maszynowym, unless actual device is present return; @@ -572,7 +572,7 @@ void TTrain::OnCommand_pantographcompressorvalvedisable(TTrain *Train, command_d { // only react to press // connect pantograps with pantograph compressor - Train->mvControlled->bPantKurek3 = false; + Train->controlled->bPantKurek3 = false; // visual feedback: Train->ggPantCompressorValve.UpdateValue(1.0); } @@ -582,7 +582,7 @@ void TTrain::OnCommand_pantographcompressoractivate(TTrain *Train, command_data { // tylko w maszynowym, unless actual device is present - if (auto const switchispresent{Train->m_controlmapper.contains("pantcompressor_sw:") || (Train->mvOccupied == Train->mvPantographUnit && Train->iCabn == 0)}; false == switchispresent) + if (auto const switchispresent{Train->m_controlmapper.contains("pantcompressor_sw:") || (Train->occupied == Train->pantographUnit && Train->iCabn == 0)}; false == switchispresent) { return; } @@ -590,10 +590,10 @@ void TTrain::OnCommand_pantographcompressoractivate(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // press or hold to activate - if (Train->mvPantographUnit->PantPress < 4.8 && true == Train->mvPantographUnit->Power24vIsAvailable) + if (Train->pantographUnit->PantPress < 4.8 && true == Train->pantographUnit->Power24vIsAvailable) { // needs live power source and low enough pressure to work - Train->mvPantographUnit->PantCompFlag = true; + Train->pantographUnit->PantCompFlag = true; } // visual feedback Train->ggPantCompressorButton.UpdateValue(1.0); @@ -601,7 +601,7 @@ void TTrain::OnCommand_pantographcompressoractivate(TTrain *Train, command_data else { // release to disable - Train->mvPantographUnit->PantCompFlag = false; + Train->pantographUnit->PantCompFlag = false; // visual feedback Train->ggPantCompressorButton.UpdateValue(0.0); } diff --git a/vehicle/cab/powercommands.cpp b/vehicle/cab/powercommands.cpp index d9f9576d1..dc4dc14ff 100644 --- a/vehicle/cab/powercommands.cpp +++ b/vehicle/cab/powercommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -131,7 +131,7 @@ void TTrain::OnCommand_linebreakeropen(TTrain *Train, command_data const &Comman { Train->ggMainButton.UpdateValue(0.0, Train->dsbSwitch); } - else if (Train->ggMainOnButton.SubModel != nullptr && false == Train->mvControlled->MainCircuitOpensWithStarterOnly()) + else if (Train->ggMainOnButton.SubModel != nullptr && false == Train->controlled->MainCircuitOpensWithStarterOnly()) { // NOTE: legacy behaviour, for vehicles equipped only with impulse close switch // it doesn't make any real sense to animate this one, but some people can't get over how there's no visual reaction to their keypress @@ -147,10 +147,10 @@ void TTrain::OnCommand_linebreakeropen(TTrain *Train, command_data const &Comman return; } // already in the desired state - if (true == Train->mvControlled->MainSwitch(false, Train->mvControlled->MainSwitchRange())) + if (true == Train->controlled->MainSwitch(false, Train->controlled->MainSwitchRange())) { Train->m_linebreakerstate = linebreaker::state::open; - if (Train->mvControlled->MainSwitchRange() != range_t::local) + if (Train->controlled->MainSwitchRange() != range_t::local) { // the engines of the vehicles in multiple stopped along: their two-state switches go off too, left on // they'd start them again after the delay @@ -232,10 +232,10 @@ void TTrain::OnCommand_linebreakerclose(TTrain *Train, command_data const &Comma // we don't need to start the diesel twice, but the other types (with impulse switch setup) still need to be launched // NOTE: this behaviour should depend on MainOnButton presence and type_delayed // TODO: change it when/if vehicle definition files get their proper switch types - if (Train->m_linebreakerstate == linebreaker::state::closing && Train->mvControlled->EngineType == TEngineType::ElectricSeriesMotor) + if (Train->m_linebreakerstate == linebreaker::state::closing && Train->controlled->EngineType == TEngineType::ElectricSeriesMotor) { // try to finalize state change of the line breaker, set the state based on the outcome - Train->m_linebreakerstate = Train->mvControlled->MainSwitch(true, Train->mvControlled->MainSwitchRange()) ? linebreaker::state::closed : linebreaker::state::open; + Train->m_linebreakerstate = Train->controlled->MainSwitch(true, Train->controlled->MainSwitchRange()) ? linebreaker::state::closed : linebreaker::state::open; } // on button release reset the closing timer Train->fMainRelayTimer = 0.0f; @@ -272,9 +272,9 @@ void release_remote_linebreaker(TTrain::remote_linebreaker &Controls, std::optio } // namespace -TMoverParameters *TTrain::remote_engine(std::size_t const Index) const +physics::Vehicle *TTrain::remote_engine(std::size_t const Index) const { - return engine_start::engine(*mvOccupied, *mvControlled, static_cast(Index) + 2); + return engine_start::engine(*occupied, *controlled, static_cast(Index) + 2); } void TTrain::OnCommand_linebreakertoggleremote(TTrain *Train, command_data const &Command) @@ -403,13 +403,13 @@ void TTrain::OnCommand_motorconnectorsopen(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { // button works while it's held down but we can ignore repeats - if (false == Train->mvControlled->StLinSwitchOff) + if (false == Train->controlled->StLinSwitchOff) { // open the connectors // visual feedback Train->ggStLinOffButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->StLinSwitchOff = true; + Train->controlled->StLinSwitchOff = true; Train->set_paired_open_motor_connectors_button(true); } else @@ -421,13 +421,13 @@ void TTrain::OnCommand_motorconnectorsopen(TTrain *Train, command_data const &Co else if (Command.action == GLFW_RELEASE) { // button released - if (Train->mvControlled->StLinSwitchType != "toggle") + if (Train->controlled->StLinSwitchType != "toggle") { // default button type (impulse) ceases its work on button release // visual feedback Train->ggStLinOffButton.UpdateValue(0.0, Train->dsbSwitch); - Train->mvControlled->StLinSwitchOff = false; + Train->controlled->StLinSwitchOff = false; Train->set_paired_open_motor_connectors_button(false); } } @@ -448,19 +448,19 @@ void TTrain::OnCommand_motorconnectorsclose(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { - if (Train->mvControlled->StLinSwitchType == "toggle") + if (Train->controlled->StLinSwitchType == "toggle") { // default type of button (impulse) has only one effect on press, but the toggle type can toggle the state // visual feedback Train->ggStLinOffButton.UpdateValue(0.0, Train->dsbSwitch); } - if (false == Train->mvControlled->StLinSwitchOff) + if (false == Train->controlled->StLinSwitchOff) { return; } // already closed - Train->mvControlled->StLinSwitchOff = false; + Train->controlled->StLinSwitchOff = false; Train->set_paired_open_motor_connectors_button(false); } } @@ -468,7 +468,7 @@ void TTrain::OnCommand_motorconnectorsclose(TTrain *Train, command_data const &C void TTrain::OnCommand_motordisconnect(TTrain *Train, command_data const &Command) { - if (Train->mvControlled->TrainType == train_type::emu ? Train->mvControlled != Train->mvOccupied : Train->iCabn != 0) + if (Train->controlled->TrainType == train_type::emu ? Train->controlled != Train->occupied : Train->iCabn != 0) { // tylko w maszynowym return; @@ -476,7 +476,7 @@ void TTrain::OnCommand_motordisconnect(TTrain *Train, command_data const &Comman if (Command.action == GLFW_PRESS) { - Train->mvControlled->CutOffEngine(); + Train->controlled->CutOffEngine(); } } @@ -485,7 +485,7 @@ void TTrain::OnCommand_motoroverloadrelaythresholdtoggle(TTrain *Train, command_ if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (true == Train->mvControlled->ShuntModeAllow ? false == Train->mvControlled->ShuntMode : false == Train->mvControlled->MotorOverloadRelayHighThreshold) + if (true == Train->controlled->ShuntModeAllow ? false == Train->controlled->ShuntMode : false == Train->controlled->MotorOverloadRelayHighThreshold) { // turn on OnCommand_motoroverloadrelaythresholdsethigh(Train, Command); @@ -504,9 +504,9 @@ void TTrain::OnCommand_motoroverloadrelaythresholdsetlow(TTrain *Train, command_ if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvControlled->CurrentSwitch(false); + Train->controlled->CurrentSwitch(false); // visual feedback - Train->ggMaxCurrentCtrl.UpdateValue(Train->mvControlled->MotorOverloadRelayHighThreshold ? 1 : 0, Train->dsbSwitch); + Train->ggMaxCurrentCtrl.UpdateValue(Train->controlled->MotorOverloadRelayHighThreshold ? 1 : 0, Train->dsbSwitch); } } @@ -516,9 +516,9 @@ void TTrain::OnCommand_motoroverloadrelaythresholdsethigh(TTrain *Train, command if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - Train->mvControlled->CurrentSwitch(true); + Train->controlled->CurrentSwitch(true); // visual feedback - Train->ggMaxCurrentCtrl.UpdateValue(Train->mvControlled->MotorOverloadRelayHighThreshold ? 1 : 0, Train->dsbSwitch); + Train->ggMaxCurrentCtrl.UpdateValue(Train->controlled->MotorOverloadRelayHighThreshold ? 1 : 0, Train->dsbSwitch); } } @@ -539,7 +539,7 @@ void TTrain::OnCommand_motoroverloadrelayreset(TTrain *Train, command_data const // visual feedback Train->ggFuseButton.UpdateValue(1.0, Train->dsbSwitch); - Train->mvControlled->FuseOn(); + Train->controlled->FuseOn(); } else if (Command.action == GLFW_RELEASE) { @@ -557,7 +557,7 @@ void TTrain::OnCommand_universalrelayreset(TTrain *Train, command_data const &Co // NOTE: relay reset switches are impulse-only if (Command.action == GLFW_PRESS) { - Train->mvOccupied->UniversalResetButton(itemindex); + Train->occupied->UniversalResetButton(itemindex); // visual feedback item.UpdateValue(1.0); } diff --git a/vehicle/cab/screens.cpp b/vehicle/cab/screens.cpp index c30b1b283..e5b2a37f3 100644 --- a/vehicle/cab/screens.cpp +++ b/vehicle/cab/screens.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index d1bac2763..699222956 100644 --- a/vehicle/cab/setup.cpp +++ b/vehicle/cab/setup.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -75,10 +75,10 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) {"localbrakesound2:", {rsSBHissU, internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, single, sound_parameters::amplitude, 100.0}}, {"brakesound:", {rsBrake, internal, -1, single, sound_parameters::amplitude | sound_parameters::frequency, 100.0}}, {"fadesound:", {rsFadeSound, internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, single, 0, 100.0}}, - {"runningnoise:", {rsRunningNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}}, - {"resonancenoise:", {rsResonanceNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}}, - {"windsound:", {rsWindSound, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}}, - {"huntingnoise:", {rsHuntingNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax}}, + {"runningnoise:", {rsRunningNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax}}, + {"resonancenoise:", {rsResonanceNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax}}, + {"windsound:", {rsWindSound, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax}}, + {"huntingnoise:", {rsHuntingNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax}}, {"rainsound:", {m_rainsound, internal, -1, single, 0, 100.0}}, }; for (auto &[soundname, soundsource] : internalsounds) @@ -143,23 +143,23 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) } if (rsBrake) { - rsBrake->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); + rsBrake->m_frequencyfactor /= static_cast(1 + occupied->Vmax); } if (rsResonanceNoise) { - rsResonanceNoise->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); + rsResonanceNoise->m_frequencyfactor /= static_cast(1 + occupied->Vmax); } if (rsWindSound) { - rsWindSound->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); + rsWindSound->m_frequencyfactor /= static_cast(1 + occupied->Vmax); } if (rsRunningNoise) { - rsRunningNoise->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); + rsRunningNoise->m_frequencyfactor /= static_cast(1 + occupied->Vmax); } if (rsHuntingNoise) { - rsHuntingNoise->m_frequencyfactor /= static_cast(1 + mvOccupied->Vmax); + rsHuntingNoise->m_frequencyfactor /= static_cast(1 + occupied->Vmax); } } std::vector>> sounds = { @@ -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->MoverParameters->Odometer.shown = true; + DynamicObject->physics->Odometer.shown = true; } set_cab_controls(NewCabNo < 0 ? 2 : NewCabNo); @@ -573,7 +573,7 @@ glm::dvec3 TTrain::MirrorPosition(bool lewe) auto const shiftdirection{(lewe ? -1 : 1) * (iCabn == 2 ? 1 : -1)}; return DynamicObject->mMatrix * - glm::dvec4(mvOccupied->Dim.W * (0.5 * shiftdirection) + 0.2 * shiftdirection, 1.5 + Cabine[iCabn].CabPos1.y, std::lerp(Cabine[iCabn].CabPos1.z, Cabine[iCabn].CabPos2.z, 0.5), 1.0); + glm::dvec4(occupied->Dim.W * (0.5 * shiftdirection) + 0.2 * shiftdirection, 1.5 + Cabine[iCabn].CabPos1.y, std::lerp(Cabine[iCabn].CabPos1.z, Cabine[iCabn].CabPos2.z, 0.5), 1.0); }; // clears state of all cabin controls @@ -587,11 +587,11 @@ void TTrain::clear_cab_controls() btLampkaNadmSil.Clear(4); btLampkaStyczn.Clear(5); btLampkaPoslizg.Clear(6); - btLampkaNadmPrzetw.Clear(mvControlled->TrainType == train_type::emu ? -1 : 7); // EN57 nie ma tej lampki - btLampkaPrzetwOff.Clear(mvControlled->TrainType == train_type::emu ? 7 : -1); // za to ma tę + btLampkaNadmPrzetw.Clear(controlled->TrainType == train_type::emu ? -1 : 7); // EN57 nie ma tej lampki + btLampkaPrzetwOff.Clear(controlled->TrainType == train_type::emu ? 7 : -1); // za to ma tę btLampkaNadmSpr.Clear(8); btLampkaNadmWent.Clear(9); - btLampkaWysRozr.Clear(mvControlled->TrainType == train_type::et22 ? -1 : 10); // ET22 nie ma tej lampki + btLampkaWysRozr.Clear(controlled->TrainType == train_type::et22 ? -1 : 10); // ET22 nie ma tej lampki btLampkaOgrzewanieSkladu.Clear(11); // overheat indicator lamps btLampkaOilOverheat.Clear(-1); @@ -888,9 +888,9 @@ void TTrain::set_cab_controls(int const Cab) { // switches // battery - ggBatteryButton.PutValue(ggBatteryButton.type() == TGaugeType::push ? 0.5f : mvOccupied->Power24vIsAvailable ? 1.f : 0.f); + ggBatteryButton.PutValue(ggBatteryButton.type() == TGaugeType::push ? 0.5f : occupied->Power24vIsAvailable ? 1.f : 0.f); // activation - ggCabActivationButton.PutValue(ggCabActivationButton.type() == TGaugeType::push ? 0.5f : mvOccupied->IsCabMaster() ? 1.f : 0.f); + ggCabActivationButton.PutValue(ggCabActivationButton.type() == TGaugeType::push ? 0.5f : occupied->IsCabMaster() ? 1.f : 0.f); // line breaker if (ggMainButton.SubModel != nullptr) { // instead of single main button there can be on/off pair @@ -915,8 +915,8 @@ void TTrain::set_cab_controls(int const Cab) if (ggModernLightDimSw.SubModel != nullptr) { - mvOccupied->modernDimmerPosition = mvOccupied->modernDimmerDefaultPosition; - ggModernLightDimSw.PutValue(static_cast(mvOccupied->modernDimmerDefaultPosition)); + occupied->modernDimmerPosition = occupied->modernDimmerDefaultPosition; + ggModernLightDimSw.PutValue(static_cast(occupied->modernDimmerDefaultPosition)); } // Init separate buttons @@ -930,35 +930,35 @@ void TTrain::set_cab_controls(int const Cab) } // motor connectors - ggStLinOffButton.PutValue(mvControlled->StLinSwitchOff ? 1.f : 0.f); + ggStLinOffButton.PutValue(controlled->StLinSwitchOff ? 1.f : 0.f); // radio ggRadioChannelSelector.PutValue(static_cast((Dynamic()->Mechanik ? Dynamic()->Mechanik->iRadioChannel : 1) - 1)); // pantographs /* - if( mvOccupied->PantSwitchType != "impulse" ) { + if( occupied->PantSwitchType != "impulse" ) { if( ggPantFrontButton.SubModel ) { ggPantFrontButton.PutValue( - ( mvControlled->Pantographs[VehicleEnd::front].valve.is_enabled ? + ( controlled->Pantographs[VehicleEnd::front].valve.is_enabled ? 1.f : 0.f ) ); } if( ggPantFrontButtonOff.SubModel ) { ggPantFrontButtonOff.PutValue( - ( mvControlled->Pantographs[VehicleEnd::front].valve.is_disabled ? + ( controlled->Pantographs[VehicleEnd::front].valve.is_disabled ? 1.f : 0.f ) ); } } - if( mvOccupied->PantSwitchType != "impulse" ) { + if( occupied->PantSwitchType != "impulse" ) { if( ggPantRearButton.SubModel ) { ggPantRearButton.PutValue( - ( mvControlled->Pantographs[VehicleEnd::rear].valve.is_enabled ? + ( controlled->Pantographs[VehicleEnd::rear].valve.is_enabled ? 1.f : 0.f ) ); } if( ggPantRearButtonOff.SubModel ) { ggPantRearButtonOff.PutValue( - ( mvControlled->Pantographs[VehicleEnd::rear].valve.is_disabled ? + ( controlled->Pantographs[VehicleEnd::rear].valve.is_disabled ? 1.f : 0.f ) ); } @@ -967,7 +967,7 @@ void TTrain::set_cab_controls(int const Cab) // front/end pantograph selection is relative to occupied cab if (ggPantSelectedButton.type() == TGaugeType::toggle) { - ggPantSelectedButton.PutValue(mvPantographUnit->PantsValve.is_enabled ? 1.f : 0.f); + ggPantSelectedButton.PutValue(pantographUnit->PantsValve.is_enabled ? 1.f : 0.f); } else { @@ -979,47 +979,47 @@ void TTrain::set_cab_controls(int const Cab) } if (ggPantSelectedDownButton.type() == TGaugeType::toggle) { - ggPantSelectedDownButton.PutValue(mvPantographUnit->PantsValve.is_disabled ? 1.f : 0.f); + ggPantSelectedDownButton.PutValue(pantographUnit->PantsValve.is_disabled ? 1.f : 0.f); } ggPantValvesButton.PutValue(0.5f); // auxiliary compressor - ggPantCompressorValve.PutValue(mvControlled->bPantKurek3 ? 0.f : // default setting is pantographs connected with primary tank + ggPantCompressorValve.PutValue(controlled->bPantKurek3 ? 0.f : // default setting is pantographs connected with primary tank 1.f); - ggPantCompressorButton.PutValue(mvPantographUnit->PantCompFlag ? 1.f : 0.f); + ggPantCompressorButton.PutValue(pantographUnit->PantCompFlag ? 1.f : 0.f); // converter - if (mvOccupied->ConvSwitchType != "impulse") + if (occupied->ConvSwitchType != "impulse") { - ggConverterButton.PutValue(mvOccupied->ConverterAllow ? 1.f : 0.f); + ggConverterButton.PutValue(occupied->ConverterAllow ? 1.f : 0.f); } - ggConverterLocalButton.PutValue(mvOccupied->ConverterAllowLocal ? 1.f : 0.f); + ggConverterLocalButton.PutValue(occupied->ConverterAllowLocal ? 1.f : 0.f); // compressor - ggCompressorButton.PutValue(mvControlled->CompressorAllow ? 1.f : 0.f); - ggCompressorLocalButton.PutValue(mvControlled->CompressorAllowLocal ? 1.f : 0.f); - ggCompressorListButton.PutValue(static_cast(mvOccupied->CompressorListPos - 1)); + ggCompressorButton.PutValue(controlled->CompressorAllow ? 1.f : 0.f); + ggCompressorLocalButton.PutValue(controlled->CompressorAllowLocal ? 1.f : 0.f); + ggCompressorListButton.PutValue(static_cast(occupied->CompressorListPos - 1)); // motor overload relay threshold / shunt mode - ggMaxCurrentCtrl.PutValue(true == mvControlled->ShuntModeAllow ? (true == mvControlled->ShuntMode ? 1.f : 0.f) : mvControlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f); + ggMaxCurrentCtrl.PutValue(true == controlled->ShuntModeAllow ? (true == controlled->ShuntMode ? 1.f : 0.f) : controlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f); // automatic relays (AutoRelay) - ggAutoRelayButton.PutValue(mvOccupied->AutoRelayFlag ? 1.f : 0.f); + ggAutoRelayButton.PutValue(occupied->AutoRelayFlag ? 1.f : 0.f); // lights - ggLightsButton.PutValue(static_cast(mvOccupied->LightsPos - 1)); + ggLightsButton.PutValue(static_cast(occupied->LightsPos - 1)); auto const vehicleend{cab_to_end(Cab)}; - if ((mvOccupied->iLights[vehicleend] & light::headlight_left) != 0) + if ((occupied->iLights[vehicleend] & light::headlight_left) != 0) { ggLeftLightButton.PutValue(1.f); } - if ((mvOccupied->iLights[vehicleend] & light::headlight_right) != 0) + if ((occupied->iLights[vehicleend] & light::headlight_right) != 0) { ggRightLightButton.PutValue(1.f); } - if ((mvOccupied->iLights[vehicleend] & light::headlight_upper) != 0) + if ((occupied->iLights[vehicleend] & light::headlight_upper) != 0) { ggUpperLightButton.PutValue(1.f); } - if ((mvOccupied->iLights[vehicleend] & light::redmarker_left) != 0) + if ((occupied->iLights[vehicleend] & light::redmarker_left) != 0) { if (ggLeftEndLightButton.SubModel != nullptr) { @@ -1030,7 +1030,7 @@ void TTrain::set_cab_controls(int const Cab) ggLeftLightButton.PutValue(-1.f); } } - if ((mvOccupied->iLights[vehicleend] & light::redmarker_right) != 0) + if ((occupied->iLights[vehicleend] & light::redmarker_right) != 0) { if (ggRightEndLightButton.SubModel != nullptr) { @@ -1041,9 +1041,9 @@ void TTrain::set_cab_controls(int const Cab) ggRightLightButton.PutValue(-1.f); } } - if (1 == DynamicObject->MoverParameters->modernDimmerPosition) + if (1 == DynamicObject->physics->modernDimmerPosition) { - ggDimHeadlightsButton.PutValue(static_cast(DynamicObject->MoverParameters->modernDimmerPosition)); + ggDimHeadlightsButton.PutValue(static_cast(DynamicObject->physics->modernDimmerPosition)); } // cab lights if (true == Cabine[Cab].bLightDim) @@ -1051,7 +1051,7 @@ void TTrain::set_cab_controls(int const Cab) ggCabLightDimButton.PutValue(1.f); } // compartment lights - ggCompartmentLightsButton.PutValue(ggCompartmentLightsButton.type() == TGaugeType::push ? 0.5f : mvOccupied->CompartmentLights.is_enabled ? 1.f : 0.f); + ggCompartmentLightsButton.PutValue(ggCompartmentLightsButton.type() == TGaugeType::push ? 0.5f : occupied->CompartmentLights.is_enabled ? 1.f : 0.f); // instrument lights ggInstrumentLightButton.PutValue(InstrumentLightActive ? 1.f : 0.f); ggDashboardLightButton.PutValue(DashboardLightActive ? 1.f : 0.f); @@ -1059,100 +1059,100 @@ void TTrain::set_cab_controls(int const Cab) // doors permits if (false == ggDoorLeftPermitButton.is_push()) { - ggDoorLeftPermitButton.PutValue(mvOccupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right].open_permit ? 1.f : 0.f); + ggDoorLeftPermitButton.PutValue(occupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right].open_permit ? 1.f : 0.f); } if (false == ggDoorRightPermitButton.is_push()) { - ggDoorRightPermitButton.PutValue(mvOccupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left].open_permit ? 1.f : 0.f); + ggDoorRightPermitButton.PutValue(occupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left].open_permit ? 1.f : 0.f); } - ggDoorPermitPresetButton.PutValue(static_cast(mvOccupied->Doors.permit_preset)); + ggDoorPermitPresetButton.PutValue(static_cast(occupied->Doors.permit_preset)); // door controls - ggDoorLeftButton.PutValue(mvOccupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right].is_closed ? 0.f : 1.f); - ggDoorRightButton.PutValue(mvOccupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left].is_closed ? 0.f : 1.f); + ggDoorLeftButton.PutValue(occupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right].is_closed ? 0.f : 1.f); + ggDoorRightButton.PutValue(occupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left].is_closed ? 0.f : 1.f); // door lock - ggDoorSignallingButton.PutValue(mvOccupied->Doors.lock_enabled ? 1.f : 0.f); + ggDoorSignallingButton.PutValue(occupied->Doors.lock_enabled ? 1.f : 0.f); // door step if (false == ggDoorStepButton.is_push()) { - ggDoorStepButton.PutValue(mvOccupied->Doors.step_enabled ? 1.f : 0.f); + ggDoorStepButton.PutValue(occupied->Doors.step_enabled ? 1.f : 0.f); } // heating - if (false == ggTrainHeatingButton.is_push() && false == mvOccupied->HeatingSwitchImpulse) + if (false == ggTrainHeatingButton.is_push() && false == occupied->HeatingSwitchImpulse) { - ggTrainHeatingButton.PutValue(mvControlled->Heating ? 1.f : 0.f); + ggTrainHeatingButton.PutValue(controlled->Heating ? 1.f : 0.f); } // brake acting time if (ggBrakeProfileCtrl.SubModel != nullptr) { - ggBrakeProfileCtrl.PutValue((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 2.f : static_cast(mvOccupied->BrakeDelayFlag - 1)); + ggBrakeProfileCtrl.PutValue((occupied->BrakeDelayFlag & bdelay_R) != 0 ? 2.f : static_cast(occupied->BrakeDelayFlag - 1)); } if (ggBrakeProfileG.SubModel != nullptr) { - ggBrakeProfileG.PutValue(mvOccupied->BrakeDelayFlag == bdelay_G ? 1.f : 0.f); + ggBrakeProfileG.PutValue(occupied->BrakeDelayFlag == bdelay_G ? 1.f : 0.f); } if (ggBrakeProfileR.SubModel != nullptr) { - ggBrakeProfileR.PutValue((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 1.f : 0.f); + ggBrakeProfileR.PutValue((occupied->BrakeDelayFlag & bdelay_R) != 0 ? 1.f : 0.f); } if (ggWiperSw.SubModel != nullptr) { - ggWiperSw.PutValue(static_cast(mvOccupied->wiperSwitchPos)); + ggWiperSw.PutValue(static_cast(occupied->wiperSwitchPos)); } if (ggBrakeOperationModeCtrl.SubModel != nullptr) { - ggBrakeOperationModeCtrl.PutValue(mvOccupied->BrakeOpModeFlag > 0 ? static_cast(std::log2(mvOccupied->BrakeOpModeFlag)) : 0); + ggBrakeOperationModeCtrl.PutValue(occupied->BrakeOpModeFlag > 0 ? static_cast(std::log2(occupied->BrakeOpModeFlag)) : 0); } // alarm chain - ggAlarmChain.PutValue(mvControlled->AlarmChainFlag ? 1.f : 0.f); + ggAlarmChain.PutValue(controlled->AlarmChainFlag ? 1.f : 0.f); // brake signalling - ggSignallingButton.PutValue(mvControlled->Signalling ? 1.f : 0.f); + ggSignallingButton.PutValue(controlled->Signalling ? 1.f : 0.f); // multiple-unit current indicator source ggNextCurrentButton.PutValue(ShowNextCurrent ? 1.f : 0.f); // water pump - ggWaterPumpBreakerButton.PutValue(mvControlled->WaterPump.breaker ? 1.f : 0.f); + ggWaterPumpBreakerButton.PutValue(controlled->WaterPump.breaker ? 1.f : 0.f); if (ggWaterPumpButton.type() != TGaugeType::push) { - ggWaterPumpButton.PutValue(mvControlled->WaterPump.is_enabled ? 1.f : 0.f); + ggWaterPumpButton.PutValue(controlled->WaterPump.is_enabled ? 1.f : 0.f); } // water heater - ggWaterHeaterBreakerButton.PutValue(mvControlled->WaterHeater.breaker ? 1.f : 0.f); - ggWaterHeaterButton.PutValue(mvControlled->WaterHeater.is_enabled ? 1.f : 0.f); - ggWaterCircuitsLinkButton.PutValue(mvControlled->WaterCircuitsLink ? 1.f : 0.f); + ggWaterHeaterBreakerButton.PutValue(controlled->WaterHeater.breaker ? 1.f : 0.f); + ggWaterHeaterButton.PutValue(controlled->WaterHeater.is_enabled ? 1.f : 0.f); + ggWaterCircuitsLinkButton.PutValue(controlled->WaterCircuitsLink ? 1.f : 0.f); // fuel pump if (ggFuelPumpButton.type() != TGaugeType::push) { - ggFuelPumpButton.PutValue(mvControlled->FuelPump.is_enabled ? 1.f : 0.f); + ggFuelPumpButton.PutValue(controlled->FuelPump.is_enabled ? 1.f : 0.f); } // oil pump if (ggOilPumpButton.type() != TGaugeType::push) { - ggOilPumpButton.PutValue(mvControlled->OilPump.is_enabled ? 1.f : 0.f); + ggOilPumpButton.PutValue(controlled->OilPump.is_enabled ? 1.f : 0.f); } // joint oil and fuel pump if (ggOilFuelPumpButton.type() != TGaugeType::push) { - ggOilFuelPumpButton.PutValue(mvControlled->OilFuelPumpsEnabled() ? 1.f : 0.f); + ggOilFuelPumpButton.PutValue(controlled->OilFuelPumpsEnabled() ? 1.f : 0.f); } // traction selector and genset of a dual-mode vehicle - ggTractionModeSwitch.PutValue(mvControlled->GensetSelected() ? 1.f : 0.f); + ggTractionModeSwitch.PutValue(controlled->GensetSelected() ? 1.f : 0.f); if (ggGensetButton.type() != TGaugeType::push) { - ggGensetButton.PutValue(mvControlled->Genset.is_enabled ? 1.f : 0.f); + ggGensetButton.PutValue(controlled->Genset.is_enabled ? 1.f : 0.f); } // traction motor fans if (ggMotorBlowersFrontButton.type() != TGaugeType::push) { - ggMotorBlowersFrontButton.PutValue(mvControlled->MotorBlowers[VehicleEnd::front].is_enabled ? 1.f : 0.f); + ggMotorBlowersFrontButton.PutValue(controlled->MotorBlowers[VehicleEnd::front].is_enabled ? 1.f : 0.f); } if (ggMotorBlowersRearButton.type() != TGaugeType::push) { - ggMotorBlowersRearButton.PutValue(mvControlled->MotorBlowers[VehicleEnd::rear].is_enabled ? 1.f : 0.f); + ggMotorBlowersRearButton.PutValue(controlled->MotorBlowers[VehicleEnd::rear].is_enabled ? 1.f : 0.f); } if (ggMotorBlowersAllOffButton.type() != TGaugeType::push) { - ggMotorBlowersAllOffButton.PutValue(mvControlled->MotorBlowers[VehicleEnd::front].is_disabled || mvControlled->MotorBlowers[VehicleEnd::rear].is_disabled ? 1.f : 0.f); + ggMotorBlowersAllOffButton.PutValue(controlled->MotorBlowers[VehicleEnd::front].is_disabled || controlled->MotorBlowers[VehicleEnd::rear].is_disabled ? 1.f : 0.f); } // second controller if (ggScndCtrl.is_push()) @@ -1163,38 +1163,38 @@ void TTrain::set_cab_controls(int const Cab) // tempomat if (false == ggScndCtrlButton.is_push()) { - ggScndCtrlButton.PutValue(mvControlled->IsSpeedCtrlEngaged() ? 1.f : 0.f); + ggScndCtrlButton.PutValue(controlled->IsSpeedCtrlEngaged() ? 1.f : 0.f); } // sandbox if (ggAutoSandButton.type() != TGaugeType::push) { - ggAutoSandButton.PutValue(mvControlled->SandDoseAutoAllow ? 1.f : 0.f); + ggAutoSandButton.PutValue(controlled->SandDoseAutoAllow ? 1.f : 0.f); } // radio ggRadioVolumeSelector.PutValue(m_radiovolume); // finding each inverter - not so optimal, but action ins performed only during changing cabin - bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; - auto const flag{CouplingSet::FromBits(DynamicObject->MoverParameters->inductionMotor.inverterControlCouplings)}; + bool kier = DynamicObject->DirectionGet() * occupied->CabOccupied > 0; + auto const flag{CouplingSet::FromBits(DynamicObject->physics->inductionMotor.inverterControlCouplings)}; int itemstart = 0; for ([[maybe_unused]] auto const &item : ggInverterToggleButtons) // for each button { int itemindex = itemstart; itemstart++; - TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, flag); + TDynamicObject *p = DynamicObject->GetFirstDynamic(occupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, flag); while (p) { - if (p->MoverParameters->inductionMotor.traction.maxPower > 1) + if (p->physics->inductionMotor.traction.maxPower > 1) { - if (itemindex < p->MoverParameters->inductionMotor.inverterCount) + if (itemindex < p->physics->inductionMotor.inverterCount) { // visual feedback - ggInverterToggleButtons[itemstart - 1].PutValue(p->MoverParameters->inductionMotor.inverters[itemindex].Activate ? 1.0 : 0.0); + ggInverterToggleButtons[itemstart - 1].PutValue(p->physics->inductionMotor.inverters[itemindex].Activate ? 1.0 : 0.0); break; } else { - itemindex -= p->MoverParameters->inductionMotor.inverterCount; + itemindex -= p->physics->inductionMotor.inverterCount; } } p = kier ? p->Next(flag) : p->Prev(flag); @@ -1338,11 +1338,11 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co {"i-doorpermit_left:", &m_doorspermitleft}, {"i-doorpermit_right:", &m_doorspermitright}, {"i-doorpermit_any:", &m_doorpermits}, - {"i-doorstep:", &mvOccupied->Doors.step_enabled}, - {"i-mainpipelock:", &mvOccupied->LockPipe}, - {"i-battery:", &mvOccupied->Power24vIsAvailable}, + {"i-doorstep:", &occupied->Doors.step_enabled}, + {"i-mainpipelock:", &occupied->LockPipe}, + {"i-battery:", &occupied->Power24vIsAvailable}, {"i-cablight:", &Cabine[iCabn].bLight}, - {"i-compartmentlights:", &mvOccupied->CompartmentLights.is_active}, + {"i-compartmentlights:", &occupied->CompartmentLights.is_active}, }; { auto lookup = autolights.find(Label); @@ -1613,26 +1613,26 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // TODO: move viable gauges here // TODO: convert dedicated gauges to auto-allocated ones, replace dedicated references in command handlers to mapper lookups std::unordered_map> const stategauges = { - {"tempomat_sw:", {ggScndCtrlButton, &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"tempomatoff_sw:", {ggScndCtrlOffButton, &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedinc_bt:", {ggSpeedControlIncreaseButton, &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speeddec_bt:", {ggSpeedControlDecreaseButton, &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedctrlpowerinc_bt:", {ggSpeedControlPowerIncreaseButton, &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedctrlpowerdec_bt:", {ggSpeedControlPowerDecreaseButton, &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton0:", {ggSpeedCtrlButtons[0], &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton1:", {ggSpeedCtrlButtons[1], &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton2:", {ggSpeedCtrlButtons[2], &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton3:", {ggSpeedCtrlButtons[3], &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton4:", {ggSpeedCtrlButtons[4], &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton5:", {ggSpeedCtrlButtons[5], &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton6:", {ggSpeedCtrlButtons[6], &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton7:", {ggSpeedCtrlButtons[7], &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton8:", {ggSpeedCtrlButtons[8], &mvOccupied->SpeedCtrlUnit.IsActive}}, - {"speedbutton9:", {ggSpeedCtrlButtons[9], &mvOccupied->SpeedCtrlUnit.IsActive}}, + {"tempomat_sw:", {ggScndCtrlButton, &occupied->SpeedCtrlUnit.IsActive}}, + {"tempomatoff_sw:", {ggScndCtrlOffButton, &occupied->SpeedCtrlUnit.IsActive}}, + {"speedinc_bt:", {ggSpeedControlIncreaseButton, &occupied->SpeedCtrlUnit.IsActive}}, + {"speeddec_bt:", {ggSpeedControlDecreaseButton, &occupied->SpeedCtrlUnit.IsActive}}, + {"speedctrlpowerinc_bt:", {ggSpeedControlPowerIncreaseButton, &occupied->SpeedCtrlUnit.IsActive}}, + {"speedctrlpowerdec_bt:", {ggSpeedControlPowerDecreaseButton, &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton0:", {ggSpeedCtrlButtons[0], &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton1:", {ggSpeedCtrlButtons[1], &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton2:", {ggSpeedCtrlButtons[2], &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton3:", {ggSpeedCtrlButtons[3], &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton4:", {ggSpeedCtrlButtons[4], &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton5:", {ggSpeedCtrlButtons[5], &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton6:", {ggSpeedCtrlButtons[6], &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton7:", {ggSpeedCtrlButtons[7], &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton8:", {ggSpeedCtrlButtons[8], &occupied->SpeedCtrlUnit.IsActive}}, + {"speedbutton9:", {ggSpeedCtrlButtons[9], &occupied->SpeedCtrlUnit.IsActive}}, {"doorleftpermit_sw:", {ggDoorLeftPermitButton, &m_doorspermitleft}}, {"doorrightpermit_sw:", {ggDoorRightPermitButton, &m_doorspermitright}}, {"dooralloff_sw:", {ggDoorAllOffButton, &m_doors}}, - {"doorstep_sw:", {ggDoorStepButton, &mvOccupied->Doors.step_enabled}}, + {"doorstep_sw:", {ggDoorStepButton, &occupied->Doors.step_enabled}}, {"dirforward_bt:", {ggDirForwardButton, &m_dirforward}}, {"dirneutral_bt:", {ggDirNeutralButton, &m_dirneutral}}, {"dirbackward_bt:", {ggDirBackwardButton, &m_dirbackward}}, @@ -1650,19 +1650,19 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con } // TODO: move viable dedicated gauges to the automatic array std::unordered_map const autoboolgauges = { - {"doormode_sw:", &mvOccupied->Doors.remote_only}, - {"coolingfans_sw:", &mvControlled->RVentForceOn}, - {"pantfront_sw:", &mvPantographUnit->Pantographs[VehicleEnd::front].valve.is_enabled}, - {"pantrear_sw:", &mvPantographUnit->Pantographs[VehicleEnd::rear].valve.is_enabled}, - {"pantfrontoff_sw:", &mvPantographUnit->Pantographs[VehicleEnd::front].valve.is_disabled}, - {"pantrearoff_sw:", &mvPantographUnit->Pantographs[VehicleEnd::rear].valve.is_disabled}, - {"radio_sw:", &mvOccupied->Radio}, - {"radiofuse_sw:", &mvOccupied->RadioFuse}, + {"doormode_sw:", &occupied->Doors.remote_only}, + {"coolingfans_sw:", &controlled->RVentForceOn}, + {"pantfront_sw:", &pantographUnit->Pantographs[VehicleEnd::front].valve.is_enabled}, + {"pantrear_sw:", &pantographUnit->Pantographs[VehicleEnd::rear].valve.is_enabled}, + {"pantfrontoff_sw:", &pantographUnit->Pantographs[VehicleEnd::front].valve.is_disabled}, + {"pantrearoff_sw:", &pantographUnit->Pantographs[VehicleEnd::rear].valve.is_disabled}, + {"radio_sw:", &occupied->Radio}, + {"radiofuse_sw:", &occupied->RadioFuse}, {"cablight_sw:", &Cabine[iCabn].bLight}, - {"springbraketoggle_bt:", &mvOccupied->SpringBrake.Activate}, + {"springbraketoggle_bt:", &occupied->SpringBrake.Activate}, {"couplingdisconnect_sw:", &m_couplingdisconnect}, {"couplingdisconnectback_sw:", &m_couplingdisconnectback}, - {"mirrors_sw:", &mvOccupied->MirrorForbidden}, + {"mirrors_sw:", &occupied->MirrorForbidden}, }; { auto lookup = autoboolgauges.find(Label); @@ -1677,8 +1677,8 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con } // TODO: move viable dedicated gauges to the automatic array std::unordered_map const autointgauges = { - {"manualbrake:", &mvOccupied->ManualBrakePos}, - {"pantselect_sw:", &mvOccupied->PantsPreset.second[cab_to_end()]}, + {"manualbrake:", &occupied->ManualBrakePos}, + {"pantselect_sw:", &occupied->PantsPreset.second[cab_to_end()]}, }; { auto lookup = autointgauges.find(Label); @@ -1817,21 +1817,21 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // Ra 2014-08: przeniesione do TCab auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&mvOccupied->BrakePress); + gauge.AssignDouble(&occupied->BrakePress); } else if (Label == "pipepress:" || Label == "pipepressb:") { // manometr przewodu hamulcowego auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&mvOccupied->PipePress); + gauge.AssignDouble(&occupied->PipePress); } else if (Label == "scndpress:") { // manometr przewodu hamulcowego auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&mvOccupied->ScndPipePress); + gauge.AssignDouble(&occupied->ScndPipePress); } else if (Label == "limpipepress:") { @@ -1845,63 +1845,63 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // manometr zbiornika kontrolnego/rorzďż˝du auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&mvPantographUnit->PantPress); + gauge.AssignDouble(&pantographUnit->PantPress); } else if (Label == "springbrakepress:") { // manometr cylindra hamulca sprężynowego auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&mvOccupied->SpringBrake.SBP); + gauge.AssignDouble(&occupied->SpringBrake.SBP); } else if (Label == "epctrlvalue:") { // wskazowka sterowania sila hamulca ep auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&mvOccupied->EpForce); + gauge.AssignDouble(&occupied->EpForce); } else if (Label == "compressor:" || Label == "compressorb:") { // manometr sprezarki/zbiornika glownego auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&mvOccupied->Compressor); + gauge.AssignDouble(&occupied->Compressor); } else if (Label == "oilpress:") { // oil pressure auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignFloat(&mvControlled->OilPump.pressure); + gauge.AssignFloat(&controlled->OilPump.pressure); } else if (Label == "oiltemp:") { // oil temperature auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignFloat(&mvControlled->diesel.heat.To); + gauge.AssignFloat(&controlled->diesel.heat.To); } else if (Label == "water1temp:") { // main circuit water temperature auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignFloat(&mvControlled->diesel.heat.temperatura1); + gauge.AssignFloat(&controlled->diesel.heat.temperatura1); } else if (Label == "water2temp:") { // auxiliary circuit water temperature auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignFloat(&mvControlled->diesel.heat.temperatura2); + gauge.AssignFloat(&controlled->diesel.heat.temperatura2); } else if (Label == "pantpress:") { // pantograph tank pressure auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&mvPantographUnit->PantPress); + gauge.AssignDouble(&pantographUnit->PantPress); } // yB - dla drugiej sekcji else if (Label == "hvbcurrent1:") @@ -1982,7 +1982,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // np. ciśnienie sterownika sprzęgła auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignDouble(&mvControlled->diesel.clutchPressure); + gauge.AssignDouble(&controlled->diesel.clutchPressure); } // ggEngageRatio.Load(Parser,DynamicObject->mdKabina); else if (Label == "maingearstatus:") { @@ -2001,35 +2001,35 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // the counter shows the odometer of the vehicle, kept between the sessions (eu07/maszyna#72). its offset // was the state it started each session with, now it is that only for a vehicle with no known state if (auto const seed{odometer::counter_seed(gauge.offset(), gauge.scale())}; seed.has_value()) - mvControlled->Odometer.seed(*seed); + controlled->Odometer.seed(*seed); gauge.offset(0.f); - gauge.AssignDouble(&mvControlled->Odometer.km); + 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 - mvControlled->Odometer.shown = true; + controlled->Odometer.shown = true; } else if (Label == "shuntmodepower:") { // shunt mode power slider auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignDouble(&mvControlled->AnPos); + gauge.AssignDouble(&controlled->AnPos); m_controlmapper.insert(gauge, "shuntmodepower:"); } else if (Label == "heatingvoltage:") { - if (mvControlled->HeatingPowerSource.SourceType == TPowerSource::Generator) + if (controlled->HeatingPowerSource.SourceType == TPowerSource::Generator) { auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignDouble(&mvControlled->HeatingPowerSource.EngineGenerator.voltage); + gauge.AssignDouble(&controlled->HeatingPowerSource.EngineGenerator.voltage); } } else if (Label == "heatingcurrent:") { auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignDouble(&mvControlled->TotalCurrent); + gauge.AssignDouble(&controlled->TotalCurrent); } else { diff --git a/vehicle/cab/signalcommands.cpp b/vehicle/cab/signalcommands.cpp index 200781dbe..bc3c6183c 100644 --- a/vehicle/cab/signalcommands.cpp +++ b/vehicle/cab/signalcommands.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -62,10 +62,10 @@ void TTrain::OnCommand_hornlowactivate(TTrain *Train, command_data const &Comman if (Command.action == GLFW_PRESS) { // only need to react to press, sound will continue until stopped - if (false == TestFlag(Train->mvOccupied->WarningSignal, horn::low)) + if (false == TestFlag(Train->occupied->WarningSignal, horn::low)) { // turn on - Train->mvOccupied->WarningSignal = horn::pressed(Train->mvOccupied->WarningSignal, horn::low, Train->has_single_horn_lever()); + Train->occupied->WarningSignal = horn::pressed(Train->occupied->WarningSignal, horn::low, Train->has_single_horn_lever()); // visual feedback Train->ggHornButton.UpdateValue(-1.0); Train->ggHornLowButton.UpdateValue(1.0); @@ -74,9 +74,9 @@ void TTrain::OnCommand_hornlowactivate(TTrain *Train, command_data const &Comman else if (Command.action == GLFW_RELEASE) { // turn off - Train->mvOccupied->WarningSignal = horn::released(Train->mvOccupied->WarningSignal, horn::low); + Train->occupied->WarningSignal = horn::released(Train->occupied->WarningSignal, horn::low); // visual feedback - if (false == (Train->has_single_horn_lever() && TestFlag(Train->mvOccupied->WarningSignal, horn::high))) + if (false == (Train->has_single_horn_lever() && TestFlag(Train->occupied->WarningSignal, horn::high))) { // leave the single lever alone if it was moved to the other tone in the meantime Train->ggHornButton.UpdateValue(0.0); @@ -100,10 +100,10 @@ void TTrain::OnCommand_hornhighactivate(TTrain *Train, command_data const &Comma if (Command.action == GLFW_PRESS) { // only need to react to press, sound will continue until stopped - if (false == TestFlag(Train->mvOccupied->WarningSignal, horn::high)) + if (false == TestFlag(Train->occupied->WarningSignal, horn::high)) { // turn on - Train->mvOccupied->WarningSignal = horn::pressed(Train->mvOccupied->WarningSignal, horn::high, Train->has_single_horn_lever()); + Train->occupied->WarningSignal = horn::pressed(Train->occupied->WarningSignal, horn::high, Train->has_single_horn_lever()); // visual feedback Train->ggHornButton.UpdateValue(1.0); Train->ggHornHighButton.UpdateValue(1.0); @@ -112,9 +112,9 @@ void TTrain::OnCommand_hornhighactivate(TTrain *Train, command_data const &Comma else if (Command.action == GLFW_RELEASE) { // turn off - Train->mvOccupied->WarningSignal = horn::released(Train->mvOccupied->WarningSignal, horn::high); + Train->occupied->WarningSignal = horn::released(Train->occupied->WarningSignal, horn::high); // visual feedback - if (false == (Train->has_single_horn_lever() && TestFlag(Train->mvOccupied->WarningSignal, horn::low))) + if (false == (Train->has_single_horn_lever() && TestFlag(Train->occupied->WarningSignal, horn::low))) { // leave the single lever alone if it was moved to the other tone in the meantime Train->ggHornButton.UpdateValue(0.0); @@ -138,10 +138,10 @@ void TTrain::OnCommand_whistleactivate(TTrain *Train, command_data const &Comman if (Command.action == GLFW_PRESS) { // only need to react to press, sound will continue until stopped - if (false == TestFlag(Train->mvOccupied->WarningSignal, 4)) + if (false == TestFlag(Train->occupied->WarningSignal, 4)) { // turn on - Train->mvOccupied->WarningSignal |= 4; + Train->occupied->WarningSignal |= 4; // visual feedback Train->ggWhistleButton.UpdateValue(1.0); } @@ -149,7 +149,7 @@ void TTrain::OnCommand_whistleactivate(TTrain *Train, command_data const &Comman else if (Command.action == GLFW_RELEASE) { // turn off - Train->mvOccupied->WarningSignal &= ~4; + Train->occupied->WarningSignal &= ~4; // visual feedback Train->ggWhistleButton.UpdateValue(0.0); } @@ -165,14 +165,14 @@ void TTrain::OnCommand_radiotoggle(TTrain *Train, command_data const &Command) // NOTE: works without the switch in the 3d model too, to allow system reset after receiving radio-stop signal // only reacting to press, so the sound can loop uninterrupted // NOTE: flips the state directly rather than through radioenable/radiodisable, so it doesn't move the radioon_sw:/radiooff_sw: buttons - Train->mvOccupied->Radio = (false == Train->mvOccupied->Radio); + Train->occupied->Radio = (false == Train->occupied->Radio); } void TTrain::OnCommand_radioenable(TTrain *Train, command_data const &Command) { if (Command.action == GLFW_PRESS) { - Train->mvOccupied->Radio = true; + Train->occupied->Radio = true; // visual feedback if (Train->m_controlmapper.contains("radioon_sw:")) { @@ -192,7 +192,7 @@ void TTrain::OnCommand_radiodisable(TTrain *Train, command_data const &Command) { if (Command.action == GLFW_PRESS) { - Train->mvOccupied->Radio = false; + Train->occupied->Radio = false; // visual feedback if (Train->m_controlmapper.contains("radiooff_sw:")) { @@ -219,14 +219,14 @@ void TTrain::OnCommand_radiofusetoggle(TTrain *Train, command_data const &Comman // NOTE: flips the state directly rather than through radiofuseenable/radiofusedisable, so it doesn't move the // radiofuseon_sw:/radiofuseoff_sw: buttons - Train->mvOccupied->RadioFuse = (false == Train->mvOccupied->RadioFuse); + Train->occupied->RadioFuse = (false == Train->occupied->RadioFuse); } void TTrain::OnCommand_radiofuseenable(TTrain *Train, command_data const &Command) { if (Command.action == GLFW_PRESS) { - Train->mvOccupied->RadioFuse = true; + Train->occupied->RadioFuse = true; // visual feedback if (Train->m_controlmapper.contains("radiofuseon_sw:")) { @@ -246,7 +246,7 @@ void TTrain::OnCommand_radiofusedisable(TTrain *Train, command_data const &Comma { if (Command.action == GLFW_PRESS) { - Train->mvOccupied->RadioFuse = false; + Train->occupied->RadioFuse = false; // visual feedback if (Train->m_controlmapper.contains("radiofuseoff_sw:")) { @@ -268,7 +268,7 @@ void TTrain::OnCommand_radiochannelincrease(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { // the channel buttons of a radio switched off or without power do nothing - if (Train->mvOccupied->RadioPowered()) + if (Train->occupied->RadioPowered()) { command_data newCommand = Command; newCommand.param1 = Train->RadioChannel() + 1; @@ -289,7 +289,7 @@ void TTrain::OnCommand_radiochanneldecrease(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { - if (Train->mvOccupied->RadioPowered()) + if (Train->occupied->RadioPowered()) { command_data newCommand = Command; newCommand.param1 = Train->RadioChannel() - 1; @@ -320,7 +320,7 @@ void TTrain::OnCommand_radiostopsend(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - if (Train->mvOccupied->RadioPowered()) + if (Train->occupied->RadioPowered()) { simulation::Region->RadioStop(Train->Dynamic()->GetPosition()); } @@ -338,7 +338,7 @@ void TTrain::OnCommand_radiostopenable(TTrain *Train, command_data const &Comman { if (Command.action == GLFW_PRESS && Train->ggRadioStop.GetValue() == 0) { - if (Train->mvOccupied->RadioPowered()) + if (Train->occupied->RadioPowered()) { simulation::Region->RadioStop(Train->Dynamic()->GetPosition()); } @@ -361,7 +361,7 @@ void TTrain::OnCommand_radiostoptest(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { - if (Train->RadioChannel() == 10 && Train->mvOccupied->RadioPowered()) + if (Train->RadioChannel() == 10 && Train->occupied->RadioPowered()) { Train->Dynamic()->RadioStop(); } @@ -379,7 +379,7 @@ void TTrain::OnCommand_radiocall1send(TTrain *Train, command_data const &Command { if (Command.action == GLFW_PRESS) { - if (Train->RadioChannel() != 10 && Train->mvOccupied->RadioPowered()) + if (Train->RadioChannel() != 10 && Train->occupied->RadioPowered()) { simulation::Events.queue_receivers(radio_message::call1, Train->Dynamic()->GetPosition()); } @@ -398,7 +398,7 @@ void TTrain::OnCommand_radiocall3send(TTrain *Train, command_data const &Command if (Command.action == GLFW_PRESS) { - if (Train->RadioChannel() != 10 && Train->mvOccupied->RadioPowered()) + if (Train->RadioChannel() != 10 && Train->occupied->RadioPowered()) { simulation::Events.queue_receivers(radio_message::call3, Train->Dynamic()->GetPosition()); } @@ -418,7 +418,7 @@ void TTrain::OnCommand_radiovolumeincrease(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { // so do the volume buttons - if (Train->mvOccupied->RadioPowered()) + if (Train->occupied->RadioPowered()) { command_data newCommand = Command; newCommand.param1 = Train->m_radiovolume + 0.125; @@ -438,7 +438,7 @@ void TTrain::OnCommand_radiovolumedecrease(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { - if (Train->mvOccupied->RadioPowered()) + if (Train->occupied->RadioPowered()) { command_data newCommand = Command; newCommand.param1 = Train->m_radiovolume - 0.125; diff --git a/vehicle/cab/sounds.cpp b/vehicle/cab/sounds.cpp index 01a40da0a..e189027e2 100644 --- a/vehicle/cab/sounds.cpp +++ b/vehicle/cab/sounds.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -57,14 +57,14 @@ void TTrain::update_sounds(double const Deltatime) if (m_lastlocalbrakepressure != -1.f) { // calculate rate of pressure drop in local brake cylinder, once it's been initialized - auto const brakepressuredifference{mvOccupied->LocBrakePress - m_lastlocalbrakepressure}; + auto const brakepressuredifference{occupied->LocBrakePress - m_lastlocalbrakepressure}; m_localbrakepressurechange = static_cast(std::lerp(m_localbrakepressurechange, 10 * (brakepressuredifference / Deltatime), 0.1f)); } - m_lastlocalbrakepressure = static_cast(mvOccupied->LocBrakePress); + m_lastlocalbrakepressure = static_cast(occupied->LocBrakePress); // local brake, release if (rsSBHiss) { - if (m_localbrakepressurechange < -0.05f && mvOccupied->LocBrakePress > mvOccupied->BrakePress - 0.05) + if (m_localbrakepressurechange < -0.05f && occupied->LocBrakePress > occupied->BrakePress - 0.05) { rsSBHiss->gain(static_cast(std::clamp(rsSBHiss->m_amplitudeoffset + rsSBHiss->m_amplitudefactor * -m_localbrakepressurechange * 0.05, 0.0, 1.5))); rsSBHiss->play(sound_flags::exclusive | sound_flags::looping); @@ -102,12 +102,12 @@ void TTrain::update_sounds(double const Deltatime) // McZapkie-280302 - syczenie // TODO: softer volume reduction than plain abrupt stop, perhaps as reusable wrapper? - if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a || mvOccupied->BrakeHandle == TBrakeHandle::FVel6) + if (occupied->BrakeHandle == TBrakeHandle::FV4a || occupied->BrakeHandle == TBrakeHandle::FVel6) { // upuszczanie z PG if (rsHiss) { - fPPress = std::lerp(fPPress, static_cast(mvOccupied->Handle->GetSound(s_fv4a_b)), 0.05f); + fPPress = std::lerp(fPPress, static_cast(occupied->Handle->GetSound(s_fv4a_b)), 0.05f); volume = fPPress > 0 ? rsHiss->m_amplitudefactor * fPPress * 0.25 + rsHiss->m_amplitudeoffset : 0; if (volume * brakevolumescale > 0.05) { @@ -122,7 +122,7 @@ void TTrain::update_sounds(double const Deltatime) // napelnianie PG if (rsHissU) { - fNPress = std::lerp(fNPress, static_cast(mvOccupied->Handle->GetSound(s_fv4a_u)), 0.25f); + fNPress = std::lerp(fNPress, static_cast(occupied->Handle->GetSound(s_fv4a_u)), 0.25f); volume = fNPress > 0 ? rsHissU->m_amplitudefactor * fNPress + rsHissU->m_amplitudeoffset : 0; if (volume * brakevolumescale > 0.05) { @@ -137,7 +137,7 @@ void TTrain::update_sounds(double const Deltatime) // upuszczanie przy naglym if (rsHissE) { - volume = mvOccupied->Handle->GetSound(s_fv4a_e) * rsHissE->m_amplitudefactor + rsHissE->m_amplitudeoffset; + volume = occupied->Handle->GetSound(s_fv4a_e) * rsHissE->m_amplitudefactor + rsHissE->m_amplitudeoffset; if (volume * brakevolumescale > 0.05) { rsHissE->gain(static_cast(volume * brakevolumescale)); @@ -151,7 +151,7 @@ void TTrain::update_sounds(double const Deltatime) // upuszczanie sterujacego fala if (rsHissX) { - volume = mvOccupied->Handle->GetSound(s_fv4a_x) * rsHissX->m_amplitudefactor + rsHissX->m_amplitudeoffset; + volume = occupied->Handle->GetSound(s_fv4a_x) * rsHissX->m_amplitudefactor + rsHissX->m_amplitudeoffset; if (volume * brakevolumescale > 0.05) { rsHissX->gain(static_cast(volume * brakevolumescale)); @@ -165,7 +165,7 @@ void TTrain::update_sounds(double const Deltatime) // upuszczanie z czasowego if (rsHissT) { - volume = mvOccupied->Handle->GetSound(s_fv4a_t) * rsHissT->m_amplitudefactor + +rsHissT->m_amplitudeoffset; + volume = occupied->Handle->GetSound(s_fv4a_t) * rsHissT->m_amplitudefactor + +rsHissT->m_amplitudeoffset; if (volume * brakevolumescale > 0.05) { rsHissT->gain(static_cast(volume * brakevolumescale)); @@ -183,7 +183,7 @@ void TTrain::update_sounds(double const Deltatime) // upuszczanie z PG if (rsHiss) { - fPPress = static_cast((4.0f * fPPress + std::max(0.0, mvOccupied->dpMainValve)) / (4.0f + 1.0f)); + fPPress = static_cast((4.0f * fPPress + std::max(0.0, occupied->dpMainValve)) / (4.0f + 1.0f)); volume = fPPress > 0.0f ? 2.0 * rsHiss->m_amplitudefactor * fPPress + rsHiss->m_amplitudeoffset : 0.0; if (volume > 0.05) { @@ -198,7 +198,7 @@ void TTrain::update_sounds(double const Deltatime) // napelnianie PG if (rsHissU) { - fNPress = static_cast((4.0f * fNPress + std::min(0.0, mvOccupied->dpMainValve)) / (4.0f + 1.0f)); + fNPress = static_cast((4.0f * fNPress + std::min(0.0, occupied->dpMainValve)) / (4.0f + 1.0f)); volume = fNPress < 0.0f ? -1.0 * rsHissU->m_amplitudefactor * fNPress + rsHissU->m_amplitudeoffset : 0.0; if (volume > 0.01) { @@ -215,14 +215,14 @@ void TTrain::update_sounds(double const Deltatime) // brakes if (rsBrake) { - if (mvOccupied->UnitBrakeForce > 10.0 && mvOccupied->Vel > 0.05) + if (occupied->UnitBrakeForce > 10.0 && occupied->Vel > 0.05) { auto const brakeforceratio{ - std::clamp(mvOccupied->UnitBrakeForce / std::max(1.0, mvOccupied->BrakeForceR(1.0, mvOccupied->Vel) / (mvOccupied->NAxles * std::max(1, mvOccupied->NBpA))), 0.0, 1.0)}; + std::clamp(occupied->UnitBrakeForce / std::max(1.0, occupied->BrakeForceR(1.0, occupied->Vel) / (occupied->NAxles * std::max(1, occupied->NBpA))), 0.0, 1.0)}; // HACK: in external view mute the sound rather than stop it, in case there's an opening bookend it'd (re)play on sound restart after returning inside - volume = FreeFlyModeFlag ? 0.0 : rsBrake->m_amplitudeoffset + std::sqrt(brakeforceratio * std::lerp(0.4, 1.0, mvOccupied->Vel / (1 + mvOccupied->Vmax))) * rsBrake->m_amplitudefactor; - rsBrake->pitch(static_cast(rsBrake->m_frequencyoffset + mvOccupied->Vel * rsBrake->m_frequencyfactor)); + volume = FreeFlyModeFlag ? 0.0 : rsBrake->m_amplitudeoffset + std::sqrt(brakeforceratio * std::lerp(0.4, 1.0, occupied->Vel / (1 + occupied->Vmax))) * rsBrake->m_amplitudefactor; + rsBrake->pitch(static_cast(rsBrake->m_frequencyoffset + occupied->Vel * rsBrake->m_frequencyfactor)); rsBrake->gain(static_cast(volume)); rsBrake->play(sound_flags::exclusive | sound_flags::looping); } @@ -242,7 +242,7 @@ void TTrain::update_sounds(double const Deltatime) if (dsbSlipAlarm) { // alarm przy poslizgu dla 181/182 - BOMBARDIER - if (mvControlled->SlippingWheels && DynamicObject->GetVelocity() > 1.0) + if (controlled->SlippingWheels && DynamicObject->GetVelocity() > 1.0) { dsbSlipAlarm->play(sound_flags::exclusive | sound_flags::looping); } @@ -296,7 +296,7 @@ void TTrain::update_sounds(double const Deltatime) update_sounds_runningnoise(*rsHuntingNoise); // modify calculated sound volume by hunting amount auto const huntingamount = std::lerp( - 0.0, 1.0, std::clamp((mvOccupied->Vel - DynamicObject->HuntingShake.fadein_begin) / (DynamicObject->HuntingShake.fadein_end - DynamicObject->HuntingShake.fadein_begin), 0.0, 1.0)); + 0.0, 1.0, std::clamp((occupied->Vel - DynamicObject->HuntingShake.fadein_begin) / (DynamicObject->HuntingShake.fadein_end - DynamicObject->HuntingShake.fadein_begin), 0.0, 1.0)); rsHuntingNoise->gain(static_cast(rsHuntingNoise->gain() * huntingamount)); } @@ -340,11 +340,11 @@ void TTrain::update_sounds(double const Deltatime) } // power-reliant sounds - if (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable) + if (occupied->Power24vIsAvailable || occupied->Power110vIsAvailable) { // buzzer shp - if (mvOccupied->SecuritySystem.is_cabsignal_beeping()) + if (occupied->SecuritySystem.is_cabsignal_beeping()) { if (dsbBuzzerShp && false == dsbBuzzerShp->is_playing()) { @@ -363,7 +363,7 @@ void TTrain::update_sounds(double const Deltatime) // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa // hunter-091012: rozdzielenie alarmow - if (mvOccupied->SecuritySystem.is_beeping()) + if (occupied->SecuritySystem.is_beeping()) { if (dsbBuzzer && false == dsbBuzzer->is_playing()) { @@ -429,11 +429,11 @@ void TTrain::update_sounds(double const Deltatime) void TTrain::update_sounds_resonancenoise(sound_source &Sound) const { // frequency calculation - auto const normalizer{mvOccupied->Vmax * 0.01f}; - auto const soundfrequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * mvOccupied->Vel * normalizer}; + auto const normalizer{occupied->Vmax * 0.01f}; + auto const soundfrequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * occupied->Vel * normalizer}; // volume calculation - auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(mvOccupied->Vel / (1 + mvOccupied->Vmax), 1.0, 0.5); // scale base volume between 0.5-1.0 + auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(occupied->Vel / (1 + occupied->Vmax), 1.0, 0.5); // scale base volume between 0.5-1.0 if (volume > 0.05) { @@ -448,16 +448,16 @@ void TTrain::update_sounds_resonancenoise(sound_source &Sound) const void TTrain::update_sounds_runningnoise(sound_source &Sound) { // frequency calculation - auto const normalizer{(true == Sound.is_combined() ? mvOccupied->Vmax * 0.01f : 1.f)}; - auto const soundfrequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * mvOccupied->Vel * normalizer}; + auto const normalizer{(true == Sound.is_combined() ? occupied->Vmax * 0.01f : 1.f)}; + auto const soundfrequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * occupied->Vel * normalizer}; // volume calculation - auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(mvOccupied->Vel / (1 + mvOccupied->Vmax), 1.0, + auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(occupied->Vel / (1 + occupied->Vmax), 1.0, 0.5); // scale base volume between 0.5-1.0 - if (std::abs(mvOccupied->nrot) > 0.01) + if (std::abs(occupied->nrot) > 0.01) { // hamulce wzmagaja halas - auto const brakeforceratio{(std::clamp(mvOccupied->UnitBrakeForce / std::max(1.0, mvOccupied->BrakeForceR(1.0, mvOccupied->Vel) / (mvOccupied->NAxles * std::max(1, mvOccupied->NBpA))), 0.0, 1.0))}; + auto const brakeforceratio{(std::clamp(occupied->UnitBrakeForce / std::max(1.0, occupied->BrakeForceR(1.0, occupied->Vel) / (occupied->NAxles * std::max(1, occupied->NBpA))), 0.0, 1.0))}; volume *= 1 + 0.125 * brakeforceratio; } @@ -467,7 +467,7 @@ void TTrain::update_sounds_runningnoise(sound_source &Sound) // for single sample sounds muffle the playback at low speeds if (false == Sound.is_combined()) { - volume *= std::lerp(0.0, 1.0, std::clamp(mvOccupied->Vel / 25.0, 0.0, 1.0)); + volume *= std::lerp(0.0, 1.0, std::clamp(occupied->Vel / 25.0, 0.0, 1.0)); } if (volume > 0.05) @@ -490,7 +490,7 @@ void TTrain::update_sounds_radio() std::erase_if(m_radiomessages, [](auto const &source) { return false == source.second->is_playing(); }); } // adjust audibility of remaining messages based on current radio conditions - auto const radioenabled{mvOccupied->RadioPowered()}; + auto const radioenabled{occupied->RadioPowered()}; for (auto const &[messagechannel, messagesound] : m_radiomessages) { auto const volume{true == radioenabled && Dynamic()->Mechanik != nullptr && messagechannel == RadioChannel() ? m_radiovolume : 0.0}; @@ -500,7 +500,7 @@ void TTrain::update_sounds_radio() // radiostop if (m_radiostop) { - if (true == radioenabled && true == mvOccupied->RadioStopFlag) + if (true == radioenabled && true == occupied->RadioStopFlag) { m_radiostop->play(sound_flags::exclusive | sound_flags::looping); radio_message_played |= true; diff --git a/vehicle/cab/train.cpp b/vehicle/cab/train.cpp index 757be2871..32f5610ae 100644 --- a/vehicle/cab/train.cpp +++ b/vehicle/cab/train.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -103,7 +103,7 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) ErrorLog( "Bad config: can't take control of inactive vehicle \"" + NewDynamicObject->asName + "\"" ); return false; */ - auto const activecab{(NewDynamicObject->MoverParameters->CabOccupied > 0 ? "1" : NewDynamicObject->MoverParameters->CabOccupied < 0 ? "2" : "p")}; + auto const activecab{(NewDynamicObject->physics->CabOccupied > 0 ? "1" : NewDynamicObject->physics->CabOccupied < 0 ? "2" : "p")}; NewDynamicObject->create_controller(activecab, NewDynamicObject->ctOwner != nullptr); } @@ -115,14 +115,14 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) fMainRelayTimer = 0; // Hunter, do k...y nędzy, ustawiaj wartości początkowe zmiennych! - iCabn = mvOccupied->CabOccupied > 0 ? 1 : mvOccupied->CabOccupied < 0 ? 2 : 0; + iCabn = occupied->CabOccupied > 0 ? 1 : occupied->CabOccupied < 0 ? 2 : 0; { Global.CurrentMaxTextureSize = Global.iMaxCabTextureSize; - auto const filename{mvOccupied->TypeName + ".mmd"}; + auto const filename{occupied->TypeName + ".mmd"}; LoadMMediaFile(filename); - InitializeCab(mvOccupied->CabOccupied, filename); + InitializeCab(occupied->CabOccupied, filename); Global.CurrentMaxTextureSize = Global.iMaxTextureSize; @@ -135,15 +135,15 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) // Ra: taka proteza - przesłanie kierunku do członów connected /* - if (mvControlled->DirActive > 0) + if (controlled->DirActive > 0) { // było do przodu - mvControlled->DirectionBackward(); - mvControlled->DirectionForward(); + controlled->DirectionBackward(); + controlled->DirectionForward(); } - else if (mvControlled->DirActive < 0) + else if (controlled->DirActive < 0) { - mvControlled->DirectionForward(); - mvControlled->DirectionBackward(); + controlled->DirectionForward(); + controlled->DirectionBackward(); } */ if (false == DynamicObject->Mechanik->AIControllFlag) @@ -157,7 +157,7 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) std::shared_ptr TTrain::GetTrainState(dictionary_source const &Extraparameters) { - if (mvOccupied == nullptr || mvControlled == nullptr) + if (occupied == nullptr || controlled == nullptr) { return nullptr; } @@ -169,22 +169,22 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const } dict->insert("name", DynamicObject->asName); - dict->insert("cab", mvOccupied->CabOccupied); - dict->insert("cabactive", mvOccupied->CabActive); - dict->insert("master", mvOccupied->CabMaster); + dict->insert("cab", occupied->CabOccupied); + dict->insert("cabactive", occupied->CabActive); + dict->insert("master", occupied->CabMaster); // basic systems state data - dict->insert("battery", mvOccupied->Power24vIsAvailable); - dict->insert("linebreaker", mvControlled->Mains); - dict->insert("main_init", mvControlled->MainsInitTimeCountdown < mvControlled->MainsInitTime && mvControlled->MainsInitTimeCountdown > 0.0); - dict->insert("main_ready", false == mvControlled->Mains && fHVoltage > 0.0 && mvControlled->MainsInitTimeCountdown <= 0.0); - dict->insert("converter", mvOccupied->Power110vIsAvailable); - dict->insert("converter_overload", mvControlled->ConvOvldFlag); - dict->insert("compress", mvControlled->CompressorFlag); - dict->insert("pant_compressor", mvPantographUnit->PantCompFlag); - dict->insert("lights_front", mvOccupied->iLights[VehicleEnd::front]); - dict->insert("lights_rear", mvOccupied->iLights[VehicleEnd::rear]); - dict->insert("off_from_dimmer", mvOccupied->currentDimPosition().isOff); - dict->insert("lights_compartments", mvOccupied->CompartmentLights.is_active || mvOccupied->CompartmentLights.is_disabled); + dict->insert("battery", occupied->Power24vIsAvailable); + dict->insert("linebreaker", controlled->Mains); + dict->insert("main_init", controlled->MainsInitTimeCountdown < controlled->MainsInitTime && controlled->MainsInitTimeCountdown > 0.0); + dict->insert("main_ready", false == controlled->Mains && fHVoltage > 0.0 && controlled->MainsInitTimeCountdown <= 0.0); + dict->insert("converter", occupied->Power110vIsAvailable); + dict->insert("converter_overload", controlled->ConvOvldFlag); + dict->insert("compress", controlled->CompressorFlag); + dict->insert("pant_compressor", pantographUnit->PantCompFlag); + dict->insert("lights_front", occupied->iLights[VehicleEnd::front]); + dict->insert("lights_rear", occupied->iLights[VehicleEnd::rear]); + dict->insert("off_from_dimmer", occupied->currentDimPosition().isOff); + dict->insert("lights_compartments", occupied->CompartmentLights.is_active || occupied->CompartmentLights.is_disabled); if (Dynamic()->Mechanik) { auto const *controller{Dynamic()->Mechanik}; @@ -194,55 +194,55 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const auto const *rearvehicle{controller->Vehicle(traindirection >= 0 ? VehicleEnd::rear : VehicleEnd::front)}; auto const frontvehicledirection{(frontvehicle->DirectionGet() == controller->Vehicle()->DirectionGet() ? 1 : -1)}; auto const rearvehicledirection{(rearvehicle->DirectionGet() == controller->Vehicle()->DirectionGet() ? 1 : -1)}; - auto const fronttrainlights{frontvehicle->MoverParameters->iLights[frontvehicledirection * cabmodifier >= 0 ? VehicleEnd::front : VehicleEnd::rear]}; - auto const reartrainlights{rearvehicle->MoverParameters->iLights[rearvehicledirection * cabmodifier >= 0 ? VehicleEnd::rear : VehicleEnd::front]}; + auto const fronttrainlights{frontvehicle->physics->iLights[frontvehicledirection * cabmodifier >= 0 ? VehicleEnd::front : VehicleEnd::rear]}; + auto const reartrainlights{rearvehicle->physics->iLights[rearvehicledirection * cabmodifier >= 0 ? VehicleEnd::rear : VehicleEnd::front]}; dict->insert("lights_train_front", fronttrainlights); dict->insert("lights_train_rear", reartrainlights); } else { // fallback, in the unlikely case we lose the controller - dict->insert("lights_train_front", mvOccupied->iLights[VehicleEnd::front]); - dict->insert("lights_train_rear", mvOccupied->iLights[VehicleEnd::rear]); + dict->insert("lights_train_front", occupied->iLights[VehicleEnd::front]); + dict->insert("lights_train_rear", occupied->iLights[VehicleEnd::rear]); } // reverser - dict->insert("direction", mvOccupied->DirActive); + dict->insert("direction", occupied->DirActive); // throttle - dict->insert("mainctrl_pos", mvControlled->MainCtrlPos); - dict->insert("mainctrl_pos_count", mvControlled->MainCtrlPosNo); - dict->insert("main_ctrl_actual_pos", mvControlled->MainCtrlActualPos); - dict->insert("scndctrl_pos", mvControlled->ScndCtrlPos); - dict->insert("dynamicbrake_pos", mvControlled->DynamicBrakeCtrlPos); - dict->insert("scnd_ctrl_actual_pos", mvControlled->ScndCtrlActualPos); - dict->insert("brakectrl_pos", mvControlled->fBrakeCtrlPos); - dict->insert("localbrake_pos", mvControlled->LocalBrakePosA); - dict->insert("new_speed", mvOccupied->NewSpeed); - dict->insert("speedctrl", mvOccupied->SpeedCtrlValue); - dict->insert("speedctrlpower", mvOccupied->SpeedCtrlUnit.DesiredPower); - dict->insert("speedctrlactive", mvOccupied->SpeedCtrlUnit.IsActive); - dict->insert("speedctrlstandby", mvOccupied->SpeedCtrlUnit.Standby); + dict->insert("mainctrl_pos", controlled->MainCtrlPos); + dict->insert("mainctrl_pos_count", controlled->MainCtrlPosNo); + dict->insert("main_ctrl_actual_pos", controlled->MainCtrlActualPos); + dict->insert("scndctrl_pos", controlled->ScndCtrlPos); + dict->insert("dynamicbrake_pos", controlled->DynamicBrakeCtrlPos); + dict->insert("scnd_ctrl_actual_pos", controlled->ScndCtrlActualPos); + dict->insert("brakectrl_pos", controlled->fBrakeCtrlPos); + dict->insert("localbrake_pos", controlled->LocalBrakePosA); + dict->insert("new_speed", occupied->NewSpeed); + dict->insert("speedctrl", occupied->SpeedCtrlValue); + dict->insert("speedctrlpower", occupied->SpeedCtrlUnit.DesiredPower); + dict->insert("speedctrlactive", occupied->SpeedCtrlUnit.IsActive); + dict->insert("speedctrlstandby", occupied->SpeedCtrlUnit.Standby); // brakes - dict->insert("manual_brake", mvOccupied->ManualBrakePos > 0); - bool const bEP = mvControlled->LocHandle->GetCP() > 0.2 || fEIMParams[0][5] > 0.01; + dict->insert("manual_brake", occupied->ManualBrakePos > 0); + bool const bEP = controlled->LocHandle->GetCP() > 0.2 || fEIMParams[0][5] > 0.01; dict->insert("dir_brake", bEP); bool bPN{false}; - auto const &brakevalve{*mvOccupied->Hamulec}; + auto const &brakevalve{*occupied->Hamulec}; if (auto const &brakevalvetype{typeid(brakevalve)}; brakevalvetype == typeid(TLSt) || brakevalvetype == typeid(TEStED)) { - TBrake *temp_ham = mvOccupied->Hamulec.get(); + TBrake *temp_ham = occupied->Hamulec.get(); bPN = static_cast(temp_ham)->GetEDBCP() > 0.2; } dict->insert("indir_brake", bPN); - dict->insert("emergency_brake", mvOccupied->AlarmChainFlag); - dict->insert("brake_delay_flag", mvOccupied->BrakeDelayFlag); - dict->insert("brake_op_mode_flag", mvOccupied->BrakeOpModeFlag); - dict->insert("pipelock", mvOccupied->LockPipe); + dict->insert("emergency_brake", occupied->AlarmChainFlag); + dict->insert("brake_delay_flag", occupied->BrakeDelayFlag); + dict->insert("brake_op_mode_flag", occupied->BrakeOpModeFlag); + dict->insert("pipelock", occupied->LockPipe); // other controls - dict->insert("ca", mvOccupied->SecuritySystem.is_vigilance_blinking()); - dict->insert("shp", mvOccupied->SecuritySystem.is_cabsignal_blinking()); + dict->insert("ca", occupied->SecuritySystem.is_vigilance_blinking()); + dict->insert("shp", occupied->SecuritySystem.is_cabsignal_blinking()); dict->insert("distance_counter", m_distancecounter); - dict->insert("pantpress", std::abs(mvPantographUnit->PantPress)); + dict->insert("pantpress", std::abs(pantographUnit->PantPress)); dict->insert("universal3", InstrumentLightActive); for (auto idx = 0; idx < ggUniversals.size(); idx++) { @@ -251,29 +251,29 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("universal" + std::to_string(idx), ggUniversals[idx].GetValue() > 0.5); } } - dict->insert("radio", mvOccupied->Radio); - dict->insert("radio_fuse", mvOccupied->RadioFuse); + dict->insert("radio", occupied->Radio); + dict->insert("radio_fuse", occupied->RadioFuse); dict->insert("radio_channel", RadioChannel()); dict->insert("radio_volume", m_radiovolume); - dict->insert("door_lock", mvOccupied->Doors.lock_enabled); - dict->insert("door_step", mvOccupied->Doors.step_enabled); - dict->insert("door_permit_left", mvOccupied->Doors.instances[VehicleSide::left].open_permit); - dict->insert("door_permit_right", mvOccupied->Doors.instances[VehicleSide::right].open_permit); + dict->insert("door_lock", occupied->Doors.lock_enabled); + dict->insert("door_step", occupied->Doors.step_enabled); + dict->insert("door_permit_left", occupied->Doors.instances[VehicleSide::left].open_permit); + dict->insert("door_permit_right", occupied->Doors.instances[VehicleSide::right].open_permit); // movement data - dict->insert("velocity", std::abs(mvOccupied->Vel)); - dict->insert("tractionforce", std::abs(mvOccupied->Ft)); - dict->insert("slipping_wheels", mvOccupied->SlippingWheels); - dict->insert("sanding", mvOccupied->SandDose); - dict->insert("odometer", mvOccupied->DistCounter); // distance run in the session, km - dict->insert("odometer_total", mvOccupied->Odometer.km); // the vehicle's odometer, kept between the sessions + dict->insert("velocity", std::abs(occupied->Vel)); + dict->insert("tractionforce", std::abs(occupied->Ft)); + dict->insert("slipping_wheels", occupied->SlippingWheels); + dict->insert("sanding", occupied->SandDose); + dict->insert("odometer", occupied->DistCounter); // distance run in the session, km + dict->insert("odometer_total", occupied->Odometer.km); // the vehicle's odometer, kept between the sessions // electric current data - dict->insert("traction_voltage", std::abs(mvPantographUnit->PantographVoltage)); - dict->insert("voltage", std::abs(mvControlled->EngineVoltage)); - dict->insert("im", std::abs(mvControlled->Im)); - dict->insert("fuse", mvControlled->FuseFlag); - dict->insert("epfuse", mvOccupied->EpFuse); - dict->insert("power_drawn", mvOccupied->EnergyMeter.first); - dict->insert("power_returned", mvOccupied->EnergyMeter.second); + dict->insert("traction_voltage", std::abs(pantographUnit->PantographVoltage)); + dict->insert("voltage", std::abs(controlled->EngineVoltage)); + dict->insert("im", std::abs(controlled->Im)); + dict->insert("fuse", controlled->FuseFlag); + dict->insert("epfuse", occupied->EpFuse); + dict->insert("power_drawn", occupied->EnergyMeter.first); + dict->insert("power_returned", occupied->EnergyMeter.second); // induction motor state data std::array const TXTT{"fd", "fdt", "fdb", "pd", "pdt", "pdb", "itothv", "1", "2", "3"}; @@ -314,20 +314,20 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("compressors_" + idx + "_car_no", std::get<2>(bCompressors[i])); } - bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; - TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); + bool kier = DynamicObject->DirectionGet() * occupied->CabOccupied > 0; + TDynamicObject *p = DynamicObject->GetFirstDynamic(occupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); int in = 0; while (p && in < 8) { - if (p->MoverParameters->inductionMotor.traction.maxPower > 1) + if (p->physics->inductionMotor.traction.maxPower > 1) { in++; - dict->insert("eimp_c" + std::to_string(in) + "_invno", p->MoverParameters->inductionMotor.inverterCount); - for (int j = 0; j < p->MoverParameters->inductionMotor.inverterCount; j++) + dict->insert("eimp_c" + std::to_string(in) + "_invno", p->physics->inductionMotor.inverterCount); + for (int j = 0; j < p->physics->inductionMotor.inverterCount; j++) { - dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_act", p->MoverParameters->inductionMotor.inverters[j].IsActive); - dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_error", p->MoverParameters->inductionMotor.inverters[j].Error); - dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_allow", p->MoverParameters->inductionMotor.inverters[j].Activate); + dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_act", p->physics->inductionMotor.inverters[j].IsActive); + dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_error", p->physics->inductionMotor.inverters[j].Error); + dict->insert("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_allow", p->physics->inductionMotor.inverters[j].Activate); } } p = kier ? p->Next(Coupling::control) : p->Prev(Coupling::control); @@ -408,30 +408,30 @@ TTrain::state_t TTrain::get_state() const static_cast(iCabn), btHaslerBrakes.GetValue(), btHaslerCurrent.GetValue(), - mvOccupied->SecuritySystem.is_beeping(), + occupied->SecuritySystem.is_beeping(), btLampkaHVoltageB.GetValue(), fTachoVelocity, - static_cast(mvOccupied->Compressor), - static_cast(mvOccupied->PipePress), - static_cast(mvOccupied->BrakePress), - static_cast(mvPantographUnit->PantPress), + static_cast(occupied->Compressor), + static_cast(occupied->PipePress), + static_cast(occupied->BrakePress), + static_cast(pantographUnit->PantPress), fHVoltage, - {fHCurrent[mvControlled->TrainType == train_type::emu ? 0 : 1], fHCurrent[2], fHCurrent[3]}, + {fHCurrent[controlled->TrainType == train_type::emu ? 0 : 1], fHCurrent[2], fHCurrent[3]}, ggLVoltage.GetValue(), - mvOccupied->DistCounter, + occupied->DistCounter, static_cast(RadioChannel()), btLampkaSpringBrakeActive.GetValue(), btLampkaNapNastHam.GetValue(), - mvOccupied->DirActive > 0, - mvOccupied->DirActive < 0, - mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? VehicleSide::right : VehicleSide::left].open_permit, - mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? VehicleSide::right : VehicleSide::left].is_open, - mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? VehicleSide::left : VehicleSide::right].open_permit, - mvOccupied->Doors.instances[mvOccupied->CabOccupied < 0 ? VehicleSide::left : VehicleSide::right].is_open, - mvOccupied->Doors.step_enabled, - mvOccupied->Power24vIsAvailable, + occupied->DirActive > 0, + occupied->DirActive < 0, + occupied->Doors.instances[occupied->CabOccupied < 0 ? VehicleSide::right : VehicleSide::left].open_permit, + occupied->Doors.instances[occupied->CabOccupied < 0 ? VehicleSide::right : VehicleSide::left].is_open, + occupied->Doors.instances[occupied->CabOccupied < 0 ? VehicleSide::left : VehicleSide::right].open_permit, + occupied->Doors.instances[occupied->CabOccupied < 0 ? VehicleSide::left : VehicleSide::right].is_open, + occupied->Doors.step_enabled, + occupied->Power24vIsAvailable, 0, - mvOccupied->LockPipe, + occupied->LockPipe, btLampkaRadioMessage.GetValue(), }; } @@ -439,21 +439,21 @@ TTrain::state_t TTrain::get_state() const bool TTrain::is_eztoer() const { - return mvControlled->TrainType == train_type::emu && mvOccupied->BrakeSubsystem == TBrakeSubSystem::ss_ESt && mvControlled->Power24vIsAvailable == true && mvControlled->EpFuse == true && - mvControlled->DirActive != 0; // od yB + return controlled->TrainType == train_type::emu && occupied->BrakeSubsystem == TBrakeSubSystem::ss_ESt && controlled->Power24vIsAvailable == true && controlled->EpFuse == true && + controlled->DirActive != 0; // od yB } -// mover master controller to specified position +// physics master controller to specified position void TTrain::set_master_controller(double const Position) { - auto positionchange{std::min(static_cast(Position), mvControlled->CoupledCtrl ? mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo : mvControlled->MainCtrlPosNo) - - (mvControlled->CoupledCtrl ? mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos : mvControlled->MainCtrlPos)}; - while (positionchange < 0 && true == mvControlled->DecMainCtrl(1)) + auto positionchange{std::min(static_cast(Position), controlled->CoupledCtrl ? controlled->MainCtrlPosNo + controlled->ScndCtrlPosNo : controlled->MainCtrlPosNo) - + (controlled->CoupledCtrl ? controlled->MainCtrlPos + controlled->ScndCtrlPos : controlled->MainCtrlPos)}; + while (positionchange < 0 && true == controlled->DecMainCtrl(1)) { ++positionchange; } - while (positionchange > 0 && true == mvControlled->IncMainCtrl(1)) + while (positionchange > 0 && true == controlled->IncMainCtrl(1)) { --positionchange; } @@ -463,16 +463,16 @@ void TTrain::set_master_controller(double const Position) void TTrain::set_train_brake(double const Position) { - auto const originalbrakeposition{static_cast(100.0 * mvOccupied->fBrakeCtrlPos)}; - mvOccupied->BrakeLevelSet(Position); + auto const originalbrakeposition{static_cast(100.0 * occupied->fBrakeCtrlPos)}; + occupied->BrakeLevelSet(Position); - if (static_cast(100.0 * mvOccupied->fBrakeCtrlPos) == originalbrakeposition) + if (static_cast(100.0 * occupied->fBrakeCtrlPos) == originalbrakeposition) { return; } // sound feedback if the lever movement activates one of the switches - if (true == is_eztoer() && false == ((originalbrakeposition / 100 == 0 || originalbrakeposition / 100 >= 5) && (mvOccupied->BrakeCtrlPos == 0 || mvOccupied->BrakeCtrlPos >= 5)) && dsbPneumaticSwitch) + if (true == is_eztoer() && false == ((originalbrakeposition / 100 == 0 || originalbrakeposition / 100 >= 5) && (occupied->BrakeCtrlPos == 0 || occupied->BrakeCtrlPos >= 5)) && dsbPneumaticSwitch) { dsbPneumaticSwitch->play(); } @@ -482,8 +482,8 @@ void TTrain::zero_charging_train_brake() { using enum TBrakeHandle; - if (mvOccupied->BrakeCtrlPos == -1 && DynamicObject->Controller != AIdriver && Global.iFeedbackMode < 3 && - (mvOccupied->BrakeHandle == FVel6 || mvOccupied->BrakeHandle == MHZ_EN57 || mvOccupied->BrakeHandle == MHZ_K8P)) + if (occupied->BrakeCtrlPos == -1 && DynamicObject->Controller != AIdriver && Global.iFeedbackMode < 3 && + (occupied->BrakeHandle == FVel6 || occupied->BrakeHandle == MHZ_EN57 || occupied->BrakeHandle == MHZ_K8P)) { // Odskakiwanie hamulce EP set_train_brake(0); @@ -495,19 +495,19 @@ void TTrain::set_train_brake_speed(TDynamicObject *Vehicle, int const Speed) // visual feedback // TODO: add setting indicator to vehicle class, for external lever/indicator - if (true == Vehicle->MoverParameters->BrakeDelaySwitch(Speed) && Vehicle == DynamicObject) + if (true == Vehicle->physics->BrakeDelaySwitch(Speed) && Vehicle == DynamicObject) { if (ggBrakeProfileCtrl.SubModel != nullptr) { - ggBrakeProfileCtrl.UpdateValue((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 2.0 : static_cast(mvOccupied->BrakeDelayFlag - 1), dsbSwitch); + ggBrakeProfileCtrl.UpdateValue((occupied->BrakeDelayFlag & bdelay_R) != 0 ? 2.0 : static_cast(occupied->BrakeDelayFlag - 1), dsbSwitch); } if (ggBrakeProfileG.SubModel != nullptr) { - ggBrakeProfileG.UpdateValue(mvOccupied->BrakeDelayFlag == bdelay_G ? 1.0 : 0.0, dsbSwitch); + ggBrakeProfileG.UpdateValue(occupied->BrakeDelayFlag == bdelay_G ? 1.0 : 0.0, dsbSwitch); } if (ggBrakeProfileR.SubModel != nullptr) { - ggBrakeProfileR.UpdateValue((mvOccupied->BrakeDelayFlag & bdelay_R) != 0 ? 1.0 : 0.0, dsbSwitch); + ggBrakeProfileR.UpdateValue((occupied->BrakeDelayFlag & bdelay_R) != 0 ? 1.0 : 0.0, dsbSwitch); } } } @@ -515,17 +515,17 @@ void TTrain::set_train_brake_speed(TDynamicObject *Vehicle, int const Speed) void TTrain::set_paired_open_motor_connectors_button(bool const State) { - if (mvControlled->TrainType == train_type::et41 || mvControlled->TrainType == train_type::et42) + if (controlled->TrainType == train_type::et41 || controlled->TrainType == train_type::et42) { // crude implementation of the button affecting entire unit for multi-unit engines // TODO: rework it into part of standard command propagation system - if (mvControlled->Couplers[VehicleEnd::front].Connected != nullptr && true == mvControlled->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::permanent)) + if (controlled->Couplers[VehicleEnd::front].Connected != nullptr && true == controlled->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::permanent)) { - mvControlled->Couplers[VehicleEnd::front].Connected->StLinSwitchOff = State; + controlled->Couplers[VehicleEnd::front].Connected->StLinSwitchOff = State; } - if (mvControlled->Couplers[VehicleEnd::rear].Connected != nullptr && true == mvControlled->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::permanent)) + if (controlled->Couplers[VehicleEnd::rear].Connected != nullptr && true == controlled->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::permanent)) { - mvControlled->Couplers[VehicleEnd::rear].Connected->StLinSwitchOff = State; + controlled->Couplers[VehicleEnd::rear].Connected->StLinSwitchOff = State; } } } @@ -551,18 +551,18 @@ 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) - mvOccupied->CabOccupied == -1 ? 2 : mvOccupied->CabOccupied)) + occupied->CabOccupied == -1 ? 2 : occupied->CabOccupied)) { - InitializeCab(mvOccupied->CabOccupied, mvOccupied->TypeName + ".mmd"); + InitializeCab(occupied->CabOccupied, occupied->TypeName + ".mmd"); } - iCabn = mvOccupied->CabOccupied == -1 ? 2 : mvOccupied->CabOccupied; + iCabn = occupied->CabOccupied == -1 ? 2 : occupied->CabOccupied; } void TTrain::add_distance(double const Distance) { - auto const meterenabled{m_distancecounter >= 0 && (mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable)}; + auto const meterenabled{m_distancecounter >= 0 && (occupied->Power24vIsAvailable || occupied->Power110vIsAvailable)}; if (true == meterenabled) { @@ -580,22 +580,22 @@ bool TTrain::CabChange(int iDirection) { // jeśli prowadzi AI albo jest w innym członie // jak AI prowadzi, to nie można mu mieszać - if (std::abs(mvOccupied->CabOccupied + iDirection) > 1) + if (std::abs(occupied->CabOccupied + iDirection) > 1) return false; // ewentualna zmiana pojazdu - mvOccupied->CabOccupied += iDirection; + occupied->CabOccupied += iDirection; } else { // jeśli pojazd prowadzony ręcznie albo wcale (wagon) - mvOccupied->CabDeactivisationAuto(); - if (mvOccupied->ChangeCab(iDirection) && InitializeCab(mvOccupied->CabOccupied, mvOccupied->TypeName + ".mmd")) + occupied->CabDeactivisationAuto(); + if (occupied->ChangeCab(iDirection) && InitializeCab(occupied->CabOccupied, occupied->TypeName + ".mmd")) { // zmiana kabiny w ramach tego samego pojazdu - mvOccupied->CabActivisationAuto(); // załączenie rozrządu (wirtualne kabiny) + occupied->CabActivisationAuto(); // załączenie rozrządu (wirtualne kabiny) DynamicObject->Mechanik->DirectionChange(); return true; // udało się zmienić kabinę } // aktywizacja poprzedniej, bo jeszcze nie wiadomo, czy jakiś pojazd jest - mvOccupied->CabActivisationAuto(); + occupied->CabActivisationAuto(); } return false; // ewentualna zmiana pojazdu } @@ -616,36 +616,36 @@ void TTrain::DynamicSet(TDynamicObject *d) // jeździć dobrze // również hamowanie wykonuje się zaworem w członie, a nie w silnikowym... DynamicObject = d; // jedyne miejsce zmiany - mvControlled = d ? DynamicObject->MoverParameters : nullptr; // albo silnikowy w EZT - mvOccupied = mvControlled; + controlled = d ? DynamicObject->physics : nullptr; // albo silnikowy w EZT + occupied = controlled; if (DynamicObject == nullptr) { return; } - mvControlled = DynamicObject->FindPowered()->MoverParameters; - mvSecond = nullptr; // gdyby się nic nie znalazło - if (mvOccupied->Power > 1.0) // dwuczłonowe lub ukrotnienia, żeby nie szukać każdorazowo + controlled = DynamicObject->FindPowered()->physics; + secondUnit = nullptr; // gdyby się nic nie znalazło + if (occupied->Power > 1.0) // dwuczłonowe lub ukrotnienia, żeby nie szukać każdorazowo { - if (mvOccupied->Couplers[1].Connected != nullptr && mvOccupied->Couplers[1].AllowedFlag.HasAny(Coupling::control)) + if (occupied->Couplers[1].Connected != nullptr && occupied->Couplers[1].AllowedFlag.HasAny(Coupling::control)) { // gdy jest człon od sprzęgu 1, a sprzęg łączony // warsztatowo (powiedzmy) - if (mvOccupied->Couplers[1].Connected->Power > 1.0) // ten drugi ma moc - mvSecond = mvOccupied->Couplers[1].Connected; // wskaźnik na drugiego + if (occupied->Couplers[1].Connected->Power > 1.0) // ten drugi ma moc + secondUnit = occupied->Couplers[1].Connected; // wskaźnik na drugiego } - else if (mvOccupied->Couplers[0].Connected != nullptr && mvOccupied->Couplers[0].AllowedFlag.HasAny(Coupling::control)) + else if (occupied->Couplers[0].Connected != nullptr && occupied->Couplers[0].AllowedFlag.HasAny(Coupling::control)) { // gdy jest człon od sprzęgu 0, a sprzęg łączony // warsztatowo (powiedzmy) - if (mvOccupied->Couplers[0].Connected->Power > 1.0) // ale ten drugi ma moc - mvSecond = mvOccupied->Couplers[0].Connected; // wskaźnik na drugiego + if (occupied->Couplers[0].Connected->Power > 1.0) // ale ten drugi ma moc + secondUnit = occupied->Couplers[0].Connected; // wskaźnik na drugiego } } // cache nearest unit equipped with pantographs { auto *lookup{DynamicObject->FindPantographCarrier()}; // HACK: set pointer to existing vehicle to avoid error checking all over the place - mvPantographUnit = lookup != nullptr ? lookup->MoverParameters : mvControlled; + pantographUnit = lookup != nullptr ? lookup->physics : controlled; } }; @@ -813,7 +813,7 @@ void TTrain::radio_message(sound_source *Message, int const Channel) m_radiomessages.emplace_back(Channel, std::make_shared(m_radiosound)); // assign sound to the template and play it auto &message = *m_radiomessages.back().second.get(); - auto const radioenabled{mvOccupied->RadioPowered()}; + auto const radioenabled{occupied->RadioPowered()}; auto const volume{true == radioenabled && Dynamic()->Mechanik != nullptr && Channel == RadioChannel() ? 1.0 : 0.0}; message.copy_sounds(*Message).gain(static_cast(volume)).play(); } diff --git a/vehicle/cab/update.cpp b/vehicle/cab/update.cpp index 538fc968b..3409f383e 100644 --- a/vehicle/cab/update.cpp +++ b/vehicle/cab/update.cpp @@ -38,7 +38,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include #include #include @@ -65,7 +65,7 @@ bool TTrain::Update(double const Deltatime) updateUnitStates(); updateFeedbackGauges(); updateConverterOverload(Deltatime); - auto const lowvoltagepower{mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable}; + auto const lowvoltagepower{occupied->Power24vIsAvailable || occupied->Power110vIsAvailable}; updateSecondUnitGauges(); updateClock(); @@ -74,12 +74,12 @@ bool TTrain::Update(double const Deltatime) /* if (ggZbS.SubModel) { - ggZbS.UpdateValue(mvOccupied->Handle->GetCP()); + ggZbS.UpdateValue(occupied->Handle->GetCP()); ggZbS.Update(); } */ // replacement for the above. TODO: move it to a more suitable place - m_brakehandlecp = mvOccupied->Handle->GetCP(); + m_brakehandlecp = occupied->Handle->GetCP(); updateEngineGauges(); updateBasicLamps(); @@ -103,15 +103,15 @@ bool TTrain::Update(double const Deltatime) updateAuxiliaryButtons(lowvoltagepower); // wyprowadzenie sygnałów dla haslera na PoKeys (zaznaczanie na taśmie) - btHaslerBrakes.Turn(mvOccupied->BrakePress > 0.4); // ciśnienie w cylindrach - btHaslerCurrent.Turn(mvOccupied->Im != 0.0); // prąd na silnikach + btHaslerBrakes.Turn(occupied->BrakePress > 0.4); // ciśnienie w cylindrach + btHaslerCurrent.Turn(occupied->Im != 0.0); // prąd na silnikach updateCabLightLevels(); // anti slip system activation, maintained while the control button is down - if (mvOccupied->BrakeSystem != TBrakeSystem::ElectroPneumatic && ggAntiSlipButton.GetDesiredValue() > 0.95) + if (occupied->BrakeSystem != TBrakeSystem::ElectroPneumatic && ggAntiSlipButton.GetDesiredValue() > 0.95) { - mvControlled->AntiSlippingBrake(); + controlled->AntiSlippingBrake(); } // screens @@ -122,13 +122,13 @@ bool TTrain::Update(double const Deltatime) } // update direction relay - if (prevBatState != mvOccupied->Power24vIsAvailable) + if (prevBatState != occupied->Power24vIsAvailable) SetupDirectionRelays(); - if (prevDirection != mvOccupied->DirActive) + if (prevDirection != occupied->DirActive) UpdateDirectionRelays(); - prevBatState = mvOccupied->Power24vIsAvailable; - prevDirection = mvOccupied->DirActive; + prevBatState = occupied->Power24vIsAvailable; + prevDirection = occupied->DirActive; // sounds update_sounds(Deltatime); @@ -140,12 +140,12 @@ bool TTrain::Update(double const Deltatime) void TTrain::updateLineBreakerState(double const Deltatime) { // line breaker: - if (m_linebreakerstate == linebreaker::state::open && true == mvControlled->Mains) + if (m_linebreakerstate == linebreaker::state::open && true == controlled->Mains) { // crude way to sync state of the linebreaker with ai-issued commands m_linebreakerstate = linebreaker::state::closed; } - if (m_linebreakerstate == linebreaker::state::closed && false == (mvControlled->Mains || mvControlled->diesel.startupRequested)) + if (m_linebreakerstate == linebreaker::state::closed && false == (controlled->Mains || controlled->diesel.startupRequested)) { // crude way to catch cases where the main was knocked out // because the state of the line breaker isn't changed to match, we need to do it here manually @@ -153,7 +153,7 @@ void TTrain::updateLineBreakerState(double const Deltatime) } if (is_hold_coil_lever(ggMainOffButton) && hold_coil_lever::cuts_off(ggMainOffButton.GetDesiredValue())) { - if (true == mvControlled->Mains) + if (true == controlled->Mains) { // the line breaker was closed with the hold coil lever off, by the AI or through the control cable: // put the lever back on to match, like the line breaker state above @@ -171,7 +171,7 @@ void TTrain::updateLineBreakerState(double const Deltatime) ggIgnitionKey.GetDesiredValue() > 0.95) { // HACK: fallback // keep track of period the line breaker button is held down, to determine when/if circuit closes - if (mvControlled->MainSwitchCheck()) + if (controlled->MainSwitchCheck()) { fMainRelayTimer += static_cast(Deltatime); } @@ -186,7 +186,7 @@ void TTrain::updateLineBreakerState(double const Deltatime) // if the button disconnecting the line breaker is down prevent the timer from accumulating fMainRelayTimer = 0.0f; } - if (m_linebreakerstate == linebreaker::state::open && fMainRelayTimer > mvControlled->InitialCtrlDelay) + if (m_linebreakerstate == linebreaker::state::open && fMainRelayTimer > controlled->InitialCtrlDelay) { // wlaczanie WSa z opoznieniem // mark the line breaker as ready to close; for electric series vehicles with impulse switch the setup is completed on button release @@ -194,10 +194,10 @@ void TTrain::updateLineBreakerState(double const Deltatime) } // for diesels and/or vehicles with toggle switch setup we complete the engine start here // TODO: make it a test for main_on_bt of type push_delayed instead - if (m_linebreakerstate == linebreaker::state::closing && (ggMainOnButton.SubModel == nullptr || mvControlled->EngineType != TEngineType::ElectricSeriesMotor)) + if (m_linebreakerstate == linebreaker::state::closing && (ggMainOnButton.SubModel == nullptr || controlled->EngineType != TEngineType::ElectricSeriesMotor)) { // try to finalize state change of the line breaker, set the state based on the outcome - m_linebreakerstate = mvControlled->MainSwitch(true, mvControlled->MainSwitchRange()) ? linebreaker::state::closed : linebreaker::state::open; + m_linebreakerstate = controlled->MainSwitch(true, controlled->MainSwitchRange()) ? linebreaker::state::closed : linebreaker::state::open; } } @@ -215,7 +215,7 @@ void TTrain::updateTimers(double const Deltatime) doorpermittimer -= static_cast(Deltatime); if (doorpermittimer < 0.f) { - mvOccupied->OperateDoors(static_cast(idx), true); + occupied->OperateDoors(static_cast(idx), true); } } @@ -244,18 +244,18 @@ void TTrain::updateDoorAndDirectionStates() { 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_doorspermitleft = mvOccupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right].open_permit && - (simulation::Time.data().wSecond % 2 < 1 || mvOccupied->DoorsPermitLightBlinking < 1 || - mvOccupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right] || - (mvOccupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right])); - m_doorspermitright = mvOccupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left].open_permit && - (simulation::Time.data().wSecond % 2 < 1 || mvOccupied->DoorsPermitLightBlinking < 1 || - mvOccupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->IsAnyDoorOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left] || - (mvOccupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->IsAnyDoorOnlyOpen[cab_to_end() == VehicleEnd::front ? VehicleSide::right : 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])); + 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])); } - m_dirforward = mvControlled->DirActive > 0; - m_dirneutral = mvControlled->DirActive == 0; - m_dirbackward = mvControlled->DirActive < 0; + m_dirforward = controlled->DirActive > 0; + m_dirneutral = controlled->DirActive == 0; + m_dirbackward = controlled->DirActive < 0; } // passes the user commands received by the vehicle to their handlers @@ -276,7 +276,7 @@ void TTrain::processReceivedCommands() // debug data if (commanddata.action == GLFW_PRESS) { - WriteLog(mvOccupied->Name + " received command: [" + simulation::Commands_descriptions[static_cast(commanddata.command)].name + "]"); + WriteLog(occupied->Name + " received command: [" + simulation::Commands_descriptions[static_cast(commanddata.command)].name + "]"); } // pass the command to the assigned handler lookup->second(this, commanddata); @@ -288,7 +288,7 @@ void TTrain::processReceivedCommands() void TTrain::returnMasterController(double const Deltatime) { // nie blokujemy AI - if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag && (mvOccupied->TrainType == train_type::et40 || mvOccupied->TrainType == train_type::ep05 || mvOccupied->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 @@ -304,14 +304,14 @@ void TTrain::returnMasterController(double const Deltatime) if (m_mastercontrollerreturndelay < 0.f) { m_mastercontrollerreturndelay = EU07_CONTROLLER_BASERETURNDELAY; - if (mvOccupied->MainCtrlPos > mvOccupied->MainCtrlActualPos) + if (occupied->MainCtrlPos > occupied->MainCtrlActualPos) { - mvOccupied->DecMainCtrl(1); + occupied->DecMainCtrl(1); } - else if (mvOccupied->MainCtrlPos < mvOccupied->MainCtrlActualPos) + else if (occupied->MainCtrlPos < occupied->MainCtrlActualPos) { // Ra 15-01: a to nie miało być tylko cofanie? - mvOccupied->IncMainCtrl(1); + occupied->IncMainCtrl(1); } } } @@ -324,12 +324,12 @@ void TTrain::updateTachometer(double const Deltatime) // McZapkie: predkosc wyswietlana na tachometrze brana jest z obrotow kol auto const maxtacho{3.0}; - double maxSpeed = mvControlled->Vmax * 1.05; // zachowanie starej logiki jak nie ma definicji max tarczki - if (mvOccupied->maxTachoSpeed != 0) + double maxSpeed = controlled->Vmax * 1.05; // zachowanie starej logiki jak nie ma definicji max tarczki + if (occupied->maxTachoSpeed != 0) { - maxSpeed = mvOccupied->maxTachoSpeed; + maxSpeed = occupied->maxTachoSpeed; } - fTachoVelocity = static_cast(std::min(std::abs(11.31 * mvControlled->WheelDiameter * mvControlled->nrot), maxSpeed)); + fTachoVelocity = static_cast(std::min(std::abs(11.31 * controlled->WheelDiameter * controlled->nrot), maxSpeed)); { // skacze osobna zmienna float ff = simulation::Time.data().wSecond; // skacze co sekunde - pol sekundy // pomiar, pol sekundy ustawienie @@ -359,24 +359,24 @@ void TTrain::updateTachometer(double const Deltatime) void TTrain::updateVoltagesAndCurrents() { // Ra 2014-09: napięcia i prądy muszą być ustalone najpierw, bo wysyłane są ewentualnie na PoKeys - if (mvControlled->EngineType != TEngineType::DieselElectric && mvControlled->EngineType != TEngineType::ElectricInductionMotor) + if (controlled->EngineType != TEngineType::DieselElectric && controlled->EngineType != TEngineType::ElectricInductionMotor) { // Ra 2014-09: czy taki rozdzia? ma sens? - fHVoltage = static_cast(std::max(mvControlled->PantographVoltage, - mvControlled->GetTrainsetHighVoltage())); // Winger czy to nie jest zle? + fHVoltage = static_cast(std::max(controlled->PantographVoltage, + controlled->GetTrainsetHighVoltage())); // Winger czy to nie jest zle? } - // *mvControlled->Mains); + // *controlled->Mains); else { - fHVoltage = static_cast(mvControlled->EngineVoltage); + fHVoltage = static_cast(controlled->EngineVoltage); } if (ShowNextCurrent) { // jeśli pokazywać drugi człon - if (mvSecond) + if (secondUnit) { // o ile jest ten drugi - fHCurrent[0] = static_cast(mvSecond->ShowCurrent(0) * 1.05); - fHCurrent[1] = static_cast(mvSecond->ShowCurrent(1) * 1.05); - fHCurrent[2] = static_cast(mvSecond->ShowCurrent(2) * 1.05); - fHCurrent[3] = static_cast(mvSecond->ShowCurrent(3) * 1.05); + fHCurrent[0] = static_cast(secondUnit->ShowCurrent(0) * 1.05); + fHCurrent[1] = static_cast(secondUnit->ShowCurrent(1) * 1.05); + fHCurrent[2] = static_cast(secondUnit->ShowCurrent(2) * 1.05); + fHCurrent[3] = static_cast(secondUnit->ShowCurrent(3) * 1.05); } else { @@ -388,10 +388,10 @@ void TTrain::updateVoltagesAndCurrents() } else { // normalne pokazywanie - fHCurrent[0] = static_cast(mvControlled->ShowCurrent(0)); - fHCurrent[1] = static_cast(mvControlled->ShowCurrent(1)); - fHCurrent[2] = static_cast(mvControlled->ShowCurrent(2)); - fHCurrent[3] = static_cast(mvControlled->ShowCurrent(3)); + fHCurrent[0] = static_cast(controlled->ShowCurrent(0)); + fHCurrent[1] = static_cast(controlled->ShowCurrent(1)); + fHCurrent[2] = static_cast(controlled->ShowCurrent(2)); + fHCurrent[3] = static_cast(controlled->ShowCurrent(3)); } } @@ -419,8 +419,8 @@ void TTrain::resetUnitStates() // reads the states of the vehicles and the units in multiple, from the cab along the control coupling void TTrain::updateUnitStates() { - bool kier = DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0; - TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); + bool kier = DynamicObject->DirectionGet() * occupied->CabOccupied > 0; + TDynamicObject *p = DynamicObject->GetFirstDynamic(occupied->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); int in = 0; fEIMParams[0][6] = 0; iCarNo = 0; @@ -432,85 +432,85 @@ void TTrain::updateUnitStates() { if (p) { - fPress[i][0] = static_cast(p->MoverParameters->BrakePress); - fPress[i][1] = static_cast(p->MoverParameters->PipePress); - fPress[i][2] = static_cast(p->MoverParameters->ScndPipePress); - fPress[i][3] = static_cast(p->MoverParameters->CntrlPipePress); - fPress[i][4] = static_cast(p->MoverParameters->Hamulec->GetBRP()); - fPress[i][5] = static_cast((p->MoverParameters->TotalMass - p->MoverParameters->Mred) * 0.001); - fPress[i][6] = static_cast(p->MoverParameters->SpringBrake.SBP); - bBrakes[i][0] = p->MoverParameters->SpringBrake.IsActive; - bBrakes[i][1] = p->MoverParameters->SpringBrake.ShuttOff; - bDoors[i][1] = p->MoverParameters->Doors.instances[VehicleSide::left].position > 0.f; - bDoors[i][2] = p->MoverParameters->Doors.instances[VehicleSide::right].position > 0.f; - bDoors[i][3] = p->MoverParameters->Doors.instances[VehicleSide::left].step_position > 0.f; - bDoors[i][4] = p->MoverParameters->Doors.instances[VehicleSide::right].step_position > 0.f; + fPress[i][0] = static_cast(p->physics->BrakePress); + fPress[i][1] = static_cast(p->physics->PipePress); + fPress[i][2] = static_cast(p->physics->ScndPipePress); + fPress[i][3] = static_cast(p->physics->CntrlPipePress); + fPress[i][4] = static_cast(p->physics->Hamulec->GetBRP()); + fPress[i][5] = static_cast((p->physics->TotalMass - p->physics->Mred) * 0.001); + fPress[i][6] = static_cast(p->physics->SpringBrake.SBP); + bBrakes[i][0] = p->physics->SpringBrake.IsActive; + bBrakes[i][1] = p->physics->SpringBrake.ShuttOff; + bDoors[i][1] = p->physics->Doors.instances[VehicleSide::left].position > 0.f; + bDoors[i][2] = p->physics->Doors.instances[VehicleSide::right].position > 0.f; + bDoors[i][3] = p->physics->Doors.instances[VehicleSide::left].step_position > 0.f; + bDoors[i][4] = p->physics->Doors.instances[VehicleSide::right].step_position > 0.f; bDoors[i][0] = bDoors[i][1] || bDoors[i][2]; iDoorNo[i] = p->iAnimType[ANIM_DOORS]; iUnits[i] = iUnitNo; - cCode[i] = p->MoverParameters->TypeName[p->MoverParameters->TypeName.length() - 1]; + cCode[i] = p->physics->TypeName[p->physics->TypeName.length() - 1]; asCarName[i] = p->name(); - if (p->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && iUnitNo <= 8) + if (p->physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && iUnitNo <= 8) { - bPants[iUnitNo - 1][VehicleEnd::front] = bPants[iUnitNo - 1][VehicleEnd::front] || p->MoverParameters->Pantographs[VehicleEnd::front].is_active; - bPants[iUnitNo - 1][VehicleEnd::rear] = bPants[iUnitNo - 1][VehicleEnd::rear] || p->MoverParameters->Pantographs[VehicleEnd::rear].is_active; + bPants[iUnitNo - 1][VehicleEnd::front] = bPants[iUnitNo - 1][VehicleEnd::front] || p->physics->Pantographs[VehicleEnd::front].is_active; + bPants[iUnitNo - 1][VehicleEnd::rear] = bPants[iUnitNo - 1][VehicleEnd::rear] || p->physics->Pantographs[VehicleEnd::rear].is_active; } // TBD, TODO: clean up compressor data arrangement? if (iUnitNo <= 8) { - bComp[iUnitNo - 1][0] = bComp[iUnitNo - 1][0] || p->MoverParameters->CompressorAllow || p->MoverParameters->CompressorStart == start_t::automatic; + bComp[iUnitNo - 1][0] = bComp[iUnitNo - 1][0] || p->physics->CompressorAllow || p->physics->CompressorStart == start_t::automatic; } - if (p->MoverParameters->CompressorSpeed > 0.00001) + if (p->physics->CompressorSpeed > 0.00001) { if (iUnitNo <= 8) { - bComp[iUnitNo - 1][1] = bComp[iUnitNo - 1][1] || p->MoverParameters->CompressorFlag; + bComp[iUnitNo - 1][1] = bComp[iUnitNo - 1][1] || p->physics->CompressorFlag; } - bCompressors.emplace_back(p->MoverParameters->CompressorAllow || p->MoverParameters->CompressorStart == start_t::automatic, p->MoverParameters->CompressorFlag, i); + bCompressors.emplace_back(p->physics->CompressorAllow || p->physics->CompressorStart == start_t::automatic, p->physics->CompressorFlag, i); } - bSlip[i] = p->MoverParameters->SlippingWheels; - if (in < 8 && p->MoverParameters->inductionMotor.traction.maxPower > 1) + bSlip[i] = p->physics->SlippingWheels; + if (in < 8 && p->physics->inductionMotor.traction.maxPower > 1) { - fEIMParams[1 + in][0] = static_cast(p->MoverParameters->inductionMotor.state.maxForce); + fEIMParams[1 + in][0] = static_cast(p->physics->inductionMotor.state.maxForce); fEIMParams[1 + in][1] = std::max(fEIMParams[1 + in][0], 0.f); fEIMParams[1 + in][2] = -std::min(fEIMParams[1 + in][0], 0.f); - fEIMParams[1 + in][3] = static_cast(p->MoverParameters->inductionMotor.state.maxForce / std::max(p->MoverParameters->inductionMotor.state.fullForce, 1.)); + fEIMParams[1 + in][3] = static_cast(p->physics->inductionMotor.state.maxForce / std::max(p->physics->inductionMotor.state.fullForce, 1.)); fEIMParams[1 + in][4] = std::max(fEIMParams[1 + in][3], 0.f); fEIMParams[1 + in][5] = -std::min(fEIMParams[1 + in][3], 0.f); - fEIMParams[1 + in][6] = static_cast(p->MoverParameters->inductionMotor.state.fieldCurrent); - fEIMParams[1 + in][7] = static_cast(p->MoverParameters->inductionMotor.state.voltage); - fEIMParams[1 + in][8] = static_cast(p->MoverParameters->Itot); // p->MoverParameters->inductionMotor.state.lineCurrent; - fEIMParams[1 + in][9] = static_cast(p->MoverParameters->EngineVoltage); + fEIMParams[1 + in][6] = static_cast(p->physics->inductionMotor.state.fieldCurrent); + fEIMParams[1 + in][7] = static_cast(p->physics->inductionMotor.state.voltage); + fEIMParams[1 + in][8] = static_cast(p->physics->Itot); // p->physics->inductionMotor.state.lineCurrent; + fEIMParams[1 + in][9] = static_cast(p->physics->EngineVoltage); fEIMParams[0][6] += fEIMParams[1 + in][8]; - bMains[in] = p->MoverParameters->Mains; - fCntVol[in] = static_cast(p->MoverParameters->BatteryVoltage); - bFuse[in] = p->MoverParameters->FuseFlag; - bBatt[in] = p->MoverParameters->Battery; - bConv[in] = p->MoverParameters->ConverterFlag; - bHeat[in] = p->MoverParameters->Heating; - // bComp[in][2] = (p->MoverParameters->CompressorAllow || (p->MoverParameters->CompressorStart == start_t::automatic)); - // bComp[in][3] = (p->MoverParameters->CompressorFlag); + bMains[in] = p->physics->Mains; + fCntVol[in] = static_cast(p->physics->BatteryVoltage); + bFuse[in] = p->physics->FuseFlag; + bBatt[in] = p->physics->Battery; + bConv[in] = p->physics->ConverterFlag; + bHeat[in] = p->physics->Heating; + // bComp[in][2] = (p->physics->CompressorAllow || (p->physics->CompressorStart == start_t::automatic)); + // bComp[in][3] = (p->physics->CompressorFlag); in++; iPowerNo = in; } - if (in < 8 && (p->MoverParameters->EngineType == TEngineType::DieselEngine || p->MoverParameters->EngineType == TEngineType::DieselElectric)) + if (in < 8 && (p->physics->EngineType == TEngineType::DieselEngine || p->physics->EngineType == TEngineType::DieselElectric)) { - fDieselParams[1 + in][0] = static_cast(p->MoverParameters->enrot * 60); - fDieselParams[1 + in][1] = static_cast(p->MoverParameters->nrot); - fDieselParams[1 + in][2] = static_cast(p->MoverParameters->RList[p->MoverParameters->MainCtrlPos].R); - fDieselParams[1 + in][3] = static_cast(p->MoverParameters->diesel.fill); - fDieselParams[1 + in][4] = static_cast(p->MoverParameters->RList[p->MoverParameters->MainCtrlPos].Mn); - fDieselParams[1 + in][5] = static_cast(p->MoverParameters->diesel.clutchPressure); - fDieselParams[1 + in][6] = p->MoverParameters->diesel.heat.Twy; - fDieselParams[1 + in][7] = p->MoverParameters->OilPump.pressure; - fDieselParams[1 + in][8] = p->MoverParameters->diesel.heat.Ts; - fDieselParams[1 + in][9] = static_cast(p->MoverParameters->retarder.fill); - bMains[in] = p->MoverParameters->Mains; - fCntVol[in] = static_cast(p->MoverParameters->BatteryVoltage); - bFuse[in] = p->MoverParameters->FuseFlag; - bBatt[in] = p->MoverParameters->Battery; - bConv[in] = p->MoverParameters->ConverterFlag; - bHeat[in] = p->MoverParameters->Heating; + fDieselParams[1 + in][0] = static_cast(p->physics->enrot * 60); + fDieselParams[1 + in][1] = static_cast(p->physics->nrot); + fDieselParams[1 + in][2] = static_cast(p->physics->RList[p->physics->MainCtrlPos].R); + fDieselParams[1 + in][3] = static_cast(p->physics->diesel.fill); + fDieselParams[1 + in][4] = static_cast(p->physics->RList[p->physics->MainCtrlPos].Mn); + fDieselParams[1 + in][5] = static_cast(p->physics->diesel.clutchPressure); + fDieselParams[1 + in][6] = p->physics->diesel.heat.Twy; + fDieselParams[1 + in][7] = p->physics->OilPump.pressure; + fDieselParams[1 + in][8] = p->physics->diesel.heat.Ts; + fDieselParams[1 + in][9] = static_cast(p->physics->retarder.fill); + bMains[in] = p->physics->Mains; + fCntVol[in] = static_cast(p->physics->BatteryVoltage); + bFuse[in] = p->physics->FuseFlag; + bBatt[in] = p->physics->Battery; + bConv[in] = p->physics->ConverterFlag; + bHeat[in] = p->physics->Heating; in++; iPowerNo = in; } @@ -548,16 +548,16 @@ void TTrain::updateUnitStates() // sets the induction motor values of the whole train and clears the slots of the units after the first in ones void TTrain::completeUnitStates(int const in) { - // if (mvControlled == mvOccupied) - // fEIMParams[0][3] = mvControlled->inductionMotor.state.forceDemand; // procent zadany + // if (controlled == occupied) + // fEIMParams[0][3] = controlled->inductionMotor.state.forceDemand; // procent zadany // else // fEIMParams[0][3] = - // mvControlled->inductionMotor.state.forceDemand - mvOccupied->LocalBrakeRatio(); // procent zadany - fEIMParams[0][3] = static_cast(mvOccupied->eimic_real); + // controlled->inductionMotor.state.forceDemand - occupied->LocalBrakeRatio(); // procent zadany + fEIMParams[0][3] = static_cast(occupied->eimic_real); fEIMParams[0][4] = std::max(fEIMParams[0][3], 0.f); fEIMParams[0][5] = -std::min(fEIMParams[0][3], 0.f); - fEIMParams[0][1] = static_cast(fEIMParams[0][4] * mvControlled->inductionMotor.state.fullForce); - fEIMParams[0][2] = static_cast(fEIMParams[0][5] * mvControlled->inductionMotor.state.fullForce); + fEIMParams[0][1] = static_cast(fEIMParams[0][4] * controlled->inductionMotor.state.fullForce); + fEIMParams[0][2] = static_cast(fEIMParams[0][5] * controlled->inductionMotor.state.fullForce); fEIMParams[0][0] = fEIMParams[0][1] - fEIMParams[0][2]; fEIMParams[0][7] = 0; fEIMParams[0][8] = 0; @@ -581,17 +581,17 @@ void TTrain::updateFeedbackGauges() const { // wykonywać tylko gdy wyprowadzone na pulpit // Ra: sterowanie miernikiem: zbiornik główny - Console::ValueSet(0, mvOccupied->Compressor); + Console::ValueSet(0, occupied->Compressor); // Ra: sterowanie miernikiem: przewód główny - Console::ValueSet(1, mvOccupied->PipePress); + Console::ValueSet(1, occupied->PipePress); // Ra: sterowanie miernikiem: cylinder hamulcowy - Console::ValueSet(2, mvOccupied->BrakePress); + Console::ValueSet(2, occupied->BrakePress); // woltomierz wysokiego napięcia Console::ValueSet(3, fHVoltage); // Ra: sterowanie miernikiem: drugi amperomierz Console::ValueSet(4, fHCurrent[2]); // pierwszy amperomierz; dla EZT prąd całkowity - Console::ValueSet(5, fHCurrent[mvControlled->TrainType == train_type::emu ? 0 : 1]); + Console::ValueSet(5, fHCurrent[controlled->TrainType == train_type::emu ? 0 : 1]); // Ra: prędkość na pin 43 - wyjście analogowe (to nie jest PWM); skakanie zapewnia mechanika napędu Console::ValueSet(6, fTachoVelocity); } @@ -604,23 +604,23 @@ void TTrain::updateConverterOverload(double const Deltatime) //------------------ // hunter-261211: nadmiarowy przetwornicy i ogrzewania // Ra 15-01: to musi stąd wylecieć - zależności nie mogą być w kabinie - if (mvControlled->ConverterFlag == true) + if (controlled->ConverterFlag == true) { fConverterTimer += static_cast(Deltatime); - if (mvControlled->CompressorFlag == true && mvControlled->CompressorPower == 1 && (mvControlled->EngineType == TEngineType::ElectricSeriesMotor || mvControlled->TrainType == train_type::emu) && + if (controlled->CompressorFlag == true && controlled->CompressorPower == 1 && (controlled->EngineType == TEngineType::ElectricSeriesMotor || controlled->TrainType == train_type::emu) && DynamicObject->Controller == Humandriver // hunter-110212: poprawka dla EZT && DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag) { // hunter-091012: poprawka (zmiana warunku z CompressorPower /rozne od 0/ na /rowne 1/) if (fConverterTimer < fConverterPrzekaznik) { - mvControlled->ConvOvldFlag = true; - if (mvControlled->TrainType != train_type::emu) - mvControlled->MainSwitch(false, mvControlled->TrainType == train_type::emu ? range_t::unit : range_t::local); + controlled->ConvOvldFlag = true; + if (controlled->TrainType != train_type::emu) + controlled->MainSwitch(false, controlled->TrainType == train_type::emu ? range_t::unit : range_t::local); } else if (fConverterTimer >= fConverterPrzekaznik) { // changed switch from always true to take into account state of the compressor switch - mvControlled->CompressorSwitch(mvControlled->CompressorAllow); + controlled->CompressorSwitch(controlled->CompressorAllow); } } } @@ -635,40 +635,40 @@ void TTrain::updateSecondUnitGauges() // youBy - prad w drugim czlonie: galaz lub calosc { TDynamicObject const *tmp{nullptr}; - if (DynamicObject->NextConnected() && mvControlled->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::control) && mvOccupied->CabOccupied == 1) + if (DynamicObject->NextConnected() && controlled->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::control) && occupied->CabOccupied == 1) tmp = DynamicObject->NextConnected(); - if (DynamicObject->PrevConnected() && mvControlled->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::control) && mvOccupied->CabOccupied == -1) + if (DynamicObject->PrevConnected() && controlled->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::control) && occupied->CabOccupied == -1) tmp = DynamicObject->PrevConnected(); - if (tmp && tmp->MoverParameters->Power > 0) + if (tmp && tmp->physics->Power > 0) { if (ggI1B.SubModel) { - ggI1B.UpdateValue(static_cast(tmp->MoverParameters->ShowCurrent(1))); + ggI1B.UpdateValue(static_cast(tmp->physics->ShowCurrent(1))); ggI1B.Update(); } if (ggI2B.SubModel) { - ggI2B.UpdateValue(static_cast(tmp->MoverParameters->ShowCurrent(2))); + ggI2B.UpdateValue(static_cast(tmp->physics->ShowCurrent(2))); ggI2B.Update(); } if (ggI3B.SubModel) { - ggI3B.UpdateValue(static_cast(tmp->MoverParameters->ShowCurrent(3))); + ggI3B.UpdateValue(static_cast(tmp->physics->ShowCurrent(3))); ggI3B.Update(); } if (ggItotalB.SubModel) { - ggItotalB.UpdateValue(static_cast(tmp->MoverParameters->ShowCurrent(0))); + ggItotalB.UpdateValue(static_cast(tmp->physics->ShowCurrent(0))); ggItotalB.Update(); } if (ggWater1TempB.SubModel) { - ggWater1TempB.UpdateValue(tmp->MoverParameters->diesel.heat.temperatura1); + ggWater1TempB.UpdateValue(tmp->physics->diesel.heat.temperatura1); ggWater1TempB.Update(); } if (ggOilPressB.SubModel) { - ggOilPressB.UpdateValue(tmp->MoverParameters->OilPump.pressure); + ggOilPressB.UpdateValue(tmp->physics->OilPump.pressure); ggOilPressB.Update(); } } @@ -696,21 +696,21 @@ void TTrain::updateEngineGauges() // youBy - napiecie na silnikach if (ggEngineVoltage.SubModel) { - if (mvControlled->DynamicBrakeFlag) + if (controlled->DynamicBrakeFlag) { - ggEngineVoltage.UpdateValue(static_cast(std::abs(mvControlled->Im * 5))); + ggEngineVoltage.UpdateValue(static_cast(std::abs(controlled->Im * 5))); } else { int x; - if (mvControlled->TrainType == train_type::et42 && mvControlled->Imax == mvControlled->ImaxHi) + if (controlled->TrainType == train_type::et42 && controlled->Imax == controlled->ImaxHi) x = 1; else x = 2; - if (mvControlled->RList[mvControlled->MainCtrlActualPos].Mn > 0 && std::abs(mvControlled->Im) > 0) + if (controlled->RList[controlled->MainCtrlActualPos].Mn > 0 && std::abs(controlled->Im) > 0) { - ggEngineVoltage.UpdateValue(static_cast(x * (std::abs(mvControlled->EngineVoltage) - mvControlled->RList[mvControlled->MainCtrlActualPos].R * std::abs(mvControlled->Im)) / - mvControlled->RList[mvControlled->MainCtrlActualPos].Mn)); + ggEngineVoltage.UpdateValue(static_cast(x * (std::abs(controlled->EngineVoltage) - controlled->RList[controlled->MainCtrlActualPos].R * std::abs(controlled->Im)) / + controlled->RList[controlled->MainCtrlActualPos].Mn)); } else { @@ -725,32 +725,32 @@ void TTrain::updateEngineGauges() { // NOTE: since we don't have functional converter object, we're faking it here by simple check whether converter is on // TODO: implement object-based circuits and power systems model so we can have this working more properly - ggLVoltage.UpdateValue(static_cast(std::max(mvOccupied->Power110vIsAvailable ? mvOccupied->NominalBatteryVoltage : 0.0, mvOccupied->Power24vIsAvailable ? mvOccupied->BatteryVoltage : 0.0))); + ggLVoltage.UpdateValue(static_cast(std::max(occupied->Power110vIsAvailable ? occupied->NominalBatteryVoltage : 0.0, occupied->Power24vIsAvailable ? occupied->BatteryVoltage : 0.0))); ggLVoltage.Update(); } - if (mvControlled->EngineType == TEngineType::DieselElectric) + if (controlled->EngineType == TEngineType::DieselElectric) { // ustawienie zmiennych dla silnika spalinowego - fEngine[1] = static_cast(mvControlled->ShowEngineRotation(1)); - fEngine[2] = static_cast(mvControlled->ShowEngineRotation(2)); + fEngine[1] = static_cast(controlled->ShowEngineRotation(1)); + fEngine[2] = static_cast(controlled->ShowEngineRotation(2)); } - else if (mvControlled->EngineType == TEngineType::DieselEngine) + else if (controlled->EngineType == TEngineType::DieselEngine) { // albo dla innego spalinowego - fEngine[1] = static_cast(mvControlled->ShowEngineRotation(1)); - fEngine[2] = static_cast(mvControlled->ShowEngineRotation(2)); - fEngine[3] = static_cast(mvControlled->ShowEngineRotation(3)); + fEngine[1] = static_cast(controlled->ShowEngineRotation(1)); + fEngine[2] = static_cast(controlled->ShowEngineRotation(2)); + fEngine[3] = static_cast(controlled->ShowEngineRotation(3)); if (ggMainGearStatus.SubModel) { - if (mvControlled->Mains) - ggMainGearStatus.UpdateValue(static_cast(1.1 - std::abs(mvControlled->diesel.automaticGearShift))); + if (controlled->Mains) + ggMainGearStatus.UpdateValue(static_cast(1.1 - std::abs(controlled->diesel.automaticGearShift))); else ggMainGearStatus.UpdateValue(0.0); ggMainGearStatus.Update(); } if (ggIgnitionKey.SubModel && ggIgnitionKey.GetDesiredValue() == 0.0) { - ggIgnitionKey.UpdateValue(mvControlled->Mains || mvControlled->diesel.startupRequested || fMainRelayTimer > 0.f || + ggIgnitionKey.UpdateValue(controlled->Mains || controlled->diesel.startupRequested || fMainRelayTimer > 0.f || (ggMainButton.SubModel != nullptr && ggMainButton.GetDesiredValue() > 0.95) || (ggMainOnButton.SubModel != nullptr && ggMainOnButton.GetDesiredValue() > 0.95)); } @@ -761,12 +761,12 @@ void TTrain::updateEngineGauges() // sets the lamps of the wheel slip, the compressors, the dynamic brake permit and the active cab void TTrain::updateBasicLamps() { - if (mvControlled->SlippingWheels) + if (controlled->SlippingWheels) { // Ra 2014-12: lokomotywy 181/182 dostają SlippingWheels po zahamowaniu powyżej 2.85 bara i buczały - double veldiff = (DynamicObject->GetVelocity() - fTachoVelocity) / mvControlled->Vmax; + double veldiff = (DynamicObject->GetVelocity() - fTachoVelocity) / controlled->Vmax; // 1% Vmax rezerwy, żeby 181/182 nie buczały po zahamowaniu, ale to proteza - if (veldiff < -0.01 && std::abs(mvControlled->Im) > 10.0) + if (veldiff < -0.01 && std::abs(controlled->Im) > 10.0) { btLampkaPoslizg.Turn(true); } @@ -777,19 +777,19 @@ void TTrain::updateBasicLamps() } // Lampka pracujacej sprezacki - if (mvControlled->CompressorFlag || mvOccupied->CompressorFlag) + if (controlled->CompressorFlag || occupied->CompressorFlag) btCompressors.Turn(true); else btCompressors.Turn(false); // Lampka zezwolenia na hamowanie ED - if (mvControlled->EpFuse) + if (controlled->EpFuse) btEDenabled.Turn(true); else btEDenabled.Turn(false); // Lampka aktywowanej kabiny - if (mvControlled->CabActive != 0) + if (controlled->CabActive != 0) { btCabActived.Turn(true); } @@ -798,7 +798,7 @@ void TTrain::updateBasicLamps() btCabActived.Turn(false); } - if (mvControlled->Battery && mvControlled->CabActive != 0) + if (controlled->Battery && controlled->CabActive != 0) btAKLVents.Turn(true); else btAKLVents.Turn(false); @@ -808,7 +808,7 @@ void TTrain::updateBasicLamps() void TTrain::updateCircuitLamps(double const Deltatime) { // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa - if (mvOccupied->SecuritySystem.is_vigilance_blinking()) + if (occupied->SecuritySystem.is_vigilance_blinking()) { if (fBlinkTimer > fCzuwakBlink) fBlinkTimer = -fCzuwakBlink; @@ -823,59 +823,59 @@ void TTrain::updateCircuitLamps(double const Deltatime) btLampkaCzuwaka.Turn(false); } - btLampkaSHP.Turn(mvOccupied->SecuritySystem.is_cabsignal_blinking()); + btLampkaSHP.Turn(occupied->SecuritySystem.is_cabsignal_blinking()); btLampkaCzuwakaSHP.Turn(btLampkaSHP.GetValue() || btLampkaCzuwaka.GetValue()); - btLampkaWylSzybki.Turn(m_linebreakerstate == linebreaker::state::closing || mvControlled->Mains); - btLampkaWylSzybkiOff.Turn(m_linebreakerstate != linebreaker::state::closing && !mvControlled->Mains); - btLampkaMainBreakerReady.Turn(mvControlled->MainsInitTimeCountdown <= 0.0 && m_linebreakerstate != linebreaker::state::closing && !mvControlled->Mains); - btLampkaMainBreakerBlinkingIfReady.Turn(m_linebreakerstate == linebreaker::state::closing || mvControlled->Mains || mvControlled->MainsInitTimeCountdown < 0.0 && simulation::Time.data().wMilliseconds > 500); + btLampkaWylSzybki.Turn(m_linebreakerstate == linebreaker::state::closing || controlled->Mains); + btLampkaWylSzybkiOff.Turn(m_linebreakerstate != linebreaker::state::closing && !controlled->Mains); + btLampkaMainBreakerReady.Turn(controlled->MainsInitTimeCountdown <= 0.0 && m_linebreakerstate != linebreaker::state::closing && !controlled->Mains); + btLampkaMainBreakerBlinkingIfReady.Turn(m_linebreakerstate == linebreaker::state::closing || controlled->Mains || controlled->MainsInitTimeCountdown < 0.0 && simulation::Time.data().wMilliseconds > 500); - btLampkaPrzetw.Turn(mvOccupied->Power110vIsAvailable); - btLampkaPrzetwOff.Turn(!mvOccupied->Power110vIsAvailable); - btLampkaPrzetwAOff.Turn(!mvControlled->ConverterFlag); - btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : mvControlled->ConvOvldFlag); + btLampkaPrzetw.Turn(occupied->Power110vIsAvailable); + btLampkaPrzetwOff.Turn(!occupied->Power110vIsAvailable); + btLampkaPrzetwAOff.Turn(!controlled->ConverterFlag); + btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : controlled->ConvOvldFlag); - btLampkaOpory.Turn(mvControlled->StLinFlag && mvControlled->ResistorsFlagCheck()); - btLampkaBezoporowa.Turn(mvControlled->ResistorsFlagCheck() || mvControlled->MainCtrlActualPos == 0); // do EU04 - btLampkaStyczn.Turn(mvControlled->LineContactorsLampLit()); // mozna prowadzic rozruch - btLampkaPrzekRozn.Turn(!mvControlled->GroundRelay && mvControlled->MainCircuitLampsEnabled()); // relay is off and needs a reset - btLampkaNadmSil.Turn(mvControlled->FuseFlagCheck() && mvControlled->MainCircuitLampsEnabled()); // relay is off and needs a reset - btLampkaUkrotnienie.Turn(mvControlled->Couplers[mvControlled->CabOccupied == 1 ? VehicleEnd::rear : VehicleEnd::front].CouplingFlag.HasAll(Coupling::control)); - btLampkaHamPosp.Turn(TestFlag(mvOccupied->Hamulec->GetBrakeStatus(), 1)); // lampka drugiego stopnia hamowania + btLampkaOpory.Turn(controlled->StLinFlag && controlled->ResistorsFlagCheck()); + btLampkaBezoporowa.Turn(controlled->ResistorsFlagCheck() || controlled->MainCtrlActualPos == 0); // do EU04 + btLampkaStyczn.Turn(controlled->LineContactorsLampLit()); // mozna prowadzic rozruch + btLampkaPrzekRozn.Turn(!controlled->GroundRelay && controlled->MainCircuitLampsEnabled()); // relay is off and needs a reset + btLampkaNadmSil.Turn(controlled->FuseFlagCheck() && controlled->MainCircuitLampsEnabled()); // relay is off and needs a reset + btLampkaUkrotnienie.Turn(controlled->Couplers[controlled->CabOccupied == 1 ? VehicleEnd::rear : VehicleEnd::front].CouplingFlag.HasAll(Coupling::control)); + btLampkaHamPosp.Turn(TestFlag(occupied->Hamulec->GetBrakeStatus(), 1)); // lampka drugiego stopnia hamowania // TODO: youBy wyciągnąć flagę wysokiego stopnia - btLampkaNadmWent.Turn(mvControlled->RventRot < 5.0 && mvControlled->ResistorsFlagCheck()); // hunter-121211: lampka zanikowo-pradowego wentylatorow - btLampkaWysRozr.Turn(mvControlled->Imax >= mvControlled->ImaxHi); + btLampkaNadmWent.Turn(controlled->RventRot < 5.0 && controlled->ResistorsFlagCheck()); // hunter-121211: lampka zanikowo-pradowego wentylatorow + btLampkaWysRozr.Turn(controlled->Imax >= controlled->ImaxHi); - btLampkaNapNastHam.Turn(mvControlled->DirActive != 0); // napiecie na nastawniku hamulcowym - btLampkaSprezarka.Turn(mvControlled->CompressorFlag); // mutopsitka dziala - btLampkaSprezarkaOff.Turn(!mvControlled->CompressorFlag); - btLampkaFuelPumpOff.Turn(!mvControlled->FuelPump.is_active); - btLampkaOilPump.Turn(mvControlled->OilPump.is_active); // pre-lubrication pump, goes off once the engine is started + btLampkaNapNastHam.Turn(controlled->DirActive != 0); // napiecie na nastawniku hamulcowym + btLampkaSprezarka.Turn(controlled->CompressorFlag); // mutopsitka dziala + btLampkaSprezarkaOff.Turn(!controlled->CompressorFlag); + btLampkaFuelPumpOff.Turn(!controlled->FuelPump.is_active); + btLampkaOilPump.Turn(controlled->OilPump.is_active); // pre-lubrication pump, goes off once the engine is started // boczniki // Ra: w SU45 boczniki wchodzą na ScndCtrlPos, a nie na ScndCtrlActualPos // - pokićkał ktoś? - int scp = mvControlled->RList[mvControlled->MainCtrlPos].ScndAct; + int scp = controlled->RList[controlled->MainCtrlPos].ScndAct; scp = scp == 255 ? 0 : scp; // Ra: whatta hella is this? - btLampkaBoczniki.Turn(!mvControlled->DelayCtrlFlag && mvControlled->ScndCtrlActualPos > 0 || scp > 0); - btLampkaBocznik1.Turn(!mvControlled->DelayCtrlFlag && mvControlled->ScndCtrlPos > 0 || mvControlled->ScndCtrlActualPos > 0 || scp > 0); - btLampkaBocznik2.Turn(!mvControlled->DelayCtrlFlag && mvControlled->ScndCtrlPos > 1 || mvControlled->ScndCtrlActualPos > 1 || scp > 1); - btLampkaBocznik3.Turn(!mvControlled->DelayCtrlFlag && mvControlled->ScndCtrlPos > 2 || mvControlled->ScndCtrlActualPos > 2 || scp > 2); - btLampkaBocznik4.Turn(!mvControlled->DelayCtrlFlag && mvControlled->ScndCtrlPos > 3 || mvControlled->ScndCtrlActualPos > 3 || scp > 3); + btLampkaBoczniki.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlActualPos > 0 || scp > 0); + btLampkaBocznik1.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlPos > 0 || controlled->ScndCtrlActualPos > 0 || scp > 0); + btLampkaBocznik2.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlPos > 1 || controlled->ScndCtrlActualPos > 1 || scp > 1); + btLampkaBocznik3.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlPos > 2 || controlled->ScndCtrlActualPos > 2 || scp > 2); + btLampkaBocznik4.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlPos > 3 || controlled->ScndCtrlActualPos > 3 || scp > 3); // biegi dla motoraka - btLampkaGear1.Turn(mvControlled->ScndCtrlActualPos == 1 && mvControlled->diesel.clutchState > 0); // bieg 1 - btLampkaGear2.Turn(mvControlled->ScndCtrlActualPos == 2 && mvControlled->diesel.clutchState > 0); // bieg 2 - btLampkaHydroLockup.Turn(mvControlled->torqueConverter.lockedUp); // zblokowanie skrzyni z silnikiem + btLampkaGear1.Turn(controlled->ScndCtrlActualPos == 1 && controlled->diesel.clutchState > 0); // bieg 1 + btLampkaGear2.Turn(controlled->ScndCtrlActualPos == 2 && controlled->diesel.clutchState > 0); // bieg 2 + btLampkaHydroLockup.Turn(controlled->torqueConverter.lockedUp); // zblokowanie skrzyni z silnikiem - if (mvControlled->Signalling == true) + if (controlled->Signalling == true) { - if (mvOccupied->BrakePress >= 1.45f) + if (occupied->BrakePress >= 1.45f) { btLampkaHamowanie1zes.Turn(true); } - if (mvControlled->BrakePress < 0.75f) + if (controlled->BrakePress < 0.75f) { btLampkaHamowanie1zes.Turn(false); } @@ -889,38 +889,38 @@ void TTrain::updateCircuitLamps(double const Deltatime) // sets the lamps of the braking, the radio, the doors, the direction, the lights and the overheating, with the low voltage on void TTrain::updateTrainLamps() { - switch (mvControlled->TrainType) + switch (controlled->TrainType) { // zależnie od typu lokomotywy case train_type::emu: { - btLampkaHamienie.Turn(mvControlled->BrakePress >= 0.2 && mvControlled->Signalling); + btLampkaHamienie.Turn(controlled->BrakePress >= 0.2 && controlled->Signalling); break; } case train_type::et41: { // odhamowanie drugiego członu - if (mvSecond) + if (secondUnit) { // bo może komuś przyjść do głowy jeżdżenie jednym członem - btLampkaHamienie.Turn(mvSecond->BrakePress < 0.4); + btLampkaHamienie.Turn(secondUnit->BrakePress < 0.4); } break; } default: { - btLampkaHamienie.Turn(mvOccupied->BrakePress >= 0.1 || mvControlled->DynamicBrakeFlag); - btLampkaBrakingOff.Turn(mvOccupied->BrakePress < 0.1 && !mvControlled->DynamicBrakeFlag); + btLampkaHamienie.Turn(occupied->BrakePress >= 0.1 || controlled->DynamicBrakeFlag); + btLampkaBrakingOff.Turn(occupied->BrakePress < 0.1 && !controlled->DynamicBrakeFlag); break; } } // KURS90 - btLampkaMaxSila.Turn(abs(mvControlled->Im) >= 350); - btLampkaPrzekrMaxSila.Turn(abs(mvControlled->Im) >= 450); - btLampkaRadio.Turn(mvOccupied->Radio && mvOccupied->RadioFuse); + btLampkaMaxSila.Turn(abs(controlled->Im) >= 350); + btLampkaPrzekrMaxSila.Turn(abs(controlled->Im) >= 450); + btLampkaRadio.Turn(occupied->Radio && occupied->RadioFuse); btLampkaRadioMessage.Turn(radio_message_played); - btLampkaRadioStop.Turn(mvOccupied->Radio && mvOccupied->RadioFuse && mvOccupied->RadioStopFlag); - btLampkaHamulecReczny.Turn(mvOccupied->ManualBrakePos > 0); + btLampkaRadioStop.Turn(occupied->Radio && occupied->RadioFuse && occupied->RadioStopFlag); + btLampkaHamulecReczny.Turn(occupied->ManualBrakePos > 0); // NBMX wrzesien 2003 - drzwi oraz sygnał odjazdu if (DynamicObject->Mechanik != nullptr) { @@ -932,20 +932,20 @@ void TTrain::updateTrainLamps() // 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(mvOccupied->door_closure_lamp_lit(DynamicObject->Mechanik->DoorClosure, simulation::Time.data().wSecond % 2 < 1)); + btLampkaBlokadaDrzwi.Turn(occupied->door_closure_lamp_lit(DynamicObject->Mechanik->DoorClosure, simulation::Time.data().wSecond % 2 < 1)); } else { - btLampkaBlokadaDrzwi.Turn(mvOccupied->Doors.is_locked); + btLampkaBlokadaDrzwi.Turn(occupied->Doors.is_locked); } - btLampkaDoorLockOff.Turn(false == mvOccupied->Doors.lock_enabled); - btLampkaDepartureSignal.Turn(mvControlled->DepartureSignal); - btLampkaNapNastHam.Turn(mvControlled->DirActive != 0 && mvOccupied->EpFuse); // napiecie na nastawniku hamulcowym + btLampkaDoorLockOff.Turn(false == occupied->Doors.lock_enabled); + btLampkaDepartureSignal.Turn(controlled->DepartureSignal); + btLampkaNapNastHam.Turn(controlled->DirActive != 0 && occupied->EpFuse); // napiecie na nastawniku hamulcowym // Wylaczanie lampek kierunku gdy jedziemy // Feature uruchamiany z fiz z sekcji Ctrl. wpisem HideDirStatusWhenMoving=Yes (domyslnie No) - if (mvOccupied->HideDirStatusWhenMoving && // Czy ta funkcja jest w ogole wlaczona - mvOccupied->Vel > mvOccupied->HideDirStatusSpeed) // Uzaleznienie od predkosci + if (occupied->HideDirStatusWhenMoving && // Czy ta funkcja jest w ogole wlaczona + occupied->Vel > occupied->HideDirStatusSpeed) // Uzaleznienie od predkosci { btLampkaForward.Turn(false); btLampkaBackward.Turn(false); @@ -953,40 +953,40 @@ void TTrain::updateTrainLamps() } else { - btLampkaForward.Turn(mvControlled->DirActive > 0); // jazda do przodu - btLampkaBackward.Turn(mvControlled->DirActive < 0); // jazda do tyłu - btLampkaNeutral.Turn(mvControlled->DirActive == 0); // kierunek neutral + btLampkaForward.Turn(controlled->DirActive > 0); // jazda do przodu + btLampkaBackward.Turn(controlled->DirActive < 0); // jazda do tyłu + btLampkaNeutral.Turn(controlled->DirActive == 0); // kierunek neutral } - btLampkaED.Turn(mvControlled->DynamicBrakeFlag); // hamulec ED - btLampkaBrakeProfileG.Turn(TestFlag(mvOccupied->BrakeDelayFlag, bdelay_G)); - btLampkaBrakeProfileP.Turn(TestFlag(mvOccupied->BrakeDelayFlag, bdelay_P)); - btLampkaBrakeProfileR.Turn(TestFlag(mvOccupied->BrakeDelayFlag, bdelay_R)); - btLampkaSpringBrakeActive.Turn(mvOccupied->SpringBrake.IsActive); - btLampkaSpringBrakeInactive.Turn(!mvOccupied->SpringBrake.IsActive); + btLampkaED.Turn(controlled->DynamicBrakeFlag); // hamulec ED + btLampkaBrakeProfileG.Turn(TestFlag(occupied->BrakeDelayFlag, bdelay_G)); + btLampkaBrakeProfileP.Turn(TestFlag(occupied->BrakeDelayFlag, bdelay_P)); + btLampkaBrakeProfileR.Turn(TestFlag(occupied->BrakeDelayFlag, bdelay_R)); + btLampkaSpringBrakeActive.Turn(occupied->SpringBrake.IsActive); + btLampkaSpringBrakeInactive.Turn(!occupied->SpringBrake.IsActive); // light indicators // NOTE: sides are hardcoded to deal with setups where single cab is equipped with all indicators - btLampkaUpperLight.Turn((mvOccupied->iLights[VehicleEnd::front] & light::headlight_upper) != 0); - btLampkaLeftLight.Turn((mvOccupied->iLights[VehicleEnd::front] & light::headlight_left) != 0); - btLampkaRightLight.Turn((mvOccupied->iLights[VehicleEnd::front] & light::headlight_right) != 0); - btLampkaLeftEndLight.Turn((mvOccupied->iLights[VehicleEnd::front] & light::redmarker_left) != 0); - btLampkaRightEndLight.Turn((mvOccupied->iLights[VehicleEnd::front] & light::redmarker_right) != 0); - btLampkaRearUpperLight.Turn((mvOccupied->iLights[VehicleEnd::rear] & light::headlight_upper) != 0); - btLampkaRearLeftLight.Turn((mvOccupied->iLights[VehicleEnd::rear] & light::headlight_left) != 0); - btLampkaRearRightLight.Turn((mvOccupied->iLights[VehicleEnd::rear] & light::headlight_right) != 0); - btLampkaRearLeftEndLight.Turn((mvOccupied->iLights[VehicleEnd::rear] & light::redmarker_left) != 0); - btLampkaRearRightEndLight.Turn((mvOccupied->iLights[VehicleEnd::rear] & light::redmarker_right) != 0); + btLampkaUpperLight.Turn((occupied->iLights[VehicleEnd::front] & light::headlight_upper) != 0); + btLampkaLeftLight.Turn((occupied->iLights[VehicleEnd::front] & light::headlight_left) != 0); + btLampkaRightLight.Turn((occupied->iLights[VehicleEnd::front] & light::headlight_right) != 0); + btLampkaLeftEndLight.Turn((occupied->iLights[VehicleEnd::front] & light::redmarker_left) != 0); + btLampkaRightEndLight.Turn((occupied->iLights[VehicleEnd::front] & light::redmarker_right) != 0); + btLampkaRearUpperLight.Turn((occupied->iLights[VehicleEnd::rear] & light::headlight_upper) != 0); + btLampkaRearLeftLight.Turn((occupied->iLights[VehicleEnd::rear] & light::headlight_left) != 0); + btLampkaRearRightLight.Turn((occupied->iLights[VehicleEnd::rear] & light::headlight_right) != 0); + btLampkaRearLeftEndLight.Turn((occupied->iLights[VehicleEnd::rear] & light::redmarker_left) != 0); + btLampkaRearRightEndLight.Turn((occupied->iLights[VehicleEnd::rear] & light::redmarker_right) != 0); // others - btLampkaMalfunction.Turn(mvControlled->diesel.heat.PA); + btLampkaMalfunction.Turn(controlled->diesel.heat.PA); // overheat indicator lamps - btLampkaOilOverheat.Turn(mvControlled->diesel.heat.oil.is_hot); - btLampkaWaterOverheat.Turn(mvControlled->diesel.heat.water.is_hot); - btLampkaWaterAuxOverheat.Turn(mvControlled->diesel.heat.water_aux.is_hot); - btLampkaEngineOverheat.Turn(mvControlled->diesel.heat.engine_is_hot); - btLampkaMotorBlowers.Turn(mvControlled->MotorBlowers[VehicleEnd::front].is_active && mvControlled->MotorBlowers[VehicleEnd::rear].is_active); - btLampkaCoolingFans.Turn(mvControlled->RventRot > 1.0); - btLampkaLouvresClosed.Turn(mvControlled->LouvresClosed()); - btLampkaTempomat.Turn(mvOccupied->SpeedCtrlUnit.IsActive); + btLampkaOilOverheat.Turn(controlled->diesel.heat.oil.is_hot); + btLampkaWaterOverheat.Turn(controlled->diesel.heat.water.is_hot); + btLampkaWaterAuxOverheat.Turn(controlled->diesel.heat.water_aux.is_hot); + btLampkaEngineOverheat.Turn(controlled->diesel.heat.engine_is_hot); + btLampkaMotorBlowers.Turn(controlled->MotorBlowers[VehicleEnd::front].is_active && controlled->MotorBlowers[VehicleEnd::rear].is_active); + btLampkaCoolingFans.Turn(controlled->RventRot > 1.0); + btLampkaLouvresClosed.Turn(controlled->LouvresClosed()); + btLampkaTempomat.Turn(occupied->SpeedCtrlUnit.IsActive); btLampkaDistanceCounter.Turn(m_distancecounter >= 0.f); // universal devices state indicators for (auto idx = 0; idx < btUniversals.size(); ++idx) @@ -1089,11 +1089,11 @@ void TTrain::turnOffLamps() void TTrain::updateSecondUnitLamps(bool const lowvoltagepower) { { // yB - wskazniki drugiego czlonu - TDynamicObject const *tmp{nullptr}; //=mvControlled->mvSecond; //Ra 2014-07: trzeba to jeszcze wyjąć z kabiny... + TDynamicObject const *tmp{nullptr}; //=controlled->secondUnit; //Ra 2014-07: trzeba to jeszcze wyjąć z kabiny... // Ra 2014-07: no nie ma potrzeby szukać tego w każdej klatce - if (mvControlled->Couplers[1].CouplingFlag.HasAll(Coupling::control) && mvOccupied->CabOccupied > 0) + if (controlled->Couplers[1].CouplingFlag.HasAll(Coupling::control) && occupied->CabOccupied > 0) tmp = DynamicObject->NextConnected(); - if (mvControlled->Couplers[0].CouplingFlag.HasAll(Coupling::control) && mvOccupied->CabOccupied < 0) + if (controlled->Couplers[0].CouplingFlag.HasAll(Coupling::control) && occupied->CabOccupied < 0) tmp = DynamicObject->PrevConnected(); if (tmp) @@ -1101,39 +1101,39 @@ void TTrain::updateSecondUnitLamps(bool const lowvoltagepower) if (lowvoltagepower) { - auto const *mover{tmp->MoverParameters}; + auto const *physics{tmp->physics}; - btLampkaWylSzybkiB.Turn(mover->Mains); - btLampkaWylSzybkiBOff.Turn(false == mover->Mains - /*&& ( mover->MainsInitTimeCountdown <= 0.0 )*/ + btLampkaWylSzybkiB.Turn(physics->Mains); + btLampkaWylSzybkiBOff.Turn(false == physics->Mains + /*&& ( physics->MainsInitTimeCountdown <= 0.0 )*/ /*&& ( fHVoltage != 0.0 )*/); - btLampkaOporyB.Turn(mover->ResistorsFlagCheck()); - btLampkaBezoporowaB.Turn(true == mover->ResistorsFlagCheck() || mover->MainCtrlActualPos == 0); // do EU04 + btLampkaOporyB.Turn(physics->ResistorsFlagCheck()); + btLampkaBezoporowaB.Turn(true == physics->ResistorsFlagCheck() || physics->MainCtrlActualPos == 0); // do EU04 - btLampkaStycznB.Turn(mover->LineContactorsLampLit()); // mozna prowadzic rozruch + btLampkaStycznB.Turn(physics->LineContactorsLampLit()); // mozna prowadzic rozruch // hunter-271211: sygnalizacja poslizgu w pierwszym pojezdzie, gdy wystapi w drugim - if (mover->SlippingWheels) + if (physics->SlippingWheels) { // Ra 2014-12: lokomotywy 181/182 dostają SlippingWheels po zahamowaniu powyżej 2.85 bara i buczały - auto const veldiff{(DynamicObject->GetVelocity() - fTachoVelocity) / mvControlled->Vmax}; + auto const veldiff{(DynamicObject->GetVelocity() - fTachoVelocity) / controlled->Vmax}; if (veldiff < -0.01) { // 1% Vmax rezerwy, żeby 181/182 nie buczały po zahamowaniu, ale to proteza - auto const lightstate{std::abs(mover->Im) > 10.0}; + auto const lightstate{std::abs(physics->Im) > 10.0}; btLampkaPoslizg.Turn(btLampkaPoslizg.GetValue() || lightstate); } } - btLampkaSprezarkaB.Turn(mover->CompressorFlag); // mutopsitka dziala - btLampkaSprezarkaBOff.Turn(false == mover->CompressorFlag); - if (mvControlled->Signalling == true) + btLampkaSprezarkaB.Turn(physics->CompressorFlag); // mutopsitka dziala + btLampkaSprezarkaBOff.Turn(false == physics->CompressorFlag); + if (controlled->Signalling == true) { - if (mover->BrakePress >= 1.45f) + if (physics->BrakePress >= 1.45f) { btLampkaHamowanie2zes.Turn(true); } - if (mover->BrakePress < 0.75f) + if (physics->BrakePress < 0.75f) { btLampkaHamowanie2zes.Turn(false); } @@ -1142,15 +1142,15 @@ void TTrain::updateSecondUnitLamps(bool const lowvoltagepower) { btLampkaHamowanie2zes.Turn(false); } - btLampkaNadmPrzetwB.Turn(mover->ConvOvldFlag); // nadmiarowy przetwornicy? - btLampkaPrzetwB.Turn(mover->ConverterFlag); // zalaczenie przetwornicy - btLampkaPrzetwBOff.Turn(false == mover->ConverterFlag); - btLampkaHVoltageB.Turn(mover->NoVoltRelay && mover->OvervoltageRelay); - btLampkaMalfunctionB.Turn(mover->diesel.heat.PA); + btLampkaNadmPrzetwB.Turn(physics->ConvOvldFlag); // nadmiarowy przetwornicy? + btLampkaPrzetwB.Turn(physics->ConverterFlag); // zalaczenie przetwornicy + btLampkaPrzetwBOff.Turn(false == physics->ConverterFlag); + btLampkaHVoltageB.Turn(physics->NoVoltRelay && physics->OvervoltageRelay); + btLampkaMalfunctionB.Turn(physics->diesel.heat.PA); // motor fuse indicator turns on if the fuse was blown in any unit under control - if (mover->Mains) + if (physics->Mains) { - btLampkaNadmSil.Turn(btLampkaNadmSil.GetValue() || mover->FuseFlagCheck()); + btLampkaNadmSil.Turn(btLampkaNadmSil.GetValue() || physics->FuseFlagCheck()); } } else // wylaczone @@ -1181,21 +1181,21 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower) { // joint master controller moves forward to adjust power and backward to adjust brakes auto const brakerangemultiplier{/* NOTE: scaling disabled as it was conflicting with associating sounds with control positions - ( mvControlled->CoupledCtrl ? - mvControlled->MainCtrlPosNo + mvControlled->ScndCtrlPosNo : - mvControlled->MainCtrlPosNo ) + ( controlled->CoupledCtrl ? + controlled->MainCtrlPosNo + controlled->ScndCtrlPosNo : + controlled->MainCtrlPosNo ) / static_cast(LocalBrakePosNo) */ 1}; // when SplitEDPneumaticBrake is active the negative range of the joint controller // represents the dedicated dynamic-brake lever (DBPN steps), not the pneumatic local brake - auto const negativePart{mvControlled->SplitEDPneumaticBrake ? - (mvControlled->DynamicBrakeCtrlPos > 0.0 ? mvControlled->DynamicBrakeCtrlPos * mvControlled->DynamicBrakeCtrlPosNo * -1 * brakerangemultiplier : 0.0) : - mvOccupied->LocalBrakePosA > 0.0 ? mvOccupied->LocalBrakePosA * LocalBrakePosNo * -1 * brakerangemultiplier : + auto const negativePart{controlled->SplitEDPneumaticBrake ? + (controlled->DynamicBrakeCtrlPos > 0.0 ? controlled->DynamicBrakeCtrlPos * controlled->DynamicBrakeCtrlPosNo * -1 * brakerangemultiplier : 0.0) : + occupied->LocalBrakePosA > 0.0 ? occupied->LocalBrakePosA * LocalBrakePosNo * -1 * brakerangemultiplier : 0.0}; ggJointCtrl.UpdateValue(negativePart < 0.0 ? static_cast(negativePart) : - mvControlled->CoupledCtrl ? static_cast(double(mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos)) : - static_cast(double(mvControlled->MainCtrlPos)), + controlled->CoupledCtrl ? static_cast(double(controlled->MainCtrlPos + controlled->ScndCtrlPos)) : + static_cast(double(controlled->MainCtrlPos)), dsbNastawnikJazdy); ggJointCtrl.Update(); } @@ -1207,24 +1207,24 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower) && Global.iFeedbackMode == 4 && Global.fCalibrateIn[2][1] != 0.0) { - set_master_controller(Console::AnalogCalibrateGet(2) * mvOccupied->MainCtrlPosNo); - mvOccupied->eimic_analog = Console::AnalogCalibrateGet(2); + set_master_controller(Console::AnalogCalibrateGet(2) * occupied->MainCtrlPosNo); + occupied->eimic_analog = Console::AnalogCalibrateGet(2); } #endif - if (mvControlled->CoupledCtrl) + if (controlled->CoupledCtrl) { - ggMainCtrl.UpdateValue(static_cast(double(mvControlled->MainCtrlPos + mvControlled->ScndCtrlPos)), dsbNastawnikJazdy); + ggMainCtrl.UpdateValue(static_cast(double(controlled->MainCtrlPos + controlled->ScndCtrlPos)), dsbNastawnikJazdy); } else { - ggMainCtrl.UpdateValue(static_cast(double(mvControlled->MainCtrlPos)), dsbNastawnikJazdy); + ggMainCtrl.UpdateValue(static_cast(double(controlled->MainCtrlPos)), dsbNastawnikJazdy); } ggMainCtrl.Update(); } if (ggMainCtrlAct.SubModel != nullptr) { - ggMainCtrlAct.UpdateValue(main_ctrl_act::position(*mvControlled, ggMainCtrlAct.has_scaletable())); + ggMainCtrlAct.UpdateValue(main_ctrl_act::position(*controlled, ggMainCtrlAct.has_scaletable())); ggMainCtrlAct.Update(); } if (ggScndCtrl.SubModel != nullptr) @@ -1232,7 +1232,7 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower) // Ra: od byte odejmowane boolean i konwertowane potem na double? if (false == ggScndCtrl.is_push()) { - ggScndCtrl.UpdateValue(static_cast(double(mvControlled->ScndCtrlPos - (mvControlled->TrainType == train_type::et42 && mvControlled->DynamicBrakeFlag))), dsbNastawnikBocz); + ggScndCtrl.UpdateValue(static_cast(double(controlled->ScndCtrlPos - (controlled->TrainType == train_type::et42 && controlled->DynamicBrakeFlag))), dsbNastawnikBocz); } ggScndCtrl.Update(); } @@ -1240,7 +1240,7 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower) { if (ggScndCtrlButton.is_toggle()) { - ggScndCtrlButton.UpdateValue(mvControlled->IsSpeedCtrlEngaged() ? 1.f : 0.f, dsbSwitch); + ggScndCtrlButton.UpdateValue(controlled->IsSpeedCtrlEngaged() ? 1.f : 0.f, dsbSwitch); } ggScndCtrlButton.Update(lowvoltagepower); } @@ -1254,13 +1254,13 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower) } if (ggDirKey.SubModel != nullptr) { - if (mvControlled->TrainType != train_type::emu) + if (controlled->TrainType != train_type::emu) { - ggDirKey.UpdateValue(static_cast(double(mvControlled->DirActive)), dsbReverserKey); + ggDirKey.UpdateValue(static_cast(double(controlled->DirActive)), dsbReverserKey); } else { - ggDirKey.UpdateValue(static_cast(double(mvControlled->DirActive) + double(mvControlled->Imin == mvControlled->IminHi)), dsbReverserKey); + ggDirKey.UpdateValue(static_cast(double(controlled->DirActive) + double(controlled->Imin == controlled->IminHi)), dsbReverserKey); } ggDirKey.Update(); } @@ -1276,37 +1276,37 @@ void TTrain::updateBrakeControllers() 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 - if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a) + if (occupied->BrakeHandle == TBrakeHandle::FV4a) { double b = Console::AnalogCalibrateGet(0); b = b * 8.0 - 2.0; - b = safe_clamp(b, -2.0, (double)mvOccupied->BrakeCtrlPosNo); // przycięcie zmiennej do granic + b = safe_clamp(b, -2.0, (double)occupied->BrakeCtrlPosNo); // przycięcie zmiennej do granic ggBrakeCtrl.UpdateValue(b); // przesów bez zaokrąglenia - mvOccupied->BrakeLevelSet(b); + occupied->BrakeLevelSet(b); } - else if (mvOccupied->BrakeHandle == TBrakeHandle::FVel6) // może można usunąć ograniczenie do FV4a i FVel6? + else if (occupied->BrakeHandle == TBrakeHandle::FVel6) // może można usunąć ograniczenie do FV4a i FVel6? { double b = Console::AnalogCalibrateGet(0); b = b * 7.0 - 1.0; - b = safe_clamp(b, -1.0, (double)mvOccupied->BrakeCtrlPosNo); // przycięcie zmiennej do granic + b = safe_clamp(b, -1.0, (double)occupied->BrakeCtrlPosNo); // przycięcie zmiennej do granic ggBrakeCtrl.UpdateValue(b); // przesów bez zaokrąglenia - mvOccupied->BrakeLevelSet(b); + occupied->BrakeLevelSet(b); } else { double b = Console::AnalogCalibrateGet(0); - b = b * (mvOccupied->Handle->GetPos(bh_MAX) - mvOccupied->Handle->GetPos(bh_MIN)) + mvOccupied->Handle->GetPos(bh_MIN); - b = safe_clamp(b, mvOccupied->Handle->GetPos(bh_MIN), mvOccupied->Handle->GetPos(bh_MAX)); // przycięcie zmiennej do granic + b = b * (occupied->Handle->GetPos(bh_MAX) - occupied->Handle->GetPos(bh_MIN)) + occupied->Handle->GetPos(bh_MIN); + b = safe_clamp(b, occupied->Handle->GetPos(bh_MIN), occupied->Handle->GetPos(bh_MAX)); // przycięcie zmiennej do granic ggBrakeCtrl.UpdateValue(b); // przesów bez zaokrąglenia - mvOccupied->BrakeLevelSet(b); + occupied->BrakeLevelSet(b); } } else #endif { // else //standardowa prodedura z kranem powiązanym z klawiaturą - // ggBrakeCtrl.UpdateValue(double(mvOccupied->BrakeCtrlPos)); - ggBrakeCtrl.UpdateValue(static_cast(mvOccupied->fBrakeCtrlPos)); + // ggBrakeCtrl.UpdateValue(double(occupied->BrakeCtrlPos)); + ggBrakeCtrl.UpdateValue(static_cast(occupied->fBrakeCtrlPos)); ggBrakeCtrl.Update(); } } @@ -1315,19 +1315,19 @@ void TTrain::updateBrakeControllers() { #ifdef _WIN32 if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag // nie blokujemy AI - && mvOccupied->BrakeLocHandle == TBrakeHandle::FD1 && Global.iFeedbackMode == 4 && Global.fCalibrateIn[0][1] != 0.0) + && occupied->BrakeLocHandle == TBrakeHandle::FD1 && Global.iFeedbackMode == 4 && Global.fCalibrateIn[0][1] != 0.0) { // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba // Firleju: dlatego kasujemy i zastepujemy funkcją w Console auto const b = std::clamp(Console::AnalogCalibrateGet(1), 0.f, 1.f); - mvOccupied->LocalBrakePosA = b; + occupied->LocalBrakePosA = b; ggLocalBrake.UpdateValue(b * LocalBrakePosNo); } else #endif { // standardowa prodedura z kranem powiązanym z klawiaturą - ggLocalBrake.UpdateValue(static_cast(mvOccupied->LocalBrakePosA * LocalBrakePosNo)); + ggLocalBrake.UpdateValue(static_cast(occupied->LocalBrakePosA * LocalBrakePosNo)); } ggLocalBrake.Update(); } @@ -1345,9 +1345,9 @@ void TTrain::updateCabSwitches(bool const lowvoltagepower) ggBrakeProfileR.Update(); ggBrakeOperationModeCtrl.Update(); ggWiperSw.Update(); - ggMaxCurrentCtrl.UpdateValue(true == mvControlled->ShuntModeAllow ? (true == mvControlled->ShuntMode ? 1.f : 0.f) : mvControlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f); + ggMaxCurrentCtrl.UpdateValue(true == controlled->ShuntModeAllow ? (true == controlled->ShuntMode ? 1.f : 0.f) : controlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f); ggMaxCurrentCtrl.Update(); - ggAutoRelayButton.UpdateValue(mvOccupied->AutoRelayFlag ? 1.f : 0.f); + ggAutoRelayButton.UpdateValue(occupied->AutoRelayFlag ? 1.f : 0.f); ggAutoRelayButton.Update(); // NBMX wrzesien 2003 - drzwi ggDoorLeftPermitButton.Update(lowvoltagepower); @@ -1374,7 +1374,7 @@ void TTrain::updateHeatingAndInstrumentLights() { //--------- // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy - if (mvControlled->Heating == true && mvControlled->ConvOvldFlag == false) + if (controlled->Heating == true && controlled->ConvOvldFlag == false) btLampkaOgrzewanieSkladu.Turn(true); else btLampkaOgrzewanieSkladu.Turn(false); @@ -1382,14 +1382,14 @@ void TTrain::updateHeatingAndInstrumentLights() //---------- // lights - auto const lightpower{(InstrumentLightType == 0 ? mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable : - InstrumentLightType == 1 ? mvControlled->Mains : - InstrumentLightType == 2 ? mvOccupied->Power110vIsAvailable : - InstrumentLightType == 3 ? mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable : - InstrumentLightType == 4 ? mvOccupied->Power24vIsAvailable || mvOccupied->Power110vIsAvailable : + auto const lightpower{(InstrumentLightType == 0 ? occupied->Power24vIsAvailable || occupied->Power110vIsAvailable : + InstrumentLightType == 1 ? controlled->Mains : + InstrumentLightType == 2 ? occupied->Power110vIsAvailable : + InstrumentLightType == 3 ? occupied->Power24vIsAvailable || occupied->Power110vIsAvailable : + InstrumentLightType == 4 ? occupied->Power24vIsAvailable || occupied->Power110vIsAvailable : false)}; InstrumentLightActive = InstrumentLightType == 3 ? true : // TODO: link the light state with the state of the master key - InstrumentLightType == 4 ? mvOccupied->iLights[VehicleEnd::front] != 0 || mvOccupied->iLights[VehicleEnd::rear] != 0 : + InstrumentLightType == 4 ? occupied->iLights[VehicleEnd::front] != 0 || occupied->iLights[VehicleEnd::rear] != 0 : InstrumentLightActive; btInstrumentLight.Turn(InstrumentLightActive && lightpower); btDashboardLight.Turn(DashboardLightActive && lightpower); @@ -1478,14 +1478,14 @@ void TTrain::updateAuxiliaryButtons(bool const lowvoltagepower) //------------ // the converter switches follow the vehicle when something else flips them (the AI driver, the other cab, // the pressure switch of an EMU), not only when the cab is entered (set_cab_controls()) - if (ggConverterButton.SubModel != nullptr && mvOccupied->ConvSwitchType != "impulse" && mvOccupied->ConverterStart == start_t::manual) + if (ggConverterButton.SubModel != nullptr && occupied->ConvSwitchType != "impulse" && occupied->ConverterStart == start_t::manual) { - ggConverterButton.UpdateValue(mvOccupied->ConverterAllow ? 1.f : 0.f, dsbSwitch); + ggConverterButton.UpdateValue(occupied->ConverterAllow ? 1.f : 0.f, dsbSwitch); } ggConverterButton.Update(); if (ggConverterLocalButton.SubModel != nullptr) { - ggConverterLocalButton.UpdateValue(mvOccupied->ConverterAllowLocal ? 1.f : 0.f, dsbSwitch); + ggConverterLocalButton.UpdateValue(occupied->ConverterAllowLocal ? 1.f : 0.f, dsbSwitch); } ggConverterLocalButton.Update(); ggConverterOffButton.Update(); @@ -1543,7 +1543,7 @@ void TTrain::updateAuxiliaryButtons(bool const lowvoltagepower) ggBatteryOffButton.Update(); if (ggCabActivationButton.SubModel != nullptr && ggCabActivationButton.type() != TGaugeType::push) { - ggCabActivationButton.UpdateValue(mvOccupied->IsCabMaster() ? 1.0 : 0.0); + ggCabActivationButton.UpdateValue(occupied->IsCabMaster() ? 1.0 : 0.0); } ggCabActivationButton.Update(); @@ -1574,7 +1574,7 @@ void TTrain::updateCabLightLevels() for (auto &cab : Cabine) { - auto const cablightlevel = (cab.bLight == false ? 0.f : cab.bLightDim == true ? 0.4f : 1.f) * (mvOccupied->Power110vIsAvailable ? 1.f : 0.5f); + auto const cablightlevel = (cab.bLight == false ? 0.f : cab.bLightDim == true ? 0.4f : 1.f) * (occupied->Power110vIsAvailable ? 1.f : 0.5f); if (cab.LightLevel != cablightlevel) { @@ -1593,23 +1593,23 @@ void TTrain::updateCabLightLevels() void TTrain::UpdateDirectionRelays() { - if (mvOccupied->DirActive < 0 && mvOccupied->Power24vIsAvailable) // wstecz + if (occupied->DirActive < 0 && occupied->Power24vIsAvailable) // wstecz Dynamic()->sDirectionRelayR.play(); - if (mvOccupied->DirActive == 0 && mvOccupied->Power24vIsAvailable) // neutral + if (occupied->DirActive == 0 && occupied->Power24vIsAvailable) // neutral Dynamic()->sDirectionRelayN.play(); - if (mvOccupied->DirActive > 0 && mvOccupied->Power24vIsAvailable) // przod + if (occupied->DirActive > 0 && occupied->Power24vIsAvailable) // przod Dynamic()->sDirectionRelayD.play(); } void TTrain::SetupDirectionRelays() { - if (mvOccupied->Power24vIsAvailable) + if (occupied->Power24vIsAvailable) { - if (mvOccupied->DirActive < 0 && mvOccupied->Power24vIsAvailable) // wstecz + if (occupied->DirActive < 0 && occupied->Power24vIsAvailable) // wstecz Dynamic()->sDirectionRelayR.play(); - if (mvOccupied->DirActive > 0 && mvOccupied->Power24vIsAvailable) // przod + if (occupied->DirActive > 0 && occupied->Power24vIsAvailable) // przod Dynamic()->sDirectionRelayD.play(); } - else if (mvOccupied->DirActive != 0) // neutral + else if (occupied->DirActive != 0) // neutral Dynamic()->sDirectionRelayN.play(); } diff --git a/vehicle/crew.cpp b/vehicle/crew.cpp index e375a0c0f..2484ca9f7 100644 --- a/vehicle/crew.cpp +++ b/vehicle/crew.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/crew.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/handover.h" namespace crew { @@ -23,7 +23,7 @@ char lower_ascii(char const Character) { } // the controllers of the vehicle to the positions giving no power, and the vehicles it controls told so -void cut_power(TMoverParameters &Vehicle) { +void cut_power(physics::Vehicle &Vehicle) { Vehicle.MainCtrlPos = Vehicle.MainCtrlNoPowerPos(); Vehicle.ScndCtrlPos = 0; // what the integrated handle and the cruise control asked for last stays in force until somebody drives @@ -110,7 +110,7 @@ std::string_view describe(action const Action) { } } -void secure(TMoverParameters &Occupied, TMoverParameters &Controlling) { +void secure(physics::Vehicle &Occupied, physics::Vehicle &Controlling) { handover::release_ai_controls(Occupied, Controlling); cut_power(Controlling); if (&Occupied != &Controlling) { diff --git a/vehicle/crew.h b/vehicle/crew.h index f2ab938f1..d7c7fb325 100644 --- a/vehicle/crew.h +++ b/vehicle/crew.h @@ -12,7 +12,7 @@ http://mozilla.org/MPL/2.0/. #include #include -class TMoverParameters; +namespace physics { class Vehicle; } // a driver put in a vehicle, or taken off it, while the scenario runs (eu07/maszyna#510): the command of a // putvalues event @@ -76,7 +76,7 @@ std::string_view describe(action Action); // hands over to a user, see handover.h), the power is off, the driver's brake valve is in the emergency position, // so a train on the move stops and stays braked, and the cab is neither active nor occupied. the engine, the // pantographs and the lights stay as they were. Occupied is the vehicle of the driver, Controlling the one whose -// motors it drove (the AI's mvOccupied and mvControlling; the same one in a locomotive) -void secure(TMoverParameters &Occupied, TMoverParameters &Controlling); +// motors it drove (the AI's occupied and mvControlling; the same one in a locomotive) +void secure(physics::Vehicle &Occupied, physics::Vehicle &Controlling); } // namespace crew diff --git a/vehicle/crewchange.cpp b/vehicle/crewchange.cpp index 06d72ab12..e509ea7cf 100644 --- a/vehicle/crewchange.cpp +++ b/vehicle/crewchange.cpp @@ -16,13 +16,13 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "vehicle/Train.h" #include "vehicle/handover.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace crew { namespace { -// TMoverParameters::CategoryFlag of the rail vehicles +// physics::Vehicle::CategoryFlag of the rail vehicles constexpr int rail_category{1}; // more vehicles than a consist has, for a walk along one whose couplers form a loop constexpr int consist_walk_limit{300}; @@ -57,7 +57,7 @@ vehicle_state state_of(TDynamicObject &Vehicle) { vehicle_state state; // a rail vehicle has a cab when it has the driver's brake valve. the others (cars, boats) have no such valve // to tell by, and each of them is driven from its own seat - state.has_cab = Vehicle.MoverParameters->HasDriverCab() || Vehicle.MoverParameters->CategoryFlag != rail_category; + 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; // a cab of the game is bound to the vehicle: the user's own, or another user's in a network game. the cab @@ -70,7 +70,7 @@ vehicle_state state_of(TDynamicObject &Vehicle) { // an AI driver for the vehicle, as the scenery gives one to a vehicle of its own outside a trainset: in charge of // the consist, with no timetable, waiting for orders when the vehicle stands and driving on when it rolls void add_driver(TDynamicObject &Vehicle, int const Cab) { - Vehicle.MoverParameters->CabOccupied = Cab; + Vehicle.physics->CabOccupied = Cab; Vehicle.Controller = AIdriver; Vehicle.create_controller(Cab > 0 ? "1" : "2", false); } @@ -78,12 +78,12 @@ void add_driver(TDynamicObject &Vehicle, int const Cab) { // takes the AI driver off. nothing but the vehicle and the vehicles the driver is in charge of points at a driver // (the panels, the events, the network and the black box read it from a vehicle each time), so these are cleared // and the driver deleted. the vehicles in its charge are looked for among all vehicles, not along the couplers: -// a coupler broken under force or in a collision (TMoverParameters::damage_coupler()) parts the train and leaves +// a coupler broken under force or in a collision (physics::Vehicle::damage_coupler()) parts the train and leaves // the vehicles parted from it in the driver's charge, as uncoupling (TDynamicObject::Dettach()) doesn't void remove_driver(TDynamicObject &Vehicle) { auto *driver{Vehicle.Mechanik}; - auto &occupied{*Vehicle.MoverParameters}; - auto &controlling{*Vehicle.FindPowered()->MoverParameters}; + auto &occupied{*Vehicle.physics}; + auto &controlling{*Vehicle.FindPowered()->physics}; if (driver->primary()) { // the train this driver was in charge of stops and stays braked secure(occupied, controlling); diff --git a/vehicle/derailmotion.h b/vehicle/derailmotion.h index 4e7163ae8..20c89747f 100644 --- a/vehicle/derailmotion.h +++ b/vehicle/derailmotion.h @@ -22,7 +22,7 @@ http://mozilla.org/MPL/2.0/. // a rail vehicle off the rails (physics.derailment new, see physics/derailment.h for when it derails): from then on // it doesn't follow the track any more, it moves on the ground by itself until the friction stops it. // -// along: the longitudinal motion stays with the physics of the vehicle (TMoverParameters), which brakes it with the +// along: the longitudinal motion stays with the physics of the vehicle (physics::Vehicle), which brakes it with the // friction() of this one, takes the grade() under it and passes the forces of the couplings on; each step gives // the distance travelled along the heading of the vehicle // the heading: the way it travels; the one the vehicle had when it derailed, turned out of the curve by the sideways @@ -382,7 +382,7 @@ public: double yaw_rate() const { return m_yawrate; } // how many times the heading was turned about, the body having turned more than a right angle off the way it // goes: the heading stays within a right angle of the front of the body, so the speed along the heading (of - // TMoverParameters, of its couplers at its ends) goes with the body; the speed changes its sign with each + // physics::Vehicle, of its couplers at its ends) goes with the body; the speed changes its sign with each int reversals() const { return m_reversals; } cause reason() const { return m_reason; } // the vehicle the motion was begun with diff --git a/vehicle/doorwings.h b/vehicle/doorwings.h index db05b03fc..4c9304445 100644 --- a/vehicle/doorwings.h +++ b/vehicle/doorwings.h @@ -20,11 +20,11 @@ http://mozilla.org/MPL/2.0/. #include -// the poses of the animated door wings of a vehicle, for the door position of the mover. a wing is posed alike +// the poses of the animated door wings of a vehicle, for the door position of the physics. a wing is posed alike // in the main model and, when the low poly interior has a submodel of the same name, in the interior as well namespace door_wings { -// the kinds of wing animation, numbered as DoorOpenMethod of the .fiz (TMoverParameters::door_data::type) +// the kinds of wing animation, numbered as DoorOpenMethod of the .fiz (physics::Vehicle::door_data::type) inline constexpr int shift_type{1}; inline constexpr int rotate_type{2}; inline constexpr int fold_type{3}; diff --git a/vehicle/drivingaid.cpp b/vehicle/drivingaid.cpp index a7d4f2af2..49f0e8ef9 100644 --- a/vehicle/drivingaid.cpp +++ b/vehicle/drivingaid.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/drivingaid.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "physics/brakes.h" #include @@ -59,7 +59,7 @@ readout compute(input const &Input) { return result; } -input from_movers(TMoverParameters const &Vehicle, TMoverParameters const &Controlling, cab_controls const &Cab) { +input from_vehicles(physics::Vehicle const &Vehicle, physics::Vehicle const &Controlling, cab_controls const &Cab) { input result; result.eim = Vehicle.EngineType == TEngineType::ElectricInductionMotor || Vehicle.EIMCtrlType > 0; result.eimctrltype = Vehicle.EIMCtrlType; diff --git a/vehicle/drivingaid.h b/vehicle/drivingaid.h index 8cec257da..71b44f773 100644 --- a/vehicle/drivingaid.h +++ b/vehicle/drivingaid.h @@ -11,7 +11,7 @@ http://mozilla.org/MPL/2.0/. #include -class TMoverParameters; +namespace physics { class Vehicle; } // what the driving aid panel shows of the controls and of the braking: the numbers of its throttle and // brakes lines, worked out from the vehicle state (eu07/maszyna#558, eu07/maszyna#555) @@ -63,6 +63,6 @@ readout compute(input const &Input); // the state the panel reads: Vehicle is the one the driver sits in, Controlling the one whose controllers // the driver moves (TController::Controlling()) -input from_movers(TMoverParameters const &Vehicle, TMoverParameters const &Controlling, cab_controls const &Cab); +input from_vehicles(physics::Vehicle const &Vehicle, physics::Vehicle const &Controlling, cab_controls const &Cab); } // namespace drivingaid diff --git a/vehicle/dynamic/animations.cpp b/vehicle/dynamic/animations.cpp index f726ee58d..7dfc25bc3 100644 --- a/vehicle/dynamic/animations.cpp +++ b/vehicle/dynamic/animations.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -141,7 +141,7 @@ void TAnimPant::DSAx() common_pantograph_settings(); }; //--------------------------------------------------------------------------- -int TAnim::TypeSet(int i, TMoverParameters currentMover, int fl) +int TAnim::TypeSet(int i, physics::Vehicle currentPhysics, int fl) { // ustawienie typu animacji i zależnej od niego ilości animowanych submodeli fMaxDist = -1.0; // normalnie nie pokazywać switch (i) @@ -170,7 +170,7 @@ int TAnim::TypeSet(int i, TMoverParameters currentMover, int fl) case 5: // 5-pantograf - 5 submodeli iFlags = 0x055; fParamPants = new TAnimPant(); - switch (currentMover.EnginePowerSource.CollectorParameters.PantographType) { + switch (currentPhysics.EnginePowerSource.CollectorParameters.PantographType) { case TPantType::AKP_4E: fParamPants->AKP_4E(); break; @@ -279,7 +279,7 @@ void TDynamicObject::SetPneumatic(bool front, bool red) x = 3; break; // mamy prawy skos, dać prawe skosy case 3: // wszystkie cztery na prosto - if (MoverParameters->Couplers[front ? VehicleEnd::front : VehicleEnd::rear].Render) + if (physics->Couplers[front ? VehicleEnd::front : VehicleEnd::rear].Render) x = 1; else x = 4; @@ -351,9 +351,9 @@ namespace // the position of the door the animated wing belongs to: its shift or angle from closed -float door_position( TMoverParameters const &Mover, TAnim const *Animation ) { +float door_position( physics::Vehicle const &Physics, TAnim const *Animation ) { - return Mover.Doors.instances[ ( + return Physics.Doors.instances[ ( door_wings::on_right_side( Animation->iNumber ) ? VehicleSide::right : VehicleSide::left ) ].position; @@ -388,7 +388,7 @@ void TDynamicObject::UpdateDoorTranslate(TAnim *pAnim) { if( pAnim->smAnimated == nullptr ) { return; } - auto const shift { door_wings::slide( door_position( *MoverParameters, pAnim ) ) }; + auto const shift { door_wings::slide( door_position( *physics, pAnim ) ) }; for( auto *wing : wing_parts( pAnim ) ) { if( wing != nullptr ) { wing->SetTranslate( shift ); @@ -401,7 +401,7 @@ void TDynamicObject::UpdateDoorRotate(TAnim *pAnim) { if( pAnim->smAnimated == nullptr ) { return; } - auto const angle { door_position( *MoverParameters, pAnim ) }; + auto const angle { door_position( *physics, pAnim ) }; for( auto *wing : wing_parts( pAnim ) ) { if( wing != nullptr ) { wing->SetRotate( float3( 1, 0, 0 ), angle ); @@ -414,7 +414,7 @@ void TDynamicObject::UpdateDoorFold(TAnim *pAnim) { if( pAnim->smAnimated == nullptr ) { return; } - auto const angles { door_wings::fold( door_position( *MoverParameters, pAnim ) ) }; + auto const angles { door_wings::fold( door_position( *physics, pAnim ) ) }; for( auto *wing : wing_parts( pAnim ) ) { fold_wing( wing, angles ); } @@ -425,7 +425,7 @@ void TDynamicObject::UpdateDoorPlug(TAnim *pAnim) { if( pAnim->smAnimated == nullptr ) { return; } - auto const shift { door_wings::plug( door_position( *MoverParameters, pAnim ), MoverParameters->Doors.range_out ) }; + auto const shift { door_wings::plug( door_position( *physics, pAnim ), physics->Doors.range_out ) }; for( auto *wing : wing_parts( pAnim ) ) { if( wing != nullptr ) { wing->SetTranslate( shift ); @@ -438,7 +438,7 @@ void TDynamicObject::UpdateDoorWing( TAnim *pAnim, door_wings::wing_spec const & if( pAnim->smAnimated == nullptr ) { return; } - auto const position { door_wings::wing_position( door_position( *MoverParameters, pAnim ), MoverParameters->Doors.range, Spec.range ) }; + auto const position { door_wings::wing_position( door_position( *physics, pAnim ), physics->Doors.range, Spec.range ) }; for( auto *wing : wing_parts( pAnim ) ) { if( wing == nullptr ) { continue; } switch( Spec.type ) { @@ -471,7 +471,7 @@ void TDynamicObject::bind_door_animation( TAnim &Animation ) { Animation.yUpdate = [ this, spec = *spec ]( TAnim *pAnim ) { UpdateDoorWing( pAnim, spec ); }; return; } - switch( MoverParameters->Doors.type ) { // od razu zapinamy potrzebny typ animacji + switch( physics->Doors.type ) { // od razu zapinamy potrzebny typ animacji case 1: Animation.yUpdate = std::bind( &TDynamicObject::UpdateDoorTranslate, this, std::placeholders::_1 ); break; @@ -512,14 +512,14 @@ void TDynamicObject::UpdatePlatformTranslate( TAnim *pAnim ) { if( pAnim->smAnimated == nullptr ) { return; } - auto const &door { MoverParameters->Doors.instances[ ( + auto const &door { physics->Doors.instances[ ( ( pAnim->iNumber & 1 ) == 0 ? VehicleSide::right : VehicleSide::left ) ] }; pAnim->smAnimated->SetTranslate( glm::vec3{ - std::lerp( 0.f, MoverParameters->Doors.step_range, door.step_position ), + std::lerp( 0.f, physics->Doors.step_range, door.step_position ), 0.0, 0.0 } ); } @@ -529,14 +529,14 @@ void TDynamicObject::UpdatePlatformRotate( TAnim *pAnim ) { if( pAnim->smAnimated == nullptr ) { return; } - auto const &door { MoverParameters->Doors.instances[ ( + auto const &door { physics->Doors.instances[ ( ( pAnim->iNumber & 1 ) == 0 ? VehicleSide::right : VehicleSide::left ) ] }; pAnim->smAnimated->SetRotate( float3( 0, 1, 0 ), - std::lerp( 0.f, MoverParameters->Doors.step_range, door.step_position ) ); + std::lerp( 0.f, physics->Doors.step_range, door.step_position ) ); } // mirror animation, rotate @@ -546,18 +546,18 @@ void TDynamicObject::UpdateMirror( TAnim *pAnim ) { // only animate the mirror if it's located on the same end of the vehicle as the active cab auto const isactive { ( - MoverParameters->CabOccupied > 0 ? ( EndOf( pAnim->iNumber >> 4 ) == VehicleEnd::front ? 1.0 : 0.0 ) : - MoverParameters->CabOccupied < 0 ? ( EndOf( pAnim->iNumber >> 4 ) == VehicleEnd::rear ? 1.0 : 0.0 ) : + physics->CabOccupied > 0 ? ( EndOf( pAnim->iNumber >> 4 ) == VehicleEnd::front ? 1.0 : 0.0 ) : + physics->CabOccupied < 0 ? ( EndOf( pAnim->iNumber >> 4 ) == VehicleEnd::rear ? 1.0 : 0.0 ) : 0.0 ) }; if( pAnim->iNumber & 1 ) pAnim->smAnimated->SetRotate( float3( 0, 1, 0 ), - std::lerp( 0.0, MoverParameters->MirrorMaxShift, dMirrorMoveR * isactive ) ); + std::lerp( 0.0, physics->MirrorMaxShift, dMirrorMoveR * isactive ) ); else pAnim->smAnimated->SetRotate( float3( 0, 1, 0 ), - std::lerp( 0.0, MoverParameters->MirrorMaxShift, dMirrorMoveL * isactive ) ); + std::lerp( 0.0, physics->MirrorMaxShift, dMirrorMoveL * isactive ) ); } // wipers @@ -568,7 +568,7 @@ void TDynamicObject::UpdateWiper(TAnim* pAnim) int i = pAnim->iNumber; // odwaramy animacje dla parzystych indexow - const double rotateAngle = (i + 1) % 2 == 0 ? -MoverParameters->WiperAngle : MoverParameters->WiperAngle; + const double rotateAngle = (i + 1) % 2 == 0 ? -physics->WiperAngle : physics->WiperAngle; if (pAnim->smElement[0]) // ramie 1 pAnim->smElement[0]->SetRotate(float3(0, 1, 0), smoothInterpolate(0.0, rotateAngle, dWiperPos[i])); diff --git a/vehicle/dynamic/consist.cpp b/vehicle/dynamic/consist.cpp index 2a53e7d2b..aa417f1c6 100644 --- a/vehicle/dynamic/consist.cpp +++ b/vehicle/dynamic/consist.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -68,7 +68,7 @@ TDynamicObject * TDynamicObject::FirstFind(int &coupler_nr, CouplingSet const cf { if (!temp) return nullptr; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów - if (false == temp->MoverParameters->Couplers[coupler_nr].CouplingFlag.HasAll(cf)) + if (false == temp->physics->Couplers[coupler_nr].CouplingFlag.HasAll(cf)) return temp; // nic nie ma już dalej podłączone sprzęgiem cf if (EndOf(coupler_nr) == VehicleEnd::front) { // jeżeli szukamy od sprzęgu 0 @@ -109,9 +109,9 @@ float TDynamicObject::GetEPP() { if (!temp) break; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów - eq += temp->MoverParameters->PipePress * temp->MoverParameters->Dim.L; - am += temp->MoverParameters->Dim.L; - if ((temp->MoverParameters->Couplers[coupler_nr].CouplingFlag & Coupling::brakeHose) != Coupling::brakeHose) + eq += temp->physics->PipePress * temp->physics->Dim.L; + am += temp->physics->Dim.L; + if ((temp->physics->Couplers[coupler_nr].CouplingFlag & Coupling::brakeHose) != Coupling::brakeHose) break; // nic nie ma już dalej podłączone if (coupler_nr == 0) { // jeżeli szukamy od sprzęgu 0 @@ -143,9 +143,9 @@ float TDynamicObject::GetEPP() { if (!temp) break; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów - eq += temp->MoverParameters->PipePress * temp->MoverParameters->Dim.L; - am += temp->MoverParameters->Dim.L; - if ((temp->MoverParameters->Couplers[coupler_nr].CouplingFlag & Coupling::brakeHose) != Coupling::brakeHose) + eq += temp->physics->PipePress * temp->physics->Dim.L; + am += temp->physics->Dim.L; + if ((temp->physics->Couplers[coupler_nr].CouplingFlag & Coupling::brakeHose) != Coupling::brakeHose) break; // nic nie ma już dalej podłączone if (coupler_nr == 0) { // jeżeli szukamy od sprzęgu 0 @@ -170,8 +170,8 @@ float TDynamicObject::GetEPP() break; // jeśli jednak z tyłu nic nie ma } } - eq -= MoverParameters->PipePress * MoverParameters->Dim.L; - am -= MoverParameters->Dim.L; + eq -= physics->PipePress * physics->Dim.L; + am -= physics->Dim.L; return eq / am; }; @@ -209,13 +209,13 @@ int TDynamicObject::DirectionSet(int d) // wskaźnik na poprzedni, nawet wirtualny TDynamicObject * TDynamicObject::PrevAny() const { - return MoverParameters->Neighbours[ iDirection ^ 1 ].vehicle; + return physics->Neighbours[ iDirection ^ 1 ].vehicle; } TDynamicObject * TDynamicObject::Prev(CouplingSet const couplings) const { - return MoverParameters->Couplers[iDirection ^ 1].CouplingFlag.HasAny(couplings) ? MoverParameters->Neighbours[iDirection ^ 1].vehicle : nullptr;// gdy sprzęg wirtualny, to jakby nic nie było + return physics->Couplers[iDirection ^ 1].CouplingFlag.HasAny(couplings) ? physics->Neighbours[iDirection ^ 1].vehicle : nullptr;// gdy sprzęg wirtualny, to jakby nic nie było } TDynamicObject * TDynamicObject::Next(CouplingSet const couplings) const { - return MoverParameters->Couplers[iDirection].CouplingFlag.HasAny(couplings) ? MoverParameters->Neighbours[iDirection].vehicle : nullptr;// gdy sprzęg wirtualny, to jakby nic nie było + return physics->Couplers[iDirection].CouplingFlag.HasAny(couplings) ? physics->Neighbours[iDirection].vehicle : nullptr;// gdy sprzęg wirtualny, to jakby nic nie było } // checks whether there's unbroken connection of specified type to specified vehicle @@ -253,11 +253,11 @@ TDynamicObject * TDynamicObject::Neighbour(int &dir) { auto *neighbour { ( - MoverParameters->Couplers[ dir ].CouplingFlag != Coupling::none ? - MoverParameters->Neighbours[ dir ].vehicle : + physics->Couplers[ dir ].CouplingFlag != Coupling::none ? + physics->Neighbours[ dir ].vehicle : nullptr ) }; // nowa wartość - dir = 1 - MoverParameters->Neighbours[ dir ].vehicle_end; + dir = 1 - physics->Neighbours[ dir ].vehicle_end; return neighbour; }; @@ -268,22 +268,22 @@ TDynamicObject::update_neighbours() { for (auto const end : VehicleEnds) { - auto &neighbour { MoverParameters->Neighbours[ end ] }; - auto const &coupler { MoverParameters->Couplers[ end ] }; + auto &neighbour { physics->Neighbours[ end ] }; + auto const &coupler { physics->Couplers[ end ] }; if( coupler.Connected != nullptr && neighbour.vehicle != nullptr ) { // physical connection with another vehicle locks down collision source on this end // neighbour.vehicle = coupler.Connected; // neighbour.vehicle_end = coupler.ConnectedNr; - neighbour.distance = TMoverParameters::CouplerDist( MoverParameters, coupler.Connected ); - if( MoverParameters->OffTrack.active() || neighbour.vehicle->MoverParameters->OffTrack.active() ) { + neighbour.distance = physics::Vehicle::CouplerDist( physics, coupler.Connected ); + if( physics->OffTrack.active() || neighbour.vehicle->physics->OffTrack.active() ) { // physics.derailment new: off the track the bodies turn against each other, the ends meet where they are // (the distance between the middles less the half lengths would press the buffers of a bent pair) neighbour.distance = off_track_gap( end ); } // take into account potential adapters attached to the couplers - auto const &othercoupler { neighbour.vehicle->MoverParameters->Couplers[ neighbour.vehicle_end ] }; + auto const &othercoupler { neighbour.vehicle->physics->Couplers[ neighbour.vehicle_end ] }; neighbour.distance -= coupler.adapter_length; neighbour.distance -= othercoupler.adapter_length; } @@ -292,7 +292,7 @@ TDynamicObject::update_neighbours() { // NOTE: we perform a new scan on each update to ensure we always locate the nearest potential source neighbour = neighbour_data(); // 10m ~= 140 km/h at 4 fps + safety margin, potential distance between outer axles of involved vehicles - auto const scanrange { std::max( 10.0, std::abs( MoverParameters->V ) ) + 40.0 }; + auto const scanrange { std::max( 10.0, std::abs( physics->V ) ) + 40.0 }; // physics.derailment new: a vehicle off the track beside the other one doesn't run into it, the scan goes on // past it to the vehicles beyond auto const lookup { find_vehicle( NumberOf( end ), scanrange, true ) }; @@ -304,15 +304,15 @@ TDynamicObject::update_neighbours() { neighbour.distance = std::get( lookup ); if( neighbour.vehicle - && neighbour.distance < (neighbour.vehicle->MoverParameters->CategoryFlag == 2 ? 50 : 100) ) { + && neighbour.distance < (neighbour.vehicle->physics->CategoryFlag == 2 ? 50 : 100) ) { // at short distances (re)calculate range between couplers directly - neighbour.distance = TMoverParameters::CouplerDist( MoverParameters, neighbour.vehicle->MoverParameters ); - if( MoverParameters->OffTrack.active() || neighbour.vehicle->MoverParameters->OffTrack.active() ) { + neighbour.distance = physics::Vehicle::CouplerDist( physics, neighbour.vehicle->physics ); + if( physics->OffTrack.active() || neighbour.vehicle->physics->OffTrack.active() ) { // physics.derailment new: the ends where they are, as for a coupled pair neighbour.distance = off_track_gap( end ); } // take into account potential adapters attached to the couplers - auto const &othercoupler { neighbour.vehicle->MoverParameters->Couplers[ neighbour.vehicle_end ] }; + auto const &othercoupler { neighbour.vehicle->physics->Couplers[ neighbour.vehicle_end ] }; neighbour.distance -= coupler.adapter_length; neighbour.distance -= othercoupler.adapter_length; } @@ -325,7 +325,7 @@ TDynamicObject::in_line_with( TDynamicObject const &Other ) const { // the middle of the other one off the axis of this one, and this one off the axis of the other one, by less than // the half widths of both: their ends can meet - auto const reach { 0.5 * ( MoverParameters->Dim.W + Other.MoverParameters->Dim.W ) }; + auto const reach { 0.5 * ( physics->Dim.W + Other.physics->Dim.W ) }; auto const apart { Other.vPosition - vPosition }; return std::abs( glm::dot( apart, vLeft ) ) < reach && std::abs( glm::dot( apart, Other.vLeft ) ) < reach; } @@ -400,8 +400,8 @@ TDynamicObject::find_vehicle( int const Direction, double const Distance, bool c if( foundobject == nullptr ) { return {}; } /* - auto const *vehicle { MoverParameters }; - auto const *foundvehicle { foundobject->MoverParameters }; + auto const *vehicle { physics }; + auto const *foundvehicle { foundobject->physics }; if( ( false == TestFlag( track->iCategoryFlag, 1 ) ) && ( distance > 50.0 ) ) { // Ra: jeśli dwa samochody się mijają na odcinku przed zawrotką, to odległość między nimi nie może być liczona w linii prostej! @@ -411,7 +411,7 @@ TDynamicObject::find_vehicle( int const Direction, double const Distance, bool c else if( distance < 100.0 ) { // at short distances start to calculate range between couplers directly // odległość do najbliższego pojazdu w linii prostej - distance = TMoverParameters::CouplerDist( vehicle, foundvehicle ); + distance = physics::Vehicle::CouplerDist( vehicle, foundvehicle ); } */ return { foundobject, foundcoupler, distance, true }; @@ -428,7 +428,7 @@ TDynamicObject * TDynamicObject::FindPowered() // problematyczna może być kwestia wybranej kabiny (w silnikowym...) // jeśli silnikowy będzie zapięty odwrotnie (tzn. -1), to i tak powinno jeździć dobrze // również hamowanie wykonuje się zaworem w członie, a nie w silnikowym... - auto const coupling { MoverParameters->is_multiple_unit() ? + auto const coupling { physics->is_multiple_unit() ? Coupling::permanent : Coupling::control }; @@ -436,7 +436,7 @@ TDynamicObject * TDynamicObject::FindPowered() find_vehicle( coupling, []( TDynamicObject * vehicle ) { - return vehicle->MoverParameters->Power > 1.0; } ) }; + return vehicle->physics->Power > 1.0; } ) }; return lookup != nullptr ? lookup : this; // always return valid vehicle for backward compatibility } @@ -452,7 +452,7 @@ TDynamicObject::FindPantographCarrier() { find_vehicle( coupling, []( TDynamicObject * vehicle ) { - return vehicle->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo > 0; } ); + return vehicle->physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && vehicle->physics->EnginePowerSource.CollectorParameters.CollectorsNo > 0; } ); if( result != nullptr ) { return result; } @@ -471,7 +471,7 @@ void TDynamicObject::ParamSet(int what, int into) // dla 8 różnych if (what & 1) // na razie mamy lewe oraz prawe, czyli używamy maskę 1=lewe, // 2=prawe, 3=wszystkie - if( MoverParameters->Doors.instances[VehicleSide::left].is_open ) + if( physics->Doors.instances[VehicleSide::left].is_open ) { // są otwarte if (!into) // jeśli zamykanie { @@ -486,7 +486,7 @@ void TDynamicObject::ParamSet(int what, int into) } } if (what & 2) // prawe działają niezależnie od lewych - if( MoverParameters->Doors.instances[VehicleSide::right].is_open ) + if( physics->Doors.instances[VehicleSide::right].is_open ) { // są otwarte if (!into) // jeśli zamykanie { @@ -512,17 +512,17 @@ int TDynamicObject::RouteWish(TTrack *tr) }; // the vehicles coupled at the ends, and the ends of theirs facing this one -TDynamicObject *TDynamicObject::NextConnected() { return MoverParameters->Neighbours[ VehicleEnd::rear ].vehicle; } -TDynamicObject *TDynamicObject::PrevConnected() { return MoverParameters->Neighbours[ VehicleEnd::front ].vehicle; } -TDynamicObject *TDynamicObject::NextConnected() const { return MoverParameters->Neighbours[ VehicleEnd::rear ].vehicle; } -TDynamicObject *TDynamicObject::PrevConnected() const { return MoverParameters->Neighbours[ VehicleEnd::front ].vehicle; } -int TDynamicObject::NextConnectedNo() const { return MoverParameters->Neighbours[ VehicleEnd::rear ].vehicle_end; } -int TDynamicObject::PrevConnectedNo() const { return MoverParameters->Neighbours[ VehicleEnd::front ].vehicle_end; } +TDynamicObject *TDynamicObject::NextConnected() { return physics->Neighbours[ VehicleEnd::rear ].vehicle; } +TDynamicObject *TDynamicObject::PrevConnected() { return physics->Neighbours[ VehicleEnd::front ].vehicle; } +TDynamicObject *TDynamicObject::NextConnected() const { return physics->Neighbours[ VehicleEnd::rear ].vehicle; } +TDynamicObject *TDynamicObject::PrevConnected() const { return physics->Neighbours[ VehicleEnd::front ].vehicle; } +int TDynamicObject::NextConnectedNo() const { return physics->Neighbours[ VehicleEnd::rear ].vehicle_end; } +int TDynamicObject::PrevConnectedNo() const { return physics->Neighbours[ VehicleEnd::front ].vehicle_end; } -void TDynamicObject::SetdMoveLen( double dMoveLen ) { MoverParameters->dMoveLen = dMoveLen; } -void TDynamicObject::ResetdMoveLen() { MoverParameters->dMoveLen = 0; } -double TDynamicObject::GetdMoveLen() { return MoverParameters->dMoveLen; } +void TDynamicObject::SetdMoveLen( double dMoveLen ) { physics->dMoveLen = dMoveLen; } +void TDynamicObject::ResetdMoveLen() { physics->dMoveLen = 0; } +double TDynamicObject::GetdMoveLen() { return physics->dMoveLen; } -double TDynamicObject::GetVelocity() const { return MoverParameters->Vel; } -double TDynamicObject::GetLength() const { return MoverParameters->Dim.L; } -double TDynamicObject::GetWidth() const { return MoverParameters->Dim.W; } +double TDynamicObject::GetVelocity() const { return physics->Vel; } +double TDynamicObject::GetLength() const { return physics->Dim.L; } +double TDynamicObject::GetWidth() const { return physics->Dim.W; } diff --git a/vehicle/dynamic/couplers.cpp b/vehicle/dynamic/couplers.cpp index 90ab27a1b..911aee242 100644 --- a/vehicle/dynamic/couplers.cpp +++ b/vehicle/dynamic/couplers.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -63,10 +63,10 @@ int TDynamicObject::DettachStatus(int dir) // rzeczywistych od strony (dir): // 0=przód,1=tył // Ra: dziwne, że ta funkcja nie jest używana - if( MoverParameters->Couplers[ dir ].CouplingFlag == Coupling::none ) { + if( physics->Couplers[ dir ].CouplingFlag == Coupling::none ) { return 0; // jeśli nic nie podłączone, to jest OK } - return MoverParameters->DettachStatus(dir); // czy jest w odpowiedniej odległości? + return physics->DettachStatus(dir); // czy jest w odpowiedniej odległości? } int TDynamicObject::Dettach(int dir) @@ -89,11 +89,11 @@ int TDynamicObject::Dettach(int dir) d = d->Next(); // i w drugą stronę } } - if( MoverParameters->Couplers[ dir ].CouplingFlag ) { + if( physics->Couplers[ dir ].CouplingFlag ) { // odczepianie, o ile coś podłączone - MoverParameters->Dettach( dir ); + physics->Dettach( dir ); /* - if( true == MoverParameters->Dettach( dir ) ) { + if( true == physics->Dettach( dir ) ) { auto *othervehicle { dir ? NextConnected : PrevConnected }; auto const othercoupler { dir ? NextConnectedNo() : PrevConnectedNo() }; ( othercoupler ? othervehicle->NextConnected : othervehicle->PrevConnected ) = nullptr; @@ -102,19 +102,19 @@ int TDynamicObject::Dettach(int dir) */ } // sprzęg po rozłączaniu (czego się nie da odpiąć - return MoverParameters->Couplers[dir].CouplingFlag.Bits(); + return physics->Couplers[dir].CouplingFlag.Bits(); } void TDynamicObject::couple( VehicleEnd const Side ) { - auto const &neighbour { MoverParameters->Neighbours[ Side ] }; + auto const &neighbour { physics->Neighbours[ Side ] }; if( neighbour.vehicle == nullptr ) { return; } - auto const &coupler { MoverParameters->Couplers[ Side ] }; + auto const &coupler { physics->Couplers[ Side ] }; auto *othervehicle { neighbour.vehicle }; - auto *othervehicleparams{ othervehicle->MoverParameters }; + auto *othervehicleparams{ othervehicle->physics }; auto const &othercoupler { othervehicleparams->Couplers[ neighbour.vehicle_end ] }; if( coupler.CouplingFlag == Coupling::none ) { @@ -122,7 +122,7 @@ TDynamicObject::couple( VehicleEnd const Side ) { if( ( coupler.AllowedFlag & othercoupler.AllowedFlag & Coupling::coupler ) == Coupling::coupler ) { - if( MoverParameters->Attach( + if( physics->Attach( Side, neighbour.FacingEnd(), othervehicleparams, Coupling::coupler ) ) { @@ -134,12 +134,12 @@ TDynamicObject::couple( VehicleEnd const Side ) { } } } - if( false == MoverParameters->Couplers[ Side ].CouplingFlag.HasAll(Coupling::brakeHose) ) { + if( false == physics->Couplers[ Side ].CouplingFlag.HasAll(Coupling::brakeHose) ) { // pneumatyka if( ( coupler.AllowedFlag & othercoupler.AllowedFlag & Coupling::brakeHose ) == Coupling::brakeHose ) { - if( MoverParameters->Attach( + if( physics->Attach( Side, neighbour.FacingEnd(), othervehicleparams, coupler.CouplingFlag | Coupling::brakeHose ) ) { @@ -150,12 +150,12 @@ TDynamicObject::couple( VehicleEnd const Side ) { } } } - if( false == MoverParameters->Couplers[ Side ].CouplingFlag.HasAll(Coupling::mainHose) ) { + if( false == physics->Couplers[ Side ].CouplingFlag.HasAll(Coupling::mainHose) ) { // zasilajacy if( ( coupler.AllowedFlag & othercoupler.AllowedFlag & Coupling::mainHose ) == Coupling::mainHose ) { - if( MoverParameters->Attach( + if( physics->Attach( Side, neighbour.FacingEnd(), othervehicleparams, coupler.CouplingFlag | Coupling::mainHose ) ) { @@ -166,12 +166,12 @@ TDynamicObject::couple( VehicleEnd const Side ) { } } } - if( false == MoverParameters->Couplers[ Side ].CouplingFlag.HasAll(Coupling::control) ) { + if( false == physics->Couplers[ Side ].CouplingFlag.HasAll(Coupling::control) ) { // ukrotnionko if( (coupler.AllowedFlag & othercoupler.AllowedFlag & Coupling::control) == Coupling::control && coupler.control_type == othercoupler.control_type - && MoverParameters->CompatibleCoupling( Side, *othervehicleparams, neighbour.FacingEnd(), coupler.CouplingFlag | Coupling::control ).HasAny( Coupling::control ) ) { - if( MoverParameters->Attach( + && physics->CompatibleCoupling( Side, *othervehicleparams, neighbour.FacingEnd(), coupler.CouplingFlag | Coupling::control ).HasAny( Coupling::control ) ) { + if( physics->Attach( Side, neighbour.FacingEnd(), othervehicleparams, coupler.CouplingFlag | Coupling::control ) ) { @@ -180,12 +180,12 @@ TDynamicObject::couple( VehicleEnd const Side ) { } } } - if( false == MoverParameters->Couplers[ Side ].CouplingFlag.HasAll(Coupling::gangway) ) { + if( false == physics->Couplers[ Side ].CouplingFlag.HasAll(Coupling::gangway) ) { // mostek if( ( coupler.AllowedFlag & othercoupler.AllowedFlag & Coupling::gangway ) == Coupling::gangway ) { - if( MoverParameters->Attach( + if( physics->Attach( Side, neighbour.FacingEnd(), othervehicleparams, coupler.CouplingFlag | Coupling::gangway ) ) { @@ -194,12 +194,12 @@ TDynamicObject::couple( VehicleEnd const Side ) { } } } - if( false == MoverParameters->Couplers[ Side ].CouplingFlag.HasAll(Coupling::heating) ) { + if( false == physics->Couplers[ Side ].CouplingFlag.HasAll(Coupling::heating) ) { // heating if( ( coupler.AllowedFlag & othercoupler.AllowedFlag & Coupling::heating ) == Coupling::heating ) { - if( MoverParameters->Attach( + if( physics->Attach( Side, neighbour.FacingEnd(), othervehicleparams, coupler.CouplingFlag | Coupling::heating ) ) { @@ -215,9 +215,9 @@ int TDynamicObject::uncouple( VehicleEnd const Side ) { if( DettachStatus( NumberOf( Side ) ) >= 0 - || true == MoverParameters->Couplers[Side].CouplingFlag.HasAll(Coupling::permanent) ) { + || true == physics->Couplers[Side].CouplingFlag.HasAll(Coupling::permanent) ) { // can't uncouple, return existing coupling state - return MoverParameters->Couplers[ Side ].CouplingFlag.Bits(); + return physics->Couplers[ Side ].CouplingFlag.Bits(); } // jeżeli sprzęg niezablokowany, jest co odczepić i się da auto const couplingflag { Dettach( NumberOf( Side ) ) }; @@ -227,12 +227,12 @@ TDynamicObject::uncouple( VehicleEnd const Side ) { bool TDynamicObject::attach_coupler_adapter( VehicleEnd const Side, bool const Enforce ) { - auto &coupler { MoverParameters->Couplers[ Side ] }; + auto &coupler { physics->Couplers[ Side ] }; // sanity check(s) if( coupler.type() == TCouplerType::Automatic ) { return false; } - auto const *neighbour { MoverParameters->Neighbours[ Side ].vehicle }; + auto const *neighbour { physics->Neighbours[ Side ].vehicle }; if( neighbour == nullptr - || MoverParameters->Neighbours[Side].distance > 25.0 ) { + || physics->Neighbours[Side].distance > 25.0 ) { // can only acquire the adapter from a nearby enough vehicle return false; } @@ -245,7 +245,7 @@ TDynamicObject::attach_coupler_adapter( VehicleEnd const Side, bool const Enforc // explicit coupler adapter definition overrides default parameters adapterdata = neighbour->m_coupleradapter; } - if( MoverParameters->Neighbours[Side].distance - adapterdata.position.x < 0.5 + if( physics->Neighbours[Side].distance - adapterdata.position.x < 0.5 && false == Enforce ) { // arbitrary amount of free room required to install the adapter // NOTE: this also covers cases with established physical connection @@ -265,7 +265,7 @@ TDynamicObject::attach_coupler_adapter( VehicleEnd const Side, bool const Enforc bool TDynamicObject::remove_coupler_adapter( VehicleEnd const Side ) { - auto &coupler{ MoverParameters->Couplers[ Side ] }; + auto &coupler{ physics->Couplers[ Side ] }; if( coupler.adapter_type == TCouplerType::NoCoupler ) { return false; } // TODO: sanity check(s) @@ -289,15 +289,15 @@ void TDynamicObject::AttachNext(TDynamicObject *Object, int iType) auto const vehicleend { iDirection }; auto const othervehicleend { Object->iDirection ^ 1 }; - MoverParameters->Attach( vehicleend, othervehicleend, Object->MoverParameters, CouplingSet::FromBits( iType ), true, false ); + physics->Attach( vehicleend, othervehicleend, Object->physics, CouplingSet::FromBits( iType ), true, false ); // update neighbour data for both affected vehicles update_neighbours(); Object->update_neighbours(); // potentially attach automatic coupler adapter to allow the connection // HACK: we're doing it after establishin actual connection, as the method needs valid neighbour data - auto &coupler { MoverParameters->Couplers[ vehicleend ] }; - auto &othercoupler { Object->MoverParameters->Couplers[ ( othervehicleend != 2 ? othervehicleend : coupler.ConnectedNr ) ] }; + auto &coupler { physics->Couplers[ vehicleend ] }; + auto &othercoupler { Object->physics->Couplers[ ( othervehicleend != 2 ? othervehicleend : coupler.ConnectedNr ) ] }; if( coupler.type() != othercoupler.type() ) { if( othercoupler.type() == TCouplerType::Automatic ) { @@ -317,11 +317,11 @@ void TDynamicObject::AttachNext(TDynamicObject *Object, int iType) Object->update_neighbours(); } // potentially adjust vehicle position to avoid collision at the simulation start - if( MoverParameters->Neighbours[ vehicleend ].distance > -0.001 ) { return; } + if( physics->Neighbours[ vehicleend ].distance > -0.001 ) { return; } - Object->Move( MoverParameters->Neighbours[ vehicleend ].distance * Object->DirectionGet() ); + Object->Move( physics->Neighbours[ vehicleend ].distance * Object->DirectionGet() ); // HACK: manually update vehicle position as it's used by neighbour distance update we do next - Object->MoverParameters->Loc = { + Object->physics->Loc = { -Object->vPosition.x, Object->vPosition.z, Object->vPosition.y }; diff --git a/vehicle/dynamic/destinations.cpp b/vehicle/dynamic/destinations.cpp index 0bad55974..e8ca19457 100644 --- a/vehicle/dynamic/destinations.cpp +++ b/vehicle/dynamic/destinations.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -106,7 +106,7 @@ void TDynamicObject::update_destinations() { if( DestinationSign.sign == nullptr ) { return; } - auto const lowvoltagepower { ( MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable ) }; + auto const lowvoltagepower { ( physics->Power24vIsAvailable || physics->Power110vIsAvailable ) }; DestinationSign.sign->fLight = DestinationSign.has_light && lowvoltagepower ? 2.0 : -1.0; @@ -184,8 +184,8 @@ std::string TDynamicObject::destination_request( std::string const &Script, std: if( Mechanik != nullptr ) { return Mechanik->TrainName(); } return "none"; } }; // shouldn't get here but, eh auto const instance { [this, &Instancing]() -> std::string { - if( Instancing == "name" ) { return MoverParameters->Name; } - if( Instancing == "type" ) { return MoverParameters->TypeName; } + if( Instancing == "name" ) { return physics->Name; } + if( Instancing == "type" ) { return physics->TypeName; } return "none"; } }; std::string signrequest { @@ -195,8 +195,8 @@ std::string TDynamicObject::destination_request( std::string const &Script, std: // timetable include + "$timetable=" + ( ctOwner == nullptr ? - MoverParameters->Name : // leading vehicle, can point to it directly - ctOwner->Vehicle()->MoverParameters->Name ) // owned vehicle, safer to point to owner as carriages can have identical names + physics->Name : // leading vehicle, can point to it directly + ctOwner->Vehicle()->physics->Name ) // owned vehicle, safer to point to owner as carriages can have identical names // basic instancing string // NOTE: underscore doesn't have any magic meaning for the time being, it's just less likely to conflict with regular dictionary keys + "&_id1=" + trainname() }; @@ -303,7 +303,7 @@ material_handle TDynamicObject::DestinationFind( std::string Destination ) { Destination = Bezogonkow( Destination ); // do szukania pliku obcinamy ogonki // now see if we can find any version of the texture std::vector const destinations { - Destination + '@' + MoverParameters->TypeName, + Destination + '@' + physics->TypeName, Destination }; for( auto const &destination : destinations ) { diff --git a/vehicle/dynamic/internal.h b/vehicle/dynamic/internal.h index 52ae88dec..27b6e80ae 100644 --- a/vehicle/dynamic/internal.h +++ b/vehicle/dynamic/internal.h @@ -17,7 +17,7 @@ http://mozilla.org/MPL/2.0/. #pragma once #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" diff --git a/vehicle/dynamic/lifecycle.cpp b/vehicle/dynamic/lifecycle.cpp index e63aa4c0e..aee2653d1 100644 --- a/vehicle/dynamic/lifecycle.cpp +++ b/vehicle/dynamic/lifecycle.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -80,7 +80,7 @@ TDynamicObject::TDynamicObject() { vFront = vWorldFront; vLeft = vWorldLeft; iNumAxles = 0; - MoverParameters = nullptr; + physics = nullptr; Mechanik = nullptr; MechInside = false; // McZapkie-270202 @@ -144,7 +144,7 @@ TDynamicObject::TDynamicObject() { TDynamicObject::~TDynamicObject() { SafeDelete( Mechanik ); - SafeDelete( MoverParameters ); + SafeDelete( physics ); SafeDeleteArray( pAnimated ); // lista animowanych submodeli } @@ -155,11 +155,11 @@ void TDynamicObject::place_on_track(TTrack *Track, double fDist, bool Reversed) axle.distance = ( Reversed ? -axle.offset : - axle.offset + MoverParameters->Dim.L ) + fDist; + axle.offset + physics->Dim.L ) + fDist; } double fAxleDistHalf = fAxleDist * 0.5; // przesuwanie pojazdu tak, aby jego początek był we wskazanym miejcu - fDist -= 0.5 * MoverParameters->Dim.L; // dodajemy pół długości pojazdu, bo ustawiamy jego środek (zliczanie na minus) + fDist -= 0.5 * physics->Dim.L; // dodajemy pół długości pojazdu, bo ustawiamy jego środek (zliczanie na minus) switch (iNumAxles) { // Ra: pojazdy wstawiane są na tor początkowy, a potem przesuwane case 2: // ustawianie osi na torze @@ -172,8 +172,8 @@ void TDynamicObject::place_on_track(TTrack *Track, double fDist, bool Reversed) break; } // the stretches the criteria of derailment held over were on the track the vehicle left (consistteleport) - MoverParameters->derailment_monitor.reset(); - MoverParameters->derailment_distance = 0.0; + physics->derailment_monitor.reset(); + physics->derailment_distance = 0.0; // potrzebne do wyliczenia aktualnej pozycji; nie może być zero, bo nie przeliczy pozycji // teraz jeszcze trzeba przypisać pojazdy do nowego toru, bo przesuwanie początkowe osi nie // zrobiło tego @@ -239,11 +239,11 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" } */ // utworzenie parametrów fizyki - MoverParameters = new TMoverParameters(iDirection ? fVel : -fVel, Type_Name, asName, Cab); + 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) - MoverParameters->Odometer = odometer::starting_state( odometer::states(), asName, asBaseDir ); + physics->Odometer = odometer::starting_state( odometer::states(), asName, asBaseDir ); // McZapkie: TypeName musi byc nazwą CHK/MMD pojazdu - if (!MoverParameters->LoadFIZ(asBaseDir)) + if (!physics->LoadFIZ(asBaseDir)) { // jak wczytanie CHK się nie uda, to błąd if (ConversionError == 666) ErrorLog( "Bad vehicle: failed to locate definition file \"" + BaseDir + "/" + Type_Name + ".fiz" + "\"" ); @@ -253,11 +253,11 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" return 0.0; // zerowa długość to brak pojazdu } // load the cargo now that we know whether the vehicle will allow it - MoverParameters->AssignLoad( LoadType, Load ); - MoverParameters->ComputeMass(); + physics->AssignLoad( LoadType, Load ); + physics->ComputeMass(); bool driveractive = fVel != 0.0; // jeśli prędkość niezerowa, to aktywujemy ruch - if (!MoverParameters->CheckLocomotiveParameters( + if (!physics->CheckLocomotiveParameters( driveractive, (fVel > 0 ? 1 : -1) * Cab * (iDirection ? 1 : -1))) // jak jedzie lub obsadzony to gotowy do drogi @@ -266,38 +266,38 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" return 0.0; // zerowa długość to brak pojazdu } // controller position - MoverParameters->MainCtrlPos = MoverParameters->MainCtrlNoPowerPos(); + physics->MainCtrlPos = physics->MainCtrlNoPowerPos(); // ustawienie pozycji hamulca - MoverParameters->LocalBrakePosA = 0.0; + physics->LocalBrakePosA = 0.0; if (driveractive) { if (Cab == 0) - MoverParameters->BrakeCtrlPos = - static_cast( std::floor(MoverParameters->Handle->GetPos(bh_NP)) ); + physics->BrakeCtrlPos = + static_cast( std::floor(physics->Handle->GetPos(bh_NP)) ); else - MoverParameters->BrakeCtrlPos = static_cast( std::floor(MoverParameters->Handle->GetPos(bh_RP)) ); + physics->BrakeCtrlPos = static_cast( std::floor(physics->Handle->GetPos(bh_RP)) ); // engage independent brake if applicable, if the vehicle is to be on standby // NOTE: with more than one driver in the consist this is likely to go awery, since all but one will be sent to sleep // TBD, TODO: have the virtual helper release independent brakes during consist check? if( DriverType != "" ) { - if( MoverParameters->LocalBrake != TLocalBrake::ManualBrake ) { + if( physics->LocalBrake != TLocalBrake::ManualBrake ) { if( fVel < 1.0 ) { - MoverParameters->IncLocalBrakeLevel( LocalBrakePosNo ); - if ( MoverParameters->EIMCtrlEmergency ) { - MoverParameters->DecLocalBrakeLevel(1); + physics->IncLocalBrakeLevel( LocalBrakePosNo ); + if ( physics->EIMCtrlEmergency ) { + physics->DecLocalBrakeLevel(1); } } } } } else - MoverParameters->BrakeCtrlPos = - static_cast( std::floor(MoverParameters->Handle->GetPos(bh_NP)) ); + physics->BrakeCtrlPos = + static_cast( std::floor(physics->Handle->GetPos(bh_NP)) ); // poprawienie hamulca po ewentualnym przestawieniu przez Pascal // TODO: check if needed, we're not in Pascal anymore, Toto - MoverParameters->BrakeLevelSet(MoverParameters->BrakeCtrlPos); + physics->BrakeLevelSet(physics->BrakeCtrlPos); // dodatkowe parametry yB MoreParams += "."; // wykonuje o jedną iterację za mało, więc trzeba mu dodać @@ -316,105 +316,105 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" WriteLog("Wpis hamulca: " + ActPar); if ( contains( ActPar, 'G') ) { - MoverParameters->BrakeDelaySwitch(bdelay_G); + physics->BrakeDelaySwitch(bdelay_G); } if( contains( ActPar, 'P' ) ) { - MoverParameters->BrakeDelaySwitch(bdelay_P); + physics->BrakeDelaySwitch(bdelay_P); } if( contains( ActPar, 'R' ) ) { - MoverParameters->BrakeDelaySwitch(bdelay_R); + physics->BrakeDelaySwitch(bdelay_R); } if( contains( ActPar, 'M' ) ) { - MoverParameters->BrakeDelaySwitch(bdelay_R); - MoverParameters->BrakeDelaySwitch(bdelay_R + bdelay_M); + physics->BrakeDelaySwitch(bdelay_R); + physics->BrakeDelaySwitch(bdelay_R + bdelay_M); } // wylaczanie hamulca if ( contains( ActPar, "<>") ) // wylaczanie na probe hamowania naglego { - MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz + physics->Hamulec->SetBrakeStatus( physics->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz } if ( contains( ActPar, '0' ) ) // wylaczanie na sztywno { - MoverParameters->Hamulec->ForceEmptiness(); - MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz + physics->Hamulec->ForceEmptiness(); + physics->Hamulec->SetBrakeStatus( physics->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz } if ( contains( ActPar, 'E' ) ) // oprozniony { - MoverParameters->Hamulec->ForceEmptiness(); - MoverParameters->Pipe->CreatePress(0); - MoverParameters->Pipe2->CreatePress(0); + physics->Hamulec->ForceEmptiness(); + physics->Pipe->CreatePress(0); + physics->Pipe2->CreatePress(0); } if ( contains( ActPar, 'Q' ) ) // oprozniony { - MoverParameters->Hamulec->ForceEmptiness(); - MoverParameters->Pipe->CreatePress(0.0); - MoverParameters->PipePress = 0.0; - MoverParameters->Pipe2->CreatePress(0.0); - MoverParameters->ScndPipePress = 0.0; - MoverParameters->PantVolume = 0.1; - MoverParameters->PantPress = 0.0; - MoverParameters->CompressedVolume = 0.0; + physics->Hamulec->ForceEmptiness(); + physics->Pipe->CreatePress(0.0); + physics->PipePress = 0.0; + physics->Pipe2->CreatePress(0.0); + physics->ScndPipePress = 0.0; + physics->PantVolume = 0.1; + physics->PantPress = 0.0; + physics->CompressedVolume = 0.0; } if ( contains( ActPar, '1' ) ) // wylaczanie 10% { if (Random(10) < 1) // losowanie 1/10 { - MoverParameters->Hamulec->ForceEmptiness(); - MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz + physics->Hamulec->ForceEmptiness(); + physics->Hamulec->SetBrakeStatus( physics->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz } } if ( contains( ActPar, 'X') ) // agonalny wylaczanie 20%, usrednienie przekladni { if (Random(100) < 20) // losowanie 20/100 { - MoverParameters->Hamulec->ForceEmptiness(); - MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz + physics->Hamulec->ForceEmptiness(); + physics->Hamulec->SetBrakeStatus( physics->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz } - if (MoverParameters->BrakeCylMult[2] * MoverParameters->BrakeCylMult[1] > + if (physics->BrakeCylMult[2] * physics->BrakeCylMult[1] > 0.01) // jesli jest nastawiacz mechaniczny PL { float rnd = Random(100); if (rnd < 20) // losowanie 20/100 usrednienie { - MoverParameters->BrakeCylMult[2] = MoverParameters->BrakeCylMult[1] = - (MoverParameters->BrakeCylMult[2] + MoverParameters->BrakeCylMult[1]) / + physics->BrakeCylMult[2] = physics->BrakeCylMult[1] = + (physics->BrakeCylMult[2] + physics->BrakeCylMult[1]) / 2; } else if (rnd < 70) // losowanie 70/100-20/100 oslabienie { - MoverParameters->BrakeCylMult[1] = MoverParameters->BrakeCylMult[1] * 0.50; - MoverParameters->BrakeCylMult[2] = MoverParameters->BrakeCylMult[2] * 0.75; + physics->BrakeCylMult[1] = physics->BrakeCylMult[1] * 0.50; + physics->BrakeCylMult[2] = physics->BrakeCylMult[2] * 0.75; } else if (rnd < 80) // losowanie 80/100-70/100 tylko prozny { - MoverParameters->BrakeCylMult[2] = MoverParameters->BrakeCylMult[1]; + physics->BrakeCylMult[2] = physics->BrakeCylMult[1]; } else // tylko ladowny { - MoverParameters->BrakeCylMult[1] = MoverParameters->BrakeCylMult[2]; + physics->BrakeCylMult[1] = physics->BrakeCylMult[2]; } } } // nastawianie ladunku if ( contains( ActPar, 'T' ) ) // prozny { - MoverParameters->DecBrakeMult(); - MoverParameters->DecBrakeMult(); + physics->DecBrakeMult(); + physics->DecBrakeMult(); } // dwa razy w dol if ( contains( ActPar, 'H' ) ) // ladowny I (dla P-Ł dalej prozny) { - MoverParameters->IncBrakeMult(); - MoverParameters->IncBrakeMult(); - MoverParameters->DecBrakeMult(); + physics->IncBrakeMult(); + physics->IncBrakeMult(); + physics->DecBrakeMult(); } // dwa razy w gore i obniz if ( contains( ActPar, 'F' ) ) // ladowny II { - MoverParameters->IncBrakeMult(); - MoverParameters->IncBrakeMult(); + physics->IncBrakeMult(); + physics->IncBrakeMult(); } // dwa razy w gore if ( contains( ActPar, 'N' ) ) // parametr neutralny { @@ -461,7 +461,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" auto const indexstart { 1 }; auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) }; auto const huntingchance { std::atoi( ActPar.substr( indexstart, indexend ).c_str() ) }; - MoverParameters->TruckHunting = Random(0, 100) < huntingchance; + physics->TruckHunting = Random(0, 100) < huntingchance; ActPar.erase( 0, indexend ); break; } @@ -473,7 +473,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" } } if( Random( 0, 100 ) <= flatchance ) { - MoverParameters->WheelFlat += fixedflatsize + Random( 0, randomflatsize ); + physics->WheelFlat += fixedflatsize + Random( 0, randomflatsize ); } } // wheel else if( ActPar.size() >= 2 @@ -500,7 +500,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" } if( true == setambient ) { // TODO: pull ambient temperature from environment data - MoverParameters->dizel_HeatSet( Global.AirTemperature ); + physics->dizel_HeatSet( Global.AirTemperature ); } } // temperature else if( ActPar.size() >= 2 @@ -512,7 +512,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" { auto const indexstart { 0 }; auto const indexend { ActPar.find_first_not_of( "1234567890", indexstart ) }; - MoverParameters->MaxLoad = std::atoi( ActPar.substr( indexstart, indexend ).c_str() ); + physics->MaxLoad = std::atoi( ActPar.substr( indexstart, indexend ).c_str() ); ActPar.erase( 0, indexend ); } while( false == ActPar.empty() ) { @@ -534,32 +534,32 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" if( hauled ) { // once the vehicle has its starting state: the hand brake and the spring brake of a standing one let go, battery off - MoverParameters->PulleeModeSwitch( true ); + physics->PulleeModeSwitch( true ); } - if (MoverParameters->CategoryFlag & 2) // jeśli samochód + if (physics->CategoryFlag & 2) // jeśli samochód { // ustawianie samochodow na poboczu albo na środku drogi if( Track->fTrackWidth < 3.5 // jeśli droga wąska || Track->m_road != nullptr ) // a lane of a road node is one-way, the vehicle keeps to its middle - MoverParameters->OffsetTrackH = 0.0; // to stawiamy na środku, niezależnie od stanu + physics->OffsetTrackH = 0.0; // to stawiamy na środku, niezależnie od stanu // ruchu else if( driveractive ) {// od 3.5m do 8.0m jedzie po środku pasa, dla // szerszych w odległości // 1.5m - auto const lanefreespace = 0.5 * Track->fTrackWidth - MoverParameters->Dim.W; - MoverParameters->OffsetTrackH = lanefreespace > 1.5 ? - -0.5 * MoverParameters->Dim.W - 0.75 : // wide road, keep near centre with safe margin + auto const lanefreespace = 0.5 * Track->fTrackWidth - physics->Dim.W; + physics->OffsetTrackH = lanefreespace > 1.5 ? + -0.5 * physics->Dim.W - 0.75 : // wide road, keep near centre with safe margin lanefreespace > 0.1 ? -0.25 * Track->fTrackWidth : // narrow fit, stay on the middle - -0.5 * MoverParameters->Dim.W - 0.075; // too narrow, just keep some minimal clearance + -0.5 * physics->Dim.W - 0.075; // too narrow, just keep some minimal clearance } else // jak stoi, to kołem na poboczu i pobieramy szerokość razem z // poboczem, ale nie z // chodnikiem - MoverParameters->OffsetTrackH = - -0.5 * (Track->WidthTotal() - MoverParameters->Dim.W) + 0.05; + physics->OffsetTrackH = + -0.5 * (Track->WidthTotal() - physics->Dim.W) + 0.05; iHornWarning = 0; // nie będzie trąbienia po podaniu zezwolenia na jazdę - if (fDist < 0.0) //-0.5*MoverParameters->Dim.L) //jeśli jest przesunięcie do tyłu + if (fDist < 0.0) //-0.5*physics->Dim.L) //jeśli jest przesunięcie do tyłu if (!Track->CurrentPrev()) // a nie ma tam odcinka i trzeba by coś // wygenerować fDist = -fDist; // to traktujemy, jakby przesunięcie było w drugą stronę @@ -574,7 +574,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // McZapkie-250202 /* - iAxles = std::min( MoverParameters->NAxles, MaxAxles ); // ilość osi + iAxles = std::min( physics->NAxles, MaxAxles ); // ilość osi */ // wczytywanie z pliku nazwatypu.mmd, w tym model erase_extension( asReplacableSkin ); @@ -653,10 +653,10 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" btMechanik1.Init( "mechanik1", mdLowPolyInt, false); btMechanik2.Init( "mechanik2", mdLowPolyInt, false); - if( MoverParameters->diesel.heat.water.config.shutters ) { + if( physics->diesel.heat.water.config.shutters ) { btShutters1.Init( "shutters1", mdModel, false ); } - if( MoverParameters->diesel.heat.water_aux.config.shutters ) { + if( physics->diesel.heat.water_aux.config.shutters ) { btShutters2.Init( "shutters2", mdModel, false ); } TurnOff(); // resetowanie zmiennych submodeli @@ -680,7 +680,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // passenger car compartments std::vector nameprefixes = { "corridor", "korytarz", "compartment", "przedzial" }; for( auto const &nameprefix : nameprefixes ) { - init_sections( mdLowPolyInt, nameprefix, MoverParameters->CompartmentLights.start_type == start_t::manual ); + init_sections( mdLowPolyInt, nameprefix, physics->CompartmentLights.start_type == start_t::manual ); } // the inside of the door wings, if the interior has them init_interior_doors(); @@ -717,7 +717,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" ( Reversed ? -axle.offset : axle.offset ) - - 0.5 * MoverParameters->Dim.L + - 0.5 * physics->Dim.L + fDist, Track->fSoundDistance ); } @@ -725,17 +725,17 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // McZapkie-250202 end. Track->AddDynamicObject(this); // wstawiamy do toru na pozycję 0, a potem przesuniemy // McZapkie: zmieniono na ilosc osi brane z chk - // iNumAxles=(MoverParameters->NAxles>3 ? 4 : 2 ); + // iNumAxles=(physics->NAxles>3 ? 4 : 2 ); initial_track = MyTrack; iNumAxles = 2; // McZapkie-090402: odleglosc miedzy czopami skretu lub osiami fAxleDist = safe_clamp( - std::max( MoverParameters->BDist, MoverParameters->ADist ), + std::max( physics->BDist, physics->ADist ), 0.2, //żeby się dało wektory policzyć - MoverParameters->Dim.L - 0.2 ); // nie mogą być za daleko bo będzie "walenie w mur" + physics->Dim.L - 0.2 ); // nie mogą być za daleko bo będzie "walenie w mur" double fAxleDistHalf = fAxleDist * 0.5; // przesuwanie pojazdu tak, aby jego początek był we wskazanym miejcu - fDist -= 0.5 * MoverParameters->Dim.L; // dodajemy pół długości pojazdu, bo ustawiamy jego środek (zliczanie na minus) + fDist -= 0.5 * physics->Dim.L; // dodajemy pół długości pojazdu, bo ustawiamy jego środek (zliczanie na minus) switch (iNumAxles) { // Ra: pojazdy wstawiane są na tor początkowy, a potem przesuwane case 2: // ustawianie osi na torze @@ -746,13 +746,13 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" break; case 4: Axle0.Init(Track, this, iDirection ? 1 : -1); - Axle0.Move((iDirection ? fDist : -fDist) + (fAxleDistHalf + MoverParameters->ADist * 0.5), false); + Axle0.Move((iDirection ? fDist : -fDist) + (fAxleDistHalf + physics->ADist * 0.5), false); Axle1.Init(Track, this, iDirection ? 1 : -1); - Axle1.Move((iDirection ? fDist : -fDist) - (fAxleDistHalf + MoverParameters->ADist * 0.5), false); + Axle1.Move((iDirection ? fDist : -fDist) - (fAxleDistHalf + physics->ADist * 0.5), false); // Axle2.Init(Track,this,iDirection?1:-1); - // Axle2.Move((iDirection?fDist:-fDist)-(fAxleDistHalf-MoverParameters->ADist*0.5),false); + // Axle2.Move((iDirection?fDist:-fDist)-(fAxleDistHalf-physics->ADist*0.5),false); // Axle3.Init(Track,this,iDirection?1:-1); - // Axle3.Move((iDirection?fDist:-fDist)+(fAxleDistHalf-MoverParameters->ADist*0.5),false); + // Axle3.Move((iDirection?fDist:-fDist)+(fAxleDistHalf-physics->ADist*0.5),false); break; } // potrzebne do wyliczenia aktualnej pozycji; nie może być zero, bo nie przeliczy pozycji @@ -761,7 +761,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" Move( 0.0001 ); ABuCheckMyTrack(); // zmiana toru na ten, co oś Axle0 (oś z przodu) // Ra: ustawienie pozycji do obliczania sprzęgów - MoverParameters->Loc = { + physics->Loc = { -vPosition.x, vPosition.z, vPosition.y }; // normalnie przesuwa ComputeMovement() w Update() @@ -785,12 +785,12 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" } // ABu: zainicjowanie zmiennej, zeby nic sie nie ruszylo w pierwszej klatce, // potem juz liczona prawidlowa wartosc masy - MoverParameters->ComputeConstans(); + physics->ComputeConstans(); // wektor podłogi dla wagonów, przesuwa ładunek - vFloor = glm::dvec3(0, 0, MoverParameters->Floor); + vFloor = glm::dvec3(0, 0, physics->Floor); // długość większa od zera oznacza OK; 2mm docisku? - return MoverParameters->Dim.L; + return physics->Dim.L; } int @@ -876,7 +876,7 @@ TDynamicObject::create_controller( std::string const Type, bool const Trainset ) // tryb pociągowy z ustaloną prędkością (względem sprzęgów) Mechanik->PutCommand( "Timetable:", - MoverParameters->V * 3.6 * ( iDirection ? -1.0 : 1.0 ), + physics->V * 3.6 * ( iDirection ? -1.0 : 1.0 ), 0, nullptr ); } diff --git a/vehicle/dynamic/lights.cpp b/vehicle/dynamic/lights.cpp index 0da7ae5b7..11ea04fc8 100644 --- a/vehicle/dynamic/lights.cpp +++ b/vehicle/dynamic/lights.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -59,22 +59,22 @@ http://mozilla.org/MPL/2.0/. void TDynamicObject::SetLights() { - auto const isfrontcaboccupied { MoverParameters->CabOccupied * DirectionGet() >= 0 }; - int const automaticmarkers { MoverParameters->CabActive == 0 && MoverParameters->InactiveCabFlag & activation::redmarkers + auto const isfrontcaboccupied { physics->CabOccupied * DirectionGet() >= 0 }; + int const automaticmarkers { physics->CabActive == 0 && physics->InactiveCabFlag & activation::redmarkers ? light::redmarker_left + light::redmarker_right : 0 }; - auto const lightpos { MoverParameters->LightsPos - 1 }; + auto const lightpos { physics->LightsPos - 1 }; ByEnd const cablights { - automaticmarkers > 0 ? automaticmarkers : MoverParameters->Lights[ VehicleEnd::front ][ lightpos ], - automaticmarkers > 0 ? automaticmarkers : MoverParameters->Lights[ VehicleEnd::rear ][ lightpos ] }; + automaticmarkers > 0 ? automaticmarkers : physics->Lights[ VehicleEnd::front ][ lightpos ], + automaticmarkers > 0 ? automaticmarkers : physics->Lights[ VehicleEnd::rear ][ lightpos ] }; // the custom position keeps the lights lit at coupled ends as well - auto const ignorecouplings { MoverParameters->LightsPos == 18 }; - auto *vehicle { GetFirstDynamic( MoverParameters->CabOccupied >= 0 ? VehicleEnd::front : VehicleEnd::rear, Coupling::control ) }; + auto const ignorecouplings { physics->LightsPos == 18 }; + auto *vehicle { GetFirstDynamic( physics->CabOccupied >= 0 ? VehicleEnd::front : VehicleEnd::rear, Coupling::control ) }; while( vehicle != nullptr ) { // set lights on given side if there's no coupling with another vehicle, turn them off otherwise auto const iscoupled { [ vehicle, ignorecouplings ]( VehicleEnd const Side ) { return false == ignorecouplings - && vehicle->MoverParameters->Couplers[ Side ].CouplingFlag.HasAny(Coupling::coupler) - && vehicle->MoverParameters->Neighbours[ Side ].vehicle != nullptr; } }; + && vehicle->physics->Couplers[ Side ].CouplingFlag.HasAny(Coupling::coupler) + && vehicle->physics->Neighbours[ Side ].vehicle != nullptr; } }; auto const lights { lights_programmer::vehicle_lights( cablights, isfrontcaboccupied, vehicle->iDirection, { iscoupled( VehicleEnd::front ), iscoupled( VehicleEnd::rear ) } ) }; vehicle->RaLightsSet( lights.head, lights.rear ); @@ -86,14 +86,14 @@ void TDynamicObject::RaLightsSet(int head, int rear) { // zapalenie świateł z przodu i z // tyłu, zależne od kierunku // pojazdu - if (!MoverParameters) + if (!physics) return; // może tego nie być na początku if (rear == ( light::redmarker_left | light::redmarker_right | light::rearendsignals ) ) { // jeśli koniec pociągu, to trzeba ustalić, czy // jest tam czynna lokomotywa // EN57 może nie mieć końcówek od środka członu - if (MoverParameters->Power > 1.0) // jeśli ma moc napędową - if (!MoverParameters->DirActive) // jeśli nie ma ustawionego kierunku + if (physics->Power > 1.0) // jeśli ma moc napędową + if (!physics->DirActive) // jeśli nie ma ustawionego kierunku { // jeśli ma zarówno światła jak i końcówki, ustalić, czy jest w stanie aktywnym // np. lokomotywa na zimno będzie mieć końcówki a nie światła rear = light::rearendsignals; // tablice blaszane @@ -114,12 +114,12 @@ void TDynamicObject::RaLightsSet(int head, int rear) // w zależności od kierunku pojazdu w składzie if( head >= 0 ) { auto const vehicleend { iDirection > 0 ? VehicleEnd::front : VehicleEnd::rear }; - MoverParameters->iLights[ vehicleend ] = head & iInventory[vehicleend]; - bool tLeft = MoverParameters->iLights[vehicleend] & (light::auxiliary_left | light::headlight_left); // roboczo czy jakiekolwiek swiatlo z lewej jest zapalone - bool tRight = MoverParameters->iLights[vehicleend] & (light::auxiliary_right | light::headlight_right); // a tu z prawej + physics->iLights[ vehicleend ] = head & iInventory[vehicleend]; + bool tLeft = physics->iLights[vehicleend] & (light::auxiliary_left | light::headlight_left); // roboczo czy jakiekolwiek swiatlo z lewej jest zapalone + bool tRight = physics->iLights[vehicleend] & (light::auxiliary_right | light::headlight_right); // a tu z prawej if (Controller == Humandriver) { - auto const dps{MoverParameters->currentDimPosition()}; + auto const dps{physics->currentDimPosition()}; // domyślnie HighBeamLights = false; @@ -128,17 +128,17 @@ void TDynamicObject::RaLightsSet(int head, int rear) // obsługa OFF if (dps.isOff) { - //MoverParameters->iLights[vehicleend] &= 0 | light::rearendsignals; // zostawiamy tylko tabliczki jesli sa + //physics->iLights[vehicleend] &= 0 | light::rearendsignals; // zostawiamy tylko tabliczki jesli sa HighBeamLights = false; DimHeadlights = false; // the headlights at the end of the active cab: A at the front, B at the rear - if( auto const cabend { CabEnd( MoverParameters->CabActive ) }; cabend.has_value() ) { + if( auto const cabend { CabEnd( physics->CabActive ) }; cabend.has_value() ) { ( *cabend == VehicleEnd::front ? HeadlightsAoff : HeadlightsBoff ) = true; } } else { - if( auto const cabend { CabEnd( MoverParameters->CabActive ) }; cabend.has_value() ) { + if( auto const cabend { CabEnd( physics->CabActive ) }; cabend.has_value() ) { ( *cabend == VehicleEnd::front ? HeadlightsAoff : HeadlightsBoff ) = false; } } @@ -156,7 +156,7 @@ void TDynamicObject::RaLightsSet(int head, int rear) } if( rear >= 0 ) { auto const vehicleend{ iDirection > 0 ? VehicleEnd::rear : VehicleEnd::front }; - MoverParameters->iLights[ vehicleend ] = rear & iInventory[vehicleend]; + physics->iLights[ vehicleend ] = rear & iInventory[vehicleend]; } }; @@ -166,7 +166,7 @@ void TDynamicObject::SetLightDimmings() if (Controller == Humandriver) { - auto const dps{MoverParameters->currentDimPosition()}; + auto const dps{physics->currentDimPosition()}; // domyślnie HighBeamLights = false; @@ -175,7 +175,7 @@ void TDynamicObject::SetLightDimmings() // obsługa OFF if (dps.isOff) { - // MoverParameters->iLights[vehicleend] &= 0 | light::rearendsignals; // zostawiamy tylko tabliczki jesli sa + // physics->iLights[vehicleend] &= 0 | light::rearendsignals; // zostawiamy tylko tabliczki jesli sa HighBeamLights = false; DimHeadlights = false; switch (vehicleend) @@ -227,7 +227,7 @@ bool TDynamicObject::has_signal_pc1_on() const { auto const pattern { equippedlights & ( light::headlight_left | light::headlight_right | light::headlight_upper ) }; auto const patternfallback { equippedlights & ( light::auxiliary_left | light::auxiliary_right | light::headlight_upper ) }; auto const hasauxiliarylights { ( equippedlights & ( light::auxiliary_left | light::auxiliary_right ) ) != 0 }; - auto const activelights { MoverParameters->iLights[ vehicleend ] }; + auto const activelights { physics->iLights[ vehicleend ] }; return (pattern != 0 && activelights == pattern) || (hasauxiliarylights && activelights == patternfallback) || (pattern == 0 && patternfallback == 0 && activelights == light::rearendsignals); // pc4 @@ -240,7 +240,7 @@ bool TDynamicObject::has_signal_pc2_on() const { auto const pattern { equippedlights & ( light::redmarker_left | light::headlight_right | light::headlight_upper ) }; auto const patternfallback { equippedlights & ( light::redmarker_left | light::auxiliary_right | light::headlight_upper ) }; auto const hasauxiliarylights { ( equippedlights & ( light::auxiliary_left | light::auxiliary_right ) ) != 0 }; - auto const activelights { MoverParameters->iLights[ vehicleend ] }; + auto const activelights { physics->iLights[ vehicleend ] }; return activelights == pattern || (hasauxiliarylights && activelights == patternfallback); } @@ -251,7 +251,7 @@ bool TDynamicObject::has_signal_pc5_on() const { auto const equippedlights { iInventory[ vehicleend ] }; auto const pattern { equippedlights & ( light::redmarker_left | light::redmarker_right ) }; auto const patternfallback { equippedlights & light::rearendsignals }; - auto const activelights { MoverParameters->iLights[ vehicleend ] }; + auto const activelights { physics->iLights[ vehicleend ] }; return (pattern != 0 && activelights == pattern) || (patternfallback != 0 && activelights == patternfallback); } @@ -261,7 +261,7 @@ bool TDynamicObject::has_signal_on( VehicleEnd const Side, int const Pattern ) c auto const vehicleend { iDirection > 0 ? Side : 1 - Side }; auto const pattern { iInventory[ vehicleend ] & Pattern }; - return ( MoverParameters->iLights[ vehicleend ] == pattern ); + return ( physics->iLights[ vehicleend ] == pattern ); */ - return MoverParameters->iLights[Side] == (Pattern & iInventory[Side]); + return physics->iLights[Side] == (Pattern & iInventory[Side]); } diff --git a/vehicle/dynamic/load.cpp b/vehicle/dynamic/load.cpp index 42c9e7913..026761d23 100644 --- a/vehicle/dynamic/load.cpp +++ b/vehicle/dynamic/load.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -61,16 +61,16 @@ http://mozilla.org/MPL/2.0/. // initiates load change by specified amounts, with a platform on specified side void TDynamicObject::LoadExchange( int const Disembark, int const Embark, int const Platforms ) { /* - if( ( MoverParameters->Doors.open_control == control_t::passenger ) - || ( MoverParameters->Doors.open_control == control_t::mixed ) ) { + if( ( physics->Doors.open_control == control_t::passenger ) + || ( physics->Doors.open_control == control_t::mixed ) ) { // jeśli jedzie do tyłu, to drzwi otwiera odwrotnie auto const lewe = ( DirectionGet() > 0 ) ? 1 : 2; auto const prawe = 3 - lewe; if( Platform & lewe ) { - MoverParameters->OperateDoors( VehicleSide::left, true, range_t::local ); + physics->OperateDoors( VehicleSide::left, true, range_t::local ); } if( Platform & prawe ) { - MoverParameters->OperateDoors( VehicleSide::right, true, range_t::local ); + physics->OperateDoors( VehicleSide::right, true, range_t::local ); } } */ @@ -93,7 +93,7 @@ float TDynamicObject::LoadExchangeTime() const { if( m_exchange.unload_count < 0.01 && m_exchange.load_count < 0.01 ) { return 0.f; } - auto const baseexchangetime { m_exchange.unload_count / MoverParameters->UnLoadSpeed + m_exchange.load_count / MoverParameters->LoadSpeed }; + auto const baseexchangetime { m_exchange.unload_count / physics->UnLoadSpeed + m_exchange.load_count / physics->LoadSpeed }; auto const nominalexchangespeedfactor { ( m_exchange.platforms == 3 ? 2.f : 1.f ) }; auto const actualexchangespeedfactor { LoadExchangeSpeed() }; @@ -108,10 +108,10 @@ float TDynamicObject::LoadExchangeSpeed() const { auto const lewe { DirectionGet() > 0 ? 1 : 2 }; auto const prawe { 3 - lewe }; if( m_exchange.platforms & lewe ) { - exchangespeedfactor += MoverParameters->Doors.instances[VehicleSide::left].is_open ? 1.f : 0.f; + exchangespeedfactor += physics->Doors.instances[VehicleSide::left].is_open ? 1.f : 0.f; } if( m_exchange.platforms & prawe ) { - exchangespeedfactor += MoverParameters->Doors.instances[VehicleSide::right].is_open ? 1.f : 0.f; + exchangespeedfactor += physics->Doors.instances[VehicleSide::right].is_open ? 1.f : 0.f; } return exchangespeedfactor; @@ -125,7 +125,7 @@ void TDynamicObject::update_exchange( double const Deltatime ) { if( m_exchange.unload_count < 0.01 && m_exchange.load_count < 0.01 ) { return; } - if( MoverParameters->Vel < 2.0 ) { + if( physics->Vel < 2.0 ) { auto const exchangespeed { LoadExchangeSpeed() }; @@ -134,14 +134,14 @@ void TDynamicObject::update_exchange( double const Deltatime ) { auto const lewe { DirectionGet() > 0 ? 1 : 2 }; auto const prawe { 3 - lewe }; if( m_exchange.platforms & lewe - && false == (MoverParameters->Doors.instances[VehicleSide::left].is_open || MoverParameters->Doors.instances[VehicleSide::left].is_opening) ) { + && false == (physics->Doors.instances[VehicleSide::left].is_open || physics->Doors.instances[VehicleSide::left].is_opening) ) { // try to open left door - MoverParameters->OperateDoors( VehicleSide::left, true, range_t::local ); + physics->OperateDoors( VehicleSide::left, true, range_t::local ); } if( m_exchange.platforms & prawe - && false == (MoverParameters->Doors.instances[VehicleSide::right].is_open || MoverParameters->Doors.instances[VehicleSide::right].is_opening) ) { + && false == (physics->Doors.instances[VehicleSide::right].is_open || physics->Doors.instances[VehicleSide::right].is_opening) ) { // try to open right door - MoverParameters->OperateDoors( VehicleSide::right, true, range_t::local ); + physics->OperateDoors( VehicleSide::right, true, range_t::local ); } } @@ -152,33 +152,33 @@ void TDynamicObject::update_exchange( double const Deltatime ) { && m_exchange.time >= 1.0 ) { m_exchange.time -= 1.0; - auto const exchangesize = std::min( m_exchange.unload_count, MoverParameters->UnLoadSpeed * exchangespeed ); + auto const exchangesize = std::min( m_exchange.unload_count, physics->UnLoadSpeed * exchangespeed ); m_exchange.unload_count -= exchangesize; - MoverParameters->LoadStatus = 1; - MoverParameters->LoadAmount = std::max( 0.f, MoverParameters->LoadAmount - exchangesize ); - MoverParameters->ComputeMass(); + physics->LoadStatus = 1; + physics->LoadAmount = std::max( 0.f, physics->LoadAmount - exchangesize ); + physics->ComputeMass(); update_load_visibility(); } if( m_exchange.unload_count < 0.01 ) { // finish any potential unloading operation before adding new load // don't load more than can fit - m_exchange.load_count = std::min( m_exchange.load_count, MoverParameters->MaxLoad - MoverParameters->LoadAmount ); + m_exchange.load_count = std::min( m_exchange.load_count, physics->MaxLoad - physics->LoadAmount ); while( m_exchange.load_count > 0.01 && m_exchange.time >= 1.0 ) { m_exchange.time -= 1.0; - auto const exchangesize = std::min( m_exchange.load_count, MoverParameters->LoadSpeed * exchangespeed ); + auto const exchangesize = std::min( m_exchange.load_count, physics->LoadSpeed * exchangespeed ); m_exchange.load_count -= exchangesize; - MoverParameters->LoadStatus = 2; - MoverParameters->LoadAmount = std::min( MoverParameters->MaxLoad, MoverParameters->LoadAmount + exchangesize ); // std::max not strictly needed but, eh - MoverParameters->ComputeMass(); + physics->LoadStatus = 2; + physics->LoadAmount = std::min( physics->MaxLoad, physics->LoadAmount + exchangesize ); // std::max not strictly needed but, eh + physics->ComputeMass(); update_load_visibility(); } } } } - if( MoverParameters->Vel > 2.0 ) { + if( physics->Vel > 2.0 ) { // if the vehicle moves too fast cancel the exchange m_exchange.unload_count = 0; m_exchange.load_count = 0; @@ -187,37 +187,37 @@ void TDynamicObject::update_exchange( double const Deltatime ) { if( m_exchange.unload_count < 0.01 && m_exchange.load_count < 0.01 ) { - MoverParameters->LoadStatus = 4; + physics->LoadStatus = 4; // if the exchange is completed (or canceled) close the door, if applicable - if( MoverParameters->Doors.close_control == control_t::passenger - || MoverParameters->Doors.close_control == control_t::mixed ) { + if( physics->Doors.close_control == control_t::passenger + || physics->Doors.close_control == control_t::mixed ) { - if( MoverParameters->Vel > 2.0 + if( physics->Vel > 2.0 || Random() < ( // remotely controlled door are more likely to be left open - MoverParameters->Doors.close_control == control_t::passenger ? 0.75 : 0.50) ) { + physics->Doors.close_control == control_t::passenger ? 0.75 : 0.50) ) { - MoverParameters->OperateDoors( VehicleSide::left, false, range_t::local ); - MoverParameters->OperateDoors( VehicleSide::right, false, range_t::local ); + physics->OperateDoors( VehicleSide::left, false, range_t::local ); + physics->OperateDoors( VehicleSide::right, false, range_t::local ); } } // if the vehicle was emptied potentially switch load visualization model - if( MoverParameters->LoadAmount == 0 ) { - MoverParameters->AssignLoad( "" ); + if( physics->LoadAmount == 0 ) { + physics->AssignLoad( "" ); } } } void TDynamicObject::LoadUpdate() { - MoverParameters->LoadStatus &= 1 | 2; // po zakończeniu będzie równe zero + physics->LoadStatus &= 1 | 2; // po zakończeniu będzie równe zero // przeładowanie modelu ładunku - if( MoverParameters->LoadTypeChange ) { + if( physics->LoadTypeChange ) { // whether we succeed or not don't try more than once - MoverParameters->LoadTypeChange = false; + physics->LoadTypeChange = false; // bieżąca ścieżka do tekstur to dynamic/... Global.asCurrentTexturePath = asBaseDir; - mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name ); + mdLoad = LoadMMediaFile_mdload( physics->LoadType.name ); // TODO: discern from vehicle component which merely uses vehicle directory and has no animations, so it can be initialized outright // and actual vehicles which get their initialization after their animations are set up if( mdLoad != nullptr ) { @@ -247,7 +247,7 @@ TDynamicObject::update_load_sections() { SectionLoadOrder.push_back( §ion ); } // HACK: disable automatic self-illumination threshold, at least until 3d model update - if( MoverParameters->CompartmentLights.start_type == start_t::manual ) { + if( physics->CompartmentLights.start_type == start_t::manual ) { section.load->SetSelfIllum( 2.0f, true, false ); } } @@ -264,9 +264,9 @@ TDynamicObject::update_load_visibility() { // each entry in load order sequence matches a single chunk of the section it points to // the length of load order sequence matches total number of load chunks auto const loadpercentage { ( - MoverParameters->MaxLoad == 0.f ? + physics->MaxLoad == 0.f ? 0.0 : - MoverParameters->LoadAmount / MoverParameters->MaxLoad ) }; + physics->LoadAmount / physics->MaxLoad ) }; auto visiblechunkcount { ( SectionLoadOrder.empty() ? 0 : @@ -281,14 +281,14 @@ TDynamicObject::update_load_visibility() { void TDynamicObject::update_load_offset() { - if( MoverParameters->LoadType.offset_min == 0.f ) { return; } + if( physics->LoadType.offset_min == 0.f ) { return; } auto const loadpercentage { ( - MoverParameters->MaxLoad == 0.f ? + physics->MaxLoad == 0.f ? 0.0 : - 100.0 * MoverParameters->LoadAmount / MoverParameters->MaxLoad ) }; + 100.0 * physics->LoadAmount / physics->MaxLoad ) }; - LoadOffset = std::lerp( MoverParameters->LoadType.offset_min, 0.f, safe_clamp( 0.0, 1.0, loadpercentage * 0.01 ) ); + LoadOffset = std::lerp( physics->LoadType.offset_min, 0.f, safe_clamp( 0.0, 1.0, loadpercentage * 0.01 ) ); } void diff --git a/vehicle/dynamic/mmd.cpp b/vehicle/dynamic/mmd.cpp index b851379cd..ba952baaa 100644 --- a/vehicle/dynamic/mmd.cpp +++ b/vehicle/dynamic/mmd.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -92,7 +92,7 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co // preliminary check whether the file exists cParser parser( TypeName + ".mmd", cParser::buffer_FILE, asBaseDir ); if( false == parser.ok() ) { - ErrorLog( "Failed to load appearance data for vehicle " + MoverParameters->Name ); + ErrorLog( "Failed to load appearance data for vehicle " + physics->Name ); return; } } @@ -173,13 +173,13 @@ void TDynamicObject::loadModelsSection( cParser &parser, std::string &token, std } while( token != "" && token != "endmodels" ); - if( false == MoverParameters->LoadAttributes.empty() ) { + if( false == physics->LoadAttributes.empty() ) { // Ra: tu wczytywanie modelu ładunku jest w porządku // bieżąca ścieżka do tekstur to dynamic/... Global.asCurrentTexturePath = asBaseDir; - mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name ); + mdLoad = LoadMMediaFile_mdload( physics->LoadType.name ); // z powrotem defaultowa sciezka do tekstur Global.asCurrentTexturePath = std::string( paths::textures ); @@ -239,7 +239,7 @@ bool TDynamicObject::loadModelsGeneralKeyword( cParser &parser, std::string &tok if (iAnimType[ANIM_WIPERS]) wipers = &pAnimations[k]; pAnimations[k].iShift = sm; // przesunięcie do przydzielenia wskaźnika - sm += pAnimations[k++].TypeSet(j, *MoverParameters); // ustawienie typu animacji i zliczanie tablicowanych submodeli + sm += pAnimations[k++].TypeSet(j, *physics); // ustawienie typu animacji i zliczanie tablicowanych submodeli } if (sm) // o ile są bardziej złożone animacje { @@ -341,7 +341,7 @@ bool TDynamicObject::loadModelsWheelKeyword( cParser &parser, std::string &token { //++iAnimatedAxles; pAnimations[i].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu pAnimations[i].yUpdate = std::bind( &TDynamicObject::UpdateAxle, this, std::placeholders::_1 ); - pAnimations[i].fMaxDist = Global.fDistanceFactor * MoverParameters->WheelDiameter * 200; + pAnimations[i].fMaxDist = Global.fDistanceFactor * physics->WheelDiameter * 200; pAnimations[i].fMaxDist *= pAnimations[i].fMaxDist; } } @@ -352,11 +352,11 @@ bool TDynamicObject::loadModelsWheelKeyword( cParser &parser, std::string &token j = 1; k = 0; m = 0; // numer osi; kolejny znak; ile osi danego typu; która średnica - if (MoverParameters->WheelDiameterL != MoverParameters->WheelDiameter || - MoverParameters->WheelDiameterT != MoverParameters->WheelDiameter) + if (physics->WheelDiameterL != physics->WheelDiameter || + physics->WheelDiameterT != physics->WheelDiameter) { // obsługa różnych średnic, o ile występują while (i < iAnimType[ANIM_WHEELS] && - j <= MoverParameters->AxleArangement.length()) + j <= physics->AxleArangement.length()) { // wersja ze wskaźnikami jest bardziej elastyczna na nietypowe układy if (k >= 'A' && k <= 'J') // 10 chyba maksimum? { @@ -370,7 +370,7 @@ bool TDynamicObject::loadModelsWheelKeyword( cParser &parser, std::string &token --k; // następna będzie albo taka sama, albo bierzemy kolejny znak } else - k = MoverParameters->AxleArangement[j++]; // pobranie kolejnego znaku + k = physics->AxleArangement[j++]; // pobranie kolejnego znaku } } } @@ -626,12 +626,12 @@ bool TDynamicObject::loadModelsPantographUpperKeyword( cParser &parser, std::str // pants[i].fParamPants->vPos.y=panty-panth-pants[i].fParamPants->PantWys; //np. 4.429-0.097=4.332=~4.335 if( pantograph.vPos.y == 0.0 ) { // crude fallback, place the pantograph(s) atop of the vehicle-sized box - pantograph.vPos.y = MoverParameters->Dim.H - pantograph.fHeight - pantograph.PantWys; + pantograph.vPos.y = physics->Dim.H - pantograph.fHeight - pantograph.PantWys; } // pants[i].fParamPants->vPos.z=0; //niezerowe dla pantografów asymetrycznych pantograph.PantTraction = pantograph.PantWys; // połowa szerokości ślizgu; jest w "Power: CSW=" - pantograph.fWidth = 0.5 * MoverParameters->EnginePowerSource.CollectorParameters.CSW; + pantograph.fWidth = 0.5 * physics->EnginePowerSource.CollectorParameters.CSW; // create sound emitters for the pantograph m_pantographsounds.emplace_back(); @@ -685,7 +685,7 @@ bool TDynamicObject::loadModelsLinkageKeyword( cParser &parser, std::string &tok panth=Parser->GetNextSymbol().ToDouble(); //długoś korbowodu (k) */ - MoverParameters->EnginePowerSource.PowerType = + physics->EnginePowerSource.PowerType = TPowerType::SteamPower; // Ra: po chamsku, ale z CHK nie działa } @@ -799,9 +799,9 @@ bool TDynamicObject::loadModelsDoorKeyword( cParser &parser, std::string &token, // the keys left out keep the values of the .fiz. the wing still follows the door of its side door_wings::wing_spec spec { 0, - MoverParameters->Doors.type, - MoverParameters->Doors.range, - MoverParameters->Doors.range_out }; + physics->Doors.type, + physics->Doors.range, + physics->Doors.range_out }; auto error { door_wings::read_spec( parser, spec ) }; if( error.empty() && ( spec.number < 1 || spec.number > iAnimType[ ANIM_DOORS ] ) ) { @@ -835,7 +835,7 @@ bool TDynamicObject::loadModelsDoorKeyword( cParser &parser, std::string &token, if (pAnimations[i + j].smAnimated) { //++iAnimatedDoors; pAnimations[i + j].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu - switch( MoverParameters->Doors.step_type ) + switch( physics->Doors.step_type ) { // od razu zapinamy potrzebny typ animacji case 1: // shift pAnimations[ i + j ].yUpdate = std::bind( &TDynamicObject::UpdatePlatformTranslate, this, std::placeholders::_1 ); @@ -1002,14 +1002,14 @@ bool TDynamicObject::loadSoundsEngineKeyword( cParser &parser, std::string &toke } else if( token == "engine:" - && MoverParameters->Power > 0 ) { + && physics->Power > 0 ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. m_powertrainsounds.engine.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); m_powertrainsounds.engine.owner( this ); - auto const amplitudedivisor = static_cast( MoverParameters->EngineType == TEngineType::DieselEngine ? 1 : - MoverParameters->EngineType == TEngineType::DieselElectric ? 1 : - MoverParameters->nmax * 60 + MoverParameters->Power * 3 ); + auto const amplitudedivisor = static_cast( physics->EngineType == TEngineType::DieselEngine ? 1 : + physics->EngineType == TEngineType::DieselElectric ? 1 : + physics->nmax * 60 + physics->Power * 3 ); m_powertrainsounds.engine.m_amplitudefactor /= amplitudedivisor; } else if (token == "fakeengine:") { @@ -1051,11 +1051,11 @@ bool TDynamicObject::loadSoundsEngineKeyword( cParser &parser, std::string &toke // the sounds of the traction motors, their blowers, the inverter, the fans and the transmission in the sounds: section; false when the token is none of them bool TDynamicObject::loadSoundsMotorKeyword( cParser &parser, std::string_view token ) { - if( token == "tractionmotor:" && MoverParameters->Power > 0 ) { + if( token == "tractionmotor:" && physics->Power > 0 ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. sound_source motortemplate { sound_placement::external }; motortemplate.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); - auto const amplitudedivisor { static_cast( MoverParameters->nmax * 60 + MoverParameters->Power * 3 ) }; + auto const amplitudedivisor { static_cast( physics->nmax * 60 + physics->Power * 3 ) }; motortemplate.m_amplitudefactor /= amplitudedivisor; motortemplate.owner( this ); @@ -1079,7 +1079,7 @@ bool TDynamicObject::loadSoundsMotorKeyword( cParser &parser, std::string_view t } } - else if( token == "tractionacmotor:" && MoverParameters->Power > 0 ) { + else if( token == "tractionacmotor:" && physics->Power > 0 ) { // plik z dzwiekiem silnika, mnozniki i ofsety amp. i czest. sound_source motortemplate { sound_placement::external }; motortemplate.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); @@ -1112,9 +1112,9 @@ bool TDynamicObject::loadSoundsMotorKeyword( cParser &parser, std::string_view t blowertemplate.owner( this ); auto const amplitudedivisor { static_cast( - MoverParameters->MotorBlowers[ VehicleEnd::front ].speed > 0 ? MoverParameters->MotorBlowers[ VehicleEnd::front ].speed * MoverParameters->nmax * 60 + MoverParameters->Power * 3 : + physics->MotorBlowers[ VehicleEnd::front ].speed > 0 ? physics->MotorBlowers[ VehicleEnd::front ].speed * physics->nmax * 60 + physics->Power * 3 : blowertemplate.has_bookends() ? 1 : // NOTE: for motorblowers with fixed speed if the sound has defined bookends we skip revolutions-based part of frequency/volume adjustments - MoverParameters->MotorBlowers[ VehicleEnd::front ].speed * -1 ) }; + physics->MotorBlowers[ VehicleEnd::front ].speed * -1 ) }; blowertemplate.m_amplitudefactor /= amplitudedivisor; blowertemplate.m_frequencyfactor /= amplitudedivisor; @@ -1147,8 +1147,8 @@ bool TDynamicObject::loadSoundsMotorKeyword( cParser &parser, std::string_view t m_powertrainsounds.rsWentylator.deserialize( parser, sound_type::single, sound_parameters::range | sound_parameters::amplitude | sound_parameters::frequency ); m_powertrainsounds.rsWentylator.owner( this ); - m_powertrainsounds.rsWentylator.m_amplitudefactor /= MoverParameters->RVentnmax; - m_powertrainsounds.rsWentylator.m_frequencyfactor /= MoverParameters->RVentnmax; + m_powertrainsounds.rsWentylator.m_amplitudefactor /= physics->RVentnmax; + m_powertrainsounds.rsWentylator.m_frequencyfactor /= physics->RVentnmax; } else if( token == "radiatorfan1:" ) { @@ -1189,7 +1189,7 @@ bool TDynamicObject::loadSoundsBrakeKeyword( cParser &parser, std::string_view t rsBrake.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency ); rsBrake.owner( this ); // NOTE: can't pre-calculate amplitude normalization based on max brake force, as this varies depending on vehicle speed - rsBrake.m_frequencyfactor /= 1 + MoverParameters->Vmax; + rsBrake.m_frequencyfactor /= 1 + physics->Vmax; } else if( token == "brake:" ) { @@ -1494,13 +1494,13 @@ bool TDynamicObject::loadSoundsDoorKeyword( cParser &parser, std::string_view to // the sounds of the load exchange, the sanders, the releaser and the running noise in the sounds: section; false when the token is none of them bool TDynamicObject::loadSoundsOtherKeyword( cParser &parser, std::string_view token ) { if( token == "unloading:" ) { - m_exchangesounds.unloading.range( MoverParameters->Dim.L * 0.5f * -1 ); + m_exchangesounds.unloading.range( physics->Dim.L * 0.5f * -1 ); m_exchangesounds.unloading.deserialize( parser, sound_type::single ); m_exchangesounds.unloading.owner( this ); } else if( token == "loading:" ) { - m_exchangesounds.loading.range( MoverParameters->Dim.L * 0.5f * -1 ); + m_exchangesounds.loading.range( physics->Dim.L * 0.5f * -1 ); m_exchangesounds.loading.deserialize( parser, sound_type::single ); m_exchangesounds.loading.owner( this ); } @@ -1519,11 +1519,11 @@ bool TDynamicObject::loadSoundsOtherKeyword( cParser &parser, std::string_view t else if( token == "outernoise:" ) { // szum podczas jazdy: sound_source noisetemplate{ sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; - noisetemplate.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, MoverParameters->Vmax ); + noisetemplate.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, physics->Vmax ); noisetemplate.owner( this ); - noisetemplate.m_amplitudefactor /= 1 + MoverParameters->Vmax; - noisetemplate.m_frequencyfactor /= 1 + MoverParameters->Vmax; + noisetemplate.m_amplitudefactor /= 1 + physics->Vmax; + noisetemplate.m_frequencyfactor /= 1 + physics->Vmax; #ifdef EU07_SOUND_BOGIESOUNDS if( true == m_bogiesounds.empty() ) { // fallback for cases without specified noise locations, convert sound template to a single sound source @@ -1655,7 +1655,7 @@ void TDynamicObject::loadLocationsSection( cParser &parser, std::string &token ) if( sides == "both" || sides == "left" ) { // left... - auto const location { glm::vec3 { MoverParameters->Dim.W * 0.5f, MoverParameters->Dim.H * 0.5f, offset } }; + auto const location { glm::vec3 { physics->Dim.W * 0.5f, physics->Dim.H * 0.5f, offset } }; door.placement = VehicleSide::left; door.rsDoorClose.offset( location ); door.rsDoorOpen.offset( location ); @@ -1669,7 +1669,7 @@ void TDynamicObject::loadLocationsSection( cParser &parser, std::string &token ) if( sides == "both" || sides == "right" ) { // ...and right - auto const location { glm::vec3 { MoverParameters->Dim.W * -0.5f, 2.f, offset } }; + auto const location { glm::vec3 { physics->Dim.W * -0.5f, 2.f, offset } }; door.placement = VehicleSide::right; door.rsDoorClose.offset( location ); door.rsDoorOpen.offset( location ); @@ -1697,8 +1697,8 @@ void TDynamicObject::loadLocationsSection( cParser &parser, std::string &token ) mirror.end = offset >= 0.f ? VehicleEnd::front : VehicleEnd::rear; for( auto const mirrorside : { VehicleSide::left, VehicleSide::right } ) { auto const location { glm::vec3 { - MoverParameters->Dim.W * ( mirrorside == VehicleSide::left ? 0.5f : -0.5f ), - MoverParameters->Dim.H * 0.5f, + physics->Dim.W * ( mirrorside == VehicleSide::left ? 0.5f : -0.5f ), + physics->Dim.H * 0.5f, offset } }; mirror.placement = mirrorside; mirror.unfold.offset( location ); @@ -1796,7 +1796,7 @@ bool TDynamicObject::loadInternalDataDeviceKeyword( cParser &parser, std::string m_powertrainsounds.rsEngageSlippery.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency ); m_powertrainsounds.rsEngageSlippery.owner( this ); - m_powertrainsounds.rsEngageSlippery.m_frequencyfactor /= 1 + MoverParameters->nmax; + m_powertrainsounds.rsEngageSlippery.m_frequencyfactor /= 1 + physics->nmax; } // dzwieki wycieraczkuf @@ -1869,7 +1869,7 @@ bool TDynamicObject::loadInternalDataDeviceKeyword( cParser &parser, std::string rsSlippery.deserialize( parser, sound_type::single, sound_parameters::amplitude ); rsSlippery.owner( this ); - rsSlippery.m_amplitudefactor /= 1 + MoverParameters->Vmax; + rsSlippery.m_amplitudefactor /= 1 + physics->Vmax; } else { return false; @@ -2175,10 +2175,10 @@ void TDynamicObject::finishLoadingMMediaFile( std::string const &asFileName, std // assigns the default samples to the sound emitters the .mmd file left out void TDynamicObject::assignDefaultMMediaSounds() { // assign default samples to sound emitters which weren't included in the config file - if( TestFlag( MoverParameters->CategoryFlag, 1 ) ) { + if( TestFlag( physics->CategoryFlag, 1 ) ) { // rail vehicles: // engine - if( MoverParameters->Power > 0 ) { + if( physics->Power > 0 ) { if( true == m_powertrainsounds.dsbWejscie_na_bezoporow.empty() ) { // hunter-111211: domyslne, gdy brak m_powertrainsounds.dsbWejscie_na_bezoporow.deserialize( "wejscie_na_bezoporow", sound_type::single ); @@ -2246,7 +2246,7 @@ void TDynamicObject::initMMediaModels() { void TDynamicObject::positionMMediaSoundEmitters() { // position sound emitters which weren't defined in the config file // engine sounds, centre of the vehicle - auto const enginelocation { glm::vec3 {0.f, MoverParameters->Dim.H * 0.5f, 0.f } }; + auto const enginelocation { glm::vec3 {0.f, physics->Dim.H * 0.5f, 0.f } }; m_powertrainsounds.position( enginelocation ); // other engine compartment sounds auto const nullvector { glm::vec3() }; @@ -2280,7 +2280,7 @@ void TDynamicObject::positionMMediaSoundEmitters() { dooranimationfirstindex += iAnimType[ i ]; } // couplers - auto const frontcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * 0.5f } }; + auto const frontcoupleroffset { glm::vec3{ 0.f, 1.f, physics->Dim.L * 0.5f } }; m_couplersounds[ VehicleEnd::front ].attach_coupler.offset( frontcoupleroffset ); m_couplersounds[ VehicleEnd::front ].attach_brakehose.offset( frontcoupleroffset ); m_couplersounds[ VehicleEnd::front ].attach_mainhose.offset( frontcoupleroffset ); @@ -2299,7 +2299,7 @@ void TDynamicObject::positionMMediaSoundEmitters() { m_couplersounds[ VehicleEnd::front ].dsbBufferClamp_loud.offset( frontcoupleroffset ); m_couplersounds[ VehicleEnd::front ].dsbAdapterAttach.offset( frontcoupleroffset ); m_couplersounds[ VehicleEnd::front ].dsbAdapterRemove.offset( frontcoupleroffset ); - auto const rearcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * -0.5f } }; + auto const rearcoupleroffset { glm::vec3{ 0.f, 1.f, physics->Dim.L * -0.5f } }; m_couplersounds[ VehicleEnd::rear ].attach_coupler.offset( rearcoupleroffset ); m_couplersounds[ VehicleEnd::rear ].attach_brakehose.offset( rearcoupleroffset ); m_couplersounds[ VehicleEnd::rear ].attach_mainhose.offset( rearcoupleroffset ); @@ -2338,7 +2338,7 @@ TDynamicObject::LoadMMediaFile_mdload( std::string const &Name ) const { // try first specialized version of the load model, vehiclename_loadname if ( loadmodel == nullptr ) { - auto const specializedloadfilename { asBaseDir + MoverParameters->TypeName + "_" + loadname }; + auto const specializedloadfilename { asBaseDir + physics->TypeName + "_" + loadname }; loadmodel = TModelsManager::GetModel( specializedloadfilename, true, false ); } // try generic version of the load model next, loadname diff --git a/vehicle/dynamic/movement.cpp b/vehicle/dynamic/movement.cpp index 77bcfbfff..3fd4687cc 100644 --- a/vehicle/dynamic/movement.cpp +++ b/vehicle/dynamic/movement.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -60,12 +60,12 @@ http://mozilla.org/MPL/2.0/. void TDynamicObject::FastMove(double fDistance) { - MoverParameters->dMoveLen = MoverParameters->dMoveLen + fDistance; + physics->dMoveLen = physics->dMoveLen + fDistance; } void TDynamicObject::Move(double fDistance) { - if( MoverParameters->OffTrack.active() ) { + if( physics->OffTrack.active() ) { // physics.derailment new: off the track it goes on the ground move_off_track( fDistance ); return; @@ -88,9 +88,9 @@ void TDynamicObject::move_axles(double fDistance) if (Axle0.GetTrack() == Axle1.GetTrack()) // przed przesunięciem { // powiązanie pojazdu z osią można zmienić tylko wtedy, gdy skrajne osie są // na tym samym torze - if (MoverParameters->Vel > + if (physics->Vel > 2) //|[km/h]| nie ma sensu zmiana osi, jesli pojazd drga na postoju - iAxleFirst = MoverParameters->V >= 0.0 ? + iAxleFirst = physics->V >= 0.0 ? 1 : 0; //[m/s] ?1:0 - aktywna druga oś w kierunku jazdy // aktualnie eventy aktywuje druga oś, żeby AI nie wyłączało sobie semafora @@ -146,15 +146,15 @@ void TDynamicObject::place_by_axles() } mMatrix = BasisChange(vLeft, vUp, vFront); // to też można by od razu policzyć, ale potrzebne jest do wyświetlania // przesuwanie jest jednak rzadziej niż renderowanie mMatrix = glm::inverse(mMatrix); // wyliczenie macierzy dla pojazdu (potrzebna tylko do wyświetlania?) - // if (MoverParameters->CategoryFlag&2) + // if (physics->CategoryFlag&2) { // przesunięcia są używane po wyrzuceniu pociągu z toru - vPosition.x += MoverParameters->OffsetTrackH * vLeft.x; // dodanie przesunięcia w bok - vPosition.z += MoverParameters->OffsetTrackH * vLeft.z; // vLeft jest wektorem poprzecznym + vPosition.x += physics->OffsetTrackH * vLeft.x; // dodanie przesunięcia w bok + vPosition.z += physics->OffsetTrackH * vLeft.z; // vLeft jest wektorem poprzecznym // if () na przechyłce będzie dodatkowo zmiana wysokości samochodu - vPosition.y += MoverParameters->OffsetTrackV; // te offsety są liczone przez moverparam + vPosition.y += physics->OffsetTrackV; // te offsety są liczone przez the physics } // obliczanie pozycji sprzęgów do liczenia zderzeń - auto dir = 0.5 * MoverParameters->Dim.L * vFront; // wektor sprzęgu + auto dir = 0.5 * physics->Dim.L * vFront; // wektor sprzęgu vCoulpler[VehicleEnd::front] = vPosition + dir; // współrzędne sprzęgu na początku vCoulpler[VehicleEnd::rear] = vPosition - dir; // współrzędne sprzęgu na końcu // bCameraNear= @@ -232,7 +232,7 @@ bool TDynamicObject::UpdateForce(double dt) return false; if( dt > 0 ) { // wywalenie WS zależy od ustawienia kierunku - MoverParameters->ComputeTotalForce( dt ); + physics->ComputeTotalForce( dt ); } return true; } @@ -261,7 +261,7 @@ bool TDynamicObject::FastUpdate(double dt) if (dt == 0.0) return true; // Ra: pauza double dDOMoveLen; - if (!MoverParameters->PhysicActivation) + if (!physics->PhysicActivation) return true; // McZapkie: wylaczanie fizyki gdy nie potrzeba if (!bEnabled) @@ -279,7 +279,7 @@ bool TDynamicObject::FastUpdate(double dt) modelRot.z }; // McZapkie: parametry powinny byc pobierane z toru // ts.R=MyTrack->fRadius; - // ts.Len= std::max(MoverParameters->BDist,MoverParameters->ADist); + // ts.Len= std::max(physics->BDist,physics->ADist); // ts.dHtrack=Axle1.pPosition.y-Axle0.pPosition.y; // ts.dHrail=((Axle1.GetRoll())+(Axle0.GetRoll()))*0.5f; // tp.Width=MyTrack->fTrackWidth; @@ -288,12 +288,12 @@ bool TDynamicObject::FastUpdate(double dt) // tp.CategoryFlag= MyTrack->iCategoryFlag&15; // tp.DamageFlag=MyTrack->iDamageFlag; // tp.QualityFlag=MyTrack->iQualityFlag; - dDOMoveLen = MoverParameters->FastComputeMovement(dt, ts, tp, l, r); // ,ts,tp,tmpTraction); + dDOMoveLen = physics->FastComputeMovement(dt, ts, tp, l, r); // ,ts,tp,tmpTraction); // Move(dDOMoveLen); // ResetdMoveLen(); FastMove(dDOMoveLen); - if( MoverParameters->LoadStatus ) { + if( physics->LoadStatus ) { LoadUpdate(); // zmiana modelu ładunku } update_exchange( dt ); @@ -314,8 +314,8 @@ double TDynamicObject::radius() const { glm::vec3 diagonal( - static_cast( MoverParameters->Dim.L ), - static_cast( MoverParameters->Dim.H ), - static_cast( MoverParameters->Dim.W ) ); + static_cast( physics->Dim.L ), + static_cast( physics->Dim.H ), + static_cast( physics->Dim.W ) ); return glm::length( diagonal ) * 0.5f; } diff --git a/vehicle/dynamic/neighbours.cpp b/vehicle/dynamic/neighbours.cpp index cc43d8e56..dc24a84a5 100644 --- a/vehicle/dynamic/neighbours.cpp +++ b/vehicle/dynamic/neighbours.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -165,7 +165,7 @@ void TDynamicObject::ABuBogies() { // Obracanie wozkow na zakretach. Na razie // uwzględnia tylko zakręty, // bez zadnych gorek i innych przeszkod. - if( smBogie[ 0 ] != nullptr && smBogie[ 1 ] != nullptr && MoverParameters->OffTrack.active() ) { + if( smBogie[ 0 ] != nullptr && smBogie[ 1 ] != nullptr && physics->OffTrack.active() ) { // off the track the bogies stay straight under the body, they don't follow the track any more bogieRot[ 0 ] = glm::vec3 { 0.f }; bogieRot[ 1 ] = glm::vec3 { 0.f }; @@ -252,12 +252,12 @@ TDynamicObject::ABuFindObject( int &Foundcoupler, double &Distance, TTrack const if( dynamic == this ) { continue; } // szukający się nie liczy // physics.derailment new: one of the two off the track beside the other one, they don't meet - if( InLine && ( MoverParameters->OffTrack.active() || dynamic->MoverParameters->OffTrack.active() ) && false == in_line_with( *dynamic ) ) { + if( InLine && ( physics->OffTrack.active() || dynamic->physics->OffTrack.active() ) && false == in_line_with( *dynamic ) ) { continue; } /* - if( ( ( dynamic == PrevConnected ) && ( MoverParameters->Couplers[ TMoverParameters::side::front ].CouplingFlag != Coupling::none ) ) - || ( ( dynamic == NextConnected ) && ( MoverParameters->Couplers[ TMoverParameters::side::rear ].CouplingFlag != Coupling::none ) ) ){ + if( ( ( dynamic == PrevConnected ) && ( physics->Couplers[ physics::Vehicle::side::front ].CouplingFlag != Coupling::none ) ) + || ( ( dynamic == NextConnected ) && ( physics->Couplers[ physics::Vehicle::side::rear ].CouplingFlag != Coupling::none ) ) ){ // stop-gap check to prevent 'detection' of attached vehicles // which seems to be a side-effect of inaccurate location calculation in 'simple' mode? // TODO: investigate actual cause @@ -293,12 +293,12 @@ TDynamicObject::ABuFindObject( int &Foundcoupler, double &Distance, TTrack const double relativeoffset; // wzajemna odległość poprzeczna if( Foundcoupler != Mycoupler ) { // facing the same direction - relativeoffset = std::abs( MoverParameters->OffsetTrackH - dynamic->MoverParameters->OffsetTrackH ); + relativeoffset = std::abs( physics->OffsetTrackH - dynamic->physics->OffsetTrackH ); } else { - relativeoffset = std::abs( MoverParameters->OffsetTrackH + dynamic->MoverParameters->OffsetTrackH ); + relativeoffset = std::abs( physics->OffsetTrackH + dynamic->physics->OffsetTrackH ); } - if( relativeoffset + relativeoffset > MoverParameters->Dim.W + dynamic->MoverParameters->Dim.W ) { + if( relativeoffset + relativeoffset > physics->Dim.W + dynamic->physics->Dim.W ) { // odległość większa od połowy sumy szerokości - kolizji nie będzie continue; } diff --git a/vehicle/dynamic/offtrack.cpp b/vehicle/dynamic/offtrack.cpp index c1dab3d46..40bb90392 100644 --- a/vehicle/dynamic/offtrack.cpp +++ b/vehicle/dynamic/offtrack.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -150,19 +150,19 @@ glm::dvec3 level_left_of( glm::dvec3 const &Front ) { // and the buffers of the side it rolled to miss those of an upright one derail_motion::end_point end_point_of( TDynamicObject const &Vehicle, VehicleEnd const End ) { auto const facing { End == VehicleEnd::front ? 1.0 : -1.0 }; - auto const &motion { Vehicle.MoverParameters->OffTrack }; + auto const &motion { Vehicle.physics->OffTrack }; glm::dvec3 const front { Vehicle.VectorFront().x, 0.0, Vehicle.VectorFront().z }; auto const length { glm::length( front ) }; auto const axis { length > 1e-6 ? front / length : glm::dvec3 { 0.0, 0.0, 1.0 } }; auto const middle { motion.active() ? motion.base() : Vehicle.GetPosition() }; return derail_motion::end_point { - middle + glm::dvec3 { 0.0, derail_motion::buffer_height, 0.0 } + axis * ( facing * 0.5 * Vehicle.MoverParameters->Dim.L ), + middle + glm::dvec3 { 0.0, derail_motion::buffer_height, 0.0 } + axis * ( facing * 0.5 * Vehicle.physics->Dim.L ), axis * facing, motion.active() ? motion.tipping() : 0.0 }; } // the push of the buffers on the end of the vehicle [N], negative the pull of its coupling -double compression_of( TMoverParameters const &Vehicle, VehicleEnd const End ) { +double compression_of( physics::Vehicle const &Vehicle, VehicleEnd const End ) { return ( End == VehicleEnd::front ? -1.0 : 1.0 ) * Vehicle.Couplers[ End ].CForce; } @@ -185,16 +185,16 @@ std::string_view side_name( int const Side ) { double TDynamicObject::off_track_gap( VehicleEnd const End ) const { - auto const *neighbour { MoverParameters->Neighbours[ End ].vehicle }; + auto const *neighbour { physics->Neighbours[ End ].vehicle }; if( neighbour == nullptr ) { return 0.0; } - return derail_motion::meet( end_point_of( *this, End ), end_point_of( *neighbour, MoverParameters->Neighbours[ End ].FacingEnd() ) ).gap; + return derail_motion::meet( end_point_of( *this, End ), end_point_of( *neighbour, physics->Neighbours[ End ].FacingEnd() ) ).gap; } double TDynamicObject::off_track_offset() const { - if( false == MoverParameters->OffTrack.active() ) { + if( false == physics->OffTrack.active() ) { return 0.0; } auto const middle { 0.5 * ( Axle0.pPosition + Axle1.pPosition ) }; @@ -228,7 +228,7 @@ int TDynamicObject::outward_side() const { // buckle bends the line the other way more than the curve does (the criteria of derailment, physics/derailment.h) if( auto const design { std::sin( Axle1.vAngles.z - Axle0.vAngles.z ) }; std::abs( design ) >= 1e-4 ) { auto const outside { design > 0.0 ? -1 : 1 }; - return MoverParameters->DerailAcceleration < 0.0 ? -outside : outside; + return physics->DerailAcceleration < 0.0 ? -outside : outside; } // a straight track: the path under the vehicle as it is, a buckle on it, turns from the rear axle to the front one auto const front { Axle0.PathDirection() }; @@ -244,22 +244,21 @@ int TDynamicObject::outward_side() const { void TDynamicObject::gather_off_track_terrain() { - auto const &mover { *MoverParameters }; - auto const &position { mover.OffTrack.active() ? mover.OffTrack.current().position : vPosition }; + auto const &position { physics->OffTrack.active() ? physics->OffTrack.current().position : vPosition }; // as far as it may slide, and some - auto const slide { derail_motion::stopping_distance( mover.V, derailment::off_rails_friction ).value_or( 0.0 ) }; - auto const reach { std::min( slide + mover.Dim.L + 50.0, 600.0 ) }; + auto const slide { derail_motion::stopping_distance( physics->V, derailment::off_rails_friction ).value_or( 0.0 ) }; + auto const reach { std::min( slide + physics->Dim.L + 50.0, 600.0 ) }; m_offtrackgathered = m_offtracktotal; m_offtrackcropped = false; // the terrain of another vehicle, where it covers the way this one goes: around it and around where it stops going // straight on, by its length and the margin the terrain is gathered again at glm::dvec3 heading { vFront.x, 0.0, vFront.z }; - if( mover.OffTrack.active() ) { - heading = mover.OffTrack.heading(); + if( physics->OffTrack.active() ) { + heading = physics->OffTrack.heading(); } auto const length { glm::length( heading ) }; - auto const stop { length > 1e-6 ? position + heading * ( std::copysign( std::max( reach - mover.Dim.L - 50.0, 0.0 ), mover.V ) / length ) : position }; - auto const margin { mover.Dim.L + 30.0 }; + auto const stop { length > 1e-6 ? position + heading * ( std::copysign( std::max( reach - physics->Dim.L - 50.0, 0.0 ), physics->V ) / length ) : position }; + auto const margin { physics->Dim.L + 30.0 }; if( auto shared { simulation::Vehicles.off_track_terrain( glm::dvec2 { std::min( position.x, stop.x ) - margin, std::min( position.z, stop.z ) - margin }, glm::dvec2 { std::max( position.x, stop.x ) + margin, std::max( position.z, stop.z ) + margin } ) }; @@ -284,7 +283,7 @@ void TDynamicObject::gather_off_track_terrain() { return std::max( std::abs( middle.x - position.x ), std::abs( middle.z - position.z ) ); }; return distance( Left ) < distance( Right ); } ); triangles.resize( off_track_triangles ); - ErrorLog( std::format( "derailment: warning: {} found more than {} triangles of terrain around it, took the nearest", MoverParameters->Name, off_track_triangles ) ); + ErrorLog( std::format( "derailment: warning: {} found more than {} triangles of terrain around it, took the nearest", physics->Name, off_track_triangles ) ); } if( triangles.empty() ) { // a scenery without terrain: level with the top of the ballast @@ -300,7 +299,7 @@ void TDynamicObject::gather_off_track_terrain() { m_offtracksite.terrain( m_offtrackterrain.get() ); auto const took { seconds_since( started ) }; if( took > off_track_slow ) { - ErrorLog( std::format( "derailment: warning: gathering the terrain of {:.0f} m around {} took {:.0f} ms ({} triangles)", reach, MoverParameters->Name, took * 1000.0, triangles.size() ) ); + ErrorLog( std::format( "derailment: warning: gathering the terrain of {:.0f} m around {} took {:.0f} ms ({} triangles)", reach, physics->Name, took * 1000.0, triangles.size() ) ); } } @@ -311,8 +310,8 @@ void TDynamicObject::crop_off_track_terrain() { } m_offtrackcropped = true; // the ground under it, and as far around as it gathers the terrain anew once it moves again - auto const &position { MoverParameters->OffTrack.current().position }; - auto const reach { 0.5 * MoverParameters->Dim.L + 40.0 }; + auto const &position { physics->OffTrack.current().position }; + auto const reach { 0.5 * physics->Dim.L + 40.0 }; m_offtrackmin = glm::dvec2 { position.x - reach, position.z - reach }; m_offtrackmax = glm::dvec2 { position.x + reach, position.z + reach }; m_offtrackterrain = std::make_shared( m_offtrackterrain->cropped( m_offtrackmin, m_offtrackmax ) ); @@ -321,40 +320,39 @@ void TDynamicObject::crop_off_track_terrain() { void TDynamicObject::begin_off_track() { - auto &mover { *MoverParameters }; derail_motion::vehicle_shape shape; - shape.length = mover.Dim.L; - shape.width = mover.Dim.W > 0.5 ? mover.Dim.W : 3.0; + shape.length = physics->Dim.L; + shape.width = physics->Dim.W > 0.5 ? physics->Dim.W : 3.0; // a height up to 2 m in the definition is the height of the floor, the older meaning of the key - shape.height = mover.Dim.H > 2.0 ? mover.Dim.H : 4.0; - shape.centre_of_gravity = mover.centre_of_gravity(); - shape.contact_spacing = derailment::contact_spacing( mover.TrackW ); + shape.height = physics->Dim.H > 2.0 ? physics->Dim.H : 4.0; + shape.centre_of_gravity = physics->centre_of_gravity(); + shape.contact_spacing = derailment::contact_spacing( physics->TrackW ); shape.base = std::max( static_cast( fAxleDist ), 1.0 ); - shape.mass = mover.TotalMass; + shape.mass = physics->TotalMass; derail_motion::start start; start.position = vPosition; start.front = vFront; start.line = track_front(); - start.speed = mover.V; - start.reason = mover.DerailCause; - start.outward = ( mover.DerailSide != 0 ? mover.DerailSide : outward_side() ); - start.acceleration = mover.DerailAcceleration; + start.speed = physics->V; + start.reason = physics->DerailCause; + start.outward = ( physics->DerailSide != 0 ? physics->DerailSide : outward_side() ); + start.acceleration = physics->DerailAcceleration; // the terrain as far as it may slide, and some m_offtracktotal = 0.0; gather_off_track_terrain(); m_offtracksite = derail_motion::site { m_offtrackterrain.get(), track_bed() }; // each vehicle its own way of going off, from the seed of the run (the same seed, the same way) - auto const scatter { derail_motion::draw_scatter( derail_motion::seed_of( Global.random_seed, mover.Name ) ) }; - mover.OffTrack.begin( start, shape, m_offtracksite, scatter ); + auto const scatter { derail_motion::draw_scatter( derail_motion::seed_of( Global.random_seed, physics->Name ) ) }; + physics->OffTrack.begin( start, shape, m_offtracksite, scatter ); m_pulledoff = {}; m_offtracklogdue = 0.0; m_offtrackslowdue = 0.0; m_offtrackaxles = 0.0; - m_offtrackfrom = mover.OffTrack.current().position; + m_offtrackfrom = physics->OffTrack.current().position; - auto const heading { mover.OffTrack.heading() }; + auto const heading { physics->OffTrack.heading() }; auto const front { glm::dvec3 { vFront.x, 0.0, vFront.z } }; auto const turn { std::asin( std::clamp( glm::dot( heading, level_left_of( glm::normalize( front ) ) ), -1.0, 1.0 ) ) }; std::string terrain { "no terrain, level ground" }; @@ -363,18 +361,18 @@ void TDynamicObject::begin_off_track() { } WriteLog( std::format( "derailment: {} leaves the track at {:.0f} km/h on track {}, heading turned {:.1f} deg to the {}, the outside of the curve to the {}; {} around it", - mover.Name, std::abs( mover.V ) * 3.6, MyTrack != nullptr ? MyTrack->name() : std::string { "(none)" }, + physics->Name, std::abs( physics->V ) * 3.6, MyTrack != nullptr ? MyTrack->name() : std::string { "(none)" }, std::abs( glm::degrees( turn ) ), side_name( turn >= 0.0 ? 1 : -1 ), side_name( start.outward ), terrain ) ); WriteLog( std::format( "derailment: {} scattered by {:+.2f} deg of departure, {:+.2f} deg of yaw at {:+.3f} rad/s, the friction under its ends x{:.2f} / x{:.2f}{}", - mover.Name, glm::degrees( scatter.departure ), glm::degrees( scatter.yaw ), scatter.yaw_rate, scatter.friction_front, scatter.friction_rear, + physics->Name, glm::degrees( scatter.departure ), glm::degrees( scatter.yaw ), scatter.yaw_rate, scatter.friction_front, scatter.friction_rear, scatter.dig_in >= 0.0 ? std::format( ", its leading end digs in after {:.2f} s, x{:.2f} for {:.2f} s", scatter.dig_in, scatter.dig_in_friction, scatter.dig_in_time ) : std::string {} ) ); } void TDynamicObject::move_off_track( double const Distance ) { auto const started { off_track_clock::now() }; - auto &motion { MoverParameters->OffTrack }; + auto &motion { physics->OffTrack }; auto const time { std::exchange( m_offtracktime, 0.0 ) }; m_offtracktotal += time; // near the edge of the terrain gathered, the terrain further on; not more than once a second, whatever happens @@ -390,19 +388,19 @@ void TDynamicObject::move_off_track( double const Distance ) { // the buffers and the couplings of its ends push and pull it, at an angle to it where the vehicle coupled there is std::array ends {}; for (auto const end : VehicleEnds) { - auto const *neighbour { MoverParameters->Neighbours[ end ].vehicle }; - auto const compression { compression_of( *MoverParameters, end ) }; + auto const *neighbour { physics->Neighbours[ end ].vehicle }; + auto const compression { compression_of( *physics, end ) }; if( neighbour == nullptr || compression == 0.0 ) { continue; } ends[ NumberOf( end ) ] = derail_motion::force_on( - derail_motion::meet( end_point_of( *this, end ), end_point_of( *neighbour, MoverParameters->Neighbours[ end ].FacingEnd() ) ), compression ); + derail_motion::meet( end_point_of( *this, end ), end_point_of( *neighbour, physics->Neighbours[ end ].FacingEnd() ) ), compression ); } auto const reversals { motion.reversals() }; - motion.step( time, Distance, MoverParameters->V, m_offtracksite, ends ); + motion.step( time, Distance, physics->V, m_offtracksite, ends ); if( ( motion.reversals() - reversals ) % 2 != 0 ) { // the body turned about against the way it goes: the vehicle goes rear first, its speed the other way along it - MoverParameters->V = -MoverParameters->V; + physics->V = -physics->V; } auto const &pose { motion.current() }; // the axles go along the track as far as the vehicle went along it, for the track nearest to it: the vehicles on it @@ -426,20 +424,20 @@ void TDynamicObject::move_off_track( double const Distance ) { m_offtrackslowdue -= time; if( took > off_track_slow && m_offtrackslowdue <= 0.0 ) { m_offtrackslowdue = 1.0; - ErrorLog( std::format( "derailment: warning: moving {} off the track took {:.0f} ms in a frame of {:.3f} s", MoverParameters->Name, took * 1000.0, time ) ); + ErrorLog( std::format( "derailment: warning: moving {} off the track took {:.0f} ms in a frame of {:.3f} s", physics->Name, took * 1000.0, time ) ); } } void TDynamicObject::place_off_track() { - auto const &pose { MoverParameters->OffTrack.current() }; + auto const &pose { physics->OffTrack.current() }; vPosition = pose.position; vFront = pose.front; vLeft = pose.left; vUp = pose.up; modelRot.z = std::atan2( -vFront.x, vFront.z ); mMatrix = glm::inverse( BasisChange( vLeft, vUp, vFront ) ); - auto const half { 0.5 * MoverParameters->Dim.L * vFront }; + auto const half { 0.5 * physics->Dim.L * vFront }; vCoulpler[ VehicleEnd::front ] = vPosition + half; vCoulpler[ VehicleEnd::rear ] = vPosition - half; m_offtrackplaced = true; @@ -448,15 +446,15 @@ void TDynamicObject::place_off_track() { void TDynamicObject::pull_neighbours( double const Distance ) { for (auto const end : VehicleEnds) { - auto const &coupler { MoverParameters->Couplers[ end ] }; - auto *neighbour { MoverParameters->Neighbours[ end ].vehicle }; - if( coupler.CouplingFlag == Coupling::none || neighbour == nullptr || neighbour->MoverParameters->OffTrack.active() - || neighbour->MoverParameters->DamageFlag.HasAll(VehicleDamage::derailed) ) { + auto const &coupler { physics->Couplers[ end ] }; + auto *neighbour { physics->Neighbours[ end ].vehicle }; + if( coupler.CouplingFlag == Coupling::none || neighbour == nullptr || neighbour->physics->OffTrack.active() + || neighbour->physics->DamageFlag.HasAll(VehicleDamage::derailed) ) { m_pulledoff[ end ].reset(); continue; } - auto &other { *neighbour->MoverParameters }; - auto const otherend { MoverParameters->Neighbours[ end ].FacingEnd() }; + auto &other { *neighbour->physics }; + auto const otherend { physics->Neighbours[ end ].FacingEnd() }; glm::dvec3 const otherfront { neighbour->vFront.x, 0.0, neighbour->vFront.z }; if( glm::length( otherfront ) < 1e-6 ) { continue; @@ -479,14 +477,14 @@ void TDynamicObject::pull_neighbours( double const Distance ) { other.pull_off( side, mass > 0.0 ? std::abs( across ) / mass : 0.0, - std::format( "Y/Q {:.2f} from the {} of {} at {:.0f} deg, {:.0f} kN", ratio, compression > 0.0 ? "buffers" : "coupling", MoverParameters->Name, glm::degrees( angle ), magnitude / 1000.0 ) ); + std::format( "Y/Q {:.2f} from the {} of {} at {:.0f} deg, {:.0f} kN", ratio, compression > 0.0 ? "buffers" : "coupling", physics->Name, glm::degrees( angle ), magnitude / 1000.0 ) ); m_pulledoff[ end ].reset(); } } void TDynamicObject::update_off_track( double const Deltatime ) { - auto const &motion { MoverParameters->OffTrack }; + auto const &motion { physics->OffTrack }; if( false == motion.active() || m_offtracklogdue < 0.0 ) { // on the track, or came to rest and told so return; @@ -499,6 +497,6 @@ void TDynamicObject::update_off_track( double const Deltatime ) { m_offtracklogdue = ( resting ? -1.0 : 1.0 ); WriteLog( std::format( "derailment: {} {} {:.1f} m from where it left the rails, {:.1f} m from the axis of the track, at {:.1f} km/h, sliding sideways at {:.1f} m/s, tipped {:.0f} deg, roll {:.0f} deg, yaw {:+.1f} deg turning at {:+.1f} deg/s{}", - MoverParameters->Name, resting ? "came to rest" : "off the track", motion.travelled(), off_track_offset(), std::abs( MoverParameters->V ) * 3.6, motion.sideways(), + physics->Name, resting ? "came to rest" : "off the track", motion.travelled(), off_track_offset(), std::abs( physics->V ) * 3.6, motion.sideways(), glm::degrees( motion.tipping() ), glm::degrees( motion.roll() ), glm::degrees( motion.yaw() ), glm::degrees( motion.yaw_rate() ), motion.lying() ? ", lying on its side" : "" ) ); } diff --git a/vehicle/dynamic/sounds.cpp b/vehicle/dynamic/sounds.cpp index 62684280f..e4ee66811 100644 --- a/vehicle/dynamic/sounds.cpp +++ b/vehicle/dynamic/sounds.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -65,21 +65,21 @@ void TDynamicObject::RenderSounds() { if( Global.iPause != 0 ) { return; } if( m_startjoltplayed - && ( std::abs(MoverParameters->AccSVBased) < 0.01 + && ( std::abs(physics->AccSVBased) < 0.01 || GetVelocity() < 0.01 ) ) { // if the vehicle comes to a stop set the movement jolt to play when it starts moving again m_startjoltplayed = false; } auto const dt{ Timer::GetDeltaRenderTime() }; - m_powertrainsounds.render( *MoverParameters, dt ); + m_powertrainsounds.render( *physics, dt ); renderAuxiliarySounds(); // brake system and braking sounds: // brake cylinder piston - auto const brakepressureratio { std::max( 0.0, MoverParameters->BrakePress ) / std::max( 1.0, MoverParameters->MaxBrakePress[ 3 ] ) }; + auto const brakepressureratio { std::max( 0.0, physics->BrakePress ) / std::max( 1.0, physics->MaxBrakePress[ 3 ] ) }; renderBrakeCylinderSounds( brakepressureratio ); renderEpBrakeSounds( dt ); renderEmergencyBrakeSound(); @@ -100,11 +100,11 @@ void TDynamicObject::RenderSounds() { renderStartJoltSound(); // McZapkie! - to wazne - SoundFlag wystawiane jest przez moje moduly gdy zachodza pewne wydarzenia komentowane dzwiekiem. - renderMoverEventSounds(); + renderPhysicsEventSounds(); renderCouplerSounds(); - MoverParameters->SoundFlag = 0; - // McZapkie! - koniec obslugi dzwiekow z mover.pas + physics->SoundFlag = 0; + // McZapkie! - koniec obslugi dzwiekow z physics.pas renderDerailmentSounds(); } @@ -115,12 +115,12 @@ void TDynamicObject::renderAuxiliarySounds() { auto frequency{ 1.0 }; // NBMX dzwiek przetwornicy - if( MoverParameters->ConverterFlag ) { - if( MoverParameters->EngineType == TEngineType::ElectricSeriesMotor ) { - auto const voltage { std::max( MoverParameters->GetTrainsetHighVoltage(), MoverParameters->PantographVoltage ) }; + if( physics->ConverterFlag ) { + if( physics->EngineType == TEngineType::ElectricSeriesMotor ) { + auto const voltage { std::max( physics->GetTrainsetHighVoltage(), physics->PantographVoltage ) }; if( voltage > 0.0 ) { // NOTE: we do sound modulation here to avoid sudden jump on voltage loss - frequency = voltage / (MoverParameters->NominalVoltage * MoverParameters->RList[MoverParameters->RlistSize].Mn); + frequency = voltage / (physics->NominalVoltage * physics->RList[physics->RlistSize].Mn); frequency *= sConverter.m_frequencyfactor + sConverter.m_frequencyoffset; sConverter.pitch( std::clamp( frequency, 0.75, 1.25 ) ); // arbitrary limits ) } @@ -137,7 +137,7 @@ void TDynamicObject::renderAuxiliarySounds() { // Odtworzenie dzwieku wentylatora rezystora hamowania - if (MoverParameters->BRVentilators) + if (physics->BRVentilators) { sBRVent.play(sound_flags::exclusive | sound_flags::looping); } @@ -150,16 +150,16 @@ void TDynamicObject::renderAuxiliarySounds() { - if( MoverParameters->CompressorSpeed > 0.0 ) { + if( physics->CompressorSpeed > 0.0 ) { // McZapkie! - dzwiek compressor.wav tylko gdy dziala sprezarka - if( MoverParameters->CompressorFlag ) { + if( physics->CompressorFlag ) { // for compressor coupled with the diesel engine sound pitch is driven by engine revolutions - if( MoverParameters->CompressorPower == 3 ) { + if( physics->CompressorPower == 3 ) { // presume the compressor sound is recorded for idle revolutions // increase the pitch according to increase of engine revolutions auto const enginefactor { std::clamp( // try to keep the sound pitch in semi-reasonable range - MoverParameters->EngineMaxRPM() / MoverParameters->EngineIdleRPM() * MoverParameters->EngineRPMRatio(), + physics->EngineMaxRPM() / physics->EngineIdleRPM() * physics->EngineRPMRatio(), 0.5, 2.5 ) }; sCompressor.pitch( enginefactor ); sCompressorIdle.pitch( enginefactor ); @@ -170,7 +170,7 @@ void TDynamicObject::renderAuxiliarySounds() { } else { // enhanced sound path, with dedicated sound for idling compressor - if( MoverParameters->CompressorGovernorLock ) { + if( physics->CompressorGovernorLock ) { sCompressor.stop(); sCompressorIdle.play( sound_flags::exclusive | sound_flags::looping ); } @@ -187,7 +187,7 @@ void TDynamicObject::renderAuxiliarySounds() { } // Winger 160404 - dzwiek malej sprezarki - if( MoverParameters->PantCompFlag ) { + if( physics->PantCompFlag ) { sSmallCompressor.play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -196,13 +196,13 @@ void TDynamicObject::renderAuxiliarySounds() { // heater sound { - auto const isdieselenginepowered { MoverParameters->EngineType == TEngineType::DieselElectric || MoverParameters->EngineType == TEngineType::DieselEngine }; - if( true == MoverParameters->Heating + auto const isdieselenginepowered { physics->EngineType == TEngineType::DieselElectric || physics->EngineType == TEngineType::DieselEngine }; + if( true == physics->Heating && ( false == isdieselenginepowered - || std::abs(MoverParameters->enrot) > 0.01 ) ) { + || std::abs(physics->enrot) > 0.01 ) ) { sHeater .pitch( true == sHeater.is_combined() ? - std::abs( MoverParameters->enrot ) * 60.f * 0.01f : + std::abs( physics->enrot ) * 60.f * 0.01f : 1.f ) .play( sound_flags::exclusive | sound_flags::looping ); } @@ -212,7 +212,7 @@ void TDynamicObject::renderAuxiliarySounds() { } // battery sound - if( MoverParameters->Battery ) { + if( physics->Battery ) { m_batterysound.play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -233,7 +233,7 @@ void TDynamicObject::renderBrakeCylinderSounds( double const brakepressureratio } // actual sound playback auto const quantizedratio { static_cast( 15 * brakepressureratio ) }; - auto const lastbrakepressureratio { std::max( 0.f, m_lastbrakepressure ) / std::max( 1.0, MoverParameters->MaxBrakePress[ 3 ] ) }; + auto const lastbrakepressureratio { std::max( 0.f, m_lastbrakepressure ) / std::max( 1.0, physics->MaxBrakePress[ 3 ] ) }; auto const quantizedratiochange { quantizedratio - static_cast( 15 * lastbrakepressureratio ) }; if( quantizedratiochange > 0 ) { m_brakecylinderpistonadvance @@ -257,10 +257,10 @@ void TDynamicObject::renderBrakeCylinderSounds( double const brakepressureratio void TDynamicObject::renderEpBrakeSounds( double const dt ) { // epbrake - epcompact - if (MoverParameters->BrakeSystem == TBrakeSystem::ElectroPneumatic && MoverParameters->LocHandle) { - auto const epbrakepressureratio{ std::min( std::max( 0.0, MoverParameters->LocHandle->GetCP() ) / std::max( 1.0, MoverParameters->MaxBrakePress[0] ), + if (physics->BrakeSystem == TBrakeSystem::ElectroPneumatic && physics->LocHandle) { + auto const epbrakepressureratio{ std::min( std::max( 0.0, physics->LocHandle->GetCP() ) / std::max( 1.0, physics->MaxBrakePress[0] ), m_epbrakepressurechangedectimer > -1.0f ? - std::max( MoverParameters->LocalBrakePosAEIM, MoverParameters->Hamulec->GetEDBCP() / MoverParameters->MaxBrakePress[3]) : + std::max( physics->LocalBrakePosAEIM, physics->Hamulec->GetEDBCP() / physics->MaxBrakePress[3]) : 1.0 ) }; if ( m_lastepbrakepressure != -1.f ) { // HACK: potentially reset playback of opening bookend sounds @@ -274,7 +274,7 @@ void TDynamicObject::renderEpBrakeSounds( double const dt ) { m_epbrakepressurechangedectimer += dt; // actual sound playback auto const epquantizedratio{ static_cast( 50 * epbrakepressureratio) }; - auto const lastepbrakepressureratio { std::max( 0.f, m_lastepbrakepressure ) / std::max( 1.0, MoverParameters->MaxBrakePress[0] ) }; + auto const lastepbrakepressureratio { std::max( 0.f, m_lastepbrakepressure ) / std::max( 1.0, physics->MaxBrakePress[0] ) }; auto const epquantizedratiochange { epquantizedratio - static_cast( 50 * lastepbrakepressureratio ) }; if ( epquantizedratiochange > 0 && m_epbrakepressurechangeinctimer > 0.05f) { m_epbrakepressureincrease @@ -295,8 +295,8 @@ void TDynamicObject::renderEpBrakeSounds( double const dt ) { } } if ( m_epbrakepressurechangeinctimer == 0 || m_epbrakepressurechangedectimer == 0 ) - m_lastepbrakepressure = std::min( MoverParameters->LocHandle->GetCP(), - MoverParameters->LocalBrakePosAEIM * std::max( 1.0, MoverParameters->MaxBrakePress[0] ) ); + m_lastepbrakepressure = std::min( physics->LocHandle->GetCP(), + physics->LocalBrakePosAEIM * std::max( 1.0, physics->MaxBrakePress[0] ) ); } } @@ -304,17 +304,17 @@ void TDynamicObject::renderEpBrakeSounds( double const dt ) { void TDynamicObject::renderEmergencyBrakeSound() { // emergency brake - if( MoverParameters->EmergencyValveFlow > 0.025 ) { + if( physics->EmergencyValveFlow > 0.025 ) { // smooth out air flow rate - m_emergencybrakeflow = m_emergencybrakeflow == 0.0 ? MoverParameters->EmergencyValveFlow : std::lerp(m_emergencybrakeflow, MoverParameters->EmergencyValveFlow, 0.1); + m_emergencybrakeflow = m_emergencybrakeflow == 0.0 ? physics->EmergencyValveFlow : std::lerp(m_emergencybrakeflow, physics->EmergencyValveFlow, 0.1); // scale volume based on the flow rate and on the pressure in the main pipe - auto const flowpressure { std::clamp( m_emergencybrakeflow, 0.0, 1.0 ) + std::clamp( 0.1 * MoverParameters->PipePress, 0.0, 0.5 ) }; + auto const flowpressure { std::clamp( m_emergencybrakeflow, 0.0, 1.0 ) + std::clamp( 0.1 * physics->PipePress, 0.0, 0.5 ) }; m_emergencybrake .pitch( m_emergencybrake.m_frequencyoffset + 1.0 * m_emergencybrake.m_frequencyfactor ) .gain( m_emergencybrake.m_amplitudeoffset + std::clamp( flowpressure, 0.0, 1.0 ) * m_emergencybrake.m_amplitudefactor ) .play( sound_flags::exclusive | sound_flags::looping ); } - else if( MoverParameters->EmergencyValveFlow < 0.015 ) { + else if( physics->EmergencyValveFlow < 0.015 ) { m_emergencybrakeflow = 0.0; m_emergencybrake.stop(); } @@ -328,10 +328,10 @@ void TDynamicObject::renderAirReleaseSounds( double const dt, double const brake // air release if( m_lastbrakepressure != -1.f ) { // calculate rate of pressure drop in brake cylinder, once it's been initialized - auto const brakepressuredifference{ m_lastbrakepressure - MoverParameters->BrakePress }; + auto const brakepressuredifference{ m_lastbrakepressure - physics->BrakePress }; m_brakepressurechange = std::lerp( m_brakepressurechange, brakepressuredifference / dt, 0.05f ); } - m_lastbrakepressure = MoverParameters->BrakePress; + m_lastbrakepressure = physics->BrakePress; // ensure some basic level of volume and scale it up depending on pressure in the cylinder; scale this by the air release rate volume = rsUnbrake.m_amplitudefactor * m_brakepressurechange * ( 0.25 + 0.75 * brakepressureratio ); if( m_brakepressurechange > 0.05 && brakepressureratio > 0.05 ) { @@ -349,11 +349,11 @@ void TDynamicObject::renderAirReleaseSounds( double const dt, double const brake } // Dzwiek odluzniacza - if( MoverParameters->Hamulec->Releaser() ) { + if( physics->Hamulec->Releaser() ) { sReleaser .gain( std::clamp( - MoverParameters->BrakePress * 1.25, // arbitrary multiplier + physics->BrakePress * 1.25, // arbitrary multiplier 0., 1. ) ) .play( sound_flags::exclusive | sound_flags::looping ); } @@ -366,12 +366,12 @@ void TDynamicObject::renderAirReleaseSounds( double const dt, double const brake void TDynamicObject::renderSlipAndSandSounds() { // slipping wheels - if( MoverParameters->SlippingWheels ) { + if( physics->SlippingWheels ) { - if( MoverParameters->UnitBrakeForce > 100.0 + if( physics->UnitBrakeForce > 100.0 && GetVelocity() > 1.0 ) { - auto const velocitydifference{ GetVelocity() / MoverParameters->Vmax }; + auto const velocitydifference{ GetVelocity() / physics->Vmax }; rsSlippery .gain( rsSlippery.m_amplitudeoffset + rsSlippery.m_amplitudefactor * velocitydifference ) .play( sound_flags::exclusive | sound_flags::looping ); @@ -382,7 +382,7 @@ void TDynamicObject::renderSlipAndSandSounds() { } // Dzwiek piasecznicy - if( MoverParameters->SandDose ) { + if( physics->SandDose ) { sSand.play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -397,17 +397,17 @@ double TDynamicObject::renderBrakeFrictionSounds( double const dt ) { // brakes auto brakeforceratio{ 0.0 }; - if( //( false == mvOccupied->SlippingWheels ) && - MoverParameters->UnitBrakeForce > 10.0 - && MoverParameters->Vel > 0.05 ) { + if( //( false == occupied->SlippingWheels ) && + physics->UnitBrakeForce > 10.0 + && physics->Vel > 0.05 ) { brakeforceratio = std::clamp( - MoverParameters->UnitBrakeForce / std::max( 1.0, MoverParameters->BrakeForceR( 1.0, MoverParameters->Vel ) / ( MoverParameters->NAxles * std::max( 1, MoverParameters->NBpA ) ) ), + physics->UnitBrakeForce / std::max( 1.0, physics->BrakeForceR( 1.0, physics->Vel ) / ( physics->NAxles * std::max( 1, physics->NBpA ) ) ), 0.0, 1.0 ); rsBrake - .pitch( rsBrake.m_frequencyoffset + MoverParameters->Vel * rsBrake.m_frequencyfactor ) - .gain( rsBrake.m_amplitudeoffset + std::sqrt( brakeforceratio * std::lerp( 0.4, 1.0, MoverParameters->Vel / (1 + MoverParameters->Vmax) ) ) * rsBrake.m_amplitudefactor ) + .pitch( rsBrake.m_frequencyoffset + physics->Vel * rsBrake.m_frequencyfactor ) + .gain( rsBrake.m_amplitudeoffset + std::sqrt( brakeforceratio * std::lerp( 0.4, 1.0, physics->Vel / (1 + physics->Vmax) ) ) * rsBrake.m_amplitudefactor ) .play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -416,20 +416,20 @@ double TDynamicObject::renderBrakeFrictionSounds( double const dt ) { // yB: przyspieszacz (moze zadziala, ale dzwiek juz jest) if( true == bBrakeAcc ) { - if( true == TestFlag( MoverParameters->Hamulec->GetSoundFlag(), sf_Acc ) ) { + if( true == TestFlag( physics->Hamulec->GetSoundFlag(), sf_Acc ) ) { sBrakeAcc.play( sound_flags::exclusive ); } } // McZapkie-280302 - pisk mocno zacisnietych hamulcow - if( MoverParameters->Vel > 2.5 ) { + if( physics->Vel > 2.5 ) { volume = rsPisk.m_amplitudeoffset + std::lerp( -1.0, 1.0, brakeforceratio ) * rsPisk.m_amplitudefactor; if( volume > 0.075 ) { rsPisk .pitch( true == rsPisk.is_combined() ? - MoverParameters->Vel * 0.01f : + physics->Vel * 0.01f : rsPisk.m_frequencyoffset + rsPisk.m_frequencyfactor * 1.f ) .gain( volume ) .play( sound_flags::exclusive | sound_flags::looping ); @@ -451,8 +451,8 @@ double TDynamicObject::renderBrakeFrictionSounds( double const dt ) { void TDynamicObject::renderSpringBrakeSounds() { // spring brake - if( m_springbrakesounds.state != MoverParameters->SpringBrake.Activate ) { - m_springbrakesounds.state = MoverParameters->SpringBrake.Activate; + if( m_springbrakesounds.state != physics->SpringBrake.Activate ) { + m_springbrakesounds.state = physics->SpringBrake.Activate; if( m_springbrakesounds.state ) { m_springbrakesounds.activate.play( sound_flags::exclusive ); m_springbrakesounds.release.stop(); @@ -468,13 +468,13 @@ void TDynamicObject::renderSpringBrakeSounds() { void TDynamicObject::renderLoadExchangeSounds() { // load exchange - if( MoverParameters->LoadStatus & 1 ) { + if( physics->LoadStatus & 1 ) { m_exchangesounds.unloading.play( sound_flags::exclusive ); } else { m_exchangesounds.unloading.stop(); } - if( MoverParameters->LoadStatus & 2 ) { + if( physics->LoadStatus & 2 ) { m_exchangesounds.loading.play( sound_flags::exclusive ); } else { @@ -486,16 +486,16 @@ void TDynamicObject::renderLoadExchangeSounds() { void TDynamicObject::renderDepartureSignalSounds() { // NBMX sygnal odjazdu - if( MoverParameters->Doors.has_warning ) { - auto const lowvoltagepower { MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable }; + if( physics->Doors.has_warning ) { + auto const lowvoltagepower { physics->Power24vIsAvailable || physics->Power110vIsAvailable }; for( auto &doorspeaker : m_doorspeakers ) { // TBD, TODO: per-location door state triggers? - if( MoverParameters->DepartureSignal + if( physics->DepartureSignal && lowvoltagepower /* - || ( ( MoverParameters->DoorCloseCtrl = control::autonomous ) - && ( ( ( false == MoverParameters->DoorLeftOpened ) && ( dDoorMoveL > 0.0 ) ) - || ( ( false == MoverParameters->DoorRightOpened ) && ( dDoorMoveR > 0.0 ) ) ) ) + || ( ( physics->DoorCloseCtrl = control::autonomous ) + && ( ( ( false == physics->DoorLeftOpened ) && ( dDoorMoveL > 0.0 ) ) + || ( ( false == physics->DoorRightOpened ) && ( dDoorMoveR > 0.0 ) ) ) ) */ ) { // for the autonomous doors play the warning automatically whenever a door is closing @@ -514,7 +514,7 @@ void TDynamicObject::renderAnnouncementSounds() { // announcements { - auto const lowvoltagepower { MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable }; + auto const lowvoltagepower { physics->Power24vIsAvailable || physics->Power110vIsAvailable }; if( lowvoltagepower ) { // system is powered up, can play queued announcements if( false == m_pasystem.announcement_queue.empty() @@ -522,7 +522,7 @@ void TDynamicObject::renderAnnouncementSounds() { // pull first sound from the queue m_pasystem.announcement = m_pasystem.announcement_queue.front(); m_pasystem.announcement.owner( this ); - m_pasystem.announcement.range( 0.5 * MoverParameters->Dim.L * -1 ); + m_pasystem.announcement.range( 0.5 * physics->Dim.L * -1 ); if( m_pasystem.soundproofing ) { if( !m_pasystem.announcement.soundproofing() ) { m_pasystem.announcement.soundproofing() = m_pasystem.soundproofing; @@ -546,12 +546,12 @@ void TDynamicObject::renderDoorSounds() { auto const &sides { VehicleSides }; for( auto const side : sides ) { - auto const &door { MoverParameters->Doors.instances[ side ] }; + auto const &door { physics->Doors.instances[ side ] }; if( true == door.is_opening ) { // door sounds if( false == door.step_unfolding // no wait if no doorstep - || MoverParameters->Doors.step_type == 2 ) { // no wait for rotating doorstep + || physics->Doors.step_type == 2 ) { // no wait for rotating doorstep if( door.position < 0.5f ) { // safety measure, to keep slightly too short sounds from repeating for( auto &doorsounds : m_doorsounds ) { if( doorsounds.placement == side ) { @@ -597,7 +597,7 @@ void TDynamicObject::renderDoorSounds() { } } // door locks - if( MoverParameters->Doors.is_locked != m_doorlocks ) { + if( physics->Doors.is_locked != m_doorlocks ) { // toggle state of the locks... m_doorlocks = !m_doorlocks; // ...and play relevant sounds @@ -619,11 +619,11 @@ void TDynamicObject::renderHornSounds() { { // for moving vehicle combine regular horn activation flag with emergency brake horn activation flag, if the brake is active; // the horns without the air or the voltage they need stay silent - auto const warningsignal { MoverParameters->SoundingHorns( - ( MoverParameters->Vel > 0.5 && MoverParameters->AlarmChainFlag ? - MoverParameters->EmergencyBrakeWarningSignal : + auto const warningsignal { physics->SoundingHorns( + ( physics->Vel > 0.5 && physics->AlarmChainFlag ? + physics->EmergencyBrakeWarningSignal : 0 ) - | MoverParameters->WarningSignal ) }; + | physics->WarningSignal ) }; if( TestFlag( warningsignal, 1 ) ) { sHorn1.play( sound_flags::exclusive | sound_flags::looping ); @@ -672,16 +672,16 @@ void TDynamicObject::renderRunningNoise( double const brakeforceratio ) { // frequency calculation auto const normalizer { ( true == bogiesound.is_combined() ? - MoverParameters->Vmax * 0.01f : + physics->Vmax * 0.01f : 1.f ) }; frequency = bogiesound.m_frequencyoffset - + bogiesound.m_frequencyfactor * MoverParameters->Vel * normalizer; + + bogiesound.m_frequencyfactor * physics->Vel * normalizer; // volume calculation volume = bogiesound.m_amplitudeoffset - + bogiesound.m_amplitudefactor * MoverParameters->Vel; + + bogiesound.m_amplitudefactor * physics->Vel; if( brakeforceratio > 0.0 ) { // hamulce wzmagaja halas volume *= 1 + 0.125 * brakeforceratio; @@ -700,7 +700,7 @@ void TDynamicObject::renderRunningNoise( double const brakeforceratio ) { std::lerp( 0.0, 1.0, std::clamp( - MoverParameters->Vel / 40.0, + physics->Vel / 40.0, 0.0, 1.0 ) ); } switch( MyTrack->eEnvironment ) { @@ -760,13 +760,13 @@ void TDynamicObject::renderRunningNoise( double const brakeforceratio ) { void TDynamicObject::renderWheelFlatSound() { // flat spot sound - if( MoverParameters->CategoryFlag == 1 ) { + if( physics->CategoryFlag == 1 ) { // trains only if( GetVelocity() > 1.0 - && MoverParameters->WheelFlat > 5.0 ) { + && physics->WheelFlat > 5.0 ) { m_wheelflat - .pitch( m_wheelflat.m_frequencyoffset + std::abs( MoverParameters->nrot ) * m_wheelflat.m_frequencyfactor ) - .gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + MoverParameters->Vel / MoverParameters->Vmax + std::clamp( MoverParameters->WheelFlat / 60.0, 0.0, 1.0 ) ) / 3.0 ) ) + .pitch( m_wheelflat.m_frequencyoffset + std::abs( physics->nrot ) * m_wheelflat.m_frequencyfactor ) + .gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + physics->Vel / physics->Vmax + std::clamp( physics->WheelFlat / 60.0, 0.0, 1.0 ) ) / 3.0 ) ) .play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -781,16 +781,16 @@ void TDynamicObject::renderCurveSound() { auto volume{ 0.0 }; // youBy: dzwiek ostrych lukow i ciasnych zwrotek - if( MoverParameters->Vel > 5.0 + if( physics->Vel > 5.0 && ts.R * ts.R > 1.0 && std::abs(ts.R) < 15000.0 ) { // scale volume with curve radius and vehicle speed volume = - std::abs( MoverParameters->AccN ) // * MoverParameters->AccN + std::abs( physics->AccN ) // * physics->AccN * std::lerp( 0.5, 1.0, std::clamp( - MoverParameters->Vel / 40.0, + physics->Vel / 40.0, 0.0, 1.0 ) ) * ( MyTrack->eType == tt_Switch && std::abs(ts.R) < 1500.0 ? 100.0 : 1.0 ); } @@ -801,7 +801,7 @@ void TDynamicObject::renderCurveSound() { rscurve .pitch( true == rscurve.is_combined() ? - MoverParameters->Vel * 0.01f : + physics->Vel * 0.01f : rscurve.m_frequencyoffset + rscurve.m_frequencyfactor * 1.f ) .gain( 2.5 * volume ) .play( sound_flags::exclusive | sound_flags::looping ); @@ -817,7 +817,7 @@ void TDynamicObject::renderStartJoltSound() { // movement start jolt if( false == m_startjoltplayed ) { auto const velocity { GetVelocity() }; - if( ( MoverParameters->V > 0.0 ? MoverParameters->AccSVBased > 0.1 : MoverParameters->AccSVBased < 0.1 ) + if( ( physics->V > 0.0 ? physics->AccSVBased > 0.1 : physics->AccSVBased < 0.1 ) && velocity > 1.0 && velocity < 15.0 ) { m_startjolt.play( sound_flags::exclusive ); @@ -826,20 +826,20 @@ void TDynamicObject::renderStartJoltSound() { } } -// the sounds of the pneumatic relay and of the door permit, set in the sound flags of the mover -void TDynamicObject::renderMoverEventSounds() { +// the sounds of the pneumatic relay and of the door permit, set in the sound flags of the physics +void TDynamicObject::renderPhysicsEventSounds() { // pneumatic relay - if( TestFlag( MoverParameters->SoundFlag, sound::pneumatic ) ) { + if( TestFlag( physics->SoundFlag, sound::pneumatic ) ) { dsbPneumaticRelay .gain( - true == TestFlag( MoverParameters->SoundFlag, sound::loud ) ? + true == TestFlag( physics->SoundFlag, sound::loud ) ? 1.0f : 0.8f ) .play(); } // door permit - if( TestFlag( MoverParameters->SoundFlag, sound::doorpermit ) ) { + if( TestFlag( physics->SoundFlag, sound::doorpermit ) ) { // NOTE: current implementation doesn't discern between permit for left/right side, // which may be undesired in weird setups with doors only on one side // TBD, TODO: rework into dedicated sound event flag for each door location instance? @@ -856,7 +856,7 @@ void TDynamicObject::renderCouplerSounds() { int couplerindex { 0 }; for( auto &couplersounds : m_couplersounds ) { - auto &coupler { MoverParameters->Couplers[ couplerindex ] }; + auto &coupler { physics->Couplers[ couplerindex ] }; if( coupler.sounds == sound::none ) { ++couplerindex; @@ -972,7 +972,7 @@ void TDynamicObject::renderDerailmentSounds() { // physics.derailment new: off the track the vehicle scrapes along the ground until it stops, or until it is put back // on the rails (rerail()) while still sliding - if( MoverParameters->OffTrack.active() && false == MoverParameters->OffTrack.at_rest() ) { + if( physics->OffTrack.active() && false == physics->OffTrack.at_rest() ) { if( false == rsDerailment.is_playing() ) { rsDerailment.play( sound_flags::exclusive | sound_flags::looping ); } @@ -983,13 +983,13 @@ void TDynamicObject::renderDerailmentSounds() { } // special events - if( MoverParameters->EventFlag ) { + if( physics->EventFlag ) { // McZapkie: w razie wykolejenia - if( true == MoverParameters->DamageFlag.HasAll(VehicleDamage::derailed) ) { + if( true == physics->DamageFlag.HasAll(VehicleDamage::derailed) ) { rsDerailment.play( sound_flags::exclusive ); } - MoverParameters->EventFlag = false; + physics->EventFlag = false; } } @@ -997,8 +997,8 @@ void TDynamicObject::play_mirror_sounds( VehicleSide const Side, mirror_moves::e if( Event == mirror_moves::event::none ) { return; } // as UpdateMirror(), only the mirrors of the occupied cab move - if( MoverParameters->CabOccupied == 0 ) { return; } - auto const cabend { MoverParameters->CabOccupied > 0 ? VehicleEnd::front : VehicleEnd::rear }; + if( physics->CabOccupied == 0 ) { return; } + auto const cabend { physics->CabOccupied > 0 ? VehicleEnd::front : VehicleEnd::rear }; for( auto &mirror : m_mirrorsounds ) { if( mirror.placement != Side || mirror.end != cabend ) { continue; } auto &sound { Event == mirror_moves::event::unfolding ? mirror.unfold : mirror.fold }; @@ -1026,7 +1026,7 @@ TDynamicObject::powertrain_sounds::position( glm::vec3 const Location ) { } void -TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, double const Deltatime ) { +TDynamicObject::powertrain_sounds::render( physics::Vehicle const &Vehicle, double const Deltatime ) { if( Vehicle.Power == 0 ) { return; } @@ -1046,7 +1046,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // the sounds of the oil, fuel and water pumps and of the water heater void -TDynamicObject::powertrain_sounds::renderPumpSounds( TMoverParameters const &Vehicle ) { +TDynamicObject::powertrain_sounds::renderPumpSounds( physics::Vehicle const &Vehicle ) { // oil pump if( true == Vehicle.OilPump.is_active ) { @@ -1092,7 +1092,7 @@ TDynamicObject::powertrain_sounds::renderPumpSounds( TMoverParameters const &Veh // the sounds of the engine and the main circuit being switched on or off void -TDynamicObject::powertrain_sounds::renderIgnitionSounds( TMoverParameters const &Vehicle ) { +TDynamicObject::powertrain_sounds::renderIgnitionSounds( physics::Vehicle const &Vehicle ) { // engine sounds // ignition @@ -1130,7 +1130,7 @@ TDynamicObject::powertrain_sounds::renderIgnitionSounds( TMoverParameters const // the sounds of the running engine, of its revving and of the fake engine, and the smoothed engine volume void -TDynamicObject::powertrain_sounds::renderEngineSounds( TMoverParameters const &Vehicle, double const Deltatime ) { +TDynamicObject::powertrain_sounds::renderEngineSounds( physics::Vehicle const &Vehicle, double const Deltatime ) { double frequency { 1.0 }; double volume { 0.0 }; @@ -1258,7 +1258,7 @@ TDynamicObject::powertrain_sounds::renderEngineSounds( TMoverParameters const &V // the sound of the turbocharger void -TDynamicObject::powertrain_sounds::renderTurboSound( TMoverParameters const &Vehicle, double const Deltatime ) { +TDynamicObject::powertrain_sounds::renderTurboSound( physics::Vehicle const &Vehicle, double const Deltatime ) { double volume { 0.0 }; @@ -1293,7 +1293,7 @@ TDynamicObject::powertrain_sounds::renderTurboSound( TMoverParameters const &Veh // the sound of the slipping clutch void -TDynamicObject::powertrain_sounds::renderClutchSound( TMoverParameters const &Vehicle ) { +TDynamicObject::powertrain_sounds::renderClutchSound( physics::Vehicle const &Vehicle ) { double frequency { 1.0 }; double volume { 0.0 }; @@ -1304,7 +1304,7 @@ TDynamicObject::powertrain_sounds::renderClutchSound( TMoverParameters const &Ve volume = rsEngageSlippery.m_amplitudeoffset + rsEngageSlippery.m_amplitudefactor * Vehicle.diesel.clutchPressure; } else { - frequency = 1.f; // rsEngageSlippery.FA+0.7*rsEngageSlippery.FM*(fabs(mvControlled->enrot)+mvControlled->nmax); + frequency = 1.f; // rsEngageSlippery.FA+0.7*rsEngageSlippery.FM*(fabs(controlled->enrot)+controlled->nmax); volume = Vehicle.diesel.clutchPressure > 0.2 ? rsEngageSlippery.m_amplitudeoffset + 0.2 * rsEngageSlippery.m_amplitudefactor * (Vehicle.enrot / Vehicle.nmax) : 0.f; } @@ -1320,7 +1320,7 @@ TDynamicObject::powertrain_sounds::renderClutchSound( TMoverParameters const &Ve // the sound of the retarder void -TDynamicObject::powertrain_sounds::renderRetarderSound( TMoverParameters const &Vehicle ) { +TDynamicObject::powertrain_sounds::renderRetarderSound( physics::Vehicle const &Vehicle ) { if (Vehicle.retarder.present) { float speed = std::abs(Vehicle.retarder.revolutions); @@ -1340,7 +1340,7 @@ TDynamicObject::powertrain_sounds::renderRetarderSound( TMoverParameters const & // the sounds of the traction motors, the generic ones and the inverter-specific ones void -TDynamicObject::powertrain_sounds::renderTractionMotorSounds( TMoverParameters const &Vehicle, double const Deltatime ) { +TDynamicObject::powertrain_sounds::renderTractionMotorSounds( physics::Vehicle const &Vehicle, double const Deltatime ) { double frequency { 1.0 }; double volume { 0.0 }; @@ -1461,7 +1461,7 @@ TDynamicObject::powertrain_sounds::renderTractionMotorSounds( TMoverParameters c // the sounds of the motor blowers, each matched with the blower at its end of the vehicle void -TDynamicObject::powertrain_sounds::renderMotorBlowerSounds( TMoverParameters const &Vehicle ) { +TDynamicObject::powertrain_sounds::renderMotorBlowerSounds( physics::Vehicle const &Vehicle ) { // motor blowers if( false == motorblowers.empty() ) { @@ -1489,7 +1489,7 @@ TDynamicObject::powertrain_sounds::renderMotorBlowerSounds( TMoverParameters con // the sound of the inverter void -TDynamicObject::powertrain_sounds::renderInverterSound( TMoverParameters const &Vehicle ) { +TDynamicObject::powertrain_sounds::renderInverterSound( physics::Vehicle const &Vehicle ) { double volume { 0.0 }; @@ -1512,7 +1512,7 @@ TDynamicObject::powertrain_sounds::renderInverterSound( TMoverParameters const & // the sounds of the ventilator and of the radiator fans void -TDynamicObject::powertrain_sounds::renderFanSounds( TMoverParameters const &Vehicle ) { +TDynamicObject::powertrain_sounds::renderFanSounds( physics::Vehicle const &Vehicle ) { // ventillator sounds if( Vehicle.RventRot > 0.1 ) { @@ -1558,7 +1558,7 @@ TDynamicObject::powertrain_sounds::renderFanSounds( TMoverParameters const &Vehi // the sounds of the relays, set in the sound flags of the vehicle void -TDynamicObject::powertrain_sounds::renderRelaySounds( TMoverParameters const &Vehicle ) { +TDynamicObject::powertrain_sounds::renderRelaySounds( physics::Vehicle const &Vehicle ) { // relay sounds auto const soundflags { Vehicle.SoundFlag }; @@ -1608,7 +1608,7 @@ TDynamicObject::powertrain_sounds::renderRelaySounds( TMoverParameters const &Ve // the sound of the transmission void -TDynamicObject::powertrain_sounds::renderTransmissionSound( TMoverParameters const &Vehicle ) { +TDynamicObject::powertrain_sounds::renderTransmissionSound( physics::Vehicle const &Vehicle ) { if( Vehicle.Vel > 0.1 ) { transmission diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index ec942b9a7..7a3dee1b7 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -83,7 +83,7 @@ bool TDynamicObject::Update(double dt, double dt1) vehicle->m_offtrackupdatedue -= frame; if( took > off_track_slow && vehicle->m_offtrackupdatedue <= 0.0 ) { vehicle->m_offtrackupdatedue = 1.0; - ErrorLog( std::format( "derailment: warning: the update of {} off the track took {:.0f} ms in a frame of {:.3f} s", vehicle->MoverParameters->Name, took * 1000.0, frame ) ); + ErrorLog( std::format( "derailment: warning: the update of {} off the track took {:.0f} ms in a frame of {:.3f} s", vehicle->physics->Name, took * 1000.0, frame ) ); } } private: @@ -91,17 +91,17 @@ bool TDynamicObject::Update(double dt, double dt1) double frame; off_track_clock::time_point started {}; }; - off_track_watch const watch { MoverParameters->OffTrack.active() ? this : nullptr, dt1 }; - if( m_offtrackterrain != nullptr && false == MoverParameters->OffTrack.active() ) { + off_track_watch const watch { physics->OffTrack.active() ? this : nullptr, dt1 }; + if( m_offtrackterrain != nullptr && false == physics->OffTrack.active() ) { // physics.derailment new: back on the rails (rerail()), the terrain it slid over is let go m_offtrackterrain.reset(); m_offtracksite.terrain( nullptr ); } - if (!MoverParameters->PhysicActivation && + if (!physics->PhysicActivation && !MechInside) { // to drugie, bo będąc w maszynowym blokuje się fizyka // physics.derailment new: a vehicle off the track stopped along its heading still settles: it slides down a // slope, falls over, or comes to rest after the step its physics stopped in - if( MoverParameters->OffTrack.active() && false == MoverParameters->OffTrack.at_rest() && bEnabled ) { + if( physics->OffTrack.active() && false == physics->OffTrack.at_rest() && bEnabled ) { m_offtracktime = dt1; Move( 0.0 ); update_off_track( dt1 ); @@ -139,20 +139,20 @@ bool TDynamicObject::Update(double dt, double dt1) updateAxleClatter( dDOMoveLen ); // fragment z EXE Kursa - /* if (MoverParameters->TrainType==train_type::et42) + /* if (physics->TrainType==train_type::et42) { - if ((MoverParameters->DynamicBrakeType=dbrake_switch) && - ((MoverParameters->BrakePress > - 0.2) || ( MoverParameters->PipePress < 0.36 ))) + if ((physics->DynamicBrakeType=dbrake_switch) && + ((physics->BrakePress > + 0.2) || ( physics->PipePress < 0.36 ))) { - MoverParameters->StLinFlag=true; + physics->StLinFlag=true; } else - if ((MoverParameters->DynamicBrakeType=dbrake_switch) && - (MoverParameters->BrakePress < + if ((physics->DynamicBrakeType=dbrake_switch) && + (physics->BrakePress < 0.1)) { - MoverParameters->StLinFlag=false; + physics->StLinFlag=false; } } */ @@ -164,19 +164,19 @@ bool TDynamicObject::Update(double dt, double dt1) // compartment lights // if the vehicle has a controller, we base the light state on state of the controller otherwise we check the vehicle itself - if( ctOwner != nullptr ? SectionLightsActive != MoverParameters->CompartmentLights.is_active : - Mechanik != nullptr ? SectionLightsActive != MoverParameters->CompartmentLights.is_active : + if( ctOwner != nullptr ? SectionLightsActive != physics->CompartmentLights.is_active : + Mechanik != nullptr ? SectionLightsActive != physics->CompartmentLights.is_active : SectionLightsActive ) { // without controller switch the lights off toggle_lights(); } - if (MoverParameters->InactiveCabPantsCheck) + if (physics->InactiveCabPantsCheck) { pants_up(); - MoverParameters->InactiveCabPantsCheck = false; + physics->InactiveCabPantsCheck = false; } - if( MoverParameters->LoadStatus ) { + if( physics->LoadStatus ) { LoadUpdate(); // zmiana modelu ładunku } update_exchange( dt ); @@ -202,7 +202,7 @@ void TDynamicObject::updateTrackParameters() if( ts.R != 0.0 ) { // sin(0) results in division by zero - ts.R = -0.5 * MoverParameters->BDist / sin( ts.R * 0.5 ); + ts.R = -0.5 * physics->BDist / sin( ts.R * 0.5 ); } } } @@ -211,7 +211,7 @@ void TDynamicObject::updateTrackParameters() // ts.R=ComputeRadius(Axle1.pPosition,Axle2.pPosition,Axle3.pPosition,Axle0.pPosition); // Ra: składową pochylenia wzdłużnego mamy policzoną w jednostkowym wektorze // vFront - ts.Len = 1.0; // std::max(MoverParameters->BDist,MoverParameters->ADist); + ts.Len = 1.0; // std::max(physics->BDist,physics->ADist); ts.dHtrack = -vFront.y; // Axle1.pPosition.y-Axle0.pPosition.y; //wektor // między skrajnymi osiami // (!!!odwrotny) @@ -220,7 +220,7 @@ void TDynamicObject::updateTrackParameters() ts.uneven_curvature = glm::dot( 0.5 * ( Axle0.UnevenBend() + Axle1.UnevenBend() ), vLeft ); ts.uneven_cross = MyTrack->uneven_underway().cross; // a buckle of the track under the body: the mean of the curvatures at the outer axles, each over the wheelbase of its bogie - ts.buckle_curvature = 0.5 * ( Axle0.BuckleCurvature( MoverParameters->ADist ) + Axle1.BuckleCurvature( MoverParameters->ADist ) ); + ts.buckle_curvature = 0.5 * ( Axle0.BuckleCurvature( physics->ADist ) + Axle1.BuckleCurvature( physics->ADist ) ); // TTrackParam tp; tp.Width = MyTrack->fTrackWidth; // McZapkie-250202 @@ -235,19 +235,19 @@ void TDynamicObject::updateTrackParameters() void TDynamicObject::updateCouplingState() { // couplers - if( MoverParameters->Couplers[0].CouplingFlag != Coupling::none - && MoverParameters->Couplers[1].CouplingFlag != Coupling::none ) { - MoverParameters->InsideConsist = true; + if( physics->Couplers[0].CouplingFlag != Coupling::none + && physics->Couplers[1].CouplingFlag != Coupling::none ) { + physics->InsideConsist = true; } else { - MoverParameters->InsideConsist = false; + physics->InsideConsist = false; } - if( TestFlag( MoverParameters->AIFlag, sound::attachcoupler ) ) { + if( TestFlag( physics->AIFlag, sound::attachcoupler ) ) { auto *driver{ ctOwner ? ctOwner : Mechanik }; if( driver != nullptr ) { driver->CheckVehicles( DriverOrder::connect ); } - ClearFlag( MoverParameters->AIFlag, sound::attachcoupler ); + ClearFlag( physics->AIFlag, sound::attachcoupler ); } } @@ -255,9 +255,9 @@ void TDynamicObject::updateCouplingState() void TDynamicObject::updateTractionVoltage( double const dt1 ) { // napiecie sieci trakcyjnej - if (MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { // dla EZT tylko silnikowy + if (physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { // dla EZT tylko silnikowy - tmpTraction.TractionVoltage = std::max( std::abs( MoverParameters->PantRearVolt ), std::abs( MoverParameters->PantFrontVolt ) ); + tmpTraction.TractionVoltage = std::max( std::abs( physics->PantRearVolt ), std::abs( physics->PantFrontVolt ) ); // jeśli brak zasilania dłużej niż 0.2 sekundy (25km/h pod izolatorem daje 0.15s) // Ra 2F1H: prowizorka, trzeba przechować napięcie, żeby nie wywalało WS pod izolatorem if( tmpTraction.TractionVoltage > 0.0) { @@ -266,20 +266,20 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) else { NoVoltTime += dt1; if( NoVoltTime <= 0.2 ) { - tmpTraction.TractionVoltage = MoverParameters->PantographVoltage; + tmpTraction.TractionVoltage = physics->PantographVoltage; } else { // jeśli jedzie - if( MoverParameters->Vel > 0.5 ) { + if( physics->Vel > 0.5 ) { // Ra 2014-07: doraźna blokada logowania zimnych lokomotyw - zrobić to trzeba inaczej - if( MoverParameters->Pantographs[VehicleEnd::front].is_active - || MoverParameters->Pantographs[VehicleEnd::rear].is_active ) { - if( MoverParameters->Mains // Ra 15-01: logować tylko, jeśli WS załączony - && MoverParameters->GetTrainsetHighVoltage() < 0.1f // yB 16-03: i nie jest to asynchron zasilany z daleka - && false == MoverParameters->GensetSelected() ) { // nor a dual-mode vehicle running on its genset + if( physics->Pantographs[VehicleEnd::front].is_active + || physics->Pantographs[VehicleEnd::rear].is_active ) { + if( physics->Mains // Ra 15-01: logować tylko, jeśli WS załączony + && physics->GetTrainsetHighVoltage() < 0.1f // yB 16-03: i nie jest to asynchron zasilany z daleka + && false == physics->GensetSelected() ) { // nor a dual-mode vehicle running on its genset // Ra 15-01: bezwzględne współrzędne pantografu nie są dostępne więc lepiej się tego nie zaloguje ErrorLog( - "Bad traction: " + MoverParameters->Name + "Bad traction: " + physics->Name + " lost power for " + to_string( NoVoltTime, 2 ) + " sec. at " + to_string(vPosition) ); } @@ -289,33 +289,33 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) } } else { - tmpTraction.TractionVoltage = 0.95 * MoverParameters->EnginePowerSource.MaxVoltage; + tmpTraction.TractionVoltage = 0.95 * physics->EnginePowerSource.MaxVoltage; } tmpTraction.TractionFreq = 0; tmpTraction.TractionMaxCurrent = 7500; // Ra: chyba za dużo? powinno wywalać przy 1500 tmpTraction.TractionResistivity = 0.3; - MoverParameters->PantographVoltage = tmpTraction.TractionVoltage; + physics->PantographVoltage = tmpTraction.TractionVoltage; } // the driver of the vehicle: the integrated controller, the brakes blended over a consist with induction motors, the AI void TDynamicObject::updateDriver( double const dt1 ) { if( Mechanik->primary() ) { - MoverParameters->EqvtPipePress = GetEPP(); // srednie cisnienie w PG + physics->EqvtPipePress = GetEPP(); // srednie cisnienie w PG } if (Mechanik->primary() && - (MoverParameters->EngineType == TEngineType::DieselEngine || - MoverParameters->EngineType == TEngineType::DieselElectric) - && MoverParameters->EIMCtrlType > 0) { - MoverParameters->CheckEIMIC(dt1); - if (MoverParameters->SpeedCtrl) - MoverParameters->CheckSpeedCtrl(dt1); - MoverParameters->eimic_real = std::min(MoverParameters->eimic,MoverParameters->eimicSpeedCtrl); - MoverParameters->SendCtrlToNext(VehicleCommand::integratedController, MoverParameters->eimic_real, MoverParameters->CabActive); + (physics->EngineType == TEngineType::DieselEngine || + physics->EngineType == TEngineType::DieselElectric) + && physics->EIMCtrlType > 0) { + physics->CheckEIMIC(dt1); + if (physics->SpeedCtrl) + physics->CheckSpeedCtrl(dt1); + physics->eimic_real = std::min(physics->eimic,physics->eimicSpeedCtrl); + physics->SendCtrlToNext(VehicleCommand::integratedController, physics->eimic_real, physics->CabActive); } if( Mechanik->primary() - && MoverParameters->EngineType == TEngineType::ElectricInductionMotor ) { + && physics->EngineType == TEngineType::ElectricInductionMotor ) { // jesli glowny i z asynchronami, to niech steruje hamulcem i napedem lacznie dla calego pociagu/ezt distributeInductionBraking( dt1 ); } @@ -351,7 +351,7 @@ struct TDynamicObject::InductionBrakeState { void TDynamicObject::distributeInductionBraking( double const dt1 ) { InductionBrakeState state; - state.kier = DirectionGet() * MoverParameters->CabOccupied > 0; + state.kier = DirectionGet() * physics->CabOccupied > 0; setInductionControl( state, dt1 ); sumConsistBrakeForces( state ); computeBrakeDeceleration( state ); @@ -369,23 +369,23 @@ void TDynamicObject::distributeInductionBraking( double const dt1 ) void TDynamicObject::setInductionControl( InductionBrakeState &state, double const dt1 ) { // 0a. ustal aktualna nastawe zadania sily napedowej i hamowania - if( MoverParameters->Power < 1 + if( physics->Power < 1 && ctOwner != nullptr ) { - MoverParameters->MainCtrlPos = ctOwner->Controlling()->MainCtrlPos*MoverParameters->MainCtrlPosNo / std::max(1, ctOwner->Controlling()->MainCtrlPosNo); - MoverParameters->SpeedCtrlValue = ctOwner->Controlling()->SpeedCtrlValue; - MoverParameters->SpeedCtrlUnit.IsActive = ctOwner->Controlling()->SpeedCtrlUnit.IsActive; + physics->MainCtrlPos = ctOwner->Controlling()->MainCtrlPos*physics->MainCtrlPosNo / std::max(1, ctOwner->Controlling()->MainCtrlPosNo); + physics->SpeedCtrlValue = ctOwner->Controlling()->SpeedCtrlValue; + physics->SpeedCtrlUnit.IsActive = ctOwner->Controlling()->SpeedCtrlUnit.IsActive; } - MoverParameters->CheckEIMIC(dt1); - MoverParameters->CheckSpeedCtrl(dt1); + physics->CheckEIMIC(dt1); + physics->CheckSpeedCtrl(dt1); - state.eimic = std::min(MoverParameters->eimic, MoverParameters->eimicSpeedCtrl); - MoverParameters->eimic_real = state.eimic; + state.eimic = std::min(physics->eimic, physics->eimicSpeedCtrl); + physics->eimic_real = state.eimic; // Elf: full braking at once in the lowest position, and in the emergency brake position below it - if (MoverParameters->EIMCtrlType == 2 && MoverParameters->MainCtrlPos <= MoverParameters->EIMCtrlEmergencyPositions()) + if (physics->EIMCtrlType == 2 && physics->MainCtrlPos <= physics->EIMCtrlEmergencyPositions()) state.eimic = -1.0; - MoverParameters->SendCtrlToNext(VehicleCommand::integratedController, std::max(0., state.eimic), MoverParameters->CabActive); + physics->SendCtrlToNext(VehicleCommand::integratedController, std::max(0., state.eimic), physics->CabActive); state.LBR = std::max(-state.eimic, 0.); - state.eim_lb = Mechanik->AIControllFlag || !MoverParameters->LocHandleTimeTraxx ? 0 : MoverParameters->eim_localbrake; + state.eim_lb = Mechanik->AIControllFlag || !physics->LocHandleTimeTraxx ? 0 : physics->eim_localbrake; } // steps 1-2 of the blending: the masses and the most braking forces, pneumatic and ED, summed over the consist @@ -401,39 +401,39 @@ void TDynamicObject::sumConsistBrakeForces( InductionBrakeState &state ) // 2. ustal mozliwa do realizacji sile hamowania ED // - w szczegolnosci powinien brac pod uwage rozne sily hamowania - for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; + for (TDynamicObject *p = GetFirstDynamic(physics->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; state.kier ? p = p->Next(Coupling::control) : p = p->Prev(Coupling::control)) { ++state.np; state.masamax += - p->MoverParameters->MBPM - + ( p->MoverParameters->MBPM > 1.0 ? + p->physics->MBPM + + ( p->physics->MBPM > 1.0 ? 0.0 : - p->MoverParameters->Mass ) - + p->MoverParameters->Mred; - auto const Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - - p->MoverParameters->BrakeCylSpring) * - p->MoverParameters->BrakeCylMult[0] - - p->MoverParameters->BrakeSlckAdj) * - p->MoverParameters->BrakeCylNo * p->MoverParameters->BrakeRigEff; - state.FmaxPN += Nmax * p->MoverParameters->Hamulec->GetFC( - Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), - p->MoverParameters->MED_Vref) * + p->physics->Mass ) + + p->physics->Mred; + auto const Nmax = ((p->physics->P2FTrans * p->physics->MaxBrakePress[0] - + p->physics->BrakeCylSpring) * + p->physics->BrakeCylMult[0] - + p->physics->BrakeSlckAdj) * + p->physics->BrakeCylNo * p->physics->BrakeRigEff; + state.FmaxPN += Nmax * p->physics->Hamulec->GetFC( + Nmax / (p->physics->NAxles * p->physics->NBpA), + p->physics->MED_Vref) * 1000; // sila hamowania pn - state.FmaxED += p->MoverParameters->Mains && p->MoverParameters->DirActive != 0 && p->MoverParameters->inductionMotor.inverterRatio == 1.0 && - p->MoverParameters->inductionMotor.braking.maxForce * p->MoverParameters->NPoweredAxles > 0 ? - p->MoverParameters->inductionMotor.braking.maxForce * 1000 : + state.FmaxED += p->physics->Mains && p->physics->DirActive != 0 && p->physics->inductionMotor.inverterRatio == 1.0 && + p->physics->inductionMotor.braking.maxForce * p->physics->NPoweredAxles > 0 ? + p->physics->inductionMotor.braking.maxForce * 1000 : 0; // chwilowy max ED -> do rozdzialu sil - FED -= std::min(p->MoverParameters->inductionMotor.state.maxForce, 0.0) * + FED -= std::min(p->physics->inductionMotor.state.maxForce, 0.0) * 1000; // chwilowy max ED -> do rozdzialu sil - state.FfulED = std::min(p->MoverParameters->inductionMotor.state.fullForce, 0.0) * + state.FfulED = std::min(p->physics->inductionMotor.state.fullForce, 0.0) * 1000; // chwilowy max ED -> do rozdzialu sil - state.FrED -= std::min(p->MoverParameters->inductionMotor.state.maxForce, 0.0) * + state.FrED -= std::min(p->physics->inductionMotor.state.maxForce, 0.0) * 1000; // chwilowo realizowane ED -> do pneumatyki - Frj += std::max(p->MoverParameters->inductionMotor.state.maxForce, 0.0) * + Frj += std::max(p->physics->inductionMotor.state.maxForce, 0.0) * 1000;// chwilowo realizowany napęd -> do utrzymującego - state.masa += p->MoverParameters->TotalMass; - state.osie += p->MoverParameters->NAxles; + state.masa += p->physics->TotalMass; + state.osie += p->physics->NAxles; } } @@ -441,11 +441,11 @@ void TDynamicObject::sumConsistBrakeForces( InductionBrakeState &state ) void TDynamicObject::computeBrakeDeceleration( InductionBrakeState &state ) { double RapidMult = 1.0; - if ((MoverParameters->BrakeDelays & bdelay_P + bdelay_R) == bdelay_P + bdelay_R - && MoverParameters->BrakeDelayFlag & bdelay_P) - RapidMult = MoverParameters->RapidMult; + if ((physics->BrakeDelays & bdelay_P + bdelay_R) == bdelay_P + bdelay_R + && physics->BrakeDelayFlag & bdelay_P) + RapidMult = physics->RapidMult; - state.amax = RapidMult * std::min(state.FmaxPN / state.masamax, MoverParameters->MED_amax); + state.amax = RapidMult * std::min(state.FmaxPN / state.masamax, physics->MED_amax); Mechanik->fMedAmax = state.amax; } @@ -454,26 +454,26 @@ void TDynamicObject::computeBrakeDeceleration( InductionBrakeState &state ) void TDynamicObject::updateShuntMode( InductionBrakeState &state ) { state.doorisopen = - false == MoverParameters->Doors.instances[VehicleSide::left].is_closed - || false == MoverParameters->Doors.instances[VehicleSide::right].is_closed - || ( MoverParameters->Doors.permit_needed - && ( MoverParameters->Doors.instances[ VehicleSide::left ].open_permit - || MoverParameters->Doors.instances[ VehicleSide::right ].open_permit ) ); - state.doorisopen &= !(MoverParameters->ReleaseParkingBySpringBrakeWhenDoorIsOpen && MoverParameters->SpringBrake.IsActive); + false == physics->Doors.instances[VehicleSide::left].is_closed + || false == physics->Doors.instances[VehicleSide::right].is_closed + || ( physics->Doors.permit_needed + && ( physics->Doors.instances[ VehicleSide::left ].open_permit + || physics->Doors.instances[ VehicleSide::right ].open_permit ) ); + state.doorisopen &= !(physics->ReleaseParkingBySpringBrakeWhenDoorIsOpen && physics->SpringBrake.IsActive); - if (MoverParameters->Vel < 0.5 && (state.eimic < 0 || state.doorisopen || MoverParameters->Hamulec->GetEDBCP())) + if (physics->Vel < 0.5 && (state.eimic < 0 || state.doorisopen || physics->Hamulec->GetEDBCP())) { - MoverParameters->ShuntMode = true; + physics->ShuntMode = true; } - if (MoverParameters->ShuntMode) + if (physics->ShuntMode) { - MoverParameters->ShuntModeAllow = false == state.doorisopen && + physics->ShuntModeAllow = false == state.doorisopen && state.LBR < 0.01; } - if( MoverParameters->Vel > 1 && false == state.doorisopen ) + if( physics->Vel > 1 && false == state.doorisopen ) { - MoverParameters->ShuntMode = false; - MoverParameters->ShuntModeAllow = MoverParameters->BrakePress > 0.2 && + physics->ShuntMode = false; + physics->ShuntModeAllow = physics->BrakePress > 0.2 && state.LBR < 0.01; } } @@ -481,21 +481,21 @@ void TDynamicObject::updateShuntMode( InductionBrakeState &state ) void TDynamicObject::computeBrakeDemand( InductionBrakeState &state, double const dt1 ) { state.Fzad = state.amax * state.LBR * state.masa; - if ((MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB) - && MoverParameters->inductionMotor.braking.cylinderPressureGain < 0.001) || - MoverParameters->EmergencyValveFlow > 0) + if ((physics->BrakeCtrlPos == physics->Handle->GetPos(bh_EB) + && physics->inductionMotor.braking.cylinderPressureGain < 0.001) || + physics->EmergencyValveFlow > 0) state.Fzad = state.amax * state.masa; //pętla bezpieczeństwa - pełne służbowe - if (MoverParameters->ScndS && - MoverParameters->Vel > MoverParameters->inductionMotor.braking.fullSpeed && state.FmaxED > 0) + if (physics->ScndS && + physics->Vel > physics->inductionMotor.braking.fullSpeed && state.FmaxED > 0) { state.Fzad = std::min(state.LBR * state.FmaxED, state.FfulED); } // the holding brake lets go once power has been demanded for its delay (SBDReleaseDelay, none by default) - auto const holdingbrakereleased { MoverParameters->UpdateStopBrakeRelease( state.eimic, dt1 ) }; - if (MoverParameters->ShuntMode && false == holdingbrakereleased || state.doorisopen /*|| - (MoverParameters->V * MoverParameters->DirAbsolute < -0.2)*/) + auto const holdingbrakereleased { physics->UpdateStopBrakeRelease( state.eimic, dt1 ) }; + if (physics->ShuntMode && false == holdingbrakereleased || state.doorisopen /*|| + (physics->V * physics->DirAbsolute < -0.2)*/) { - auto const sbd { ( MoverParameters->SpringBrake.IsActive && MoverParameters->ReleaseParkingBySpringBrake ? 0.0 : MoverParameters->StopBrakeDecc ) }; + auto const sbd { ( physics->SpringBrake.IsActive && physics->ReleaseParkingBySpringBrake ? 0.0 : physics->StopBrakeDecc ) }; state.Fzad = std::max( state.Fzad, sbd * state.masa ); } } @@ -503,10 +503,10 @@ void TDynamicObject::computeBrakeDemand( InductionBrakeState &state, double cons // the log of the braking of the consist opened, once it brakes while moving void TDynamicObject::openMedLog( InductionBrakeState const &state ) { - if (state.Fzad > 1 && !MEDLogFile.is_open() && MoverParameters->Vel > 1) + if (state.Fzad > 1 && !MEDLogFile.is_open() && physics->Vel > 1) { MEDLogFile.open( - "MEDLOGS/" + MoverParameters->Name + "_" + std::to_string( ++MEDLogCount ) + ".csv", + "MEDLOGS/" + physics->Name + "_" + std::to_string( ++MEDLogCount ) + ".csv", std::ios::in | std::ios::out | std::ios::trunc ); MEDLogFile << "t\tVel\tMasa\tOsie\tFmaxPN\tFmaxED\tFfulED\tFrED\tFzad\tFzadED\tFzadPN"; for(int k=1;k<=state.np;k++) @@ -524,23 +524,23 @@ void TDynamicObject::openMedLog( InductionBrakeState const &state ) void TDynamicObject::computeElectrodynamicDemand( InductionBrakeState &state, double const dt1 ) { state.FzadED = 0.0; - if( state.LBR > MoverParameters->MED_MinBrakeReqED - && ( MoverParameters->BrakeHandle == TBrakeHandle::MHZ_EN57 ? - (MoverParameters->BrakeOpModeFlag & bom_MED) != 0 : - MoverParameters->EpFuse ) ) { + if( state.LBR > physics->MED_MinBrakeReqED + && ( physics->BrakeHandle == TBrakeHandle::MHZ_EN57 ? + (physics->BrakeOpModeFlag & bom_MED) != 0 : + physics->EpFuse ) ) { state.FzadED = std::min( state.Fzad, state.FmaxED ); } /*/ELF - wdrazanie ED po powrocie na utrzymanie hamowania - do usuniecia - if (MoverParameters->EIMCtrlType == 2 && MoverParameters->MainCtrlPos < 2 && MoverParameters->eimic > -0.999) + if (physics->EIMCtrlType == 2 && physics->MainCtrlPos < 2 && physics->eimic > -0.999) { FzadED = std::min(FzadED, MED_oldFED); } //*/ //opoznienie wdrazania ED if (state.FzadED > MED_oldFED) { - if (MoverParameters->MED_ED_DelayTimer <= 0) { - MoverParameters->MED_ED_DelayTimer += dt1; - if (MoverParameters->MED_ED_DelayTimer > 0) { + if (physics->MED_ED_DelayTimer <= 0) { + physics->MED_ED_DelayTimer += dt1; + if (physics->MED_ED_DelayTimer > 0) { } else { @@ -550,13 +550,13 @@ void TDynamicObject::computeElectrodynamicDemand( InductionBrakeState &state, do else { state.FzadED = std::min(state.FzadED, MED_oldFED); - MoverParameters->MED_ED_DelayTimer = state.FrED > 0 ? -MoverParameters->MED_ED_Delay2 : -MoverParameters->MED_ED_Delay1; + physics->MED_ED_DelayTimer = state.FrED > 0 ? -physics->MED_ED_Delay2 : -physics->MED_ED_Delay1; } } - if (MoverParameters->BrakeCtrlPos == MoverParameters->Handle->GetPos(bh_EB) - && MoverParameters->inductionMotor.braking.cylinderPressureGain < 0.001) + if (physics->BrakeCtrlPos == physics->Handle->GetPos(bh_EB) + && physics->inductionMotor.braking.cylinderPressureGain < 0.001) state.FzadED = 0; //pętla bezpieczeństwa - bez ED - state.FzadPN = state.Fzad - state.FrED * MoverParameters->MED_FrED_factor; + state.FzadPN = state.Fzad - state.FrED * physics->MED_FrED_factor; } // steps 3-6 of the blending: the ED and the pneumatic braking forces set to the vehicles of the consist void TDynamicObject::distributeBrakeForces( InductionBrakeState &state, double const dt1 ) @@ -577,49 +577,49 @@ void TDynamicObject::distributeBrakeForces( InductionBrakeState &state, double c // 6. ustaw pojazdom sile hamowania ep // - proporcjonalnie do masy, do liczby osi, rowne cisnienia - jak // bedzie, tak bedzie dobrze - float Fpoj = 0; // MoverParameters->CabOccupied < 0 + float Fpoj = 0; // physics->CabOccupied < 0 ////ALGORYTM 2 - KAZDEMU PO ROWNO, ale nie wiecej niz eped * masa // 1. najpierw daj kazdemu tyle samo int i = 0; - for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; + for (TDynamicObject *p = GetFirstDynamic(physics->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; p = state.kier == true ? p->Next(Coupling::control) : p->Prev(Coupling::control) ) { - auto const Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - - p->MoverParameters->BrakeCylSpring) * - p->MoverParameters->BrakeCylMult[0] - - p->MoverParameters->BrakeSlckAdj) * - p->MoverParameters->BrakeCylNo * p->MoverParameters->BrakeRigEff; + auto const Nmax = ((p->physics->P2FTrans * p->physics->MaxBrakePress[0] - + p->physics->BrakeCylSpring) * + p->physics->BrakeCylMult[0] - + p->physics->BrakeSlckAdj) * + p->physics->BrakeCylNo * p->physics->BrakeRigEff; FmaxEP[i] = Nmax * - p->MoverParameters->Hamulec->GetFC( - Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), - p->MoverParameters->MED_Vref) * + p->physics->Hamulec->GetFC( + Nmax / (p->physics->NAxles * p->physics->NBpA), + p->physics->MED_Vref) * 1000; // sila hamowania pn PrzekrF[i] = false; FzED[i] = state.FmaxED > 0 ? state.FzadED / state.FmaxED : 0; - p->MoverParameters->AnPos = - MoverParameters->ScndS ? state.LBR : FzED[i]; - FzEP[ i ] = static_cast( state.FzadPN * p->MoverParameters->NAxles ) / static_cast( state.osie ); + p->physics->AnPos = + physics->ScndS ? state.LBR : FzED[i]; + FzEP[ i ] = static_cast( state.FzadPN * p->physics->NAxles ) / static_cast( state.osie ); ++i; - p->MoverParameters->ShuntMode = MoverParameters->ShuntMode; - p->MoverParameters->ShuntModeAllow = MoverParameters->ShuntModeAllow; + p->physics->ShuntMode = physics->ShuntMode; + p->physics->ShuntModeAllow = physics->ShuntModeAllow; } while (test) { test = false; i = 0; float przek = 0; - for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; + for (TDynamicObject *p = GetFirstDynamic(physics->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; p = state.kier == true ? p->Next(Coupling::control) : p->Prev(Coupling::control) ) { if (FzEP[i] > 0.01 && - FzEP[i] > p->MoverParameters->TotalMass * p->MoverParameters->inductionMotor.braking.maxEpDeceleration + std::min(p->MoverParameters->inductionMotor.state.maxForce, 0.) * 1000 && + FzEP[i] > p->physics->TotalMass * p->physics->inductionMotor.braking.maxEpDeceleration + std::min(p->physics->inductionMotor.state.maxForce, 0.) * 1000 && !PrzekrF[i]) { - float przek1 = -std::min(p->MoverParameters->inductionMotor.state.maxForce, 0.) * 1000 + + float przek1 = -std::min(p->physics->inductionMotor.state.maxForce, 0.) * 1000 + FzEP[i] - - p->MoverParameters->TotalMass * - p->MoverParameters->inductionMotor.braking.maxEpDeceleration * 0.999; + p->physics->TotalMass * + p->physics->inductionMotor.braking.maxEpDeceleration * 0.999; PrzekrF[i] = true; test = true; state.nPrzekrF++; @@ -633,7 +633,7 @@ void TDynamicObject::distributeBrakeForces( InductionBrakeState &state, double c } i = 0; przek = przek / (state.np - state.nPrzekrF); - for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; + for (TDynamicObject *p = GetFirstDynamic(physics->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; true == state.kier ? p = p->Next(Coupling::control) : p = p->Prev(Coupling::control)) { if (!PrzekrF[i]) @@ -644,42 +644,42 @@ void TDynamicObject::distributeBrakeForces( InductionBrakeState &state, double c } } i = 0; - for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; + for (TDynamicObject *p = GetFirstDynamic(physics->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; true == state.kier ? p = p->Next(Coupling::control) : p = p->Prev(Coupling::control)) { - float Nmax = ((p->MoverParameters->P2FTrans * p->MoverParameters->MaxBrakePress[0] - - p->MoverParameters->BrakeCylSpring) * - p->MoverParameters->BrakeCylMult[0] - - p->MoverParameters->BrakeSlckAdj) * - p->MoverParameters->BrakeCylNo * p->MoverParameters->BrakeRigEff; + float Nmax = ((p->physics->P2FTrans * p->physics->MaxBrakePress[0] - + p->physics->BrakeCylSpring) * + p->physics->BrakeCylMult[0] - + p->physics->BrakeSlckAdj) * + p->physics->BrakeCylNo * p->physics->BrakeRigEff; if (state.FrED > 0.1) - p->MoverParameters->MED_EPVC_CurrentTime = 0; + p->physics->MED_EPVC_CurrentTime = 0; else - p->MoverParameters->MED_EPVC_CurrentTime += dt1; - bool EPVC = p->MoverParameters->MED_EPVC && (p->MoverParameters->MED_EPVC_Time < 0 || p->MoverParameters->MED_EPVC_CurrentTime < p->MoverParameters->MED_EPVC_Time); - float VelC = EPVC ? safe_clamp(p->MoverParameters->Vel, p->MoverParameters->MED_Vmin, p->MoverParameters->MED_Vmax) : p->MoverParameters->MED_Vref;//korekcja EP po prędkości + p->physics->MED_EPVC_CurrentTime += dt1; + bool EPVC = p->physics->MED_EPVC && (p->physics->MED_EPVC_Time < 0 || p->physics->MED_EPVC_CurrentTime < p->physics->MED_EPVC_Time); + float VelC = EPVC ? safe_clamp(p->physics->Vel, p->physics->MED_Vmin, p->physics->MED_Vmax) : p->physics->MED_Vref;//korekcja EP po prędkości float FmaxPoj = Nmax * - p->MoverParameters->Hamulec->GetFC( - Nmax / (p->MoverParameters->NAxles * p->MoverParameters->NBpA), VelC) * + p->physics->Hamulec->GetFC( + Nmax / (p->physics->NAxles * p->physics->NBpA), VelC) * 1000; // sila hamowania pn - p->MoverParameters->LocalBrakePosAEIM = FzEP[i] / FmaxPoj; - if (p->MoverParameters->LocalBrakePosAEIM>0.009) - if (p->MoverParameters->P2FTrans * p->MoverParameters->BrakeCylMult[0] * - p->MoverParameters->MaxBrakePress[0] != 0) + p->physics->LocalBrakePosAEIM = FzEP[i] / FmaxPoj; + if (p->physics->LocalBrakePosAEIM>0.009) + if (p->physics->P2FTrans * p->physics->BrakeCylMult[0] * + p->physics->MaxBrakePress[0] != 0) { - float x = (p->MoverParameters->BrakeSlckAdj / p->MoverParameters->BrakeCylMult[0] + - p->MoverParameters->BrakeCylSpring) / (p->MoverParameters->P2FTrans * - p->MoverParameters->MaxBrakePress[0]); - p->MoverParameters->LocalBrakePosAEIM = x + (1 - x) * p->MoverParameters->LocalBrakePosAEIM; + float x = (p->physics->BrakeSlckAdj / p->physics->BrakeCylMult[0] + + p->physics->BrakeCylSpring) / (p->physics->P2FTrans * + p->physics->MaxBrakePress[0]); + p->physics->LocalBrakePosAEIM = x + (1 - x) * p->physics->LocalBrakePosAEIM; } else - p->MoverParameters->LocalBrakePosAEIM = p->MoverParameters->LocalBrakePosAEIM; + p->physics->LocalBrakePosAEIM = p->physics->LocalBrakePosAEIM; else - p->MoverParameters->LocalBrakePosAEIM = 0; - if (p->MoverParameters->LocHandleTimeTraxx) + p->physics->LocalBrakePosAEIM = 0; + if (p->physics->LocHandleTimeTraxx) { - p->MoverParameters->eim_localbrake = state.eim_lb; - p->MoverParameters->LocalBrakePosAEIM = std::max(p->MoverParameters->LocalBrakePosAEIM, state.eim_lb); + p->physics->eim_localbrake = state.eim_lb; + p->physics->LocalBrakePosAEIM = std::max(p->physics->LocalBrakePosAEIM, state.eim_lb); } ++i; } @@ -699,12 +699,12 @@ void TDynamicObject::recordMedState( InductionBrakeState const &state, double co if (MEDLogFile.is_open()) { - MEDLogFile << MEDLogTime << "\t" << MoverParameters->Vel << "\t" << state.masa*0.001 << "\t" << state.osie << "\t" << state.FmaxPN*0.001 << "\t" << state.FmaxED*0.001 << "\t" + MEDLogFile << MEDLogTime << "\t" << physics->Vel << "\t" << state.masa*0.001 << "\t" << state.osie << "\t" << state.FmaxPN*0.001 << "\t" << state.FmaxED*0.001 << "\t" << state.FfulED*0.001 << "\t" << state.FrED*0.001 << "\t" << state.Fzad*0.001 << "\t" << state.FzadED*0.001 << "\t" << state.FzadPN*0.001; - for (TDynamicObject *p = GetFirstDynamic(MoverParameters->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; + for (TDynamicObject *p = GetFirstDynamic(physics->CabOccupied < 0 ? VehicleEnd::rear : VehicleEnd::front, Coupling::control); p; true == state.kier ? p = p->Next(Coupling::control) : p = p->Prev(Coupling::control)) { - MEDLogFile << "\t" << p->MoverParameters->BrakePress; + MEDLogFile << "\t" << p->physics->BrakePress; } MEDLogFile << "\n"; if (floor(MEDLogTime + dt1) > floor(MEDLogTime)) @@ -713,7 +713,7 @@ void TDynamicObject::recordMedState( InductionBrakeState const &state, double co } MEDLogTime += dt1; - if (MoverParameters->Vel < 0.1 || MoverParameters->MainCtrlPowerPos() > 0) + if (physics->Vel < 0.1 || physics->MainCtrlPowerPos() > 0) { MEDLogInactiveTime += dt1; } @@ -734,25 +734,25 @@ void TDynamicObject::recordMedState( InductionBrakeState const &state, double co void TDynamicObject::switchOffMainsWithoutBattery() { // fragment "z EXE Kursa" - if( MoverParameters->Mains ) { // nie wchodzić w funkcję bez potrzeby - if( false == (MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable) + if( physics->Mains ) { // nie wchodzić w funkcję bez potrzeby + if( false == (physics->Power24vIsAvailable || physics->Power110vIsAvailable) /* // NOTE: disabled on account of multi-unit setups, where the unmanned unit wouldn't be affected && ( Controller == Humandriver ) */ - && MoverParameters->EngineType != TEngineType::DieselEngine - && MoverParameters->EngineType != TEngineType::WheelsDriven ) { // jeśli bateria wyłączona, a nie diesel ani drezyna reczna - if( MoverParameters->MainSwitch( false, MoverParameters->TrainType == train_type::emu ? range_t::unit : range_t::local ) ) { + && physics->EngineType != TEngineType::DieselEngine + && physics->EngineType != TEngineType::WheelsDriven ) { // jeśli bateria wyłączona, a nie diesel ani drezyna reczna + if( physics->MainSwitch( false, physics->TrainType == train_type::emu ? range_t::unit : range_t::local ) ) { // wyłączyć zasilanie // NOTE: we turn off entire EMU, but only the affected unit for other multi-unit consists - MoverParameters->EventFlag = true; + physics->EventFlag = true; // drop pantographs // NOTE: this isn't universal behaviour // TODO: have this dependant on .fiz-driven flag // NOTE: moved to pantspeed calculation part a little later in the function. all remarks and todo still apply /* - MoverParameters->PantFront( false, ( MoverParameters->TrainType == train_type::emu ? range::unit : range::local ) ); - MoverParameters->PantRear( false, ( MoverParameters->TrainType == train_type::emu ? range::unit : range::local ) ); + physics->PantFront( false, ( physics->TrainType == train_type::emu ? range::unit : range::local ) ); + physics->PantRear( false, ( physics->TrainType == train_type::emu ? range::unit : range::local ) ); */ } } @@ -774,7 +774,7 @@ double TDynamicObject::moveByPhysics( double const dt, double const dt1 ) 0.0, modelRot.z }; // McZapkie-260202 - dMoveLen przyda sie przy stukocie kol - double const dDOMoveLen = GetdMoveLen() + MoverParameters->ComputeMovement(dt, dt1, ts, tp, tmpTraction, l, r); + double const dDOMoveLen = GetdMoveLen() + physics->ComputeMovement(dt, dt1, ts, tp, tmpTraction, l, r); if( Mechanik ) { // dodanie aktualnego przemieszczenia Mechanik->MoveDistanceAdd( dDOMoveLen ); @@ -782,11 +782,11 @@ double TDynamicObject::moveByPhysics( double const dt, double const dt1 ) if( simulation::Train != nullptr && simulation::Train->Dynamic() == this ) { // update distance meter in user-controlled cab - // TBD: place the meter on mover logic level? + // TBD: place the meter on physics logic level? simulation::Train->add_distance( dDOMoveLen ); } // physics.derailment new: derailed, the vehicle leaves the track and goes on the ground - if( MoverParameters->leaves_track() ) { + if( physics->leaves_track() ) { begin_off_track(); } m_offtracktime = dt1; @@ -815,7 +815,7 @@ void TDynamicObject::updateAxleClatter( double const dDOMoveLen ) dRailLength = MyTrack->fSoundDistance; } if( dRailLength > 0.0 ) { - if( MoverParameters->Vel > 0 ) { + if( physics->Vel > 0 ) { // TODO: track quality and/or environment factors as separate subroutine auto volume = std::lerp( @@ -844,9 +844,9 @@ void TDynamicObject::updateAxleClatter( double const dDOMoveLen ) ctOwner->Vehicle()->DirectionGet() == DirectionGet() ? 1 : -1 ) }; for( auto &axle : m_axlesounds ) { if( axle_passed_joint( axle, dDOMoveLen, directioninconsist ) - && MoverParameters->Vel > 0.1 ) { + && physics->Vel > 0.1 ) { // NOTE: for combined clatter sound we supply 1/100th of actual value, as the sound module converts does the opposite, converting received (typically) 0-1 values to 0-100 range - auto const frequency = true == axle.clatter.is_combined() ? MoverParameters->Vel * 0.01 : 1.0; + auto const frequency = true == axle.clatter.is_combined() ? physics->Vel * 0.01 : 1.0; axle.clatter .pitch( frequency ) .gain( volume ) @@ -867,37 +867,37 @@ void TDynamicObject::applyJointJolt( int const axleindex ) { // crude bump simulation, drop down on even axles, move back up on // the odd ones - // MoverParameters->AccVert += (MoverParameters->Vel*0.1f) * + // physics->AccVert += (physics->Vel*0.1f) * // the arguments keep the order they had up to 26.05.1, 0 in place of the value and the figure in place of the // upper limit, so they work out as the old clamp worked them out up to 26.05.1: the headroom is // Vmax - (Vel + 0.32 Vmax) whatever its sign, and the bump is capped from above only - double const headroom = safe_clamp( 0.0, MoverParameters->Vmax, MoverParameters->Vmax - ( MoverParameters->Vel + MoverParameters->Vmax * 0.32f ) ); + double const headroom = safe_clamp( 0.0, physics->Vmax, physics->Vmax - ( physics->Vel + physics->Vmax * 0.32f ) ); double const jolt = headroom * .05f * ( MyTrack->iDamageFlag * 0.25f ); if (MyTrack->eType == tt_Normal) { - MoverParameters->AccVert += safe_clamp( 0.0, 4.0, jolt ); + physics->AccVert += safe_clamp( 0.0, 4.0, jolt ); } else if (MyTrack->eType == tt_Switch) { double const accHorizontal = safe_clamp( 0.0, 1.0, jolt ) * ((axleindex % 2) != 0 ? 1 : -1); - MoverParameters->AccS += accHorizontal; - MoverParameters->AccN += accHorizontal; - MoverParameters->AccVert += safe_clamp( 0.0, 2.0, jolt ); + physics->AccS += accHorizontal; + physics->AccN += accHorizontal; + physics->AccVert += safe_clamp( 0.0, 2.0, jolt ); } } // the wheels turned by the distance the vehicle went void TDynamicObject::updateWheelAngles( double const dt1 ) { - if (MoverParameters->Vel != 0) + if (physics->Vel != 0) { // McZapkie-050402: krecenie kolami: glm::dvec3 old_wheels = glm::dvec3(dWheelAngle[0], dWheelAngle[1], dWheelAngle[2]); - dWheelAngle[0] += 114.59155902616464175359630962821 * MoverParameters->V * dt1 / - MoverParameters->WheelDiameterL; // przednie toczne - dWheelAngle[1] += MoverParameters->nrot * dt1 * 360.0; // napędne - dWheelAngle[2] += 114.59155902616464175359630962821 * MoverParameters->V * dt1 / - MoverParameters->WheelDiameterT; // tylne toczne + dWheelAngle[0] += 114.59155902616464175359630962821 * physics->V * dt1 / + physics->WheelDiameterL; // przednie toczne + dWheelAngle[1] += physics->nrot * dt1 * 360.0; // napędne + dWheelAngle[2] += 114.59155902616464175359630962821 * physics->V * dt1 / + physics->WheelDiameterT; // tylne toczne m_future_wheels_angle = (glm::dvec3(dWheelAngle[0], dWheelAngle[1], dWheelAngle[2]) - old_wheels) / dt1 * Timer::GetDeltaRenderTime(); @@ -915,8 +915,8 @@ void TDynamicObject::updateCurrentCollectors( double const dt1 ) { // przeliczanie kątów dla pantografów // prąd pobierany przez pojazd z sieci: trakcyjny (on the genset of a dual-mode vehicle none) i TotalCurrent // TotalCurrent to bedzie prad nietrakcyjny (niezwiazany z napedem) - double fCurrent = MoverParameters->CatenaryCurrent(); - // fCurrent+=fabs(MoverParameters->Voltage)*1e-6; //prąd płynący przez woltomierz, rozładowuje kondensator orgromowy 4µF + double fCurrent = physics->CatenaryCurrent(); + // fCurrent+=fabs(physics->Voltage)*1e-6; //prąd płynący przez woltomierz, rozładowuje kondensator orgromowy 4µF /* double fPantCurrent = fCurrent; // normalnie cały prąd przez jeden pantograf if (iAnimType[ANIM_PANTS] > 1) { // a jeśli są dwa pantografy //Ra 1014-11: proteza, trzeba zrobić sensowniej @@ -938,7 +938,7 @@ void TDynamicObject::updateCurrentCollectors( double const dt1 ) } else { if( pantograph->hvPowerWire != nullptr - && true == MoverParameters->Pantographs[PantographEnd( idx )].is_active + && true == physics->Pantographs[PantographEnd( idx )].is_active && pantograph->PantTraction - pantograph->PantWys < 0.01 ) { // tolerancja niedolegania ++activepantographs; } @@ -952,8 +952,8 @@ void TDynamicObject::updateCurrentCollectors( double const dt1 ) } // koniec pętli po pantografach playPantographDropSounds(); } - else if (MoverParameters->EnginePowerSource.SourceType == TPowerSource::InternalSource) - if (MoverParameters->EnginePowerSource.PowerType == TPowerType::SteamPower) + else if (physics->EnginePowerSource.SourceType == TPowerSource::InternalSource) + if (physics->EnginePowerSource.PowerType == TPowerType::SteamPower) // if (smPatykird1[0]) { // Ra: animacja rozrządu parowozu, na razie nieoptymalizowane /* //Ra: tymczasowo wyłączone ze względu na porządkowanie animacji @@ -1035,10 +1035,10 @@ void TDynamicObject::updateCurrentCollectors( double const dt1 ) */ } - if (MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector - && MoverParameters->EnginePowerSource.CollectorParameters.FakePower) { - MoverParameters->PantRearVolt = 0.95 * MoverParameters->EnginePowerSource.MaxVoltage; - MoverParameters->PantFrontVolt = 0.95 * MoverParameters->EnginePowerSource.MaxVoltage; + if (physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector + && physics->EnginePowerSource.CollectorParameters.FakePower) { + physics->PantRearVolt = 0.95 * physics->EnginePowerSource.MaxVoltage; + physics->PantFrontVolt = 0.95 * physics->EnginePowerSource.MaxVoltage; } } @@ -1059,9 +1059,9 @@ void TDynamicObject::updatePantograph( int const i, double const fPantCurrent, d if (p->fAngleU > M_PI) p->fAngleU = M_PI; if (i & 1) // zgłoszono, że po połamaniu potrafi zostać zasilanie - MoverParameters->PantRearVolt = 0.0; + physics->PantRearVolt = 0.0; else - MoverParameters->PantFrontVolt = 0.0; + physics->PantFrontVolt = 0.0; return; // reszta wtedy nie jest wykonywana } PantDiff = p->PantTraction - p->PantWys; // docelowy-aktualny @@ -1078,30 +1078,30 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d if (Global.bLiveTraction == false && p->hvPowerWire == nullptr ) { // jeśli nie ma drutu, może pooszukiwać - MoverParameters->PantFrontVolt = + physics->PantFrontVolt = p->PantWys >= 1.2 ? - 0.95 * MoverParameters->EnginePowerSource.MaxVoltage : + 0.95 * physics->EnginePowerSource.MaxVoltage : 0.0; } - else if( true == MoverParameters->Pantographs[VehicleEnd::front].is_active + else if( true == physics->Pantographs[VehicleEnd::front].is_active && PantDiff < 0.01 ) // tolerancja niedolegania { if (p->hvPowerWire) { - auto const lastvoltage { MoverParameters->PantFrontVolt }; + auto const lastvoltage { physics->PantFrontVolt }; // TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage() if( lastvoltage == 0.0 ) { // HACK: retrieve the wire voltage for calculations down the road without blowing up the supply - MoverParameters->PantFrontVolt = p->hvPowerWire->VoltageGet( MoverParameters->PantographVoltage, 0.0 ); + physics->PantFrontVolt = p->hvPowerWire->VoltageGet( physics->PantographVoltage, 0.0 ); } else { - MoverParameters->PantFrontVolt = p->hvPowerWire->VoltageGet( MoverParameters->PantographVoltage, fPantCurrent ); - if( MoverParameters->PantFrontVolt > 0.0 ) { + physics->PantFrontVolt = p->hvPowerWire->VoltageGet( physics->PantographVoltage, fPantCurrent ); + if( physics->PantFrontVolt > 0.0 ) { fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf (unless it doesn't) } } - // TODO: refactor reaction to voltage change to mover as sound event for specific pantograph + // TODO: refactor reaction to voltage change to physics as sound event for specific pantograph if( lastvoltage == 0.0 - && MoverParameters->PantFrontVolt > 0.0 ) { + && physics->PantFrontVolt > 0.0 ) { for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z > 0 ) { // limit to pantographs located in the front half of the vehicle @@ -1111,40 +1111,40 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d } } else - MoverParameters->PantFrontVolt = 0.0; + physics->PantFrontVolt = 0.0; } else - MoverParameters->PantFrontVolt = 0.0; - ( fPantCurrent > 0.0 ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantFrontVolt * fPantCurrent * dt1 / 3600000.0; + physics->PantFrontVolt = 0.0; + ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->PantFrontVolt * fPantCurrent * dt1 / 3600000.0; break; case 1: if( false == Global.bLiveTraction && nullptr == p->hvPowerWire ) { // jeśli nie ma drutu, może pooszukiwać - MoverParameters->PantRearVolt = + physics->PantRearVolt = p->PantWys >= 1.2 ? - 0.95 * MoverParameters->EnginePowerSource.MaxVoltage : + 0.95 * physics->EnginePowerSource.MaxVoltage : 0.0; } - else if ( true == MoverParameters->Pantographs[VehicleEnd::rear].is_active + else if ( true == physics->Pantographs[VehicleEnd::rear].is_active && PantDiff < 0.01 ) { if (p->hvPowerWire) { - auto const lastvoltage { MoverParameters->PantRearVolt }; + auto const lastvoltage { physics->PantRearVolt }; // TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage() if( lastvoltage == 0.0 ) { // HACK: retrieve the wire voltage for calculations down the road without blowing up the supply - MoverParameters->PantRearVolt = p->hvPowerWire->VoltageGet( MoverParameters->PantographVoltage, 0.0 ); + physics->PantRearVolt = p->hvPowerWire->VoltageGet( physics->PantographVoltage, 0.0 ); } else { - MoverParameters->PantRearVolt = p->hvPowerWire->VoltageGet( MoverParameters->PantographVoltage, fPantCurrent ); - if( MoverParameters->PantRearVolt > 0.0 ) { + physics->PantRearVolt = p->hvPowerWire->VoltageGet( physics->PantographVoltage, fPantCurrent ); + if( physics->PantRearVolt > 0.0 ) { fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf (unless it doesn't) } } - // TODO: refactor reaction to voltage change to mover as sound event for specific pantograph + // TODO: refactor reaction to voltage change to physics as sound event for specific pantograph if( lastvoltage == 0.0 - && MoverParameters->PantRearVolt > 0.0 ) { + && physics->PantRearVolt > 0.0 ) { for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z < 0 ) { // limit to pantographs located in the rear half of the vehicle @@ -1154,13 +1154,13 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d } } else - MoverParameters->PantRearVolt = 0.0; + physics->PantRearVolt = 0.0; } else { // Global.iPause ^= 2; - MoverParameters->PantRearVolt = 0.0; + physics->PantRearVolt = 0.0; } - ( fPantCurrent > 0.0 ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantRearVolt * fPantCurrent * dt1 / 3600000.0; + ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->PantRearVolt * fPantCurrent * dt1 / 3600000.0; break; } // pozostałe na razie nie obsługiwane } @@ -1169,24 +1169,24 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d void TDynamicObject::updatePantographMotion( int const i, TAnimPant *p, double const PantDiff, double const dt1 ) { double k; // tymczasowy kąt - if( MoverParameters->PantPress > ( - MoverParameters->TrainType == train_type::emu ? + if( physics->PantPress > ( + physics->TrainType == train_type::emu ? 2.45 : // Ra 2013-12: Niebugocław mówi, że w EZT podnoszą się przy 2.5 3.45 ) ) { // z EXE Kursa // Ra: wysokość zależy od ciśnienia !!! - pantspeedfactor = 0.015 * MoverParameters->PantPress * dt1; + pantspeedfactor = 0.015 * physics->PantPress * dt1; } else { pantspeedfactor = 0.0; } - if( false == ( MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable ) ) { + if( false == ( physics->Power24vIsAvailable || physics->Power110vIsAvailable ) ) { pantspeedfactor = 0.0; } pantspeedfactor = std::max( 0.0, pantspeedfactor ); k = p->fAngleL; if( pantspeedfactor > 0.0 - && MoverParameters->Pantographs[i].is_active )// jeśli ma być podniesiony + && physics->Pantographs[i].is_active )// jeśli ma być podniesiony { if (PantDiff > 0.001) // jeśli nie dolega do drutu { // jeśli poprzednia wysokość jest mniejsza niż pożądana, zwiększyć kąt dolnego @@ -1234,9 +1234,9 @@ void TDynamicObject::updatePantographMotion( int const i, TAnimPant *p, double c // the sound of the pantographs dropping, at the end whose pantograph went down void TDynamicObject::playPantographDropSounds() { - // TBD, TODO: generate sound event during mover update instead? - if( MoverParameters->Pantographs[VehicleEnd::front].sound_event != MoverParameters->Pantographs[ VehicleEnd::front ].is_active ) { - if( MoverParameters->Pantographs[ VehicleEnd::front ].is_active ) { + // TBD, TODO: generate sound event during physics update instead? + if( physics->Pantographs[VehicleEnd::front].sound_event != physics->Pantographs[ VehicleEnd::front ].is_active ) { + if( physics->Pantographs[ VehicleEnd::front ].is_active ) { // pantograph moving up // TBD: add a sound? } @@ -1249,10 +1249,10 @@ void TDynamicObject::playPantographDropSounds() } } } - MoverParameters->Pantographs[ VehicleEnd::front ].sound_event = MoverParameters->Pantographs[ VehicleEnd::front ].is_active; + physics->Pantographs[ VehicleEnd::front ].sound_event = physics->Pantographs[ VehicleEnd::front ].is_active; } - if( MoverParameters->Pantographs[ VehicleEnd::rear ].sound_event != MoverParameters->Pantographs[ VehicleEnd::rear ].is_active ) { - if( MoverParameters->Pantographs[ VehicleEnd::rear ].is_active ) { + if( physics->Pantographs[ VehicleEnd::rear ].sound_event != physics->Pantographs[ VehicleEnd::rear ].is_active ) { + if( physics->Pantographs[ VehicleEnd::rear ].is_active ) { // pantograph moving up // TBD: add a sound? } @@ -1265,7 +1265,7 @@ void TDynamicObject::playPantographDropSounds() } } } - MoverParameters->Pantographs[ VehicleEnd::rear ].sound_event = MoverParameters->Pantographs[ VehicleEnd::rear ].is_active; + physics->Pantographs[ VehicleEnd::rear ].sound_event = physics->Pantographs[ VehicleEnd::rear ].is_active; } } @@ -1278,22 +1278,22 @@ void TDynamicObject::updateWipers( double const dt1 ) for (int i = 0; i < dWiperPos.size(); i++) // iteracja po kazdej wycieraczce { bool wipersActive; - auto const bytesum = MoverParameters->WiperList[MoverParameters->wiperSwitchPos].byteSum; + auto const bytesum = physics->WiperList[physics->wiperSwitchPos].byteSum; // rozroznienie kabinowe - if (MoverParameters->CabActive == 1) + if (physics->CabActive == 1) { - wipersActive = (bytesum & 1 << i) != 0 && MoverParameters->Battery; + wipersActive = (bytesum & 1 << i) != 0 && physics->Battery; } - else if (MoverParameters->CabActive == -1) + else if (physics->CabActive == -1) { // odwroconie indexow wycieraczek - wipersActive = (bytesum & 1 << dWiperPos.size() - 1 - i) != 0 && MoverParameters->Battery; + wipersActive = (bytesum & 1 << dWiperPos.size() - 1 - i) != 0 && physics->Battery; } else { wipersActive = false; } - auto const currentWiperParams = MoverParameters->WiperList[workingSwitchPos[i]]; + auto const currentWiperParams = physics->WiperList[workingSwitchPos[i]]; wiperOutTimer[i] += dt1; // aktualizujemy zegarek wiperParkTimer[i] += dt1; // aktualizujemy zegarek @@ -1340,7 +1340,7 @@ void TDynamicObject::updateWipers( double const dt1 ) sWiperToParkPlayed = false; wiperOutTimer[i] = 0.0; wiperDirection[i] = false; - workingSwitchPos[i] = MoverParameters->wiperSwitchPos; // update configuration + workingSwitchPos[i] = physics->wiperSwitchPos; // update configuration } } @@ -1355,9 +1355,9 @@ void TDynamicObject::updateMirrors( double const dt1 ) // mirrors auto const mirrorleft { dMirrorMoveL }; auto const mirrorright { dMirrorMoveR }; - if( MoverParameters->Vel > MoverParameters->MirrorVelClose - || MoverParameters->CabActive == 0 && activation::mirrors - || MoverParameters->MirrorForbidden ) { + if( physics->Vel > physics->MirrorVelClose + || physics->CabActive == 0 && activation::mirrors + || physics->MirrorForbidden ) { // automatically fold mirrors when above velocity threshold if( dMirrorMoveL > 0.0 ) { dMirrorMoveL = std::max( @@ -1373,13 +1373,13 @@ void TDynamicObject::updateMirrors( double const dt1 ) else { // unfold mirror on the side with open doors, if not moving too fast if( dMirrorMoveL < 1.0 - && true == MoverParameters->Doors.instances[VehicleSide::left].open_permit ) { + && true == physics->Doors.instances[VehicleSide::left].open_permit ) { dMirrorMoveL = std::min( 1.0, dMirrorMoveL + 1.0 * dt1 ); } if( dMirrorMoveR < 1.0 - && true == MoverParameters->Doors.instances[VehicleSide::right].open_permit ) { + && true == physics->Doors.instances[VehicleSide::right].open_permit ) { dMirrorMoveR = std::min( 1.0, dMirrorMoveR + 1.0 * dt1 ); @@ -1394,7 +1394,7 @@ void TDynamicObject::pants_up() TDynamicObject *d = this; bool isAnyPantUp = false; while (d) { - for (auto &item : d->MoverParameters->Pantographs) + for (auto &item : d->physics->Pantographs) { isAnyPantUp |= item.is_active; } @@ -1402,7 +1402,7 @@ void TDynamicObject::pants_up() } d = Prev(Coupling::control); while (d) { - for (auto &item : d->MoverParameters->Pantographs) + for (auto &item : d->physics->Pantographs) { isAnyPantUp |= item.is_active; } @@ -1412,14 +1412,14 @@ void TDynamicObject::pants_up() { d = this; while (d) { - d->MoverParameters->OperatePantographValve(VehicleEnd::front, operation_t::enable, range_t::local); - d->MoverParameters->OperatePantographValve(VehicleEnd::rear, operation_t::enable, range_t::local); + d->physics->OperatePantographValve(VehicleEnd::front, operation_t::enable, range_t::local); + d->physics->OperatePantographValve(VehicleEnd::rear, operation_t::enable, range_t::local); d = d->Next(Coupling::control); // pozostałe też } d = Prev(Coupling::control); while (d) { - d->MoverParameters->OperatePantographValve(VehicleEnd::front, operation_t::enable, range_t::local); - d->MoverParameters->OperatePantographValve(VehicleEnd::rear, operation_t::enable, range_t::local); + d->physics->OperatePantographValve(VehicleEnd::front, operation_t::enable, range_t::local); + d->physics->OperatePantographValve(VehicleEnd::rear, operation_t::enable, range_t::local); d = d->Prev(Coupling::control); // w drugą stronę też } } @@ -1482,9 +1482,9 @@ void TDynamicObject::RadioStop() { // zatrzymanie pojazdu if( Mechanik ) { // o ile ktoś go prowadzi - if( MoverParameters->SecuritySystem.radiostop_available() - && MoverParameters->Radio - && MoverParameters->RadioFuse ) { + if( physics->SecuritySystem.radiostop_available() + && physics->Radio + && physics->RadioFuse ) { // jeśli pojazd ma RadioStop i jest on aktywny // HACK cast until math types unification glm::dvec3 pos = static_cast(vPosition); @@ -1503,8 +1503,8 @@ void TDynamicObject::Damage(char flag) { if (flag & 1) //różnicówka nie robi nic { - MoverParameters->MainSwitch(false); - MoverParameters->FuseOff(); + physics->MainSwitch(false); + physics->FuseOff(); } else { @@ -1512,20 +1512,20 @@ void TDynamicObject::Damage(char flag) if (flag & 2) //usterka sterowania { - MoverParameters->StLinFlag = false; - if (MoverParameters->InitialCtrlDelay<100000000) - MoverParameters->InitialCtrlDelay += 100000001; + physics->StLinFlag = false; + if (physics->InitialCtrlDelay<100000000) + physics->InitialCtrlDelay += 100000001; } else { - if (MoverParameters->InitialCtrlDelay>100000000) - MoverParameters->InitialCtrlDelay -= 100000001; + if (physics->InitialCtrlDelay>100000000) + physics->InitialCtrlDelay -= 100000001; } if (flag & 4) //blokada przetwornicy { - if( MoverParameters->ConverterStart != start_t::disabled ) { - MoverParameters->ConvOvldFlag = true; + if( physics->ConverterStart != start_t::disabled ) { + physics->ConvOvldFlag = true; } } else @@ -1534,32 +1534,32 @@ void TDynamicObject::Damage(char flag) if (flag & 8) //blokada sprezarki { - if (MoverParameters->MinCompressor>0) - MoverParameters->MinCompressor -= 100000001; - if (MoverParameters->MaxCompressor>0) - MoverParameters->MaxCompressor -= 100000001; + if (physics->MinCompressor>0) + physics->MinCompressor -= 100000001; + if (physics->MaxCompressor>0) + physics->MaxCompressor -= 100000001; } else { - if (MoverParameters->MinCompressor<0) - MoverParameters->MinCompressor += 100000001; - if (MoverParameters->MaxCompressor<0) - MoverParameters->MaxCompressor += 100000001; + if (physics->MinCompressor<0) + physics->MinCompressor += 100000001; + if (physics->MaxCompressor<0) + physics->MaxCompressor += 100000001; } if (flag & 16) //blokada wału { - if (MoverParameters->CtrlDelay<100000000) - MoverParameters->CtrlDelay += 100000001; - if (MoverParameters->CtrlDownDelay<100000000) - MoverParameters->CtrlDownDelay += 100000001; + if (physics->CtrlDelay<100000000) + physics->CtrlDelay += 100000001; + if (physics->CtrlDownDelay<100000000) + physics->CtrlDownDelay += 100000001; } else { - if (MoverParameters->CtrlDelay>100000000) - MoverParameters->CtrlDelay -= 100000001; - if (MoverParameters->CtrlDownDelay>100000000) - MoverParameters->CtrlDownDelay -= 100000001; + if (physics->CtrlDelay>100000000) + physics->CtrlDelay -= 100000001; + if (physics->CtrlDownDelay>100000000) + physics->CtrlDownDelay -= 100000001; } if (flag & 32) //hamowanie nagŁe @@ -1569,7 +1569,7 @@ void TDynamicObject::Damage(char flag) { } - MoverParameters->EngDmgFlag = flag; + physics->EngDmgFlag = flag; }; void TDynamicObject::OverheadTrack(float o) diff --git a/vehicle/dynamic/vehicletable.cpp b/vehicle/dynamic/vehicletable.cpp index 689ef28c4..8a49d822f 100644 --- a/vehicle/dynamic/vehicletable.cpp +++ b/vehicle/dynamic/vehicletable.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -77,16 +77,16 @@ coupled_train( TDynamicObject *Vehicle ) { auto side { direction }; // a train of more vehicles than are on the tracks would be one coupled into a ring while( train.size() < 10000 ) { - auto const &mover { *vehicle->MoverParameters }; - auto *next { mover.Neighbours[ side ].vehicle }; + auto const &physics { *vehicle->physics }; + auto *next { physics.Neighbours[ side ].vehicle }; if( next == nullptr - || false == mover.Couplers[ side ].CouplingFlag.HasAny(Coupling::coupler) + || false == physics.Couplers[ side ].CouplingFlag.HasAny(Coupling::coupler) || std::ranges::find( train, next ) != train.end() ) { break; } train.emplace_back( next ); // onwards from the end of the next vehicle away from this one - side = EndOf( 1 - mover.Neighbours[ side ].vehicle_end ); + side = EndOf( 1 - physics.Neighbours[ side ].vehicle_end ); vehicle = next; } } @@ -100,10 +100,10 @@ trains_closing_in( std::vector const &Train ) { std::vector trains; for( auto *vehicle : Train ) { for (auto const side : VehicleEnds) { - auto const &mover { *vehicle->MoverParameters }; - auto const &neighbour { mover.Neighbours[ side ] }; + auto const &physics { *vehicle->physics }; + auto const &neighbour { physics.Neighbours[ side ] }; if( neighbour.vehicle == nullptr - || mover.Couplers[ side ].CouplingFlag.HasAny(Coupling::coupler) + || physics.Couplers[ side ].CouplingFlag.HasAny(Coupling::coupler) || neighbour.distance > coupler_physics_reach || std::ranges::find( Train, neighbour.vehicle ) != Train.end() ) { continue; @@ -147,10 +147,10 @@ vehicle_table::update_coupler_physics() const { std::unordered_set checked; for( auto *vehicle : m_items ) { if( covered.contains( vehicle ) ) { - vehicle->MoverParameters->CouplerPhysics = true; + vehicle->physics->CouplerPhysics = true; continue; } - if( false == vehicle->MoverParameters->CouplerPhysics + if( false == vehicle->physics->CouplerPhysics || checked.contains( vehicle ) ) { continue; } @@ -159,7 +159,7 @@ vehicle_table::update_coupler_physics() const { checked.insert( other.begin(), other.end() ); if( false == trains_within( other, train, coupler_physics_release ) ) { for( auto *othervehicle : other ) { - othervehicle->MoverParameters->CouplerPhysics = false; + othervehicle->physics->CouplerPhysics = false; } } } @@ -199,28 +199,28 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { auto const camera { Global.pCamera.Pos }; for( std::size_t index = 0; index < m_items.size(); ++index ) { auto const *vehicle { m_items[ index ] }; - auto const road { ( vehicle->MoverParameters->CategoryFlag & 2 ) != 0 }; + auto const road { ( vehicle->physics->CategoryFlag & 2 ) != 0 }; auto const distant { glm::length2( vehicle->GetPosition() - camera ) > Timer::subsystem.VEHICLE_NEAR * Timer::subsystem.VEHICLE_NEAR }; kinds[ index ] = static_cast( ( road ? 2 : 0 ) + ( distant ? 1 : 0 ) ); coarse[ index ] = static_cast( roadlod && road && distant && ( false == vehicle->MechInside ) && ( Iterationcount > 1 ) ); if( false == vehicle->bEnabled ) { continue; } ++counts.kind[ kinds[ index ] ]; - auto const *mover { vehicle->MoverParameters }; - if( mover->Vel < 0.01 ) { + auto const *physics { vehicle->physics }; + if( physics->Vel < 0.01 ) { ++counts.standing[ kinds[ index ] ]; - if( ( false == road ) && mover->PhysicActivation ) { - // the test of TMoverParameters::ComputeTotalForce(), part by part + if( ( false == road ) && physics->PhysicActivation ) { + // the test of physics::Vehicle::ComputeTotalForce(), part by part auto const moving = []( neighbour_data const &Neighbour ) { return ( Neighbour.vehicle != nullptr ) - && ( ( Neighbour.vehicle->MoverParameters->Vel > 0.0001 ) || Neighbour.vehicle->MoverParameters->accelerating() ); }; + && ( ( Neighbour.vehicle->physics->Vel > 0.0001 ) || Neighbour.vehicle->physics->accelerating() ); }; auto &awake { counts.awake }; ++awake.vehicles; - if( mover->CabActive != 0 ) { ++awake.cab; } - if( mover->Vel > 0.0001 ) { ++awake.speed; } - if( mover->accelerating() ) { ++awake.acceleration; } - if( mover->LastSwitchingTime < 5 ) { ++awake.switching; } - if( mover->is_multiple_unit() ) { ++awake.multipleunit; } - if( moving( mover->Neighbours[ VehicleEnd::front ] ) || moving( mover->Neighbours[ VehicleEnd::rear ] ) ) { ++awake.neighbour; } + if( physics->CabActive != 0 ) { ++awake.cab; } + if( physics->Vel > 0.0001 ) { ++awake.speed; } + if( physics->accelerating() ) { ++awake.acceleration; } + if( physics->LastSwitchingTime < 5 ) { ++awake.switching; } + if( physics->is_multiple_unit() ) { ++awake.multipleunit; } + if( moving( physics->Neighbours[ VehicleEnd::front ] ) || moving( physics->Neighbours[ VehicleEnd::rear ] ) ) { ++awake.neighbour; } } } } @@ -234,19 +234,19 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { for( auto const *vehicle : m_items ) { if( false == vehicle->bEnabled ) { continue; } ++counts.enabled; - if( vehicle->MoverParameters->CategoryFlag & 2 ) { ++counts.road; } + if( vehicle->physics->CategoryFlag & 2 ) { ++counts.road; } if( ( vehicle->Mechanik != nullptr ) && vehicle->Mechanik->AIControllFlag ) { ++counts.ai; } - if( vehicle->MoverParameters->PhysicActivation || vehicle->MechInside ) { ++counts.active; } + if( vehicle->physics->PhysicActivation || vehicle->MechInside ) { ++counts.active; } } Timer::subsystem.vehicles_prepare.start(); for( auto *vehicle : m_items ) { if( false == vehicle->bEnabled ) { continue; } // Ra: zmienić warunek na sprawdzanie pantografów w jednej zmiennej: czy pantografy i czy podniesione - if( vehicle->MoverParameters->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { + if( vehicle->physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) { update_traction( vehicle ); } - vehicle->MoverParameters->ComputeConstans(); + vehicle->physics->ComputeConstans(); vehicle->update_neighbours(); } update_coupler_physics(); @@ -261,7 +261,7 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { std::size_t work { 0 }; for( std::size_t index = 0; index < m_items.size(); ++index ) { auto const *vehicle { m_items[ index ] }; - if( vehicle->MoverParameters->PhysicActivation || vehicle->MechInside ) { + if( vehicle->physics->PhysicActivation || vehicle->MechInside ) { work += ( coarse[ index ] != 0 ? 1 : static_cast( std::max( Iterationcount, 1 ) ) ); } } @@ -351,10 +351,10 @@ namespace // the body of the vehicle as it stands, for the contacts: off the track by its motion, on the track upright on it derail_motion::footprint footprint_of( TDynamicObject const &Vehicle ) { - auto const &mover { *Vehicle.MoverParameters }; + auto const &physics { *Vehicle.physics }; derail_motion::pose pose; - if( mover.OffTrack.active() ) { - pose = mover.OffTrack.current(); + if( physics.OffTrack.active() ) { + pose = physics.OffTrack.current(); } else { pose.position = Vehicle.GetPosition(); @@ -362,24 +362,24 @@ derail_motion::footprint footprint_of( TDynamicObject const &Vehicle ) { pose.left = Vehicle.VectorLeft(); pose.up = Vehicle.VectorUp(); } - auto const &shape { mover.OffTrack.shape() }; + auto const &shape { physics.OffTrack.shape() }; return derail_motion::footprint_of( - pose, mover.Dim.L, - mover.OffTrack.active() ? shape.width : ( mover.Dim.W > 0.5 ? mover.Dim.W : 3.0 ), - mover.OffTrack.active() ? shape.height : ( mover.Dim.H > 2.0 ? mover.Dim.H : 4.0 ) ); + pose, physics.Dim.L, + physics.OffTrack.active() ? shape.width : ( physics.Dim.W > 0.5 ? physics.Dim.W : 3.0 ), + physics.OffTrack.active() ? shape.height : ( physics.Dim.H > 2.0 ? physics.Dim.H : 4.0 ) ); } // the vehicle as a body in a contact derail_motion::contact_body contact_body_of( TDynamicObject const &Vehicle ) { - auto const &mover { *Vehicle.MoverParameters }; + auto const &physics { *Vehicle.physics }; derail_motion::contact_body body; - body.mass = mover.TotalMass; - if( mover.OffTrack.active() ) { - body.base = mover.OffTrack.base(); - body.velocity = mover.OffTrack.velocity(); - body.yaw_rate = mover.OffTrack.yaw_rate(); - body.gyration = mover.OffTrack.gyration(); + body.mass = physics.TotalMass; + if( physics.OffTrack.active() ) { + body.base = physics.OffTrack.base(); + body.velocity = physics.OffTrack.velocity(); + body.yaw_rate = physics.OffTrack.yaw_rate(); + body.gyration = physics.OffTrack.gyration(); } else { // on the rails it goes along them only @@ -388,7 +388,7 @@ derail_motion::contact_body contact_body_of( TDynamicObject const &Vehicle ) { body.guided = true; body.guide = length > 1e-6 ? front / length : glm::dvec3 { 0.0, 0.0, 1.0 }; body.base = Vehicle.GetPosition(); - body.velocity = body.guide * mover.V; + body.velocity = body.guide * physics.V; } return body; } @@ -396,13 +396,13 @@ derail_motion::contact_body contact_body_of( TDynamicObject const &Vehicle ) { // how the two came to overlap, for the log std::string_view overlap_kind( TDynamicObject const &First, TDynamicObject const &Second ) { - auto const offtrack { First.MoverParameters->OffTrack.active() && Second.MoverParameters->OffTrack.active() }; + auto const offtrack { First.physics->OffTrack.active() && Second.physics->OffTrack.active() }; for (auto const end : VehicleEnds) { - if( First.MoverParameters->Couplers[ end ].Connected == Second.MoverParameters - && First.MoverParameters->Couplers[ end ].CouplingFlag != Coupling::none ) { + if( First.physics->Couplers[ end ].Connected == Second.physics + && First.physics->Couplers[ end ].CouplingFlag != Coupling::none ) { return offtrack ? "coupled, both off the track" : "coupled, one on the rails"; } - if( First.MoverParameters->Neighbours[ end ].vehicle == &Second ) { + if( First.physics->Neighbours[ end ].vehicle == &Second ) { return offtrack ? "neighbours, both off the track" : "neighbours, one on the rails"; } } @@ -420,7 +420,7 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) { // by their places in the table: the order the pairs are taken in is the same in every run std::vector offtrack; for( std::size_t index = 0; index < m_items.size(); ++index ) { - if( m_items[ index ]->bEnabled && m_items[ index ]->MoverParameters->OffTrack.active() ) { + if( m_items[ index ]->bEnabled && m_items[ index ]->physics->OffTrack.active() ) { offtrack.push_back( index ); } } @@ -433,7 +433,7 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) { auto resting { true }; for( auto const place : offtrack ) { auto *vehicle { m_items[ place ] }; - resting = resting && vehicle->MoverParameters->OffTrack.at_rest(); + resting = resting && vehicle->physics->OffTrack.at_rest(); auto const print { footprint_of( *vehicle ) }; auto const reach { std::hypot( print.half_length, print.half_width ) }; for( std::size_t otherplace = 0; otherplace < m_items.size(); ++otherplace ) { @@ -442,13 +442,13 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) { continue; } // each pair of two off the track once - auto const otheroff { other->MoverParameters->OffTrack.active() }; + auto const otheroff { other->physics->OffTrack.active() }; if( otheroff && otherplace < place ) { continue; } // the bounding circles first auto const apart { other->GetPosition() - vehicle->GetPosition() }; - auto const otherreach { 0.5 * other->MoverParameters->Dim.L + std::max( other->MoverParameters->Dim.W, other->MoverParameters->Dim.H ) }; + auto const otherreach { 0.5 * other->physics->Dim.L + std::max( other->physics->Dim.W, other->physics->Dim.H ) }; if( glm::length( glm::dvec3 { apart.x, 0.0, apart.z } ) > reach + otherreach + 1.0 ) { continue; } @@ -459,19 +459,19 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) { } if( hit->depth > deepest ) { deepest = hit->depth; - deepestpair = std::format( "{} and {}, {}", vehicle->MoverParameters->Name, other->MoverParameters->Name, overlap_kind( *vehicle, *other ) ); + deepestpair = std::format( "{} and {}, {}", vehicle->physics->Name, other->physics->Name, overlap_kind( *vehicle, *other ) ); } auto const body { contact_body_of( *vehicle ) }; auto const otherbody { contact_body_of( *other ) }; auto const impulse { derail_motion::contact_impulse( *hit, body, otherbody ) }; // the one off the track: kicked, and moved out of the other one (half of the way when both are off it) auto const [ velocity, yawrate ] { derail_motion::impulse_change( body, -impulse, hit->point ) }; - auto &motion { vehicle->MoverParameters->OffTrack }; + auto &motion { vehicle->physics->OffTrack }; auto const share { otheroff ? 0.5 : 1.0 }; auto const correction { derail_motion::contact_correction * std::max( 0.0, hit->depth - derail_motion::contact_slop ) }; if( glm::length( impulse ) > 0.0 ) { motion.kick( velocity, yawrate ); - vehicle->MoverParameters->V = motion.speed(); + vehicle->physics->V = motion.speed(); } if( correction > 0.0 ) { motion.nudge( -hit->normal * ( share * correction ) ); @@ -479,10 +479,10 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) { } if( otheroff ) { auto const [ othervelocity, otheryawrate ] { derail_motion::impulse_change( otherbody, impulse, hit->point ) }; - auto &othermotion { other->MoverParameters->OffTrack }; + auto &othermotion { other->physics->OffTrack }; if( glm::length( impulse ) > 0.0 ) { othermotion.kick( othervelocity, otheryawrate ); - other->MoverParameters->V = othermotion.speed(); + other->physics->V = othermotion.speed(); } if( correction > 0.0 ) { othermotion.nudge( hit->normal * ( share * correction ) ); @@ -491,23 +491,23 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) { continue; } // one on the rails: along them into its speed, across them on its wheels, as a coupling pulls them off - auto &othermover { *other->MoverParameters }; - othermover.V += glm::dot( impulse, otherbody.guide ) / std::max( othermover.TotalMass, 1.0 ); - if( othermover.DamageFlag.HasAll(VehicleDamage::derailed) ) { + auto &otherPhysics { *other->physics }; + otherPhysics.V += glm::dot( impulse, otherbody.guide ) / std::max( otherPhysics.TotalMass, 1.0 ); + if( otherPhysics.DamageFlag.HasAll(VehicleDamage::derailed) ) { continue; } glm::dvec3 const otherleft { otherbody.guide.z, 0.0, -otherbody.guide.x }; auto const across { glm::dot( impulse, otherleft ) / Deltatime }; - auto const mass { othermover.TotalMass - othermover.Mred }; - auto const ratio { derail_motion::pull_ratio( std::abs( across ), 0.5 * std::numbers::pi, mass, othermover.NAxles ) }; + auto const mass { otherPhysics.TotalMass - otherPhysics.Mred }; + auto const ratio { derail_motion::pull_ratio( std::abs( across ), 0.5 * std::numbers::pi, mass, otherPhysics.NAxles ) }; // held over the window of the climbing as the bodies slide along each other, or a hit three times as hard // at once: the wheels jump the rail auto const sliding { glm::length( derail_motion::velocity_at( body, hit->point ) - otherbody.velocity ) * Deltatime }; if( other->m_struck.update( ratio >= derailment::climbing_limit, sliding ) || ratio >= 3.0 * derailment::climbing_limit ) { - othermover.pull_off( + otherPhysics.pull_off( across >= 0.0 ? 1 : -1, mass > 0.0 ? std::abs( across ) / mass : 0.0, - std::format( "Y/Q {:.2f} from {} running into it, {:.0f} kN across", ratio, vehicle->MoverParameters->Name, std::abs( across ) / 1000.0 ) ); + std::format( "Y/Q {:.2f} from {} running into it, {:.0f} kN across", ratio, vehicle->physics->Name, std::abs( across ) / 1000.0 ) ); other->m_struck.reset(); } } @@ -562,12 +562,12 @@ vehicle_table::update_brake_pipes( double const Deltatime ) { m_brakepipes.clear(); for( auto *vehicle : m_items ) { - if( ( true == vehicle->MoverParameters->PipeCouplersPending ) - || ( true == vehicle->MoverParameters->ScndPipeCouplersPending ) ) { - m_brakepipes.push_back( vehicle->MoverParameters ); + if( ( true == vehicle->physics->PipeCouplersPending ) + || ( true == vehicle->physics->ScndPipeCouplersPending ) ) { + m_brakepipes.push_back( vehicle->physics ); } } - TMoverParameters::UpdatePipeCouplers( m_brakepipes, Deltatime ); + physics::Vehicle::UpdatePipeCouplers( m_brakepipes, Deltatime ); } // records the odometer states of the vehicles and saves them for the next sessions (eu07/maszyna#72) @@ -577,8 +577,8 @@ vehicle_table::save_odometers() { m_odometersavetimer = 0.0; auto &odometers { odometer::states() }; for( auto const *vehicle : m_items ) { - if( vehicle->MoverParameters != nullptr ) { - odometer::record( odometers, vehicle->name(), vehicle->MoverParameters->HasDriverCab(), vehicle->MoverParameters->Odometer ); + if( vehicle->physics != nullptr ) { + odometer::record( odometers, vehicle->name(), vehicle->physics->HasDriverCab(), vehicle->physics->Odometer ); } } odometer::save(); @@ -608,11 +608,11 @@ vehicle_table::update_steps_parallel( double const Deltatime, int const Iteratio } return Index; }; for( std::size_t index = 0; index < itemcount; ++index ) { - auto const *mover { m_items[ index ]->MoverParameters }; + auto const *physics { m_items[ index ]->physics }; for (auto const end : VehicleEnds) { - auto const *neighbour { mover->Neighbours[ end ].vehicle }; - if( ( mover->Couplers[ end ].Connected != nullptr ) - && ( ( neighbour == nullptr ) || ( neighbour->MoverParameters != mover->Couplers[ end ].Connected ) ) ) { + auto const *neighbour { physics->Neighbours[ end ].vehicle }; + if( ( physics->Couplers[ end ].Connected != nullptr ) + && ( ( neighbour == nullptr ) || ( neighbour->physics != physics->Couplers[ end ].Connected ) ) ) { return false; } if( neighbour == nullptr ) { continue; } @@ -650,7 +650,7 @@ vehicle_table::update_steps_parallel( double const Deltatime, int const Iteratio std::begin( m_groups[ group ] ), std::end( m_groups[ group ] ), [ this ]( std::uint32_t const Index ) { auto const *vehicle { m_items[ Index ] }; - return ( vehicle->MoverParameters->LoadStatus != 0 ) || ( vehicle->LoadExchangeTime() > 0.f ); } ) }; + return ( vehicle->physics->LoadStatus != 0 ) || ( vehicle->LoadExchangeTime() > 0.f ); } ) }; ( loading ? m_maingroups : m_threadgroups ).push_back( static_cast( group ) ); } std::sort( @@ -677,7 +677,7 @@ vehicle_table::update_steps_parallel( double const Deltatime, int const Iteratio set_thread_random_engine( &engine ); // the hoses join only vehicles coupled with each other, which are in one group: the air they carry is exchanged // within the group after each step, as update_brake_pipes() does for all the vehicles in one thread - std::vector pipes; + std::vector pipes; if( Iterationcount > 1 ) { // ABu: ponizsze wykonujemy tylko jesli wiecej niz jedna iteracja for( int iteration = 0; iteration < Iterationcount - 1; ++iteration ) { @@ -689,12 +689,12 @@ vehicle_table::update_steps_parallel( double const Deltatime, int const Iteratio } pipes.clear(); for( auto const index : members ) { - auto *mover { m_items[ index ]->MoverParameters }; - if( mover->PipeCouplersPending || mover->ScndPipeCouplersPending ) { - pipes.push_back( mover ); + auto *physics { m_items[ index ]->physics }; + if( physics->PipeCouplersPending || physics->ScndPipeCouplersPending ) { + pipes.push_back( physics ); } } - TMoverParameters::UpdatePipeCouplers( pipes, Deltatime ); + physics::Vehicle::UpdatePipeCouplers( pipes, Deltatime ); } } for( auto const index : members ) { @@ -724,7 +724,7 @@ vehicle_table::update_traction( TDynamicObject *Vehicle ) { for( int pantographindex = 0; pantographindex < Vehicle->iAnimType[ ANIM_PANTS ]; ++pantographindex ) { // pętla po pantografach auto *pantograph { Vehicle->pants[ pantographindex ].fParamPants }; - if( true == Vehicle->MoverParameters->Pantographs[ pantographindex ].is_active ) { + if( true == Vehicle->physics->Pantographs[ pantographindex ].is_active ) { // jeśli pantograf podniesiony auto const pant0 { position + vLeft * pantograph->vPos.z + vUp * pantograph->vPos.y + vFront * pantograph->vPos.x }; if( pantograph->hvPowerWire != nullptr ) { @@ -859,8 +859,8 @@ vehicle_table::erase_disabled() { else { // the distance the vehicle ran goes in the odometer store now, it doesn't depend on the vehicle being // kept on the list until the next save (eu07/maszyna#72) - if( vehicle->MoverParameters != nullptr ) { - odometer::record( odometer::states(), vehicle->name(), vehicle->MoverParameters->HasDriverCab(), vehicle->MoverParameters->Odometer ); + if( vehicle->physics != nullptr ) { + odometer::record( odometer::states(), vehicle->name(), vehicle->physics->HasDriverCab(), vehicle->physics->Odometer ); } if( vehicle->MyTrack != nullptr && true == vehicle->MyTrack->RemoveDynamicObject(vehicle) ) { diff --git a/vehicle/dynamic/visual.cpp b/vehicle/dynamic/visual.cpp index 5d7e83562..60a1c5c4b 100644 --- a/vehicle/dynamic/visual.cpp +++ b/vehicle/dynamic/visual.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/lightsprogrammer.h" #include "simulation/simulation.h" #include "simulation/blackboxrecorder.h" @@ -126,8 +126,8 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // display _xon if connected with another vehicle and not the coupling owner // display _xon if not connected, but equipped with coupling adapter // display _off if not connected, not equipped with coupling adapter or if _xon model is missing - if( MoverParameters->Couplers[ VehicleEnd::front ].CouplingFlag.HasAll(Coupling::coupler) ) { - if( MoverParameters->Couplers[ VehicleEnd::front ].Render ) { + if( physics->Couplers[ VehicleEnd::front ].CouplingFlag.HasAll(Coupling::coupler) ) { + if( physics->Couplers[ VehicleEnd::front ].Render ) { btCoupler1.TurnOn(); } else { @@ -136,13 +136,13 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } else { - if( true == MoverParameters->Couplers[ VehicleEnd::front ].has_adapter() ) { + if( true == physics->Couplers[ VehicleEnd::front ].has_adapter() ) { btCoupler1.TurnxOnWithOffAsFallback(); btnOn = true; } } - if( MoverParameters->Couplers[ VehicleEnd::rear ].CouplingFlag.HasAll(Coupling::coupler) ) { - if( MoverParameters->Couplers[ VehicleEnd::rear ].Render ) { + if( physics->Couplers[ VehicleEnd::rear ].CouplingFlag.HasAll(Coupling::coupler) ) { + if( physics->Couplers[ VehicleEnd::rear ].Render ) { btCoupler2.TurnOn(); } else { @@ -151,7 +151,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } else { - if( true == MoverParameters->Couplers[ VehicleEnd::rear ].has_adapter() ) { + if( true == physics->Couplers[ VehicleEnd::rear ].has_adapter() ) { btCoupler2.TurnxOnWithOffAsFallback(); btnOn = true; } @@ -168,7 +168,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) SetPneumatic(true, true); // ktore z nich nalezy SetPneumatic(false, true); // wyswietlic w tej klatce - if (MoverParameters->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::brakeHose)) + if (physics->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::brakeHose)) { switch (cp1) { @@ -188,7 +188,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } - if (MoverParameters->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::brakeHose)) + if (physics->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::brakeHose)) { switch (cp2) { @@ -209,7 +209,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } // przewody zasilajace, j.w. (yB) - if (MoverParameters->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::mainHose)) + if (physics->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::mainHose)) { switch (sp1) { @@ -229,7 +229,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } - if (MoverParameters->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::mainHose)) + if (physics->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::mainHose)) { switch (sp2) { @@ -254,18 +254,18 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) { // przewody powietrzne j.w., ABu: decyzja czy rysowac tylko na podstawie // 'render' - if (MoverParameters->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::brakeHose)) + if (physics->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::brakeHose)) { - if (MoverParameters->Couplers[VehicleEnd::front].Render) + if (physics->Couplers[VehicleEnd::front].Render) btCPneumatic1.TurnOn(); else btCPneumatic1r.TurnOn(); btnOn = true; } - if (MoverParameters->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::brakeHose)) + if (physics->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::brakeHose)) { - if (MoverParameters->Couplers[VehicleEnd::rear].Render) + if (physics->Couplers[VehicleEnd::rear].Render) btCPneumatic2.TurnOn(); else btCPneumatic2r.TurnOn(); @@ -275,18 +275,18 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // przewody powietrzne j.w., ABu: decyzja czy rysowac tylko na podstawie // 'render' // //yB - zasilajace - if (MoverParameters->Couplers[0].CouplingFlag.HasAll(Coupling::mainHose)) + if (physics->Couplers[0].CouplingFlag.HasAll(Coupling::mainHose)) { - if (MoverParameters->Couplers[0].Render) + if (physics->Couplers[0].Render) btPneumatic1.TurnOn(); else btPneumatic1r.TurnOn(); btnOn = true; } - if (MoverParameters->Couplers[1].CouplingFlag.HasAll(Coupling::mainHose)) + if (physics->Couplers[1].CouplingFlag.HasAll(Coupling::mainHose)) { - if (MoverParameters->Couplers[1].Render) + if (physics->Couplers[1].Render) btPneumatic2.TurnOn(); else btPneumatic2r.TurnOn(); @@ -298,13 +298,13 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // uginanie zderzakow for (int i = 0; i < 2; ++i) { - if( MoverParameters->Couplers[ i ].has_adapter() ) { + if( physics->Couplers[ i ].has_adapter() ) { // HACK: if there's coupler adapter on this side, we presume there's additional distance put between vehicles // which prevents buffers from clashing against each other (or the other vehicle doesn't have buffers to begin with) continue; } - auto const dist { safe_clamp( MoverParameters->Couplers[ i ].Dist / 2.0, -MoverParameters->Couplers[ i ].DmaxB, 0.0 ) }; + auto const dist { safe_clamp( physics->Couplers[ i ].Dist / 2.0, -physics->Couplers[ i ].DmaxB, 0.0 ) }; if( dist >= 0.0 ) { continue; } @@ -320,64 +320,64 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // Winger 160204 - podnoszenie pantografow // przewody sterowania ukrotnionego - if (MoverParameters->Couplers[0].CouplingFlag.HasAll(Coupling::control)) + if (physics->Couplers[0].CouplingFlag.HasAll(Coupling::control)) { btCCtrl1.Turn( true ); btnOn = true; } // else btCCtrl1.TurnOff(); - if (MoverParameters->Couplers[1].CouplingFlag.HasAll(Coupling::control)) + if (physics->Couplers[1].CouplingFlag.HasAll(Coupling::control)) { btCCtrl2.Turn( true ); btnOn = true; } // else btCCtrl2.TurnOff(); // McZapkie-181103: mostki przejsciowe - if (MoverParameters->Couplers[0].CouplingFlag.HasAll(Coupling::gangway)) + if (physics->Couplers[0].CouplingFlag.HasAll(Coupling::gangway)) { btCPass1.Turn( true ); btnOn = true; } // else btCPass1.TurnOff(); - if (MoverParameters->Couplers[1].CouplingFlag.HasAll(Coupling::gangway)) + if (physics->Couplers[1].CouplingFlag.HasAll(Coupling::gangway)) { btCPass2.Turn( true ); btnOn = true; } // else btCPass2.TurnOff(); - if (MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable) + if (physics->Power24vIsAvailable || physics->Power110vIsAvailable) { // sygnaly konca pociagu if (m_endsignals1.Active()) { - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::redmarker_left | light::redmarker_right ) ) { + if (TestFlag(physics->iLights[VehicleEnd::front], light::redmarker_left | light::redmarker_right ) ) { m_endsignals1.Turn( true ); btnOn = true; } } else { - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::redmarker_left) && !HeadlightsAoff) + if (TestFlag(physics->iLights[VehicleEnd::front], light::redmarker_left) && !HeadlightsAoff) { m_endsignal13.Turn( true ); btnOn = true; } - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::redmarker_right) && !HeadlightsAoff) + if (TestFlag(physics->iLights[VehicleEnd::front], light::redmarker_right) && !HeadlightsAoff) { m_endsignal12.Turn( true ); btnOn = true; } } if (m_endsignals2.Active()) { - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::redmarker_left | light::redmarker_right ) ) { + if (TestFlag(physics->iLights[VehicleEnd::rear], light::redmarker_left | light::redmarker_right ) ) { m_endsignals2.Turn( true ); btnOn = true; } } else { - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::redmarker_left) && !HeadlightsBoff) + if (TestFlag(physics->iLights[VehicleEnd::rear], light::redmarker_left) && !HeadlightsBoff) { m_endsignal23.Turn( true ); btnOn = true; } - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::redmarker_right) && !HeadlightsBoff) + if (TestFlag(physics->iLights[VehicleEnd::rear], light::redmarker_right) && !HeadlightsBoff) { m_endsignal22.Turn( true ); btnOn = true; @@ -385,12 +385,12 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } } // tablice blaszane: - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::rearendsignals)) { + if (TestFlag(physics->iLights[VehicleEnd::front], light::rearendsignals)) { m_endtab1.Turn( true ); btnOn = true; } // else btEndSignalsTab1.TurnOff(); - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::rearendsignals)) { + if (TestFlag(physics->iLights[VehicleEnd::rear], light::rearendsignals)) { m_endtab2.Turn( true ); btnOn = true; } @@ -402,17 +402,17 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) for (int i = 0; i < 4; ++i) if (smWahacze[i]) smWahacze[i]->SetRotate(float3(1, 0, 0), - fWahaczeAmp * cos(MoverParameters->eAngle)); + fWahaczeAmp * cos(physics->eAngle)); // cooling shutters // NOTE: shutters display _on state when they're closed, _off otherwise - if( true == MoverParameters->diesel.heat.water.config.shutters - && false == MoverParameters->diesel.heat.zaluzje1 ) { + if( true == physics->diesel.heat.water.config.shutters + && false == physics->diesel.heat.zaluzje1 ) { btShutters1.Turn( true ); btnOn = true; } - if( true == MoverParameters->diesel.heat.water_aux.config.shutters - && false == MoverParameters->diesel.heat.zaluzje2 ) { + if( true == physics->diesel.heat.water_aux.config.shutters + && false == physics->diesel.heat.zaluzje2 ) { btShutters2.Turn( true ); btnOn = true; } @@ -424,21 +424,21 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) && Mechanik != nullptr && Mechanik->action() != TAction::actSleep ) { // rysowanie figurki mechanika - btMechanik1.Turn(MoverParameters->CabOccupied > 0); - btMechanik2.Turn( MoverParameters->CabOccupied < 0 ); - if( MoverParameters->CabOccupied != 0 ) { + btMechanik1.Turn(physics->CabOccupied > 0); + btMechanik2.Turn( physics->CabOccupied < 0 ); + if( physics->CabOccupied != 0 ) { btnOn = true; } } } // vehicle within 400m - if( MoverParameters->Power24vIsAvailable || MoverParameters->Power110vIsAvailable ) + if( physics->Power24vIsAvailable || physics->Power110vIsAvailable ) { // sygnały czoła pociagu //Ra: wyświetlamy bez // ograniczeń odległości, by były widoczne z // daleka - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::headlight_left) + if (TestFlag(physics->iLights[VehicleEnd::front], light::headlight_left) && !HeadlightsAoff && !HighBeamLights) { if( DimHeadlights ) { @@ -449,7 +449,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::headlight_upper) + if (TestFlag(physics->iLights[VehicleEnd::front], light::headlight_upper) && !HeadlightsAoff) { if( DimHeadlights ) { @@ -460,7 +460,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::headlight_right) + if (TestFlag(physics->iLights[VehicleEnd::front], light::headlight_right) && !HeadlightsAoff && !HighBeamLights) { if( DimHeadlights ) { @@ -472,7 +472,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } // else btHeadSignals13.TurnOff(); - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::headlight_left) + if (TestFlag(physics->iLights[VehicleEnd::rear], light::headlight_left) && !HeadlightsBoff && !HighBeamLights) { if( DimHeadlights ) { @@ -483,7 +483,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::headlight_upper) + if (TestFlag(physics->iLights[VehicleEnd::rear], light::headlight_upper) && !HeadlightsBoff) { if( DimHeadlights ) { @@ -494,7 +494,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::headlight_right) + if (TestFlag(physics->iLights[VehicleEnd::rear], light::headlight_right) && !HeadlightsBoff && !HighBeamLights) { if( DimHeadlights ) { @@ -506,7 +506,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } // auxiliary lights - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::auxiliary_left) && !HeadlightsAoff) + if (TestFlag(physics->iLights[VehicleEnd::front], light::auxiliary_left) && !HeadlightsAoff) { if( DimHeadlights ) { m_headsignal13.TurnxOnWithOnAsFallback(); @@ -516,7 +516,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::auxiliary_right) && !HeadlightsAoff) + if (TestFlag(physics->iLights[VehicleEnd::front], light::auxiliary_right) && !HeadlightsAoff) { if( DimHeadlights ) { m_headsignal12.TurnxOnWithOnAsFallback(); @@ -526,7 +526,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::auxiliary_left) && !HeadlightsBoff) + if (TestFlag(physics->iLights[VehicleEnd::rear], light::auxiliary_left) && !HeadlightsBoff) { if( DimHeadlights ) { m_headsignal23.TurnxOnWithOnAsFallback(); @@ -536,7 +536,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } btnOn = true; } - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::auxiliary_right) && !HeadlightsBoff) + if (TestFlag(physics->iLights[VehicleEnd::rear], light::auxiliary_right) && !HeadlightsBoff) { if( DimHeadlights ) { m_headsignal22.TurnxOnWithOnAsFallback(); @@ -548,26 +548,26 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } // logika dlugich - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::headlight_left) + if (TestFlag(physics->iLights[VehicleEnd::front], light::headlight_left) && !HeadlightsAoff && HighBeamLights) m_highbeam13.TurnxOnWithOnAsFallback(); else m_highbeam13.TurnOff(); - if (TestFlag(MoverParameters->iLights[VehicleEnd::front], light::headlight_right) + if (TestFlag(physics->iLights[VehicleEnd::front], light::headlight_right) && !HeadlightsAoff && HighBeamLights) m_highbeam12.TurnxOnWithOnAsFallback(); else m_highbeam12.TurnOff(); // i to samo od dupy strony - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::headlight_left) + if (TestFlag(physics->iLights[VehicleEnd::rear], light::headlight_left) && !HeadlightsBoff && HighBeamLights) m_highbeam23.TurnxOnWithOnAsFallback(); else m_highbeam23.TurnOff(); - if (TestFlag(MoverParameters->iLights[VehicleEnd::rear], light::headlight_right) + if (TestFlag(physics->iLights[VehicleEnd::rear], light::headlight_right) && !HeadlightsBoff && HighBeamLights) m_highbeam22.TurnxOnWithOnAsFallback(); else @@ -583,7 +583,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) cabsection &= sectionname.size() >= 4 && sectionname.starts_with("cab"); } // TODO: add cablight devices - auto const sectionlightlevel { section.light_level * ( cabsection ? 1.0f : MoverParameters->CompartmentLights.intensity ) }; + auto const sectionlightlevel { section.light_level * ( cabsection ? 1.0f : physics->CompartmentLights.intensity ) }; sectionlightcolor = glm::vec4( sectionlightlevel == 0.f || Global.fLuminance > section.compartment->fLight ? glm::vec3(240.f / 255.f) : // TBD: save and restore initial submodel diffuse instead of enforcing one? @@ -642,35 +642,35 @@ TDynamicObject::update_shake( double const Timedelta ) { if( Global.iSlowMotion == 0 ) { // musi być pełna prędkość glm::dvec3 shakevector; - if( MoverParameters->EngineType == TEngineType::DieselElectric - || MoverParameters->EngineType == TEngineType::DieselEngine ) { - if( std::abs( MoverParameters->enrot ) > 0.0 ) { + if( physics->EngineType == TEngineType::DieselElectric + || physics->EngineType == TEngineType::DieselEngine ) { + if( std::abs( physics->enrot ) > 0.0 ) { // engine vibration shakevector.x += - std::sin(MoverParameters->eAngle * 4.0) * Timedelta * + std::sin(physics->eAngle * 4.0) * Timedelta * EngineShake.scale // fade in with rpm above threshold * std::clamp( - ( MoverParameters->enrot - EngineShake.fadein_offset ) * EngineShake.fadein_factor, + ( physics->enrot - EngineShake.fadein_offset ) * EngineShake.fadein_factor, 0.0, 1.0 ) // fade out with rpm above threshold * std::lerp( 1.0, 0.0, std::clamp( - ( MoverParameters->enrot - EngineShake.fadeout_offset ) * EngineShake.fadeout_factor, + ( physics->enrot - EngineShake.fadeout_offset ) * EngineShake.fadeout_factor, 0.0, 1.0 ) ); } } if( HuntingShake.fadein_begin > 0.f - && true == MoverParameters->TruckHunting ) { + && true == physics->TruckHunting ) { // hunting oscillation - HuntingAngle = clamp_circular( HuntingAngle + 4.0 * HuntingShake.frequency * Timedelta * MoverParameters->Vel, 360.0 ); + HuntingAngle = clamp_circular( HuntingAngle + 4.0 * HuntingShake.frequency * Timedelta * physics->Vel, 360.0 ); auto const huntingamount = std::lerp( 0.0, 1.0, std::clamp( - ( MoverParameters->Vel - HuntingShake.fadein_begin ) / ( HuntingShake.fadein_end - HuntingShake.fadein_begin ), + ( physics->Vel - HuntingShake.fadein_begin ) / ( HuntingShake.fadein_end - HuntingShake.fadein_begin ), 0.0, 1.0 ) ); shakevector.x += std::sin(glm::radians(HuntingAngle)) * Timedelta * HuntingShake.scale @@ -687,11 +687,11 @@ TDynamicObject::update_shake( double const Timedelta ) { if( iVel > 0.5 ) { // acceleration-driven base shake shakevector += glm::dvec3( - replaced.sway ? 0.0 : -MoverParameters->AccN * Timedelta * 5.0 * Global.ShakingMultiplierRL, // highlight side sway - -MoverParameters->AccVert * Timedelta * Global.ShakingMultiplierUD, - -MoverParameters->AccSVBased * Timedelta * 1.5 * Global.ShakingMultiplierBF); // accent acceleration/deceleration + replaced.sway ? 0.0 : -physics->AccN * Timedelta * 5.0 * Global.ShakingMultiplierRL, // highlight side sway + -physics->AccVert * Timedelta * Global.ShakingMultiplierUD, + -physics->AccSVBased * Timedelta * 1.5 * Global.ShakingMultiplierBF); // accent acceleration/deceleration // unevenness of the track under the outer axles - auto const ride { 0.5 * ( Axle0.UnevenBend() + Axle1.UnevenBend() ) * ( MoverParameters->V * MoverParameters->V ) }; + auto const ride { 0.5 * ( Axle0.UnevenBend() + Axle1.UnevenBend() ) * ( physics->V * physics->V ) }; shakevector += glm::dvec3( -glm::dot( ride, vLeft ) * Timedelta * 5.0 * Global.ShakingMultiplierRL, -ride.y * Timedelta * Global.ShakingMultiplierUD, diff --git a/vehicle/enginestart.cpp b/vehicle/enginestart.cpp index df29fae07..c221119f4 100644 --- a/vehicle/enginestart.cpp +++ b/vehicle/enginestart.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/enginestart.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "utilities/utilities.h" namespace engine_start { @@ -18,13 +18,13 @@ namespace engine_start { namespace { // whether the vehicle has an engine the cab can start, the same test the tachometers of the vehicles in multiple make -bool has_engine(TMoverParameters const &Vehicle) { +bool has_engine(physics::Vehicle const &Vehicle) { return Vehicle.Power > 0.01; } // walks from Start through its coupler Side along the control cable, and returns the Number-th vehicle with an engine // other than Skipped it meets; Number is lowered by the ones it met when it doesn't get that far -TMoverParameters *find_along(TMoverParameters const &Start, int const Side, TMoverParameters const &Skipped, int &Number) { +physics::Vehicle *find_along(physics::Vehicle const &Start, int const Side, physics::Vehicle const &Skipped, int &Number) { auto const *vehicle{&Start}; auto side{Side}; // a train can't loop back on itself, the limit only guards against a broken chain of couplers @@ -49,7 +49,7 @@ TMoverParameters *find_along(TMoverParameters const &Start, int const Side, TMov } // namespace -TMoverParameters *engine(TMoverParameters const &Occupied, TMoverParameters &Controlled, int Number) { +physics::Vehicle *engine(physics::Vehicle const &Occupied, physics::Vehicle &Controlled, int Number) { if (Number < 1) { return nullptr; } @@ -66,7 +66,7 @@ TMoverParameters *engine(TMoverParameters const &Occupied, TMoverParameters &Con return find_along(Occupied, 1 - behind, Controlled, others); } -void remote_switch::update(TMoverParameters *Engine, bool const Closeheld, bool const Openheld, double const Deltatime, bool const Closesonrelease) { +void remote_switch::update(physics::Vehicle *Engine, bool const Closeheld, bool const Openheld, double const Deltatime, bool const Closesonrelease) { if (Engine != m_engine) { // another vehicle under the switch, after a change in the train m_engine = Engine; @@ -98,11 +98,11 @@ void remote_switch::update(TMoverParameters *Engine, bool const Closeheld, bool } } -bool remote_switch::open(TMoverParameters &Engine) { +bool remote_switch::open(physics::Vehicle &Engine) { return Engine.MainSwitch(false, range_t::local); } -bool remote_switch::is_running(TMoverParameters const &Engine) { +bool remote_switch::is_running(physics::Vehicle const &Engine) { return Engine.Mains || Engine.diesel.startupRequested; } diff --git a/vehicle/enginestart.h b/vehicle/enginestart.h index 77b6a2d93..b2696ba46 100644 --- a/vehicle/enginestart.h +++ b/vehicle/enginestart.h @@ -9,20 +9,20 @@ http://mozilla.org/MPL/2.0/. #pragma once -class TMoverParameters; +namespace physics { class Vehicle; } // starting the engines (closing the line breakers) of the vehicles in multiple from the cab (eu07/maszyna#80). in // vehicles like the ST43, the SP32 or the SN61 every engine of the train has its own switches in the cab: main_* work -// the vehicle the cab controls (TTrain::mvControlled: the cab's own vehicle, on an EMU its motor car), mainb_* the +// the vehicle the cab controls (TTrain::controlled: the cab's own vehicle, on an EMU its motor car), mainb_* the // second one and mainc_* the third one under its control. Engine:JointEngineStart=No in the .fiz of the controlled // vehicle (on an EMU the motor car's, not the one of the car with the cab) keeps main_* to that vehicle alone -// (TMoverParameters::MainSwitchRange()); by default it works all of them, as before. +// (physics::Vehicle::MainSwitchRange()); by default it works all of them, as before. namespace engine_start { // the Number-th vehicle with an engine under the cab's control: 1 is Controlled, the cab's own; then the others // connected through the control cable, those behind the cab of Occupied first, the nearest first, then those in front // of it. nullptr when there are fewer of them -TMoverParameters *engine(TMoverParameters const &Occupied, TMoverParameters &Controlled, int Number); +physics::Vehicle *engine(physics::Vehicle const &Occupied, physics::Vehicle &Controlled, int Number); // the switch starting the engine of another vehicle in multiple. like the cab's own switch, it has to be held closed // for the vehicle's InitialCtrlDelay, with the vehicle ready for it, before the engine starts (the line breaker closes) @@ -31,14 +31,14 @@ public: // one step of Deltatime seconds of the switch of Engine, with the switch held closed (Closeheld) or open (Openheld). // with Closesonrelease, the line breaker closes when the switch is let go after the delay, as the impulse switch // of an electric locomotive with series motors does - void update(TMoverParameters *Engine, bool Closeheld, bool Openheld, double Deltatime, bool Closesonrelease); + void update(physics::Vehicle *Engine, bool Closeheld, bool Openheld, double Deltatime, bool Closesonrelease); // opens the line breaker / stops the engine of Engine, the vehicle alone; returns whether it was running - static bool open(TMoverParameters &Engine); + static bool open(physics::Vehicle &Engine); // whether the line breaker of Engine is closed or its engine starting or running - static bool is_running(TMoverParameters const &Engine); + static bool is_running(physics::Vehicle const &Engine); private: - TMoverParameters const *m_engine{nullptr}; // the vehicle the switch worked the last step + physics::Vehicle const *m_engine{nullptr}; // the vehicle the switch worked the last step double m_heldtime{0.0}; // how long the switch is held closed with the vehicle ready to start bool m_ready{false}; // held long enough, the line breaker closes now or when the switch is let go }; diff --git a/vehicle/handover.cpp b/vehicle/handover.cpp index 878afdf3d..73996d12e 100644 --- a/vehicle/handover.cpp +++ b/vehicle/handover.cpp @@ -10,11 +10,11 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/handover.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace handover { -void release_ai_controls(TMoverParameters &Occupied, TMoverParameters &Controlling) { +void release_ai_controls(physics::Vehicle &Occupied, physics::Vehicle &Controlling) { // the AI's hornoff action touches the horn only while the AI drives Occupied.WarningSignal = 0; // the AI drives the sandbox directly, bypassing the manual and automatic sanding states @@ -29,7 +29,7 @@ void release_ai_controls(TMoverParameters &Occupied, TMoverParameters &Controlli } } -int light_selector_position(TMoverParameters const &Occupied, int const Lightstable, int const Headlights, int const Inventory) { +int light_selector_position(physics::Vehicle const &Occupied, int const Lightstable, int const Headlights, int const Inventory) { // the selector size comes from the vehicle definition, the table holds a fixed number of positions auto const positioncount{std::min(Occupied.LightsPosNo, static_cast(std::size(Occupied.Lights[0])))}; if (positioncount <= 0 || Lightstable < 0 || Lightstable >= static_cast(std::size(Occupied.Lights))) { @@ -48,7 +48,7 @@ int light_selector_position(TMoverParameters const &Occupied, int const Lightsta return Occupied.LightsPos; } -int dimmer_position(TMoverParameters const &Occupied, bool const Headlightson) { +int dimmer_position(physics::Vehicle const &Occupied, bool const Headlightson) { auto const &positions{Occupied.dimPositions}; auto const current{Occupied.modernDimmerPosition}; auto const count{static_cast(positions.size())}; diff --git a/vehicle/handover.h b/vehicle/handover.h index 32ed57d0a..f02edca68 100644 --- a/vehicle/handover.h +++ b/vehicle/handover.h @@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/. #pragma once -class TMoverParameters; +namespace physics { class Vehicle; } // what changes about a vehicle when the AI hands it over to the human driver. the AI operates some // controls directly, bypassing the cab controls a human uses, and only the AI ever releases them; @@ -18,16 +18,16 @@ namespace handover { // releases what the AI latches, but which is held only while pressed for the human driver: // the horn, the sandbox, the departure signal and the brake releaser -void release_ai_controls(TMoverParameters &Occupied, TMoverParameters &Controlling); +void release_ai_controls(physics::Vehicle &Occupied, physics::Vehicle &Controlling); // position of the light preset selector [1..LightsPosNo] for the human driver: the current one when it // gives the head lights the AI has set, else the first one which does, else the current one. // Lightstable is the end of the selector's table in use, Inventory the lights the head end has -int light_selector_position(TMoverParameters const &Occupied, int Lightstable, int Headlights, int Inventory); +int light_selector_position(physics::Vehicle const &Occupied, int Lightstable, int Headlights, int Inventory); // position of the headlight dimmer for the human driver: the current one, unless it's the off position // which would hide the head lights the AI has lit. then the default one, else the first regular one, // else any other than off -int dimmer_position(TMoverParameters const &Occupied, bool Headlightson); +int dimmer_position(physics::Vehicle const &Occupied, bool Headlightson); } // namespace handover diff --git a/vehicle/lightsprogrammer.h b/vehicle/lightsprogrammer.h index bf9728b1e..6e0cd7bbb 100644 --- a/vehicle/lightsprogrammer.h +++ b/vehicle/lightsprogrammer.h @@ -11,7 +11,7 @@ http://mozilla.org/MPL/2.0/. #include -#include "physics/mover.h" +#include "physics/vehicle.h" // the lights the light preset selector (programmer) of the occupied cab gives one vehicle of the consist namespace lights_programmer { diff --git a/vehicle/linebreaker.h b/vehicle/linebreaker.h index e87312dd1..cfcf76003 100644 --- a/vehicle/linebreaker.h +++ b/vehicle/linebreaker.h @@ -12,7 +12,7 @@ http://mozilla.org/MPL/2.0/. // the line breaker (main switch, WS) controls of the cab namespace linebreaker { -// the state the cab keeps of the line breaker, besides the vehicle's own (TMoverParameters::Mains) +// the state the cab keeps of the line breaker, besides the vehicle's own (physics::Vehicle::Mains) enum class state : int { open, closed, diff --git a/vehicle/mainctrlact.h b/vehicle/mainctrlact.h index eb594473e..15b943de1 100644 --- a/vehicle/mainctrlact.h +++ b/vehicle/mainctrlact.h @@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/. #pragma once -#include "physics/mover.h" +#include "physics/vehicle.h" // the position the controller position marker of the cab (mainctrlact:) shows namespace main_ctrl_act { @@ -17,14 +17,14 @@ namespace main_ctrl_act { // the diesel engines work the controller position straight away, they have no camshaft or relays of their own that // would follow it, and nothing sets their MainCtrlActualPos; only with a controller of the EIM kind (EIMCtrlType) // it is kept up to date (CheckEIMIC). so their marker shows the position of the controller (MaSzyna-EU07/maszyna#74) -inline bool follows_controller(TMoverParameters const &Vehicle) { +inline bool follows_controller(physics::Vehicle const &Vehicle) { return (Vehicle.EngineType == TEngineType::DieselEngine || Vehicle.EngineType == TEngineType::DieselElectric) && Vehicle.EIMCtrlType == 0; } // Scaletable: the cab's gauge has a scaletable:. only such a marker follows the controller; the cabs that define // mainctrlact: without one (the ST43 so far) keep their marker still, as before, instead of moving it on a scale // nobody has checked -inline float position(TMoverParameters const &Vehicle, bool const Scaletable) { +inline float position(physics::Vehicle const &Vehicle, bool const Scaletable) { auto const controller{Scaletable && follows_controller(Vehicle)}; auto const main{controller ? Vehicle.MainCtrlPos : Vehicle.MainCtrlActualPos}; auto const scnd{controller ? Vehicle.ScndCtrlPos : Vehicle.ScndCtrlActualPos}; diff --git a/vehicle/odometer.h b/vehicle/odometer.h index 958a15f60..4fe369764 100644 --- a/vehicle/odometer.h +++ b/vehicle/odometer.h @@ -105,7 +105,7 @@ private: // the vehicle is one the store keeps: one with a driver's cab, which can show its odometer on the cab's counter or a // python screen. that's -// - a vehicle whose type has a cab (Drivercab, TMoverParameters::HasDriverCab(): it has the driver's brake valve). that +// - a vehicle whose type has a cab (Drivercab, physics::Vehicle::HasDriverCab(): it has the driver's brake valve). that // includes the locomotives and units the AI runs before a player's cab loads them, their made up states stay // replaceable by the cab's counter // - a vehicle whose cab showed the odometer in this session (reading::shown): the cab was loaded for a player, or a diff --git a/vehicle/odometerreading.h b/vehicle/odometerreading.h index 286b2da5a..e5d0e7b00 100644 --- a/vehicle/odometerreading.h +++ b/vehicle/odometerreading.h @@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/. #pragma once -// the odometer of a vehicle (eu07/maszyna#72), the part the vehicle physics (TMoverParameters::Odometer) keeps: plain +// the odometer of a vehicle (eu07/maszyna#72), the part the vehicle physics (physics::Vehicle::Odometer) keeps: plain // data, without the store and its files, which are in vehicle/odometer.h namespace odometer { diff --git a/vehicle/pulleemode.h b/vehicle/pulleemode.h index f01ed5768..e1b7a73ed 100644 --- a/vehicle/pulleemode.h +++ b/vehicle/pulleemode.h @@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/. #include // the pullee mode ("jazda ciągniona", MaSzyna-EU07/maszyna#64): a vehicle prepared for being hauled dead in a train, -// TMoverParameters::PulleeModeSwitch(). a scenery asks for it with the parameter H among the ones written after the +// physics::Vehicle::PulleeModeSwitch(). a scenery asks for it with the parameter H among the ones written after the // coupling of the vehicle, split by dots: "3.H", or with others, "3.BG.H" // node -1 0 EU160-001 dynamic pkp/vectron_v1 1293-107 wariant_7w 0 nobody 3.H 0 enddynamic namespace pullee_mode { diff --git a/vehicle/smoke.cpp b/vehicle/smoke.cpp index b12c4d3ca..b0805374d 100644 --- a/vehicle/smoke.cpp +++ b/vehicle/smoke.cpp @@ -10,37 +10,37 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/smoke.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace smoke { namespace { // how hard the engine works, scaling the spawn rate of the source -double engine_load(TMoverParameters const &Mover) { - if (Mover.diesel.spinningUp) { +double engine_load(physics::Vehicle const &Physics) { + if (Physics.diesel.spinningUp) { // starting up, it puffs harder the faster it turns - return ((Mover.enrot / 4) * 0.01); + return ((Physics.enrot / 4) * 0.01); } - auto const rpmrise{(Mover.DElist[Mover.MainCtrlPosNo].RPM - Mover.enrot) / 60}; - if (Mover.DirAbsolute == 0 || Mover.Im == 0) { + auto const rpmrise{(Physics.DElist[Physics.MainCtrlPosNo].RPM - Physics.enrot) / 60}; + if (Physics.DirAbsolute == 0 || Physics.Im == 0) { // idling: speeding up to the revolutions of the master controller - return ((rpmrise * 0.02) * (Mover.EnginePower * 0.005)); + return ((rpmrise * 0.02) * (Physics.EnginePower * 0.005)); } // under load: the more current the traction motors draw, the more smoke - return ((rpmrise * (std::sqrt(Mover.Im) * 0.01) * 0.02) * (Mover.EnginePower * 0.005)); + return ((rpmrise * (std::sqrt(Physics.Im) * 0.01) * 0.02) * (Physics.EnginePower * 0.005)); } } // namespace -float vehicle_spawn_count(TMoverParameters const &Mover, bool const Ontracks, spawn_rate const &Rate, double const Timedelta) { - if (false == Ontracks || Mover.diesel.firingCountdown > 0.0) { +float vehicle_spawn_count(physics::Vehicle const &Physics, bool const Ontracks, spawn_rate const &Rate, double const Timedelta) { + if (false == Ontracks || Physics.diesel.firingCountdown > 0.0) { return 0.f; } // the steady rate of the source, the way a source of the scenery spawns... auto const steady{std::min(static_cast(Rate.pending + (Rate.rate * Timedelta * Rate.fidelity)), Rate.limit)}; // ...and on top of it the share of the engine - return std::min(static_cast(steady + (Rate.rate * Timedelta * Rate.fidelity * engine_load(Mover))), Rate.limit); + return std::min(static_cast(steady + (Rate.rate * Timedelta * Rate.fidelity * engine_load(Physics))), Rate.limit); } } // namespace smoke diff --git a/vehicle/smoke.h b/vehicle/smoke.h index e3c3adec5..0391c70ff 100644 --- a/vehicle/smoke.h +++ b/vehicle/smoke.h @@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/. #pragma once -class TMoverParameters; +namespace physics { class Vehicle; } // the smoke of a vehicle's engine, let out by the smoke sources of its model (rendering/particles.h) namespace smoke { @@ -25,7 +25,7 @@ struct spawn_rate { // number of particles the smoke source of a vehicle has to spawn after Timedelta seconds: the steady rate of the // source, plus a share which grows with the work of its engine. a vehicle taken off the tracks (Ontracks false: gone through a portal, or waiting in the pool of the road // traffic) puffs no more, the particles it already let out fade away as usual -// an engine the starter turns but which hasn't fired yet (TMoverParameters::diesel.firingCountdown) lets out no smoke either -float vehicle_spawn_count(TMoverParameters const &Mover, bool Ontracks, spawn_rate const &Rate, double Timedelta); +// an engine the starter turns but which hasn't fired yet (physics::Vehicle::diesel.firingCountdown) lets out no smoke either +float vehicle_spawn_count(physics::Vehicle const &Physics, bool Ontracks, spawn_rate const &Rate, double Timedelta); } // namespace smoke diff --git a/vehicle/timetableservice.cpp b/vehicle/timetableservice.cpp index cca7a5e17..eac25815b 100644 --- a/vehicle/timetableservice.cpp +++ b/vehicle/timetableservice.cpp @@ -10,11 +10,11 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/timetableservice.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace timetable { -bool opens_doors(TMoverParameters const &Vehicle, service_flags const &Flags) { +bool opens_doors(physics::Vehicle const &Vehicle, service_flags const &Flags) { switch (Vehicle.Doors.open_control) { case control_t::conductor: case control_t::driver: diff --git a/vehicle/timetableservice.h b/vehicle/timetableservice.h index b5c72adf7..b1c32576f 100644 --- a/vehicle/timetableservice.h +++ b/vehicle/timetableservice.h @@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/. #include "world/timetableflags.h" -class TMoverParameters; +namespace physics { class Vehicle; } // what the AI driver does at a stop and on the way, as the service flags of the timetable ask (eu07/maszyna#95). with // no flags each answer is the one the AI gave before the flags @@ -22,7 +22,7 @@ namespace timetable { // whether the driver opens the doors of the consist from the cab at a stop, Vehicle being the one he drives: the doors // the conductor or the driver opens, and with the central door opening also the ones of mixed control, which are // otherwise left to the passengers -bool opens_doors(TMoverParameters const &Vehicle, service_flags const &Flags); +bool opens_doors(physics::Vehicle const &Vehicle, service_flags const &Flags); // the state the driver sets the doorsteps to before he opens the doors at a stop, none when he leaves them as they are std::optional doorstep(service_flags const &Flags); diff --git a/widgets/trainingcard.cpp b/widgets/trainingcard.cpp index 31434237f..d5a464e92 100644 --- a/widgets/trainingcard.cpp +++ b/widgets/trainingcard.cpp @@ -2,7 +2,7 @@ #include "widgets/trainingcard.h" #include "simulation/simulation.h" #include "utilities/utilities.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include "vehicle/DynObj.h" #ifdef __linux__ @@ -179,7 +179,7 @@ void trainingcard_panel::render_contents() { state.store(2); if (simulation::Trains.sequence().size() > 0) - distance = static_cast(simulation::Trains.sequence()[0]->Dynamic()->MoverParameters->DistCounter); + distance = static_cast(simulation::Trains.sequence()[0]->Dynamic()->physics->DistCounter); if (save_thread.joinable()) save_thread.join(); diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index 86966de40..dd439cfbb 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -4,7 +4,7 @@ #include "application/driveruipanels.h" #include "vehicle/Driver.h" #include "vehicle/Train.h" -#include "physics/mover.h" +#include "physics/vehicle.h" ui::vehicleparams_panel::vehicleparams_panel(const std::string &vehicle) : ui_panel(std::string(STR("Vehicle parameters")) + ": " + vehicle, false), m_vehicle_name(vehicle) { @@ -47,7 +47,7 @@ void ui::vehicleparams_panel::draw_infobutton(const char *str, ImVec2 pos, const ImGui::PopStyleColor(4); } -void ui::vehicleparams_panel::draw_mini(const TMoverParameters &mover) +void ui::vehicleparams_panel::draw_mini(const physics::Vehicle &physics) { if (vehicle_mini == null_handle) return; @@ -63,34 +63,34 @@ void ui::vehicleparams_panel::draw_mini(const TMoverParameters &mover) { ImGui::Image((ImTextureID)(intptr_t)(tex.get_id()), ImVec2(x, y), ImVec2(0, 1), ImVec2(1, 0)); - if (mover.Pantographs[VehicleEnd::rear].is_active) + if (physics.Pantographs[VehicleEnd::rear].is_active) draw_infobutton("╨╨╨", ImVec2(126, 10)); - if (mover.Pantographs[VehicleEnd::front].is_active) + if (physics.Pantographs[VehicleEnd::front].is_active) draw_infobutton("╨╨╨", ImVec2(290, 10)); - if (mover.Battery) + if (physics.Battery) draw_infobutton(STR_C("bat."), ImVec2(120, 55)); - if (mover.Mains) + if (physics.Mains) draw_infobutton(STR_C("main.")); - if (mover.ConverterFlag) + if (physics.ConverterFlag) draw_infobutton(STR_C("conv.")); - if (mover.CompressorFlag) + if (physics.CompressorFlag) draw_infobutton(STR_C("comp.")); - if (mover.WarningSignal) + if (physics.WarningSignal) draw_infobutton(STR_C("horn"), ImVec2(361, 11)); - if (mover.iLights[VehicleEnd::front] & light::redmarker_left) + if (physics.iLights[VehicleEnd::front] & light::redmarker_left) draw_infobutton("o", ImVec2(490, 71), ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); - else if (mover.iLights[VehicleEnd::front] & light::headlight_left) + else if (physics.iLights[VehicleEnd::front] & light::headlight_left) draw_infobutton("O", ImVec2(490, 71), ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); - if (mover.iLights[VehicleEnd::front] & light::redmarker_right) + if (physics.iLights[VehicleEnd::front] & light::redmarker_right) draw_infobutton("o", ImVec2(443, 71), ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); - else if (mover.iLights[VehicleEnd::front] & light::headlight_right) + else if (physics.iLights[VehicleEnd::front] & light::headlight_right) draw_infobutton("O", ImVec2(443, 71), ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); - if (mover.iLights[VehicleEnd::front] & light::headlight_upper) + if (physics.iLights[VehicleEnd::front] & light::headlight_upper) draw_infobutton("O", ImVec2(467, 18), ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); } ImGui::EndChild(); @@ -138,28 +138,28 @@ void ui::vehicleparams_panel::render_contents() } TDynamicObject &vehicle = *vehicle_ptr; - TMoverParameters &mover = *vehicle.MoverParameters; + physics::Vehicle &physics = *vehicle.physics; std::vector lines; std::array buffer; - auto const isdieselenginepowered{(mover.EngineType == TEngineType::DieselElectric) || (mover.EngineType == TEngineType::DieselEngine)}; - auto const isdieselinshuntmode{mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric}; + auto const isdieselenginepowered{(physics.EngineType == TEngineType::DieselElectric) || (physics.EngineType == TEngineType::DieselEngine)}; + auto const isdieselinshuntmode{physics.ShuntMode && physics.EngineType == TEngineType::DieselElectric}; std::snprintf(buffer.data(), buffer.size(), STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s%s%s%.0f@%.0f"), // devices - (mover.Battery ? 'B' : '.'), (mover.Mains ? 'M' : '.'), (mover.FuseFlag ? '!' : '.'), (mover.Pantographs[VehicleEnd::rear].is_active ? (mover.PantRearVolt > 0.0 ? 'O' : 'o') : '.'), - (mover.Pantographs[VehicleEnd::front].is_active ? (mover.PantFrontVolt > 0.0 ? 'P' : 'p') : '.'), (mover.PantPressLockActive ? '!' : (mover.PantPressSwitchActive ? '*' : '.')), - (mover.WaterPump.is_active ? 'W' : (false == mover.WaterPump.breaker ? '-' : (mover.WaterPump.is_enabled ? 'w' : '.'))), - (true == mover.WaterHeater.is_damaged ? '!' : (mover.WaterHeater.is_active ? 'H' : (false == mover.WaterHeater.breaker ? '-' : (mover.WaterHeater.is_enabled ? 'h' : '.')))), - (mover.FuelPump.is_active ? 'F' : (mover.FuelPump.is_enabled ? 'f' : '.')), (mover.OilPump.is_active ? 'O' : (mover.OilPump.is_enabled ? 'o' : '.')), - (false == mover.ConverterAllowLocal ? '-' : (mover.ConverterAllow ? (mover.ConverterFlag ? 'X' : 'x') : '.')), (mover.ConvOvldFlag ? '!' : '.'), - (mover.CompressorFlag ? 'C' : (false == mover.CompressorAllowLocal ? '-' : ((mover.CompressorAllow || mover.CompressorStart == start_t::automatic) ? 'c' : '.'))), - (mover.CompressorGovernorLock ? '!' : '.'), "", std::string(isdieselenginepowered ? STR(" oil pressure: ") + to_string(mover.OilPump.pressure, 2) : "").c_str(), + (physics.Battery ? 'B' : '.'), (physics.Mains ? 'M' : '.'), (physics.FuseFlag ? '!' : '.'), (physics.Pantographs[VehicleEnd::rear].is_active ? (physics.PantRearVolt > 0.0 ? 'O' : 'o') : '.'), + (physics.Pantographs[VehicleEnd::front].is_active ? (physics.PantFrontVolt > 0.0 ? 'P' : 'p') : '.'), (physics.PantPressLockActive ? '!' : (physics.PantPressSwitchActive ? '*' : '.')), + (physics.WaterPump.is_active ? 'W' : (false == physics.WaterPump.breaker ? '-' : (physics.WaterPump.is_enabled ? 'w' : '.'))), + (true == physics.WaterHeater.is_damaged ? '!' : (physics.WaterHeater.is_active ? 'H' : (false == physics.WaterHeater.breaker ? '-' : (physics.WaterHeater.is_enabled ? 'h' : '.')))), + (physics.FuelPump.is_active ? 'F' : (physics.FuelPump.is_enabled ? 'f' : '.')), (physics.OilPump.is_active ? 'O' : (physics.OilPump.is_enabled ? 'o' : '.')), + (false == physics.ConverterAllowLocal ? '-' : (physics.ConverterAllow ? (physics.ConverterFlag ? 'X' : 'x') : '.')), (physics.ConvOvldFlag ? '!' : '.'), + (physics.CompressorFlag ? 'C' : (false == physics.CompressorAllowLocal ? '-' : ((physics.CompressorAllow || physics.CompressorStart == start_t::automatic) ? 'c' : '.'))), + (physics.CompressorGovernorLock ? '!' : '.'), "", std::string(isdieselenginepowered ? STR(" oil pressure: ") + to_string(physics.OilPump.pressure, 2) : "").c_str(), // power transfers - mover.Couplers[VehicleEnd::front].power_high.voltage, mover.Couplers[VehicleEnd::front].power_high.current, std::string(mover.Couplers[VehicleEnd::front].power_high.is_local ? "" : "-").c_str(), - std::string(vehicle.DirectionGet() ? ":<<:" : ":>>:").c_str(), std::string(mover.Couplers[VehicleEnd::rear].power_high.is_local ? "" : "-").c_str(), - mover.Couplers[VehicleEnd::rear].power_high.voltage, mover.Couplers[VehicleEnd::rear].power_high.current); + physics.Couplers[VehicleEnd::front].power_high.voltage, physics.Couplers[VehicleEnd::front].power_high.current, std::string(physics.Couplers[VehicleEnd::front].power_high.is_local ? "" : "-").c_str(), + std::string(vehicle.DirectionGet() ? ":<<:" : ":>>:").c_str(), std::string(physics.Couplers[VehicleEnd::rear].power_high.is_local ? "" : "-").c_str(), + physics.Couplers[VehicleEnd::rear].power_high.voltage, physics.Couplers[VehicleEnd::rear].power_high.current); ImGui::TextUnformatted(buffer.data()); @@ -167,20 +167,20 @@ void ui::vehicleparams_panel::render_contents() STR_C("Controllers:\n master: %d(%d), secondary: %s\nEngine output: %.1f, current: %.0f\nRevolutions:\n engine: %.0f, motors: %.0f\n engine fans: %.0f, motor fans: %.0f+%.0f, " "cooling fans: %.0f+%.0f"), // controllers - mover.MainCtrlPos, mover.MainCtrlActualPos, - std::string(isdieselinshuntmode ? to_string(mover.AnPos, 2) + STR(" (shunt mode)") : std::to_string(mover.ScndCtrlPos) + "(" + std::to_string(mover.ScndCtrlActualPos) + ")").c_str(), + physics.MainCtrlPos, physics.MainCtrlActualPos, + std::string(isdieselinshuntmode ? to_string(physics.AnPos, 2) + STR(" (shunt mode)") : std::to_string(physics.ScndCtrlPos) + "(" + std::to_string(physics.ScndCtrlActualPos) + ")").c_str(), // engine - mover.EnginePower, std::abs(mover.TrainType == train_type::emu ? mover.ShowCurrent(0) : mover.Im), + physics.EnginePower, std::abs(physics.TrainType == train_type::emu ? physics.ShowCurrent(0) : physics.Im), // revolutions - std::abs(mover.enrot) * 60, std::abs(mover.nrot) * mover.Transmision.Ratio * 60, mover.RventRot * 60, std::abs(mover.MotorBlowers[VehicleEnd::front].revolutions), - std::abs(mover.MotorBlowers[VehicleEnd::rear].revolutions), mover.diesel.heat.rpmw, mover.diesel.heat.rpmw2); + std::abs(physics.enrot) * 60, std::abs(physics.nrot) * physics.Transmision.Ratio * 60, physics.RventRot * 60, std::abs(physics.MotorBlowers[VehicleEnd::front].revolutions), + std::abs(physics.MotorBlowers[VehicleEnd::rear].revolutions), physics.diesel.heat.rpmw, physics.diesel.heat.rpmw2); ImGui::TextUnformatted(buffer.data()); if (isdieselenginepowered) { - std::snprintf(buffer.data(), buffer.size(), STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"), mover.diesel.heat.Ts, mover.diesel.heat.To, mover.diesel.heat.temperatura1, - (mover.WaterCircuitsLink ? '-' : '|'), mover.diesel.heat.temperatura2); + std::snprintf(buffer.data(), buffer.size(), STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"), physics.diesel.heat.Ts, physics.diesel.heat.To, physics.diesel.heat.temperatura1, + (physics.WaterCircuitsLink ? '-' : '|'), physics.diesel.heat.temperatura2); ImGui::TextUnformatted(buffer.data()); } @@ -190,7 +190,7 @@ void ui::vehicleparams_panel::render_contents() for (auto const &delay : delays) { - if ((mover.BrakeDelayFlag & delay.first) == delay.first) + if ((physics.BrakeDelayFlag & delay.first) == delay.first) { brakedelay += delay.second; } @@ -201,19 +201,19 @@ void ui::vehicleparams_panel::render_contents() STR_C("Brakes:\n train: %.2f, independent: %.2f, mode: %d, delay: %s, load flag: %d\nBrake cylinder pressures:\n train: %.2f, independent: %.2f, status: 0x%.2x\nPipe pressures:\n " "brake: %.2f (hat: %.2f), main: %.2f, control: %.2f\nTank pressures:\n auxiliary: %.2f, main: %.2f, control: %.2f"), // brakes - mover.fBrakeCtrlPos, mover.LocalBrakePosA, mover.BrakeOpModeFlag, brakedelay.c_str(), mover.LoadFlag, + physics.fBrakeCtrlPos, physics.LocalBrakePosA, physics.BrakeOpModeFlag, brakedelay.c_str(), physics.LoadFlag, // cylinders - mover.BrakePress, mover.LocBrakePress, mover.Hamulec->GetBrakeStatus(), + physics.BrakePress, physics.LocBrakePress, physics.Hamulec->GetBrakeStatus(), // pipes - mover.PipePress, mover.BrakeCtrlPos2, mover.ScndPipePress, mover.CntrlPipePress, + physics.PipePress, physics.BrakeCtrlPos2, physics.ScndPipePress, physics.CntrlPipePress, // tanks - mover.Hamulec->GetBRP(), mover.Compressor, mover.Hamulec->GetCRP()); + physics.Hamulec->GetBRP(), physics.Compressor, physics.Hamulec->GetCRP()); ImGui::TextUnformatted(buffer.data()); - if (mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector) + if (physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { - std::snprintf(buffer.data(), buffer.size(), STR_C(" pantograph: %.2f%cMT"), mover.PantPress, (mover.bPantKurek3 ? '-' : '|')); + std::snprintf(buffer.data(), buffer.size(), STR_C(" pantograph: %.2f%cMT"), physics.PantPress, (physics.bPantKurek3 ? '-' : '|')); ImGui::TextUnformatted(buffer.data()); } @@ -221,16 +221,16 @@ void ui::vehicleparams_panel::render_contents() STR_C("Forces:\n tractive: %.1f, brake: %.1f, friction: %.2f%s\nAcceleration:\n tangential: %.2f, normal: %.2f (path radius: %s)\nVelocity: %.2f, distance traveled: %.2f\nPosition: " "[%.2f, %.2f, %.2f]"), // forces - mover.Ft * 0.001f * - (mover.CabActive ? mover.CabActive : + physics.Ft * 0.001f * + (physics.CabActive ? physics.CabActive : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabActive : 1) + 0.001f, - mover.Fb * 0.001f, mover.Adhesive(mover.RunningTrack.friction), (mover.SlippingWheels ? " (!)" : ""), + physics.Fb * 0.001f, physics.Adhesive(physics.RunningTrack.friction), (physics.SlippingWheels ? " (!)" : ""), // acceleration - mover.AccSVBased, mover.AccN + 0.001f, std::string(std::abs(mover.RunningShape.R) > 10000.0 ? "~0" : to_string(mover.RunningShape.R, 0)).c_str(), + physics.AccSVBased, physics.AccN + 0.001f, std::string(std::abs(physics.RunningShape.R) > 10000.0 ? "~0" : to_string(physics.RunningShape.R, 0)).c_str(), // velocity - vehicle.GetVelocity(), mover.DistCounter, + vehicle.GetVelocity(), physics.DistCounter, // position vehicle.GetPosition().x, vehicle.GetPosition().y, vehicle.GetPosition().z); @@ -249,8 +249,8 @@ void ui::vehicleparams_panel::render_contents() while (vehicle_iter) { - TrainsetPowerMeter.first += vehicle_iter->MoverParameters->EnergyMeter.first; - TrainsetPowerMeter.second += vehicle_iter->MoverParameters->EnergyMeter.second; + TrainsetPowerMeter.first += vehicle_iter->physics->EnergyMeter.first; + TrainsetPowerMeter.second += vehicle_iter->physics->EnergyMeter.second; vehicle_iter = vehicle_iter->Prev(); } @@ -262,7 +262,7 @@ void ui::vehicleparams_panel::render_contents() ImGui::TextUnformatted(buffer.data()); } - draw_mini(mover); + draw_mini(physics); if (ImGui::Button(STR_C("Radiostop"))) m_relay.post(user_command::radiostopsend, 0.0, 0.0, GLFW_PRESS, 0, vehicle_ptr->GetPosition()); @@ -293,7 +293,7 @@ void ui::vehicleparams_panel::render_contents() if (ImGui::IsItemDeactivated()) m_relay.post(user_command::consistreleaser, 0.0, 0.0, GLFW_RELEASE, 0, glm::vec3(0.0f), &vehicle_ptr->name()); - if (vehicle_ptr->MoverParameters->V < 0.01) + if (vehicle_ptr->physics->V < 0.01) { if (ImGui::Button(STR_C("Move +500m"))) m_relay.post(user_command::dynamicmove, 500.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name()); diff --git a/widgets/vehicleparams.h b/widgets/vehicleparams.h index 787e1e819..d8eb0910e 100644 --- a/widgets/vehicleparams.h +++ b/widgets/vehicleparams.h @@ -14,7 +14,7 @@ class vehicleparams_panel : public ui_panel texture_handle vehicle_mini; void draw_infobutton(const char *str, ImVec2 pos = ImVec2(-1.0f, -1.0f), const ImVec4 color = ImVec4(1.0f, 1.0f, 0.0f, 1.0f)); - void draw_mini(const TMoverParameters &mover); + void draw_mini(const physics::Vehicle &physics); public: vehicleparams_panel(const std::string &vehicle); diff --git a/world/Event.cpp b/world/Event.cpp index acd53908c..d76749dc6 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -34,7 +34,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "utilities/Logs.h" #include "widgets/map_objects.h" -#include "physics/mover.h" +#include "physics/vehicle.h" void basic_event::event_conditions::bind( basic_event::node_sequence *Nodes ) { @@ -722,7 +722,7 @@ putvalues_event::run_() { else { // przekazanie do pojazdu WriteLog( " Vehicle: [" + m_activator->name() +"]" ); - m_activator->MoverParameters->PutCommand( + m_activator->physics->PutCommand( m_input.data_text, m_input.data_value_1, m_input.data_value_2, @@ -1042,30 +1042,30 @@ whois_event::run_() { -1.0 ) }; targetcell->UpdateValues( - m_activator->MoverParameters->TypeName, // typ pojazdu + m_activator->physics->TypeName, // typ pojazdu consistbrakelevel, collisiondistance, m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " - + "[type: " + m_activator->MoverParameters->TypeName + "], " + + "[type: " + m_activator->physics->TypeName + "], " + "[consist brake level: " + to_string( consistbrakelevel, 2 ) + "], " + "[obstacle distance: " + to_string( collisiondistance, 2 ) + " m]" ); } else { // jeśli parametry ładunku targetcell->UpdateValues( - m_activator->MoverParameters->LoadType.name, // nazwa ładunku - m_activator->MoverParameters->LoadAmount, // aktualna ilość - m_activator->MoverParameters->MaxLoad, // maksymalna ilość + m_activator->physics->LoadType.name, // nazwa ładunku + m_activator->physics->LoadAmount, // aktualna ilość + m_activator->physics->MaxLoad, // maksymalna ilość m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " - + "[load type: " + m_activator->MoverParameters->LoadType.name + "], " - + "[current load: " + to_string( m_activator->MoverParameters->LoadAmount, 2 ) + "], " - + "[max load: " + to_string( m_activator->MoverParameters->MaxLoad, 2 ) + "]" ); + + "[load type: " + m_activator->physics->LoadType.name + "], " + + "[current load: " + to_string( m_activator->physics->LoadAmount, 2 ) + "], " + + "[max load: " + to_string( m_activator->physics->MaxLoad, 2 ) + "]" ); } } // +8 @@ -1073,14 +1073,14 @@ whois_event::run_() { targetcell->UpdateValues( m_activator->asDestination, // adres docelowy m_activator->DirectionGet(), // kierunek pojazdu względem czoła składu (1=zgodny,-1=przeciwny) - m_activator->MoverParameters->Power, // moc pojazdu silnikowego: 0 dla wagonu + m_activator->physics->Power, // moc pojazdu silnikowego: 0 dla wagonu m_input.flags & ( flags::text | flags::value1 | flags::value2 ) ); WriteLog( "Type: WhoIs (" + std::to_string( m_input.flags ) + ") - " + "[destination: " + m_activator->asDestination + "], " + "[direction: " + std::to_string( m_activator->DirectionGet() ) + "], " - + "[engine power: " + to_string( m_activator->MoverParameters->Power, 2 ) + "]" ); + + "[engine power: " + to_string( m_activator->physics->Power, 2 ) + "]" ); } // +0 else { diff --git a/world/Road.cpp b/world/Road.cpp index 58b5fd575..39396b87f 100644 --- a/world/Road.cpp +++ b/world/Road.cpp @@ -20,7 +20,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "utilities/parser.h" #include "utilities/utilities.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace { @@ -3161,8 +3161,8 @@ void junction_node::update(double const Deltatime) if (first != nullptr) { gate.distance = nearest; - gate.speed = std::abs(first->MoverParameters->V); - gate.halflength = 0.5 * first->MoverParameters->Dim.L; + gate.speed = std::abs(first->physics->V); + gate.halflength = 0.5 * first->physics->Dim.L; gate.taken = ways_of(gate, first); gate.active = gate.distance < std::max(gate_zone, gate.speed * gate_gap) + gate.halflength; } diff --git a/world/RoadPoint.cpp b/world/RoadPoint.cpp index 15ae891ad..f3e8b89ba 100644 --- a/world/RoadPoint.cpp +++ b/world/RoadPoint.cpp @@ -26,7 +26,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "utilities/parser.h" #include "utilities/utilities.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace { @@ -860,7 +860,7 @@ void roadpoint_node::prepare() } pooled_vehicle entry; entry.vehicle = vehicle; - entry.velocity = vehicle->MoverParameters->V; + entry.velocity = vehicle->physics->V; m_pool.emplace_back(entry); // ...which is taken off the road right away, the way the vehicles leaving the scenery are, to wait for its turn if (vehicle->MyTrack != nullptr) @@ -998,7 +998,7 @@ void roadpoint_node::update_spawn(double const Deltatime) entry.standing = 0.0; continue; } - auto const speed{vehicle->MoverParameters->V}; + auto const speed{vehicle->physics->V}; // forward is the way it went when it was put on the road auto const backwards{speed * entry.velocity < 0.0 && std::abs(speed) > reverse_speed}; if (std::abs(speed) > stuck_speed || simulation::Roadpoints.holds(*vehicle)) @@ -1061,9 +1061,9 @@ void roadpoint_node::update_spawn(double const Deltatime) auto *vehicle{entry.vehicle}; // it comes back the way it was made: whole, at speed, with the driver told to drive on vehicle->bEnabled = true; - vehicle->MoverParameters->repair_damage(); - vehicle->MoverParameters->V = entry.velocity; - vehicle->place_on_track(m_lanes.front(), m_offset + 0.5 * vehicle->MoverParameters->Dim.L, false); + vehicle->physics->repair_damage(); + vehicle->physics->V = entry.velocity; + vehicle->place_on_track(m_lanes.front(), m_offset + 0.5 * vehicle->physics->Dim.L, false); if (vehicle->Mechanik != nullptr) { // the same order a vehicle put in the scenery gets; it has the driver forget the road they knew @@ -1079,7 +1079,7 @@ void roadpoint_node::update_despawn() { for (auto *vehicle : lane->Dynamics) { - if (vehicle == nullptr || false == vehicle->bEnabled || vehicle->MoverParameters->CategoryFlag != 2) + if (vehicle == nullptr || false == vehicle->bEnabled || vehicle->physics->CategoryFlag != 2) { continue; } @@ -1088,7 +1088,7 @@ void roadpoint_node::update_despawn() // not the one the user sits in continue; } - if (planar_distance(vehicle->GetPosition(), m_state.position) > m_state.radius + 0.5 * vehicle->MoverParameters->Dim.L) + if (planar_distance(vehicle->GetPosition(), m_state.position) > m_state.radius + 0.5 * vehicle->physics->Dim.L) { continue; } diff --git a/world/Track.cpp b/world/Track.cpp index 6e2824756..06aa6ce00 100644 --- a/world/Track.cpp +++ b/world/Track.cpp @@ -31,7 +31,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "utilities/Logs.h" #include "rendering/renderer.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include @@ -2344,7 +2344,7 @@ void trail_switch( TTrack &Track, int const i, TDynamicObject const *o ) { Track.Switch(i); // jeśli się tu nie przełączy, to każdy pojazd powtórzy event rozrprucia if( Track.SwitchExtension->m_movablenose && o != nullptr ) { // the wheels can't push the nose of the frog over, the vehicle runs off the rails at it - o->MoverParameters->Derail( TRAILED_SWITCH ); + o->physics->Derail( TRAILED_SWITCH ); } } diff --git a/world/TrackBuckle.cpp b/world/TrackBuckle.cpp index f0328d8d1..7dabf4c0b 100644 --- a/world/TrackBuckle.cpp +++ b/world/TrackBuckle.cpp @@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Globals.h" #include "utilities/Logs.h" #include "vehicle/DynObj.h" -#include "physics/mover.h" +#include "physics/vehicle.h" #include @@ -214,8 +214,8 @@ void TTrack::buckle_pass_enter( TDynamicObject const &Dynamic ) { return; } ++m_buckle_passes; - auto const *mover { Dynamic.MoverParameters }; - auto const train { mover != nullptr && track_buckle::stirs( std::abs( mover->Vel ), mover->BrakePress > 0.5 ) }; + auto const *physics { Dynamic.physics }; + auto const train { physics != nullptr && track_buckle::stirs( std::abs( physics->Vel ), physics->BrakePress > 0.5 ) }; auto const rise { rail_temperature_now() - m_cwr.neutral }; auto const draw { track_buckle::draw( buckle_key(), Global.random_seed, track_buckle::pass, m_buckle_passes ) }; m_buckle_armed = ( track_buckle::decide( rise, buckle_limits(), train, draw ) != track_buckle::verdict::none ); diff --git a/world/TrkFoll.cpp b/world/TrkFoll.cpp index 6477f9763..8013af966 100644 --- a/world/TrkFoll.cpp +++ b/world/TrkFoll.cpp @@ -21,7 +21,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "vehicle/Driver.h" #include "utilities/Logs.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace { @@ -127,7 +127,7 @@ TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end) pCurrentTrack = pTrack; pCurrentSegment = pCurrentTrack != nullptr ? pCurrentTrack->CurrentSegment() : nullptr; if (!pCurrentTrack) - Error(Owner->MoverParameters->Name + " at NULL track"); + Error(Owner->physics->Name + " at NULL track"); return pCurrentTrack; }; @@ -345,7 +345,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) { // gdy zostaje na tym samym torze (przesuwanie już nie zmienia toru) if (bPrimary) { // tylko gdy początkowe ustawienie, dodajemy eventy stania do kolejki - if (Owner->MoverParameters->CabOccupied != 0) { + if (Owner->physics->CabOccupied != 0) { pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner, -1.0 ); pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner, -1.0 ); diff --git a/world/station.cpp b/world/station.cpp index 8ac77db30..40c343118 100644 --- a/world/station.cpp +++ b/world/station.cpp @@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/utilities.h" #include "vehicle/DynObj.h" #include "world/mtable.h" -#include "physics/mover.h" +#include "physics/vehicle.h" namespace simulation { @@ -43,7 +43,7 @@ basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Sch auto *vehicle { First }; while( vehicle != nullptr ) { - auto ¶meters { *vehicle->MoverParameters }; + auto ¶meters { *vehicle->physics }; if( parameters.Doors.range == 0.f ) { goto next; }