17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 13:19:20 +02:00
Commit Graph

3138 Commits

Author SHA1 Message Date
maj00r
321c9dd7ab Editor: fold the plan library into the tree as modules, drop its own name
The track layout library came in as a subproject of its own -- its own
CMakeLists, its own install and export rules, its own include tree -- which only
made the build harder to follow now that everything else is a module. It is part
of the editor, so it lives where the editor lives.

- editor/plan_*.cppm / plan_*.cpp: the fifteen interface units and twelve
  implementation units, flat in editor/ beside editorTerrain and orthophoto, with
  the plan_ prefix keeping them clear of what was already there (editor/turnouts
  is the preset catalogue, so the geometry is plan_turnout_geometry).
- modules are named eu07.editor.plan_*, like every other module in the tree.
- namespaces move under the editor's own: editor::plan, editor::plan::geometry,
  ::io, ::render. The library's old name is gone from the sources and the docs.
- every moved file carries the MPL header the rest of the tree carries; it had
  none. version.hpp went with the subproject: macros only, and unused.
- the umbrella header is dropped -- nothing imported it.
- the unit tests survive the fold: editor/tests, behind EU07_EDITOR_PLAN_TESTS
  (off by default), compiles the interfaces a second time into a small library of
  its own, because a test can only import modules from a target it links and
  linking the game would drag the whole simulator in. The code under test needs
  nothing but a compiler. 7/7 pass.
- a switch may now be written with two dashes as well: --editor beside -editor.

Builds with clang 22 (-DWITH_BETTER_RENDERER=OFF); -editor and --editor both come
up in the editor on empty ground.
2026-09-13 13:31:01 +02:00
maj00r
c15e200e37 Merge the track layout editor into cpp20-modules, ported to modules
The editor branch was written against headers and the PCH, both of which this
branch has done away with, so its own files were ported rather than merged: the
five headers it added are now interface units and their .cpp files module
implementation units.

- editor/{puwg1992,polandmap,turnouts,orthophoto} become eu07.editor.* modules,
  application/planpanel becomes eu07.application.planpanel. The plan tool keeps
  to its own module rather than joining the eu07.simcore partitions: it stands on
  the editor's libraries and eu07.application.uilayer, not on the simulation core,
  so :editoruilayer can export import it without a cycle.
- glm arrives by import eu07.glm, never by include, as the rest of the tree does.
  maj0sted is header-only and glm-free, so its headers stay includes in the global
  module fragment - every unit that names those types includes them itself, since
  a global fragment is not visible across units.
- the one textual conflict was :editoruilayer's include block against this
  branch's imports; resolved this branch's way plus the planpanel import.

Builds with clang 22 (-DWITH_BETTER_RENDERER=OFF) and starts into the editor on
empty ground with -editor alone.
2026-09-13 12:36:21 +02:00
maj00r
3bdd5d8e90 start without scenery flag 2026-09-13 12:44:48 +02:00
maj00r
63a66628f7 let clang find the Windows SDK on its own
The failing chain showed the same directory reached two ways - one
spelling with doubled separators, one without - so #pragma once did not
recognise the file and the SDK headers were parsed twice: every COM
interface then looked like a uuid mismatch and BroadcastSystemMessageEx
like a conflicting redeclaration.

vcvars64 was putting the SDK in INCLUDE while clang was also locating it
itself. Dropped the vcvars call; clang's own detection is enough, and one
spelling means the include guards work.
2026-09-10 17:11:54 +02:00
maj00r
61b3ec6f3f parse windows.h before any import reaches betterRenderer
Six module interfaces carry windows.h in their fragment, and a fragment's
include guard does not cross the boundary, so a unit that imported first
and included the SDK afterwards parsed it twice: clang reports it as
conflicting redeclarations of BroadcastSystemMessageEx and mismatched
uuids all through the SDK. Same shape as the basic_filebuf failure, one
level further out - the header arrives through d3d12.h, not directly.

