mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 08:55:22 +01:00
6373b49447
Brings in staging up to 6f566c075 (PR #468, the GL 4.6 / Vulkan renderers, the weather model,
the dual-mode traction commands and the motion of a vehicle off the track).
Conflicts:
- application/application.cpp: staging takes a -seed only when seed_given() reads one and marks it
with Global.random_seed_given; the branch remembered a seed from the command line so the snapshot's
seed doesn't replace it. Kept staging's parsing and set seedfromcommandline inside it; the seed taken
from the snapshot now also sets Global.random_seed_given, or init() would draw a random one over it
(it used to check only for a seed of 0) and the test mode would put its "test" seed over it.
- input/command.h, input/command.cpp: both added commands after genericset29. Staging's
tractionmode*/genset* first, then snapshotsave, in the same order in the enum, the descriptions
and the name map.
- simulation/simulationenvironment.h: the old opengl_renderer/opengl33_renderer forward declarations
are gone with #468, opengl46_renderer kept, <array> of the branch kept; wind_state() of the branch
and weather() of staging both kept.
- vehicle/DynObj.h: the snapshot methods of the branch in the public part, followed by staging's
off-track members and methods with their own private:/public: switch.
98 lines
3.8 KiB
C++
98 lines
3.8 KiB
C++
/*
|
|
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/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "utilities/inionlysettings.h"
|
|
|
|
namespace
|
|
{
|
|
|
|
// puts Kept back into Current, and adds Key to Changed when they differed
|
|
template <typename Type_> void keep(Type_ &Current, Type_ const &Kept, std::string_view const Key, std::vector<std::string_view> &Changed)
|
|
{
|
|
if (false == (Current == Kept))
|
|
{
|
|
Current = Kept;
|
|
Changed.push_back(Key);
|
|
}
|
|
}
|
|
|
|
// a switch a scenery may turn off but not on: puts Kept back into Current, and adds Key to Changed, only when the
|
|
// scenery turned it on. turned off it stays so, as before these keys were kept
|
|
void keep_off(bool &Current, bool const Kept, std::string_view const Key, std::vector<std::string_view> &Changed)
|
|
{
|
|
if (Current && false == Kept)
|
|
{
|
|
Current = false;
|
|
Changed.push_back(Key);
|
|
}
|
|
}
|
|
|
|
} // namespace
|
|
|
|
ini_only_settings::ini_only_settings(global_settings const &Settings)
|
|
: m_exec_on_exit{Settings.exec_on_exit}, m_screenshot_dir{Settings.screenshot_dir}, m_snapshot_dir{Settings.snapshot_dir}, m_extcam_cmd{Settings.extcam_cmd},
|
|
m_extcam_rec{Settings.extcam_rec}, m_network_servers{Settings.network_servers}, m_network_client{Settings.network_client},
|
|
#ifdef WITH_ZMQ
|
|
m_zmq_address{Settings.zmq_address},
|
|
#endif
|
|
m_motiontelemetry{Settings.motiontelemetry_conf},
|
|
#ifdef WITH_UART
|
|
m_uart{Settings.uart_conf},
|
|
#endif
|
|
m_feedback_mode{Settings.iFeedbackMode}, m_feedback_port{Settings.iFeedbackPort}, m_python_enabled{Settings.python_enabled},
|
|
m_luascreens_enabled{Settings.luascreens_enabled}, m_lua_fulllibraries{Settings.lua_fulllibraries}, m_wasm_enabled{Settings.wasm_enabled},
|
|
m_odometer_expiry{Settings.odometer_expiry}
|
|
{
|
|
}
|
|
|
|
std::vector<std::string_view> ini_only_settings::restore(global_settings &Settings) const
|
|
{
|
|
std::vector<std::string_view> changed;
|
|
keep(Settings.exec_on_exit, m_exec_on_exit, "execonexit", changed);
|
|
keep(Settings.screenshot_dir, m_screenshot_dir, "screenshotsdir", changed);
|
|
keep(Settings.snapshot_dir, m_snapshot_dir, "snapshotsdir", changed);
|
|
keep(Settings.extcam_cmd, m_extcam_cmd, "extcam.cmd", changed);
|
|
keep(Settings.extcam_rec, m_extcam_rec, "extcam.rec", changed);
|
|
keep(Settings.network_servers, m_network_servers, "network.server", changed);
|
|
keep(Settings.network_client, m_network_client, "network.client", changed);
|
|
#ifdef WITH_ZMQ
|
|
keep(Settings.zmq_address, m_zmq_address, "zmq.address", changed);
|
|
#endif
|
|
// the structures as a whole, told apart by what turns them on and where they lead
|
|
{
|
|
auto ¤t{Settings.motiontelemetry_conf};
|
|
if (current.enable != m_motiontelemetry.enable || current.proto != m_motiontelemetry.proto || current.address != m_motiontelemetry.address ||
|
|
current.port != m_motiontelemetry.port)
|
|
{
|
|
changed.emplace_back("motiontelemetry");
|
|
}
|
|
current = m_motiontelemetry;
|
|
}
|
|
#ifdef WITH_UART
|
|
{
|
|
auto ¤t{Settings.uart_conf};
|
|
if (current.enable != m_uart.enable || current.port != m_uart.port)
|
|
{
|
|
changed.emplace_back("uart");
|
|
}
|
|
current = m_uart;
|
|
}
|
|
#endif
|
|
keep(Settings.iFeedbackMode, m_feedback_mode, "feedbackmode", changed);
|
|
keep(Settings.iFeedbackPort, m_feedback_port, "feedbackport", changed);
|
|
// a scenery may switch a runtime off, and keep its scripts in the sandbox
|
|
keep_off(Settings.python_enabled, m_python_enabled, "python.enabled", changed);
|
|
keep_off(Settings.luascreens_enabled, m_luascreens_enabled, "luascreens.enabled", changed);
|
|
keep_off(Settings.lua_fulllibraries, m_lua_fulllibraries, "lua.fulllibraries", changed);
|
|
keep_off(Settings.wasm_enabled, m_wasm_enabled, "wasm.enabled", changed);
|
|
keep(Settings.odometer_expiry, m_odometer_expiry, "odometer.expiry", changed);
|
|
return changed;
|
|
}
|