18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-03 06:35:21 +01:00

4768 Commits

Author SHA1 Message Date
maj00r e8b3ba054a Merge pull request #584 from MaSzyna-EU07/feat/rail-singing
feat(audio): the rails sing before a train comes, as heard by the track
2026-12-03 05:53:37 +01:00
Hirek f4d31e7884 Merge pull request #595 from MaSzyna-EU07/fix/gl46-ssbo-binding-limit
fix(gl46): keep the storage buffer binding points under 16 for Intel graphics
build-staging
2026-12-02 23:48:00 +00:00
maj00r 35cafe9de5 fix(audio): the rails stop singing when the editor opens, nor sing in the test mode; Sonar of #584
- driver_mode::push_editor() stops the singing before the editor is pushed, by F11 and by the edit session. push_mode()
  doesn't call exit() of the mode it covers, so the loops went on playing in the editor. Back in the driver mode the
  next update scans the rails again.
- The sound of the singing isn't made in the test mode, which has no sound (enter() skips begin()); update() is under
  the test-mode guard of staging since the merge.
- sound.railsinging.nearboost: a train within 40 m is louder by it, one at 40-100 m by a part of it growing as it comes,
  as closeness() has it; the comment said within 100 m.
- Sonar, the values unchanged: the measured levels written as floats (each the same float as before, checked for all
  232), the centres of the sixths of an octave counted in a while loop, CTAD, try_emplace, the flag of the sound made with
  the default ordering, an if without a variable, using enum in a test. The std::mt19937 of the noise is NOSONAR: the
  noise of a sound, the same for a seed on every compiler.