Thirty units get a guarded windows.h ahead of everything; on Linux it is
a no-op. Vendored single-header libraries are left alone, and the block
goes after a BOM rather than before it.
2026-09-10 15:40:52 +02:00
maj00r
eff5ce687f keep the version resource ASCII
The BOM did not help: CMake preprocesses the .rc with clang before
handing it to llvm-rc, and the marker does not survive that, so llvm-rc
still met a byte it refuses to guess at. Dropped the diacritic from the
file description - it is metadata for the properties dialog.
2026-09-10 15:22:35 +02:00
maj00r
3daf984a64 put audit --fix includes in the fragment, not the purview
The inserter aimed at the spot before the first import, which in a module
unit is past the module declaration - so the includes landed in the
purview, attaching those declarations to the module, and re-running piled
up duplicates. It now targets the global module fragment for module units
and keeps the before-first-import rule only for ordinary units.
2026-09-10 14:37:03 +02:00
maj00r
9ea57e0525 fix the Windows-only sources and the resource encoding
LPT.cpp and PoKeys55.cpp never imported the modules holding WriteLog,
ToLower and contains. Neither file is compiled on Linux, so nothing had
caught it; Console.cpp, which is built the same way, already had its
imports.

eu07.rc.in was stored in CP1250 - the o-acute in "pojazdow" is a single
0xF3 byte. rc.exe guessed a codepage, llvm-rc refuses to. Re-encoded as
UTF-8 with a BOM, which both recognise.
2026-09-10 14:35:10 +02:00
maj00r
14b2e6dc6f define WIN32 when not building with the MSVC driver
Only Platform/Windows-MSVC.cmake passes /DWIN32; neither Windows-GNU nor
the GNU branch of Windows-Clang does. Switching drivers silently took the
macro away from every translation unit, and third-party code that tests
the unprefixed WIN32 took its non-Windows path: FSR2 defined wcscpy_s as
wcscpy, which then failed against the SDK's own three-argument call. asio
reads the same macro.

Defined before any add_subdirectory so every target sees it.
2026-09-10 14:24:15 +02:00
maj00r
5b4df01565 pick the AVX2 spelling by driver, not by platform
betterRenderer gated on WIN32, and WIN32 is true for clang's GNU driver
too, so /arch:AVX2 reached a driver that reads it as a file name.

Swept every compile and link option in the tree for MSVC-style flags
without an MSVC guard; this was the only one left.
2026-09-10 14:14:53 +02:00
maj00r
fcbf034a91 spell the delay-load flag for the driver in use
clang's GNU driver read /DELAYLOAD:dxcompiler.dll as a file name. CMake's
LINKER: prefix emits -Xlinker for it and passes it bare under MSVC.

The other raw linker flags in the tree sit inside if(MSVC), which is
false for this driver, so they never reach the command line.
2026-09-10 14:08:48 +02:00
maj00r
14e12582b6 give CMake forward slashes on Windows
CMake writes the compiler paths verbatim into CMakeRCCompiler.cmake and
friends, where a backslash starts an escape sequence, so %ProgramFiles%
arrived as "C:\Program Files/LLVM/..." and tripped on \P. Same trap
waits for the Python root at C:\hostedtoolcache.
2026-09-10 13:57:08 +02:00
maj00r
78c8961591 use clang's GNU driver on Windows, not clang-cl
CMake wires up C++20 module scanning for Clang only when the frontend
variant is GNU; for clang-cl it sets nothing and refuses to generate:
"the compiler does not provide a way to discover the import graph
dependencies". Not a missing tool, a hard gap - Compiler/Clang-CXX.cmake
guards the whole scandep block on the GNU variant.

clang++ on Windows still targets x86_64-pc-windows-msvc, so the ABI, the
SDK, the vcpkg packages and D3D12 are unchanged. CMake then takes the
GNU path and leaves MSVC false, which is what the /MD /Zi /O2 block wants
anyway; the version resource had to move to a WIN32 guard to survive.
2026-09-10 13:49:54 +02:00
maj00r
7daf200748 build Windows with clang-cl instead of MSVC
clang-cl keeps the MSVC ABI, so the Windows SDK, the vcpkg packages and
D3D12 all still link; only the front end changes. That front end is the
one whose module support has been giving way - global module fragment
merging and type completeness at a template's instantiation point.

