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

273 Commits

Author SHA1 Message Date
maj00r fa06830c64 Merge feat/editor-turnout-catalogue into feat/editor-model-in-editor 2026-11-24 19:15:15 +01:00
maj00r 348cc2df47 fix(editor): migrated switches leave to the side their records say, bent ones migrate, a record fitting two types isn't guessed
- The migration mapped L to hand 1, but switch_store::classify() writes R where the diverging end lies to the positive cross of
  the direction, which is the side of hand 1 of the domain (its curvature above 0 turns that way). Every migrated switch came
  out mirrored, and the test checked hand == 1 for an L record without looking at where the diverging end lies. R is hand 1
  now, and the test checks the side of the diverging end.
- classify() writes a switch bent into a curve as Rlj or Rld with the radius of the ordinary switch it's bent from; the
  catalogue has it as an Rz, so no bent switch could migrate. They're looked up as Rz.
- catalogue_type() took the first loose match. A movable nose isn't in the record, so the ordinary frog is taken where the
  catalogue has both; a record fitting two other types (the variants of an Rpd) is kept as it was, why with it.
- Slips and crossings are kept as they were, as the header of the migration says.
- Smaller: the type looked up is checked before its length is read; new diverging, slip and crossing tracks get the
  chainage of the turnout as a diverging track had before; the walk of a bent transition stops on a step that turned nothing
  instead of dividing by it.
- Sonar: the leg check skips an end whose turnout isn't found (S2259), the spacing of a crossover is measured in whole steps
  counted in an integer (S2193), the seeded generator of the turnout kinds test is marked (S2245).
2026-11-24 19:15:13 +01:00
maj00r 28a81ee0bd Merge ui/editor-lay-flow into feat/editor-turnout-catalogue
# Conflicts:
#	editor/layout/layoutGenerator.cpp
#	editor/layout/layoutNetwork.cpp
2026-11-24 19:15:02 +01:00
maj00r b15f7dcdec fix(editor): file names outside the code page don't crash the project, includes are found in any case, a project file cut short isn't put in place
- The scenario index made a string of the name of every file in the folder, which throws on Windows for a name the ANSI code
  page can't hold (the class of GE#560). It looks at the extension first and leaves out a .scn the game couldn't open by its
  name either; the messages of the project file show paths as UTF-8.
- The includes are read with the FileCased() fallback of the game (scenery_text::file_text), so on Linux an include written in
  another case no longer drops the scenario from the index, skips the migration of its file or marks its tracks as changed by
  hand.
- save() closes the file before looking at it: a failed last flush no longer renames a truncated .new over the project.
- "next node 0" is refused instead of wrapping to 0xffffffff.
- open_project() writes no .eu07proj when there were no //$ lines to migrate, and asks exists() without throwing.
2026-11-24 18:54:33 +01:00
maj00r 2b36fbe9af Merge feat/editor-track-turnouts into feat/editor-project-file 2026-11-24 18:52:09 +01:00
maj00r fffdbb9578 fix(editor): no diverging track is laid from a main track that isn't laid, a switch track with no pieces isn't written
- lay_diverging() didn't look at turnout_frame::valid: with the main track unsolved the diverging track was laid from the origin
  and settle moved its end node there. Edits were rolled back by the check, but nothing refused it at its source. It now
  returns an error, for every caller.
- whole_path() took Pieces.front() of a track the cutter gave no pieces of; the switch track is refused with the reason.
- Sonar: the turnout lookups of the node and network checks are guarded (S2259), the search of the free transition and the
  test loops count in integers (S2193; 2 m steps, the same values as their sum), the seeded generator of the turnout edits
  is marked (S2245).
2026-11-24 18:52:04 +01:00
maj00r e95ee2fc4c Merge ui/editor-first-steps into feat/editor-track-turnouts
# Conflicts:
#	editor/layout/layoutNetwork.cpp
2026-11-24 18:50:23 +01:00
maj00r 4ae90e99c6 fix(editor): the norms see a Bloss transition as it is, a line splits at the tangent point of an arc with no transitions
- A Bloss transition went to the norms as an even one: 60 m into R 600 m at 100 km/h showed 63 mm/s of deficiency change,
  where its middle reaches 109 mm/s, past the hard limit of 80 mm/s, so the edit wasn't blocked. norms::element::bloss makes the
  engine follow 3t^2 - 2t^3 of the curvature, look at the transition in eight pieces, and take the shift as L^2 / 40R instead
  of L^2 / 24R. Two Bloss halves no longer run on into one element of the chain.