build-feat-rail-singing
2026-12-02 18:33:09 +01:00
maj00r fbf4e0b03e Merge remote-tracking branch 'origin/staging' into feat/rail-singing
# Conflicts:
#	application/drivermode.cpp
2026-12-02 18:13:21 +01:00
jerrrrycho ed8708c5e2 feat(simulation): snapshots, save the state of a running scenery and load it back (stage A) (#420)
* feat(simulation): text format of simulation snapshots

A snapshot of a running simulation is a text file in the syntax of the scenery
files: entries of the form <type> <name> <key> <value> ... end<type>, the first
one a header which names the scenery. This is the text alone: entries, writer,
reader, the names of the things of a scenery, the plan of coupling changes and
the command line switches (--load-snapshot, --snapshot-at), in the core library
with unit tests. Nothing reads or writes a snapshot yet.

* feat(simulation): snapshot of time, weather, cells, switches and events (L1)

--snapshot-at <seconds> <file> writes a snapshot when the simulation has run
that long, --load-snapshot <file> puts one over the scenery once it has loaded,
before the first frame. This layer keeps the clock and the simulation timer,
the weather with the wind, the random engine, the memory cells, the switches,
the tracks an event can change and the ones made on the run, the traction
power sources, the event queue, the timers of the launchers and the lamps of
the signals.

While a snapshot is put back the event manager is suspended, so nothing in the
scenery reacts to it. Existing classes only get accessors for what was private
(the fraction of the second, launcher timers, the speed limit of a track, the
wind, the state of a power source, the event queue). Without the switches
nothing changes.

* feat(simulation): state of a vehicle's physics for snapshots (L3, core)

What TMoverParameters holds of a running vehicle, to and from an entry of a
snapshot: speed, load, controls, switches and relays, pantographs, doors,
engine and its cooling, the air of the pipes, of every reservoir of the brake
valve (with the flow it has yet to take in) and of the chambers of the driver's
valves, the vigilance device, the power circuits. In the core library, tested
on the real vehicle definitions: a
vehicle restored on a fresh one saves the same, and runs on next to the one it
was saved from.

The brake valves, the driver's valves and the vigilance device get accessors
for their private state (reservoirs(), latches(), pressures(), state()), a
reservoir one for the flow it has yet to take in; nothing else in the physics
changes. This comes before the vehicles of the scenery (L2), whose
speed and load are kept by it.

* feat(simulation): snapshot of vehicles and consists (L2)

Every vehicle is kept with the place of both its axles (track, distance,
direction, path of a switch, events still to set off), the way it faces, its
couplings with their flags, destination and, through its physics, speed and
load. Loaded, the vehicles are put straight where they were
(TTrackFollower::Place(), which trails no switch and fires no event), then
parted and joined until they are coupled as saved, whatever trainsets the
scenery made of them.

A vehicle of the snapshot the scenery does not have is skipped and reported,
one the snapshot does not know stays as the scenery made it, one which had left
the simulation is taken out again.

* feat(simulation): pantographs and passenger exchange in snapshots (L3)

What a vehicle keeps of its machinery beside its physics: the arms of the
pantographs as they stand under the wire, the time without voltage, the
passengers getting on and off, the lighting of the compartments, the headlight
toggles, the last force asked of the electrodynamic brake.

* feat(simulation): snapshot of the drivers and of the player's vehicle (L4)

A driver is kept with its orders and the one it is on, the name of its
timetable and its place in it, the consist it has, what it holds to (speeds of
signals and limits, the reason it stands, its timers and flags), its table of
what is ahead on the track with the point limits it has latched, its tables of
what the brake of the consist gives, and whether the AI drives. A driver who
had moved to another vehicle of its train is moved there.

A run loaded in ghost view (the test mode) is ready before its first frame, as
the run it goes on from was.

The snapshot also names the vehicle the player was in, which --load-snapshot
starts in unless -v says otherwise.

* feat(simulation): snapshotsave command, on [Ctrl]+[Shift]+[F9]

Writes a snapshot of the simulation to snapshots/<scenery>_<date>_<time>.snapshot
in the game folder. The command is the last one of the list, so the numbers of
the others stay.

* test: scenario cases which load a simulation snapshot and compare the run

A case with a "snapshot" section runs its scenery to a time, taking snapshots
on the way and at the end, then again from the first snapshot, and compares the
two ends: positions, speeds, pressures, couplings, cells, switches, drivers.
The snapshot saved right after loading has to be the one loaded.
tests/scenarios/snapshots.py reads the format and tells two snapshots apart.
The switches and the format are described in tests/scenarios/README.md.

* fix(simulation): a vehicle gone in the snapshot leaves its isolated sections

The scenery counts the axles of every vehicle in the isolated sections of
the tracks it puts it on. A vehicle the snapshot has as removed was only
taken off the list of its track, so its two axles stayed counted there and
the section never went free again: the next train on it went 4-6-4 axles
instead of 0-2-0, and its busy and free events never fired.

- A removed vehicle counts both axles out of the sections of their tracks,
  is taken off the list of its track only if it's on it, and has no owner.
- The drivers a snapshot doesn't have are deleted as before, and no
  vehicle keeps its owner pointing at one of them.
- The snapshot keeps the count of every isolated section and sets it after
  the vehicles are placed: the vehicles a consist leaves behind as it goes
  through a portal stay counted where they were, in the game too. A count
  the placing gives other than the snapshot has is told in the log.
- A vehicle with two entries is placed once.
- TIsolated::axles() reads and sets the count.
- The harness compares the counts of the sections; a new case,
  snapshot_td_portal_isolated, has a train leave through a portal from the
  track of a section before the snapshot.

* fix(simulation): every value of a snapshot file is checked before it's used

A damaged or edited snapshot could put an index past a table, a count
which takes forever or a number out of the range of its type into the
simulation, and a file cut short was put back half way.

- Reading a value: a whole number has to be whole and fit its type (an
  enum its underlying one), a float can't be past its largest value; what
  doesn't fit is refused. Every refusal names the entry, the key and the
  value, and goes to the log (errors.txt), up to 100 lines and a count.
- Ranges: coupler ends 0 or 1 and the flags of a coupling; couplings which
  would close a ring of vehicles; the count of the points of a driver's
  table and of its point limits (not past the keys of the entry), the
  indices into the table (tablelast, semnext, semnextstop); the order
  stack and its position, the timetable station, the driver's enums and
  directions; the path, events and distance of an axle, facing and first
  axle; the date and time; switch states, made track ends, crossing
  segments, event siblings and times, launcher timers, the weather; the
  load (amount, and a name which isn't a path); the whole numbers inside
  number lists (flags of a table point, the stop of a coupler pair, the
  track flags under a vehicle, the fuse count of a power source, the cab
  of the vigilance device).
- The positions of the controllers are brought within the ranges of the
  vehicle: master and secondary controller (set and actual), reverser,
  cabs, light, compressor and wiper switches, brake handle, hand brake,
  dimmer.
- A document with problems isn't loaded unless --load-snapshot-force says
  so; a test run ends with the error code then. The header counts the
  entries, so a file cut between two entries is found too. A file of a
  newer version is a warning, not a problem.
- A snapshot is written to <file>.tmp and renamed over the file only when
  the stream didn't fail.
- Unit tests of the reader on damaged input.

* feat(simulation): the pullee mode and the holding brake timer in snapshots

Of what #419 and #424 added to TMoverParameters, two are state: PulleeMode
(prepared for being hauled dead; the scenery sets it, PulleeModeSwitch()
can change it) and StopBrakeReleaseTimer (how long power has been asked
for, which lets the holding brake of a unit go after its delay). Both are
kept now, as "pulleemode" and "stopbrakereleasetimer". The others
(PressureSwitchBrakeCylinder, EmergencyBrakeMainOffPressure,
StopBrakeReleaseDelay) come from the vehicle definition and aren't.

* fix(simulation): the snapshot code without Sonar issues

No declaration shadows an enumerator, the variables used only by a
condition are declared in it, write_file takes its writer as a template,
the temporary file is a std::filesystem::path, the isolated sections are
looked up by a transparent hash, apply_couplings is split into helpers,
and the copies of the simulation's random engine are marked NOSONAR.
The test data has no http:// in it. No snapshot key or format changes.

* fix(brakes): TSt113 lists the control pressure once

TSt113::pressures() added CP on top of TH14K1::pressures(), which
already has it since #366 removed the CP of TSt113 that hid it. A
snapshot held the St113's control chamber twice. The second entry is
removed.

Tests: every driver's handle lists each pressure once, and the St113
pressures of an EN57 saved through a snapshot come back on a fresh one.

* fix(simulation): snapshots skip road traffic, refuse changed sceneries, keep misplaced vehicles apart

Cars of the road spawn points which a snapshot has on the road are no longer put back: the spawn point owns
them and the snapshot would leave them frozen on the track. They're counted in the log. The pooled cars keep
their AI drivers, which the snapshot used to delete.

A snapshot whose scenery fingerprint differs is refused unless --load-snapshot-force is given: tracks named
"#N" shift when a track is added. Each vehicle is checked against the x/y/z of its entry after placing. One
more than 1 m off, or one which can't be placed, goes back where the scenery put it, isn't coupled to the
placed vehicles, and keeps its scenery state and driver.

Couplings set from a snapshot keep to CompatibleCoupling, so no MU control between an electric and a diesel
loco (#520).

The snapshotsave key writes to snapshotsdir of eu07.ini (snapshots by default, ini only like screenshotsdir),
adds _2, _3... to a name that is taken, and shows where the file went.

* refactor(simulation): the snapshot reads and writes the private state of the vehicles through their own members

Since #552 the state of physics::Vehicle and of its parts is private, and since #531 the vehicle, the AI
and the cab live in other files under other names. The snapshot code is ported to that:

- the state of a vehicle's physics is saved and loaded by physics::Vehicle::SnapshotSave() and
  SnapshotLoad() (physics/components/snapshot.cpp), with the tables of the variables in a nested
  snapshot_members; capture_mover() and apply_mover() only hand it the entry. The parts with private
  state (low voltage, line breaker, line contactors, protective relays, converter, air of the
  pantographs, compressor, air supply) give a plain Snapshot of it and take it back
  (TakeSnapshot(), RestoreSnapshot()); the rest goes through their queries and setters
- the keys, their order and the numbers in them are unchanged, so the snapshots written before load:
  the fields that moved into the parts are mapped there (Mains to lineBreaker, PipePress to brakePipe,
  BrakeCtrlPos to brakes, dizel_* to diesel, hydro_* to torqueConverter and retarder, eimv to
  inductionMotor.state in the order of the old table, EngDmgFlag to equipmentFaults, ...)
- TDynamicObject: the machinery of a vehicle (sections, rail joints, the passenger exchange) is saved
  by members of its own, as these are private now; MED_oldFED is the last ED demand of the consist's
  brake blending (ConsistBrakeBlending::LastElectrodynamicDemand())
- TController: the driving flags are saved as the bits of iDrivigFlags they were, the running brake
  test as the number of its stage, the uphill start and the braking shortfall from their structs;
  StaticBrakeTest, which is gone, is written as 0 and not read
- the couplings take Coupling, CouplingSet and VehicleEnd; orders are DriverOrders
- the unit tests of the snapshot of a vehicle use the queries and the parts

* fix(simulation): carry the driver's coupling set in the snapshot as the bits of the set

iCoupler is a CouplingSet since 2098614f, which record::set()/get() can't take. It goes
through the converted values as a whole number, as the driving flags do: Bits() on save,
CouplingSet::FromBits() on load. The key and its values are the same as before.

* fix(simulation): a loaded snapshot counts the vehicles it left where they stand

apply_isolated() set every isolated section to the count of the snapshot, also where a
vehicle the load left at its scenery place (misplaced, forced load, road traffic not put
back) stands, or where the snapshot had it. The axles of those vehicles are now counted in
the sections they stand in and out of the ones the snapshot has them in, and the memory
cells of those sections say whether they are taken by that count.

An AI consist doesn't end on a vehicle the load left: the ends are then found along what is
coupled now, as CheckVehicles() finds them.

The player entry no longer writes the cab, which nothing read: the cab is the one the
vehicle has occupied (caboccupied of its entry).

* feat(simulation): the snapshot keeps a derailment and the brakes of a sleeping vehicle

A derailed vehicle came back on the rails. Its entry now keeps what derailed it (outcome,
cause, speed, the cause and side of the motion off the track, the acceleration, the
collision derailment) and the distance its criteria were last checked over; the
derailment the scenery and the test mode were told of (new_derailment()), so it isn't told
again; and with physics.derailment new the motion of the body off the track
(derail_motion::body::state()) with the timers of the vehicle off the track. The terrain
under it is gathered anew around it when it loads.

sleep_brakes, what a sleeping vehicle's brake force came from, is kept too.

All keys are new: an entry without them leaves the vehicle as the scenery made it, so files
written before still load. New scenario case snapshot_td_off_track.

* fix(simulation): the snapshot keeps the sanded start of an AI driver

#494 (in staging since the last runs of the snapshot cases) made a driver whose start
slipped keep sanding under power until the train is under way, and take the power down a
step at a time. Neither the flag nor the time of the last step down was kept, so on
linia61 the loaded run sanded one frame later than the run which went on and parted from
it 0.06 s after loading (suwnica2, 9 mm and 0.08 km/h at 600 s). Both are kept now
(sandedstart, sandedstarttime); an entry without them leaves the driver as it is.

* fix(simulation): the snapshot keeps a train running forked on a switch thrown under it

Staging's switch fork running (#496) gave the axles and the vehicles state of their own: the way of a
switch an axle ran onto (TTrackFollower::iPath, which it leaves the switch by after a throw), the ways it
remembers of the switches behind it (path_memory, read when the axle behind it comes onto one of them),
and per vehicle the switch its bogies or its coupled ends run forked on with whether that was told
(m_forkbogies, m_forkends). None of it was in a snapshot: a loaded train on a switch thrown under it
would have left it by the way it is set now and never derailed running forked.

- Place() sets the way of the switch from the path the axle is put on, as SetCurrentTrack() does, and
  clears the facing entry the vehicle hasn't looked at (there is none between frames).
- A vehicle entry has the remembered ways of each axle, oldest first (axle0switch0, axle0way0...),
  recorded again into an empty memory on load (path_memory::entries()), and the forked watches
  (forkbogies, fork0, fork1 with their "told"). A name which isn't a switch is refused.
- New case snapshot_td_switch_thrown: the snapshot is taken while the second coach of
  eu07_td_switch_thrown_facing_behind_derails runs forked and hasn't derailed yet; the loaded run derails
  it the same way and the two files at 150 s are identical.
2026-12-02 15:40:25 +01:00
Hirek 99b9265110 fix(gl46): keep the storage buffer binding points under 16 for Intel graphics
The drivers of integrated Intel graphics offer 16 shader storage buffer
binding points (GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS). The OpenGL 4.6
renderer used 16 (the water of the windscreens), 17 (the spherical
harmonics of the cab probe) and 18 (the cells of the rain). Every material
shader includes light_common.glsl, which declares the cab probe block, so
none of them compiled on Intel and the whole scenery was drawn pink
("shader storage buffer binding must be less than ... (16)").

- the sky light (sky_ubo) and the light of the cab probe (cab_probe_ubo)
  are uniform blocks now: 9 vec4 each, which every fragment reads the
  same of, and which std140 lays out as std430 did. cabprobe_sh.comp still
  writes the probe's buffer as a storage buffer, bound right before its
  dispatch (gl::ssbo::bind_uniform() binds the same buffer as the block)
- the result of the atmosphere and the write of the cab probe share
  binding point 9 with the other compute passes, which bind theirs right
  before their dispatch; the sky no longer keeps the atmosphere result bound
- the water of the windscreens takes point 5 and the rain cells point 7
- gl::MAX_SSBO_BINDINGS (16) with a static_assert over every point, and
  the log gives the points the driver offers at start, with an error when
  there are fewer

No extra binds per draw: the cost on NVIDIA and AMD stays what it was.
The SPIR-V binaries of shaders/ogl46bin/ compiled from the old common.glsl
are out of date and the shaders are compiled from the sources until they
are made again (shaders/compile_spirv.py).

feat/gl46-migration has the same points (water 16, cab probe 17) and needs
the same change.
build-fix-gl46-ssbo-binding-limit
2026-12-02 15:15:11 +01:00
Hirek 304ce934cc Merge pull request #375 from miloszunio/pr/brush
Editor: the brush of models as one model or many in a circle
2026-12-01 23:40:31 +00:00
Hirek 33feccb61b Merge pull request #406 from MaSzyna-EU07/fix/linux-case-extras
fix(files): the files #362 left are found and written in another case on Linux (GE#542)
2026-12-01 23:40:14 +00:00
Hirek fdc77484b8 Merge pull request #566 from MaSzyna-EU07/perf/msvc-release-lto
build: link-time optimization on by default for MSVC Release builds
2026-12-01 23:39:47 +00:00
Hirek a05781fc1e Merge pull request #562 from MaSzyna-EU07/ci/sonar-master-only
ci(sonar): one analysis per pull request at a time, with a time limit
2026-12-01 23:39:30 +00:00
Hirek b7772203fc Merge pull request #558 from MaSzyna-EU07/fix/sonar-staging-reliability
fix: the five bugs SonarQube Cloud reports on staging (reliability E)
2026-12-01 23:39:12 +00:00
Hirek 9bbbed18f6 Merge pull request #488 from MaSzyna-EU07/fix/inactive-cab-mirrors-flag
fix(vehicle): fold the mirrors of an inactive cab only when InactiveCabFlag says so
2026-12-01 23:38:42 +00:00
Hirek 082f248264 Merge pull request #484 from miloszunio/feat/flashlight-gl46
feat(driver): a flashlight for the player (Ctrl+Shift+F)
2026-12-01 23:37:41 +00:00
Hirek 1b3b92f6af Merge pull request #496 from MaSzyna-EU07/feat/switch-fork-running
feat(physics): a switch thrown under a train runs forked, and may derail it
2026-12-01 23:37:22 +00:00
Hirek c54b4e3589 Merge pull request #524 from MaSzyna-EU07/fix/compile-spirv-paths
fix(shaders): compile_spirv.py keeps its paths inside the shader tree and runs the compiler without a shell
2026-12-01 23:36:09 +00:00
Hirek 664a864f13 Merge pull request #563 from MaSzyna-EU07/perf/test-mode-hot-paths
perf: faster simulation step, mostly in the test mode (byte-identical results)
2026-12-01 23:35:27 +00:00
Hirek 9d73bb960d Merge pull request #568 from MaSzyna-EU07/test/scenario-runner-longest-first
test(scenarios): longest cases first, -j from the CPU count, utf-8 output
2026-12-01 23:35:02 +00:00
Hirek f71da105f6 Merge pull request #581 from MaSzyna-EU07/fix/derail-coupling-pull-angle
fix(derailment): the coupling off the track pulls hook to hook, not straight across (GH#579)
2026-12-01 23:34:09 +00:00
Hirek 22be853abc Merge pull request #582 from MaSzyna-EU07/feat/vulkan-memory-breakdown
feat(vulkan): the statistics show the device memory by its uses
2026-12-01 23:33:43 +00:00
maj00r ed58a3aab0 Merge pull request #535 from MaSzyna-EU07/feat/model-format-e4d
feat(model): the E4D model format: spec, reader, writer and conversion from E3D/T3D
2026-12-02 00:11:40 +01:00
maj00r d313e75107 perf(audio): the sound of the singing rails is made on a thread of its own
Making the sound took about 0.8 s on the main thread at the first frame of
driving, which stalled the game once. It's now made on a std::jthread
started when the driving mode is entered, and handed to the audio on the
main thread once it's done; until then the effect is silent.

The making itself is a little quicker too (0.68 s in RelWithDebInfo): the
spectrum is smoothed over the sixths of an octave in one pass, the levels
the plums and the voice are set against come from one spectrum, and dB
are turned into amplitudes with exp rather than pow. The sound made is the
same.
2026-12-01 23:41:00 +01:00
maj00r 98ce78a659 feat(audio): the rails sing before a train comes, as heard by the track
A listener by the track hears the rail next to them hiss before a train
arrives: the wheels set the rail vibrating and the bending waves run along
the steel far ahead of the train. The rail nearest the listener now gives
this sound for the trains along it, as far as the way along the rails lets
it through.

The sound is made in code when first needed, so no asset is needed. It's
built from a recording of rail singing: noise of its measured spectrum (a
table of levels every 1/24 octave), close tones near 1.2-1.5 kHz that
swell together now and then, a calm ring near 7.84 kHz, short tones
falling from about 1.3 to 0.9 kHz now and then, and, for a train within
100 m, steady tones near 5 and 6 kHz measured under a passing train. The
parts are six looped buffers, played by sources placed on the rail where
it's nearest the listener.

The volume follows the way along the rails, walked through the switches as
they are set: the rail takes 0.02 dB/m, each joint 0.5 dB (from the
existing sound distance of the track, so jointed track carries it a much
shorter way), each switch 3 dB. The sound comes in from 1500 m, faster as
the train nears, in full from 100 m, and 6 dB louder within 100 m. It
grows with the speed and with the mean axle load of the consist, so a
draisine hardly sings. The listener's own consist isn't heard from the
rails.

eu07.ini: sound.railsinging (yes) turns it off, and sound.railsinging.volume
(0.45), .range (1500 m), .full (100 m), .decay (0.02 dB/m) and .nearboost
(6 dB) tune it. With sound.railsinging no the simulator behaves as before.
No format changes, no SVN changes.
2026-12-01 23:24:09 +01:00
miloszunio 585e51d140 docs(editor): the brush says rightly what happens when the step of a stroke is gone; the test's generator marked for Sonar (#375)
A correction of 1a6d2bb, whose message and comment were wrong: a stroke whose step is gone from the history didn't crash the
editor and doesn't go on in a step of its own. brush_dab() ends it before the models of the dab, as it did in a87a94d, so
brush_step(true) always has a step in the loop; the null check there is for the analysis (S2259). brush_step() returns null for a
step that is gone without touching the serial, as before 1a6d2bb, and the comments say so.

The helper of the unit test which takes the generator of the test carries the NOSONAR(cpp:S2245) the other ones have: a
repeatable test, not security. Without it the quality gate failed on the security rating.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1p6qPUo2Cgx4KaVYU
2026-12-01 22:34:14 +01:00
jerrrrycho 88139ce300 fix: the swapchain is destroyed without allocating, not by swallowing what the destructor throws
destroy() let go of everything at once through release_images(), which keeps the present semaphores for later in a vector and so may
allocate. It now destroys the views and the semaphores itself and is noexcept, and the destructor needs no empty catch (Sonar
cpp:S2486 on the PR).
build-fix-sonar-staging-reliability
2026-12-01 20:38:43 +01:00
miloszunio 1a6d2bbc2f fix(editor): the brush keeps its models when the step of the stroke is gone from the history (Sonar)
A stroke held long enough for its step to be trimmed from the history took the step as null and the next model crashed the
editor (Sonar S2259 in editormodebrush.cpp). The rest of the stroke now goes to a step of its own, which Ctrl+Z takes back.

The other notes of the analysis, with no change of behaviour: the fill loops test their counter only and stop on the limit
inside (S886), brush_on_line() is const, the step is found with std::to_address, the line shape of the brush is
shape::along_line (it shadowed the line settings, S1117), and the test of the picks without finite settings is a helper
(S134), with std::numbers::pi in the density test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1p6qPUo2Cgx4KaVYU
2026-12-01 20:29:37 +01:00
Hirek 2ceaa816a4 feat(vulkan): the statistics show the device memory by its uses
Each buffer and image in device local memory counts to the use it was
made for: its name without the number at the end, the textures and the
terrain maps in groups of their own (they are named after their files).
The statistics list the largest uses, the free space in the blocks of
the allocator and what the process holds outside of it (the swapchain,
the driver, DLSS), under the device memory line.

The unnamed staging buffers of the uploads are named "upload staging".
build-feat-vulkan-memory-breakdown
2026-12-01 19:59:36 +01:00
jerrrrycho 8ffb74a3b0 test, docs: the buckle case folds less with the coupling pulling hook to hook (GH#579)
eu07_td_off_track_buckle_fast checked that the overturned train comes to
rest folded by 8 deg at least. With the pull of the couplings no longer
across between the buffer faces, they hold the bodies more in line: with
the fixed seed the bends are 1 to 4 deg (3 to 8 before), with the seeds
1 to 6 the largest bend is 7 to 73 deg (21 to 78 before); the same with a
local build of staging and with the CI one. The check takes 3 deg, the
description gives the numbers.

behaviour-changes.md: the coupling off the track pulls hook to hook.
build-fix-derail-coupling-pull-angle
2026-12-01 19:51:07 +01:00
jerrrrycho 4f8b77c474 fix(derailment): the coupling off the track pulls hook to hook, not across between the buffer faces (GH#579)
With physics.derailment new, derail_motion::meet() took the pull of the
coupling along the line between the two buffer faces. Ends side by side,
almost touching along the track and 0.4 m apart across it, gave a line at
80-90 deg to the vehicles, and pull_neighbours() pulled the neighbours off
with Y/Q 1.4-4.3 from a coach that had barely left its line.

A screw coupling hangs between the draw hooks, which swing in the
headstocks behind the buffers. The pull now goes from the hook of one end
to that of the other: the end points moved back along each body's axis by
hook_depth (= buffer_length, 0.6 m; UIC buffers stand 620 mm out of the
headstock). 0.4 m across with the buffers touching gives ~18 deg. In line
nothing changes. Ends gone past each other (gap = distance between the
beams) keep the line between the beams, the way that gap closes: the hook
line turns about there and would hold the bodies with the hooks side by
side, pulling straight across.

gap, push, the buffer path and the point the force acts at are unchanged.
The shares of the force along each vehicle (measure_off_track) follow the
new line too.
2026-12-01 18:58:27 +01:00
jerrrrycho b63e9c5916 perf(audio): without an audio device the sound files aren't decoded (#571)
The test mode turns the sound off, so upload_sound() makes no AL buffer and
the decoded samples were thrown away; decoding them took a fifth of the load
of tomaszewo and over half of the load of l053_poranek. The file is still
found and its caption read, so what the simulation sees doesn't change.

Load to 'test: started' (LTO build, det.ini, seed 12345, 3 runs each):
- tomaszewo_raj40821: 34.8 / 35.4 / 36.2 s -> 26.2 / 19.1 / 19.1 s
- l053_poranek: 26.6 / 26.1 / 26.0 s -> 7.1 / 7.2 / 7.2 s
Physics logs of the full tomaszewo run: 14 of 14 identical, log lines after
the start identical; the 6 scenario cases: 6 of 6 .dat identical.
2026-12-01 18:51:54 +01:00
jerrrrycho f2aa5d5852 fix: count the names asked for in the case summary line, and scope the lock build-fix-linux-case-extras 2026-12-01 18:24:05 +01:00
jerrrrycho 77affa28d5 fix(files): the files found in another case are counted, and listed only with logs.filecase
These files load fine since #362, so a run no longer gets a log line for each of them. It gets one line with their
count when the game closes, none when there are none; "logs.filecase yes" in eu07.ini logs each name, once, as before.

- The count is written at the closing, as it covers the whole run: the vehicles, sounds and textures loaded after the
  scenery count too, which a line at the end of loading would miss.
- An eu07.ini key rather than a log type of its own: logs.filter sets all the types at once, so a type off by default
  would come on for anyone with "logs.filter 0".
- On Windows nothing is found in another case, so nothing is counted or logged.
2026-12-01 18:24:05 +01:00
jerrrrycho 67a7e3876c fix(files): a new layer isn't made over a file there in another case, and the review's smaller points
- node_layers::create() refuses a name a file is there with in any case: on Linux path() wrote over it.
- A name is marked as logged only once the file is known to be there.
- The log line says the file is on disk in another case; the folders FileOnDiskToWrite() looks up aren't logged.
- The editor start reads the layers, and the heightmap terrain its terrain.yaml and pack files, as they're named on the disk.
- The write test compares the names exactly; a test of the log line once per name, with the lines kept by the test log stub.
2026-12-01 18:24:04 +01:00
jerrrrycho 40cc6a2c93 refactor(utilities): the case report list without Sonar issues
The set of files already reported sits behind a function instead of a
mutable global, with a transparent hasher. No change in behaviour.
2026-12-01 18:23:28 +01:00
jerrrrycho d670cc2e53 fix(files): the files #362 left are found and written in another case on Linux (GE#542)
were still opened by the name the scenery gives, in lowercase, and some were written by it, so on Linux a new file went
to a new lowercase folder next to the real one, or a second file was made next to the one there.

Opened through FileOnDisk() now: the .vmd animations of the events, the Lua script of the scenery, the Lua and WASM
screens and the files they read from their folder, the textures read for the colour of the rails, and the .sbt files a
scenery includes with the terrain directive.

FileOnDiskToWrite() gives the file to write: the one there in any case under its name on the disk, otherwise the name
given in the folders as they are on the disk, the folders missing in any case named as given. The editor's layers
(node_layers::path()), the .sbt the game writes and the heightmap terrain folder go through it; the editor removes an
.sbt there in another case. The .e3d made of a .t3d is written next to the text, or over the .e3d there in another case.

FileCased() writes each file found only in another case to the log once (logtype::file), the list for the authors of
the data to name the files as they're asked for.

Nothing changes on Windows: FileCased() gives the name back as it is there, and nothing is logged.
2026-12-01 18:23:24 +01:00
jerrrrycho a1a988d753 test: the trains of the hose exchange kept from one step to the next against ones worked out in every step
One train, a locomotive with five freight wagons on a gradient, stepped twice from the same seed: as the game
steps it, the trains of the hoses kept in the cache, and with them worked out again in every step
(test::consist::keep_hose_trains(false)). Charged, braked, the last two wagons uncoupled, released: with
Global.physics_sleepheld the wagons held by their brakes fall asleep and wake on the way, so the trains change
with the uncoupling and with the vehicles going to sleep and waking. The pipes, the reservoirs of the hoses and
the brake cylinders of the two are bitwise the same after every step. A cache which is never laid out again
after its first step fails it (10203 differences).
build-perf-test-mode-hot-paths
2026-12-01 17:28:55 +01:00
jerrrrycho c45700d253 test(scenarios): the second coach derails forked first, its neighbours then pulled off
eu07_td_switch_thrown_facing_behind_derails failed on its on_track check:
once c2 derails running forked, the off-track motion of #451 takes its
ends, 0.4 m to the side of the coaches next to it, as a pull across them
(80-88 deg, Y/Q 1.4-4.3) and pulls c1 and c3 off, and c1 the locomotive.
The case now checks what the fork does: c2 derails first, with nothing
derailed or off the track before it in the log, it leaves the track
upright (flange climbed), and the train stops. log_lacks takes an
optional before pattern for that.
build-feat-switch-fork-running
2026-12-01 17:27:32 +01:00
jerrrrycho 2a63ddd1a9 fix(derailment): a vehicle derailed running forked slides along the track of its leading axle
With its bogies on the two ways of a switch, the line between its axles
is a chord across the two tracks, and the bed of the off-track motion lay
between them. track_front() and track_bed() now take the leading axle by
the sign of V while the bogies run forked (m_forkbogies, the axles not on
one way): its PathDirection() is the line, its position the point of the
bed. off_track_offset() is measured from that point too. Without a fork
nothing changes: the bed is between the axles as before.

same_way() moves to vehicle_dynamic (vehicle/dynamic/internal.h) for this.
2026-12-01 17:27:31 +01:00
jerrrrycho 5911ae728a fix(ai): the route scan of the switch fork after the includes again
The merge of staging put TableTrainPath(), TableTrackLength() and
TableSwitchThrownUnder() at the top of vehicle/ai/routescan.cpp, before
its licence header and includes, so the file didn't compile (both CI
builds of 3ebaf6871 failed on it). Moved below the includes, unchanged.
2026-12-01 17:27:31 +01:00
jerrrrycho 4187171859 ci(sonar): analyse every pull request again, one analysis per pull request at a time
The premise of the previous commit was wrong: pull requests into staging are analysed and get a
quality gate (#566 today). The run of #558 that gave no result was cancelled in the queue, which
is about an hour per analysis with many pull requests at once.

- build.yml runs for pull requests into any branch again, as on staging
- sonar.yml: a concurrency group per pull request with cancel-in-progress, so a newer commit's
  Build stops the analysis of the older one. workflow_run.pull_requests is empty for a pull
  request from a fork, so the fork and its branch name the group then. A push to master gets
  a group of its own commit and isn't cancelled
- sonar.yml: timeout-minutes 120 on Analyze, and an error status on the commit when the
  analysis is cancelled, so it doesn't stay "Analysis in progress"
- the scan of staging stays removed: build.yml pushes only on master, so it could never run
build-ci-sonar-master-only
2026-12-01 17:11:58 +01:00
jerrrrycho f3212f9bad docs(shaders): glslc from the Vulkan SDK or on PATH in the README
--glslc is gone, so the README names PATH instead. GLSLC_NAMES is back in the order of staging,
glslc.exe first.
build-fix-compile-spirv-paths
2026-12-01 17:02:07 +01:00
jerrrrycho ecf524063e refactor: std::array for the buffers of the physics log line and the seed of the lazy engine, ownP in the if
Sonar's remarks on the new code of this branch: the C arrays of append_fixed(), append_int() and
lazy_random_engine are std::arrays (S5945), the pressure of the ESt3 relays read once is declared in the
if that uses it (S6004), and the thread_local pointer to the lazy engine has the NOSONAR of the one above
it. The snprintf of the infinities and NaNs of the physics log stays, with a NOSONAR: std::format writes
them otherwise than printf's inf and nan(ind). No change of what the code does.
2026-12-01 16:59:35 +01:00
jerrrrycho 2883887f5c perf(physics): the trains of the hose exchange kept by the vehicle table, the inputs of a step read into kept storage
The cache of the trains was a function-local static of vehicle_table::update_brake_pipes(), shared by every
vehicle_table and kept from one scenery to the next; it's now a member next to m_brakepipes, the list it is
for. The inputs of each step were read into a new vector, twice per step (the brake and the main reservoir
pipe); they're now read into scratch storage of the cache, swapped with the kept inputs when they differ.
2026-12-01 16:58:29 +01:00
jerrrrycho b490d6a49d build: link-time optimization for the unit tests too, reword the USE_LTO comment
eu07_unit_tests links eu07_core, which USE_LTO compiles with /GL; without the property on the test
target MSVC met those objects in a link without /LTCG and restarted the link with it, after a warning.
INTERPROCEDURAL_OPTIMIZATION_RELEASE is now set on the test target too.
2026-12-01 16:58:17 +01:00
jerrrrycho 5b77fed81f perf: the settings static back with MSVC's thread-safe initialisation check
Takes back 3be7f5e82. /Zc:threadSafeInit- on utilities/Globals.cpp drops the guard from every function-local
static compiled in that file, those of the inline and template functions of stdafx.h and the project's headers
included, and the linker may keep that file's copy of such a function for the whole program. The 1.4% it gave
in one run is inside the run-to-run noise, so a static put in a header later and used from two threads isn't
worth the risk. Globals.cpp is built with the precompiled header again.
2026-12-01 16:57:52 +01:00
jerrrrycho 4a7eab6e13 test: the copy of the thread's engine marked as the simulation's randomness for Sonar (S2245) 2026-12-01 16:57:52 +01:00
jerrrrycho 5b1bbd7a09 test(scenarios): at most 2 slow cases at once with the default -j
With --slow and the default -j (half the logical CPUs) the five slow cases that don't have to run alone
started together, longest first, up to 5 x 2.4 GB at the start of the run. Without -j at most 2 of them
now run at once; the other places take the short cases meanwhile, in the same longest-first order. A -j
given on the command line lifts the limit. "started" is printed when a case really starts.

README: the slow wrzosy_pxe336080_couples still runs alone after all the others.
2026-12-01 16:56:57 +01:00
Hirek 1089a24995 Merge pull request #576 from MaSzyna-EU07/fix/vulkan-host-copy-fallback
fix(vulkan): textures filled by the host fall back to staging buffers where the driver can't make their images
2026-12-01 15:07:25 +00:00
Hirek 02f450c1ab fix(vulkan): a texture image that fails for another reason doesn't turn off host copy for its format
An image to be filled by the host which can't be made is tried again without the host transfer usage, and only when that one
can be made is the format filled through staging buffers from then on. When it can't either (the memory ran out), the texture
fails as before and the format keeps the host copy. The warning says the error logged before it was recovered from.
build-fix-vulkan-host-copy-fallback
2026-12-01 16:03:43 +01:00
Hirek 1ae8fdc62a Merge pull request #560 from MaSzyna-EU07/fix/derailment-ground-556
fix(derailment): no fall through the ground off the track, and more friction on it (#556)
2026-12-01 10:07:17 +00:00
Hirek c90113f4d3 fix(vulkan): textures filled by the host fall back to staging buffers where the driver can't make their images
On a GeForce GTX 1050 (driver 582.28) every DDS texture loaded in the background came out white: the driver reports
hostImageCopy for the format, but an image with VK_IMAGE_USAGE_HOST_TRANSFER_BIT can't be made (vmaCreateImage fails with
VK_ERROR_FEATURE_NOT_PRESENT), and the texture was left without a gpu image.

- The check of a format (once a format) also asks the allocator for the memory a trial image of the textures' kind would go to,
  and uses hostImageCopy only when there is such memory and it is device local.
- Each texture is checked against the limits of the format for that use (maxExtent, maxMipLevels), which were left unread.
- An image the driver still can't make is made again without the host transfer usage and filled through a staging buffer, and
  the rest of its format goes that way too.
- The log says once a format which way its textures go.

Devices where hostImageCopy works keep it: the check is made once a format.
2026-11-30 23:37:40 +01:00