mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 12:16:02 +01:00
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.
This commit is contained in:
@@ -1779,6 +1779,10 @@ 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 );
|
||||
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, "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 );
|
||||
|
||||
@@ -26,7 +26,17 @@ double fRenderTime{ 0.0 };
|
||||
double fSoundTimer{ 0.0 };
|
||||
double fSinceStart{ 0.0 };
|
||||
double override_delta = -1.0f;
|
||||
double fixed_step = 0.0;
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -56,7 +66,7 @@ void set_delta_override(double t)
|
||||
|
||||
void set_fixed_step(double t)
|
||||
{
|
||||
fixed_step = t;
|
||||
fixed_step() = t;
|
||||
}
|
||||
|
||||
void ResetTimers()
|
||||
@@ -82,15 +92,16 @@ void UpdateTimers(bool pause)
|
||||
fr = 1000000000;
|
||||
#endif
|
||||
DeltaRenderTime = double(count - oldCount) / double(fr);
|
||||
if (fixed_step > 0.0)
|
||||
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 = fixed_step;
|
||||
DeltaRenderTime = fixedstep;
|
||||
}
|
||||
fRenderTime += DeltaRenderTime;
|
||||
if (!pause)
|
||||
{
|
||||
DeltaTime = (fixed_step > 0.0 ? 1.0 : Global.fTimeSpeed) * DeltaRenderTime;
|
||||
DeltaTime = (fixedstep > 0.0 ? 1.0 : Global.fTimeSpeed) * DeltaRenderTime;
|
||||
fSoundTimer += DeltaTime;
|
||||
if (fSoundTimer > 0.1)
|
||||
fSoundTimer = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user