18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 19:57:06 +01:00
Commit Graph

405 Commits

Author SHA1 Message Date
maj00r fc74ff0860 Merge origin/staging into feat/model-format-e4d 2026-11-30 00:32:49 +01:00
Hirek f964f75ece Merge pull request #544 from MaSzyna-EU07/fix/staging-case-regressions
Fix two scenario cases broken on staging: the uuid of scene nodes, the AI stop on a gradient, an off-track coupling
2026-11-29 17:35:36 +00:00
jerrrrycho a8bd72cc7f Merge staging into fix/staging-case-regressions 2026-11-29 18:04:00 +01:00
jerrrrycho c0e1f1c8fe Merge staging into feat/derailment-trust-limits 2026-11-29 18:04:00 +01:00
maj00r 0d095e225c fix(model): E4D review of #535: no guessed pass in the file, the header and the tree checked, unknown sections passed over
- The pass bits (0x30) BinInit guesses from a material when the E3D has none are marked (TSubModel::m_passguessed) and the
  converter leaves them out of legacy_flags and the primitive flags: it loads through the null renderer, whose materials
  all guess opaque, so the game makes the guess again with the real material.
- A vehicle's model isn't converted from its .t3d (dynamic 1): the game prepares it only after the vehicle marked its
  animated parts, so the .e3d the game makes of it is converted instead.
- read_header refuses a file_size smaller than the header, which made the hash check read outside the span.
- Sections seen twice are found with a set, not O(n^2); all the sections together may claim at most 2 GiB; a section the
  reader doesn't know and the model can do without is passed over before it is unpacked when keep_unknown is off.
- validate() checks that the parent of each node is the innermost node whose subtree holds it, so the tree of the ranges
  is the tree of the parents.
- Light_OnNN / Light_OffNN found by the game's GetFromName, so of two submodels of a name the same one counts; a
  replaceable skin drawn translucent gets material_flags::translucent; the convertmodels flags parsed without stoi.
- S3519: the matrix made with glm::make_mat4 instead of a memcpy into its first column; NOSONAR on the seeded engines of
  the tests (S2245).
- The spec: u16 indices up to 65 536 vertices, and the two rules above.

Tests: a file_size below the header, a node in the subtree of another than its parent, an unknown section passed over.
2026-11-29 17:25:23 +01:00
jerrrrycho 5182e4eb43 Merge pull request #548 from MaSzyna-EU07/test/baltyk-skm1-cases-new-units
test(scenarios): baltyk_skm1 cases follow the new units of their missions
2026-11-29 17:12:04 +01:00
jerrrrycho de6e886048 test: the trusted-limit cases check the derailment as VehicleDamage, as staging does since #531 2026-11-29 15:24:16 +01:00
jerrrrycho 66908502b3 test: the off-track coupler case names the ends as VehicleEnd, as staging does since #531 2026-11-29 15:07:19 +01:00
jerrrrycho 1e825cb596 Merge staging into feat/derailment-trust-limits
# Conflicts:
#	McZapkie/Mover.cpp
2026-11-29 14:56:21 +01:00
jerrrrycho 501123c3b8 Merge staging into fix/staging-case-regressions
# Conflicts:
#	McZapkie/Mover.cpp
#	physics/vehicle.h
#	vehicle/Driver.cpp
#	vehicle/DynObj.cpp
2026-11-29 14:54:08 +01:00
Hirek 23b695752a refactor(physics): the demand of the integrated controller is private to the vehicle
eimic_real, the demand of the integrated controller the vehicle goes by with
the speed control counted, which TDynamicObject and the consist braking set
for the vehicle that leads, is private: EimicReal() and SetEimicReal(). The
field of the same name of drivingaid::input stays as it is.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:39:07 +01:00
Hirek ef8a1fdbfd refactor(physics): six more of what the rest only reads are private, under names of their own
The mass of the empty vehicle, the braking force, the outcome of a derailment,
the departure signal, the traction mode of a dual-mode vehicle and the moment
of the motors are private to physics::Vehicle like the 53 before them, read
through Mass(), Fb(), Derailed(), DepartureSignal(), TractionMode() and Mm().
Inside the class they are emptyMass, brakingForce, derailOutcome,
departureSignalOn, tractionModeSetting and motorMoment, as the plain camelCase
names were taken by locals there.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:23:53 +01:00
Hirek 5879c228dc refactor(physics): what the rest of the simulator only reads of a vehicle is private to it
53 fields of physics::Vehicle that only the vehicle itself writes, and the rest
of the simulator reads, are private, with a query each, named as the field was
(Vmax(), TotalMass(), Ft(), nrot(), NAxles(), PhysicActivation(), ...): the
compiler now keeps the cab, the AI, the scenery, the renderer and the tests from
changing what the definition gives or the physics works out. The fields were
picked by what is never written outside the class, of plain types, with no
other member of the same name to confuse; inside the class they keep their
meaning under camelCase names. The one place outside that cleared a flag of
the AI through a reference does it through ClearAIFlag().

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:17:56 +01:00
Hirek f65411a668 refactor(physics): the motion of the vehicle is private to it
The speed along the couplers, the location, the offsets from the track axis,
the accelerations, the distance counter and the distance moved since the last
check, the flat of the wheels and the truck hunting, the distance of the
derailment check, whether the vehicle is inside a consist and in the coupler
model, the analog demand of the integrated controller and the flow of the pipe
stabiliser are private to physics::Vehicle. TDynamicObject places and moves the
vehicle, the scenery puts road vehicles on their way and the contacts push them
through the operations (SetV(), SetLoc(), SetOffsetTrackH(), ...), and the
jolts of the track are ShakeVertically() and ShakeHorizontally(), the same
additions as before.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 12:43:38 +01:00
Hirek 0b5459ef7b refactor(physics): the positions of the brake handles are private to the brakes
The positions of the driver's brake valve (stepped, continuous, and of the
FV4a with its cap), of the independent brake and of its EP counterpart in
units with induction motors, and of the hand brake are private to
physics::Braking: read through HandlePosition(), IndependentPosition(), ...
and moved through SetHandlePosition(), SetIndependentPosition(), ..., by the
vehicle's own stepping as by the cab, the AI and the consist braking. The
gauges of the cab bind to them read-only.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 12:38:26 +01:00
Hirek 242474dd11 refactor(physics): the lights, the load and the event flags are private to the vehicle
- The lights switched on at each end (iLights) are LitLights(), changed
  through SetLitLights(): the cab's switches, the AI's light patterns and the
  scenery's toggles of the end signals all go through it.
