18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-14 09:06:58 +01:00
Commit Graph

42 Commits

Author SHA1 Message Date
jerrrrycho
8fb596f218 fix(simulation): any exception ends a test run with error, other runs as on master
main() tells a test run (--test) apart before anything runs. Only a test run
catches every exception and installs a std::terminate handler, both ending the
run with the error code and a test: line; any other run keeps master's
exception handling, so on Linux an uncaught runtime_error aborts at the throw
site again.

A test run doesn't start the Discord RPC thread: it published the test
scenery as the player's presence and held the closing up to 5 s.

run.py drops a case scenery's .sbt cache after a run cut short (wall_timeout,
error, a crash, killed by run.py), which could have been writing it.

The -edit branch of the test command line parser had no effect (a token that
isn't an option is ignored either way) and is gone; its test checks what can
be seen instead.
2026-11-08 19:46:16 +01:00
jerrrrycho
03a417c7b0 feat(simulation): a real time watchdog ends a test run that hangs
A test run that hung, in the loading or anywhere else, waited until whoever
started it killed it. A watchdog thread now ends a run still going test.wall_timeout
seconds of real time after the start of the simulator, loading included: it says
`test: timeout ... still running after N s of real time` and quits with the
timeout code, whatever the main thread is doing, with no dialog. A test that has
ended but whose simulator doesn't close ends with its own result.

The limit is test.wall_timeout (settings, the scenery's config block) or
--test-wall-timeout, which wins. Not given, it is test.timeout + 600 s: ten
minutes for the loading, and a simulation that runs at least as fast as real
time is never cut short. test.timeout 0 means no watchdog unless the limit is
given; test.wall_timeout 0 turns it off.

run.py passes the case's timeout as --test-wall-timeout and kills a simulator
only 30 s after it. A timeout from the watchdog counts as wall_timeout there, so
a run that hung doesn't pass a case expecting the simulation time to run out;
test_mode_wall_timeout ends while loading on a limit of 2 s.
2026-11-08 11:33:36 +01:00
jerrrrycho
14d25520f3 fix(simulation): a test's standard output carries its result only
The log was printed in colour to stdout too (debuglog bit 2), so a script reading
the verdict of a test got the whole log with it. In test mode the log goes to the
log file only and stdout has the `test: ...` line alone; the usage text of a bad
command line goes to stderr. Whether the run is a test is now known before the
log service starts.
2026-11-08 11:23:02 +01:00
jerrrrycho
1626df2bc4 fix(simulation): a scenery's config block can't turn back on what a test keeps off
The config block of a scenery is read like the settings files, after the test
mode settings were applied, so a scenery with soundenabled, multiplayer,
execonexit, feedbackmode or the like in it got them back in a test run. The test
mode settings now are applied again after each config block of the scenery;
apply_test_mode_settings() moved to simulationtest.cpp for that.
2026-11-08 11:22:37 +01:00
jerrrrycho
7f8892cda6 fix(simulation): a test doesn't read the player's own eu07.ini
The simulator reads eu07.ini from %APPDATA%/MaSzyna (~/.config/MaSzyna on Linux)
when there is one, in place of the game folder's. A test run then depended on
whose machine it ran on. With --test only the game folder's eu07.ini is read,
then the files given with -ini. The test mode options are taken from the command
line before the settings for that; --test-timeout still wins over test.timeout
of any settings file.
2026-11-08 11:21:57 +01:00
jerrrrycho
486a714f52 refactor(simulation): the rules of the test mode in a file of their own, with unit tests
The command line options of the test mode and the end conditions checked after
each frame are now plain functions in simulation/simulationtestrules.cpp, which
needs nothing of the running simulation: parse_test_command_line() and
evaluate_frame(). The file is part of the core library, so the unit tests check
them (tests/unit/test_test_mode.cpp): the --test-timeout value, values of other
options not taken for options, a pass that waits for the stop, the standstill,
the timeout. test_manager only gathers what a frame brought and acts on the
verdict. No change in behaviour.
2026-11-08 11:20:52 +01:00
jerrrrycho
93e2b85d08 fix(simulation): the test mode gives nothing to the outside and leaves the player's files alone
The test mode turned off what comes in from outside, but a few settings
of the user's eu07.ini still reached out of a test run:

- feedbackmode: 1 and 2 toggle Caps Lock / Scroll Lock by injecting key
  events into the whole system, 3 and 4 drive an LPT port or a PoKeys
  desk (and 4 reads the desk's switches);
- multiplayer: events are reported to a multiplayer server, and some
  events are held back for it;
- execonexit: a program is run with system() at the end of each run,
  which also waits for it;
- showsystemconsole: a console of the run's own pops up and stdout is
  reopened on it, so whoever started the test with a redirected output
  doesn't get the `test:` line (and a console the run was started from
  would be hidden without it);
- imgui.ini in the game folder was written by every run, and by several
  at once with run.py -j.

All of these are off in test mode. Nothing changes outside it.
2026-11-08 09:36:51 +01:00
jerrrrycho
4356e7c3fd fix(simulation): a test run that can't start ends with the error code and says why
- `--test` is looked for before the rest of the command line is read. An
  unknown option before it (e.g. `-s x.scn --test-timout 90 --test`) used
  to end the run with exit code 0, which a caller reads as a pass.
- `--test-timeout` without a value, or with one that isn't a number of
  seconds, fails the run instead of leaving the default or, through atof,
  turning the timeout off.
- These, a missing -s, a failed start and an exception caught in main()
  end the test through test_manager::conclude(), which writes the usual
  `test: error (exit code 5) ... : <reason>` line to stdout and the log.
  Before, `eu07 --test` alone exited with 5 and nothing anywhere: the
  error went to the log queue and the process ended before the log
  thread wrote it. In test mode main() now stops the log thread and
  waits for it before _Exit().

Outside the test mode nothing changes: conclude() does nothing there.
2026-11-08 09:36:28 +01:00
jerrrrycho
dd019d88ba feat(simulation): the test mode takes no input from outside (eu07/maszyna#541)
With --test the gamepad, mouse picking, UART, ZeroMQ and motion telemetry are
off, the hidden window gets no key, mouse, scroll or char callbacks, and the
window procedure that takes WM_COPYDATA commands from other programs isn't
installed, so nothing but the scenery drives a test run.
2026-11-07 17:38:37 +01:00
jerrrrycho
441caeed64 refactor(simulation): tidy the test mode code
The test manager is reached through simulation::test() instead of a global,
the result cell is owned by a unique_ptr until the memory table takes it, the
cell value is compared with a margin, strings are built with std::format and
the --test settings moved to apply_test_mode_settings(). The driver's signal
check is folded into UpdateSpeedPosition(), which updates a speed table entry
and reports a signal at stop the head of the train just passed. The test.*
keys are listed with the other settings at the start of the log.
2026-11-07 17:12:11 +01:00
jerrrrycho
02e29f6971 feat(simulation): test mode, --test runs a scenery unattended and exits with the result (eu07/maszyna#541)
eu07 --test -s <scenery> [--test-timeout <s>] runs the scenery in ghostview with
the null renderer (models loaded, no textures), a hidden window, no sound,
network or python, and in fixed steps of 0.03 s of simulation time per frame
(three 10 ms physics steps) as fast as it can. Without -seed it uses a fixed
seed, so two runs give byte-identical physicslogs.

The scenery reports its result to the __test.result memory cell, which the
simulator always creates: value 1 passes once every vehicle has stood still for
1 s, value 0 fails at once. The run ends with exit code
  0 pass, 1 fail,
  2 a train passed a signal at stop (SetVelocity 0 0, as seen in its driver's
    speed table; SetVelocity 0 x on automatic block doesn't count),
  3 timeout (test.timeout, default 3600 s of simulation time),
  4 standstill (every vehicle still for test.standstill s, default 300, with no
    result; a pass with test.pass_on_standstill yes),
  5 error (no -s, the scenery didn't load or has no vehicles, an exception).
The test.* keys go in the scenery's config block; test.fail_if_stop_overran no
only logs a signal passed at danger. Outside the test mode a signal passed at
danger is logged.

The null renderer gets a ui backend which draws nothing, hands out the null
texture and material instead of throwing, and ends the ui frame. A GL context
is still made for the hidden window, without asking for a version, as parts
of the ui create textures with gl calls of their own. No crash dialog or
message box in test mode; the window code no longer needs a monitor.
2026-11-07 16:20:42 +01:00
jerrrrycho
798fd89dd0 test: scenario tests that run the simulator and check a vehicle's physicslog
tests/scenarios/run.py builds a test scenery from a game install's scenery
(own trainsets removed, case fragment added), runs eu07 in ghostview with
physicslog on, and checks what the vehicle did: starts, max speed, brakes,
stops. First case: EU07 on td.scn driven by AI on the td/rozklad timetable,
with the Stacja1 exit route set by an event launcher instead of shift+4.

eu07 gets a -ini <file> option: an extra settings file read after eu07.ini,
so a test run can switch to a window and turn on physicslog without touching
the user's config.

Local only: scenery and vehicle data are not in the repo.
2026-11-07 16:20:41 +01:00
maj00r
a6778c9fe2 refactor: the Sonar remarks on the small fixes taken care of
- the log stops through a flag kept in a function, not a global one
- the messages are put together with std::format
- a vehicle dropped on a trainset in the launcher goes in once the
  trainset is drawn, so the vehicles are gone through with a plain loop
  again; the drop split into a new vehicle and a moved one
- the scenario that can't be opened is caught as the runtime error it
  is, a file name outside of the code page as the system error it is
- a track of an unknown type is left out through the pointer owning it
- the keyword of a track type written out by a function of its own
- the picked node forgotten with ranges::replace_if, the empty
  Forget_Node of the base renderer told why it is empty
- FileCased takes the path it works on
2026-11-06 19:54:54 +01:00
maj00r
ed0ff36a69 fix(app): a scenario failing as it loads goes back to the launcher too, the files of other cases looked for only off Windows
A scenario failing past its opening popped the loader mode and went on to pop it again and push the driver mode with the scenery half loaded; it goes back to the launcher as one that can't be opened. FileCased() goes through the folder only where the file system tells the case apart: on Windows a missing file was looked for in its whole folder for nothing, and a name outside the code page threw from the parser. The Discord thread sleeps a quarter of a second outside the driver mode, not to hold the closing up.
2026-11-03 21:53:52 +01:00
maj00r
b34238f33f fix(app): the log written to the end of the closing, each step of it with its time; the Discord thread idle outside the driver mode
The log service stopped with applicationQuitOrder, so whatever was logged while the simulator closed was lost; it now runs until StopLogService() and writes out what came before. The closing logs each of its steps with the time since it began, to tell where a closing that hangs stops. Outside the driver mode the Discord thread spun a core in its loop, it now sleeps a second between the checks.
2026-11-03 21:45:57 +01:00
maj00r
04af7d5758 fix(python): stop python workers before destroying windows on exit 2026-10-21 21:23:29 +02:00
jerrrrycho
8125166690 Fix/sonar reliability security (#205)
* fix(sonar): addressing reliability/security issues

* fix(sonar): addressing reliability/security issues

* fix(sonar): addressing reliability/security issues

* fix(sonar): addressing last reliability/security issues

* fix(sonar): addressing last reliability/security issues

* fix(sonar): addressing last reliability/security issues

* refactor(sonar): imgui update

* refactor(sonar): hasChar revert
2026-10-11 15:31:45 +02:00
9935257783 Add nosonar tags 2026-10-09 18:40:31 +02:00
344034ec70 feat(ui): imgui 1.91.9b-docking in place of 1.73: local changes of the backends carried over (glad as the gl loader, srgb and gamma of the ui, gles glsl string), BufferingBar/Spinner kept, imgui_tables in cmake; cursor position, cursor enter and focus of the main window passed to the glfw backend, which works with events now; code adapted to the api: ImGuiListClipper::Begin, BeginListBox, ImTextureID as an integer, ImageButton with an id, ImGuiKey without GetKeyIndex, logarithmic sliders in place of the removed power argument; ImGuizmo with the math operators defined before imgui.h and SetNextFrameWantCaptureMouse 2026-10-08 20:38:13 +02:00
917c8f7285 Merge branch 'master' into feat/modern-editor 2026-10-08 17:44:58 +02:00
maj00r
0a3cd55e59 feat(launcher): -edit without a scenery opens the wizard of a new scenery: file name, title and centre, picked on the OpenStreetMap map of geoportal.gov.pl in PUWG 1992 or given in degrees; the scenery is written with the centre as its //$g reference and opened in the editor; a bare -edit no longer loads the scenery of eu07.ini 2026-10-06 22:19:40 +02:00
jerrrrycho
79bd0c8e91 fix(sonar): addressing reliability/security issues (#202) 2026-10-04 20:00:13 +02:00
73f2f68aa0 feat(editor): edit session (-edit) and scenery layers 2026-10-02 21:29:18 +02:00
jerrrrycho
176427f96b refactor: sonar c++20 changes (#185) 2026-09-28 21:08:15 +02:00
jerrrrycho
4137f5504a fix: sonar sast fixes - sonar.yml, nosonar, linux chmod modification 2026-09-28 21:07:53 +02:00
maj00r
3fa3853018 fix for sonar 2026-09-14 22:51:33 +02:00
e7b64c7397 Merge branch 'random-seed-entropy' of https://github.com/MaSzyna-EU07/maszyna into random-seed-entropy 2026-09-14 19:28:45 +02:00
788135cc2d Improve random engine entropy and clean up random engine initialization 2026-09-14 19:26:24 +02:00
maj00r
2945f3f9b2 use random_device for local generator 2026-09-14 19:11:07 +02:00
maj00r
ff3daea78c seed the random engines from the system pool, not std::random_device 2026-09-14 18:26:16 +02:00
Sebastian Krzyszkowiak
22361eec1d Fix compilation with discord-rpc turned off (#135)
Closes #55
2026-07-15 21:50:16 +02:00
Sebastian Krzyszkowiak
c98441d1aa Initialize random seed early in the init sequence
Network client will overwrite the seed if necessary.
2026-07-02 03:14:54 +02:00
d60841944d Merge pull request #124 from xwizard/refactor/user-config-path
refactor: extract user_config_path() helper
2026-06-30 22:35:53 +02:00
Mateusz Włodarczyk
fe603f15eb refactor: extract user_config_path() helper
Consolidates platform-specific config-directory logic (APPDATA on Windows,
~/Library/Application Support on macOS, ~/.config on Linux) into a single
user_config_path(filename) function in utilities/utilities.{cpp,h}, removing
copy-pasted #ifdef blocks from application.cpp, editor/editorSettings.cpp,
input/{keyboard,gamepad,drivermouse,uart}input.cpp.
2026-06-30 21:30:36 +02:00
jerrrrycho
d85096f64d reformat: remove redundant parentheses 2026-06-30 21:19:46 +02:00
jerrrrycho
7a32e7e9ab Merge pull request #113 from MaSzyna-EU07/refactor-nullptr
refactor: replace null with nullptr
2026-06-29 13:40:06 +02:00
jerrrrycho
bf147dd155 refactor: replace null with nullptr 2026-06-29 02:48:25 +02:00
75461eaf86 World Streaming Part 1 2026-06-18 18:18:02 +02:00
bae20a69e8 Bring back old simulator console as ini option showsystemconsole 2026-05-01 23:51:57 +02:00
jakubg1
8a94bfbfa2 Fix a segfault when closing on Wayland
According to https://github.com/glfw/glfw/issues/2744, this will be fixed in GLFW 3.5.
2026-04-14 15:08:44 +02:00
copilot-swe-agent[bot]
7e49aa8740 Rewrite #includes to use explicit subdirectory paths
Co-authored-by: Hirek193 <23196899+Hirek193@users.noreply.github.com>
2026-03-14 19:16:48 +00:00
copilot-swe-agent[bot]
0531086bb9 Reorganize source files into logical subdirectories
Co-authored-by: Hirek193 <23196899+Hirek193@users.noreply.github.com>
2026-03-14 19:01:57 +00:00