mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-21 00:24:57 +01:00
Merge remote-tracking branch 'origin/master' into fix/freight-brake-setting-cw1
# Conflicts: # CMakeLists.txt # utilities/Globals.cpp
This commit is contained in:
@@ -817,6 +817,12 @@ bool global_settings::ConfigParseSimulation(cParser& Parser, const std::string&
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token == "controlcoupling.enginecheck")
|
||||
{
|
||||
ParseOne(Parser, control_coupling_engine_check, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1659,6 +1665,7 @@ global_settings::export_as_text( std::ostream &Output ) const {
|
||||
export_as_text( Output, "scenario.time.current", ScenarioTimeCurrent );
|
||||
export_as_text( Output, "scenario.weather.temperature", AirTemperature );
|
||||
export_as_text( Output, "ai.trainman", AITrainman );
|
||||
export_as_text( Output, "controlcoupling.enginecheck", control_coupling_engine_check );
|
||||
export_as_text( Output, "ai.brakesetting.cw1", AIBrakeSettingCw1 );
|
||||
export_as_text( Output, "scalespeculars", ScaleSpecularValues );
|
||||
export_as_text( Output, "gfxrenderer", GfxRenderer );
|
||||
|
||||
@@ -276,6 +276,7 @@ struct global_settings {
|
||||
bool captureonstart = true;
|
||||
bool render_cab = true;
|
||||
bool crash_damage = true;
|
||||
bool control_coupling_engine_check = true; // no multiple-unit control between electric and diesel traction vehicles (eu07/maszyna#520)
|
||||
bool gui_defaultwindows = true;
|
||||
bool gui_showtranscripts = true;
|
||||
bool gui_trainingdefault = false;
|
||||
|
||||
@@ -67,6 +67,7 @@ struct subsystem_stopwatches {
|
||||
stopwatch sim_events;
|
||||
stopwatch sim_ai;
|
||||
stopwatch mainloop_total;
|
||||
stopwatch mainloop_period; // start to start, the wait for fpslimit included
|
||||
};
|
||||
|
||||
extern subsystem_stopwatches subsystem;
|
||||
|
||||
59
utilities/framepacer.h
Normal file
59
utilities/framepacer.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
|
||||
// paces the main loop to the frame time set by fpslimit in eu07.ini.
|
||||
// the frames are scheduled on a fixed cadence rather than by sleeping off what is left of each frame,
|
||||
// so a sleep that overshoots (the windows timer wakes up in steps of up to ~15.6 ms) is made up by
|
||||
// a shorter wait in the next frame, and the frame rate averages to the limit.
|
||||
// all the time arithmetic is done in the clock's integer ticks: a sleep_for() given a float duration
|
||||
// adds it to now() as float nanoseconds, which after a few hours of system uptime rounds the wake-up
|
||||
// time to tens of milliseconds and lets the limit fall through (eu07/maszyna#416)
|
||||
class frame_pacer {
|
||||
|
||||
public:
|
||||
using clock = std::chrono::steady_clock;
|
||||
|
||||
// called at the end of each frame. returns the point in time the next frame may start at,
|
||||
// or nothing when it may start right away
|
||||
[[nodiscard]] std::optional<clock::time_point> next_frame(clock::time_point const Now, std::chrono::duration<float> const Frametime) {
|
||||
return next_frame(Now, std::chrono::duration_cast<clock::duration>(Frametime));
|
||||
}
|
||||
[[nodiscard]] std::optional<clock::time_point> next_frame(clock::time_point const Now, clock::duration const Minframetime) {
|
||||
if (Minframetime <= clock::duration::zero()) {
|
||||
// no limit
|
||||
m_framestart.reset();
|
||||
return std::nullopt;
|
||||
}
|
||||
if (!m_framestart) {
|
||||
// first paced frame
|
||||
m_framestart = Now;
|
||||
return std::nullopt;
|
||||
}
|
||||
auto const nextframe{*m_framestart + Minframetime};
|
||||
if (Now >= nextframe + Minframetime) {
|
||||
// a whole frame or more behind: start the cadence anew rather than run frames back to back to catch up
|
||||
m_framestart = Now;
|
||||
return std::nullopt;
|
||||
}
|
||||
m_framestart = nextframe;
|
||||
if (Now >= nextframe) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return nextframe;
|
||||
}
|
||||
|
||||
private:
|
||||
// the scheduled start of the current frame
|
||||
std::optional<clock::time_point> m_framestart;
|
||||
};
|
||||
@@ -225,6 +225,10 @@ std::string locale::label_cab_control(std::string const &Label)
|
||||
{ "coolingfans_sw:", STRN("cooling fans") },
|
||||
{ "main_off_bt:", STRN("line breaker") },
|
||||
{ "main_on_bt:", STRN("line breaker") },
|
||||
{ "mainb_off_bt:", STRN("line breaker B") },
|
||||
{ "mainb_on_bt:", STRN("line breaker B") },
|
||||
{ "mainc_off_bt:", STRN("line breaker C") },
|
||||
{ "mainc_on_bt:", STRN("line breaker C") },
|
||||
{ "security_reset_bt:", STRN("alerter") },
|
||||
{ "shp_reset_bt:", STRN("shp") },
|
||||
{ "releaser_bt:", STRN("independent brake releaser") },
|
||||
@@ -270,7 +274,14 @@ std::string locale::label_cab_control(std::string const &Label)
|
||||
{ "converterlocal_sw:", STRN("local converter") },
|
||||
{ "converteroff_sw:", STRN("converter") },
|
||||
{ "main_sw:", STRN("line breaker") },
|
||||
{ "mainb_sw:", STRN("line breaker B") },
|
||||
{ "mainc_sw:", STRN("line breaker C") },
|
||||
{ "radio_sw:", STRN("radio") },
|
||||
{ "radioon_sw:", STRN("radio") },
|
||||
{ "radiooff_sw:", STRN("radio") },
|
||||
{ "radiofuse_sw:", STRN("radio fuse") },
|
||||
{ "radiofuseon_sw:", STRN("radio fuse") },
|
||||
{ "radiofuseoff_sw:", STRN("radio fuse") },
|
||||
{ "radiochannel_sw:", STRN("radio channel") },
|
||||
{ "radiochannelprev_sw:", STRN("radio channel") },
|
||||
{ "radiochannelnext_sw:", STRN("radio channel") },
|
||||
|
||||
Reference in New Issue
Block a user