Switches the job to Ninja, which is where CMake's module scanning is best
supported, with vcvars64 for the SDK paths. Ninja is single-config, so
the artifacts move from build/bin/<config>/ to build/bin/.

CMakeLists: the MSVC-only blocks tested CMAKE_CXX_COMPILER_ID, which
clang-cl reports as Clang, so the version resource, the icon and /utf-8
would have been dropped silently. They test MSVC now, which is true for
both. /MAP and /MP stay behind a real-MSVC check - the first is a
link.exe spelling, the second clang-cl rejects.
2026-09-10 13:35:35 +02:00
maj00r
96161dcacb include the platform header where Win32 types are used
windows.cpp and piped_proc.cpp reached windows.h through an imported
module's global module fragment, which does not cross the boundary.
LPT.cpp and zmq_input.cpp never had it at all - the first was in an
MSBuild batch that aborted before reaching it, the second is behind
WITH_ZMQ and has not been compiled by either CI job.

The earlier sweep only looked inside #ifdef _WIN32 blocks, but these
files are gated by CMake instead, so they have no such block.
2026-09-10 02:40:50 +02:00
maj00r
c158a5c3ee include windows.h where Driver.cpp calls CreateDirectory
The _WIN32 branch of the physics-log setup calls a Win32 API the file
never included; Linux takes the mkdir branch, so it never showed up
locally. Swept the tree for the same shape - Win32 calls inside _WIN32
blocks without windows.h - and this was the only one.
2026-09-10 02:21:33 +02:00
maj00r
02c6e6895e cover the units that are not module units
The template-header propagation only walked files with a module
declaration, so EU07.cpp, windows.cpp, export_e3d_standalone.cpp and
every betterRenderer source were outside it - including the file with
main(). They reach cParser and friends through eu07.simcore and
instantiate their templates without the headers those bodies name.

Adds audit_modules.py, which checks the whole tree for the seven classes
this migration hit; all seven are clean now.
2026-09-10 02:04:06 +02:00
maj00r
b8f040e6fd propagate template headers transitively, import Console where used
AnimModel.cpp reaches cParser through the simulation core, not a direct
import, so the previous pass missed it; the propagation now follows the
whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call
Console:: inside _WIN32 guards without importing eu07.console - invisible
on Linux, where those blocks are skipped.
2026-09-10 01:41:24 +02:00
maj00r
6550c88536 give importers the headers module templates need
A template defined in a module interface is instantiated in the importing
unit, where its body's types must be complete. A declaration reaching the
importer only through the interface's global module fragment is not
enough for MSVC: cParser::operator>> uses std::stringstream, and every
unit that parsed a float got an incomplete type.

526 headers across 161 units, derived from what each interface's template
bodies actually name.
2026-09-10 01:20:33 +02:00
maj00r
26501b0fd7 hoist standard includes above everything else
Ordering them before the imports in the same file was not enough: a
project header on line 1 can import a module several levels down whose
global module fragment already pulled in the same standard header, and
that include guard does not cross the module boundary. Putting them
first means the guard is set before anything can import.

