mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 15:17:08 +01:00
16568d5695
The rest of the braking of physics::Vehicle moves into brakes, with English
names (physics/components/braking.h):
the valves Hamulec distributor, Handle driverValve,
LocHandle independentValve
the definition BrakeSystem kind, BrakeSubsystem subsystem, BrakeValve /
BrakeValveSize / BrakeValveParams distributorType / Size /
Parameters, BrakeHandle / BrakeLocHandle driverValveType /
independentValveType, the Handle_* driverValveSettings,
LocalBrake localKind, MaxBrakePress maxCylinderPressure,
LoadFlag loadSetting, P2FTrans pressureToForce, NBpA
blocksPerAxle, High/Low/DeltaPipePress pipeHigh/LowPressure
/ pipePressureRange, CntrlPipePress controlReservoirPressure,
Spg pipeSection, RapidMult / RapidVel rapidRatio / rapidSpeed,
BrakeDelay delays, BrakeCtrlPosNo handlePositions, ...
cylinders BrakeCylNo / Radius / Dist / Mult / Spring, BrakeSlckAdj,
BrakeRigEff: count, radius, stroke, leverRatio, springForce,
slackAdjusterForce, riggingEfficiency
emergencyValve EmergencyValveOn / Off / Open / Area / Flow
pipeLock LockPipeOn / Off, HandleUnlock, LockPipe, UnlockPipe
the state BrakePress cylinderPressure, LocBrakePress
independentCylinderPressure, EqvtPipePress
equivalentPipePressure, Volume reservoirAir, dpBrake / dpPipe /
dpMainValve / dpLocalValve brakeFlow / pipeFlow /
driverValveFlow / independentValveFlow, BrakeCtrlPos(R, 2)
handlePosition(Real), handleCapPosition, fBrakeCtrlPos
handlePositionSmooth, LocalBrakePosA(EIM) independentPosition
(Eim), BrakeStatus status, AlarmChainFlag alarmChain,
BrakeDelayFlag / BrakeDelays delaySetting / availableDelays,
BrakeOpModeFlag / BrakeOpModes operatingMode /
availableOperatingModes, UnitBrakeForce unitForce, ...
Renamed in the files of the vehicle itself, and elsewhere only where reached
through -> or .: the driver keeps its own BrakeSystem, the editor its Handle,
the radio its Volume, and the brake valve classes (brakes.*, oerlikonest.*)
their fields of the same names. The C arrays (MaxBrakePress, BrakeCylMult,
the universal buttons) are std::arrays of the same values; the bits of status,
delaySetting and operatingMode stay ints for now.
No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
77 lines
2.7 KiB
C++
77 lines
2.7 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "vehicle/handover.h"
|
|
|
|
#include "physics/vehicle.h"
|
|
|
|
namespace handover {
|
|
|
|
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
|
|
if (Controlling.SandDose && false == (Controlling.SandDoseManual || Controlling.SandDoseAuto)) {
|
|
Controlling.Sandbox(false);
|
|
}
|
|
if (Occupied.DepartureSignal) {
|
|
Occupied.signal_departure(false);
|
|
}
|
|
if (Occupied.brakes.distributor->Releaser()) {
|
|
Occupied.BrakeReleaser(0);
|
|
}
|
|
}
|
|
|
|
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<int>(std::size(Occupied.Lights[0])))};
|
|
if (positioncount <= 0 || Lightstable < 0 || Lightstable >= static_cast<int>(std::size(Occupied.Lights))) {
|
|
return Occupied.LightsPos;
|
|
}
|
|
auto const &lights{Occupied.Lights[Lightstable]};
|
|
auto const lightsmatch{[&lights, Inventory, Headlights](int const Position) { return (lights[Position - 1] & Inventory) == Headlights; }};
|
|
if (Occupied.LightsPos >= 1 && Occupied.LightsPos <= positioncount && lightsmatch(Occupied.LightsPos)) {
|
|
return Occupied.LightsPos;
|
|
}
|
|
for (auto position = 1; position <= positioncount; ++position) {
|
|
if (lightsmatch(position)) {
|
|
return position;
|
|
}
|
|
}
|
|
return Occupied.LightsPos;
|
|
}
|
|
|
|
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<int>(positions.size())};
|
|
auto const isoff{[&positions, count](int const Position) { return Position < 0 || Position >= count || positions[Position].isOff; }};
|
|
|
|
if (false == Occupied.enableModernDimmer || false == Headlightson || false == isoff(current)) {
|
|
return current;
|
|
}
|
|
if (false == isoff(Occupied.modernDimmerDefaultPosition)) {
|
|
return Occupied.modernDimmerDefaultPosition;
|
|
}
|
|
for (auto position = 0; position < count; ++position) {
|
|
if (false == (positions[position].isOff || positions[position].isDimmed || positions[position].isHighBeam)) {
|
|
return position;
|
|
}
|
|
}
|
|
for (auto position = 0; position < count; ++position) {
|
|
if (false == positions[position].isOff) {
|
|
return position;
|
|
}
|
|
}
|
|
return current;
|
|
}
|
|
|
|
} // namespace handover
|