mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 08:46:00 +01:00
Merge remote-tracking branch 'origin/master' into feat/second-loco-engine-start
# Conflicts: # CMakeLists.txt
This commit is contained in:
@@ -456,6 +456,66 @@ bool global_settings::ConfigParseInput(cParser& Parser, const std::string& token
|
||||
return false;
|
||||
}
|
||||
|
||||
bool global_settings::ConfigParseTest(cParser& Parser, std::string_view const Token)
|
||||
{
|
||||
// integration test limits, usually given in the config block of a test scenery
|
||||
if (Token == "test.timeout")
|
||||
{
|
||||
double value{ test.timeout };
|
||||
ParseOne(Parser, value);
|
||||
if (false == test.timeout_from_command_line)
|
||||
test.timeout = std::max(0.0, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Token == "test.wall_timeout")
|
||||
{
|
||||
double value{ 0.0 };
|
||||
ParseOne(Parser, value);
|
||||
if (false == test.wall_timeout_from_command_line)
|
||||
test.wall_timeout = std::max(0.0, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Token == "test.vehicle")
|
||||
{
|
||||
// a vehicle of a train under test, by its name in the scenery; the pass and the standstill wait for its
|
||||
// consist only, not for other trains (eu07/maszyna#541). given more than once, for each of them
|
||||
std::string name;
|
||||
ParseOne(Parser, name, 1, true);
|
||||
if (false == name.empty() && std::ranges::find(test.vehicles, name) == test.vehicles.end())
|
||||
test.vehicles.emplace_back(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Token == "test.standstill")
|
||||
{
|
||||
ParseOne(Parser, test.standstill);
|
||||
test.standstill = std::max(0.0, test.standstill);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Token == "test.pass_on_standstill")
|
||||
{
|
||||
ParseOne(Parser, test.pass_on_standstill);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Token == "test.fail_if_stop_overran")
|
||||
{
|
||||
ParseOne(Parser, test.fail_if_stop_overran);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Token == "test.no_movement_before_pass")
|
||||
{
|
||||
ParseOne(Parser, test.no_movement_before_pass);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool global_settings::ConfigParseSimulation(cParser& Parser, const std::string& token)
|
||||
{
|
||||
if (token == "async.trainThreads")
|
||||
@@ -1316,6 +1376,9 @@ void global_settings::ConfigParse(cParser& Parser)
|
||||
if (ConfigParseDebug(Parser, token))
|
||||
continue;
|
||||
|
||||
if (ConfigParseTest(Parser, token))
|
||||
continue;
|
||||
|
||||
// WriteLog(std::format("Unknown config token: {}", token), logtype::warning, false);
|
||||
|
||||
} while (true);
|
||||
@@ -1742,6 +1805,17 @@ global_settings::export_as_text( std::ostream &Output ) const {
|
||||
export_as_text( Output, "gfx.shadowmap.enabled", gfx_shadowmap_enabled );
|
||||
// TODO: export fpslimit
|
||||
export_as_text( Output, "randomseed", Global.random_seed );
|
||||
export_as_text( Output, "test.timeout", test.timeout );
|
||||
if( test.wall_timeout.has_value() ) {
|
||||
export_as_text( Output, "test.wall_timeout", *test.wall_timeout );
|
||||
}
|
||||
export_as_text( Output, "test.standstill", test.standstill );
|
||||
export_as_text( Output, "test.pass_on_standstill", test.pass_on_standstill );
|
||||
export_as_text( Output, "test.fail_if_stop_overran", test.fail_if_stop_overran );
|
||||
export_as_text( Output, "test.no_movement_before_pass", test.no_movement_before_pass );
|
||||
for( auto const &vehicle : test.vehicles ) {
|
||||
export_as_text( Output, "test.vehicle", vehicle );
|
||||
}
|
||||
export_as_text( Output, "gfx.envmap.enabled", gfx_envmap_enabled );
|
||||
export_as_text( Output, "gfx.postfx.motionblur.enabled", gfx_postfx_motionblur_enabled );
|
||||
export_as_text( Output, "gfx.postfx.motionblur.shutter", gfx_postfx_motionblur_shutter );
|
||||
|
||||
@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/utilities.h"
|
||||
#include "utilities/motiontelemetry.h"
|
||||
#include <map>
|
||||
#include <optional>
|
||||
|
||||
#ifdef WITH_UART
|
||||
#include "utilities/uart.h"
|
||||
@@ -86,6 +87,20 @@ struct global_settings {
|
||||
std::string local_start_vehicle{ "EU07-424" };
|
||||
std::string editor_enter_vehicle; // vehicle placed in the editor, to be entered when the driving goes on
|
||||
bool editor_session{ false }; // scenery was opened for editing (-edit): loader keeps track of scenery layers and hands over to the editor
|
||||
// integration test mode (--test, eu07/maszyna#541); the limits can be set in the scenery's config block (test.*)
|
||||
struct test_settings {
|
||||
bool enabled{ false };
|
||||
double timeout{ 3600.0 }; // [s] of simulation time; no result by then fails the test
|
||||
double standstill{ 300.0 }; // [s] the tested trains standing still this long ends the test; 0 = never
|
||||
bool pass_on_standstill{ false }; // the standstill end passes the test instead of failing it
|
||||
bool fail_if_stop_overran{ true }; // a train passing a signal at stop ends the test as failed; with false it's only logged
|
||||
bool no_movement_before_pass{ true }; // a pass waits until the tested trains stand still; with false it ends the test at once
|
||||
std::vector<std::string> vehicles; // test.vehicle: the trains under test are the consists of these; none = every vehicle
|
||||
bool timeout_from_command_line{ false }; // --test-timeout given, the scenery doesn't override it
|
||||
std::optional<double> wall_timeout; // [s] of real time since the start; none = test.timeout + time for the loading, 0 = no limit
|
||||
bool wall_timeout_from_command_line{ false }; // --test-wall-timeout given, the scenery doesn't override it
|
||||
};
|
||||
test_settings test;
|
||||
bool editor_tracks{ false }; // F3 track workspace: draw and pick tracks without the scenery draw-range cap
|
||||
int iConvertModels{ 0 }; // tworzenie plików binarnych
|
||||
int iConvertIndexRange{ 1000 }; // range of duplicate vertex scan
|
||||
@@ -377,6 +392,7 @@ struct global_settings {
|
||||
bool ConfigParseNetwork(cParser& Parser, const std::string& token);
|
||||
bool ConfigParseHardware(cParser& Parser, const std::string& token);
|
||||
bool ConfigParseDebug(cParser& Parser, const std::string& token);
|
||||
bool ConfigParseTest(cParser& Parser, std::string_view Token);
|
||||
bool ConfigParse_gfx( cParser &parser, std::string_view const Token );
|
||||
// sends basic content of the class in legacy (text) format to provided stream
|
||||
void
|
||||
|
||||
@@ -125,8 +125,8 @@ void LogService()
|
||||
if (log_scrollback.size() > 200)
|
||||
log_scrollback.pop_front();
|
||||
|
||||
// log to console
|
||||
if (Global.iWriteLogEnabled & 2)
|
||||
// log to console; not in test mode, where the standard output carries the result of the test only
|
||||
if ((Global.iWriteLogEnabled & 2) && false == Global.test.enabled)
|
||||
{
|
||||
if (isError)
|
||||
printf("\033[1;37;41m%s\033[0m\n", msg.c_str());
|
||||
|
||||
@@ -27,6 +27,17 @@ double fSoundTimer{ 0.0 };
|
||||
double fSinceStart{ 0.0 };
|
||||
double override_delta = -1.0f;
|
||||
|
||||
namespace {
|
||||
|
||||
// when set (test mode), every frame lasts this long, see set_fixed_step()
|
||||
double &fixed_step()
|
||||
{
|
||||
static double step{0.0};
|
||||
return step;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
double GetTime()
|
||||
{
|
||||
return fSimulationTime;
|
||||
@@ -53,6 +64,11 @@ void set_delta_override(double t)
|
||||
override_delta = t;
|
||||
}
|
||||
|
||||
void set_fixed_step(double t)
|
||||
{
|
||||
fixed_step() = t;
|
||||
}
|
||||
|
||||
void ResetTimers()
|
||||
{
|
||||
UpdateTimers( Global.iPause != 0 );
|
||||
@@ -76,10 +92,16 @@ void UpdateTimers(bool pause)
|
||||
fr = 1000000000;
|
||||
#endif
|
||||
DeltaRenderTime = double(count - oldCount) / double(fr);
|
||||
auto const fixedstep{fixed_step()};
|
||||
if (fixedstep > 0.0)
|
||||
{
|
||||
// the frame lasts exactly as long as said, however long it took to compute; the time speed doesn't apply
|
||||
DeltaRenderTime = fixedstep;
|
||||
}
|
||||
fRenderTime += DeltaRenderTime;
|
||||
if (!pause)
|
||||
{
|
||||
DeltaTime = Global.fTimeSpeed * DeltaRenderTime;
|
||||
DeltaTime = (fixedstep > 0.0 ? 1.0 : Global.fTimeSpeed) * DeltaRenderTime;
|
||||
fSoundTimer += DeltaTime;
|
||||
if (fSoundTimer > 0.1)
|
||||
fSoundTimer = 0.0;
|
||||
|
||||
@@ -19,6 +19,9 @@ double GetDeltaRenderTime();
|
||||
|
||||
void set_delta_override(double v);
|
||||
|
||||
// every frame advances the clocks by this many seconds, whatever the real time; 0 = real time (test mode)
|
||||
void set_fixed_step(double v);
|
||||
|
||||
void ResetTimers();
|
||||
|
||||
void UpdateTimers(bool pause);
|
||||
|
||||
Reference in New Issue
Block a user