Skips vendored single-header libraries and anything inside an #if.
2026-09-10 01:02:17 +02:00
maj00r
cfd1c1f318 repair the include reordering
The previous pass dropped imports into the middle of HR_RETURN's
line continuations, breaking nvrenderer_d3d12.cpp, and its scan gave up
on the first line of any file with a BOM - which is why nvtexture.cpp
still had five includes sitting after its imports. Rewritten to skip
macro continuations, tolerate a BOM, and insert only immediately before
the first import.
2026-09-10 00:52:06 +02:00
maj00r
1455583ab6 put every include before every import
A header first pulled in through an imported module's global module
fragment leaves no include guard in the importing unit - macros do not
cross a module boundary - so a later textual include parses it again and
MSVC rejects the redefinition. Redoes the betterRenderer sweep with
placement that stays out of #if blocks, which is where the previous one
dropped <fstream> and broke nvrenderer_d3d12.cpp.
2026-09-10 00:40:32 +02:00
maj00r
2695c8e525 include what you use in betterRenderer
Its sources reached the standard library through the project headers they
included; those are imports now. 178 headers across 56 files, plus 18 C
library headers elsewhere for memcpy/printf and friends. MSVC's STL does
not supply these transitively the way libstdc++ does.
2026-09-10 00:26:55 +02:00
maj00r
2896c2dd60 add the C library headers MSVC needs
Unqualified uint8_t/size_t and friends were reaching 24 units through
some other header on libstdc++; MSVC's STL does not do that, which broke
gl/ubo.cppm (and made its UBS_PAD macro look like garbage). Also
silences C5244, MSVC's counterpart to the clang warning about glm being
included in the module purview, which is deliberate here.
2026-09-10 00:10:52 +02:00
maj00r
7667d8d4d3 build betterRenderer against the modules
Verified locally now that Vulkan and DXC are installed: all 31 targets
compile. glm has to come from eu07.glm only - having it both as a plain
include and as an import made every overload ambiguous. nvrenderer.h is
self-sufficient, since register.cpp includes nothing else. Fixes the
vcpkg triplet, which was pinned to x64-windows.
2026-09-09 23:45:53 +02:00
maj00r
06f6c6035b let betterRenderer import the modules
The module file set moves to its own eu07_modules library: a target can
only consume C++20 modules by linking the target that owns them, and
betterRenderer is a separate add_library. Its project includes become
imports.

CXX_EXTENSIONS must match across the two - a BMI built with -std=c++20
is refused by a unit compiled with -std=gnu++20.
2026-09-09 23:30:34 +02:00
maj00r
ce5ee288ff fix the clang CI build
Every module unit now includes the standard headers it uses. Declarations
reaching a unit only through an imported module's global module fragment
are reachable but not visible, so ADL misses the free operators older
libstdc++ declares beside a type - reproduced on ubuntu 24.04 (libstdc++
13), where gl/vao.cpp could not compare vector iterators.

Also drops a stale editor/editorSettings.hpp from the MSVC source list,
which broke the Windows configure step, silences the deliberate
include-in-purview warning in the glm wrapper, and removes GCC support:
clang or MSVC only.
2026-09-09 22:52:28 +02:00
maj00r
f16b5deefb build with clang
Linux CI switches to clang 22; fixes what that exposed - export on
out-of-line member definitions, missing std includes, missing glm
imports. GCC 16 still builds.
2026-09-09 22:34:32 +02:00
maj00r
3f7960aad5 pch migration to modules [wip] 2026-09-09 20:35:26 +02:00
jerrrrycho
c3007e3237 ci: skip Sonar coverage gate 2026-09-06 15:02:10 +02:00
7a469190ca Merge pull request #168 from pwarszawski/whois-owner-fallback
whois: fall back to the consist owner in the +0/+7 mode too
2026-09-05 21:08:29 +02:00
3b061a1bf1 Merge pull request #171 from pwarszawski/event-name-registration-casefold
event names: fix registration/lookup casing mismatch for non-ASCII identifiers
2026-09-05 21:07:41 +02:00
76eede79aa Merge pull request #154 from MaSzyna-EU07/uart-independent-dynamic-brake
Add independent dynamic brake support (eg. Vectron) to UART controllers
2026-09-05 20:04:34 +02:00
fadcc2d666 Merge pull request #170 from MaSzyna-EU07/fix/reflections-and-burned-colors
Fix relfections on default shader and tonemapping
2026-09-05 20:03:31 +02:00
Piotr Warszawski
2dcae05c77 event names: drop redundant locale-dependent ToLower() at registration
make_event() lowercased the event name twice: cParser::getToken() already
folds ASCII via toLowerChar() (which intentionally leaves bytes >= 0x80
alone), then ToLower() ran std::tolower() over every byte on top of that.