- The exchange of the load, which TDynamicObject ran by setting the status, the
  amount and the mass itself, goes through UnloadStep(), LoadStep(),
  FinishLoadExchange() and AcknowledgeLoadExchange(), with the same arithmetic;
  the change of the kind of the load is taken once (TakeLoadTypeChange()).
- The events the physics reports for the sounds to follow up are raised and
  cleared by name (RaiseEventFlag(), ClearEventFlag(), ClearSoundFlags()).

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 12:33:13 +01:00
Hirek 84f1aa2515 refactor(physics): the controllers and the switches of the cab are private to the vehicle
The positions of the master and the secondary controller, of the analog
controller and of the lights selector, the occupied cab, the horns, the radio
and its fuse, the radio-stop, the wipers' switch, the dimmer, the mirrors'
button, the end-of-train signalling and the forced resistor fans: fourteen
fields the cab, the AI, the scenery and the tests wrote straight into
physics::Vehicle are private now. The rest of the simulator reads them through
queries named as the fields were (MainCtrlPos(), Radio(), ...) and changes them
through operations (SetMainCtrlPos(), SetRadio(), ...), so every place that
moves a controller past its own stepping (IncMainCtrl()) is named and can be
found; the compiler keeps anything else out. Inside the vehicle they keep
their meaning under camelCase names. The queries return const references, as
the gauges of the cab bind to them.

The .fiz keys are untouched.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 12:26:21 +01:00
Hirek ea7a770d6c refactor(physics): the step of the doors belongs to the doors
The step of the doors of a vehicle (their lock, the requests to open and to
close from the passengers, from the cab and by themselves, the permits, the
movement of the doors and their steps, the timers of the doors that close
after a while) and the state of their closure signalling move from
physics::Vehicle into physics::door_data (Update(), Closure()). The vehicle
hands the doors what they need as plain values (door_data::StepInputs: its
speed, whether the doors have their voltage, whether it is a multiple unit,
whether passengers are getting in or out) and keeps only that.

The doors can now be tested on their own, without a vehicle
(test_door_component.cpp): opening and closing from the cab, no movement
without the voltage, the lock over its speed, the doors closing by themselves
unless the passengers are getting in.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 11:01:47 +01:00
Hirek 6b9558f588 refactor(physics): the faults of the equipment are a named set the physics sets
The faults the scenery or the network sets on a vehicle (TDynamicObject::
Damage() with the number of a message, held as EngDmgFlag and tested as its
bits 1, 4) are EquipmentFault and EquipmentFaultSet, and what each does moves
out of TDynamicObject into physics::Vehicle::SetEquipmentFaults(). The number of
a message comes in through FromBits() and goes back out through Bits(), as it
was.

The faults of the control and of the camshaft still hold the start and the
steps of the controller by delays moved out of reach by 100000001 and back,
the very same arithmetic, now named and in one place. Tests of it are added
(test_equipment_faults.cpp), as nothing reached it before.

The setters of the parts that took a parameter named as one of their queries
(Pressure, Voltage) take Value instead.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 10:56:17 +01:00
Hirek 2d67e9b1a3 refactor(physics): the definition of the brakes apart from their state
What the .fiz gives about the brakes of a vehicle (the kinds of the brake
system, the valves and the handles, the cylinders and the rigging, the pipe
pressures, the delays and the modes it can be set to: 35 fields) moves into
physics::Braking::Config, held as brakes.config, set as the vehicle loads and
not changed after. Six fields that sat with the definition but change in the
run (the weighted pressures of the handle position, the universal buttons
pressed, the load setting, the control reservoir, the emergency valve, the
lock of the pipe) go with the state.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 10:36:09 +01:00
Hirek d0b8d689af refactor(physics): the blending of the brakes of a consist is a module of the physics
The blending of the electrodynamic and the electropneumatic brakes over a
consist driven by induction motors (the MED of the .fiz) moves out of
TDynamicObject into physics::ConsistBrakeBlending (physics/consistbraking.*).
It works on the physics of the vehicles alone, given in the order of the
consist; TDynamicObject::distributeInductionBraking() only lists them from the
occupied cab, as its loops walked them, and hands the result (the most
deceleration of the service braking) to the driver. The state of the blending
(the ED demand of the step before, the log of MEDLOGS/, the figures of the
debug screen) goes with it.

The code moves as it was: its arithmetic, its float and double conversions and
the order of its steps are kept. Nothing in the unit tests reached it before, as
they don't run TDynamicObject; now that it stands on its own, tests of it are
added (test_consist_braking.cpp): the full braking demand over the mass of an
Elf, the electropneumatic brake of every car standing, no demand at neutral.

The figures of the debug screen start at zero rather than uninitialised for a
vehicle that never led a consist.
2026-11-29 10:24:00 +01:00
jerrrrycho a8f295f53a test: NOSONAR on the copy of the simulation's random engine (S2245) 2026-11-29 10:15:39 +01:00
Hirek bc2af26dd5 refactor(physics): the compressed air supply and the pipes keep their state to themselves
The compressor, the main reservoir and the pipes along the train
(physics/components/airsupply.h) become classes, as the parts of the main
circuit: the definition in `config`, the state behind queries and operations.

The step of the compressor (the programmer of a unit, its supply and its start
delay, the governor and its lock, the venting over the top pressure) moves into
AirCompressor::Update(), with what it needs from the vehicle as plain values
(CompressorInputs); the vehicle follows the step up as before (the switching
delay, the counter of the debug panel, the sound of the relay). The leaks and
the pressure of the main reservoir move into AirSupply, and the reservoir is
filled and drawn through it.