- split_line right at the tangent point of an arc without transitions was refused ("the tangent there doesn't cross the
  tangents of the curve"): the curvature there is already the arc's, so it now takes the start or the end of the curve.
- Sonar: the chain walk, describe_chain and check_norms check the lines they look up (S2259), join_ends returns when an end
  isn't found rather than when a reason was given (S836), the test loops count in integers (S2193), the seeded generator
  of the random edits is marked (S2245).
2026-11-24 18:48:49 +01:00
maj00r e3092df0ca Merge feat/editor-norms into feat/editor-track-model 2026-11-24 18:40:24 +01:00
maj00r a8e1e6ab71 fix(editor): TSI and EN take close jumps of the cant deficiency together, the norms queue keeps its own span after a delete
- TSI INF and EN 13803 limit an abrupt change of the cant deficiency but give no intermediate length, so two jumps a few metres
  apart were each checked alone: at km 478 of the golden line CH reported 191 mm over the TSI limit, TSI itself nothing. With
  no intermediate length in the profiles of the element, the longest any profile asks for is taken. The golden report changes
  that way: TSI gets the 191 mm hard limit at km 478, EN reports it instead of 106 and 85 mm one by one.
- forget() moves the span whose findings alone are kept (a diverging track) down by the spans removed before it, and drops a
  queued line whose own span was removed, instead of leaving the index on another span.
- The report test of R 400 / 80 mm runs at 90 km/h and requires the finding: at 80 km/h there was none and the check never ran.
2026-11-24 18:40:23 +01:00
maj00r 001dd0439a Merge test/editor-track-golden into feat/editor-norms
# Conflicts:
#	application/editormodeselftestexpect.cpp
2026-11-24 18:35:42 +01:00
maj00r 4217650469 test(editor): the entries known to be lost are checked apart from should_fail, the cant test says where the inspector conversion is tested
- A normal test checks that known_lost.scn and each of its entries are there and read, so the should_fail tests can't pass for
  data gone missing.
- The comment of test_cant.cpp said the tests of cant_of_roll()/roll_of_cant() are here; they are the self-test case
  1_inspector_cant.txt, as the unit tests don't link the editor.
2026-11-24 18:35:19 +01:00
maj00r 6ed30b0fbd Merge fix/editor-switch-rules into test/editor-track-golden 2026-11-24 18:34:45 +01:00
maj00r 0de04dceed Merge ui/editor-track-panels into fix/editor-switch-rules
# Conflicts:
#	application/editormodeselftestexpect.cpp
2026-11-24 18:34:44 +01:00
maj00r 65e4870318 test(editor): a mistyped track fails the self-test, indented comments are skipped, case 7b checks the switch got bent
- A blank line or an indented `#` comment in a script is no longer a command no group takes.
- `trackcant`, `routegauge` and `tracksetdelete` with a track that isn't there count as a failed expectation.
- `expect shaped <switch> <yes|no>`: 7b checks that the gizmo drag bent the switch out of its record before deleting it.
- The ramp-length loop of test_alignment counts in an integer (Sonar S2193).
2026-11-24 18:34:25 +01:00
maj00r 00f5dbb98a feat(editor): the scenarios naming a track looked through before it goes, the index of the map built in the background and kept
The last part of E4a (editor-tracks-domain.md §0 pkt 7; §8, deleting a line): with the editing on the model on, a track a scenario of
the map names goes, or is renamed, only when the user says so.

- editor/project/scenarioIndexCache: the scenario index of E3 built on a thread of its own as the map is opened, and kept: in memory,
  and in a file of the cache of the user between the sessions (scenario_index/<map>.txt; not for the self-tests), for as long as the
  *.scn files of the folder are the ones it was built of (their names, sizes and times); on a big map it takes minutes, once. The
  editor doesn't wait for it to close. users_of() tells the scenarios naming the tracks, with what names them and where.
- Del on an old track with a name, on a set of them, or on a track of a line of the model (its line goes), the route design applied
  to old tracks, and a track renamed in the inspector (editor_mode::track_rename) wait for the index ("Checking the scenarios":
  cancel, or go on without checking), then go at once where no scenario names the tracks, or ask: "Track used by 2 scenarios", each
  scenario with the trainsets, events and the rest naming the track, the file and the line; delete (rename) anyway, or cancel and
  nothing changes.
- The self-tests: the scenarios of the map of the fixture, tests/editor/scenery/autotest_editor.<part>.scn, copied by run.py next to
  the copy of the fixture as autotest_editor_<case>_<part>.scn, naming that copy (autotest_editor.uses.scn: a trainset on s1, an event
  on d2). The index of the fixture's map over the scenarios of the game's folder takes about 80 s.

Tests: U: the index written and read back with its fingerprint, other versions refused; the users of a track by its name as the
simulator compares it; built once in the background, given again for the scenarios as they are, built again when one changed, read
from the file of the cache in the next session, built for another map. Self-test: modelwait, modelrename, expect question
<waiting|scenarios> [n]; the case m_5_index_delete (Del on s1 asks: cancelled it stays, confirmed it goes; d2 renamed the same; a3 and
a line of the model go at once); m_6 and m_7 wait for the index.

lang/editor_pl.po: the Polish of the new texts.
2026-11-23 15:58:30 +01:00
maj00r a7a641944f feat(editor): the project of the map opened with the scenery and written with it, behind a setting of the editing on the model
The first part of E4a (editor-tracks-domain.md §3, §9, §14): the domain model of E2 and the project file of E3 brought into the
running editor, behind a setting, "Editing on the model (trial)" in the settings of the editor, off by default. Off, nothing of it
runs and the editor is as it was.

- editor/project/projectSession: the project of the map open in the editor, no scene. open() reads the project file of the map, or
  makes it of the //$ lines the first time (open_project of E3), and compares the tracks the generator wrote with the files as they
  are now: a track changed or gone outside the editor marks its line changed by hand. trial() tries a command on a copy of the network
  and tells the lines it lays anew or takes away (differences()), nothing changed; execute() carries it out, the lines of Overwrite
  no longer taken for changed by hand with it. A command kept is a step of the model's history with a token, which the editor's step of
  it takes back and brings again (undo(Token), redo(Token)): only the latest step kept, or taken back, can be, so the two histories
  can't go out of step; the marks of a change by hand go with the step. record_written() records the tracks of a line as the scenery
  save wrote them, save() writes the project with the network as it is, the records of the lines gone taken out.
- The setting on, the project of the map (the file of the scenery opened, <map>.eu07proj next to it) is opened with the scenery and
  written with it. The scenery save asks for the text of each track it writes (scene::node_layers::path_writer): a track the generator
  made, as long as nothing else changed it, is written as the generator made it (the numbers in the shortest form which reads back to
  the same double, not the 15 digits of the export), and its checksum recorded; one changed by the other tools is written by its own
  export and its line marked changed by hand. The tracks of the lines of the project are found in the scene by their names, with the
  text the file has for each (scene::node_layers::source() tells the file and the placement of a node).

Tests: U: a map opened gets its project file; a command refused, tried or carried out, changes nothing and isn't a step; a command
tried changes nothing, carried out tells its lines (new, split, a curve changed, deleted); the steps taken back and brought again by
their tokens in the order of the history, another token refused, a command after an undo dropping the step taken back, the
identifiers not given again; the tracks of two lines written and recorded, a reopen finding nothing changed and the line the same to
the bit as the model laid it, a speed edited in the file marking its line alone, deleting it writing over it too, the mark taken off by
a command writing over it and back with its undo, the records of a line deleted gone with it at the save.

Self-test: modelediting <0|1> (the setting for the run, not kept), expect modellines, expect projectfile <present|absent|lines n>.

lang/editor_pl.po: the Polish of the new texts.
2026-11-23 15:58:30 +01:00
maj00r 84dca7cccb feat(editor): the //$r switches of an old scenery on the lines of its alignments made turnouts of its project
E5, what E3 left (editor-tracks-domain.md §9 "Migracja"): the //$r records were kept in the project file as a block a file; the switches
among them which the domain can lay now become its turnouts when the map is first opened.

- A switch or a double switch of the editor becomes a turnout where its record names a type of the catalogue (its type, rail, radius, ratio
  and a, b of an ordinary or a symmetric one; the first of the catalogue's order where a movable nose is the only difference, which the
  record doesn't keep), its start lies on a line made of an alignment within a centimetre and its direction along the line or against it,
  and its main track is bent as the record says the line is there (straight, or the radius within 5 %). It's laid into the line by the
  command insert_turnout, the hand of the record, with edit_policy::no_new_block: the old line may break the norms where nobody touched
  it, the turnout may add no BLOCK finding to it.
- Its record goes on its own into the project with the main track of the turnout (as an //$h record keeps the line it became); the rest of
  the block stays as written, the comments with it, why each switch didn't become a turnout with it: a slip or a crossing (their records
  don't tell the side of the crossing track), a connection (the solver of the connections lays it anew), a lifted outer track, no type of
  the catalogue, no line under it, a bending other than the line's, or the reasons the command refused it for. A block none of whose
  switches became one is kept as before, with the reasons.

Tests: U: an alignment of data/records with five //$r lines: two switches on its straight, along it and against it, to the left and to
the right, made turnouts of their types at their starts (the structure whole, no reason); one beside the line, one of no type of the
catalogue and a connection kept in the block with the comment, each with why; the two records each with the main track of its turnout;
the project written and read back the same. The records of data/records and of the map of data/project/migration (no switch on a line)
kept whole as before. Unit tests 1096 -> 1097.
2026-11-23 14:49:35 +01:00
maj00r efcc28b0ed feat(editor): the solver of the connections of the tracks: a crossover between two lines, the norms of the straight and the spacing
E5 (editor-tracks-domain.md §7 "Połącz tory", §8 "Połącz dwa końce ... odmowa ... z najlepszą propozycją"): editor/layout/layoutConnection
plans a crossover between two lines running alongside, straight or curved, and the command connect_tracks lays it, one step to undo.

- The first turnout where it's asked for, toward the other line; the second one on the other line running back, its diverging track facing
  the first one's, where the line between their ends turns by as much at both of them: on one straight between straights alongside (the
  headings of the ends within 1e-13 rad), one curve between curved lines. Found by the secant along the other line, each try the turnout
  laid in a copy of the network, so it's put as the command will put it.
- The spacing of the lines measured along the whole crossover, a point every metre, not where it starts; the least of it against the
  least spacing of the type: of ST-T1-A6 tab. 11.2 where the catalogue gives it, or what its geometry needs with the least straight
  between its turnouts (crossover_spacing()), the larger.
- The least straight between the turnouts from the norms: a new parameter of the E1 module, switch_straight, at the speed through them:
  max(0.15 V; 6) m in the running and the main tracks (11.3 pkt 7d, WARN), 30 m on a line of 160 km/h or more (pkt 7e, BLOCK; the new
  feature fast_line), 6 m recommended in the side tracks (pkt 7c). The solver asks for the normal limit.
- Where they can't be met: refused with the reasons and the best which fits the spacing measured, a type of the catalogue of the rail of
  the one asked for before the others, the fastest; or that none fits, and the spacing the type asked for needs.
- The line between the turnouts runs at the speed of their diverging tracks and is a part of the connection of the tracks for the norms
  (the feature switch_track of its class, which describe_chain() puts on its elements): an arc with no transitions nor cant where it isn't a
  straight, and the steps of the cant deficiency and the elements between them judged as in the tracks of turnouts (tab. 9.15, 9.16).

Tests: U: crossovers of Rz 60E1-500-1:12 between straights 4.75 m apart, both ways to both sides: the spacing 4.75 m all along, the
straight between the ends (4.75 m less twice the offset of an end) / sin(1:12), the norms' 9 m at 60 km/h, the ends facing each other on
one straight, one step to undo; a line closing in on the other refused for its spacing along the crossover though wide enough at its
start; 0.15 m short of the spacing for the 9 m straight refused with "11.3 pkt 7" and a type proposed, which then is laid; 30 m on a
line of 160 km/h; Rz 60E1-760-1:14 refused at 4.74 m by tab. 11.2 though its geometry fits; between two curves of R 1200 and 1195.5 m
4.5 m apart (4.50086 to 4.50087 m along it), both turnouts bent, one curve turning by 0.6 degree between their ends; a slip, a line to
itself, a line across and a type of none refused; the rows of switch_straight. Unit tests 1089 -> 1096.
2026-11-23 14:49:35 +01:00
maj00r bed4898ca6 feat(editor): the bending of the turnouts exact: table 11.8 for the whole diverging track, the main track on a transition as it is
E5 (editor-tracks-domain.md §4 "Rozjazd", §7 "Na łuku — łukowanie z dokładnym wzorem (tab. 11.8)"), what E2b left: table 11.8 for the curve
of the basic switch only, the rest of the diverging track bent with the main track by the sum of the curvatures, a main track on a transition
taken at its mean curvature, the sign of the curvature of the diverging track judged from headings sampled every half metre.

- Table 11.8 written for the curvatures, r" = (R r -+ t^2) / (R +- r) as k" = (k + K) / (1 - k K t^2) with the tangent t of the basic switch,
  bends every curve of the diverging track and the ends of its transitions, each as long as keeps its turn off the main track (the angle of
  the frog); the curve of the basic switch keeps switch_curve::bent_radius(), the same numbers as before; a straight goes with the main
  track as before (the formula gives K for k = 0). On a straight nothing changes.
- The frame of a turnout knows its main track: where its curvature changes under the turnout (a transition curve, or the end of one) the
  diverging track is laid in steps of 2 m at most, each one's curvature at its ends by the table with the curvature of the main track at the
  station it runs by (along the main track, its heading off the main one taken in), the turn of each part kept; the straights and the lead
  with the main track step by step too.
- The curvature of a diverging track of one sign all along it, from its elements (9.7 pkt 12, 11.4 pkt 6): a BLOCK rule of the turnout in
  place of the sampled check of switch_curve (KZW II), which a short straight through the frog going the other way could slip through.

Tests: U: a diverging track of a curve of 800 m, the curve of the basic switch of 500 m and a transition off it, bent with main tracks of
1200 m both ways and of 3000 m: each by the table with the tangent of the basic switch, the basic one the same as bent_radius(), each turning
off as far as in the basic switch, on a straight to the bit as it was; Rz 60E1-500-1:12 60 m into a transition of 200 m to R 1200 m: laid in
steps, its curvature at the start by the table with the main track's there, growing along it, the frog against the main track where it ends
beside it at 1:12.0004 (1:11.9966 by the mean curvature, the end 27 mm apart), moved and back the same; Rz 60E1-190-1:9 bent two-sided
refused, its curve turning off to its side and the straight through its frog the other way (KZW II), one-sided not. Unit tests 1086 -> 1089.
2026-11-23 14:49:35 +01:00
maj00r ca1f2239df feat(editor): the double, symmetric and secant switches, the slips and the crossings of the catalogue in the domain model
E5 (editor-tracks-domain.md §4 "Rozjazd", §7): every type of the catalogue is a turnout the model lays, its tracks lines it owns and its
legs nodes, kept whole or refused like the ordinary switches E2b laid. E2b refused the rest with "stage E5".

- Secant blades (S42): the diverging track runs along the main one for the pre-blade stretch and turns off it by the angle of the blades
  at their tips, the rest of 1:n on its arc; a turn inside the track, the node at the start keeping the heading of the main track. The
  generator ends a piece there with the heading of the element before it (unchanged where a line runs on in its heading).
- Double switches (Rpd, Rpj, Rps): the main track cut at the start of the second switch, its node holding the main track, the main track
  of the second switch (main2) and its diverging track, to the other side or the same one, as switch_design::build() lays it. Written as
  the switch tool writes them: the first switch, a plain track of a metre before the second one (the simulation joins a switch to plain
  tracks only), the second switch.
- Symmetric switches (Rls): both tracks turning off by half of the angle, to both sides, laid at a free end of a line, which they end (the
  line beyond it would have to turn at the node); not moved along the line.
- Slips (Rkp, Rkpd) and diamond crossings (Skrz): the main track a part of the line, the crossing track across its middle at the angle of
  the slip between two nodes of its own, the slip curves from the start to the end of the crossing track and, of a double slip, from its
  start to the end of the main track; slip_of() lays the curves with the blades of the ordinary switch of the rail, radius and angle (no
  data of the slips' own blades was found), passing the crossing as near as the rails of the simulator's profile let them. The three with
  the blades outside of the diamond whose curves then reach past the half length of Id-4 (49E1 190-1:6,6, 300-1:9, 500-1:9, by up to 0.3 m)
  are laid as long as their curves. Written as the switch tool writes them: a switch at each leg a slip curve leaves, the tracks crossing
  and the middles of the slip curves plain tracks, the joints inside it the same numbers on both sides.
- The rules: a double switch, a slip, a crossing (11.4 pkt 4 a, b) and a symmetric switch (no rule of table 11.8 for it) lie on straights
  only; an invariant, refused with the reason before anything is laid. The norms judge the tracks crossing at a slip or a crossing as
  crossings (no cant, tab. 9.6), its slip curves as diverging tracks.
- The ends of the tracks of a turnout which carry no line through their node (the starts of the diverging tracks, the ends of the slip
  curves) are branch_end(); a node holds such an end beside a track of the same turnout on its side. settle() lays all the tracks a turnout
  lays itself (lay_tracks()), the nodes of its own where they end; lifting, moving, changing (to another kind too) and removing a turnout
  take all of them along.
- The project file: the turnout record gets "second <node> <main2> <diverging2> <node>" and "crossing <line> <node> <node> slip <line>"
  where the turnout has them (diverging 0 0 for a crossing); version 1, unreleased, read as before without them. The generated section
  keeps each track a turnout is made of.
- TSI INF 4.2.3.4(1), 150 m at least, judges the plain line, not the curves of switches (4.2.5): its hard row leaves out the tracks of the
  turnouts, so the industrial S42 switches of R 70 and 140 m are laid.

Tests: U: every type of the catalogue laid (41 ordinary, 3 symmetric, 15 double, 18 slips, 20 crossings) on a straight to both sides
along the line and against it, its legs where the catalogue puts them (the main track a + b, 1:n at the ends, the second switch at the
stagger, the crossing track at the angle of the slip, half its length from the crossing), moved and taken out, the line one again, each a
step to undo; the turn of the secant blades of S42-190-1:7 at the end of the pre-blade stretch; a double switch, two slips and a crossing
refused in a curve, a secant S42 bent in a side track, a symmetric switch refused at the end of a curve. The three fitted to the tangents
of S42-140-1:6,6 16/12 measured are refused by the norms (tab. 9.14) where the transition one is. P: 200 random edits with every type along
arcs and transitions, seeds 5150, 2718 and 1618: the invariants after each, a refusal changing nothing, undone back to the start exactly.
G: every type made into the tracks of the simulator and read back by TTrack::Load, the ends of the paths at the legs or at each other to
the bit, the velocity and the frog; a double switch, a double slip and a crossing written to the project file and read back, their tracks
laid again the same to the bit. The E2b case of the types refused now checks that they're laid. Unit tests 1077 -> 1086.
2026-11-23 14:49:35 +01:00
maj00r e9f8b6a059 feat(editor): the catalogue of the turnouts a data file, the switch tool and the domain model reading it
The first part of E5 (editor-tracks-domain.md §7, "Katalog jako dane"): the types the editor lays its switches from were a table in
switch_design::catalogue() and two in editor_track::standard_switch_templates(); now they are editor/data/turnouts.txt, one type a
line, built into the executable as its text (CMakeLists.txt writes it out as editor_turnouts_txt.inc, as it does the icons), so the
game data doesn't need it, and read once when first needed.

- The format, which the templates of the user (eu07_switch_templates.txt) share: switch <name> <key> <value>... source <the rest>.
  A type of the catalogue gives its geometry as the instruction does (type, rail, radius, ratio, a, b, diverging, the blades tangent or
  secant, the cut tip of the blade; stagger and the keys of the second switch of a double one; middle and the half length of a slip;
  fit for the three fitted to measured tangents), the parts made of it as before; a template of the user gives its parts. What §7 asks
  besides the geometry, - where the source has nothing: the frog (fixed or movable), the locks (Id-4 tab. 14-3), the drive, the speed of
  the diverging track (ST-T1-A6 tab. 11.2), the bending (tab. 11.9), the least spacing for a crossover (tab. 11.2) and the source of the
  values, unconfirmed ones said so: the cut tips of SKMd-4 (190, 300, 500, 1200 m; 760 m the editor's own), the secant blades of S42 at
  25' and the one fitted for S42-140-1:7, the a and b of 2500-1:26,5, the slips' blades (not found), the tip of a blade with no data by the
  rule sqrt(2R 0.005) - 0.125.
- read_designs() reads the format, a line which isn't one left out with why; catalogue() the switches as before, in the same order, slips()
  the slips and the crossings, catalogue_entries() all of them, read once (secant_blade() no longer builds the catalogue at each call).
- The slip curve and slip_of() moved from editor_track to switch_design, which the domain model lays its slips with (E5); editor_track
  keeps the names.
- A template of the user with a movable nose writes frog movable, which it lost before; without one the line is what the builds before
  wrote (they leave out a template with a key they don't know). The lines they wrote read as they did.

Tests: U: every switch of the data file the same to the bit as the catalogue of the code (kept in the test as it was), the slips and the
crossings as the switch tool had them; every line read, with its source; each switch against Id-4 and ST-T1-A6: R, 1:n, a, the main
track a + b, the pre-blade stretch, the blades (the tip lead + cut where the sheets give it, about sqrt(2R 0.005) - 0.125 where they
don't; secant at 25'), the speed of tab. 11.2, the bending of tab. 11.9, the spacing of tab. 11.2; the rule of the tip against the sheets
(190 m +3 mm, 300 m +105 mm, 500 m -56 mm, 1200 m +3 mm; the 4.5 mm rule +60, +143, -44, -49 mm); a template keeping its movable nose,
an old line read as before; lines left out with why. Unit tests 1070 -> 1077.
2026-11-23 14:49:35 +01:00
maj00r ac5e735f91 feat(editor): the scenarios using a map and the tracks, events and memory cells they name in it
The last part of E3 (editor-tracks-domain.md §0 pkt 7, §3 "Indeks scenariuszy"): a change of the map mustn't take away what a
scenario relies on. Read only, from the text of the files as the simulator reads it; nothing of the editor asks it yet (E4, E7).

- The scenarios are the *.scn files of the scenery folder. A quick look at the include words of the files, each file once for all
  of them, tells which may reach the file of the map; those are read whole (sceneryText), their includes followed with the
  parameters of the templates, the terrain passed over where the scenario has its binary terrain. A scenario uses the map where the
  file of the map is among its files.
- What the map defines: the tracks, the events and the memory cells of the statements of its files. What a scenario names in it: of
  the statements outside the files of the map, the tracks the trainsets start on (anywhere, a scenario being its own map too) and
  the vehicles standing on their own; the events called by multiple events, by event launchers and by the tracks of the scenario;
  the cells and tracks acted on by the events (updatevalues, getvalues, copyvalues and its source, whois, logvalues; switch,
  trackvel, trackbuckle), checked by their conditions (memcompare, trackoccupied, trackfree) and by the launchers; the tracks of the
  scenario's cells and isolated circuits; the events named after a track of the map, <track>:event1..., which the track calls. Each
  with what names it, the file and the line. The names as the parser makes them, A to Z small.
- Not seen: the names the simulator makes (the tracks of the roads, the turntables), the scripts, the timetables, the commands the
  cells give the drivers, the random includes.

Tests: U: data/project/index, a map of tracks, events and memory cells, some from a template included with parameters at an origin,
and three scenarios: two using it (one through a file of its own) with their trainsets, vehicles, events, launchers, cells and
isolated circuits, listed in full; the trainset on a track of the scenario, the names in comments, an event of none_ and a name of
nothing left out; the scenario of another map with tracks of the same names not among them. The include tree read with the
parameters and the placements; the words split as the parser splits them.
2026-11-23 13:11:47 +01:00
maj00r f24714c6d6 feat(editor): the //$ lines of an old scenery taken into the project file when its map is first opened
Continues E3 (editor-tracks-domain.md §9 "Migracja", §10): what the //$ lines describe of the track geometry becomes the lines and the
nodes of the domain where the domain lays it as the editor laid it; the rest is kept in the project file as it was written. The lines
stay in the scenery files, untouched; the scenery files aren't written.

- //$h, an alignment: a line between two nodes at its ends, its vertices where the design puts them (from the tangents of the ends
  for one, by the offsets for the first and the last of more), their radii, transitions and cants, the shape of the transitions,
  the origin as the chainage of the start, the speed as the highest of the class; a curve going on from the adjoining track as an end
  going on from the curvature and the cant of its node. Not a compound curve, two transitions with no arc between them, cant ramps
  of its own, a curve turning the longer way, a curve going on from a switch, a design kept for a part of its line, nor one the domain
  lays to a length 5 mm off the old one: kept as it was, with why. The free ends of two lines within 0.5 mm, running on from one
  another, join at a node (a turn of the headings over 1e-9 rad told). The record is kept whole in the project with the line it
  became: the points clicked, the old norms, the pieces and the fit have no place in the domain yet.
- //$p, a grade line along such a line (its ends and length within 5 cm, either way): its breaks with their vertical curves as the
  breaks of the line, the heights of its ends as those of the nodes; not one with a break of no vertical curve, or along no line, or
  one the line can't be laid with. Kept whole too.
- //$r switches (E5), //$k the kilometrage of the railway lines (the line's own chainage is the //$h origin), //$t the tracks fitted,
  //$w the tracks sharing a grade line, //$b the objects bound to the tracks (E6, the anchors), //$s the stations (E7): no place in
  the domain yet, kept as they were, a block a kind a file. //$c, //$o, //$z, what the editor keeps of itself, aren't taken.
- The lines read as the editor reads them: the old letters of the marks under the new ones, the lines other tools put after the same
  marks (Rainsted's includes after //$r) left out. marked_files() finds the files of the map with their includes followed and the
  placement in effect at each; open_project() reads the project of the map, or makes it of the //$ lines and writes it where there's
  none.

Tests: G: the sceneries of data/records/ made into a project: the alignment of clothoids a line within a millimetre of the old design
along all of it, the one kept for a part of its line and the grade line along nothing kept with why, each other kind kept as the file
has it and read back by editor_records as from the scenery, the camera, the orthophoto and the area left; written and read back the
same. A map of data/project/migration (its tracks included at an origin) opened the first time: two alignments joined at a node in the
world, the grade line of the second one its break and the heights of its ends, the one along the first refused for a break of no
vertical curve, the compound curve kept; the scenery files byte for byte as they were; opened again, the file read and not made again.
2026-11-23 13:11:47 +01:00
maj00r c912ed2ab1 feat(editor): the tracks the generator wrote kept by their checksums, a track changed by hand marking its line
Continues E3 (editor-tracks-domain.md §9, "Ręczna zmiana wygenerowanego węzła ... wykrywana po sumie kontrolnej"): the generated
section of the project file and what the scenery files hold of it now. Nothing of the editor writes the tracks yet (E4).

- generated: a record a track the generator wrote, its name, its line, the file it's written into and the FNV-1a checksum (64 bits)
  of its text as the simulator reads it: the words joined by one blank, the comments left out, so the line ends and the blanks
  another tool writes aren't a change; the switch track of a turnout kept by the main track of the turnout.
    track l1_s11 line 1 file trasa/tory.scm sum 0123456789abcdef
    switch t1 line 2 file trasa/tory.scm sum 00000000000000ff
    hand 3
  record_generated() puts the pieces of a line, or the switch track of a turnout, in the place of the ones the project had of it;
  find_hand_changes() looks the names up in the text of the files now: a text of another checksum, or a track gone, or a file which
  can't be read; mark_hand_changes() marks their lines changed by hand (hand <line>, kept by the file), may_overwrite() tells the
  editor to leave them, until the line is written again by the editor (the author decided).
- editor/project/sceneryText: the text of the scenery files read as cParser and state_serializer read it, with no scene: the words
  (blanks and semicolons between them, // and /* */ comments, the quotes), the node of a name and its words up to the end word of its
  type, and the statements of a scenery with its includes followed relative to the scenery folder (the words of each file taken as
  they're needed, the includes no deeper than 32), the parameters of a template in place of (p1)..., the placement of origin, rotate
  and scale at each include, the terrain files passed over for a binary terrain. The scenario index and the migration read the files
  with it.

Tests: U: two lines generated into one file among other nodes: as written nothing is changed, through the project file too; the speed
of a track of the second line edited: that line and that track told, marked changed by hand once, kept by the file, the first line
not; written again, not marked. The switch track of a turnout: its speed edited marks its main track. Blanks doubled, the line ends of
windows and comments inside a track aren't a change; a track taken away, a file which can't be read are. The node of a name found by
the words.
2026-11-23 13:11:46 +01:00
maj00r 9c76001e9a feat(editor): the project file of the track geometry, one per map, of a schema of its own
The first part of E3 (editor-tracks-domain.md §9): the domain of the editor written next to the scenery, the .scn and .scm files
staying what the simulator reads. editor/project/projectFile reads and writes it, nothing else does; nothing of the editor uses it yet.

- <map>.eu07proj next to the file of the map, shared by the scenarios of the map; plain text, a line a record, the version of the
  schema on the first line. Version 1:
    eu07proj 1
    next node 9 line 8 vertex 1 turnout 3
    norms plk
    area granica ch 4 -500 0 -100 0 -100 400 -500 400
    lineprofile 91 en13803
    class 1 vmax 80 vmin 0 traffic mixed track main load 5 features 0
    node 3 at 300 101.2 0 heading 1 0 curvature 0 cant 0 grade 0.004 ends 3 1 end 1 2 start 1 4 start 1
    line 1 from 1 to 3 class 1 chainage 0 transition clothoid ramp linear continues 0 0 turnout 0 profile tsi
    vertex 2 at 0 800 radius 300 in 60 out 60 cant 40
    grade 200 101.5 5000
    end
    turnouts
    turnout 1 type Rz%2060E1-500-1:12 hand 1 direction 1 start 3 main 2 4 diverging 4 5 chainage 300 radii 0 500 cant 0
      speeds 80 60 velocity -60 movable 0
    end
    anchors ... end                      kept for E6 as read, empty in version 1
    generated ... end                    the tracks the generator wrote (the next commit)
    legacy h trasa/tory.scm line 1 [why ...] / | <the //$ line> / end    the //$ lines read when the map was first opened
  The profile of the scenery, the areas and the lines by name; the classes of the lines, each one once, the lines naming theirs; the
  nodes with all they hold, the ends in their order; the lines with their vertices, grade breaks, shapes, chainage, turnout and
  profile of their own; the turnouts of E2b with their legs, their tracks and what they derive. Numbers in the shortest form which
  reads back to the same double, names and files with %20 for a blank.
- Read: the lines laid between their nodes as read, then the diverging tracks laid by their turnouts off the main tracks, the nodes
  and the turnouts as written; what refers to what checked (a line's ends held once by its nodes, the classes there, the turnouts and
  their tracks each of the other); a file of a newer schema refused before anything of it is read, with the reason, as is one which
  isn't a project file, has a record not of its version or a section not ended. Saved through a file next to it put in its place.
- The identifiers handed out are kept (next), so none is handed out again after a load, whatever was deleted before the save:
  layout::network gets handed() and hand_out(), the turnouts' counter with them; nothing else of editor/layout changes.

Tests: G: a network edited by the model (a line deleted between two) written, read and written again: the same text, the lines laid
again the same to the bit as the model laid them; two turnouts, one against the line, and a line of a profile of its own: the same to
the bit, the diverging tracks too (the network as settle() leaves it: the model lays the diverging track of a turnout against the line
before the node at its start takes the grade of the line beyond it, 1e-16 off); the golden file of data/project/ read and written back
the same, with the line ends of windows too; the anchors kept as read. A newer schema, an empty file, not a project file, broken
records (a turnout whose track isn't its among them) refused cleanly. U: the identifiers after the last line is deleted, a save and
a load: the next line, its nodes and its vertices numbered past them.
2026-11-23 13:11:45 +01:00
maj00r b0f7744434 feat(editor): the switch tracks of the simulator made of the turnouts of the track geometry, the legs at their nodes to the bit
The generator (editor-tracks-domain.md §5, "Rozjazdy") makes a turnout one switch track entry TTrack::Load reads: the paths of its main
and its diverging track, each from the start of the turnout.

- Each path the pieces of its line as the generator cuts any line (within 0.5 mm of the elements, the rolls and the heights from the
  line), turned round where the main track runs against the turnout, written as pieces1/pieces2; the path itself the curve between
  their ends and headings for the versions which know only the path, or the one piece where one makes it. The ends of both paths are
  the numbers of the nodes of the legs, so the tracks on the other side of them meet them to the bit.
- velocity as the speed rule gives it (the main limit for both where it's the lower, else the diverging one below 0), frogs, the
  movable nose and the blades of the type where it has them; the name <turnout_prefix><turnout>, t by default.
- A track of a turnout isn't made as a line of its own; generate_all() makes the lines, then the turnouts.

Tests (G): turnouts on a straight with a grade (a 1:12 to the left along the line, a 1:9 to the right against it, a 1:26.5 with a
movable nose) and one bent outward into R 1200 m with 60 mm, written and read back: both paths from the start node, the main one to
the end of the main track, the diverging one to its end, to the bit; the pieces as written, joined to the bit, each within 0.5 mm of
its line both ways (the farthest 6e-6 mm: short arcs of one Bezier curve each); the radius of the bent diverging curve; the velocity,
the movable nose and the frogs read back; the tracks of the lines on the other side of the legs ending there with the same numbers and
rolls (of the other sign where they meet head on). The diverging track of Rz 60E1-2500-1:26,5 as the simulator draws it within the chord
offsets of Id-4 (30 m chords, 41 to 49 mm in the middle): 45.0 mm all along, 130 km/h on it.

Left for E5: the catalogue as a data file (now switch_design::catalogue() in code), the double, symmetric and secant switches, the bending
exact everywhere (now table 11.8 for the curve of the basic switch, the rest of the diverging track bent with the main one, a main track
on a transition taken at its mean curvature), the connection solver (crossovers, the spacing measured along).
2026-11-23 12:41:49 +01:00
maj00r 6f0b8be091 feat(editor): the edits E2a left: vertices, the grade line, the class and the profile of a line, a join from a curve, no new BLOCK
The rest of the list E2a left for E2b (editor-tracks-domain.md §8), commands of the domain model of the track geometry like the others:
kept whole or refused with the reasons, one step to undo.

- insert_vertex (after a vertex, or after the start, with its radius, transitions and cant, its id given) and remove_vertex.
- set_grades: the breaks of the grade line with their heights and vertical radii; checked by the solver (overlapping vertical curves)
  and the norms.
- set_line_class and set_line_profile: the class of a line (its speed, traffic, main or side track) and a profile of the norms of its
  own (the line's own wins over the areas, as norms::area_map has it); a chain of the norms doesn't run on into a line of another
  profile of its own. The tracks of a turnout take a class too, their speeds derived again.
- join_ends from a free end in a curve (a line cut inside one): one curve where the tangents meet, going on from the curve at the end,
  its arc of the radius there with no transition (or, where that doesn't fit, a radius the norms prefer and a transition from the
  curvature of the end), the transition at the straight end as long as makes the curve begin right at the curved end (bisected to the
  bit), refused where both ends lie in curves or the curve would turn the other way. The original join and this one lay the new line
  the same way (add_joined).
- edit_policy::no_new_block for old tracks (stage E6): an edit is refused by a BLOCK finding only where it adds one; one there before,
  of the same parameter on the same stretch (the elements within 1.5 m, the findings carry their element as points of the plan) and no
  worse, doesn't refuse; the same rule of the same turnout neither. The invariants refuse in any case. model(network) takes a network
  over as it is, the norms not asked.

Tests: U: a vertex put in and another after it, both taken out, the line as it was; a grade break and its vertical curve, two
overlapping and one of no radius refused; a class of 200 km/h refused on curves fine at 80, one of 60 kept; R 280 m at 80 km/h warned
by PLK, not by the TSI as the line's own profile; a line joined to a free end in an arc going on from it with the transition the part
taken away had, the track the same within a micrometre; both ends in curves refused; R 170 m laid by the TSI and judged by PLK: an
edit refused when any BLOCK refuses, kept with no_new_block, a sharper curve and a cant past (R - 50) / 1.5 refused, a wider curve
kept. P: 250 random edits of an old track breaking the norms (curves laid for 80 km/h judged at 120), seed 4242, with no_new_block: no
BLOCK finding over all the network which wasn't there before, a refusal changing nothing, an undo exact; the random edits with
turnouts put vertices into straight lines and take them out.
2026-11-23 12:41:49 +01:00
maj00r 4a3b36c204 feat(editor): the turnouts of the track geometry, laid into a line, moved, changed and taken out, their legs nodes
E2b (editor-tracks-domain.md §2, §4 "Rozjazd", §7, §8): a turnout is an aggregate of the domain model, laid from the catalogue the
editor lays its switches from, its rules invariants which refuse.

- layoutTurnout: the type of the catalogue (switch_design::catalogue(), Id-4) as the model lays it: R, 1:n, a, b, the main length,
  the lead and the parts of the diverging track, the movable nose, the blades; the ordinary switches whose diverging track leaves
  tangentially, the double, symmetric and secant ones refused with the reason (E5). The diverging track laid off the start along the
  turnout: on a straight the curve of the type; bent with the main track the curve of the basic switch of the radius of table 11.8
  (switch_curve::bent_radius), over the length which keeps its turn off the main track, so the angle of the frog stays 1:n, the lead
  and the straight through the frog bent along with the main track; the cant of the main track all along it, the grade of its start.
  The speeds: the diverging one by switch_curve::branch_speed (the rule the editor writes), the main one the line's, bent no faster
  than the deficiency of the frog lets it; the velocity written by the same rule as the editor's.
- The turnout: its type, hand, direction along the line, its start, the ends of its two tracks (nodes), its main and diverging track
  (lines it owns), derived: the kilometrage of its start, the bending, the cant, the speeds. The network keeps the turnouts with the
  lines and the nodes, in the snapshots of undo and in the transactions; settle() has a turnout whose main track or start changed
  lay its diverging track again, move the node at its end and lay again the lines going on from there.
- The nodes: three ends at the start of a turnout, its two tracks on one side of it; the start of a diverging track tells its node
  nothing (the node keeps the curvature of the main track) and runs on into no line, the end of one sets its node.
- check(): the turnouts whose tracks or legs are touched, their invariants (the legs, the tracks, the main track as long as the type)
  and the rules of Q2 and 11.4 through switch_curve::check (the curvature of each track of one sign, KZW II refused; the cant the same
  over it; the ends of the ramps at its ends or 6 m off it), a switch of 1:9.403 or steeper than 1:9 bent in a main track refused (the
  model knows a main track from a side one, where the editor only warns), table 11.9 and a transition under it as warnings. The norms
  of the E1 module with the switch context: the elements of a turnout track are a connection of tracks of their frog (fixed or movable
  nose: the deficiency of tab. 9.7), bent or not (the cant of tab. 9.6), at its speeds; the chain of the line runs through the main
  track, the element cut by a turnout open. BLOCK findings are kept apart from the broken invariants (verdict::blocks).
- The commands: insert a turnout at a chainage of a line (cut at its legs, the part between them its main track), move it along its
  line (the lines on both sides and its main track one line again, cut anew, the ids kept, a line going on from the end of its
  diverging track carried with it), change its type or hand, remove it (the line one again where it can be: the merge laid and kept
  only where it's the same track within a micrometre). The tracks of a turnout aren't split, deleted or edited as lines; a line is joined
  to the free side of a turnout's start, or to the end of its diverging track from a straight (the curvature stepping there).

Tests: U: the types laid and refused; the legs on a straight against the catalogue for four types both hands both ways (the main
track a + b, the tangent of the diverging end meeting the main track at R tan(a/2), Id-4's a within half a millimetre, the angle 1:n,
the speeds of table 11.2); Rz 60E1-500-1:12 bent outward and inward into R 1200 m with 60 mm (r" 857.8 m and 352.7 m, 60 km/h, the
angle of the frog kept, the cant over it); refusals: KZW II, a ramp under it and 3 m off it, a 1:7.5 bent in a main track (laid in a
side track), no type, no hand, no room; moved, changed, turned, taken out with the line laid again within a micrometre, each a step
to undo; a line from the diverging end carried along. P: 250 random edits with turnouts each, seeds 20261124, 31 and 977 (laid,
moved, changed, taken out, with vertices moved and set, splits, joins, deletions, undo, redo): the invariants after each (the legs
and the nodes whole, three ends only at a start, the velocity by the rule), no BLOCK, a refusal changing nothing, an undo exact.
2026-11-23 12:41:49 +01:00
maj00r 31dc959cec feat(editor): the speed of the diverging track of a switch, one rule for the editor and the domain model
The formula Q2 gave the editor (editor_mode::branch_speed_of) taken out into a pure function of the switch curve module, which the
domain model of the track geometry (editor/layout, E2b) calls for its turnouts too, so the two write the same speed.

- switch_curve::branch_speed(): of the basic switch of R and 1:n, its main track bent by table 11.8, the cant with its sign toward
  the side the diverging track leaves to: formula 9.9 with the normal deficiency of the frog (table 9.7), rounded down to the steps of
  the speed limits, no more than table 11.2 gives the basic switch. It reports the radius, the cant into the turn, the deficiency, the
  formula, the rounded speed and the table, which the editor's message tells.
- switch_curve::basic_speed(): table 11.2, moved from editor_track::diverging_speed(), which now returns it.
- switch_curve::written_velocity(): the one velocity a switch keeps, the main limit for both where it's the lower, else the
  diverging one below 0; write_switch_speed() calls it.
- speed_check::suggested() inline in editorSpeed.hpp, so the switch curve module takes it in the unit tests, which don't build the
  checks of the speed.

The editor computes the same numbers the same way: the basic radius and the bent main radius as before (bent only where the type is
known), the cant toward the diverging side the same product, its sign flipped by the bent radius as before (a multiplication by -1,
exact), then the same calls in the same order. tests/unit/test_switch_curve.cpp unchanged and passing.

Tests (U): the examples of Q2 through branch_speed (Rz 60E1-500-1:12 outward in R 1200 m with 60 mm 60 km/h, inward 60 by the table;
Rz 60E1-190-1:9 in R 600 m with 60 mm 30 and 40 km/h), the table of the basic switches, a movable nose kept to 130 km/h, a diverging
track bent straight, the editor's table the same, the velocity written.
2026-11-23 12:41:49 +01:00
maj00r e53fbcfe55 feat(editor): the tracks of the simulator made of the lines of the track geometry, within half a millimetre
The last part of E2a (editor-tracks-domain.md §3 and §5): the generator, the layer between the domain and the simulator. A line is
cut into cubic Bezier pieces, each one a track entry of the text TTrack::Load reads. Nothing of the editor writes them yet.

- The pieces end at the elements, at the ends of the vertical curves and of the cant ramps; each one halved until the curve as the
  simulator draws it lies within 0.5 mm of the line, in the plan and in the height, and its cant within 2 mm of the line where the
  simulator turns the roll evenly; none longer than a track may be (400 m), none shorter than 10 cm. The handles of an arc are its
  own, 4/3 tan(turn / 4) R; a transition takes the handles which give the curve the curvatures of the line at its ends (G2 Hermite,
  by Newton's method, those of an arc where it finds none near them); a cubic parabola is the cubic Bezier curve it is, cut by its
  blossom; a straight of an even grade has no control vectors, as the simulator draws it. A piece TTrack would take for a straight
  (its 2 cm check of the control vector) is one, close enough or halved.
- The rolls and the heights come from the functions of the line, the radius from the element: an arc's own, the sharpest over a
  transition, 0 on a straight. A piece ends at a node with the numbers of the node, its place, its heading and its cant, so the
  tracks on both sides of it have the same numbers to the bit; the numbers are written in the shortest form which reads back to the
  same double.
- The names come from the identifiers: <prefix><line>_<element><piece>, the element the straight leading to a vertex (s7, se to
  the end) or the transition in, the arc or the transition out of a vertex (v7i, v7a, v7o); a change of a curve leaves the names of
  the pieces of the others.
- The joints of old tracks as hard points of the pieces, keeping their names and events, are E6 (§10): generator_options has their
  place, a line given any is refused rather than made without them.

Tests: the pieces of lines of clothoids, Bloss curves and cubic parabolas, of R 190 m and of 5 km with vertical curves, each
measured both ways (the points of the curve set square onto the line, and the points of the line against the nearest of the curve,
searched on its own): within 1 mm, the farthest 0.35 mm (0.45 mm with Bloss curves). G: a line split on a straight and in an arc,
its tracks written and read back by TTrack::Load (the E0 seam): the ends at the nodes and between the pieces the same to the bit on
both sides, the rolls and the headings of the control vectors too, the curve within 1 mm of the line, the radius of the element;
a line laid the other way through its nodes; the names unique and kept by a change of another curve; the E6 hook refusing.
2026-11-23 11:30:25 +01:00
maj00r 555b77b11d feat(editor): the nodes of the track geometry and the commands editing the lines, kept whole or refused, one step to undo
Continues E2 (editor-tracks-domain.md §4 "Edycja = polecenie", §8): the lines meet at nodes, and every edit is a command which
proposes a new state, has what depends on it laid again, is checked and kept, or refused with its reasons and nothing changed.

- layoutNetwork: the node, its place (the only coordinates of the ends of the lines), the heading, the curvature, the cant and the
  grade, and the ends of the lines meeting there, each with its sense along the heading; the network of the nodes and the lines
  with the profiles of the norms by place and the identifiers handed out once, never again (an undone line made again is a new one).
  A transaction keeps each line and node the first time it touches it, so a change is rolled back whole or recorded.
- settle(): the lines touched laid again; the nodes take the values of their ends (a free end follows its line, a node keeps the
  curvature and the cant a line going on from it reads), a line going on from a node whose curve changed is laid again.
- check(): the invariants of the touched lines and nodes: laid, at their nodes, two ends at most on the two sides of a node (more
  is a turnout, E5), the heading the same within 1e-9 rad, the cant within 0.5 mm, the grade within the 2 per mille that needs no
  rounding; and the norms along the chains through the touched lines (the lines running on through the nodes as one line, the
  elements running on alike across a node as one, a jump of the curvature at a node a step of the deficiency the profile judges):
  BLOCK refuses, WARN and PREFER are told as notices.
- layoutCommands: create a line between two new nodes; move a vertex; set its radius, transitions or cant; split a line at a
  chainage (the track kept as it was: on a straight, in an arc, in a clothoid with a straight ramp, the parts going on from the new
  node at its curvature and cant; refused inside a vertical curve and inside a Bloss or cubic parabola transition); join two free
  ends with a line solved between them (a straight, a curve where the tangents meet, or two curves, the largest radius which fits
  with the cant and the transitions the norms prefer, a grade line meeting the grades of the ends); delete a line (a node left with
  no end goes). The model keeps the network and the steps: undo and redo restore the snapshots of the lines and nodes a command
  touched, one step a command.

Tests: the cases of each command, a refusal (a radius under the least, a cant over the greatest, curves overlapping, transitions
too long) leaving the state as it was, a WARN radius kept with its notice, undo and redo, the track the same along a line split on a
straight, in an arc and in a clothoid, a middle part deleted and joined again both ways round, a straight joining two ends on one
straight. P: 300 random edits each with the seeds 20261123, 7 and 450 (moved vertices, new radii, transitions and cants, splits,
joins, deletions, undo, redo): after each the invariants checked on their own (each element running on from the last, the cant
running on, the ends of the lines at their nodes to the bit, the heading, the cant and the grade running on through the nodes) and
no BLOCK along any chain; a refused command leaves the state as it was, an undo gives the state before the command.
2026-11-23 11:30:24 +01:00
maj00r f83afa8a96 feat(editor): the elements and the line of the track geometry, a module of their own
The first part of E2 (editor-tracks-domain.md §2 - §4): the geometry of a line computed in one place, editor/layout, standing on its
own with no scene, no tracks and no user interface. Nothing of the editor uses it yet; the route design keeps its own solver.

- layoutElements: the elements of a line, the straight, the arc, the clothoid (the curvature changing evenly, from any curvature to
  any other), the Bloss curve (3t^2 - 2t^3) and the cubic parabola (y = x^3 / 6RL by the abscissa, the length along it its own):
  the length, the curvature along, the point and the heading at a distance, a point offset from the axis, the shift of the arc. The
  local forms of the clothoid and the cubic parabola and the blossom of a Bezier curve are the ones of editorAlignment.cpp, moved
  here word for word; the alignment calls them, so the two agree to the bit and its tests run as before.
- layoutLine: the line as a tangent polygon between the points of its two end nodes (it has no coordinates of its own there), its
  vertices with the radius, the transitions in and out and the cant, a grade line of breaks with their vertical curves, the shape of
  the transitions and of the cant ramps (linear or Bloss). solve() lays it: each curve fitted in the frame of its tangent point
  from its deflection (the arc what the transitions leave of it), the straights what the tangents leave of the sides, every element
  placed from the polygon so nothing drifts; the cant held along the arcs, ramped along the transitions, a step refused; the heights
  and the grades by the breaks. An end can go on from the curvature and the cant its node holds (a line split inside a curve):
  its curve begins right at the node. What can't be laid is an error with the vertex and the metres: curves overlapping, a curve
  starting before the start, transitions turning more than the tangents, a cant step, a vertical curve past the end.
- described(): the line as the norms module reads it (elements, cant points, grade elements), a Bloss ramp seen by eight points
  so its steeper middle counts. preferred_curve(): the cant and the transition length the profile prefers for a radius at the line
  class, the deficiency, the excess and the greatest cant of PREFER, else of WARN, the transitions long enough for dD/ds, dD/dt
  and dI/dt.
- norms::line_class compares by its values (operator==), the line keeping it compares whole.

Tests (U): the clothoid, the cubic parabola, the Bloss curve and the arc against the series of the textbooks (the end point, the
length of the parabola, the shift: L^2/24R and L^2/40R), the point as the integral of the heading, the circles alongside an arc, the
curve of a vertex by its tangent length (R + p) tan(a/2) + x_m.
2026-11-23 11:30:12 +01:00
maj00r 38f90387c4 feat(editor): the norms checked on the tracks laid, read only: a Norms tab of the track analysis and its report
The second half of E1: what the tracks of a scenery are against a profile of the norms, listed. Nothing of the tracks is changed.

- editor/editorNormsReport: a line of paths sampled a metre apart, two samples at each joint, into what the norms read a line
  from: the plan, the curvature signed by the turn, the cant on the base of 1500 mm (as the simulator takes the rolls) signed by
  the side it leans to as the line runs, the grade, the speed of each path (a switch's for its diverging track alone too), and
  what the path is a part of (a switch, its diverging track, a curved switch, a movable frog, a crossing). The line described,
  checked, and each finding set back on its path with a point of it; its message, "cant ramp 3.00 mm/m, PLK allows at most 2.50 mm/m
  (tab. 9.12)", "break of the grade with no vertical curve, PLK asks for a radius of at least 2500 m (tab. 10.2)", through STR_C;
  the text of the report: the class, the elements, the cant, the grade line and the findings of each line.
- The Norms tab of the track window, under More beside Speed and Joints, no key; its window is ###trackanalysis, as theirs. The
  line through the selected path (run_route, as the speed check walks it) or the whole scenery: the lines through the plain tracks,
  then each path of a switch none of them ran along, checked with the line it lies in and its own findings kept, a place two lines
  run through listed once. The profile (PLK by default) and the class of the line folded under a line saying it: the line speed for
  the tracks with none of their own (on by default: the speed of each track), the slow trains (tab. 8.1 by default), the traffic,
  main track or siding, the load, at a platform. The results in the table of the speed check and the joints, the worst first,
  coloured by the tier, the values above the recommended ones on a tick; a click on a row shows the place, the hard limits and the
  warnings are marked in the view. The icon is drawn into its own cell of editor_icons.png only (the generator has it): the sheet
  drawn again with this Pillow differs in other cells.
- Self-test: normsreport <file> [scope] [plk|tsi|en|ch] [km/h] writes the report to the file; expect findings <tier> <least> <most>;
  the case e1_norms_report checks the curves k0..k3 of the fixture at 60 km/h against PLK and the whole scenery against the TSI.
- Golden: data/norms/line.scn, a line of 14 tracks written by make_line.py there (curves with and without transitions, cant on and
  off a curve and along a straight, reverse curves 10 m apart, short straights, a grade with breaks), and its report against the
  four profiles in data/norms/line_report.txt; EU07_UNIT_TESTS_UPDATE_GOLDEN=1 writes it anew. A test lays a canted corner with the
  alignment of the editor and finds the samples leaning into it, both turns and run both ways, I = Deq - D.

alignment::limits stays as the laying tools use it. Where its values differ from PLK P0:
- unbalanced 0.6 m/s2 is I 92 mm on the 1500 mm base; P0 110 mm (P1 130) on the running lines, 80 on the sidings;
- ramp_factor 10, a ramp of 1:(10 V), 1 mm/m at 100 km/h and 2.5 mm/m at 40 km/h, has no counterpart: P0 1.6 mm/m at any speed;
- jerk 0.3 m/s3 is dI/dt 46 mm/s; P0 55 mm/s;
- vertical_factor 0.4 V^2 and vertical_min 2000 m; P0 max(0.77 V^2, 5000 m) (P1 max(0.35 V^2, 5000), P2 max(0.25 V^2, 2000));
- arc_min 20 m and arc_min_factor 0.4 V; P0 max(0.35 V, 30 m) up to 120 km/h, 0.40 V up to 200 km/h, also for the straights, where
  tangent_min_time is 0;
- the same: cant_max 150 mm (P0 = P1 = P2 on ballast), cant_rate 35 mm/s (P0 of tab. 9.13), the base of 1500 mm.
2026-11-23 10:28:27 +01:00
maj00r db5a171ccd feat(editor): the norms of the track geometry, a module of their own: the profiles as tables, one engine
Stage E1 of editor-tracks-domain.md (§3, §6): the norms stand on their own in editor/norms, with no scene, no tracks and no user
interface, so they are tested whole in tests/unit. Nothing of the editor uses them yet but the report of the next commit;
alignment::limits stays as the laying tools use it.

- The profiles are tables of rows (normsTables.cpp). A row holds the limits of PREFER / WARN / BLOCK of one parameter where its
  conditions hold (a band of the speed, of the radius or of the load, main or side track, the traffic, a switch and its frog, a
  crossing, an expansion device, a platform, a station track, ballastless track, crest or sag), with the table or the paragraph of
  its document. Where several rows hold the strictest limit of each tier counts. A cell can be unconfirmed: it warns, never blocks.
  - PLK, ST-T1-A6 v1.0: P0 PREFER, P1 WARN, P2 BLOCK; tab. 8.1, 9.1, 9.2, 9.6 - 9.8, 9.10, 9.12 - 9.16, 10.1, 10.2, formula 9.8.
  - TSI only, Reg. 1299/2014 consolidated 28.9.2023: BLOCK; 4.2.3.3 - 4.2.3.5, 4.2.4.2 - 4.2.4.4.
  - EN 13803-1:2010 5.2.1 - 5.2.5: normal WARN, exceptional BLOCK.
  - CH, AB-EBV AB 17 (Normalspur, 1.7.2024): Grenzwert im Normalfall WARN, maximaler Grenzwert BLOCK.
  - In every profile the global hard limits of §6.3: the TSI rows and the cant gradient of 2.5 mm/m (EN 13803-1 5.2.5, the twist).
- The line class: Vmax, Vmin of the slow trains (by tab. 8.1 when not given), passenger / mixed / freight, main or side track,
  the load, and what holds along the line (platform, station, ballastless, suburban, tilting).
- One engine (normsEngine.cpp) over a line of elements (straights, transitions, arcs, the curvature changing evenly along each),
  its cant (points, a step being two at one chainage) and its grade line: I at Vmax and E at Vmin; dI/dt along the transitions
  and the ramps; ΔI at every jump of the curvature or of the cant, the jumps closer than the intermediate length of the profile
  (tab. 9.16) taken together while the deficiency keeps changing one way (9.11 pkt 8 - 13); dD/ds and dD/dt along the ramps, a
  step of the cant as its twist on the 5 m base; the lengths of the straights, arcs and transitions and the shift of the arc; R;
  D with (R - 50) / 1.5 and the least cant; Rv and the breaks of the grade over 2 per mille; the held grades. A finding names the
  parameter, the value, the limit, the tier, the profile, the source, confirmed or not, hard or not, and the chainage. The module
  makes no text, its users write the messages.
- Areas (§6.4): the default profile of the scenery, areas outlined in the plan, lines by name (a line's own wins). An element with
  its ends under two profiles is checked against both, the worse kept (the stricter one); an arc across a boundary is a warning.
- describe() reads a line from samples along it (the curvature, the cant and the grade simplified by Douglas and Peucker), with a
  precision of 0.2 % for the values measured on it.
- The formulas of ST-T1-A6 9.1 - 9.10: Deq, Dreg, I, E, Dmin, Dmax, Rmin, V.

The sources, and what they gave:
- The cells of ST-T1-A6 spanning two or three columns (tab. 9.1, 9.6, 9.7, 9.13 - 9.15, 10.1, 10.2; §6.5 pkt 4) were read on the
  pages of the PDF. Tab. 9.15 has for the connections of tracks P0 = P1 = 80 mm at 100 < V <= 160 and 60 mm at 160 < V <= 200,
  P2 160 - 0.35 V; the table of §6.2 has P1 = 160 - 0.35 V there. Tab. 9.1 has P1 = P0 (one cell), not "-".
- TSI tab. 8 (§6.5 pkt 3): the 153 mm spans both columns up to 300 km/h, 100 mm only above 300 km/h.
- Unconfirmed, warning only: tab. 9.8, 5 < q <= 10, P0 95 mm, and tab. 9.7, movable frog 230 < V <= 250, P2 110 mm (as printed,
  out of line with the rows around them); EN 13803-2:2006+A1:2009 7.1.3, ΔI of the plain line 50 / 40 / 30 mm, read from a garbled
  preview.
- Not there: ST-T1-A6 tab. 9.4 (a picture); EN 13803-1 dD/dt, dI/dt, ΔI in S&C, element lengths, Rv and grades (beyond the part of
  the standard published as its preview); AB-EBV a limit of the grade of a line, the least cant, the table of the buffer locking of
  5.4.2; the TSI has no dD/ds, dD/dt nor dI/dt. DB (Ril 800.0110) is left out: it isn't published, its values are known from
  secondary sources only.
- Simplified: the (R - 50) / 1.5 of the TSI holds for every R < 305 m of mixed and freight traffic, leaving out its condition of
  a ramp steeper than 1 mm/m; the intermediate element of tab. 9.16 between transitions is the one of tab. 9.1 at P2 (tab. 9.10 at
  P2 would do there); a switch has a fixed frog unless the track says it moves; the track is ballasted unless the class says not.

Tests: test_norms_tables.cpp, every value of the PLK tables and of the TSI with its table in the name of the test, the edges of the
bands (a speed on the boundary, R 300, 250 and 200 m), some of EN and AB-EBV; test_norms_engine.cpp, the examples of ST-T1-A6
(Z1-1, Z1-2, załącznik 2, the ramps of Z3-2 and Z3-3), I at Vmax and E at Vmin, ΔI of arcs turning alike and the other way, taken
together over a short straight or not, dD/ds, dD/dt, a step of the cant, dI/dt, the lengths, the vertical curves, the areas and the
boundary, describe().
2026-11-23 10:25:52 +01:00
maj00r e27d3b7e73 test(editor): golden round trips of the tracks and of the //$ lines, the cant at the joints
The safety net of the track editor before its domain model changes (E0 of
editor-tracks-tests.md): what the editor reads from the scenery files and
writes back is read, written and read again in tests/unit, with no game data.

Tracks (test_track_text.cpp, data/tracks/). Entries written the way the game
writes them, read by TTrack::Load() and written by export_as_text(), come out
byte for byte the same, and read again give the same track field by field:
plain tracks with all their attributes (events, speed, isolated, overhead,
vradius, rail profile, friction cell), a curve with cant, radius, uneven,
buckle, cwr and sleeper models, a bridge, switches with trackbed, frogs,
movable nose, blades, uneven of both paths and timbers, a turntable, paths of
pieces, the speeds +40, -40, 0.5, 0 and none of tracks, switches and
turntables, a river, a tributary, a road and a crossing. What the game writes
otherwise than given is checked as it is (table as turn, mountain as
mountains, the length of the path, a switch heard from 10 m, the events in
order, names in lower case, model paths with forward slashes, the texture
length, rolls as floats, no overhead and no vradius left out).

The seam: TTrack built from text with no scene. The engine stubs of the tests
had none of it, so the tests link the few sources reading and writing a track
takes (world/Track.cpp, Segment.cpp, TrackUneven.cpp, MemCell.cpp,
scene/scenenode.cpp, utilities/Timer.cpp, rendering/geometrybank.cpp) and
track_stubs.cpp stands in for the rest: a renderer keeping the materials by
their names, and the scene, events, vehicles and the geometry of the rails,
which reading and writing never reach and which stop the test with their name
if one does. It tests the game's own Load() and export, where a parser of its
own would have meant rewriting Load(), and changes no code of the game. The
stub of basic_node::radius_() goes, scenenode.cpp brings the real one. The
rails don't buckle in the tests (TrackBuckle.cpp needs the environment), the
buckle declared is read and written either way; material names go through a
stand-in, the game's material manager isn't tested here.

The //$ lines (test_editor_records.cpp, data/records/). Their readers and
writers were members of editor_mode, srk_tool and the stores, with the scene
around them; they move as they were into editor/editorRecords.cpp, the one
place each kind is read and written, which the stores call (and which the
migration to the project file of E3 will need apart anyway). The methods of
scene::layer_context move into scene/scenelayercontext.cpp so it links alone.
Each kind, h r k p t w b s c o z, read from golden lines and written back comes
out the same, in the coordinates of the file and of a file placed at an
origin; //$e, the descriptions of the templates, read and saved by
editor_includes in a template in a scratch folder, leaves the file as it was.

Cant (test_cant.cpp). The paths an alignment lays roll by asin(cant/gauge),
signed with the turn, back to the cant of the line at every end; a curve the
other way rolls the other way. At a joint editor_track::match_rolls() gives
the joined track the roll for the travel across it, turned where the paths
face or stand back to back, and the track written keeps it. The inspector's
own conversion on 1500 mm stays in its lambdas here; named, as
editor_mode::cant_of_roll()/roll_of_cant(), it comes with the quick fixes.

Known bugs found, tests of the change each (doctest::should_fail, passing
until fixed, then reported to drop the decorator), data/tracks/known_lost.scn:
- angle1/angle2 are read and dropped: not written back.
- fouling1/fouling2 are read and dropped: not written back.
- name@circuit: the circuit is taken out of the name with the letter before
  the @ ("tor1@iso1" becomes track "tor"; substr(0, i - 1)).
- the attributes of the entry (gauge, friction, texture sizes, speed...) are
  written to 6 significant digits, a float has 9: more digits are lost on the
  first save.
None in the //$ lines.

Unit tests: 957 cases before, 974 after, all passing.
2026-11-23 09:10:30 +01:00
maj00r c7afa3ca10 fix(editor): a switch laid gets the speed of its diverging track, one breaking a hard rule of ST-T1-A6 isn't laid
- Every switch laid writes the speed of its diverging track (`velocity`): the switch tool on a
  straight, into a curve, from a free end and linked, a double switch, the switches of a slip, a
  switch given another template of the catalogue, and a switch moved along the curve it's bent
  into. A switch of the catalogue had no limit before, one copied from a switch of the scenery kept
  that one's, one laid without a track had the laying speed on both its tracks. The limit is for the
  diverging track alone (`velocity -V`); the own limit of the track it goes into stays for both
  where it's the lower. The switch tool says the speed and what gives it.
- The speed is formula 9.9 of PKP PLK ST-T1-A6 the other way round, V = sqrt((I + D) r / 11.8), with
  the normal cant deficiency of the frog of table 9.7 (110 mm a fixed frog, 130 mm a movable nose),
  rounded down to the steps of the speed limits and no more than table 11.2 gives the basic switch.
  For the fixed frogs the formula gives table 11.2 itself (190 40, 300 50, 500 60, 760 80, 1200
  100 km/h); the 2500-1:26.5 with a movable nose stays 130. A switch bent into a curve takes the
  radius of its diverging track from table 11.8 (one-sided r" = (Rr - t^2)/(R + r), two-sided
  (Rr + t^2)/(R - r)) and the cant of the line with its sign: leaning against the diverging track it
  takes speed away, where the speed check counted it as helping. Rz 60E1-190-1:9 bent out of the
  curve R 600 m with 60 mm: 30 km/h, not 40; the 60E1-500-1:12 of the review, out of R 1200 m with
  60 mm: 60 km/h at its fixed frog (54 at I = 100 mm, the 0.65 m/s2 the editor took), not 107.
- A switch breaking a hard rule isn't laid, the tracks left as they were, and the switch tool says
  why, with the value, the limit and the paragraph: the cant changing within it (11.4 pkt 7), a cant
  ramp ending within it or nearer than 6 m (9.6 pkt 16-17; one ending right at an end of the switch
  is let be, as the snapping of the start offers it), a double switch, a slip or a crossing bent
  (11.4 pkt 4), the curvature of its diverging or its main track turning from one side to the other
  (9.7 pkt 12, KZW II). They were warnings shown after the switch was laid, and on a straight the
  cant wasn't looked at at all. The line is looked at 10 m past the ends of the curve or the
  straight too, so the ramp on the straight before a curve counts. The previews show the refusals.
- A switch moved along its straight or the curve it's bent into, a double switch moved along its
  straight, and a switch given another template go through the same checks; one breaking a rule
  stays as it is.
- Warnings still: 1:9.403 and steeper than 1:9 bent (11.4 pkt 4c-d), a rule of the running and the
  main tracks, which the editor doesn't tell from the side ones, as the warning now says; the limits
  of table 11.9 and a cant over 100 mm in a bent switch (table 9.6), as before.

Tests: unit tests of tables 11.8 and 11.9 (the least main radius bends the diverging track to the
least radius the table gives), table 9.7, the speeds of table 11.2 by formula 9.9, the speed of a
bent switch with the cant with its sign (the example of the review), the cant over a switch on a
straight and a double switch bent. Editor cases `q2_1_switch_speed`, `q2_2_switch_refusals` and
`q2_3_switch_move`, with `expect status` (the status of the switch tool) and `expect steps` (the
undo steps), the fixture with a straight taking a cant on and a compound curve without cant. All
pass; with the changes of the editor reverted all three fail.
2026-11-23 09:09:01 +01:00
maj00r c813c03865 fix(editor): track edits keep the joints, the norms, the records and the saved speed together
- The cant typed in the inspector goes on into the track joined at that end, as the gizmo and the
  joints tool do it; the neighbours go into the same undo step. The joint stepped before.
- A track laid on from a canted joint takes the cant off along the ramp the norms ask for at the
  speed (`alignment::cant_ramp_length`), not at a fixed 1.5 mm a metre whatever the speed and the
  norms: 120 mm at 100 km/h over 120 m, not 80 m.
- Deleting a track of the line under the route tool keeps the laying norms. They went back to the
  defaults, and every later lay, extend and join used those.
- The gauge is a paste group of its own, off by default: pasting how a track rides or sounds no
  longer changes its gauge.
- The speed of a turntable set in the editor is the one saved. The editor changed the speed the
  turntable runs at, while the file keeps the limit it was loaded with.
- Deleting a set of tracks does what Del does with each: a double switch, a slip and a crossover go
  whole, the records of the switches go with them, and the model and events of a turntable too. The
  records stayed behind and on saving were given to another switch, which then showed a wrong type.
- Deleting a switch of a crossover takes the crossover out whole, as the connection tools do: the
  outer track of a crossover on a curve comes down by its lift and the record of the connection
  goes. Alone, the switch left the outer track up for good, and the connection to the next switch
  given its name. A switch bent out of the shape of its record is found by its name.

Tests: a unit test of the norm ramp. The other changes are in the editor's UI, which the unit tests
don't reach.
2026-11-23 01:31:37 +01:00
jerrrrycho f15ea40575 test(scripting): the image memory test makes fewer images, to finish in time under coverage (#427)
The dropped images were 20 of 64 MB, each filled pixel by pixel. Under the
GCC -O0 --coverage build that sometimes took longer than the 20 s a screen
has to draw, so the check got -1. 4 dropped images, twice the memory of a
screen, still prove that dropped images don't count.
2026-11-22 19:23:40 +01:00
jerrrrycho e76ab8b5b3 Revert #408 and merge master into staging (unblocks #442) (#443)
* Enhance Windows build matrix with AVX2 variants

* fix(lang): the two Polish lines of the download area written with \n, so they match the tooltip and the hint

* fix(files): data named in another case is found on Linux, folders included

The parser and the loaders lowercase every name they read, while the data
made on Windows has files and folders named in any case (scenery/Braniewo,
textures/siec_trakcyjna_ph/.../STS_*.tga, sounds/sip/Gorki.wav). FileCased
matched the file name only, so a folder in another case wasn't found.

- FileCased walks every part of the path on Linux, the folder listings kept
  by their lowercase and read again once the folder changed; Windows as it was
- FileExists finds the file in any case on Linux, and the variant with names
  and extensions gives back the name as it's on the disk, so textures,
  materials, sounds, station announcements and scripts open that name
- models, sound captions, timetables and nodebank previews open the file
  as it's named on the disk; the texture format is told by the extension in
  any case

* fix(files): the banks keep the names asked for, only the opening takes the case of the disk

The textures, materials and sounds are kept by the names they're asked for.
Given back as named on the disk, a file in another case missed the bank and
was loaded again on every request.

- FileExists with names and extensions finds the file in any case but gives
  back the name asked for; FileOnDisk gives the file to open, used where
  textures, sounds and scripts are opened
- FileExists of a single name is a plain check again, the places checking
  it and opening the same name stay as they were
- the texture format is told by the extension asked for again
- a folder changed shortly before it was read is read again for a name
  missing from it, the time of a change being as coarse as the clock of the
  file system; a listing cut short isn't kept

* fix(files): a folder changed in the future isn't read again on every name missing from it

* perf(files): a file missing costs a single check, as before

Measured in a case sensitive folder (3000 textures, every 20th in mixed
case, looked up the way Texture.cpp does), the walk over every part of the
path made a texture lookup 4-5 times slower than master: each name tried
and missing checked every folder of its path.

- the folders found are kept by the name they're given with, the missing
  ones for a second, so a missing file checks its folder alone
- a folder named as it is on the disk is taken without its listing
- the time a folder was changed is looked at once a second at most

The lookup is now as fast as master's (about 180 us per texture on NTFS in
both) while finding the files named in another case too.

* fix(files): terrain files named in another case are found on Linux

The terrain directive names .txtf/.btf files in lowercase, as the parser
gives every token. The name is now taken as it is on disk, from the text
file first, so the binary file is made next to the text and the editor's
references and layers keep one name.

* fix(files): models named in another case are found on Linux

The manager of the models looked for the file with FileExists of a single
name, a plain check again since the banks keep the names asked for, so a
model named in another case (models/przejazdy/plyty3_L,
dynamic/pkp/st44_v2/main/2M62-0685-A) was reported missing before
TModel3d::LoadFromFile() could open it as it's named on the disk.

find_on_disk() finds the file in any case and gives back the name asked
for, the key of the bank.

* refactor(files): named functions instead of the lambdas of the folder cache (Sonar S2259, S3608, S6004)

Sonar took the folder captured by the lambda reading it for a reference
to null, failing the quality gate on reliability. The folder is read and
the path kept by functions in the anonymous namespace, the age of the
listing declared in its if.

* fix: the simulator opens more than 512 files at once, and a shader it can't open says why

With "physicslog yes" every driver keeps its .dat open, and a large scenery (Tomaszewo: some 500 vehicles,
cars of the roads included) took all 512 streams the MSVC runtime gives: the next fopen failed and the
simulator stopped at "cannot read shader: shaders/map.vert" on opening the map. The limit is raised to
8192 at the start (the soft limit of open files up to the hard one on Linux), and a shader file that
doesn't open is told as such, with the system's reason, rather than as one that can't be read.

* feat(blackbox): the black box on its own, writing the tapes of the user's vehicles at the end

"blackbox yes" in eu07.ini records the black box with the physics logs on or off, "blackbox no" never;
with no entry it goes with "physicslog yes" as before. With the physics logs off, the recorder keeps the
line of the physics log of the driver the user is with, every 0.05 s, and writes it to
physicslog/<vehicle>.dat when the recording closes: the speed recorder's tape of the vehicles the user
was in, without every vehicle keeping a log open and written twenty times a second.

The line and the header of the log are made by one function of the driver, which its own log writes
too, and the file is opened the same way, so the two are the same to the byte: the readers of these
logs (the old Hasler tape viewer, the starter) read them as before.

* feat(physicslog): the logs written every two seconds by a thread of their own, no file kept open; the black box's tapes as it goes

"physicslog yes" kept the .dat of every vehicle with a driver open for the whole run and flushed it twenty
times a second from the simulation's thread: some 580 open files on Tomaszewo. The lines are kept now and a
thread of their own writes them every two seconds, each file opened only for the moment it is written to.
The files, their lines and their text mode stay as they were.

- The black box, with the physics logs off, writes the tapes of the user's vehicles through the same
  writer as it goes, not at the end. A log begins when the user is first in the vehicle and goes on
  while the user looks around outside, until another vehicle is taken; back in it, the log goes on after
  the gap. The vehicle's own driver keeps the log only if it is the primary one, as a passive one's clock
  stands still; otherwise the driver of its train does.
- What is kept is written when the simulator closes, after the black box, at the end of a test run, and
  when the test watchdog ends a run. A crash loses the last two seconds.
- On Tomaszewo with the black box alone, the one tape grows every two seconds. With "physicslog yes", the
  581 logs grow and the simulator holds as many handles as without them; writing them takes the thread
  about 1.9 s, which the closing waits for once.

* feat(blackbox): the cab record holds the speed of the wheels, apart from the vehicle's when they slip

The speed of the cab record is the vehicle's. The speedometer, and a speed recorder's tape with it, shows the
speed of the wheels as they turn, which runs away from it while they slip and drops to 0 while they are
locked in a skid. It is added at the end of the record (194 bytes), where the readers skip what they don't
know; the .dat tapes have it already, in their second column.

* fix(ci): build OpenAL Soft with the PipeWire, PulseAudio and ALSA backends, so the Linux game has sound

The Linux job builds OpenAL Soft 1.24.2 from source, but the runner had none of the headers of its
audio backends, and OpenAL Soft's CMake leaves out every backend it can't find. The bundled
libopenal.so.1 had only OSS, Null, Wave and Loopback. Modern distributions and the Steam Linux
Runtime have no /dev/dsp, so the game logged "Failed to obtain audio device" and played nothing,
with any Steam Linux Runtime and without one.

- install libasound2-dev, libpulse-dev and libpipewire-0.3-dev before building OpenAL Soft
- configure it with ALSOFT_REQUIRE_PIPEWIRE/PULSEAUDIO/ALSA, so a missing header fails the build
  instead of shipping a library without sound

The backends are loaded with dlopen at run time (ALSOFT_DLOPEN is on by default), so the bundled
library gains no new dependency. Tested by putting an OpenAL Soft 1.24.2 with these backends next to
the game from the Steam depot: under Steam Linux Runtime 4.0 the sound works.

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

* fix(editor): the certificates of https looked for where the distribution keeps them

The Linux game bundles the libcurl of Ubuntu, which knows only Ubuntu's
/etc/ssl/certs/ca-certificates.crt. Fedora, RHEL and openSUSE keep the
certificates elsewhere, so every download of the editor (orthophoto, terrain
model, topo map) failed there with a certificate error.

The file is taken from SSL_CERT_FILE or CURL_CA_BUNDLE when set, else the
first of the files the distributions keep, and passed as CURLOPT_CAINFO.
With none found libcurl keeps its own.

* fix(editor): an https proxy checked with the same certificates

CURLOPT_PROXY_CAINFO gets the file found for CURLOPT_CAINFO, so a download through an https:// proxy on Fedora or RHEL doesn't fail on the proxy's certificate.

* fix(ci): the no-AVX2 Windows build has its own concurrency group and its own public download

After master was merged the two Windows variants shared one concurrency group with
cancel-in-progress, so one cancelled the other, and the publish job looked for an artifact
name the matrix no longer produces. Each variant now has its own group, the publish job
downloads both, and the release carries maszyna-windows-x64.zip (AVX2, the old name, so the
links already handed out still work) and maszyna-windows-x64-noavx2.zip. The AVX2 variant
passes -DENABLE_AVX2=ON explicitly instead of an empty flag.

* build: a build without AVX2 has _noavx2 at the end of its executable name

With ENABLE_AVX2=OFF the executable is eu07-x64_<date>_<hash>_noavx2.exe (eu07-x64_noavx2.exe
without ADD_VERSION_SUFFIX), so a starter can tell the two builds apart by the name alone and
pick this one on a CPU without AVX2. The AVX2 build keeps its name.

* ci: Linux is built without AVX2 too, published as maszyna-linux-x64-noavx2.tar.gz

The Linux job becomes the same two-variant matrix as Windows (ENABLE_AVX2=ON/OFF), each
variant with a concurrency group of its own. The publish job downloads both Linux artifacts,
restores the executable bits in both and releases maszyna-linux-x64.tar.gz (AVX2, the old
name) next to maszyna-linux-x64-noavx2.tar.gz. The no-AVX2 executable is
eu07_<date>_<hash>_noavx2.

* fix(renderer): the legacy renderer clears the arrays the scene left before it draws the ui

The legacy renderer drew the ui with the client arrays of the last scene draw
still enabled: the texture coordinates of the normal map unit and the normals,
pointing into the vertex buffer of whatever was drawn last, 48 bytes a vertex.
The ImGui backend sets up the vertex, colour and texture coordinates of the
active unit only, so the driver read the stale arrays with the indices of the
ui. Once the ui had more vertices than that buffer, the NVIDIA driver read past
its end and the game crashed; a crash dump of the editor (an area selected, a
track being laid) shows the read of vertex 15113 at a 48-byte stride in
ImGui_ImplOpenGL2_RenderDrawData.

The arrays are now disabled on every texture unit the geometry uses, with the
normal and colour arrays, inside the glPushClientAttrib already there, so the
scene gets its state back after the ui. The default and the experimental
renderers don't go through this code.

* fix(app): a renderer this build doesn't have starts the full one, not the legacy one

The starter writes "gfxrenderer vulkan" for the Vulkan renderer of the builds
that have it. This exe doesn't know the word, and every word other than
default/experimental fell to the legacy renderer: a player who picked Vulkan
got the slowest renderer, the one whose ui crashes on NVIDIA (the arrays left
by the scene). "experimental" in a build without the NVRHI renderer ended with
"no renderer found!" and no game at all.

After the settings are read, a gfxrenderer word this build has no renderer for
becomes "default", with a line in the log saying so. The words it knows stay
as they were: full/default, legacy, simple, null, the older starters'
simpleshader and off (legacy as before), and experimental where it is built.

* fix(settings): the gfxrenderer word read in any case, as the starter reads it

A hand-written "gfxrenderer Legacy" started the legacy renderer only because every unknown word did; with unknown words going to the full renderer it would have changed. The word is lowercased when read, as StarterNG's RenderEngineOf does, so Legacy, Simple or Full mean what they say.

* fix(physicslog): a log whose file can't be written keeps its lines and header, and the writer is stopped once on every way out

A failed write put its lines back, ahead of those since, so a file held by
another program for a while gets its header and every line once it can be
written; up to 4 MB kept per log. Stopping is joined once, and not from the
writer's own thread. main stops the logs after an error it caught too, and the
test watchdog flushes with a time limit, so a disk that doesn't answer doesn't
keep the run from ending.

* fix(blackbox): the wheels of the powered vehicle, as the speedometer has them, and the logs described as the drivers' they are

In a unit driven from an unpowered car, the speed of the wheels was of the car
the user is in, whose wheels never slip; now of the motor car, signed as the
occupied vehicle's speed. The doc tells of a log per driver, and of the two
seconds of real time a crash loses.

* fix(physicslog): failed logs kept within 64 MB in all, cut outside the lock, never written twice; the writer knows itself when stopped

The lines kept while files can't be written are cut to their share of 64 MB
before the lock the simulation waits on. A log written in part is cut back to
its length, so the next try doesn't write its start twice. A stop from the
writer itself is told by its id even after another thread took it to join, and
the watchdog's flush waits at most its time, the writing on a thread of its own.

* feat(physicslog): the logs of the trains only, physicslog.trains

"physicslog.trains yes" in eu07.ini writes the .dat log of each driver who
drives rail vehicles, not of the passengers nor of the road vehicles that make
"physicslog yes" hundreds of files on a big scenery: the tape of every train.
A driver made primary later begins its log then, and isn't counted while it
doesn't log. The black box goes with it when the ini says nothing of its own,
and doesn't write a second log of a driver writing its own. The doc tells the
doors' sides are the vehicle's, the driver's swapped in the rear cab.

* fix(physicslog): a train's log begun at its first line, so passive crews get no file

Every crew is primary in the constructor and the drivers but one of a train with crews in more
vehicles are made passive only before it starts, so a log begun there left files with only
the header. With physicslog on all logs begin at once as before; one of a train waits for
update_logs.

* fix(editor): the texture pickers let go of the images scrolled past, the memory no longer runs out

The picker of the textures of a track offers every texture of the textures folder, and each tile that came into sight read its texture full size, into the graphics card and the memory, and kept it there for good. Scrolling through the list for a trackbed texture took about 2.5 MB a tile: some 900 tiles made 3.5 GB, the whole folder 28 GB, and the game went down once the memory ran out.

An image out of sight for 3 seconds is now taken out of both again (texture_manager::unload, Unload_Texture of the renderers) and read anew when it's shown once more, a few a frame as before. Only a texture the scene has never drawn is let go; those of the scene stay to the resource sweep. The texture browser lets go of its images on Refresh too. The picker no longer lists textures/previews: the 4100 previews of the node bank are images of models, not textures of anything.

Checked on td.scn by a scripted run: 8000 images of the picker read one batch a few frames after another held the game at 2-3 GB, where it went to 28 GB and fell before; images shown again after they were let go come back; a trackbed texture picked from the folder is drawn on the track after its image was let go.

* fix(physicslog): the writer's destructor throws nothing, its wait a plain condition variable woken to stop; a driver of no vehicle controls nothing

* fix(editor): the images of the materials let go of with all their textures, the browser's Refresh a frame later

An image of a material read the material with all its textures, the normal and specular maps and the variants, and only the first one was let go of: those stayed in the memory for every material scrolled past. They are let go of together now (Unload_Material). texture_manager::unload also takes the textures read and not made yet, waiting for a worker still reading one, and deletes the gl texture itself: release() would read it back from the card with gfx.resource.move only for it to be dropped.

The Refresh of the texture browser let go of the images in the middle of the frame, while panels drawn before it could still refer to them; it now marks them, and they go at the start of the next frame.

Checked on td.scn by a scripted run: 8040 images of the picker read a batch every few frames end at 2.0 GB, against 2.3-2.6 GB before this and 1.1 GB at the start; a trackbed material picked from the folder is drawn on the track after its image was let go.

* fix(physicslog): every stop asked wakes the writer, the one from itself too; no psyche for a driver of no vehicle

* fix(editor): the image of a material with no texture in its first slot is let go of too

Its normal and specular maps were read with it and stayed in the memory: the trim passed over every image with no texture of its own, the material along with it.

* fix(physicslog): nothing that goes wrong in the writing ends the simulator; a name in 1250 makes a path on a Windows set to UTF-8

The writer's thread called flush() with nothing around it, so an exception leaving write() ended the
process with std::terminate, with no message. One that happens: the file of a log was made a
std::filesystem::path of the vehicle's name, which MSVC converts in the code page of the system and
throws for bytes not of it; on a Windows with "Use Unicode UTF-8 for worldwide language support" a
vehicle named in 1250, as the sceneries have them (0xB3 for ł), isn't UTF-8.

- the file of a log is made of the name with MultiByteToWideChar without MB_ERR_INVALID_CHARS: the same
  file as before for every name of the code page, U+FFFD for the bytes not of it instead of a throw.
  Elsewhere the bytes are the name of the file as they were
- a log whose writing throws for any other reason (memory) is kept for the next try as one whose file
  can't be written, and the other logs are written still
- the thread, flush_for() and stop() write through flush_safely(), which lets nothing out: what was taken
  for a writing failing as a whole is lost and told in the log, the next writing goes on
- the messages name the file by the bytes of the name, not by path::string(), which converts back

Tests: a log which can't be written doesn't keep the others from theirs; a vehicle named in 1250 has its
log, read back by physicslog_writer::file().

Reported in the review of #385.

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

* fix(blackbox): the tapes go on after the editor, with the physics logs off

The tapes of the user's vehicles were written by update() after the check for the writer of the
recording, which close() drops on entering the editor (F11). With "physicslog no", the speed recorder's
tape ended at F11 while the drivers' own logs of "physicslog yes" went on.

The tapes are files of their own: they are kept from the moment the recording was to be made, the file
made or not, closed or not, until the simulator closes, after the gap of the time in the editor.
Only the recording itself stops at F11, as before.

Reported in the review of #385.

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

* fix(physicslog): what no file name may have on Windows is replaced in the name of a log, on every system

A spawned vehicle is named <spawn>:<number>, and its log went to physicslog/<spawn>:<number>.dat. On
NTFS that isn't even an error: it is the stream <number>.dat of the file <spawn>, which nothing lists,
so the log was written and no one could find it. On Linux the file was there, under a name Windows
can't open.

The name of the file of a log has < > : " / \ | ? * and the control characters replaced by _, on every
system, so the logs are named alike everywhere (spawn_ezt:12 is spawn_ezt_12.dat), and a _ before a
name Windows keeps for a device (con, nul, com1..., with an extension too). The bytes of 1250 stay.
The black box tells the log it begins by the same name.

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

* refactor(renderer): a material's textures let go of in one place, for every backend

Unload_Material walked the textures of a material and of its variants the
same way in both opengl renderers, and Sonar counted its declarations, set
into the long run of overrides the two headers share, as duplicated: 5.2%
of the new code, 3% allowed. The walk is gfx_renderer's now, over
IMaterial::GetAllTextures and the backend's Unload_Texture. Materials that
don't tell their textures, the Vulkan renderer's, give none, and are left
alone as before.

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

* AI: shunting brakes for a stop point again; test mode: no false SPAD for a train set across a signal (#409)

* fix(ai): shunting AI brakes for a stop point again, the braking curve doesn't plan from a brake table left at zero

The braking curve outside the final approach plans from the consist brake table since ce87aa0e (#187, merged
with #264) whenever the brake is pneumatic. That table is worked out only for train running (Obey_train, Bank);
in shunting it stays at zero, the planned full braking falls to its floor of 0.01 m/s2, and the demand comes out
at a few hundredths of a m/s2, above the shunting brake threshold of -0.2. A shunting engine then rolled on
without braking until the final approach, too late, and ran through the signal it was to stop at (seed
480873929 of l053_poranek: ep07p-2003 at sandomierz_g4_sem_info, sm42-1096, et22-654).

With no worked out table the curve is again the constant deceleration over the distance left, as it was before
ce87aa0e and as #187 meant to keep it for shunting. Train running is unchanged.

The curve moves out of TController into vehicle/brakingcurve.{h,cpp} so that it is unit tested:
tests/unit/test_braking_curve.cpp checks a shunting engine braking to a stop point with the zeroed table, and
that a train with a worked out table gets the same demand as before.

* test(ai): pin the train braking-curve demand to the results of the code before the move

A brake table that grips harder as the train slows and a gradient, so that a wrong gravity sign, table index or a dropped term in the shaped demand shows; the expected values were worked out with the code removed from TController::adjust_desired_speed_for_braking_curve.

* fix(test): a train set across a signal doesn't pass it at danger the moment the AI first looks at it

The speed table takes in events up to a train length behind the head, so a signal the train stands across at the start of a scenario is found already behind the head, becomes elapsed on its first update, and the test mode reported it as passed at danger (calkowo_lotos: st43-189 at mac_daleko3_sem_info, manewrowo3: st43-100 at suw_szopa_a02_sem_info, both at 13.6 s with the train at a stand, the signal 20 m behind the head). A point now counts as passed only when the head of the train had it ahead once; the blackbox record of passed signals follows the same rule.

* fix(test): a signal found up to 5 m behind the head still counts as seen ahead

The distance to an event is found in steps of a metre from the position of its memory cell, so a signal just ahead of the head (a train stopped short of it when the autopilot takes over, or set right at it at the start) could come out slightly behind it, and passing it would not be reported. The trains set across a signal that the previous commit is about stood 20 m past it.

Still not reported: a signal crossed while the speed table is being traced anew in motion (a Timetable: command to a running train, the autopilot taking over in motion), as it is found behind the head when the trace is made.

* docs(test): say what the seen-ahead tolerance gives up

A train set less than 5 m past a signal at stop is still reported to pass it at danger: standing that close it can't be told from a train stopped just short of the signal, which the tolerance is there for.

---------

Co-authored-by: maj00r <maj00r@host>

* fix(camera): the roll of the cab shake tilts the view about the line of sight again (#414)

623c4f82 (#97, in 26.05.1) changed the order of the camera rotations from
Z, X, Y to X, Y, Z. The order matters only with a roll, which the cab
shake gives (Angle.z, set in drivermode.cpp), or a camera entry of the
scenery with a roll. Applied last, in the
space of the cab, the roll nodded the view up and down when looking out
of a side window instead of tilting it. The roll is multiplied in first
again, as in 26.05.

Co-authored-by: maj00r <maj00r@host>

* fix(particles): the smoke of a cold diesel keeps the colour of its template (#413)

bcb9e644 (#109) turned a comparison into an assignment: the smoke of a
vehicle in air at 5 degrees or less, or with its engine under 45 degrees,
got the colour 128,128,128. The emitter colour is on a 0-1 scale, so the
smoke turned pure white, glowing at night, and stayed so once the engine
warmed up. Up to 26.05 the line compared and did nothing; the smoke keeps
the colour of its template again, as it did then.

Co-authored-by: maj00r <maj00r@host>

* Fix stutter with fpslimit on Windows and a texture unit cache race with threaded Python screens (#399)

* fix(render): the python upload thread only marks the texture unit cache stale, the drawing thread clears it

update_from_memory() runs on the python upload thread with python.threadedupload (the default), and since
e230d7b9 it cleared opengl_texture::units there outright. That raced Bind_Material filling the same array
for its multi-bind: a unit reset between the fill and glBindTextures() made the bind of that unit fail, and
the object was drawn with the texture of the one drawn before it, for a frame, at the rate of the screens.

The thread now sets an atomic flag, and the drawing thread clears the cache when it next binds textures
(bind() and the multi-bind of Bind_Material), so a screen texture given a new gl name is still rebound.

* fix(app): fpslimit asks Windows for the 1 ms timer, the frames no longer come in turns long and short

The wait of fpslimit sleeps, and Windows wakes a process which didn't ask for a finer timer in steps of
up to ~15.6 ms. A 10 ms slot of fpslimit 100 ended ~15.6 ms later, the pacer made it up with no wait in the
next frame, and with vsync on the frames were shown for one or two refreshes in turn: visible stutter at a
steady FPS. timeBeginPeriod(1) is held from the settings to the exit, only when fpslimit is set.

* fix: the 1 ms timer also for an fpslimit set by the scenery, the stale unit cache checked with a plain load first

A config block of the scenery is parsed after the settings and can set fpslimit, so the timer period is
asked for at the first wait of the pacer too, once. bind() checks the stale flag of the unit cache with a
relaxed load before the exchange, which it does for every texture.

* fix(textures): the stale flag of the unit cache uses the default memory order (Sonar S8417)

On x86 a sequentially consistent load and exchange cost the same as the
relaxed and acq_rel ones; only the store in invalidate_unit_cache() becomes
an xchg, and it runs rarely.

---------

Co-authored-by: maj00r <maj00r@host>

* fix(camera): the cab shake taken at the frame's moment between its fixed steps, it no longer moves in steps (#403)

The shake of the cab camera (ShakeState) is stepped by update_shake at a fixed 1/50 s, while the camera read the
raw state every frame. At any frame rate other than 50 the shake moved in steps: some frames showed the same
state as the one before, others jumped one or two steps at once. Players with 144/165 Hz screens saw the cab
jump around the camera.

The vehicle now keeps the state from before the last step (ShakeStateBefore), and the camera takes the state
between the two at the share of the step the simulation time has reached (shake_between). The offset and the
velocity are blended, the angles worked out from the blended velocity. The shake itself is computed as before,
with the same fixed step and the same springs; only what the camera shows of it changes. It lags the vehicle
by a constant 1/50 s instead of 0 to 1/50 s.

Measured with the same build and the blending switched off by a temporary environment variable (not in this
commit), the EU07 on td.scn driven by the AI, frames over 30 km/h, two runs of each:
- 60 fps: frames with the shake standing still 25% -> 0%, the change in its speed frame to frame 4-5 times
  smaller for the offset, a third smaller for the angles
- ~144 fps: 65% -> 0%, 10-18 times smaller for the offset, 4 times for the angles
- no fps limit (~520 fps): 90% -> 0%

Co-authored-by: maj00r <maj00r@host>

* fix: inverted clamp bounds give the upper bound again, as the old clamp did (#412)

* fix: inverted clamp bounds give the upper bound again, as the old clamp did

The project's own clamp() of 26.05 applied the lower bound first and the
upper one last, so bounds given the wrong way round always gave the upper
one. Its calls became std::clamp (undefined for such bounds) and, where the
bounds can cross, safe_clamp, which swapped them instead. Neither gives the
old result.

- safe_clamp is the old clamp again, min(max(value, lo), hi). This restores
  26.05 at every place it is used, among them the AI's dynamic brake test
  (its demand was fAccThreshold x1.21, the swap made it x1.01), the
  generator voltage, the heavy cargo acceleration of the AI and the EP
  correction of the brake.
- The cab camera is kept inside the cab with safe_clamp. The bounds come
  from the .mmd as written and some cabs have them reversed (the B cars of
  SA134 and 21xM, ET40, 754); with std::clamp the camera jumped between
  the two bounds every frame on MSVC, as its result is fed back.

* fix: every call of the old clamp gives what it gave up to 26.05.1

d1f16411 (#99) made every call of the project's clamp() std::clamp. Where the bounds come from the data or
are computed at runtime they can cross, and then std::clamp gives another result (undefined behaviour;
MSVC gives the lower bound unless the value is above the upper one) where the old clamp gave the upper
bound. These calls use safe_clamp, the old clamp, too:

- Mover: the pantograph pressure (MaxPress), the compressor switch (CompressorListPosNo), the coupler
  distance (DmaxB, DmaxC), the engine revolutions, the eimic ramp (CtrlDelay), the eimic limit
  (eimic_max), the speed control ramp (PowerUpSpeed, PowerDownSpeed), the load (MaxLoad), the magnet of
  the security system (Dim.L);
- DynObj: the coupler distance of the buffers (DmaxB), the axle distance (Dim.L);
- Train: the brake handle positions (BrakeCtrlPosNo, the range of the handle);
- the legacy renderer: the mouse pick (the window size).

With the bounds in order nothing changes. Calls whose bounds the code keeps in order (constants,
SplineFidelity 1-4, the season table, the guarded output calibration) give the same result with
std::clamp and stay as they are.

The load offset takes its arguments in the 26.05.1 order again; fa2ed089 swapped them, which with the
old clamp differs only for a negative load.

The bump at a rail joint gives the old result again. Up to 26.05.1 its clamps had 0 in place of the
value (since 96f43e11 and 4d72d352), and the old clamp made that the headroom Vmax - (Vel + 0.32 Vmax),
negative above 68% of the top speed, capped from above only; d464628a and 03bfbb13 kept it at 0 or
above. Only damaged track has the bump: a damage flag in the .scn, a derailer set by an event, a track
made on a derailment.

The interior light of the cab in the 3.3 renderer is computed in double again, as before d1f16411.

The call added since (stepped_uc_value, 00955513) keeps what master does: bounds given the other way
round are put in order.

* fix: the alpha of a particle in the legacy renderer as up to 26.05.1, the NaN cases of the clamp tested

Up to 26.05.1 the alpha was clamp<std::uint8_t>( particle.opacity * 255, 0, 255 ): the float was
made a byte first, so the clamp did nothing and an opacity over 1 (a smoke max_opacity over 1)
wrapped round, 1.2 giving 50. The move to std::clamp made it 255. It's made a byte as then again,
through int: the byte the x86-64 compilers gave, without the undefined behaviour of that conversion
(MSVC makes the same two instructions of both). openglparticles.cpp goes with feat/gl46-migration;
its opengl33 counterpart, std::clamp( opacity, 0, 1 ), already gives what 26.05.1 gave.

The tests pin what the old clamp gave with NaN: a NaN value stays NaN, a NaN bound doesn't clamp.
The checks named after the AI braking test and the bump at a rail joint say they test the helper with
the arguments of those calls, not the calls.

* test: the includes of the clamp tests before the project's headers

<cmath> and <limits> go up, after the test headers, so the change no longer touches the lines
#416 adds its includes after. With both merged <cmath> is included twice, which is harmless.

---------

Co-authored-by: maj00r <maj00r@host>

* Python screens: the worker's image goes in place only after its fence, not a bare glFlush (#411)

* fix(python): a screen uploaded by the worker goes into a texture of its own, put in place after a fence

With python.threadedupload (the default) the worker wrote the image into the texture the drawing thread
draws from, with glTexImage2D and glGenerateMipmap from its own context, and only a glFlush after. Nothing
ordered the two contexts: the drawing one could sample the texture while its storage was being made anew,
its level 0 half written or its mipmaps not made yet, and on a change of size the worker deleted the texture
and wrote a new name into `id` with no synchronisation.

The worker now uploads each image into a new texture, sets a fence after it and flushes. The drawing thread,
once per frame in python_taskqueue::update(), waits for that fence on the gpu (glWaitSync, the cpu goes on),
deletes the old texture and puts the new one in place. The worker no longer touches the texture drawn from,
nor `id`. An image the drawing thread didn't take yet is dropped by the next one. Without sync objects the
worker waits for the upload with glFinish.

The windows of python.displaywindows with python.sharectx bound the texture once; they now bind the name of
the last image put in place, which python_rt keeps for them.

Uploads on the drawing thread (python.threadedupload no, the Lua and WebAssembly screens, the editor) are
as they were.

* fix(python): the image of the worker goes in place once its fence is signalled, the viewer binds it each frame

From the review of 8811ee5a:

- glWaitSync ordered only the context of the main window. The extra viewports and the windows of
  python.displaywindows draw in contexts of their own and could bind the new texture before the upload
  was done. commit_thread_upload() now asks the fence without waiting (glClientWaitSync, timeout 0) and
  puts the image in place only once it is signalled, so every context binding it afterwards has it whole.
  Until then the task stays in the upload queue and is asked again the next frame.
- The drawing thread chose between upload and commit by python.threadedupload, the worker by whether it
  got a context. With python.threadedupload on and no context made for the worker, the screens were no
  longer updated. The task now records that a worker uploaded it.
- The viewer of python.displaywindows told a new image by its texture name, but a deleted name comes back
  for a later texture. It binds the name of the last image each frame, read under the lock of the render
  target, and the name it starts with is read on the drawing thread when it is made.

* fix(python): the old texture deleted under the lock the viewers bind under, a fence not made waited for with glFinish

From the review of #411:

- finish_upload() deleted the old texture before it took the lock of the render target, and the
  windows of python.displaywindows read the name under that lock but bound it after letting go of it.
  A window could bind a name already deleted, or already given to the next upload. In a compatibility
  context (the legacy renderer) that makes a new empty texture: a black frame and a texture never
  deleted. The commit and the publishing of the new name now go under the lock, and the viewer binds
  under it too. A name bound before the deletion stays alive in that window's context while bound.
- A glFenceSync that returns no fence was taken for a signalled one: the image went in place at once,
  with nothing ordering the contexts. The worker now waits for its upload with glFinish then, as
  without sync objects.

* fix(python): the worker waits for the lock of the screen without the gil, no flush after a finish

From the review of 939514ea:

- The drawing thread now holds the lock of the render target for a whole upload with
  python.threadedupload off. The worker, copying the next image under that lock, waited for it holding
  the gil. It now lets the gil go around the lock and the copy: the bytes it copies stay valid, the
  object is immutable and held by the reference the worker has.
- glFlush after glFinish did nothing; the worker flushes only when it made a fence.

---------

Co-authored-by: maj00r <maj00r@host>

* fix(models): a scenery light that is off no longer shows lit for a moment the first time it comes into view (#407)

* fix(models): a scenery light that is off no longer shows lit for a moment the first time it comes into view

Since d13c27a7 (the light blinking rework) the opacity of a light changes step
by step from its last value, and the opacities start at 1. RaAnimate runs only
for the instances that are drawn, so a model with "lights 0" (a W24 LED
indicator, for one) was drawn lit when it first came into range and faded out
over 0.45 s. Before d13c27a7 the opacity of a plain on/off light was worked out
anew from a timer starting at 0, so a light that is off was off from the first
frame.

Now the first time an instance is animated its lights take their current
state at once, whether it came from the definition or from an event since.
Every later change fades as before. The light threshold modes (ls_Dark,
ls_Home) are untouched. The only other difference from before d13c27a7: a
light that is on no longer fades in the first time it is drawn.

* fix(models): the light opacity step written without an implicit double to float conversion (Sonar S5276)

The sum is still worked out in double and rounded to float once, as the
compound assignment did, so the result is the same to the bit.

---------

Co-authored-by: maj00r <maj00r@host>

* Editor: switch drives with no switch listed and marked; a deleted switch takes its drives and ballast along (#330)

* feat(track): the rail code split by concern, the blades of the switches with the key frogs shaped from their templates

The rails are laid by code of their own instead of inside Track.cpp: gauge lines (GaugeLine), knot lines (Knots.h), crossings and check rails (RailCrossings), rail materials (RailMaterials), measuring the rail profile (RailProfile), planning the cuts (RailPlan), the carving scan (RailCarve) and laying the geometry (RailLayer).

A switch with the key frogs draws its blades from the tip where their planed nose ends to the heel, bent as they're thrown, and the rail behind them from the heel on, where they were laid from the start of the switch before; on a switch of the catalogue they start at the cut tip of the tables, 1.248 m from the joint at R 190, 1.5 m at R 300 (track_features::blades). The frogs cut from the rails, the wing and the check rails are built but switched off (track_features::crossings), the rails laid whole as before. The switches without the key keep the blades they had.

A switch path can be a chain of pieces: pieces1 and pieces2 keep the parts of each path after the classic bezier, which stays as the approximation older versions read. A path with its radius given is a curve however gently it bends, a plain track a straight only where both of its control vectors lie along it. A vehicle trailing through a switch with a movable nose set the other way runs off the rails at it (TRAILED_SWITCH).

* feat(render): the shared treads of the rails and their cut faces drawn, the cut faces in the matte variants of the rail materials

Both renderers draw the treads a track shares with the rails it crosses, in the pick pass too, and a pass of their own for the faces where the rails are cut, the ends of the blades among them, in the matte variants of the rail materials, so the cut faces don't shine like the head the wheels polish.

* feat(vehicle): an axle on a switch keeps to the path it came on, and coming from the frog end trails the switch through where the wheels reach the blades

The switch thrown under an axle no longer moves it over onto the other path; it runs on along the one it entered. Coming from the frog end, where the blades are shaped or the frog has a movable nose, the switch set the other way is trailed through (rozprucie) only where the wheels get to the blades or to the nose, not as the axle enters the track; the other switches are trailed through as it enters, as before.

* fix(track): the tracks drawn straight before, which their second control vector bends now, written to the log

The simulator told a straight by the first control vector of a path alone, so a track whose second control vector bent it was drawn straight; now it's a curve. Such a track is named in the log as it loads, so a scenery made counting on the straight can be found: 25 tracks of lk357. Paths with both control vectors along them bend a centimetre or so at most and aren't named.

* feat(track): 3D sleepers and switch timbers laid where the simulator makes the ballast, switched off in the build

The sleepers of a track running alone are laid square to it, the timbers of the switches and crossings across the tracks running over them, shared by them, of the models set with sleepers3d and sleepers3dplain in eu07.ini; sleepers3dbed tells whether the ballast is laid under them too, lowered so they stick out of it. The layout of a cluster of tracks is worked out once and kept till a track of it changes, in a thread of its own while the simulation runs. timbermodel of a track, read and written back before, takes the place of the model of sleepers3d there. All of it is off whatever eu07.ini sets (track_features::sleepers), the tracks keeping their ballast and their sleeper models.

* feat(render): the 3D sleepers and switch timbers drawn in instanced batches

Render_Timbers lays the beams of the tracks in range where they're out of date and draws those of a run of tracks of a cell gathered by the model and its part or its level of detail, in as few instanced batches as they fit in; in the shadow pass only those near the camera. A track with them leaves its old sleeper model out. OpenGL 3.3 renderer only.

* fix(track): the counts of what's wrong with the sleepers kept safe from the thread laying them, and that thread stopped before what it works with goes

The counts of the beams clipped, dropped and off the plane, of the slowest and the biggest cluster, are counted by the thread working out the layouts in the background as well as by the simulation laying a cluster itself, and were plain values written by both; they're atomic now. What the thread keeps the clusters in, their version and the counts were made after the worker, as it first asked for them, and so destroyed before it at the exit while its thread could still be laying a cluster; they're made first now, the worker stopping and joining its thread before they go. The tracks go with the paths of the simulation, made before the worker.

* revert(track): a tributary and a track of an unknown type load as before

They came in with the rail code from the guards of the editor against crashing, and don't belong with the blades: a track of an unknown type loaded as a normal track of the railway could be joined to it and run on, and a tributary loaded as a river with its first path lost the second one when the editor saved the scenery. Both load as on master again; the place where the editor crashed on them is to be guarded where it is.

* fix(track): the tracks drawn straight before named in the log once, as they load, and the paths of the switches with no radius told a straight as before in one term

The log of the tracks the second control vector bends now was written each time the segments of a track were made again, as a track with its unevenness loads and as the editor changes or drags a track; it's written only the first time, as the track loads. The paths of a switch or a crossing with no radius keep the rule of master, a straight told by the first control vector alone, its two terms being the same length; they're one term now, with the comment saying so.

* fix(track): the thread laying the sleepers stopped as the application exits, and loading no models itself

The thread reads the scenery, which the application deletes as it exits well before the statics go: it's stopped and joined first thing in exit() now, the worker destroyed with the statics only where the application exits some other way, and not started again after. The models the beams are made of were loaded by the thread where it didn't find them, through the renderer, out of the thread of the renderer, into a map read by the simulation meanwhile: they're found under a lock now and loaded only by the threads other than it, again for all the tracks whenever a track changed since, before a layout is asked of it. With the 3D sleepers off in the build their settings aren't exported, and a track changed doesn't look for the tracks around to lay their beams again.

* feat(track): the 3D sleepers turned on with sleepers3d in eu07.ini, no longer switched off in the build

track_features::sleepers is gone: sleepers3d <model> in eu07.ini lays them, none (the default) lays nothing and the
tracks keep their ballast, as before. The sleepers3d settings are written back with the others.

The editor changes the tracks, so while it's open their sleepers are worked out on the main thread as they're needed,
not in the background.

* fix(render): only the part of a timber model drawn, not what else the model holds

A timber model of parts may hold more than its begin, main and end, as the kits with the fastenings of the rails do. Those
were drawn with each part of each timber, in the middle of the track; they aren't laid, so they're skipped now.

* fix(track): the 3D sleepers laid only for a renderer which draws them

Only the OpenGL 3.3 renderer draws the beams. With another one a track set to them lost its ballast to them, lowered or
not laid at all with sleepers3dbed no, and nothing was drawn in its place. Draws_Timbers() of the renderer tells now,
and where it's false the tracks keep their ballast, as with sleepers3d none.

* fix(render): the submodels of a timber model left as they were after its parts are drawn

They were all made visible after a part was drawn, the ones the model hides itself too, like Light_On, while the same
model may stand in the scenery. The submodels of the top level besides the parts are listed as the model is loaded,
hidden while a part is drawn and given back their own visibility after. The parts have to be at the top level of the
model for that; a model with them deeper is logged and drawn whole.

Render_Timbers no longer looks the model up under the lock for every run of tracks, the name set is enough there.

* fix(render): a vertex whose faces give its texture no direction gets a tangent across its normal, not a NaN one

The cut ends of the rails have one spot of the texture on all their corners, so their tangent came out of normalize() as NaN. The normal-mapped shaders then shaded them with a NaN normal: about half of the vertices of the cuts and frogs, and the end faces of the rails.

* feat(track): the frogs cut from the rails turned on with frogs in eu07.ini, no longer switched off in the build

frogs yes cuts the rails of the plain tracks and of the switches with the key frogs where they cross other rails, into frogs, wing rails and check rails. It's off by default: the rails are laid whole as before, the blades of the switches with the key are shaped still.

* refactor(editor): the track mode file split into the files of its tools, the code as it was

A pure move, so that the commits after it show what changes in each tool rather than a 4800-line file rewritten.
The member functions of editor_mode go to the file the editor of this branch has them in: route, straights, lay,
switchplace, switchdrive, switchtool, trackgizmo, and the rest stays in editormodetrack.cpp. The helpers of its
anonymous namespace go to editormodetrackshared.h, as they were but inline, in namespace track_mode, which the files
use. No line of code changes; the files add only their license, includes and the using line.

* feat(editor): the groundwork the tools of the editor share

- The tool interface (editortool.h), the gestures of the mouse (editorgestures.h) and what the modes share
  (editormodeshared.h); the projection, viewport, selection and texture picking taking them up.
- Scripted input (scriptedinput): the input of a selftest script fed to the editor as if typed and clicked, the real
  mouse and keyboard ignored meanwhile; EU07_EDITOR_SELFTEST_HIDDEN draws into a window never shown nor focused.
- The ui layers and panels of the editor, its settings, icons and the info of the includes; the layers of the scenery
  and their saving; the launcher mode.
- utilities: user_cache_path (the cache folder of the system for the user) and the helpers of the translations.
- stb_image: the gif loader takes the frame two back from the frames it decoded, not from before its buffer.
- tools/editor: the scripts making the headers of the drives, the turntables, the editor and its usage.
- Unit tests: test_area and the stubs of the editor the tests link.

Not built on its own: the tree builds again with the selftests commit, the one before the translation.

* feat(editor): the tracks laid along an alignment, to the PKP PLK norms, with their grade line and the ground

- The alignment of the laying (editorAlignment, editorAlignmentStore): straights, transition curves and arcs with the
  cant of the norms for the speed, the radius below the minimum for it a warning; the lay, route and straights tools
  build on it, the route plan reading the curves going on from the tracks adjoining.
- The grade line (editorProfile, the profile and gradeline tools): fitted to the terrain model or edited by hand, the
  tracks fitted marked in the scenery (//$f), the shared grade lines of nearly parallel tracks (//$n).
- The ground under the tracks (editorGroundFollow, trackbed): the terrain drawn to the tracks and restored, the tracks
  put onto the terrain.
- Connections between tracks (editorConnections, the connection and connection curve tools), the track presets, the
  shape of a track (editorTrackShape), digitizing tracks from the orthophoto, the properties sheet of the tracks
  (trackprops) and the track ux.
- Unit tests: alignment, ground fit, heights, with the data of two fits.

Not built on its own: the tree builds again with the selftests commit, the one before the translation.

* feat(editor): the switches placed, slid and designed from their templates

- The switch templates (editorSwitchStore, the template tool): the catalogue switches and the user's own, kept with
  the settings; the designer (editorSwitchDesign) with a drawing of the dimensions, a and b typed in with the shape
  making up the rest, a switch clicked off the orthophoto.
- The curve of a switch laid into a curve (editorSwitchCurve), placement on a straight or into a curve, slide along
  it, crossovers and double slips (switchplace, switchslide), the drives of the switches (switchdrive) and the records
  of the switches placed (records).
- Unit tests: test_switch_curve.

Not built on its own: the tree builds again with the selftests commit, the one before the translation.

* feat(editor): the tools of the infrastructure beside the tracks

The gauge, speed, joints, lineside, parallel tracks, vehicles, signals, turntables, sweep and road tools with headers
of their own; the kilometrage of the lines (editorKilometrage, the km tool); the infrastructure, roads and speeds
behind them (editorInfra, editorRoad, editorSpeed).

Not built on its own: the tree builds again with the selftests commit, the one before the translation.

* feat(editor): the terrain model of geoportal.gov.pl and the orthophoto downloaded for the editor

- editorNmt: the squares of the terrain model at 1 m (NMT GRID1, the WCS service of geoportal.gov.pl) fetched by two
  workers, kept in editor/cache/nmt/grid1 of the game folder, the heights of the scenery taken from them; the nmt
  mode loads it along the tracks or around the camera.
- editorHttp: the HTTP client of both, WinHTTP on Windows, libcurl elsewhere where it's built with it; without it the
  caches only.
- The orthophoto: its cache moved to the cache folder of the system for the user, the download area a polygon on the
  topo map (//$a) filled in the background, the 4K imagery, the tiles waiting outlined on the ground.
- editorGeoMap: the topo map of the top view; heightmapterrain and the terrain streamer grow the terrain made from the
  model around the camera.

Not built on its own: the tree builds again with the selftests commit, the one before the translation.

* feat(launcher): the scenery wizard picks the place of a new scenery on the topo map the editor shares

The wizard drops its own map download and decoding for the topo map widget of the editor (editorGeoMap). The place
clicked becomes the geographic reference of the new scenery (//$g PUWG1992), and the scenery starts with the
orthophoto of the editor on (//$o), lying under it in place.

Not built on its own: the tree builds again with the selftests commit, the one before the translation.

* feat(editor): the tools wired into the editor mode and the build

editor_mode takes the tools of the commits before: its header declares them, editormode.cpp and the track mode drive
them, and the renderers draw their overlays (opengl33 and legacy). CMakeLists lists the new sources and adds
WITH_EDITOR_SELFTESTS (off by default); the unit tests build the new test files.

Not built on its own: the tree builds again with the selftests commit, the one before the translation.

* feat(editor): the selftests of the editor split by what they test

The scripts of EU07_EDITOR_SELFTEST run the commands of editormodeselftest*.cpp: scene, track, rails, join, switch,
signal, sleepers, sweep, terrain, monkey. The code is in every build; only with WITH_EDITOR_SELFTESTS=ON does the
editor read the variables and run a script. The selftests of master now need the option too.

The tree builds again with this commit.

* feat(editor): the Polish texts of the editor, all of them in one update of editor_pl.po

* fix(editor): the marks of the editor moved off the letters the starters read, and its lines told by their words

The starters read some letters in a scenery file: the Starter the title //$n, the attachments //$f and the old scenery //$a,
StarterNG and the launcher of the game the attachments //$f and the title //$n. The editor wrote its download area,
shared grade lines and fitted tracks under them, and took every line of those marks as its own: saved, a scenery lost
its title and attachments, and the starters showed the lines of the editor as them.

- The download area is //$z, the shared grade lines //$w, the fitted tracks //$t.
- Their lines and those of //$o are told by their first words, as //$h, //$r and //$k were: //$o only as "on 0" or
  "on 1", the origin or the settings of older builds after it, so a trainset described as "on ..." isn't taken.
- The lines older builds wrote under //$a, //$n and //$f are read only by the words the editor wrote in them, or by
  its own comment line before them, under the new mark. Each save writes them again with it, also when the editor
  didn't change them; the lines of the starters stay.

* fix(editor): a square of the terrain model cut short isn't read, and the squares are kept in the user's cache

The service puts the directory of its GeoTIFF before the pixels, so a file cut short by a write or a fetch broken off
was read whole, the pixels missing coming out as heights of 0 m, for good.

- The reader (editorGeoTiff.hpp, with unit tests) wants all the strips the rows need, each within the file.
- A square is written under a name of its own and renamed.
- The squares are kept in the user's cache folder (nmt/grid1), as the orthophoto, since the game folder may not be
  writable; without one, in the game folder as before. The ones older builds kept there are moved over as each is
  asked for, a damaged one deleted.
- Capabilities that didn't come aren't kept as the fallback name for the session: the next square asks again.

* chore(editor): the http client said to serve the terrain model and the topo map too, the gif fix of stb_image marked local

- CMake names the orthophoto, the terrain model and the topo map as what goes without libcurl.
- The fix of the gif frame two back in stb_image is ours, not upstream's (v2.30 still has the old line): a comment at
  the line says so, for an update of stb_image to keep it.

* fix(editor): the lines moved off the letters of the starters in a merged layer written once, not again with each save

A merged layer's text goes into the file of its target on save, and the target is read again; the marked lines of the
merged layer were dropped only for the marks the editor had changed. The lines moved to the new letters stayed with
their old places, and the next save of the session wrote them into the target once more.

- After a save, the marked lines of every merged layer are dropped; those of its target are read again from its file.
- The lines of a dead layer aren't written again.
- The selftest layermerge merges the layer of one file into another's, as the layers panel does.

* feat(editor): the station as the signalling sees it, found from a switch of it, and its schematic

editorStation: the switches joined by plain track no longer than 1.5 km, the tracks between them and the lines leading
out, 400 m of each beyond the outermost switch; laid out as a schematic along the main track through the station. The
track circuits, the signals and their lights, the lengths of the station tracks and the lines to the next stations are
worked out from it for the signalling tool.

Nothing uses it yet: the signalling tool, wired in the next commit, does. It builds on its own.

* feat(editor): the signalling of a station in the Signalling tab, laid out from a switch of it as on the lines of PKP PLK

LMB on a switch in the Signalling tab opens its station: the schematic in a window of its own, the name, the code, the
line and the km of the station, and the steps of its signalling, each one step of undo:

- the switches numbered along the station after its code, bpd_1, the parts of a slip bpd_15a..d; the drives and the
  objects naming a switch follow it, events written by hand keep the old names;
- the tracks cut at the joints of the track circuits, Ie-4, and the circuits named, bpd_iz1, bpd_it1;
- the entry, exit and shunting signals placed and named, A, F1, Tm1, from the templates chosen;
- the signals of the lines out: the automatic block of three or four aspects, the block sections no shorter than the
  braking distance, or the semi-automatic one with a warning disc; block boundaries drawn by hand;
- the lights each signal needs for its routes, Ie-1 and Ie-4 § 8, its template fitted to them;
- the SHP track resonators the signals lack, rezonator.inc;
- the lengths of the station tracks as a table, and what the station and its lines still lack, with Repair.

The stations described are kept as //$s lines in the files of their layers.

* fix(editor): the signals of a station and of its lines not placed with no template for a kind, no track cut for them first

- Set the signals and Set the line signals cut the tracks first, and only then found no template for a kind. They
  stopped there, but the cuts stayed as a step of undo. Now they ask for the templates first, by the lookup
  signal_batch() uses (signal_template_for(), behind editor_signals::signal_templates_missing()). Without one
  nothing is cut.
- Set the signals and Set the track circuits again under Track lengths had the ids of the buttons of the steps
  above them. ImGui flagged them when hovered. Each now has an id of its own.

* fix(utilities): win1250_to_utf8 turns the polish letters into utf-8, not into themselves

utilities.cpp starts with a byte order mark, so the compiler reads it as utf-8. The game's targets don't get
/utf-8, though: set_target_properties(... COMPILE_OPTIONS ...) in the MSVC block of CMakeLists.txt replaces the
options add_compile_options gave them. So the string literals went into the program in the code page of the
system, windows-1250 on a polish one, and the map of win1250_to_utf8 turned each letter into itself.

What read windows-1250 through it got no utf-8: the names, descriptions and categories of the sceneries and the
names of the textures in the launcher, and the descriptions of the templates in the editor. The editor writes
such a description back through utf8_to_win1250, which makes a question mark of each byte that doesn't start
a utf-8 sequence, so the letters it had read unchanged didn't come back.

The utf-8 sequences are written as bytes now, the way utf8_to_win1250 has them, so they don't depend on the
options. The options stay as they are: with /utf-8 other literals of the files with a byte order mark would
change, the "±" of the table of Bezogonkow would take two bytes and move the letters after it.

The unit tests check the letters and that the text given is valid utf-8.

(cherry picked from commit 9ffed96ec1)

* fix(editor): the switches renamed only after the events by their old names are shown, the station records in windows-1250 and in the file the scenery had

Number the switches renames the switches and what the editor writes along with them, but not the events written
by hand: a switch event aiming at a switch, or <name>:event0 and the others named after it, would keep the old
name and lose its switch. Now the first click lists them in the status, up to six and how many more, and renames
nothing. A second click with the same renames goes ahead.

The name of a station is written in windows-1250, like the rest of the scenery file. A name read that isn't
valid utf-8 is taken for windows-1250; the utf-8 the earlier builds wrote is read as it is. utf8_to_win1250
moves from editorIncludeInfo.cpp to the utilities, beside win1250_to_utf8, and the unit tests check both ways.

The record of a station that had none goes beside the records of the other stations, in the file marked with
them, so a scenery saved under another name keeps them in one file. output_layer takes, after
<scenery>_<part>.scm, an included file of the part of another name, the one of the scenery it was copied from,
before it makes a new one.

The comments: the joints of the track circuits stand 4.2 m beyond the fouling points, where the axes are 3.5 m
apart, as joints() counts them; the regulation of the lengths is cited with its date and title.

* fix(editor): a scenery saved under another name keeps one file of the keys by the movable noses, not the old one beside its own

The editor writes the keys by the movable noses on each save to <scenery>_dzioby.scm and includes it. A copy of
a scenery, saved under another name, still included the file of the scenery it came from, and its save wrote a
file of its own and included it too, so each key stood twice.

Now the save leaves out of the scenery the other files of such keys it includes, told by the line the editor
writes at their start. Their files stay on the disk, for the scenery they were made for. A file made by hand,
without that line, stays included. The turntable controls had the same, fixed the same way on their own.

* fix(editor): a file of the scenery named like a part of a tool isn't taken for the one the tool made

output_layer took, after <scenery>_<part>.scm, any included file named *_<part>.scm, so that a scenery saved under
another name goes on with the file of the scenery it was copied from. A file of the scenery named alike, written by
hand, such as rejon_teren.scm, got the terrain directive, the hectometre posts or the new signals too.

The files output_layer makes start with a line of their own now, "// scenery layer created in the editor for its
<part> part", and a file of another name is taken only with that line. A layer gets it through the new parameter
of scene::node_layers::create(); the others start with the general line as before. <scenery>_<part>.scm of the
scenery itself is taken without the line, as it was. A file made for a part by an earlier build has only the
general line, so a copy saved from it gets a file of its own.

* feat(editor): a player of GIF clips for the windows of the editor

editor_clips::clip plays a GIF in an ImGui window, looped, from the time given. stb_image decodes the whole
file on a thread of its own, so the window isn't held up; until then the clip says it's loading. The frames are
kept as stb_image decoded them, and the one shown is a texture of the ImGui renderer (Create_Image), made again
only when the frame changes. A file that isn't there is told missing at once, with no thread started.

Nothing uses it yet; the tutorial of the next commit shows its clips with it.

* feat(editor): Help > Tutorial, fifteen short lessons of the editor

The lessons: looking around, laying track, curves, the radius of the curves at the bends, correcting a curve,
joining tracks, switches, switch templates, signals and posts, selecting and fixing, editing with the gizmo, the
grade line, terrain from the terrain model, sceneries made before, saving and driving.

Each lesson has:
- in eight lessons, a looping clip from lang/editor_tutorial/<lesson>.gif, played from the start on a click;
  in six others, a moving drawing (the radius at a bend, a switch template clicked, the signals, the grade
  line, the terrain, a trainset);
- the mouse buttons and keys drawn as pictures beside what they do;
- ticks that fill in as the user does it, told by the tools through editor_guide::first_step_done();
- a button that turns the tool of the lesson on;
- Back / Next and a dot per lesson, green when the lesson is done.

The window follows the work: when the tool in use changes, it turns to the first lesson of that tool not done
yet, and a page turned by hand stays until then. In a lesson of laying it warns when there's no ground under
the cursor.

Where it opens:
- by itself when an editor session starts, until "Show when the editor opens" is unticked (first_steps in the
  editor's settings);
- from the Help menu;
- from a Tutorial button beside Lay a track in the hint of an empty scenery, which isn't drawn while the
  tutorial is open;
- at its lesson, from a "?" by the radius at the bends in the lay panel.

A lesson whose clip isn't there is shown without it; the clips aren't in this commit.

editor_guide is a new role of the editor, given to the hekto-post and trainset tools. Selftest command
tutorial <page>: opens the tutorial at a lesson, from 0; -1 closes it.

* fix(editor): the lessons of the tutorial say what the editor does

The lesson texts checked one by one against the tools; the ones that told otherwise:
- Switches: a connection isn't chosen at the top of the panel, its kind comes from where the drag is let go (a
  crossover onto the other track, over a crossover the other way a double one, or scissors where they overlap).
- Switches: a ladder leads onto the parallel tracks it's dragged across, let go on the farthest, with the
  straights up to where they start; it lays no missing tracks.
- Terrain: there is no step 3. Step 1 is Location, step 2 is Load around the camera while there are no tracks
  and Tracks and terrain with its three ways once there are. The rows had the step numbers in the keys column,
  and 1, 2 and 3 switch the edit modes in the Terrain field. Now the steps show the mouse, the terrain under
  some tracks only is a row of F3 (the line the terrain panel shows), and the rows that only tell what the
  fit does have no key.
- Sceneries made before: a plain include can be changed; the row lists what can't: an include template (.inc),
  the binary terrain cache, a file included twice or with parameters, a locked or hidden layer.
- Laying: the second Esc drops the points only within 3 s.
- The radius at the bends: two transition curves from 6000 m down to 2000 m while they're long enough for the
  speed, then an arc; a label turns orange where the curve breaks the norms, not because it came out smaller;
  two transitions meeting read 2xL and R; the labels of each transition curve are on laid tracks, close up.
- Signals and posts: the W17 markers go by the selected switch, around the camera or the whole scenery, not
  along a line.
- Selecting and fixing: E lengthens the track, the control vectors bend it.
- The gizmo: at a point Q moves the point alone, W turns the whole track about it.

The tooltip of Help > Tutorial no longer speaks of clips: the tutorial goes without them. lang/editor_pl.po
has the new texts.

* fix(editor): the lessons of the tutorial in plain words

Every row, goal and warning of the tutorial is said again for someone
who has never laid a track, in English and in Polish:
- the words of the railway and of the editor are said in everyday ones,
  or explained where they come: the radius (how big the curve is), the
  transition curve (the easing into it), the cant (the outer rail
  raised), the gizmo (handles on the track), the control vectors (points
  that bend it), the grade line (how the line goes up and down), the
  terrain model (the real ground), the orthophoto (the aerial photo),
  the hectometre posts (every 100 m), W17 (how far a wagon may stand);
- what only a designer needs is left out: the 6000 and 2000 m of the
  radius ladder, the compound curve, the hump, the kinds of include that
  can't be changed;
- the buttons are named as the panels name them: Apply to the scenery,
  Template editor..., the tiles of the switch tool;
- the Polish names of three lessons say what they are about ("Uchwyty na
  torze (gizmo)", "Wzniesienia i spadki", "Prawdziwy teren"). Their
  English titles stay, the lessons are found by them;
- the warning of no ground under the cursor tells what happens to the
  track;
- two captions of the drawings say what they show (the tracks inside a
  box, posts every 100 m), and in Polish the button of the top view is
  "Widok z góry (O)", without "ortogonalny".

What each row tells of is the same as before. The msgid of the length
typed while laying stays, the window of the keys (F1) uses it.

* feat(editor): the semaphores and the warning discs chosen by what their descriptions say they show

The descriptions of the signal templates can now say what a semaphore shows and what a disc
repeats, and the editor reads it:

- signal: {arms: 2, aspects: {Sr1: ..., Sr2: ..., Sr3: ..., Sz: ...}, repeats: {stop: ...,
  vmax: ..., "40": ...}} is kept with the template, the events named for each aspect
- the palette shows a template with arms as a semaphore of its arms, with 1 arm / 2 arms and
  Sz picking the template of the same tile that has them
- the signals of SRK take a semaphore whose aspects cover what the signal needs (Sr3 where a
  speed is reduced, Sz on the main signals), the fewest arms that do it, and say which one
  does when the placed one hasn't them or has more than it needs
- the warning disc before a semaphore is one whose repeats cover stop, the highest speed and
  40 km/h when the semaphore shows Sr3; SRK writes no events of the routes, so this only
  chooses and checks the disc
- the linked signal (parameter 7) is read for the role link as well as text
- signal_headers.py keeps the keys written by hand in a description (arms, aspects, repeats,
  the description and the parameters from 6 on) when it writes the guessed ones again
- signaltemplates of the self test lists what the templates say and the heads made of them

* feat(editor): the shaped discs swapped and set by hand, the warning discs checked by what they repeat

The shaped shunting and stop discs (mk1, tzm, z1) are known to the signalling, but it doesn't
place them by itself:

- a shaped disc chosen in the palette for the shunting or the stop signals is placed by hand
  only; the signalling of a station takes the light template of the kind there, and says so
  when there is none
- the template of a shunting or a stop signal standing can be swapped for a light or a shaped
  one of another mount as well (dwarf and mast, not gantry)
- a signal whose description lists its aspects shows a button for each under its card: it sets
  the signal to that aspect in the editor, by the animations, the lights and the submodels its
  event sets off, the time standing still; nothing of it is saved. TAnimContainer::Finish takes
  an animation to its end at once, giving the submodel its angles, multi_event::branches tells
  the events set off when the condition isn't met

From the review of the descriptions:

- a shaped warning disc standing before a semaphore described is checked by the events it
  repeats: stop, the highest speed and 40 km/h of a second arm told apart; one which doesn't is
  offered the disc which does, and Fit swaps it
- the disc offered is of the mount of the disc chosen, taken from the template even when it
  isn't described
- 1 arm / 2 arms / Sz of the palette pick the template leaning as the chosen one and most like
  it by its name
- a semaphore described with its arms but not its aspects has Sr1, Sr2 and with a second arm
  Sr3
- Fit leaves a semaphore having what it needs with its arms, for the events written by hand to
  the aspects of a second one; the messages of the fitting speak of what the signals need, not
  of their lights
- signal_headers.py warns of a signal map written as a block, whose keys it can't keep

* fix(editor): an aspect shown by hand doesn't name a vehicle that may be gone

The Show button runs the events of the aspect outside the queue. run() writes
the vehicle that set the event off last into the log, and nothing clears that
pointer, so a train deleted since would have been read after it was freed. The
queue sets the activator anew each time, so it is cleared before the run.

* fix(editor): a disc not described is only offered the one that tells, a light stand-in of the mount of the shaped one

- A shaped warning disc whose template doesn't say what it repeats may tell
  all its semaphore shows as well. It is no longer marked as not fitting:
  the disc described is offered as a hint, and Fit leaves it be. A disc whose
  template isn't among the scanned, its mount not known, is offered nothing
  rather than discs of any mount.
- A shaped disc chosen for shunting or stop is stood in for by a light
  template of its own mount first, a dwarf for a dwarf.
- The tooltip of the aspect buttons says the trains read the signal as its
  events set it last, in a run started from the editor too.
- The Polish texts of the fitting speak of signals, not semaphores, since it
  takes the discs too.

* refactor: the Sonar remarks on the switch blades taken care of

- the big functions of the rails split into helpers with one job each:
  the carving, the laying and the planning of the rails, their
  crossings, the blades, the lofted spans of a segment, the profile of
  a rail measured piece by piece, the joining of the switches
- the floating-point loop counters are while loops doing the same
  additions, so the samples come out where they did
- C arrays are std::array, the two sides of the paths path_sides; the
  ends of a cut are two parts of one struct, ending and starting
- the rail laid by a course of its own, not eleven parameters
- the globals kept in functions, the nested ternaries taken apart, one
  declaration per statement, explicit captures, ranges algorithms,
  std::format, std::numbers, emplace_back, structured bindings
- the region finds the sections around a point into a list the caller
  gives, so the search for the rails around a track shares no list with
  another thread
- check_rails and create_track_rail_profile are const, the pool of the
  reused chunks can't be copied

The geometry of every chunk of lk357 and td_fog, with the frogs on and
off, comes out the same as before.

* refactor: the Sonar remarks on the 3D sleepers taken care of

- the big functions of the sleepers split into helpers with one job
  each: the clusters and the lines of timbers, the gaps under the rails,
  the models and their parts, the check of the layout, the drawing of
  the timbers in instanced batches
- the tracks near a track found into a list of their own, the region
  searched into a list the caller keeps, not the one the region shares
  with the main thread; the callbacks are templates, not std::function
- the layout of a cluster takes a span of its tracks
- the globals kept in functions, the parts of a beam int constants,
  beam_overhang no longer hidden by a field of the same name
- scoped_lock, jthread, contains, ranges algorithms, std::format,
  emplace_back, structured bindings, explicit captures, upper-case
  literal suffixes, one declaration per statement
- the uniform buffer takes a span of bytes

* fix(editor): the editor core builds with GCC again

- kCrossoverStraights is constexpr, so the connection curve can take it into
  a constant expression; GCC refused a double that was only const there.
- the track_hover alias inside editor_mode dropped: declared after
  hovered_track had already used the name, it changed what the name meant in
  the class (-Wchanges-meaning); the definitions name the shared track_hover.
- <cstring> included where the rail self-test uses std::memcpy, which MSVC
  reached through other headers.

* refactor: the second round of Sonar remarks on the switch blades

- the carve of a throwable part takes the cut before it only where there
  is one, as only that cut makes it throwable
- the splitting of a grooved profile by the floor of its groove moved out
  of the rail layer into a class of its own, which is given the profile,
  the size of the rail, the texture of the plates and the side
- the rail drawing is made by a const function
- the triangles of an ear-clipped outline go in as the arrays they are,
  the search for a corner within an ear is an any_of, the loop pruning
  thin corners keeps the count it started with, as it stops at the first
- the bytes of the blocks of a texture are taken off the file through
  its buffer, with no cast of their storage
- the log of a carved part takes the tracks around it as a span
- the joint length of a switch, a constant, isn't captured, and the
  directions at the ends of a crossroads are tested in one condition each

* refactor: the Sonar remarks on the tutorial

- the window of the tutorial in smaller pieces: the steps reached, the
  lesson followed and its clip, the clip or the sketch of a lesson, its
  keys and steps, the button under it and the buttons of the pages; the
  lessons are a table of their own, the button of each kind of lesson
  picked from a switch
- a clip whose delays add up to nothing shows no frame instead of
  dividing by them
- the frames of a clip are decoded by a function of their own, on a
  thread kept with them and joined once it's done, or as the editor
  closes, instead of a detached one
- the sleepers of the signal sketch counted by a whole number, the texts
  of the sketches made by std::format, their points kept in std::array,
  the whole numbers turned into floats where it's meant

* fix: the bugs and vulnerabilities Sonar found in the editor core

- the loops stepping along a track, a curve or the view count their
  steps by a whole number and take the station as so many steps from
  the first, instead of adding a fraction up, which drifts
- the self-test of the guard rails keeps the plan of the rails of the
  track against while it goes through them: the range of the loop was
  in a plan made for it and gone before the loop began
- the generators of the self-tests and of a unit test are seeded on
  purpose, so a run can be repeated: marked for Sonar as such
- the tool writing the descriptions of the templates takes the names
  out of its tables only where they stay in the data folder

* fix: the loops of the signalling stepping by a whole number

the places of the block signals along a line and the marks of the
chainage under the plan of a station are counted by a whole number and
taken as so many steps from the first, instead of adding a fraction up,
which drifts; Sonar took the counters of floats for bugs

* refactor: the checks of the signal heads and the signal sheet in smaller pieces

the remarks Sonar made on the signal descriptions: the warning about
a disc on the mount of a signal is worked out by a function of its own,
the fit and the aspects of a head, the swap of a template and its
aspects in the sheet of a signal are drawn by members of their own, the
walk over the events of a signal is a free function instead of a
std::function held by a lambda, and the description of an include is
read a part at a time; the names of the kinds are kept in a std::array
and looked up by the algorithms of ranges, a name is taken as a
std::string_view where it is only compared, and the locals named event,
which hid the enumerator, are renamed

* style: a space after a comma in the join self-test

* style: a space after the question mark in the terrain sketch

* style: a space after the question mark in the status of the fitting

* refactor: the last Sonar remarks on the small fixes

the opening of a scenario catches the exception the scenery throws when
it can't be read, not any runtime error; the vehicle moved between
trainsets keeps its source by a reference to const; the messages of a
track of an unknown type and of a tributary are raw string literals;
the parser opens a file by a std::filesystem::path, and the log of a
file it can't open still names its folder and its name

* refactor: the crossings of a track found without casting its const away

the radius of a node can be read off a const one: radius_() is const
across the nodes, the ones of the tracks and the models marked override,
and a const radius() gives the radius worked out already, or works it
out anew without keeping it; the helpers finding the crossings of a
track only read it and take it const, its own run of rails typed apart
from the ones of the tracks it crosses, which the crossings found name;
the triangles of a filled outline are pushed as named corners

* refactor: the paths around a track sampled without casting its const away

the sampling of the paths and the clusters of tracks laid together only
read the tracks, so they take and keep them const: the path sampled
points at a const track, the tracks near one are found from a const one
by its const radius, and a cluster holds const tracks; the shared zones
of the timbers no longer cast the const of their track away

* fix(editor): the Sonar blocker remarks on the stack, no side effects in the operands of && and ||, no local named final (S912, S1669)

Counting the leftover signals, the pieces of a station walk, the places with nothing beside a run and the joints and fouling points
logged by the self-tests no longer counts inside a condition; the last span of a straight is named tail. The counts and what they
log are the same.

* revert(vehicle): an axle on a switch follows the switch as it is set, as before the stack

The axle kept to the path it came on, so a switch thrown under a moving train no longer sent the rest of it onto the other
branch, and coming from the frog end it trailed shaped blades only where the wheels reached them. That changed the running of
every switch in every scenery, and the AI still scans its route by the switch as set. TrkFoll is as on master again, and the
trailing point of the blades it used is gone.

* revert(track): a path is told a straight by its first control vector alone again, as the sceneries are made for

A plain track was drawn bent where its second control vector was off the chord though the first lay along it, and a path with a
radius given was never straightened. Tracks of existing sceneries drawn straight before would have been drawn bent, with their
length, cant and the models along them. TTrack::straightened is the rule of master, for plain tracks and the paths of switches.

The editor keeps a bend dragged with the second control vector, or set by joining the tangents, by moving the first one 2.5 cm
off the chord to the side of the bend, past the tolerance, so the track is drawn, saved and read back bent, by older builds too;
the second one dragged back along the chord takes the first one back onto it.

* feat(track): the switches joined directly to other switches at load told in the log

A switch right after another one is joined to it as the sceneries load, where its end was left open before and vehicles came off
the track there. Each switch joined so is logged with its place and the number of ends, and the whole number once, so a scenery
can be checked for places that run differently now.

* fix(editor): a bend kept by lengthening the first control vector, not turning it

keep_bent moved the first control vector 2.5 cm sideways, which turned the
start tangent: a kink of 0.29 deg on a 15 m track, flagged by the joints
check, and against the fixed direction at a switch or a locked track.

Now the vector keeps its direction and gets 2.5 cm longer than a third of
the chord, which the simulator no longer takes for a straight. It is also
applied after an end is moved or snapped, since a new chord or a snap onto
a neighbour could bring the vector back within the tolerance. With the
second vector back on the chord, the first goes back to a third of it.

* fix(track): each switch joined directly to another one logged with both names

join_switches counted ends, while one join links both switches, and only
the first switch of a pair was named. It now returns the switches joined
to, and the log names both of each joint and gives the number of joints.

* fix(editor): a path drawn bent is kept bent through every edit, one drawn straight is left as it is

The first control vector is made longer past the 2 cm tolerance only where the path was drawn bent before the edit, or where
the edit itself sets the second vector: the end of the path moved, its first vector, its second one, a neighbour followed or
its grade taken, the controls aligned at a joint, an end snapped. A path drawn straight keeps being straight when its ends
move, and the paths of a track that the edit doesn't bend aren't changed. Moving the second vector back along the chord takes
the first one back to a third of the chord where it was made longer here.

* fix(app): a scenery that can't be opened takes the game back to the launcher whatever the file system throws

Catches std::runtime_error again, as master did: invalid_scenery_exception is one of them, and so is what the file system
throws while the scenery is opened.

* fix(track): the beams worked out in the background don't read the ends a switch is set to

The ballast a switch trackbed takes is asked of the tracks joined to its main path, as the trackbed is made at the load,
not of the ends the switch is set to now, which change as it's thrown while the thread runs. What the thread reads with no
lock against the main thread is written down where it runs, with the two things driving can change: a switch thrown and a
turntable turned.

* perf(render): the cut faces of a track drawn with nothing put on the heap, a track with none passed over at once

* chore(track): the switch drawing the cut faces in the unrolled material read only in the builds with the self-tests

* docs(track): the blades flag said to be switched on, and what frogs in eu07.ini changes of it

* fix(editor): a response over 64 MB is refused, curl kept to http and https, the address read as UTF-8

The body of a map or of a service the user typed is read into memory up to 64 MB and fails above that, with WinHTTP and
with curl. curl follows at most 10 redirects and only to http or https. WinHTTP gets the address widened from UTF-8, so a
pasted one with letters past ASCII isn't turned into garbage.

* fix(editor): only the orthophoto an older editor kept is deleted from the settings folder, not all its cache

The geoportal folder of the old cache is removed, and the cache folder itself only where nothing else is left in it.

* fix(editor): the square metre of the outlined area written as its UTF-8 bytes, shown right where /utf-8 doesn't reach

* docs(track): why the velocity read for a switch is put back after its segments are made

* fix(track): the blade tips and the open ends of a track take the dark of the rail, not the colour of a worn tread

No wheel runs over them, so their cut faces aren't drawn as worn: the beige the matte material gives a worn face is left
to the cut faces of the frogs.

* fix(editor): a neighbour followed or given its grade is bent only where its second vector really changed

follow() and follow_grade() write the second vector of a track joined at its end back as it was when the joint didn't
turn or keep its grade; a track the simulator draws straight with that vector off the chord was made bent then, though
the edit never touched it. Its first vector is lengthened now only where the path was drawn bent or the second vector
took another direction or grade.

* fix(track): the open ends of a track laid with cuts take the dark of the rail too

The rails a frog or a crossing cuts are laid piece by piece; the caps of their pieces at the open ends of the track were
drawn worn with the cuts of the frogs. They aren't worn now, as the open ends of the other tracks.

* fix(editor): a neighbour drawn straight is bent only where the edit took its second vector off the chord

follow_grade() sets the height of the second vector anew on every graded joint, a fraction of a millimetre off the height
the scenery has, so a change of the vector bent a track whose second vector stood off the chord sideways already, though
the simulator draws it straight. follow() and follow_grade() keep a path drawn straight bent now only where its second
vector lay along the chord before the edit and stands off it after; a path drawn bent is kept bent as before. How far the
vector stands off the chord is measured in one place, keep_bent() uses it too.

* docs(editor): the comment of keep_bent above keep_bent again, not above the measure of the chord

* Editor: signal reads kept by the signal, level crossing discs, signals out of the gauge, indicators, the signalling tools split (#307)

* fix(editor): the read of a signal stays by it as its track is split, on a switch and when it is moved, and a level crossing disc is placed

The trains find a signal by its read, a passive event in a list of the track, and measure the way to the cell it reads along three
tracks further at most. The editor let the read drift away from the signal, or put it where trains of another path read it.

- A track split in two: a read the trains scan for (a passive event) goes to the piece by the point it reads, whatever its list;
  before, those of the runs towards the end stayed on the first piece. Five splits left the reads of A, B, C and J on the first
  piece while the signals stood on the sixth, out of the reach of the trains. The reads of signals placed since the scenery was
  opened, not bound to an event yet, go to the piece by their signal the same way.
- A signal moved off its track jumped back to that track's end once the track was changed: the track had taken it up as its
  object and measured it again along itself. A moved signal is let go by the track it stood by, and an object of a single point
  moved off the side of its track no longer follows it.
- A switch reads its events to the trains of both its paths. A signal past the frog of a path, where the axes are a gauge apart,
  is passed by the trains of that path only, so its read goes to the track joined to the far end of the path, in the list of
  the trains running from the switch onto it or the other way. Before the frog it stays on the switch. Moving the signal across
  the frog takes the read between the two.
- A signal by a switch on the side of its other path stood on that path, in the way of its trains (0.45 m from its axis); it
  is refused there, placed or moved, with the reason.
- The kind crossing of the descriptions (tsosp, tsospn) is known: the level crossing disc is listed in the palette and placed
  with its read.

Checked in the editor on a hidden desktop: five splits of a track with bound and fresh reads, a signal moved to another track
and the old one raised, signals placed before and past the frog of a switch on both paths, turned and moved across the frog,
saved and opened again with the reads bound, the tracks raised, shifted and bent with the signals following. Unit tests pass.

* fix(editor): a split keeps reads far off the path and bound objects up to 30 m by their pieces

A read the trains scan for moves to the piece by the point it reads only from event1 and event2, only
when it isn't ignored and only when that point is within 50 m of one of the pieces; a read at the
station building stays in its list. An object bound by hand keeps its binding as its path moves up to
30 m from it, an adopted one up to 12 m as before.

* feat(editor): the tracks that read a signal are drawn and can be picked, flipped or dropped

The selected signal shows each read of its _sem_info as a thick band over the reading track, arrows
in the way the read is scanned, a line from the foot of the signal and a plate with the list and the
track; the hovered one shows them thinner and placing or moving a signal shows where it will be read.
The panel lists the reads: each can be turned the other way or removed, "Pick the path" takes a
click on a track (with Shift one read more or less) and "By the path it stands by" puts back the
read the signal gets when it is placed. Each change is one step of the undo.

The self-test gets signalread, signalreadflip, signalreaddrop and signalreaddefault, and the probe
lists every read of a signal.

* fix(editor): a moved or turned signal keeps the reads picked by hand, and a read set again isn't an undo step

Moving a signal, taking it across the track or turning it put back only the read by the track it
stands by and dropped the others: those stay on their tracks now, on the other list when the signal
is turned. Setting the reads the signal has already says so and adds no step to the undo. Picking a
reading track disarms the template, so a click after Esc doesn't place a signal, and the signals
are listed again after any change of the history, also once it is full.

* feat(editor): a signal is placed out of the gauge of the tracks around it

As a signal is placed, moved, taken across or turned, its models are measured against the gauge
chosen in the Gauge window along every path near it. One that enters it is taken sideways, away
from the axis of the track whose gauge it enters, as deep as it went in and 3 cm more, in the same
step of the undo; between two tracks too close for it, it stays where it was put and the status
tells which gauge it enters and how deep. A gantry is only measured.

The panel of the selected signal tells when it stands in the gauge, with a button to move it out,
and the view marks the deepest place. The gauge tool measures any models against the paths around
them for it. The self-test places a signal at a given offset and its probe tells the gauge.

* fix(editor): a moved signal leaves only the read of the track it stood by, and the gauge is checked on its level

The reads a moved signal keeps were all but the first one listed, which is the first track of the
scenery having it, not the one the signal stood by: a read picked by hand could go and the track
it left could keep it. It is the read of the track it stood by that goes with it now, and turned,
eventall1 and eventall2 swap as well. A track more than 2 m above or below the foot doesn't push
the signal aside, the status tells the real distance it went, the gauge is measured again when the
signal follows a dragged track, and the marker in the view shows only what is up to date.

* feat(editor): indicators put on a signal from the panel, they move and go with it

The indicators of scenery/pkp/wskazniki described as "category: indicator"
are offered under the selected signal, grouped by their sign. One is put
in as an include named after the signal, on the srk layer:

- a lit one (place: head) under the lowest lamp of the signal, 0.73 m
  below it and 5 cm ahead of the mast, each next one 0.45 m lower; a dwarf
  signal is refused, it has no mast for one;
- a plate (place: foot) at the foot of the signal, its model has its place
  by the mast built in.

The panel lists the indicators standing by the signal with a Remove
button. They are found as the includes whose first parameter is the
signal's name, within 1 m of it in plan. When the signal is flipped,
turned or moved, they keep their place in its frame, in the same undo
step; deleting the signal deletes them too. If the signal and the
indicator both define an event, the status says so, since the scenery
keeps only one of them.

The self-test gets signalindicator and signalindicatordrop, and its
signalprobe gives each indicator's height and the height of the lowest
lamp.

* feat(tools): indicator descriptions and the indicators taken out of the signal templates

indicator_headers.py writes //$e descriptions into the LED indicators of
scenery/pkp/wskazniki (W19, W20, W21, W24, W26) with the events each
shows. It also makes the indicators that were so far only built into the
signal templates:

- W1 of the warning discs, new, old and with the light strip;
- W1 and W18 (new and old) of the block signals;
- the I, II and III plates of the repeaters.

The plates fixed flat to the mast are moved 4 cm ahead. Their back is
5 cm from the mast's axis, while the mast is 6.1 cm thick and its clamp
under them 8.3 cm, so the mast went through the plate, in the templates
too.

* fix(editor): a signal turned or moved by the gizmo is read and kept out of the gauge, its indicators go with it everywhere

The gizmo of an include only rewrote the numbers of a signal. Its read stayed on the event it had, even when the signal was turned
to the trains of the other direction. Its indicators stayed behind, its height could be dragged off the ground, and the gauge
wasn't checked. Now:

- the gizmo moves a signal in the plan only, at the height it has;
- while it is dragged, its indicators keep their place by it;
- once it is let go, the drag is made again as a move of the signal tool, one step of the history: the read goes to the event of
  the trains it faces on the path it stands by, and it is taken out of the gauge;
- dropped away from every track, it goes back where it stood.

The indicators of a signal are found in the scenery now, not in the list the signal tool keeps up only while it is open:

- deleted from another tab, the signal takes them with it;
- a signal renamed in the node properties gives its new name to them in the same step of the history;
- in the station and line batches, a renamed signal renames them, and a removed one removes them;
- the binding of objects to tracks puts them on the path reading their signal, not on the one nearest to them, and a signal moved
  by hand lets go of them too.

Also:

- a signal on a gantry takes no indicator from the list;
- an indicator a signal has already isn't put on it twice;
- the signals and their indicators are found in one pass over the includes, the indicators by the name of their signal;
- a step of the history with tracks is always one of their edit, so they are taken back with the includes.

The self-test gets signalgizmo, which turns and moves a signal as the gizmo does.

* fix(tools): indicator_headers.py keeps the files it replaces, writes beside the data on request

- An indicator it made, found changed, is put into a tar in editor_backup before it's written again.
- --sidecar writes the descriptions of the lit indicators into editor/templates, as the other header scripts do, the files of
  the game left alone.
- The indicators it makes are copies: the signal templates keep their own, and the docstring and the files say so.

* fix(editor): a signal moved by the gizmo by another track is read by it, the templates known without the signal tool

- At the end of a gizmo move the nearest track takes the signal when it is nearer than its own by more than 0.5 m; a track it
  was dropped onto, within 1.2 m of its axis, doesn't, so a signal only turned between two tracks or dropped onto one in a
  switch keeps its own.
- The signal templates and indicators are looked for when a signal is renamed or its gizmo shown, so its indicators follow
  without the signal tool opened first.
- A drop refused puts the gizmo and the node properties back where the signal stands.
- The indicators follow only once the gizmo made its step, and the ones not changed are left alone: grabbed and let go it
  changes nothing.

* fix(editor): a signal dropped by the gizmo onto a track keeps its own, the gizmo doesn't wait for the template scan

- When the nearest path to the drop is within 1.2 m of its axis, the signal keeps its own track, instead of only that path
  being left out: dropped onto a middle track it no longer goes to the track beyond it.
- The gizmo starts the signal template scan without waiting for it, so a rescan with a signal selected doesn't stop the
  editor; renaming a signal still waits.

* feat(editor): the signalling split into Signals, Station, Station signals and Line block

The one Signalling tool held the signals placed by hand, the whole wizard of a station and its checks; each is now a tool of its
own in the toolbar:
- Signals (I): the palette, a signal placed by a track, dragged along it, selected; a click on a switch no longer opens a station.
- Station: LMB on a switch lays the station out; its name, code, line, km, speed and braking distance, the numbers of the
  switches, the track circuits, the number of the selected track, the list of the switches.
- Station signals: the signals of the whole station placed at once, the template of each of their kinds (main, shunt) chosen in
  a table, and below what the signalling lacks: the repairs, the SHP resonators, the track lengths, the signal heads.
- Line block: the block of each line, the block boundaries drawn by hand, the line signals, the templates of the block signals
  and warning discs.
The station tools share the open station and its schematic; Station signals and Line block show what the Station tool set for
it, the line and the km in red where the line block needs them. The template table replaces the palette in the station
tools, so choosing a template there no longer arms placing. Two icons drawn for the new tools, in editor_icons.py too; the
png is drawn by the same shapes, Pillow wasn't at hand. The tracktab self-test takes a tool by its name, and srkopen shows the
Station tool.

* feat(editor): a signal shows its distance from the track axis and to the switch ahead, and goes to 50, 100 m... from it

- editor/editorTrackTrace: the track followed the way a train runs, shared by the W17 markers and the signals. The fouling
  point of a switch (where the axes of its tracks are 3.5 m apart) moved here…

* fix: a failed start says why and ends with an error code; a small crash dump by default (#425)

* fix: a failed start says why in the log and ends with an error code

When the window could not be made, the log only said "Bad init: failed to
create glfw window", without the reason glfw knows (no OpenGL driver, no
pixel format that fits, no EGL). Sometimes it did not even say that: the
log thread writes every 50 ms, and main() ended the process with
std::_Exit(0) without stopping it, so a start that failed within that time
left a log that ends at "// startup".

- glfw's errors go to the log and errors.txt through glfwSetErrorCallback,
  set before glfwInit(); each distinct message once.
- after a failed start (or an exception caught in main) the log thread is
  stopped and waited for, as the test runs already do, so nothing logged
  last is lost.
- a failed start ends with exit code 1 instead of 0, so the starter can
  tell it from a closing. A start that worked ends as before.

* fix: glfw's errors told during the start only, a closed crash dialog is no failed start

After review of the previous commit:

- the glfw error callback is taken off at the end of init(). Once the
  simulator runs, glfw would only repeat what the platform can't do
  (glfwSetCursorPos on Wayland, on every mouse-look) or what a scenery
  asks for in vain (launcher key codes below GLFW_KEY_SPACE, checked on
  every update), which would put new lines in errors.txt of existing
  sceneries and cost a format and a lock per call.
- closing the crash-report window ends the simulator as before, but
  init() now returns 1 for it (above 0: closed by the player), and only a
  result below 0 gives exit code 1.
- a start that throws from init() (bad_alloc, or a runtime_error on
  Windows) ends with exit code 1 too; an exception after a start that
  worked ends with 0 as before.

* feat: a small crash dump by default, the full one with "crashdump.full yes"

The dump written by the crash handler (Windows, WITHDUMPGEN) held all the
memory of the simulator (MiniDumpWithFullMemory), so it was as large as
the memory the simulator took: gigabytes on a large scenery, written to
the game folder at the moment of the crash, on machines with 8 GB of RAM
too.

By default it now holds the stacks with the memory they point to, the
threads, the modules, the handles, the memory map and the modules' data
segments (MiniDumpWithDataSegs in place of MiniDumpWithFullMemory, the
rest of the flags as before). The globals, Global among them, stay
readable. "crashdump.full yes" in eu07.ini writes the full dump as before.

Measured on td.scn with a ghostview camera (1.2 GB committed): the small
dump 44 MB in 2 s, the full one 1.6 GB in 19 s.

The key is new and optional: eu07.ini files without it read as before,
and the setting is listed in the log at start.

* fix: the small crash dump keeps the process and thread blocks

MiniDumpWithProcessThreadData adds the PEB and the TEBs, a few KB: the
command line (the scenery and the vehicle), the environment and the last
error of each thread, which the small dump otherwise lacks, since the heap
behind Global's longer strings is not in it.

* fix: an exception that ends the simulator says what it was in the log

After review of #425:

- the exceptions main() catches are logged ("Critical error: ..."): on
  Windows the runtime_error that only showed a message box, and on the
  other systems any std::exception, which used to end the simulator
  through std::terminate with no word in the log. On Windows the others
  are still left to CrashHandler, whose dump shows where they were
  thrown.
- every exception caught there ends with exit code 1, in the start or
  later, as a crash; it used to be 0 when caught, the abort code when not.
- closing the crash-report window logs "Crash report window closed,
  closing" instead of the error "Failed to run crash gui!", which stays
  for a result below 0.

* feat: the stack of a crash on Linux in the log and on the standard error

On Linux no dump is written (the crash handler is Windows only, crashpad
is off), so a crash left a log that just stopped.

A handler of SIGSEGV, SIGBUS, SIGFPE, SIGILL and SIGABRT (installed at
the start of main) now writes, with write() only:

  Crash: signal 11 (SIGSEGV) at address 0x...
  Version: EU07 (cmake), <hash> (...)
  Stack (addr2line -f -C -e <the eu07 file of this version> <offset>):
  <backtrace_symbols_fd>

to the end of the log file (its whole path, set when the log opens it)
and to the standard error, which StarterNG shows first. The Linux builds
carry their symbols (GENERATE_PDB adds -g, nothing strips them), so
addr2line on the eu07 file of the same version gives the files and lines.

Then the signal ends the process as before (SA_RESETHAND, raise): the
same exit status, and a core dump where the system makes one. The
handler runs on an alternate stack, so an overflow of the main thread's
stack is reported too; backtrace() is warmed up at install so it doesn't
allocate in the handler, and alarm(5) ends a handler that hangs (a crash
in the allocator or the loader). WAMR is built without its hardware bound
checks, so it installs no SIGSEGV handler of its own.

Elsewhere crash_signals does nothing. A unit test (Linux only) crashes a
child process and checks the report on its standard error and in the log,
and that the child still ended by SIGSEGV.

* fix: the crash report can't be cut by a second crash signal or end with SIGALRM

After review:
- the five crash signals are blocked while a report is written, so a
  second one waits rather than starting a second report in its middle
  (a fault that comes while blocked still ends the process).
- a report that hangs past alarm(5) ends the process by the signal of
  the crash, not by SIGALRM: a SIGALRM handler, set only in the crash
  handler, raises the crash signal and unblocks it.
- the child of the unit test calls alarm(10) first, so a child stuck
  before the crash can't hang the build.

---------

Co-authored-by: maj00r <maj00r@host>

* feat(track): unevenness waves shaped by the track spectra of FRA and ORE B176 (#426)

* feat(track): unevenness waves shaped by the track spectra of FRA and ORE B176

The waves were 5-42 m sideways and 8-83 m vertically, with the long ones
cut down, so a short wavelength carried a large share and the ride and
the rails looked busy. They are now 7-90 m sideways and 8-110 m
vertically, about the bands D1-D3 of EN 13848, each wave standing for a
band of the spectrum S ~ Wc^2 / (W^2 (W^2 + Wc^2)), Wc = 0.8245 rad/m,
the shape the FRA and the ORE B176 (German) spectra share: the longer
a wave, the higher it is.

The "uneven" value keeps its meaning, the peak deviation of a rail on a
10 m chord as PLK Id-14 measures it, so the values in sceneries stay as
they are. Since the chord sees the long waves less, the amplitudes are
calibrated again, and apart for the vertical and the sideways waves:
stray_per_mm becomes stray_up_per_mm 0.00229 and stray_side_per_mm
0.0031, and cross_share 0.35. A track at "uneven 18" measures 18 mm
vertically, 17 sideways, 15 of twist, +-10 of gauge, 21 of cross level
and J 5.7 against the Id-14 limits for 80 km/h. A rail now goes up to
about 5 cm off its design over the long waves, so the bound of the test
goes from 40 to 60 mm; the short waves the cab shakes on are smaller,
the sideways bend under the axles about 30% less.

Every scenery with unevenness looks and rides differently after this.
No release has unevenness yet. The grading tool follows the vertical
waves; on Baltyk the pantograph keeps within 0.6 cm of the wire up to
the product 1150 of the vertical value and the speed (925 before).

* test(track): bound the sideways offset of an uneven track off its design

The longer waves move the track about 4.5 cm sideways off its design at
"uneven 18" (2 cm before), and nothing checked or stated it. The Id-14
test now bounds the peak sideways offset of the middle of the track
below 5 cm, next to the vertical one, so a later change of the shares
can't double it unnoticed. The doc gives the figure, and names platform
edges and level crossing panels among what a rail moves away from.

---------

Co-authored-by: maj00r <maj00r@host>

* feat(editor): ~ shows or hides the orthophoto, Ctrl+~ downloads what the camera sees first; the speed of the camera in the View menu (#312)

* feat(editor): ~ shows or hides the orthophoto, Ctrl+~ downloads what the camera sees first; the speed of the camera in the View menu

~ (the key left of 1) turns the orthophoto on and off. Ctrl+~ finds what of the ground the camera sees (rays through a grid
over the screen down to the level of the ground under the camera, or as far as 2.5 km where they don't come down to it) and
puts those tiles at the front of the queue of the downloads, the ones which failed tried again at once; the status line
tells how many. Tab is not used, the laying and the switches have it.

View > Camera speed: the speed of the free camera of the editor (x0.05 to x10, 1 as it was), how many times faster Ctrl makes
it (1 to 30, 30 as it was), and in the top view as fast as the view is zoomed, so the map crosses the screen at the same pace
zoomed in or out. Kept in the settings of the editor; the camera of the cab and of the free fly outside the editor unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* fix(editor): Ctrl+~ in the top view, over a scenery with no terrain under the camera and with the orthophoto off; "As it was" without the speed going with the zoom

In the top view the box is the view itself, its corners on the ground. The ground under the camera is the terrain, else the
scenery, else the rays go as far as the reach. The tile of the camera is taken anew by hurry(), it isn't followed while the
layer is off. The top view is as fast zoomed in as out by default, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* fix(editor): the corners of the top view on the ground put where the camera is (the view matrix is camera-relative)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* i18n(editor): Polish for the orthophoto keys and the camera speed, on top of the master's own translations

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDcMn1Q7wdYkbxDUWscNHZ

* fix(editor): Ctrl+~ asks only for the tiles update() would ask for; the tooltip of "Track colours" back in its place

After the reviews of #312:
- hurry() skips the tiles outside the download area set and marks the ones outside the area the service covers
  as empty, as update() does, so Ctrl+~ no longer queues downloads update() drops at once (and the workers took
  anyway, into the disk cache, against the area set), nor requests the service can't answer.
- A blank tile hurried takes the standard image first, as in update(); first_level() and outside_area() are
  shared by both loops, and the body of the loop of hurry() is hurry_tile().
- orthophoto_hurry() takes the level of the terrain only when it's below the camera, as the branch of the
  scenery already did: a camera under the terrain (a tunnel, under the heightmap) no longer flips the box of
  the view behind it.
- The "Camera speed" menu goes after the tooltip of "Track colours", which it had taken.
- #include <set> once in editorOrthophoto.hpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QRgQ1K1Qu7TCsa74zsNURd

---------

Co-authored-by: Claude <noreply@anthropic.com>

* fix: whole-number bounds of Random() give a real number again (#416)

* fix: whole-number bounds of Random() give a real number again

ee3af0bf (#99, in 26.05.2) renamed RandomInt to an overload,
Random(int, int). The calls with whole-number bounds that expect a real
number in between took the overload and draw whole numbers since:

- wheel flats given with P0 happen to 1 vehicle in 101 (before: none),
  the random part of a flat is a whole number of millimetres;
- the chance of truck hunting is h/101 instead of h/100;
- the wind starts with a whole azimuth, speed and rates of change, and
  its direction changes in whole degrees per second;
- the tachometer below 5 km/h jumps to whole numbers.

The whole-number draw is RandomInt again, keeping the shared engine and
the swap of inverted bounds; the loading screen's trivia use it. Those
calls take the real Random() again, as up to 26.05.1.

* RandomInt: the comment says what it draws and why it has a name of its own

The comment put the bug on the overloading. It was in the calls that pass
whole-number bounds and expect a real number; the separate name keeps
them on Random(double, double).

* fix: RandomInt draws from the local engine, as up to 26.05.1 from one of its own

From the review of #416: ee3af0bf moved RandomInt from an engine of its own
(std::mt19937 seeded by std::random_device) to Global.random_engine, the
engine of the run's seed, and only the name was taken back here. Its one
caller draws the trivia of the loading screen, in init_modes, before a
network client gets the seed of the session in server_hello: the server's
engine was then one draw ahead of the client's, and with a fixed
randomseed the trivia was the same on every start. It is drawn from
Global.local_random_engine now, the engine of what one machine shows,
seeded from a true random source in init_modes before the loader is made.

The test of the same seed checks the shared engine with Random() and the
local one with RandomInt(); a new test checks that RandomInt() doesn't move
the engine of the run's seed.

---------

Co-authored-by: maj00r <maj00r@host>

* fix(editor): the orthophoto only on the chunks of the heightmap terrain in memory, and laid onto the ground again once it comes (#417)

* fix(editor): the orthophoto only on the chunks of the heightmap terrain in memory, and laid onto the ground again once it comes

Right after the editor started, the tiles of the orthophoto came from the disk cache at once and were fitted to the ground before
the chunks of the heightmap terrain had come (on IRT the orthophoto was on at 24.5 s, the first chunk came at 24.5 s, the last one
at 85 s). A tile with no ground under it, and none beside, stayed flat at the height of the layer (0 m, some 230 m under IRT);
one partly over the ground had its holes filled from the points beside. Neither was fitted again when the ground came: only the
guessed tiles were, by their middle and corners alone, and a tile with no chunk under it at all never got any. The overlay,
drawn over everything, then slid with the camera (WASD, turning) instead of lying on the ground. Turning the orthophoto off and on
hid it: by then the terrain was in and the tiles took their heights from it or from the edges of the tiles beside.

- With the heightmap terrain (the terrain streamer active), a tile of the orthophoto, of the WMS layers and of Ctrl+~ is asked
  for and shown only where its chunks are in memory (terrain_streamer::ground_under): it waits while one is still to come, and
  where no chunk is nor will be there's no imagery at all. A scenery without the heightmap terrain is as before.
- A tile remembers the points of its grid the ground didn't answer and is fitted again once the ground comes under any of them
  (every second point and the edges), not only the guessed tiles.

No asset changes.

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

* fix(editor): the orthophoto waits only for the chunks that will come at this distance, and lies on the other ground or the guess elsewhere

After the reviews of maj00r and jerrrrycho on #417:

- A tile is no longer dropped where no chunk of the heightmap terrain is nor will be. There it lies on whatever ground there is (terrain models) or on the NMT guess, as on master; a scenery with a few chunks, or with chunks removed, keeps its imagery around them.

- A chunk counts as still to come only while it's being loaded or lies within the circle the streamer walks around the camera. The corners of the imagery in the 3D view, beyond that circle, no longer wait for chunks that won't load there: they lie on the guess and are sampled again when the camera comes near and the chunk loads.

- terrain_streamer::ground_under() (true / false / empty) became ground_coming() (bool), the cover source of the orthophoto the coming source, and on_ground() waits_for_ground(), which only holds back a new tile.

- In the scene (in_scene), the points a steep triangle leaves without a height but the heightmap terrain answers aren't kept as unanswered, so the tile isn't sampled again on every chunk that comes. The holes are counted from the heights again, as on master.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(editor): the closing doesn't wait for a geoportal service that doesn't answer (#432)

* fix(editor): the closing doesn't wait for a geoportal service that doesn't answer

When geoportal.gov.pl took the connection and never answered, the
editor's closing stood still for tens of seconds and was killed: the
WinHTTP client was synchronous and looked at the stop only between the
reads of a body, so a request waiting for the answer held the closing
for the timeouts (up to 20 s for the answer, a few tries a square),
and the map of the place-picker downloaded with no stop at all, its
std::async future waited for to the end.

On Windows the client now uses WinHTTP asynchronously: each step is
waited for while the stop is looked at every 50 ms, and a stop closes
the request at once. The timeouts, the user agent, the size limit, the
errors and the body of a response with an error status stay as they
were. The map of the place-picker is given up when it goes. libcurl
looked at the stop during the whole transfer already.

The unit tests run the client against a local server that never
answers (given up within 0.4 s of the stop), one with a body of
100 kB and one with an error status.

* fix(editor): the capabilities of a WMS service being added don't hold the closing either

The reading of the layers of a WMS service the user adds ran on a
std::async future of the editor with no stop: closing the editor while
such a service didn't answer waited for its three tries. The reading
is given up when the editor goes, as the other downloads now are, and
editor_http_get, left with no callers, goes.

The unit test's silent server no longer waits for the client to close
its connection, and the requests to the local server are skipped when
the environment names a proxy, which couldn't reach it.

* fix(editor): the stop of the WMS reading outlives the future waiting for it

The flag was declared after the future of the reading, so it was
destroyed first while the future's destructor still waited for the
task reading it.

---------

Co-authored-by: maj00r <maj00r@host>

* revert(environment): the turbidity of the sky as it was before #227 (#410)

#227 (842b7688) raised the turbidity of the sky dome for most cloud covers
(3 -> 4 for a clear sky, 5 -> 6 at 0.41-0.60, one more from 0.61 up to 0.90).
In the Preetham model a higher turbidity darkens the sky a lot once the sun is
below the horizon: with a cover of 0.47 the zenith is about a third darker
1.4 degrees below it and half as bright 3 degrees below, the stars come out
right after the sunset and the ambient light taken from the sky dome drops
with it. Players report the dusk as too dark since the update.

The values are put back as they were before #227, in the turbidity_of()
that #323 made of the old chain of conditionals. A clear sky gets the
turbidity 3 again, which #227 said breaks the model at night.

Co-authored-by: maj00r <maj00r@host>

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

This reverts commit d6c3593520.

---------

Co-authored-by: maj00r <73280030+maj00r@users.noreply.github.com>
Co-authored-by: maj00r <maj00r@host>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Hirek193 <polomarket73@gmail.com>
Co-authored-by: pol102 <mindak.m@icloud.com>
2026-11-22 09:55:09 +01:00
jerrrrycho 2f12768815 fix(timetable): the station of departure written in capitals is still a stop (#343)
The first row of a timetable, which usually gives only the departure time,
became a stop only when its name matched the relation's first station
case-sensitively. Os33733 of linia_107_poludnie.scn writes ZAGORZ in the rows
and Zagorz in the relation, so its driver counted Zagorz as passed at the
start, left before its departure time and the train manager never gave the
departure signal. The names are now compared regardless of case
(timetable::starts_at in the core library).

Tests: unit test of the rule; td.scn scenario cases with a timetable of the
case's own (first row STACJA1, and Stacja1 as control) and the td.scn train
started with its head 80 m past the W4 of Stacja1; the scenario runner can
copy a timetable of the case into the game for the run.
2026-11-20 16:35:59 +01:00
jerrrrycho 96bc3e6863 fix(cab): the compartment lights keyboard toggle works more than once in a cab without the switch (#353)
* fix(cab): the compartment lights keyboard toggle works more than once in a cab without the switch

The compartment lights get two requests, on (CompartmentLights.is_enabled)
and off (is_disabled), and the off one wins in LightsCheck(). The enable
and disable commands withdrew the other request only when the cab had a
toggle type compartmentlights_sw:. A push type switch and the separate
compartmentlightson_sw:/compartmentlightsoff_sw: push buttons withdraw
their own request when released, but a cab with none of these controls
(the CD 810 cab A, where only the engine compartment has the switch)
never withdrew anything: after one on/off both requests stayed set, the
lights stayed off and ctrl+; kept choosing "turn off".

Now a command withdraws the other request when the cab has the toggle
type switch (as before), or when it has no compartmentlights_sw: and no
push button for the other request, so the keyboard toggle acts as a
two-state switch there. Cabs with a push type switch or with the on/off
push buttons keep their behaviour. The decision is in
vehicle/compartmentlightsswitch.h, unit tested together with the
vehicle's LightsCheck() on the Elf definition.

* fix(cab): the compartment lights keyboard toggle latches in a cab with the on and off push buttons (#355)

In a cab with the compartmentlightson_sw: / compartmentlightsoff_sw: push
buttons and no compartmentlights_sw: (the EN57-2000, the SA134, the 214M,
the EN57AKL/AL/KM and EN71) ctrl+; turned the compartment lights off only
while the key was held. OnCommand_compartmentlightstoggle picked the
command from the lights' state again on the key release, after the press
had changed that state, so the release went to the other command: the
push button that was pressed never withdrew its request. After the first
press the on request stayed set, and from then on every release withdrew
the off request and the lights came back on.

The toggle now sends the release to both commands, as a release of the
push buttons would: each returns its own push type control to the
neutral position and withdraws its request. The press is picked from the
state as before. Mouse clicks on the push buttons go to the enable and
disable commands directly and are unchanged; with a compartmentlights_sw:
both commands release it the same way, and a cab without the controls
has nothing to release. In the Elf cab (an impulse compartmentlights_sw:
and the on/off return buttons) the lights worked, but the button the key
had pressed stayed pressed; now it returns too.

* test(cab): the compartment lights switch test without Sonar issues

using enum for range_t in the release helpers, and the lights declared
in the if that reads them. No change in what is tested.
2026-11-20 16:33:42 +01:00
jerrrrycho 97a6218094 fix(audio): measure the start offset on the buffer queued last, not on AL_BUFFER (AL_INVALID_NAME) (#350)
* fix(audio): measure the start offset on the buffer queued last, not on AL_BUFFER (AL_INVALID_NAME)

openal_source::update() looked up the buffer left playing after a multipart
sound's opening bookend with alGetSourcei(AL_BUFFER). For a source with
queued buffers that is 0 in OpenAL Soft 1.18 (the version the game ships),
and in newer versions once the source has stopped, so alGetBufferi(0) raised
AL_INVALID_NAME ("sound: al error: AL_INVALID_NAME" in errors.txt) and the
sample offset came from an uninitialised size. It happened every time a
sound with a start offset (the motor blowers of the EN76/EN96 family, with
start/stop bookends) went from its start sample to the loop.

The source now remembers the buffer it queued last and measures that one.
The offset itself is computed by audio::start_sample(), in the core library
with unit tests; it also keeps the offset inside the buffer.

* refactor(audio): the start sample without Sonar issues

The sample count is cast to float explicitly, as it was converted
implicitly. No change in behaviour.
2026-11-20 16:33:34 +01:00
jerrrrycho b24e87dc63 Cab: the light preset selector turns on past its end, with sound (#345)
* fix: the light preset selector turns on past its end with sound (eu07/maszyna#464)

A selector with Wrap=Yes turned past its last position to the first one (or
back) was set with PutValue(): no animation and no sound. On the EN57AKM these
are the positions 0 and A1. A knob whose positions make a full turn now turns on
the same way it was turned, sounding the position it reaches; other switches
still jump, but sound the position too.

* refactor(cab): the wrapping rotary switch without Sonar issues

The full turn and the way on are declared in the ifs that use them, and
the optional is tested with has_value(). No change in behaviour.
2026-11-20 16:32:55 +01:00
jerrrrycho 3cbb529d16 fix(scene): write the region cache through a temporary file, reject a damaged one (#351)
* fix(scene): write the region cache through a temporary file, reject a damaged one

The static geometry cache of a scenery (<scenery>.sbt) was written in place,
and only its 8-byte header was checked before it was used. A write cut short
(a crash, the process killed, the test mode's real time watchdog) left a
truncated file which every later start loaded as it was: the sections up to
the cut, then whatever the reads past the end produced, with the section
index used unchecked and the section size read and ignored.

- basic_region::serialize() writes <scenery>.sbt.tmp and renames it over the
  final name only when complete; a failed write is logged and the temporary
  file removed, the previous file stays.
- basic_region::is_scene() checks the whole layout: header, section count,
  every section index within the region and present once, and the section
  sizes adding up to the length of the file. A cut-short file is turned down
  there ("Bad file: ... ignored"), so the scenery loads from the text and the
  cache is written anew at the end of the load.
- basic_region::deserialize() checks the layout again, reads each section out
  of its own data (sectionsize bytes) and requires the section to use exactly
  that; sections are restored apart from the region and taken over only when
  the whole file was read, so a damaged file leaves nothing of itself behind.
  If the content is damaged although the layout holds, the default .sbt (the
  game's own copy of the text) is removed so the next start rebuilds it.
- A vertex count the rest of the data can't hold, a shape count running past
  the data, and a string cut short by the end of the data
  (sn_utils::d_str() looped forever there) now stop the read instead of
  allocating or looping on.
- The layout check and the write through a temporary file are in
  scene/regionfile.{h,cpp}, in the core library with sn_utils, and have unit
  tests (test_region_file.cpp).
- run.py also removes a <case>.sbt.tmp left by a run cut short.

The file format is unchanged.

* refactor(scene): the region file code without Sonar issues

write_through_temporary takes the writer as a template parameter, the
messages are built with std::format, the reading of one section moves
into a helper (one break per loop), and the test drops chained
assignments and implicit lambda captures. No change in behaviour.
2026-11-20 16:32:32 +01:00
jerrrrycho 040e600bf6 Test the 6Dg's power demand in steps of 5% on its real definition (#336)
* test: the 6Dg's power demand in steps of 5% on its real definition

The 6Dg's definition from the game data (6dg_v1/6dg.fiz, converted alone
with test_fiz.cpp; SVN r9630 gave its UCList line CtrlValStep=0.05) joins
the real vehicles of tests/unit/data/fiz. On it:

- the key loads as shipped, and the demand of the universal controller
  (eimic) moves by 0.05 per tap or per step of the held raise and lower
  positions, 20 steps from 0 to 1 and back, never in between nor past
  the ends of the table;
- with the engine running, the engine revolutions, generator power,
  tractive force and speed reached grow with the demand (0.25 to 1);
- without the key the demand moves continuously, as before #273.

* test: no empty loop bodies and emplace_back in the 6Dg power steps test (Sonar S1116, S6003)
2026-11-20 16:31:47 +01:00
jerrrrycho da1f10d6b7 feat(cab): i-compartmentlights: lamp showing the compartment lighting (#352)
A cab lamp keyword for the .mmd, lit while the compartment lighting of the
cab's own vehicle (mvOccupied) is on: CompartmentLights.is_active, which
LightsCheck() works out from the low voltage power and the compartment
lights switches. Bound like i-cablight: in the autolights table, so it is
bound again whenever the cab's .mmd is read on a change of the occupied
vehicle. No vehicle uses it yet.

Unit tests of the state the lamp shows on the real Elf definition.

Refs eu07/maszyna#456.
2026-11-20 04:38:31 +01:00
jerrrrycho 18143c2254 feat(event): putvalues Crew:<vehicle> puts an AI driver in a vehicle or takes it off (GE#510) (#422)
* test: scenario runs convert no models in the game dir

* feat(vehicle): rules of the crew command of putvalues events

Crew:<vehicle> <cab> <flags> (eu07/maszyna#510): reading the command,
what gets done in each state of the vehicle, and the state a train is
left in when the driver in charge of it is taken off. Core library,
with unit tests; nothing calls it yet.

* feat(event): putvalues Crew:<vehicle> puts an AI driver in a vehicle or takes it off

event <name> putvalues <delay> none 0 0 0 Crew:<vehicle> <cab> <flags> endevent
(eu07/maszyna#510): cab 1 or -1 gives the vehicle named an AI driver in
cab A or B, the way the scenery creates one, 0 takes the AI driver off
and leaves the train with the power off and the brake valve in the
emergency position. A vehicle with a user in it is left alone, with a
line in the log. The vehicle is named in the text, so the event needs
nothing to set it off. Without the command nothing changes.

* test: scenario checks on the driver and the speed of a vehicle in the black box

* test: scenario cases of the crew event on td.scn

A driver appears in cab A and in cab B of a standing locomotive and
leaves with it, a train on the run loses its driver and stops (EU07,
EN57, Vectron, SM42), a driver is replaced, and the commands which have
to be refused change nothing about a timetable run.

* feat(event): road vehicles take a driver from the crew command too

They have no driver's brake valve, which is what tells a cab in a rail
vehicle, and any of them is driven from its own seat.

* test: scenario case of the crew event on a car

stops_driverless holds until the vehicle gets a driver again, not only
to the end of the recording.

* fix(event): the crew command clears the driver from every vehicle in its charge

A coupler broken under force or in a collision parts the train without clearing
the owner of the vehicles parted from it. When the driver was taken off, these
kept a pointer to the deleted driver. All vehicles are now looked at, not only
the ones still coupled. The log tells how many vehicles the driver let go.

* test: scenario case of the crew event on a train parted by a broken coupler

A new black box check, parts, tells two vehicles came apart in the run.
The case parts an EN57-2000 unit by a hit at 100 km/h and takes its driver
off: the driver had the parted car in charge too, and lets it go.

* fix(event): one vehicle in the log line of the crew command
2026-11-20 04:24:48 +01:00
jerrrrycho b9737fe76d docs: coverage of the parser, the helpers and the PLC with their tests (#338)
Numbers of the Coverage run of master bac9954a, after #333: ladderlogic.cpp
4.1% -> 98.2% of its lines, parser.cpp 40.0% -> 97.6%, utilities.cpp 28.2% ->
95.5%; and the first numbers of brakesetting.cpp and odometer.cpp.
2026-11-20 03:44:50 +01:00
jerrrrycho f398c0039d fix(odometer): a save lost to another simulation's save is written again (#354)
Two simulations sharing eu07_odometers.txt could lose a save: A reads the
file, B renames its file in, A renames its own over it. B had already
cleared its modified flag, so its next save returned at once and its
states stayed lost (known limit from the review of #283).

A write now leaves the store unconfirmed. The next save with nothing
recorded reads and merges the file as before, and writes again only when
the file lacks a state of the process, the same or newer by the merge
rule (compared as written, rounded to the file's digits). Otherwise the
store is confirmed and later saves return at once, as before. A process
holding an older state takes the file's one, so two processes settle
instead of rewriting each other.
2026-11-20 03:43:57 +01:00