A control defined again in the same cab section of the .mmd with the
block key "duplicate: yes" no longer replaces the control: the first
definition stays the control (sounds, type, command feedback), and the
duplicate adds a copy with its own submodel, animation type and scale /
offset, following the control's value and active state. The duplicate's
sound keys are ignored so the control is not heard twice, and clicking
any copy works the control. This lets e.g. the ASF cab move its second
master controller and reverser with the first ones.
Without the key a repeated definition still replaces the earlier one,
as some of the game's .mmd files repeat controls with other submodels.
A duplicate with no definition of the control loaded from the current
cab's models before it is just the control.
clear_cab_controls() now also clears ggCompressorListButton, which kept
the previous cab's submodel.
The rule is in vehicle/gaugeduplicates.h, covered by
tests/unit/test_gauge_duplicates.cpp.
(eu07/maszyna#527)
An optional third column in the LightsList rows of the .fiz sets the cab
interior light when the driver moves the light preset selector to that
position: 0 off, 1 on, 3 on dimmed (bit 2 the dimmer). Rows without the
column, or with a negative value, leave the cab light to its own switch,
so the existing tables work as before; a stray note after the two light
columns (e.g. "38 38 / A") is not read as the flag.
The light follows the occupied cab, or all cabs of a JointCabs vehicle,
as with the interior light commands; the dimmer switch is moved along.
The lightsset custom position and the AI leave the cab light alone.
Covered by tests/unit/test_lights_preset_cablight.cpp.
(eu07/maszyna#529)
Takes care of the last two Sonar remarks, with no change in what the AI does:
- S134: the braking curve followed outside the final approach moves out of
adjust_desired_speed_for_target_speed() into
adjust_desired_speed_for_braking_curve(), with early returns.
- S6004: deltaAcc of increase_train_brake() is declared in the
init-statement of its if.
No change in what the AI or the distributor does:
- S134: the step of the train brake sized from the consist brake table
moves out of IncBrake() into increase_train_brake(), with early returns.
- S134, S1066: while starting uphill, the check of the released brakes
leaves Ready as it was by assigning the flag instead of nesting an if.
- S6004: the uphill condition of control_uphill_start(), and the target
cylinder pressure of TNESt3::CheckState(), are declared in the
init-statement of their if.
- S5350: the loop summing the tractive force walks the consist through a
pointer to const.
- S3776: the cylinder nozzle calibration for the AL2 relay moves out of
TNESt3::SetSize() into ScaleNozzlesForAL2().
No change in what the AI does; only the structure of the code that came in
with the braking changes:
- S107: shaped_braking_demand() takes the consist brake table as a struct
instead of four separate parameters; its lambdas capture explicitly.
- S3358: brake_response_horizon() picks the BrakeDelay entry without a
nested conditional operator.
- S5276: the speed passed to braking_distance_multiplier() is converted to
float explicitly, as it was implicitly before.
- S134: the stop case of the proximity range is an else-if of its own, and
its body a method of its own, adjust_desired_speed_for_final_approach(),
with early returns instead of nested ifs. The cargo train threshold
push is a conditional subtraction instead of a nested if.
- S3776: pick_optimal_speed() hands the uncoupling stages and the uphill
stand to set_velocity_for_uncoupling() and
hold_train_coming_to_stand_uphill().
TMoverParameters::RadioFuse, closed by default, stands for a fuse in the
cabinet, a lever on the desk or the switch on the radio's power supply.
RadioPowered() needs it closed, so with it open the radio's buttons, calls,
messages and the radio-stop stop working; opening it at a standstill resets
the radio-stop as switching the radio off does, and the radio and radio-stop
lamps go out. New commands radiofusetoggle/radiofuseenable/radiofusedisable
(no default keys), cab controls radiofuse_sw: (follows the fuse state),
radiofuseon_sw: and radiofuseoff_sw:, and radio_fuse for the Python screens.
The AI turning the radio back on closes the fuse too.
Existing vehicles don't change: the fuse starts closed and opens only from a
new cab control or a bound key. SVN data, optional: cabs that have such a
fuse or lever get one of the new controls in their .mmd, in the form of
radio_sw: (e.g. "radiofuse_sw: { <submodel> rot 0 0 0 }"); lang/*.po can
translate "radio fuse".
(eu07/maszyna#438)
A new optional key in the AI section of the .fiz, ShuntPantstate= (bits as in
Pantstate: 1 front, 2 rear, 3 both), sets the pantographs the AI driver keeps
up while its order is Shunt or Loose_shunt, moving and standing alike: it
raises those of the setup and lowers the others once one of the setup
collects the voltage, and doesn't raise more when idling. Lowering on the
track's demand still comes first. Without the key (default 0) nothing
changes, so an ET41 no longer has to shunt on all four pantographs once its
.fiz says so.
SVN data, optional: add "AI: ShuntPantstate=<1|2|3>" to the .fiz of vehicles
that should shunt on fewer pantographs, e.g. dynamic/pkp/et41_v2/203e-a.fiz,
203e-b.fiz and their _dsa150 variants (no AI line there yet). Without it the
vehicles behave as before.
(eu07/maszyna#461)
full_power() notched up as soon as the controlling half had closed its line
contactors. In the ET42 test the locomotive brake is still at about 2.0 bar
then, right at the pressure switch threshold, so whether the second half
starts as well depended on thousandths of a bar in its cylinder: a half whose
switch is on when the controller leaves zero doesn't close its line
contactors until the controller is back at zero. Any change to the air
brakes could tip it either way (with the corrected ESt3 the second half
stayed off and the train reached 88.7 instead of 106 km/h).
The helper now waits, as a driver does, until no pressure switch in the
train cuts the start off.
An electric and a diesel locomotive got their control coupled whenever the
scenario (and so the Starter) asked for it, since the scenery coupling ignores
ControlType, or when neither coupler named a control system, so a Vectron and
an SM42 ran in multiple unit.
TMoverParameters::Attach() now leaves the control connection out between an
electric (ElectricSeriesMotor, ElectricInductionMotor) and a diesel
(DieselEngine, DieselElectric/DumbDE) traction vehicle, for the scenery, the
AI, the coupling keys and the automatic couplers alike, and logs it. Vehicles
without own traction (cars, control trailers) are not affected, nor are
permanent couplings within a unit, nor couplers that both name the same
ControlType, which stays the vehicle authors' way to allow such a pair. The
AI coupling order expects the coupling the vehicles can take, so it doesn't
wait for the control connection forever.
Existing scenarios coupling such a pair still load, without the control
connection. "controlcoupling.enginecheck no" in eu07.ini turns the check off.
No SVN data change is needed. (eu07/maszyna#520)
New optional Cntrl. key ScndCtrlResistiveLock=Yes: IncScndCtrl() refuses
to step the shunt controller up while the master controller is at its
no-power position or on a resistive RList position (R >= 0.01), as the
interlock of the ET21, ET22 and EP09 does. Decreasing the shunt stays
allowed so it can't get stuck. The AI doesn't choose field shunting
while the lock applies. Without the key nothing changes.
Game data: the key is to be added to the Cntrl. line of the ET21
(et21_v2), ET22 (et22_v3, et22-2000_v2) and EP09 (ep09_v1, ep09_v2)
.fiz files that define it; until then they behave as before.
(eu07/maszyna#402)
The shunt mode of the diesel-electrics (ShuntMode=1: SM42, SP42, SU42) now
suspends their vigilance device (CA): no alerter while running, no alarm for the
button held too long, and an alarm already on goes out. The cab signalling (SHP)
stays as it was. Back in the line mode the CA works as before.
CurrentSwitch() asked MaxCurrentSwitch() first. Since 2e86b3a5 (2021) that one
takes any change of the motor overload relay threshold, on every engine type, and
reports it, so the first move of the switch only flipped the threshold (meaningless
on a diesel) and the shunt mode of the SM42/SP42 (and the 2Ls150 gear of the SM03)
took a second one, both on and off; the cab switch, which shows the shunt mode,
didn't move at the first click. The diesels with a shunt mode now set it alone.
The Elf's master controller (EIMCtrlType 2) gets an optional emergency
brake position below its position 0, turned on by the new .fiz key
EIMCtrlMainEmergency=Yes in Cntrl (default No, no change without it).
With it the old positions move up by one (MCPN 5, neutral at 4): the
emergency position brakes fully at once and vents the brake pipe, like
the alarm chain or the Impuls's EIMCtrlEmergency. The loader raises a
too small MCPN to 5 and logs it. The Elf code with hard-coded positions
(CheckEIMIC, the MED full braking, the AI) takes the shift into account.
SVN data to change afterwards (dynamic/pkp/elf_v1, needs this exe):
- every .fiz with EIMCtrlType=2: EIMCtrlMainEmergency=Yes, MCPN=5,
DirChangeMaxPos=4 where present;
- the cab .mmd mainctrl entries: offset one notch lower (-0.06 -> -0.09),
sounds shifted one index up, new sound0 with
26284_elf_nastawnik_nagle_*.wav.
Issue: (eu07/maszyna#413)
The 6Dg sets its power demand in 5% steps, while the universal controller
(EIMCtrlType 3) ramped it continuously. A new optional UCList header key,
CtrlValStep (e.g. 0.05), makes the setting move in whole steps: one at once
when the controller is moved onto a raising or lowering position, then one
each time SpeedUp / SpeedDown covers a step, stopping at the position's set
value. Without the key (default 0) nothing changes.
Data (SVN, optional, after this): add CtrlValStep=0.05 to the UCList: line
of dynamic/pkp/6dg_v1/6dg.fiz (its variants include it).
(eu07/maszyna#412)
The mainctrlact: gauge showed MainCtrlActualPos, which nothing sets for
DieselEngine/DieselElectric without an EIM controller, so the ST43's marker
never moved. For those it now follows MainCtrlPos (vehicle/mainctrlact.h);
every other vehicle reads what it did before.
New optional gauge key scaletable: [ value scaled, ... ] in the block form
gives a non-uniform scale, interpolated linearly between its points, in the
units of value * scale + offset; without it gauges behave as before.
Assets: none needed. To get the true ST43 scale, the line
"mainctrlact: stery_1 rot -0.016 0 0.0" of dynamic/pkp/st43_v1/*.mmd is to
become a block with a scaletable: of the 25 positions read off the cab's
scale; until then the marker moves linearly with -0.016 turn per position.
The limiter slept off the rest of each frame with sleep_for() given a float
duration. MSVC adds that to steady_clock::now() in float nanoseconds, so after
a few hours of system uptime the wake-up time is rounded to tens of ms: at
95 h uptime fpslimit 60 had no effect at all and fpslimit 30 gave ~22 fps, in
the full and the legacy renderer alike.
frame_pacer now schedules frames on a fixed cadence in steady_clock ticks and
the loop waits with sleep_until; an overshooting wait is made up in the next
frame. The FPS shown and the motion blur use the new mainloop_period stopwatch
(frame start to frame start, wait included); the targetfps/fpsaverage
draw-range controllers keep reading the work time as before.
(eu07/maszyna#416)
The smoke of a diesel came out at full strength the moment its ignition
set Mains and started the spin up, together with the ignition sound, whose
first part is the starter cranking the engine.
The ignition now starts a countdown of the new optional .fiz parameter
SmokeDelay (Engine section of DieselEngine and DieselElectric vehicles,
seconds, default 2.0, 0 restores the old behaviour); the smoke source of
the vehicle spawns nothing until it runs out. Engines already running, or
switched on another way, smoke as before. No SVN data change is needed;
vehicle authors may tune SmokeDelay to the cranking part of their
ignition: sample.
main_off_bt declared with "type: toggle" in the cab's .mmd is now the
line breaker's hold coil lever of the ET22 and EP09: it stays where it is
put. Off, it opens the line breaker and keeps it from closing (also
cancelling a closing armed by a held main_on_bt); back on, it only feeds
the coil again. The single keyboard key puts the lever back on before
closing, and a line breaker closed by the AI or through the control
cable puts the lever back on to match.
TGauge now remembers whether type: was given, since every control
defaults to toggle. Without type: on main_off_bt (all vehicles today)
nothing changes.
Data (SVN, not part of this commit): add "type: toggle" to main_off_bt:
in dynamic/pkp/et22_v3/*.mmd and dynamic/pkp/ep09_v1, ep09_v2/*.mmd.
Older exes ignore it.
Starting uphill the AI released the train brake (and the locomotive
brake with it) at once, while the power came on only later: a train on
10 per mille rolled back 20-30 m (E186 with 19 container wagons), and an
E189 with 7 Z2 coaches rolled back for minutes without power, because
the brake applied again for the rollback kept the power off. Many
locomotives cannot pull while their own cylinder is under pressure
(asynchronous drives switch to braking, others have a control pressure
switch), so holding the train on the locomotive brake is no way out.
A train standing on an up gradient with the train brake applied now
starts as a driver of a heavy train does:
- the train brake stays applied, the locomotive brake is released and
the locomotive's own share of the train brake is let off with the
releaser;
- the power is applied against the braked train (Ready does not hold
it back meanwhile, and the rule that brakes a train slipping back
is off);
- the train brake is released only once the tractive force exceeds 1.1
times the gradient force, the train moves forward, or after 45 s if
the locomotive cannot hold the train on its own power.
Multiple units are not affected.
Changes to how the AI works the train brake on the way to a lower speed
or a stop, so that it uses few, early applications instead of a late
deep one:
- Approaching a lower speed, the deceleration may fall short of the
demand by only half of a step (fBrake_a1) before the brake is applied
harder. With a full step the demand crept up meanwhile and a long G
train got its next step many seconds too late.
- The shortfall is checked every 3 s. If it keeps growing at a handle
left alone for longer than the brake takes to respond, the AI adds a
small step at once instead of waiting until the margin calls for a
deep one. A shortfall that shrinks on its own (brake still filling,
blocks gripping harder at lower speed) does not trigger it.
- Releasing, a position short of the first one counts as giving the
minimum stage of the distributor, not less.
- Holding the speed on a descent, the predicted excess speed is taken
off over the time the brake takes to respond, not at once, so a slow
brake does not get a deep application that then takes as long to
release.
Uphill a long train often came to a stand with its brake on the way
off and rolled back several metres: the AI released the train brake
to 0 about 20 m short of the stop (the gradient alone would have
stopped the train short of the stopping window), applied only the
first step again at the last moment, and a G train cannot apply its
brake again within the few seconds the gradient takes to stop it.
Coming to a stand on an up gradient (also when only part of the train
is on it) the AI now:
- applies the brake before the train stops on the gradient alone, once
the time left to the stand is no longer than half of what the brake
takes to apply;
- does not let the train coast on or pull up while the brake is applied
and the gradient would stop the train sooner than the brake of the
consist can be released;
- does not release the train brake any further below 10 km/h on the
way to a stand (unless the train is to be driven on);
- puts the locomotive brake on below 3 km/h when the train will reach
the point it is to stop at (not when it has slowed down short of it
and is to pull up), and at once if the train rolls back.
SetLights() gives RaLightsSet() the lights for the vehicle's end towards
the head of the consist and the end towards its tail, whichever way the
occupied cab faces. The coupling that switches an end off was looked up
at the opposite end whenever the cab faced the tail of the consist
(e.g. 6Dg driven from its second cab position), so the free end went
dark and the end with the train was lit.
The per-vehicle choice moves to lights_programmer::vehicle_lights() in
vehicle/lightsprogrammer.h, which checks the coupling at the same end
it lights, with unit tests for both cabs, both orientations and the
train at either end. Driving from a cab facing the head of the consist
gives the same lights as before. No data change needed.
The config key from eu07/maszyna#541. By default (yes) a pass reported to
__test.result waits until every vehicle has stood still for 1 s; with no it
ends the test at once. The key is listed with the other test.* settings in the
log and in the test start line.
Scenario tests: new case test_mode_pass_while_moving reports the pass from
event2 of tor1k as the train runs onto it and checks the run ended with the
train still moving (new check ends_moving). The README lists the test.* keys
with their defaults and the input the test mode ignores.
With --test the gamepad, mouse picking, UART, ZeroMQ and motion telemetry are
off, the hidden window gets no key, mouse, scroll or char callbacks, and the
window procedure that takes WM_COPYDATA commands from other programs isn't
installed, so nothing but the scenery drives a test run.
The test manager is reached through simulation::test() instead of a global,
the result cell is owned by a unique_ptr until the memory table takes it, the
cell value is compared with a margin, strings are built with std::format and
the --test settings moved to apply_test_mode_settings(). The driver's signal
check is folded into UpdateSpeedPosition(), which updates a speed table entry
and reports a signal at stop the head of the train just passed. The test.*
keys are listed with the other settings at the start of the log.
run.py starts eu07 with --test (and --test-timeout <duration> for cases that
record a fixed time) and compares the result from the exit code with the
case's expect key, before the physicslog checks. The 14 cases take about 30 s
with -j 4 instead of minutes. --watch keeps the old windowed run.
New case keys: expect, test_config (lines of a config block), track_events
(lines added to a track of the base scenery, e.g. event0 test_pass). New cases
show each end of the test mode: test_mode_pass, _signal_passed_at_danger,
_timeout and _standstill. The slippery rail cases slide past the red signal,
which now ends a test, so they set test.fail_if_stop_overran no.
README documents the test mode for scenery authors.
eu07 --test -s <scenery> [--test-timeout <s>] runs the scenery in ghostview with
the null renderer (models loaded, no textures), a hidden window, no sound,
network or python, and in fixed steps of 0.03 s of simulation time per frame
(three 10 ms physics steps) as fast as it can. Without -seed it uses a fixed
seed, so two runs give byte-identical physicslogs.
The scenery reports its result to the __test.result memory cell, which the
simulator always creates: value 1 passes once every vehicle has stood still for
1 s, value 0 fails at once. The run ends with exit code
0 pass, 1 fail,
2 a train passed a signal at stop (SetVelocity 0 0, as seen in its driver's
speed table; SetVelocity 0 x on automatic block doesn't count),
3 timeout (test.timeout, default 3600 s of simulation time),
4 standstill (every vehicle still for test.standstill s, default 300, with no
result; a pass with test.pass_on_standstill yes),
5 error (no -s, the scenery didn't load or has no vehicles, an exception).
The test.* keys go in the scenery's config block; test.fail_if_stop_overran no
only logs a signal passed at danger. Outside the test mode a signal passed at
danger is logged.
The null renderer gets a ui backend which draws nothing, hands out the null
texture and material instead of throwing, and ends the ui frame. A GL context
is still made for the hidden window, without asking for a version, as parts
of the ui create textures with gl calls of their own. No crash dialog or
message box in test mode; the window code no longer needs a monitor.
- physicslog rows keep all columns (text ones as None), checks can read
the wheelslip flag and the new vehicle speed column
- slips: the lead vehicle's wheels slip at some point (makes sure a
slippery rail case does what it's meant to)
- slip_clears: once stopped, the wheels stop slipping within N seconds
- holds_still: once stopped, the vehicle doesn't creep, by vehicle speed
- td_red_signal_moving.scn: the red signal case starting already moving
- eu07_slippery_red_signal / eu07_slippery_push_red_signal: skid on
braking for the red signal with track friction 0.03; the pushing one
fails without the fix for eu07/maszyna#479 (stays skidding, creeps)
- sn61_td_timetable: stop hold 5 -> 2 s, the railcar arrives 5-7 s
before its departure time, so 5 s made the case flaky
The Velocity column is the wheel speed, which stays at 0 while the wheels
are locked in a skid, so a vehicle sliding on locked wheels looked as if
it stood still. Add the signed vehicle speed in km/h as the last column.
- eu07_td_red_signal: no route set, the train has to stop before the exit
signal and stay there (new checks stays_stopped and distance; distance
is integrated from the speed, the physicslog has no position)
- en57/ep09/et22/sm42/sn61/vectron/eu07_td_timetable share one fragment
template, td_timetable.scn; a case sets vars.consist and the lead vehicle
is named {{vehicle}} = autotest_<case>
- -j N runs cases in parallel: each case has its own physicslog and, with
multiplelogs, its own log files, which are moved to out/<case>/
- a run stops at once on Bad vehicle / Bad trainset instead of waiting for
the timeout, and fails after 120 s without physicslog rows
- the .sbt geometry cache of a test scenery is dropped when the base
scenery is newer
All 8 cases pass in about a minute with -j 4.
eu07_td_timetable now takes about 20 s instead of 4 min. Its speed profile
at 20 and 60 matched a real-time run within a few km/h and seconds; the
physicslog keeps its 0.05 s rows. The runner polls the log every 0.25 s so
it does not overshoot the case duration by a minute of simulation.
tests/scenarios/run.py builds a test scenery from a game install's scenery
(own trainsets removed, case fragment added), runs eu07 in ghostview with
physicslog on, and checks what the vehicle did: starts, max speed, brakes,
stops. First case: EU07 on td.scn driven by AI on the td/rozklad timetable,
with the Stacja1 exit route set by an event launcher instead of shift+4.
eu07 gets a -ini <file> option: an extra settings file read after eu07.ini,
so a test run can switch to a window and turn on physicslog without touching
the user's config.
Local only: scenery and vehicle data are not in the repo.
* docs: CLAUDE.md with the team's notes for Claude Code
The rules Claude Code sessions kept relearning, shared with the team:
- the code builds and behaves the same with GCC 13 (Linux CI and the
Sonar build) as with MSVC, with the MSVC leniencies to watch for;
- every SonarCloud remark on the changed code gets fixed without
changing behaviour, with the recipes for the rules that keep coming
up;
- building, the unit tests, scripted editor runs, the game data and
the profile folders, and GPU hangs;
- the game data in the asset SVN and backward compatibility: existing
files keep being read as before, new entries are optional, code
falls back without new assets and a change that uses them says so
in its commit message, what the editor saves stays readable by the
current release, new features can be turned off in eu07.ini and
don't change the look of existing data abruptly; StarterNG is the
official starter.
* docs: CLAUDE.md on the move to OpenGL 4.6 and Vulkan
betterRenderer/ is to be removed and the OpenGL 3.3 and legacy
renderers are being replaced by feat/gl46-migration (PR #216, a draft
with milestone 27.04). Work on that code and on the shaders is kept to
fixes and to what a feature on master needs to be drawn, with the PR
saying where the branch has the counterpart.
---------
Co-authored-by: maj00r <maj00r@host>
The rule "wyluzuj lokomotywe, to szybciej ruszymy" released the
locomotive's own brake whenever power was asked for and the locomotive
cylinder held more than 0.4 bar. It had no speed condition, so it also
fired in motion, at 50-75 km/h, right after an application. On a
locomotive with the EStED distributor (E186) this vented the control
reservoir; with the pipe not yet recharged the locomotive brake then
faded to nothing at the next application.
The rule is meant for starting off, so it now applies only below
1 km/h.
The rule "wyluzuj lokomotywe, to szybciej ruszymy" released the
locomotive's own brake whenever power was asked for and the locomotive
cylinder held more than 0.4 bar. It had no speed condition, so it also
fired in motion, at 50-75 km/h, right after an application. On a
locomotive with the EStED distributor (E186) this vented the control
reservoir; with the pipe not yet recharged the locomotive brake then
faded to nothing at the next application.
The rule is meant for starting off, so it now applies only below
1 km/h.
On the electric locomotives the lamp of the open line contactors tells the start can be made, so it goes out with the
start cut off by the pressure switch. The diesel-electric SU45 and SU46 (the only diesel-electrics with the lamp) use
it just to show the contactors are open, but it went out the same way: with too low a pressure in the main pipe the
contactors were open and the lamp out. Once the pressure came back with the master controller past the first
position, the contactors stayed open, as they should, and the lamp lit up on a power position, which looked like
the lamp working the other way round.
On the diesel-electrics TMoverParameters::LineContactorsLampLit() now follows the contactors alone; the electric
locomotives and the other main circuit lamps are unchanged.
Tests: tests/unit/test_line_contactors.cpp, on a locomotive made after the SU46.