The fault of the compressor the scenery can set no longer adds 100000001 to its
pressures from TDynamicObject::Damage(): AirCompressor::SetFault() does the same
arithmetic, so a fault behaves exactly as it did.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 10:14:37 +01:00
jerrrrycho 1eaca10ac9 test(scenarios): baltyk_skm1 cases follow the new units of their missions
SVN r9644 (2026-11-15) put an EN57AL-1230ra in mission ROJ55321 instead of
EN71-014ra and an ED78-019A in ROJ55324 instead of EN90-009A, so both cases
ended at once with "the scenery has no vehicle" (exit code 14). The cases
now test the new units; both pass on staging b7f2186a1.
2026-11-29 10:12:35 +01:00
Hirek 160ffe2147 refactor(physics): the low voltage, the train heating and the pantographs keep their state to themselves
As the parts of the main circuit: the battery and the low voltage circuits,
the train heating, the circuit of the pantographs and their air become classes
with the definition in `config` and the state behind queries and operations.

The step of the air of the pantographs (the small compressor, the three-way
cock, the leaks, the pressure switch) moves into PantographAir::Update(), which
gets what it needs as plain values (PantographAirSupply) and reports a trip of
the pressure switch, so the vehicle opens its line breaker or switches the
converter of a unit off as before. The drain of the battery and its limits move
into LowVoltageSupply. The latch of the held battery button of the cab moves
from the physics to TTrain, where the button is.

The gauges of the cab bind to the values they show through const pointers
(TGauge::Assign*() take them), so the queries they bind to return const
references and the cab reads the state live without being able to change it.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 10:08:54 +01:00
Hirek 22ebc41d70 refactor(physics): the parts of the main circuit keep their state to themselves
The line breaker, the line contactors, the protective relays and the converter
(physics/components/maincircuit.h) become classes: what the .fiz defines is in
their public `config`, their state is private, read through queries
(IsClosed(), UndervoltageHolds(), IsRunning()) and changed through operations
(Close(), ResetGround(), Switch()). The logic that concerns only them moves in:
the initialisation of the main circuit, the ground relay, the pressure switch,
the resets of the relays, and the whole step of the converter, which gets what
it needs from the vehicle as plain values (ConverterSupply).

The vehicle still decides when they act (the interlocks, the controller
positions, the voltages); the parts don't take a physics::Vehicle.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 09:37:01 +01:00
Hirek 6aca6bc4f6 fix(review): an empty Load= no longer throws, and the stale notes of the review of #531
From the review of #531:
- Load= and UnLoad= without the name of a load threw std::out_of_range as
  soon as ParseVehicleCommand() read them: extract_value() reads past the end
  of the text when nothing but spaces follows the =. Before this branch the
  same exception came later, in the RunCommand() of a vehicle standing at the
  ramp. ParseVehicleCommand() gives an empty name now, which loads and
  unloads nothing (AssignLoad("") and LoadingDone() with no name, as for an
  empty vehicle). extract_value() itself is left as it was: it has hundreds
  of callers and test_utilities.cpp records its exception at the end of the
  text. New checks in test_vehicle_command.cpp.
- compression_at() is an inline function of physics/components/internal.h,
  as square() is, rather than a global function of external linkage defined
  in collisions.cpp; its body is the same
- the comment of train_type::sn61 says what the AI does for it (the master
  controller up to a position with torque after setting the direction)
  rather than that nothing handles it
- tests/unit/COVERAGE.md names the files as they are now (physics/components/,
  vehicle/dynamic/lifecycle.cpp) instead of physics/physics.cpp, a name the
  renaming script left there

The naming of AGENTS.md, which the review asked about, stays as it is.
2026-11-29 04:13:17 +01:00
Hirek 38b1110d1b Merge origin/staging into cleanup/mover
Staging's 7 commits since 62f7a29b. Two of them changed files this branch
split up, so their changes are carried into the new files by hand:
- #445 (the decisions of an uphill start in uphill_start::): the changes to
  TController::control_tractive_force() and control_uphill_start() of
  vehicle/Driver.cpp go into vehicle/ai/force.cpp, with the names of this
  branch (VehicleEnd::front, ->physics)
- #530 (the lowpoly driver figure follows the direction in single desk
  vehicles): the figure in ABuLittleUpdate() goes into
  vehicle/dynamic/visual.cpp; the reading of cab1model:/cab2model: and of
  driverNpos:/driverNsitpos: goes into the helpers of the internaldata:
  section in vehicle/dynamic/mmd.cpp, which pass the cab places along
  (loadInternalDataKeyword, loadInternalDataDeviceKeyword,
  loadInternalDataCabKeyword); read_driver_position() takes the tokens no
  group of keywords knows, as the last else of the chain did
vehicle/Driver.cpp and vehicle/DynObj.cpp stay deleted. The rest merged on
its own. 1185/1185 tests, golden traces exact against staging 62f7a29b.
2026-11-29 04:00:11 +01:00
jerrrrycho 096e60ff38 feat(derailment): trust the speed limit of the track (physics.derailment.trustlimits)
With physics.derailment new, a verdict the curve and the cant alone give
(the criterion holds for the vehicle without its coupler forces, on the
track without a buckle, damage flags or unevenness) is held back while
the vehicle runs under the trusted speed of the track: its speed limit
times 1.1 plus 5 km/h. The log names the track once as a defect of the
scenery ("derailment monitor: data: ..."). Over the trusted speed, on a
track without a limit, and for whatever the couplings, a buckle or the
damage of the track bring about, the verdict goes as before.

physics.derailment.trustlimits yes|no, default yes; no is the behaviour
before. The decision is a set of pure functions in McZapkie/derailment
(trusted_speed, from_track_alone, limited_verdict, held_back_report);
check_derailment only calls them.

The 144 tracks physics.trackcheck finds with limits their curves don't
take (backlog L4) no longer derail trains that keep to them, so the
default of physics.derailment can be decided apart from the data fixes.