With a non-"C" global locale, that second pass remaps cp1250 uppercase
accented letters (e.g. 0xAF -> 0xBF). Every lookup path - TTrack::AssignEvents(),
child-event resolution in multi_event, event-launcher name resolution -
normalizes only through the parser, so a registered name containing such a
letter can no longer be found: the track logs "can't find assigned event"
and the binding is silently dropped.

Removing the extra ToLower() makes the registration key match every lookup
site (ASCII-only folding, non-ASCII bytes compared verbatim), and matches
the direction toLowerChar()'s own comment already points at for UTF-8.
2026-09-05 19:10:58 +02:00
Piotr Warszawski
1ce576c0c6 whois: log the no-activator case instead of failing silently
A whois with no triggering vehicle previously just wrote nothing to
the target cell with no trace in the log, which is a real pain to
diagnose from the scenery side (this is exactly the kind of thing that
cost real debugging time on a station script recently).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-04 22:22:25 +02:00
Piotr Warszawski
7ead4f11b4 whois: guard against a null activator
whois_event::run_() dereferenced m_activator unconditionally in every
branch (this predates this PR). getvalues_event::run_() and
putvalues_event::run_() already guard the same way elsewhere in this
file; whois_event was missing it. Single early return covers every
branch, old and new.
2026-09-04 22:09:23 +02:00
Piotr Warszawski
4f47233a89 whois: fall back to the consist owner in the +0/+7 mode too
The +8/+16/+24/+32/+40 (and the new +48) modes all pick the reporting
vehicle the same way: the activator's own Mechanik if it's the primary
driver, otherwise the consist's controlling vehicle (ctOwner) - so the
event still resolves correctly if a wagon happens to trigger it ahead
of its locomotive.

+0 (train name / stations left / stop flag) predates that pattern and
never got it: it required m_activator->Mechanik directly and silently
wrote nothing otherwise. A whois hook placed where the loco doesn't
necessarily lead (e.g. a train that reverses direction, or one being
propelled) can have a wagon trigger the event first and the memcell
stays empty, with no error - hard to diagnose from scenery side.

Same owner-selection, same guard semantics (still nothing written if
neither the activator nor its consist has a controller), only the
source of the vehicle it reads from is widened.
2026-09-04 21:01:33 +02:00
6befd69968 Merge pull request #149 from combolek/getpf
state_manager: Optimize computation of pressure flow for Oerlikon ESt valves
2026-09-04 16:39:49 +02:00
maj00r
a9b561cd65 Merge pull request #162 from MaSzyna-EU07/bugfix/260825-00jor
make targetfps great again
2026-09-03 22:18:16 +02:00
jakubg1
db6296124b Merge pull request #166 from jakubg1/dev/revert_remove_instructor_panel
Revert "Remove training card window"
2026-09-02 12:37:40 +02:00
jakubg1
ba19db8715 Revert "Remove training card window"
This reverts commit 363b50c9c2.
2026-09-02 12:32:35 +02:00
jakubg1
4e35a5f45f Merge pull request #160 from jakubg1/dev/remove_instructor_panel
Remove training card window
2026-09-02 11:59:49 +02:00
jakubg1
a2f62c56ff Merge pull request #161 from jakubg1/dev/epfuse_engage_fix
Fix EP fuse auto-(dis)engaging
2026-09-02 11:59:30 +02:00
766a957527 Fix relfections on default shader and tonemapping 2026-09-01 20:41:06 +02:00
maj00r
61336a0660 sonar fix, registration to sbt.sources improved 2026-08-30 17:14:08 +02:00
maj00r
2376e4867b Editor: rebuild the plan library around a solved document, and bend turnouts onto curves
The library was a heap of half-built services - fitting, parallelism, niwelety,
an SVG writer - that never met each other. In their place is one authored
Document and one solver that lays it whole: tracks as element chains, turnouts
placed on them, and a Solution that is rebuilt from scratch every time and never
fed back into the document. What cannot be laid comes back as a diagnostic with
the number in it rather than as silence or a fitted-away error.

