mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-18 21:06:00 +01:00
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.
This commit is contained in:
@@ -1200,17 +1200,6 @@ int eu07_application::init_settings(int Argc, char *Argv[])
|
||||
{
|
||||
Global.asVersion = VERSION_INFO;
|
||||
|
||||
fs::path iniPath = user_config_path("eu07.ini");
|
||||
|
||||
if (!iniPath.empty() && fs::exists(iniPath))
|
||||
{
|
||||
Global.LoadIniFile(iniPath.string().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.LoadIniFile("eu07.ini");
|
||||
}
|
||||
|
||||
// a test run is known before the rest of the command line is read, so a command line it can't take
|
||||
// ends with the error code of the test, not with 0, which would pass it
|
||||
auto const testcommandline{simulation::parse_test_command_line(std::vector<char const *>(Argv, Argv + Argc))};
|
||||
@@ -1226,6 +1215,19 @@ int eu07_application::init_settings(int Argc, char *Argv[])
|
||||
Global.test.timeout_from_command_line = true;
|
||||
}
|
||||
|
||||
fs::path iniPath = user_config_path("eu07.ini");
|
||||
|
||||
// a test reads the settings of the game folder only (and those given with -ini), not the player's own
|
||||
// (%APPDATA%/MaSzyna, ~/.config/MaSzyna), so it runs the same for whoever runs it
|
||||
if (false == Global.test.enabled && !iniPath.empty() && fs::exists(iniPath))
|
||||
{
|
||||
Global.LoadIniFile(iniPath.string().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.LoadIniFile("eu07.ini");
|
||||
}
|
||||
|
||||
// process command line arguments
|
||||
bool sceneryfromcommandline{false};
|
||||
bool editwithoutscenery{false};
|
||||
|
||||
@@ -19,6 +19,9 @@ eu07 --test -s <scenery.scn> [--test-timeout <seconds>] [-seed <number|word>] [-
|
||||
With `--test` the simulator:
|
||||
|
||||
- needs `-s`; `-v` is ignored and every train is driven by AI (ghostview),
|
||||
- reads the settings of the game folder's `eu07.ini` and of the files given with `-ini` (in that
|
||||
order), not the player's own `eu07.ini` in `%APPDATA%\MaSzyna` (`~/.config/MaSzyna` on Linux),
|
||||
so a test runs the same for whoever runs it,
|
||||
- draws nothing: the null renderer loads the 3D models (the physics needs some of their
|
||||
data) but no textures, and the window stays hidden,
|
||||
- has no sound, no network, no python, no pause (not even one set by the scenery), and
|
||||
|
||||
@@ -62,7 +62,8 @@ EXIT_RESULTS = {
|
||||
14: "error",
|
||||
}
|
||||
|
||||
# settings layered over the user's eu07.ini for a test run; the window ones only matter
|
||||
# settings layered over the game's eu07.ini for a test run (test mode doesn't read the player's own
|
||||
# in %APPDATA%); the window ones only matter
|
||||
# with --watch, test mode keeps its window hidden and turns the sound off by itself
|
||||
TEST_INI = """\
|
||||
fullscreen no
|
||||
|
||||
Reference in New Issue
Block a user