Tests: unit tests of the decision and of a vehicle on a curve with a bad
limit; scenario cases eu07_td_overspeed_bad_limit (140 km/h, held on),
_fast (175 km/h, overturns) and _untrusted (trustlimits no, overturns).
2026-11-29 03:26:32 +01:00
Hirek 89258eb72c refactor(physics): the low voltage, the train heating and the electrodynamic brake as components
The rest of the electrics of physics::Vehicle beside the traction motors
becomes components, with English names:

  lowVoltage (LowVoltageSupply,   Battery batteryOn, BatteryVoltage,
  physics/components/lowvoltage.h) NominalBatteryVoltage, BatteryStart,
                                  Power110vIsAvailable / Power24vIsAvailable /
                                  Power24vVoltage power110vAvailable /
                                  power24vAvailable / power24vVoltage, the
                                  battery button of the cab: batteryButtonFired,
                                  batteryButtonImpulse, batteryButtonHeld,
                                  batteryButtonHoldTime
  trainHeating (TrainHeating)     Heating on, HeatingAllow allow,
                                  HeatingSwitchImpulse switchImpulse,
                                  HeatingPower power, EngineHeatingRPM engineRpm
  brakes.electrodynamic           the DynamicBrake* fields: type, ammeters,
  (ElectrodynamicBrake,           controllerPositions, controllerPosition,
  physics/components/braking.h)   resistance(1, 2), on, emuWorking;
                                  SplitEDPneumaticBrake splitFromPneumatic;
                                  the fans of the braking resistor (BRVentilators,
                                  BRVto, BRVtimer, Imaxrpc): resistorFansRunning,
                                  resistorFansSustain, resistorFansTimer,
                                  resistorPassiveMaxCurrent

The diesel-electric dynamic brake (DEDynamicBrake) and the currents of the
traction circuit (Im, Itot, EngineVoltage ...) stay for the traction stage.

No string literal changed (checked over all the changed files).

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
2026-11-29 03:15:56 +01:00
Hirek 1bea280010 refactor(physics): the line breaker, the line contactors, the relays and the converter as components
The main circuit of physics::Vehicle becomes components, with English names
(physics/components/maincircuit.h):

  lineBreaker (LineBreaker)     Mains closed, MainsInitTime(Countdown)
                                initTime / initCountdown, MainsStart start,
                                JointEngineStart jointStart,
                                PantographsRequireMains pantographsRequireIt,
                                LineBreakerClosesOnlyAtNoPowerPos
                                closesOnlyAtNoPower,
                                EmergencyBrakeMainOffPressure emergencyOffPressure
  lineContactors (LineContactors) StLinFlag closed, StLinSwitchOff forcedOpen,
                                StLinSwitchType switchType,
                                LineContactorsInterlock interlock,
                                LastRelayTime lastSwitchTime
  protection (ProtectionRelays) NoVoltRelay noVoltage, OvervoltageRelay
                                overvoltage, GroundRelay(Start) ground(Start),
                                ControlPressureSwitch pressureSwitch,
                                HasControlPressureSwitch hasPressureSwitch,
                                PressureSwitchBrakeCylinder
                                pressureSwitchWatchesCylinders
  converter (PowerConverter)    the Converter* fields: start, startDelay(Timer),
                                allow(Local), running, overloadRelayStart,
                                overloadRelayOffWithLineBreaker; ConvOvldFlag
                                overloaded, ConvSwitchType switchType

The long comments of the fields went with them into the header. Where the
loading of the .fiz has using enum start_t, the member is this->converter:
the enumerator start_t::converter would hide it there.

No string literal changed (checked over all the changed files).

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
2026-11-29 02:50:50 +01:00
jerrrrycho e6d576fd82 fix(derailment): a coupling between a vehicle off the track and one on it pulls taut, holds or breaks
With either vehicle of a pair off the track (physics.derailment new) the distance between their ends is
measured where they are, but the physical coupler model still took its change from the moves of the
vehicles along the track. Once the ends had gone past each other (the locomotive lying beside the track,
the coach coupled to it running on along the rails) a run that opened the gap counted as closing it: the
draw gear unloaded, the coupling carried 0 N while the gap grew to tens of metres, the stop of the draw
gear was never hit and the coupling never broke. The tension, had there been any, pushed the coach on.

update_neighbours() now gives the pair the shares the move of each vehicle along its axis has in the gap,
in the direction the ends are apart in (TMoverParameters::coupler_gap_change()); the gap, its rate and the
hit on the stop go by them, and of the coupler force each vehicle takes along its axis the share the gap
goes by. On the track nothing changes.

The coupling of a vehicle off the track pulls the one coupled to it off the rails once the climbing limit
holds over 2 m. That distance was the run of the vehicle off the track, so one lying at rest never pulled
off the vehicle running past it; it is the run of the wheels of the vehicle pulled now.
2026-11-29 02:39:09 +01:00
jerrrrycho b4b342c523 fix(ai): down a gradient a train at walking pace in the last metres before its stop stops there
In the final approach the braking curve asks for next to nothing once the train is down to walking pace a
metre or two short of the point it aims at, or past it. Down a gradient the pneumatic brake let off for that
lets the gradient take the train again: it crept on at about 1 km/h and braked again, a release and an
application at a time. EU07 alone down 20 per mille to the signal gr_sem (eu07_td_downgrade_w4_signal) did
it three times and stood 12 s later than it had stopped. Below 5 km/h within 2 m of that point, or past it,
on a descent, the AI now stops where it is (the desired speed 0), as it does once it stands there.
2026-11-29 02:19:43 +01:00
Hirek 5e56a91515 refactor(physics): the devices out of physics::Vehicle, the pantographs as components
The types of the devices nested in physics::Vehicle (basic_device, the pumps,
the fans, basic_valve, basic_pantograph, basic_door, door_data, water_heater,
genset_device) move out of it into physics/components/devices.h, namespace
physics, so the components of the vehicle can hold them.

The pantographs and their air become components, with English names
(physics/components/pantographs.h):

  Pantographs                 pantographs (ByEnd<basic_pantograph>)
  pantographCircuit           PantFrontVolt / PantRearVolt frontVoltage /
                              rearVoltage, PantographVoltage supplyVoltage,
                              PantAllDown allDown, PantSwitchType switchType,
                              PantsPreset presets
  pantographAir               PantVolume volume, PantPress pressure,
                              PantCompFlag compressorRunning,
                              PantographCompressorStart compressorStart,
                              SmallCompressorPower compressorPower, PantsValve
                              valve, bPantKurek3 connectedToMainReservoir,
                              PantAutoValve autoValve, PantPressSwitchActive /
                              PantPressLockActive pressureSwitchActive /
                              pressureLockActive