Turnouts are dimensioned the way the drawings dimension them. The blade follows
Koc's rys. 5.9 - the curve is theoretically tangent to the opornica at PR, the
blade starts at a with a planed nose of d, and A is where the rail stands u
thick - and a + d derived that way lands on his tablica 5.1. Bending follows
5.3.6: it rotates the triangle OBC about the centre of the turnout, so the
tangent t and the crossing angle stand and both radii follow from them. That is
Koc's (5.7) and (5.8) without coding either, and it puts a symmetrically bent
Rz 49E1-190-1:9 on the catalogue's Rlus 49E1-380,292-1:9. A rozjazd standing on
a curve is bent onto it; one on a track drawn straight can carry a bend of its
own. The szyny laczace take up the difference, because the switch and the frog
are only bent, not re-cut.

The plan panel draws all of it: the catalogue drawing of a type with its
construction points, the theoretical arc dashed where no rail runs, and the
blade nose as the straight it is cut as. Dragging a straight now stops where it
would pull the track out from under a turnout.

File format goes to m0s 6. Versions 3 to 5 still open.
2026-08-29 19:32:46 +02:00
maj00r
8cd42980e6 Switches: lay the pre-blade lead and the blade, not a tangent arc
A turnout's diverging track does not leave the through track tangentially. It
runs straight along the through track to the blade tip (odcinek przediglicowy),
breaks away there by the blade angle (kąt nagięcia iglicy, beta), runs straight
over the blade to its heel, and only then curves - through alfa - beta, not the
whole crossing angle - to the frog.

Give TurnoutSegment a turn_in: a signed heading break applied before the segment
is laid, which is the only way to express a track leaving by an angle rather than
a tangent. lay_turnout then places the lead, the break and the blade ahead of the
curve and hands the curve the angle that is actually left to spend; a zero blade
length keeps the break and starts the curve at the tip. Reject a blade angle that
is negative or already reaches the crossing angle.

All-zero blade figures lay exactly the old tangent arc from PR, so existing
layouts are untouched. Junction and turnout_preset carry the three new figures
through to the panel; the presets themselves still hold zeros until the Id-1
catalogue numbers are in.

Add test_turnout: the lead sits on the through track, the blade breaks by beta,
and the frog still lands on the full crossing angle and the catalogue length,
mirrored for a right-hand turnout.
2026-08-27 19:36:56 +02:00
maj00r
4ae24114ba Editor: pin the whole branch rigidly to its frog, not just the leaving straight
Pinning previously rewrote only the branch's first (leaving) straight to start
at the frog and run along the frog heading. Any straight appended behind it
stayed where the user drew it, so its gap fit was solved against a leaving
straight that had jumped out from under it — the appended fragment could end up
~1.4 km from the frog.

Move the branch as one rigid body instead: the leaving straight fixes the
rotation+translation onto the frog, and every appended straight rides along
under the same motion, so the shapes and inter-fragment fits are preserved and
the branch still meets the switch tangentially by construction.

Add a test that draws an L-shaped branch far from the frog and checks the whole
centreline lands next to the frog after pinning.
2026-08-27 19:36:55 +02:00
maj00r
707b4de2f4 Editor checkpoint: turnout domain service, web->editor rename, Id-1 templates
Checkpoint of the editor branch so work isn't carried loose across a branch
switch. Builds.

- maj0sted turnout geometry moved into the domain: domain::lay_turnout lays the
  diverging path (pre-blade lead, blade at beta, arc of alfa-beta, frog rail) and
  solve_junction is a thin adapter onto it.
- the maj0sted web/ tree renamed to editor/ (namespace and paths) - there is no
  WASM here, it's plain native C++ the editor calls.
- click places the switch at its start (początek rozjazdu); the branch's leaving
  straight is locked tangent to the frog; switches can be slid along the through
  track and flipped L/P.
- Polish turnout templates carry catalogue length (Id-1-consistent lengths), plus
  blade-angle and pre-blade fields (left 0 until the catalogue figures are in).
- TURNOUT_SPEC.md: the Bezier-based runtime/model contract.
- also folds in other pending branch changes (scenery, tests) to leave a clean tree.
2026-08-27 19:36:55 +02:00