No string literal changed (checked over all the changed files).

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
2026-11-29 02:13:17 +01:00
jerrrrycho d237996afd fix(scene): the uuid of a scene node no longer takes the random numbers of the simulation
Each scene node drew its uuid (which only the editor goes by) from Global.random_engine, the engine of the
run's seed, two numbers a node. A node added to a scenery, or made by the program before it, moved every
random number drawn after it: the pressure the brake valves are set to, the brake delays, the sound sets
and the rest. The memory cell __simulation.metar (2be85410c, merged with #468) did that to every run, so
the same seed gave a different train from 27.11 on, with no change in its physics. The uuids come from an
engine of their own now.
2026-11-29 02:06:40 +01:00
Hirek 16568d5695 refactor(physics): the brake valves, cylinders, pressures and positions in physics::Braking
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.
2026-11-29 01:48:33 +01:00
Hirek 309926bb05 refactor(physics): the air supply and the pipes along the train as components
The air of physics::Vehicle becomes components of their own, with the fields
named in English (physics/components/airsupply.h):

  air (AirSupply)            the compressor and the main reservoir:
    compressor (AirCompressor) MinCompressor, MaxCompressor and those of each
                             cab, CabDependentCompressor, CompressorSpeed,
                             CompressorPower, CompressorStartDelay,
                             CompressorTankValve, CompressorStart, the
                             CompressorList programmer and its switch, and
                             the state: CompressorFlag running,
                             CompressorAllow(Local) allow(Local),
                             CompressorGovernorLock, CompressorPowerTime
    VeselVolume              mainReservoirVolume
    Compressor               mainReservoirPressure
    CompressedVolume         compressedVolume
    AirLeakRate              leakRate
  brakePipe, mainPipe        the two pipes along the train, of one type,
  (TrainPipe)                TrainPipe: reservoir, pressure, couplersPending
                             (Pipe, PipePress, PipeCouplersPending and Pipe2,
                             ScndPipePress, ScndPipeCouplersPending before)

CompressorPower, a number 0 to 5, is the enum CompressorSupply (mainCircuit,
converterManual, converter, engine, frontUnitConverter, rearUnitConverter),
read from the same words of the .fiz. The CompressorList table is a
std::array of the same ints.

The exchange of air through the hoses (pneumatics.cpp) takes the pipe as one
TrainPipe of the vehicle instead of three member pointers.

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
2026-11-29 01:18:26 +01:00
Hirek 2753994bf6 refactor(physics): the blending, the holding brake and the spring brake in physics::Braking
The first part of the braking of physics::Vehicle becomes a component of its
own, brakes (physics/components/braking.h), with the fields named in English:

  blending (BrakeBlending)    the MED_* of the Blending section and their
                              timers: maxSpeed, minSpeed, referenceSpeed,
                              maxDeceleration, epCorrection(Time, Timer),
                              loadCorrection, minEdDemand, edForceFactor,
                              edFirstDelay, edNextDelay, edDelayTimer
  emuDynamic (EmuDynamicBrake) the DCEMUED_*: checkedCoupler, epMaxSpeed,
                              epMinCurrent, epDelay
  holding (HoldingBrake)      StopBrakeDecc, StopBrakeReleaseDelay, the timer:
                              deceleration, releaseDelay, releaseTimer
  spring (SpringBrake)        the nested spring_brake (SBP is pressure,
                              ShuttOff shutOff, MultiTractionCoupler
                              controlCouplings ...) and the
                              ReleaseParkingBySpringBrake*,
                              SpringBrakeCutsOffDrive,
                              SpringBrakeDriveEmergencyVel of the vehicle

Each field says in its comment the key of the .fiz it comes from; the keys,
the golden channel names and the texts are as they were. The struct is
Braking, not BrakeSystem, the name of the kind of the train brake the vehicle
already has.

Kept as it was, to look at: the spring brake reads valveOffArea from the key
ValveOnArea and valveOnArea from ValveOffArea.

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
2026-11-29 00:28:52 +01:00
Hirek d0387753f8 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.
2026-11-28 23:56:46 +01:00
Hirek 9568dba9e4 fix(vehicle): the bugs the split of the giant functions brought to light
What changes for the player:

- the OFF position of the headlights dimmer puts out the headlights at the
  end of the active cab: A from cab 1, B from cab -1. It took the numbers
  of the ends for the numbers of the cabs, so cab 1 put out B, the end
  behind the driver, and cab -1 nothing (eff9fe88)
- each pantograph meters the energy it draws at its own voltage; it took
  the voltage of the other one, so a vehicle of one pantograph metered
  none
- with the live traction, a pantograph counts as touching the wire by the
  switch of its own end (the current shared between the pantographs);
  every one was counted by the switch of the front one
- radiatorfan2: in the sounds of the .mmd is read as radiatorfan1: is; only
  radiatorfan2 without the colon was. No vehicle of the game data uses
  either form of it, so no vehicle sounds different, and the old form is
  still read

Faults that couldn't show in a usual consist, fixed:

- the pantographs of more than 8 units in multiple went past the end of
  the table of the cab (TTrain::bPants), the compressors next to them had
  the check already
- the overload relay of the converter dereferenced the driver of the
  vehicle without checking there is one
- an empty row of the table of the consist kept the spring brake pressure
  of the vehicle there before
- more than 8 wipers went past the end of the state of the wipers

And a tidy-up of no effect: a motor blower sound looks at the speed of its
own blower, not of the front one (both are the speed of the .fiz).

CabEnd() and PantographEnd() (physics/vehicletypes.h) give the end of a cab
and of a pantograph of the model; test_vehicle_ends.cpp tests them and the
rest of the vocabulary of the ends.

Left as they are, for someone who knows what they should do: FfulED of the
braking of a consist of induction motors (TDynamicObject::Update) is assigned
rather than summed and is never above 0, so with ScndS above fullSpeed the
force asked of the ED brake is 0; and the calibration check of the brake
handle of the PoKeys desk (TTrain::updateBrakeControllers) is never tested,
by the precedence of ?: and &&.

1149/1149 tests; golden traces exact against staging 62f7a29b.
2026-11-28 22:13:19 +01:00
maj00r d6bace0fda feat(model): the E4D model format: spec, reader, writer and conversion from E3D/T3D
A fully binary successor of E3D, laid out for the GL 4.6 and Vulkan 1.4 renderers. Stage 1 of the plan: the format
and its tools. The game doesn't load .e4d yet; that is stage 2, behind a switch in eu07.ini.

- docs/e4d-format.md: the spec (in Polish, like world-format-eu07.md).
- model/e4d/e4d_format.h: the records and FourCCs, with static_asserts on sizes and offsets.
  - A table of sections with required/optional flags and zstd per section; tables carry count and stride, so a later
    version appends fields and an older reader takes the part it knows.
  - Nodes in depth-first order with TRS (XFRM for sheared matrices), meshes, 48-byte primitives.
  - Split vertex streams: VPOS f32x3, VATT QTangent snorm16x4 + UV f32x2 (28 B a vertex instead of 48 B), VSKN/VSKW
    skin weights, VUSR user data, VBND for primitives merged from several nodes (rigid joints, light slots).
  - Indices u16 or u32 per primitive, local to its base vertex.
  - Typed components on the model, nodes, meshes and vertex groups (PROP, SOCK, JOIN, SPRG, CHAN, VARI, CHNL, LSLT,
    LGHT, EMIT, MREF, COLL, LANM, LTXT, STAR), skins, vertex groups, a name index and bounds.
- model/e4d/e4d_io: write and read; the file is untrusted, so every offset, size, index, parent and reference is
  checked (validate) before anything is used, and a broken file is refused with a reason.
- model/e4d/e4d_build: QTangent packing, TRS from matrices, the name index and the bounds.
- model/e4d/e4d_convert: a model loaded from E3D or T3D into E4D, and the command line:
  eu07 -e4d convert <in.e3d|in.t3d> <out.e4d> [dynamic], eu07 -e4d dump <file>, eu07 -e4d validate <file>.
- zstd moves to eu07_core, which the unit tests link.
- tests/unit/test_e4d.cpp: round trip, section alignment, records of a later version, broken files, random mutations,
  QTangent, TRS, name lookup, bounds, merged primitives.

Checked: 250 random .e3d of the installed game convert (E4D 21% of their size with zstd, 60% without), and the
vehicle families en57_v2, t448p_v2 and vectron_v1 (701 files). Unit tests 1188/1188. Not built with GCC here.
2026-11-28 19:45:55 +01:00
Hirek fbb9dc1e89 refactor(physics): the ends and the sides of a vehicle as scoped enums
end and side were unscoped enums: front, rear, left and right sat in the
global namespace (the test PCH had to leave mover.h out for it), and an end
went into any int, a side into an end, without a word from the compiler. They
become enum class VehicleEnd and VehicleSide (physics/vehicletypes.h); the
names follow the rule for types, and leave "end" and "side" to the many
locals of that name. The numbers stay: front 0, rear 1, right 0, left 1.

- ByEnd<T> / BySide<T>: two values indexed by the enum, and by a number
  where a loop or a format counts them. The arrays of the ends and the sides
  are these now: Couplers, Neighbours, Pantographs, MotorBlowers, Lights,
  iLights, Doors.instances, pVehicles, IsAnyDoor*, m_lighthints, vCoulpler,
  m_couplersounds, m_mirrormotion, iInventory, and the voltages of the
  couplers
- VehicleEnds / VehicleSides to go through them, Opposite() in place of
  1 - end, NumberOf() where a number is needed
- the couplers and the collisions take the ends they work on as VehicleEnd:
  CouplerForce, CouplerVelocityDifference, CollisionDetect, crush_hit,
  CompatibleCoupling and the rest of their family, DirF, DirPatch, and of
  the vehicle couple, uncouple, the adapters, off_track_gap, has_signal_on;
  Attach, Dettach and DettachStatus have overloads by the ends
- neighbour_data::FacingEnd() and TCoupling::ConnectedEnd() give the end of
  the other vehicle as VehicleEnd; the fields stay numbers, as they hold -1
  and 2 for "none" in places

The walks along the consist (FirstFind, Neighbour, the AI's coupling and
uncoupling) still carry the ends as numbers; where one of them meets a typed
end, NumberOf() and EndOf() say so, and keep the number as it was.

Kept as it was, and worth a look: TDynamicObject::SetLights() switches the
headlights A/B off by CabActive with the cases end::front and end::rear, that
is CabActive 0 and 1, while CabActive is 1 or -1 for the cabs; the cases are
NumberOf(VehicleEnd::front / rear) now, the same numbers.

No change in behaviour: 1144/1144 tests, golden traces exact against staging
62f7a29b. betterRenderer/, not built, has had only end:: and side:: renamed.
2026-11-28 18:32:58 +01:00
Hirek f4ef43feec refactor(physics): the definition and the state of the induction motor drive as named fields
The arrays eimc[26] and eimv[21] of InductionMotor, indexed by the eimc_* and
eimv_* constants, become structs with named and described fields. The
definition splits into blocks by what it describes:

  motor      dfic currentPerSlip, dfmax maxSlipFrequency, p polePairs,
             cfu voltsPerHertz, cim torquePerCurrent, icif fieldCurrentRatio
  converter  Uzmax maxLinkVoltage, Uzh brakingLinkVoltage, DU voltageDrop,
             I0 noLoadCurrent, fcfu voltsPerHertz, fcfuH brakingVoltsPerHertz
  traction   F0 startingForce, a1 forceDropPerSpeed, Pmax maxPower,
             Imax maxCurrent
  braking    Fh maxForce, Ph maxPower, Vh0 offSpeed, Vh1 fullSpeed,
             abed cylinderPressureGain, edep maxEpDeceleration

and the state (InductionMotorState) groups the forces, the frequencies, the
values of the motors and the powers: FMAXMAX absoluteMaxForce, Fmax maxForce,
Fful fullForce, Fr force, Fzad forceDemand, ks slipShare, df slipFrequency,
fp supplyFrequency, fkr criticalFrequency, Uzsmax linkVoltage, U voltage,
pole flux, Ic torqueCurrent, If fieldCurrent, M torque, Ipoj lineCurrent,
Imax currentLimit, Pmax powerLimit, Pm mechanicalPower, Pe electricalPower,
eta efficiency.

The old comments of the constants took the "h" entries (Uzh, fcfuH, Fh, Ph,
Vh0, Vh1) for field weakening; the code uses them for the electrodynamic
brake, and the new names say so. The .fiz keys don't change. The constants
eimc_* / eimv_* are gone from physics/vehicletypes.h, and the labels of the
debug panel (TMoverParameters::eimc_labels, eimv_labels) move into
InductionMotor::ConfigListing() and StateListing().

One change on the screen: the eimc column of the debug panel (the engine
section of an induction motor vehicle) showed the labels from "Uzmax:" on
next to the wrong values (shifted by one entry, from "F0:" on by two), and
never showed abed and eped. It now shows each label with its own value. The
eimv column is as it was.

No change in the simulation: 1144/1144 tests, golden traces exact against
staging 62f7a29b.
2026-11-28 16:29:17 +01:00
Hirek ff739d2328 refactor(physics): the induction motor drive is a component of its own
The fields of the drive of asynchronous motors fed by inverters move from
TMoverParameters into InductionMotor inductionMotor
(physics/components/inductionmotor.h):

  eimc[26]                    config (std::array, indexed by eimc_* as before)
  eimv[21]                    state (std::array, indexed by eimv_*)
  eimv_pr                     forceShare
  InverterFrequency           inverterFrequency
  InvertersNo, InvertersRatio inverterCount, inverterRatio
  Inverters                   inverters (of Inverter, inverter before)
  InverterControlCouplerFlag  inverterControlCouplings
  EIM_Pmax_Table              maxPowerTable
  EIMCLogForce                logForce

The integrated controller (eimic, EIMCtrlType), which the diesel-electric
vehicles use too, and the ED/EP blending (MED_*) stay where they are.

No change in behaviour: 1144/1144 tests, golden traces exact against staging
62f7a29b.
2026-11-28 15:43:22 +01:00
Hirek 04f76951f5 refactor(physics): the diesel engine, the torque converter and the retarder are components of their own
TMoverParameters held some 80 fields of the diesel engine and its hydraulic
transmission among its other 600, named dizel_*, hydro_TC_* and hydro_R_*.
They are now three structures of physics/components/dieselengine.h, with
English names:

- DieselEngine diesel: the definition (maxMoment, maxRevolutions,
  minRevolutions, the governor, the clutch, the fuel consumption, the tables)
  and the state (fill, clutchState, clutchPressure, torque, power, the start
  up, the fuel consumed) and its heat (EngineHeat, heat_data before)
- TorqueConverter torqueConverter: present, the ratios, the lockup, the
  fill rates, the table, and its state (fill, lockedUp, torqueRatio, the
  revolutions in and out)
- Retarder retarder: present, its placement, torque, power, fill rates,
  clutch, and its state

The .fiz keywords, the keys of the dictionaries of the Python screens and the
names of the golden channels (dizel_fill...) are unchanged; only the C++
names changed. The functions of the engine (dizel_Update, dizel_Momentum...)
stay members of TMoverParameters for now.

No change in behaviour: 1144/1144 tests, golden traces exact against staging
62f7a29b.
2026-11-28 15:23:36 +01:00
Hirek b35a6129bc refactor(ai): the orders of the AI are DriverOrder and DriverOrders, not the bits of TOrders
The orders of the AI driver (TOrders) were unscoped bits, summed (an order
carries Change_direction on top of Shunt), masked, and compared as numbers
(order < Obey_train, order >= Shunt).

- vehicle/driverorders.h: enum class DriverOrder (waitForOrders,
  prepareEngine, releaseEngine, changeDirection, connect, disconnect, shunt,
  looseShunt, obeyTrain, bank, jumpToFirstOrder) and DriverOrders, an
  EnumSet of them. A small header, so brakesetting.h names the orders without
  Driver.h.
- the comparisons of the numbers are the sets they meant: the orders from
  shunt up are movingOrders, those from obeyTrain up trainOrders;
  SingleOrder() gives the order to a switch, where a sum of several matches
  no case, as it did
- the texts of the scenery commands (Shunt, Obey_train...) and of the
  translations are unchanged; only the C++ names changed

No change in behaviour: 1144/1144 tests, golden traces exact against staging
62f7a29b.
2026-11-28 13:43:45 +01:00
Hirek 54d3a1040a refactor(physics): EnumSet<E> for the sets of flags; the damage of a vehicle is VehicleDamage and DamageSet
- utilities/enumset.h: EnumSet<E>, a set of the values of an enum class whose
  values are bits, with the operations CouplingSet had (HasAll, HasAny,
  Empty, Set, Clear, Without, |, &, ^, ==, FromBits, Bits). CouplingSet is
  EnumSet<Coupling> now; an enum is a kind of the sets by IsEnumSetKind<E>,
  which gives it its operator |.
- the damage of a vehicle (DamageFlag) is a DamageSet of VehicleDamage
  instead of the int and the dtrain_* constants. A bit means one thing for a
  locomotive and another for a wagon; both names are there (thinWheel and
  loadShift, ventilator and loadDamage, engine and loadDestroyed).
- the SetDamage command of the scenery adds or takes away the damage by its
  number as SetFlag() did (setOrClear()); "WRECKED" is still the set of the
  number 255; the bearing divisor of the resistance stays the number 4.
- the damage of the tracks and of the catenary (dtrack_*, the traction's
  DamageFlag) are other flags and stay as they were.

No change in behaviour: 1144/1144 tests, golden traces exact against staging
62f7a29b.
2026-11-28 01:22:57 +01:00
Hirek 6003615e3e build(tests): a precompiled header for the unit tests
The game and the core library build with stdafx.h precompiled, the unit tests
didn't: each of their ~150 files parsed windows.h, GLFW, glm and doctest
anew, about 50 s each on a busy machine, half of the CPU time of the whole
build.

eu07_unit_tests precompiles stdafx.h and doctest.h too. main.cpp defines the
implementation of doctest before including doctest.h and goes without. The
vehicle physics stays out of the header: its unscoped enums (end::front...)
clash with names in the tests.

The test files take 28 min of CPU instead of 95 (10.7 s each on average), a
full build some 4-5 minutes less on 16 cores. 1144/1144 tests, golden traces
exact.
2026-11-28 00:08:13 +01:00
pol102 b7f2186a19 fix(audio): the sound comes back after the output device is lost or changed (#433)
* fix(audio): the sound comes back after the output device is lost or changed

Pulling out the headphones, or changing the output in the system, could leave the game silent until it was
restarted, also after the very same output came back. The renderer learned about the output only from the
events of the system (ALC_SOFT_system_events), and the check of the connection ran only without them. But:

- the system doesn't report every loss. A stream invalidated without the device being removed and without
  another default output (a jack pulled out of a shared output, a change of the format, exclusive mode taken
  by another program) only marks the device as disconnected. Nothing looked at that, so nothing reopened it;
- alcReopenDeviceSOFT returns ALC_TRUE also when the new output was opened but failed to start, which happens
  when the default output is reported before it is ready. The log said "reopened", the device stayed dead;
- a reopen that failed was never tried again, in spite of "(will retry)" in the log;
- with a device set in eu07.ini (sound.openal.renderer) nothing was followed at all: once that device lost its
  output it stayed silent, and a device absent at the start meant no sound for the whole session.

Now the connection of the device is checked once a second next to the events, a removed device has it checked
at once, a reopen counts only if the device is connected afterwards, and a failed one is tried again after
0.5, 1, 2, 4 and then every 4 s, and at once when the system reports any change. A device set in eu07.ini is
left alone while it works; when it is lost it is opened again, the default output stands in for it while it is
absent (also at the start), and the playback moves back when it returns. The failure is logged once per loss.

The decisions are in audio::output_follower (audio/outputfollow.h), free of OpenAL, with unit tests. The time
is the real one (steady_clock) rather than the simulation's, which stands still in pause and runs faster with
time acceleration.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRgQ1GsKSGmguyc4rhvXWy

* Revert "fix(physicslog): no road-vehicle logs, formatting on the writer, a slow disk and the closing kept short (#408)"

This reverts commit d6c3593520.

* fix(audio): no gaps from devices that aren't the one set, the move back retried, rarer attempts after a minute

Answers the review of #433:

- A move back to the device set in eu07.ini that opened but didn't start
  left no output at all (the library lets go of the default output before it
  tries the other one). The default output is opened again at once.
- The device set in eu07.ini is tried only when the library lists it, so a
  device of any other kind coming (USB, Bluetooth, HDMI of a monitor) no
  longer breaks the sound for a moment.
- With no output at all the attempts thin out to every 30 s after the first
  minute. An event of the system still has one made at once, but not sooner
  than 250 ms after the last one, as a device coming reports a burst.

And two faults found on the way:

- A device name with Polish letters, written in code page 1250 by the
  starter, was never found again once the device had been absent: it was
  passed to the library as it was. It is matched as 1250 text too, with or
  without the "OpenAL Soft on " prefix of the library.
- A move back that failed (the device reported before it was ready) wasn't
  tried again until another device came. It is tried again after 1, 2 and 4 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(audio): the log says which OpenAL library the game got and whether the sound follows the output with it

At the start the game writes one line naming the OpenAL library it plays through, its version and the file it
was loaded from (OpenAL32.dll of the game folder or of the system). With OpenAL Soft 1.23 or newer the line
says the sound follows the default output of the system, or the device set in eu07.ini
(sound.openal.renderer). With an older one, such as the 1.18.1 the game folder still has, nothing changes: the
sound stays on the device opened at the start, and the line says why and what library follows the output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: jerrrrycho <jurek.pakula@gmail.com>
2026-11-27 23:51:50 +01:00
pawelw 1a12c7ef4f fix(events): say in the log when a condition passes because it can't test, and when a call is dropped (#448)
* fix(events): say in the log when a condition passes because it can't test, and when a call is dropped

A condition which can't do its test passes, and nothing told the scenery
author. Now the log says so when the scenery loads:

- trackfree / trackoccupied with no target, or with a target that isn't a
  track (an isolated section, a memory cell): the track test passes every
  time;
- a word in a condition the reader doesn't know, such as a name written
  after trackfree: it's skipped;
- a multiple comparing a memory cell that doesn't exist: besides the cell
  (already logged), that its whole memcompare condition is off and it
  always runs the events before its else.

And log.txt says when an event called while it's still in the queue isn't
added again, with the vehicle of the lost call and of the queued one.

Nothing changes in how events run.

* fix(events): log a lost call once per stay in the queue, set the activator of a joint event

A standing vehicle queues its event0 / eventall0 every frame, so an event
with a delay logged "EVENT ALREADY IN QUEUE" once a frame until it ran
(65 thousand lines in 70 s of a train standing on such a track). Now a lost
call is logged only when it comes from another vehicle than the one which
queued the event, and once per stay in the queue.

An instant event handing over to its joint (same-name) event queued that
event with the vehicle of its previous run. It gets the vehicle of the
call now, which it runs with and which the log names.

The message about a missing memory cell says that only the memcompare test
is off, and that the event always runs the events before its else only when
no track or probability test is left.

* fix(events): don't log a lost call from another vehicle of the same train

A standing train calls its eventall0 from every vehicle, so the second
vehicle's call was logged once per stay in the queue, and as the line is
written once per stay, it could hide a lost call of another train standing
on another track with the same event. A call from a vehicle coupled to the
one which queued the event isn't logged now.

* test(events): the unknown word in a condition is logged with the event and skipped

A name written after trackfree is read as a word the condition reader
doesn't know: one line in the log names the event and the word, and only
the track test is set. The known words of a condition log nothing.

* test(events): turn the log capture off when a case stops at a failed REQUIRE
2026-11-27 23:51:42 +01:00