18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 11:47:06 +01:00
Files
maszyna/utilities/Globals.cpp
T
maj00r d8e6c6e36e feat(model): the game loads .e4d models, behind modelformat e4d in eu07.ini
Stage 2 of the E4D model format. With modelformat e4d a model with an .e4d file beside its .e3d / .t3d is loaded from it;
legacy, the default, leaves the .e4d files alone and the game loads models exactly as before. The key is written to the
log at the start.

- TModel3d::LoadFromE4D (model/e4d/e4d_load.cpp) builds the same tree of submodels LoadFromBinFile builds from E3D,
  and both go on through the same finish_binary() (the end of the E3D loading, moved out of deserialize unchanged).
  .mmd, events, GetFromName and the editor work as before. A file that can't be read or isn't valid is logged and the
  .e3d / .t3d is loaded instead. TModelsManager finds a model which comes as an .e4d alone.
- Format additions found by comparing loads (the format isn't released, so still version 1.0):
  - the LMAT component: the material of a node without geometry (light points, rotators), whose light threshold,
    colours and material the lights use;
  - node_flags::no_transform: an E3D submodel without a matrix, told apart from one with the identity matrix;
  - section_flags::meshopt: the vertex and index streams in the codecs of meshoptimizer (vertex codec version 1,
    index sequence codec), lossless, several times faster to unpack than zstd on this data. zstd packs the other
    sections; zstd over the coded streams is an option for archives (write_options::compress_streams).
- meshoptimizer v1.3 (MIT) as a submodule in ref/meshoptimizer; only its vertex and index codecs are built, into
  eu07_core.
- Loading speed: the big streams unpack on threads of their own, and a model of 100 000 vertices or more fills the
  vertices and indices of its submodels on up to 8 threads (std::jthread); the vertices are written once, without the
  zeroes of resize(). QTangent decoding takes the two matrix columns it needs without a square root.
- eu07 -e4d diff <e3d|t3d> <e4d> [dynamic] compares the two loads submodel by submodel and times them.

Checked:
- 250 random models of the installed game: all convert, and loaded from E4D they give the same tree, names, flags,
  materials and indices as from E3D; positions and UVs bit for bit, transforms within 6.5e-5, normals within 0.03 deg
  (4 vertices with a broken normal in the E3D get a proper one).
- Size 39% of the E3D (263 MB against 682 MB). Load outside the game, with the files in the system's cache: 516 ms
  against 561 ms, 0.75 of the time for the models of 5 MB and more, 1.21 for the smaller ones.
- In the game on Vulkan (self-test, the same 250 models): 3.05 s against 3.15 s to load them, the same frame time and
  device memory, the picture within 1/255 of the legacy one.
- Unit tests 1189/1189, among them the codecs with and without zstd, a codec on a wrong section and a cut stream. Not
  built with GCC here.

No asset change is needed: the game data has no .e4d files, and the release doesn't read them.
2026-11-28 20:55:57 +01:00

2945 lines
100 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/.
*/
/*
MaSzyna EU07 locomotive simulator
Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
*/
#include "stdafx.h"
#include "utilities/Globals.h"
#include "simulation/simulation.h"
#include "simulation/simulationenvironment.h"
#include "vehicle/Driver.h"
#include "utilities/Logs.h"
#include "utilities/inionlysettings.h"
#include "utilities/utilities.h"
#include "world/catenary_span.h"
#include "Console.h"
#include "scripting/PyInt.h"
#include "utilities/Timer.h"
#include "vao.h"
void global_settings::LoadIniFile(std::string asFileName)
{
// initialize season data in case the main config file doesn't
std::tm const tm = local_tm(std::time(nullptr));
fMoveLight = tm.tm_yday + 1; // numer bieżącego dnia w roku
simulation::Environment.compute_season(fMoveLight);
cParser parser(asFileName, cParser::buffer_FILE);
ConfigParse(parser);
}
template <typename T>
static void ParseOne(cParser& parser, T& out, int tokenCount = 1, bool convert = false)
{
parser.getTokens(tokenCount, convert);
parser >> out;
}
template <typename T>
static void ParseOneClamped(cParser& parser, T& out, T minValue, T maxValue, int tokenCount = 1, bool convert = false)
{
parser.getTokens(tokenCount, convert);
parser >> out;
out = std::clamp(out, minValue, maxValue);
}
void global_settings::FinalizeConfig()
{
if (!bLoadTraction)
{
bEnableTraction = false;
bLiveTraction = false;
}
if (vr)
{
gfx_skippipeline = false;
VSync = false;
}
if (iPause)
iTextMode = GLFW_KEY_F1;
#ifndef WITH_PYTHON
python_enabled = false;
#endif
#ifndef WITH_WASM
wasm_enabled = false;
#endif
#ifndef WITH_LUA
luascreens_enabled = false;
#endif
#ifdef _WIN32
Console::ModeSet(iFeedbackMode, iFeedbackPort);
#endif
}
glm::ivec2 global_settings::gfx_buffer_size(float const Scale) const
{
auto const scale{Scale > 0.f ? Scale : gfx_buffer_scale};
return glm::max(glm::ivec2(glm::round(glm::vec2(fb_size) * scale)), glm::ivec2(1));
}
bool global_settings::ConfigParseGeneral(cParser& Parser, const std::string& token)
{
if (token == "sceneryfile")
{
ParseOne(Parser, SceneryFile);
return true;
}
if (token == "humanctrlvehicle")
{
ParseOne(Parser, local_start_vehicle);
return true;
}
if (token == "width")
{
ParseOne(Parser, window_size.x, 1, false);
return true;
}
if (token == "height")
{
ParseOne(Parser, window_size.y, 1, false);
return true;
}
if (token == "fullscreen")
{
ParseOne(Parser, bFullScreen);
return true;
}
if (token == "fullscreenmonitor")
{
ParseOne(Parser, fullscreen_monitor, 1, false);
return true;
}
if (token == "fullscreenwindowed")
{
ParseOne(Parser, fullscreen_windowed);
return true;
}
if (token == "hideconsole")
{
ParseOne(Parser, bHideConsole);
return true;
}
if (token == "lang")
{
ParseOne(Parser, asLang, 1, false);
return true;
}
if (token == "screenshotsdir")
{
ParseOne(Parser, Global.screenshot_dir, 1);
return true;
}
if (token == "execonexit")
{
ParseOne(Parser, exec_on_exit, 1);
std::replace(std::begin(exec_on_exit), std::end(exec_on_exit), '_', ' ');
return true;
}
if (token == "prepend_scn")
{
ParseOne(Parser, prepend_scn, 1);
return true;
}
return false;
}
bool global_settings::ConfigParseAudio(cParser& Parser, const std::string& token)
{
if (token == "soundenabled")
{
ParseOne(Parser, bSoundEnabled);
return true;
}
if (token == "sound.openal.renderer")
{
AudioRenderer = Parser.getToken<std::string>(false);
return true;
}
if (token == "sound.volume")
{
ParseOneClamped(Parser, AudioVolume, 0.f, 2.f);
return true;
}
if (token == "sound.volume.radio")
{
ParseOneClamped(Parser, DefaultRadioVolume, 0.f, 1.f);
return true;
}
if (token == "sound.maxsources")
{
ParseOne(Parser, audio_max_sources);
return true;
}
if (token == "sound.asyncload")
{
ParseOne(Parser, AudioAsyncLoad);
return true;
}
if (token == "fmradio.enabled")
{
ParseOne(Parser, fmradio_enabled);
return true;
}
if (token == "fmradio.cleansound")
{
ParseOne(Parser, fmradio_cleansound);
return true;
}
if (token == "fmradio.stations")
{
fmradio_stations = Parser.getToken<std::string>(false);
return true;
}
if (token == "sound.volume.vehicle")
{
ParseOneClamped(Parser, VehicleVolume, 0.f, 1.f);
return true;
}
if (token == "sound.volume.positional")
{
ParseOneClamped(Parser, EnvironmentPositionalVolume, 0.f, 1.f);
return true;
}
if (token == "sound.volume.ambient")
{
ParseOneClamped(Parser, EnvironmentAmbientVolume, 0.f, 1.f);
return true;
}
return ConfigParseAudioDevice(Parser, token);
}
bool global_settings::ConfigParseAudioDevice(cParser& Parser, const std::string& token)
{
if (token == "sound.outputmode")
{
AudioOutputMode = Parser.getToken<std::string>(true);
return true;
}
if (token == "sound.hrtf")
{
AudioHrtf = Parser.getToken<std::string>(true);
return true;
}
if (token == "sound.hrtf.profile")
{
AudioHrtfProfile = Parser.getToken<std::string>(false);
return true;
}
if (token == "sound.resampler")
{
AudioResampler = Parser.getToken<std::string>(false);
return true;
}
if (token == "sound.limiter")
{
AudioLimiter = Parser.getToken<std::string>(true);
return true;
}
if (token == "sound.frequency")
{
ParseOneClamped(Parser, AudioFrequency, 0, 192000);
return true;
}
if (token == "sound.doppler")
{
ParseOneClamped(Parser, AudioDoppler, 0.f, 10.f);
return true;
}
if (token == "sound.efx.lowpass")
{
ParseOne(Parser, AudioLowpass);
return true;
}
if (token == "sound.efx.airabsorption")
{
ParseOneClamped(Parser, AudioAirAbsorption, 0.f, 10.f);
return true;
}
return false;
}
bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& token)
{
if (token == "fieldofview")
{
ParseOneClamped(Parser, FieldOfView, 10.0f, 75.0f, 1, false);
return true;
}
if (token == "targetfps")
{
ParseOne(Parser, targetfps, 1, false);
return true;
}
if (token == "heightbase")
{
ParseOne(Parser, fDistanceFactor, 1, false);
return true;
}
if (token == "basedrawrange")
{
ParseOne(Parser, BaseDrawRange, 1);
return true;
}
if (token == "vsync")
{
ParseOne(Parser, VSync);
return true;
}
if (token == "wireframe")
{
ParseOne(Parser, bWireFrame);
return true;
}
if (token == "skyenabled")
{
std::string value;
ParseOne(Parser, value);
asSky = value == "yes" ? "1" : "0";
return true;
}
if (token == "defaultext")
{
std::string value;
ParseOne(Parser, value);
if (value == "tga")
szDefaultExt = szTexturesTGA;
else
szDefaultExt = value[0] == '.' ? value : "." + value;
return true;
}
if (token == "anisotropicfiltering")
{
ParseOne(Parser, AnisotropicFiltering, 1, false);
if (AnisotropicFiltering < 1.0f)
AnisotropicFiltering = 1.0f;
return true;
}
if (token == "usevbo")
{
// only the removed legacy renderer had a non-VBO path; read and ignore so old eu07.ini files still load
bool usevbo{true};
ParseOne(Parser, usevbo);
WriteLog("eu07.ini: \"usevbo\" is no longer supported and was ignored");
return true;
}
if (token == "maxtexturesize")
{
unsigned int size = 0;
ParseOne(Parser, size, 1, false);
iMaxTextureSize = static_cast<GLint>(clamp_power_of_two(size, 64u, 8192u));
return true;
}
if (token == "maxcabtexturesize")
{
unsigned int size = 0;
ParseOne(Parser, size, 1, false);
iMaxCabTextureSize = static_cast<GLint>(clamp_power_of_two(size, 512u, 8192u));
return true;
}
if (token == "dynamiclights")
{
ParseOne(Parser, DynamicLightCount, 1, false);
DynamicLightCount = std::clamp(DynamicLightCount, 0, 7);
return true;
}
if (token == "gfxrenderer")
{
ParseOne(Parser, GfxRenderer);
// read in any case, as the starter does: "Legacy" written by hand is the legacy renderer
GfxRenderer = ToLower(GfxRenderer);
// "default": the opengl 4.6 renderer, "vulkan": the vulkan 1.4 one (opengl when it can't run on the machine)
if ((GfxRenderer == "full") || (GfxRenderer == "opengl") || (GfxRenderer == "gl46"))
GfxRenderer = "default";
else if (GfxRenderer == "vulkan14")
GfxRenderer = "vulkan";
// "null" draws nothing and loads no textures, for the test runs
if ((GfxRenderer != "default") && (GfxRenderer != "vulkan") && (GfxRenderer != "null"))
{
// the legacy OpenGL 2.1 renderer ("legacy", "simple" and other values) and the NVRHI renderer ("experimental") were removed
WriteLog("eu07.ini: gfxrenderer \"" + GfxRenderer + "\" is no longer supported, using \"default\"");
GfxRenderer = "default";
}
return true;
}
if (token == "shadows")
{
ParseOne(Parser, RenderShadows);
return true;
}
if (token == "shadowtune")
{
Parser.getTokens(4, false);
float discard = 0.f;
Parser >> shadowtune.map_size >> discard >> shadowtune.range >> discard;
shadowtune.map_size = clamp_power_of_two<unsigned int>(shadowtune.map_size, 512, 8192);
shadowtune.range =
std::max(shadowtune.map_size <= 2048 ? 75.f : 75.f * shadowtune.map_size / 2048,
shadowtune.range);
return true;
}
if (token == "scalespeculars")
{
ParseOne(Parser, ScaleSpecularValues);
return true;
}
if (token == "rendercab")
{
ParseOne(Parser, render_cab);
return true;
}
if (token == "multisampling")
{
ParseOne(Parser, iMultisampling, 1, false);
iMultisampling = std::clamp(iMultisampling, 0, 4);
gfx_antialiasing = (iMultisampling > 0 ? antialiasing_mode::msaa : antialiasing_mode::off);
return true;
}
if (token == "compresstex")
{
Parser.getTokens(1);
Parser >> compress_tex;
return true;
}
if (token == "gfx.angleplatform")
{
// the OpenGL ES / ANGLE path was removed; read and ignore so old eu07.ini files still load
std::string angleplatform;
ParseOne(Parser, angleplatform, 1);
WriteLog("eu07.ini: \"gfx.angleplatform\" is no longer supported and was ignored");
return true;
}
if (token == "gfx.gldebug")
{
ParseOne(Parser, gfx_gldebug, 1);
return true;
}
if (token == "extraviewport")
{
Parser.getTokens(15, false);
extraviewport_config conf;
Parser >> conf.monitor >> conf.width >> conf.height
>> conf.draw_range
>> conf.projection.pa.x >> conf.projection.pa.y >> conf.projection.pa.z
>> conf.projection.pb.x >> conf.projection.pb.y >> conf.projection.pb.z
>> conf.projection.pc.x >> conf.projection.pc.y >> conf.projection.pc.z
>> conf.projection.pe.x >> conf.projection.pe.y >> conf.projection.pe.z;
extra_viewports.push_back(conf);
if (gl::vao::use_vao && conf.monitor != "MAIN")
{
gl::vao::use_vao = false;
WriteLog("using multiple windows, disabling vao!");
}
return true;
}
return false;
}
bool global_settings::ConfigParseInput(cParser& Parser, const std::string& token)
{
if (token == "freefly")
{
ParseOne(Parser, FreeFlyModeFlag);
Parser.getTokens(3, false);
Parser >> FreeCameraInit[0].x >> FreeCameraInit[0].y >> FreeCameraInit[0].z;
return true;
}
if (token == "mousescale")
{
Parser.getTokens(2, false);
Parser >> fMouseXScale >> fMouseYScale;
return true;
}
if (token == "mousecontrol")
{
ParseOne(Parser, InputMouse);
return true;
}
if (token == "consistviews")
{
// no: [Shift]+[F4] cycles through the four views of the train it had before the views of its vehicles
ParseOne(Parser, ConsistViews);
return true;
}
if (token == "input.gamepad")
{
ParseOne(Parser, InputGamepad);
return true;
}
if (token == "headtrack")
{
Parser.getTokens(14);
Parser >> headtrack_conf.joy
>> headtrack_conf.magic_window
>> headtrack_conf.move_axes[0] >> headtrack_conf.move_axes[1] >> headtrack_conf.move_axes[2]
>> headtrack_conf.move_mul[0] >> headtrack_conf.move_mul[1] >> headtrack_conf.move_mul[2]
>> headtrack_conf.rot_axes[0] >> headtrack_conf.rot_axes[1] >> headtrack_conf.rot_axes[2]
>> headtrack_conf.rot_mul[0] >> headtrack_conf.rot_mul[1] >> headtrack_conf.rot_mul[2];
return true;
}
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")
{
ParseOne(Parser, trainThreads);
return true;
}
if (token == "physicslog")
{
ParseOne(Parser, WriteLogFlag);
return true;
}
// the physics logs of the trains only, of the drivers of rail vehicles; "physicslog yes" writes them all anyway
if (token == "physicslog.trains")
{
ParseOne(Parser, WriteTrainLogFlag);
return true;
}
// the saved odometer states of the vehicles not run for this many days are dropped, 0 = never (vehicle/odometer.h)
if (token == "odometer.expiry")
{
ParseOne(Parser, odometer_expiry);
odometer_expiry = std::max(0, odometer_expiry);
return true;
}
if (token == "blackbox")
{
bool blackbox{false};
ParseOne(Parser, blackbox);
BlackBox = blackbox;
return true;
}
if (token == "fullphysics")
{
ParseOne(Parser, FullPhysics);
return true;
}
if (token == "physics.sleepheld")
{
ParseOne(Parser, physics_sleepheld);
return true;
}
if (token == "physics.roadlod")
{
ParseOne(Parser, physics_roadlod);
return true;
}
if (token == "physics.pipewake")
{
ParseOne(Parser, physics_pipewake);
return true;
}
if (token == "performance.multithreading")
{
ParseOne(Parser, performance_multithreading);
return true;
}
if (token == "enabletraction")
{
ParseOne(Parser, bEnableTraction);
return true;
}
if (token == "loadtraction")
{
ParseOne(Parser, bLoadTraction);
return true;
}
if (token == "friction")
{
ParseOne(Parser, fFriction, 1, false);
return true;
}
if (token == "livetraction")
{
ParseOne(Parser, bLiveTraction);
return true;
}
if (token == "newaircouplers")
{
ParseOne(Parser, bnewAirCouplers);
return true;
}
if (token == "movelight")
{
ParseOne(Parser, fMoveLight, 1, false);
if (fMoveLight == 0.f)
{
std::tm const tm = local_tm(std::time(nullptr));
fMoveLight = tm.tm_yday + 1;
}
simulation::Environment.compute_season(fMoveLight);
return true;
}
if (token == "scenario.time.override")
{
Parser.getTokens(1, false);
std::string value;
Parser >> value;
std::istringstream stream(value);
if (value.find(':') != std::string::npos)
{
float hours = 0.f;
float minutes = 0.f;
char sep = '\0';
stream >> hours >> sep >> minutes;
ScenarioTimeOverride = hours + minutes / 60.0f;
}
else
{
stream >> ScenarioTimeOverride;
}
ScenarioTimeOverride = std::clamp(ScenarioTimeOverride, 0.f, 24 * 1439 / 1440.f);
return true;
}
if (token == "scenario.time.offset")
{
ParseOne(Parser, ScenarioTimeOffset, 1, false);
return true;
}
if (token == "scenario.time.current")
{
ParseOne(Parser, ScenarioTimeCurrent, 1, false);
return true;
}
if (token == "scenario.weather.temperature")
{
ParseOneClamped(Parser, AirTemperature, -15.f, 45.f);
return true;
}
if (token == "smoothtraction")
{
ParseOne(Parser, bSmoothTraction);
return true;
}
if (token == "catenary.procedural")
{
ParseOne(Parser, CatenaryProcedural);
return true;
}
if (token == "catenary.solidrange")
{
// zasięg rysowania przewodów sieci trakcyjnej jako brył [m]; 0 wyłącza
ParseOne(Parser, CatenarySettings.solid_range);
CatenarySettings.solid_range = std::clamp(CatenarySettings.solid_range, 0.f, 2000.f);
return true;
}
if (token == "splinefidelity")
{
float splinefidelity = 0.f;
ParseOne(Parser, splinefidelity);
SplineFidelity = std::clamp(splinefidelity, 1.f, 4.f);
return true;
}
if (token == "sleeperdistance")
{
float sleeperdistance = 0.f;
ParseOne(Parser, sleeperdistance);
// negative values disable the cap; we clamp at 0 so 0 means "do not render sleepers"
SleeperDistance = std::max(0.f, sleeperdistance);
return true;
}
if (token == "sleepers3d")
{
// model of the sleepers and switch timbers, put together from its submodels begin, main and end; none: no such sleepers
ParseOne(Parser, Sleepers3D);
if (Sleepers3D == "none")
{
Sleepers3D.clear();
}
return true;
}
if (token == "sleepers3dbed")
{
// the ballast under the tracks with 3D sleepers; no: the sleepers are laid on the ground alone
ParseOne(Parser, Sleepers3DBed);
return true;
}
if (token == "sleepers3dplain")
{
// model, skin and the height of the rail seat of the sleepers of a track running alone, square to it; none: the timbers of sleepers3d there too
Parser.getTokens(3, false);
Parser >> Sleepers3DPlain >> Sleepers3DPlainSkin >> Sleepers3DPlainSeat;
if (Sleepers3DPlain == "none")
{
Sleepers3DPlain.clear();
}
if (Sleepers3DPlainSkin == "none")
{
Sleepers3DPlainSkin.clear();
}
return true;
}
if (token == "createswitchtrackbeds")
{
ParseOne(Parser, CreateSwitchTrackbeds);
return true;
}
if (token == "frogs")
{
// yes: the rails of the plain tracks and of the switches with the key frogs cut where they cross other rails
ParseOne(Parser, Frogs);
return true;
}
if (token == "timespeed")
{
ParseOne(Parser, default_timespeed, 1, false);
fTimeSpeed = default_timespeed;
return true;
}
if (token == "deltaoverride")
{
float deltaoverride = 0.f;
ParseOne(Parser, deltaoverride, 1, false);
if (deltaoverride > 0.f)
Timer::set_delta_override(1.0f / deltaoverride);
return true;
}
if (token == "latitude")
{
ParseOne(Parser, fLatitudeDeg, 1, false);
return true;
}
if (token == "convertmodels")
{
ParseOne(Parser, iConvertModels, 1, false);
return true;
}
if (token == "convertindexrange")
{
ParseOne(Parser, iConvertIndexRange, 1, false);
return true;
}
if (token == "file.binary.terrain")
{
ParseOne(Parser, file_binary_terrain, 1, false);
return true;
}
if (token == "file.binary.terrain.checksum")
{
// off, simple or full; anything else leaves the setting as it was
std::string mode;
ParseOne(Parser, mode, 1, true);
file_binary_terrain_checksum = (mode == "off" ? 0 : mode == "simple" ? 1 : mode == "full" ? 2 : file_binary_terrain_checksum);
return true;
}
if (token == "inactivepause")
{
ParseOne(Parser, bInactivePause);
return true;
}
if (token == "slowmotion")
{
ParseOne(Parser, iSlowMotionMask, 1, false);
return true;
}
if (token == "fpsaverage")
{
ParseOne(Parser, fFpsAverage, 1, false);
return true;
}
if (token == "fpsdeviation")
{
ParseOne(Parser, fFpsDeviation, 1, false);
return true;
}
if (token == "brakestep")
{
ParseOne(Parser, fBrakeStep, 1, false);
return true;
}
if (token == "brakespeed")
{
ParseOne(Parser, brake_speed, 1, false);
return true;
}
if (token == "joinduplicatedevents")
{
ParseOne(Parser, bJoinEvents);
return true;
}
if (token == "hiddenevents")
{
ParseOne(Parser, iHiddenEvents, 1, false);
return true;
}
if (token == "ai.trainman")
{
ParseOne(Parser, AITrainman, 1, false);
return true;
}
if (token == "driverfigure.followsdirection")
{
ParseOne(Parser, DriverFigureFollowsDirection, 1, false);
return true;
}
if (token == "ai.brakesetting.cw1")
{
ParseOne(Parser, AIBrakeSettingCw1, 1, false);
return true;
}
if (token == "pause")
{
std::string value;
ParseOne(Parser, value);
iPause |= value == "yes" ? 1 : 0;
return true;
}
if (token == "priorityloadtext3d")
{
std::string value;
ParseOne(Parser, value, 1);
priorityLoadText3D = value == "yes";
return true;
}
if (token == "modelformat")
{
// e4d: a model with an .e4d file beside its .e3d / .t3d is loaded from it; legacy: the .e4d files are left alone
std::string value;
ParseOne(Parser, value, 1);
modelformat_e4d = value == "e4d";
return true;
}
if (token == "fpslimit")
{
float fpslimit = 0.f;
ParseOne(Parser, fpslimit, 1);
if (fpslimit > 0.f)
minframetime = std::chrono::duration<float>(1.0f / fpslimit);
return true;
}
if (token == "randomseed")
{
std::string text;
ParseOne(Parser, text);
// nothing after the key gives no seed; anything else does, 0 too
if (auto const seed{seed_given(text)})
{
Global.random_seed = *seed;
Global.random_seed_given = true;
}
return true;
}
if (token == "map.manualswitchcontrol")
{
ParseOne(Parser, map_manualswitchcontrol, 1);
return true;
}
if (token == "map.highlightdistance")
{
ParseOne(Parser, map_highlight_distance, 1);
return true;
}
if (token == "crashdamage")
{
ParseOne(Parser, crash_damage, 1);
return true;
}
if (token == "physics.trackbuckling")
{
// off, scenery: the buckles of the scenery and its events, auto: also by the temperature of the rails
std::string mode;
ParseOne(Parser, mode, 1);
if (mode == "off" || mode == "no")
track_buckling = track_buckling_mode::off;
else if (mode == "auto")
track_buckling = track_buckling_mode::automatic;
else
track_buckling = track_buckling_mode::scenery;
return true;
}
if (token == "couplerphysics")
{
// yes: the player's train and the trains it closes in on, all: every train
std::string scope;
ParseOne(Parser, scope, 1);
coupler_physics_all = scope == "all";
coupler_physics = coupler_physics_all || scope == "yes" || scope == "true" || scope == "1";
return true;
}
if (token == "physics.derailment")
{
// new: the physical criteria (McZapkie/derailment.h), old: the legacy draw, off: no derailment from the speed,
// monitor: the legacy draw, and the criteria to the log
std::string model;
ParseOne(Parser, model, 1);
derailment = derailment_model_of(model);
return true;
}
if (token == "physics.trackcheck")
{
ParseOne(Parser, track_check, 1);
return true;
}
if (token == "physics.collisions")
{
// new: the crush of the ends past the buffers (McZapkie/collision.h), old: the legacy rule, monitor: the legacy
// rule, and the crush to the log
std::string model;
ParseOne(Parser, model, 1);
collisions = collision_model_of(model);
return true;
}
if (token == "controlcoupling.enginecheck")
{
ParseOne(Parser, control_coupling_engine_check, 1);
return true;
}
return false;
}
bool global_settings::ConfigParseUI(cParser& Parser, const std::string& token)
{
if (token == "uitextcolor")
{
Parser.getTokens(3, false);
Parser >> UITextColor.r >> UITextColor.g >> UITextColor.b;
UITextColor = glm::clamp(UITextColor, 0.f, 255.f);
UITextColor = UITextColor / 255.f;
UITextColor.a = 1.f;
return true;
}
if (token == "ui.bg.opacity")
{
ParseOneClamped(Parser, UIBgOpacity, 0.f, 1.f);
return true;
}
if (token == "ui.fontsize")
{
ParseOne(Parser, ui_fontsize, 1);
return true;
}
if (token == "ui.scale")
{
ParseOne(Parser, ui_scale, 1);
return true;
}
if (token == "ui.viewports")
{
ParseOne(Parser, ui_viewports, 1);
return true;
}
if (token == "gui.defaultwindows")
{
ParseOne(Parser, gui_defaultwindows, 1);
return true;
}
if (token == "gui.showtranscripts")
{
ParseOne(Parser, gui_showtranscripts, 1);
return true;
}
if (token == "gui.trainingdefault")
{
ParseOne(Parser, gui_trainingdefault, 1);
return true;
}
return false;
}
bool global_settings::ConfigParseScriptScreens(cParser& Parser, std::string_view const token)
{
if (token == "luascreens.enabled")
{
ParseOne(Parser, luascreens_enabled, 1);
return true;
}
// the scenery scripts (lua in the .scn) with all of LuaJIT's libraries, for a scenery that needs io, ffi or
// require: they then reach files and programs as the player does. from eu07.ini only: a config block of the
// scenery doesn't change it (utilities/inionlysettings.h)
if (token == "lua.fulllibraries")
{
ParseOne(Parser, lua_fulllibraries, 1);
return true;
}
if (token == "wasm.enabled")
{
ParseOne(Parser, wasm_enabled, 1);
return true;
}
// wasm.cabframes and wasm.externalframes: the first names of the keys, from before the Lua screens
if (token == "screens.cabframes" || token == "wasm.cabframes")
{
ParseOneClamped(Parser, screens_cabframes, 1, 1000);
return true;
}
if (token == "screens.externalframes" || token == "wasm.externalframes")
{
ParseOneClamped(Parser, screens_externalframes, 1, 1000);
return true;
}
if (token == "screens.gpupost")
{
ParseOne(Parser, screens_gpupost, 1);
return true;
}
return false;
}
bool global_settings::ConfigParsePython(cParser& Parser, const std::string& token)
{
if (token == "python.enabled")
{
ParseOne(Parser, python_enabled, 1);
return true;
}
if (token == "python.updatetime")
{
ParseOne(Parser, PythonScreenUpdateRate);
return true;
}
if (token == "python.displaywindows")
{
ParseOne(Parser, python_displaywindows, 1);
return true;
}
if (token == "python.threadedupload")
{
ParseOne(Parser, python_threadedupload, 1);
return true;
}
if (token == "python.sharectx")
{
ParseOne(Parser, python_sharectx, 1);
return true;
}
if (token == "python.uploadmain")
{
ParseOne(Parser, python_uploadmain, 1);
return true;
}
if (token == "python.fpslimit")
{
float fpslimit = 0.f;
ParseOne(Parser, fpslimit, 1);
if (fpslimit > 0.f)
python_minframetime = std::chrono::duration<float>(1.0f / fpslimit);
return true;
}
if (token == "python.vsync")
{
ParseOne(Parser, python_vsync, 1);
return true;
}
if (token == "python.mipmaps")
{
ParseOne(Parser, python_mipmaps, 1);
return true;
}
if (token == "python.viewport")
{
Parser.getTokens(8, false);
pythonviewport_config conf;
Parser >> conf.surface >> conf.monitor
>> conf.size.x >> conf.size.y
>> conf.offset.x >> conf.offset.y
>> conf.scale.x >> conf.scale.y;
python_viewports.push_back(conf);
return true;
}
return false;
}
bool global_settings::ConfigParseNetwork(cParser& Parser, const std::string& token)
{
if (token == "network.server")
{
Parser.getTokens(2);
std::string backend;
std::string conf;
Parser >> backend >> conf;
network_servers.emplace_back(backend, conf);
return true;
}
if (token == "network.client")
{
Parser.getTokens(2);
network_client.emplace();
Parser >> network_client->first >> network_client->second;
return true;
}
return false;
}
bool global_settings::ConfigParseHardware(cParser& Parser, const std::string& token)
{
if (token == "feedbackmode")
{
ParseOne(Parser, iFeedbackMode, 1, false);
return true;
}
if (token == "feedbackport")
{
ParseOne(Parser, iFeedbackPort, 1, false);
return true;
}
if (token == "multiplayer")
{
ParseOne(Parser, iMultiplayer, 1, false);
return true;
}
if (token == "isolatedtrainnumber")
{
ParseOne(Parser, bIsolatedTrainName, 1, false);
return true;
}
if (token == "motiontelemetry")
{
Parser.getTokens(8);
Global.motiontelemetry_conf.enable = true;
Parser >> Global.motiontelemetry_conf.proto
>> Global.motiontelemetry_conf.address
>> Global.motiontelemetry_conf.port
>> Global.motiontelemetry_conf.updatetime
>> Global.motiontelemetry_conf.includegravity
>> Global.motiontelemetry_conf.fwdposbased
>> Global.motiontelemetry_conf.latposbased
>> Global.motiontelemetry_conf.axlebumpscale;
return true;
}
if (token == "vr.enabled")
{
ParseOne(Parser, vr, 1);
return true;
}
if (token == "vr.backend")
{
ParseOne(Parser, vr_backend, 1);
return true;
}
#ifdef WITH_UART
if (token == "uart")
{
uart_conf.enable = true;
Parser.getTokens(3, false);
Parser >> uart_conf.port
>> uart_conf.baud
>> uart_conf.updatetime;
return true;
}
if (token == "uarttune")
{
Parser.getTokens(18);
Parser >> uart_conf.mainbrakemin >> uart_conf.mainbrakemax
>> uart_conf.localbrakemin >> uart_conf.localbrakemax
>> uart_conf.tankmax >> uart_conf.tankuart
>> uart_conf.pipemax >> uart_conf.pipeuart
>> uart_conf.brakemax >> uart_conf.brakeuart
>> uart_conf.pantographmax >> uart_conf.pantographuart
>> uart_conf.hvmax >> uart_conf.hvuart
>> uart_conf.currentmax >> uart_conf.currentuart
>> uart_conf.lvmax >> uart_conf.lvuart;
return true;
}
if (token == "uarttachoscale")
{
ParseOne(Parser, uart_conf.tachoscale, 1);
return true;
}
if (token == "uartfeature")
{
Parser.getTokens(1);
std::string firstToken = Parser.peek();
if (firstToken.find('|') != std::string::npos || firstToken == "none" || uartfeatures_map.count(firstToken))
{
for (auto const& x : uartfeatures_map)
{
*x.second = false;
}
std::string key;
std::stringstream firstTokenStream(firstToken);
while (!firstTokenStream.eof())
{
std::getline(firstTokenStream, key, '|');
if (uartfeatures_map.count(key))
{
*uartfeatures_map[key] = true;
}
}
}
else
{
Parser >> uart_conf.mainenable;
Parser.getTokens(3);
Parser >> uart_conf.scndenable
>> uart_conf.trainenable
>> uart_conf.localenable;
}
return true;
}
if (token == "uartdebug")
{
ParseOne(Parser, uart_conf.debug, 1);
return true;
}
if (token == "uartmainpercentage")
{
ParseOne(Parser, uart_conf.mainpercentage, 1);
return true;
}
#endif
#ifdef WITH_ZMQ
if (token == "zmq.address")
{
ParseOne(Parser, zmq_address, 1);
return true;
}
#endif
#ifdef USE_EXTCAM_CAMERA
if (token == "extcam.cmd")
{
ParseOne(Parser, extcam_cmd, 1);
return true;
}
if (token == "extcam.rec")
{
ParseOne(Parser, extcam_rec, 1);
return true;
}
if (token == "extcam.res")
{
Parser.getTokens(2);
Parser >> extcam_res.x >> extcam_res.y;
return true;
}
#endif
return false;
}
bool global_settings::ConfigParseDebug(cParser& Parser, const std::string& token)
{
if (token == "debugmode")
{
ParseOne(Parser, DebugModeFlag);
return true;
}
if (token == "debug.memorystats")
{
ParseOne(Parser, debug_memorystats);
return true;
}
if (token == "debuglog")
{
std::string value;
ParseOne(Parser, value);
if (value == "yes")
iWriteLogEnabled = 3;
else if (value == "no")
iWriteLogEnabled = 0;
else
iWriteLogEnabled = stol_def(value, 3);
return true;
}
if (token == "multiplelogs")
{
ParseOne(Parser, MultipleLogs);
return true;
}
if (token == "crashdump.full")
{
ParseOne(Parser, crashdump_full);
return true;
}
if (token == "showsystemconsole")
{
ParseOne(Parser, ShowSystemConsole);
return true;
}
if (token == "shakefactor")
{
ParseOne(Parser, ShakingMultiplierBF);
ParseOne(Parser, ShakingMultiplierRL);
ParseOne(Parser, ShakingMultiplierUD);
return true;
}
if (token == "logs.filter")
{
ParseOne(Parser, DisabledLogTypes);
return true;
}
if (token == "rollfix")
{
ParseOne(Parser, bRollFix);
return true;
}
if (token == "loadinglog")
{
ParseOne(Parser, loading_log, 1);
return true;
}
if (token == "captureonstart")
{
ParseOne(Parser, captureonstart, 1);
return true;
}
if (token == "ddsupperorigin")
{
ParseOne(Parser, dds_upper_origin, 1);
return true;
}
if (token == "calibratein")
{
Parser.getTokens(1, false);
int in = 0;
Parser >> in;
if (in < 0 || in > 5)
in = 5;
Parser.getTokens(4, false);
Parser >> fCalibrateIn[in][0]
>> fCalibrateIn[in][1]
>> fCalibrateIn[in][2]
>> fCalibrateIn[in][3];
fCalibrateIn[in][4] = 0.0;
fCalibrateIn[in][5] = 0.0;
return true;
}
if (token == "calibrate5din")
{
Parser.getTokens(1, false);
int in = 0;
Parser >> in;
if (in < 0 || in > 5)
in = 5;
Parser.getTokens(6, false);
Parser >> fCalibrateIn[in][0]
>> fCalibrateIn[in][1]
>> fCalibrateIn[in][2]
>> fCalibrateIn[in][3]
>> fCalibrateIn[in][4]
>> fCalibrateIn[in][5];
return true;
}
if (token == "calibrateout")
{
Parser.getTokens(1, false);
int out = 0;
Parser >> out;
if (out < 0 || out > 6)
out = 6;
Parser.getTokens(4, false);
Parser >> fCalibrateOut[out][0]
>> fCalibrateOut[out][1]
>> fCalibrateOut[out][2]
>> fCalibrateOut[out][3];
fCalibrateOut[out][4] = 0.0;
fCalibrateOut[out][5] = 0.0;
return true;
}
if (token == "calibrate5dout")
{
Parser.getTokens(1, false);
int out = 0;
Parser >> out;
if (out < 0 || out > 6)
out = 6;
Parser.getTokens(6, false);
Parser >> fCalibrateOut[out][0]
>> fCalibrateOut[out][1]
>> fCalibrateOut[out][2]
>> fCalibrateOut[out][3]
>> fCalibrateOut[out][4]
>> fCalibrateOut[out][5];
return true;
}
if (token == "calibrateoutmaxvalues")
{
Parser.getTokens(7, false);
Parser >> fCalibrateOutMax[0]
>> fCalibrateOutMax[1]
>> fCalibrateOutMax[2]
>> fCalibrateOutMax[3]
>> fCalibrateOutMax[4]
>> fCalibrateOutMax[5]
>> fCalibrateOutMax[6];
return true;
}
if (token == "calibrateoutdebuginfo")
{
ParseOne(Parser, iCalibrateOutDebugInfo, 1, false);
return true;
}
if (token == "pwm")
{
Parser.getTokens(2, false);
int pwm_out = 0;
int pwm_no = 0;
Parser >> pwm_out >> pwm_no;
iPoKeysPWM[pwm_out] = pwm_no;
return true;
}
return false;
}
void global_settings::ConfigParse(cParser& Parser, config_source const Source)
{
// what a scenery doesn't change, kept before its keys are read
std::optional<ini_only_settings> const inionly{Source == config_source::scenery ? std::make_optional<ini_only_settings>(*this) : std::nullopt};
std::string token;
do
{
token.clear();
Parser.getTokens();
Parser >> token;
if (token.empty() || token == "endconfig")
break;
if (ConfigParse_gfx(Parser, token))
continue;
if (ConfigParse_gfx_lamps(Parser, token))
continue;
if (ConfigParseGeneral(Parser, token))
continue;
if (ConfigParseAudio(Parser, token))
continue;
if (ConfigParseGraphics(Parser, token))
continue;
if (ConfigParseInput(Parser, token))
continue;
if (ConfigParseSimulation(Parser, token))
continue;
if (ConfigParseUI(Parser, token))
continue;
if (ConfigParsePython(Parser, token))
continue;
if (ConfigParseScriptScreens(Parser, token))
continue;
if (ConfigParseNetwork(Parser, token))
continue;
if (ConfigParseHardware(Parser, token))
continue;
if (ConfigParseDebug(Parser, token))
continue;
if (ConfigParseTest(Parser, token))
continue;
// WriteLog(std::format("Unknown config token: {}", token), logtype::warning, false);
} while (true);
if (inionly.has_value())
{
// put back before FinalizeConfig() acts on them (feedbackmode)
for (auto const key : inionly->restore(*this))
{
ErrorLog("scenery config: \"" + std::string(key) + "\" is read from eu07.ini only, ignored");
}
}
FinalizeConfig();
}
bool
global_settings::ConfigParse_gfx( cParser &Parser, std::string_view const Token ) {
// TODO: move other graphics switches here
auto tokenparsed { true };
if (Token == "gfx.shadows.cab.range")
{
// shadow render toggle
Parser.getTokens();
Parser >> RenderCabShadowsRange;
}
else if (Token == "gfx.smoke")
{
// smoke visualization toggle
Parser.getTokens();
Parser >> Smoke;
}
else if (Token == "gfx.smoke.fidelity")
{
// smoke visualization fidelity
float smokefidelity;
Parser.getTokens();
Parser >> smokefidelity;
SmokeFidelity = std::clamp(smokefidelity, 1.f, 4.f);
}
else if (Token == "gfx.resource.sweep")
{
Parser.getTokens();
Parser >> ResourceSweep;
}
else if (Token == "gfx.resource.move")
{
Parser.getTokens();
Parser >> ResourceMove;
}
else if (Token == "gfx.textures.streaming")
{
Parser.getTokens();
Parser >> gfx_texture_streaming;
}
else if (Token == "gfx.textures.releasedistance")
{
// multiplier of the draw range, 0 turns the release off. textures within the draw range are never released
Parser.getTokens();
Parser >> gfx_texture_releasedistance;
gfx_texture_releasedistance = (gfx_texture_releasedistance > 0.f ? std::max(gfx_texture_releasedistance, 1.f) : 0.f);
}
else if (Token == "gfx.reflections.framerate")
{
auto const updatespersecond{std::abs(Parser.getToken<double>())};
reflectiontune.update_interval = 1.0 / updatespersecond;
}
else if (Token == "gfx.reflections.fidelity")
{
Parser.getTokens(1, false);
Parser >> reflectiontune.fidelity;
reflectiontune.fidelity = std::clamp(reflectiontune.fidelity, 0, 2);
}
else if (Token == "gfx.reflections.range_instances")
{
Parser.getTokens(1, false);
Parser >> reflectiontune.range_instances;
}
else if (Token == "gfx.reflections.range_vehicles")
{
Parser.getTokens(1, false);
Parser >> reflectiontune.range_vehicles;
}
else if ((Token == "gfx.framebuffer.width") || (Token == "gfx.framebuffer.height"))
{
// the size of the image is a part of the size of the window now (gfx.buffer.percent)
Parser.getTokens(1, false);
int ignored{0};
Parser >> ignored;
WriteLog("eu07.ini: \"" + std::string(Token) + "\" is no longer supported and was ignored, use gfx.buffer.percent");
}
else if (Token == "gfx.buffer.percent")
{
// a part of the window: 0.5 is half its width and half its height. a value over 4 is taken as percents (50: 0.5)
Parser.getTokens(1, false);
Parser >> gfx_buffer_scale;
if (gfx_buffer_scale > 4.f)
{
gfx_buffer_scale *= 0.01f;
}
gfx_buffer_scale = std::clamp(gfx_buffer_scale, 0.25f, 2.f);
}
else if (Token == "gfx.shadowmap.enabled")
{
Parser.getTokens(1);
Parser >> gfx_shadowmap_enabled;
}
else if (Token == "gfx.envmap.enabled")
{
Parser.getTokens(1);
Parser >> gfx_envmap_enabled;
}
else if (Token == "gfx.lights.clustered")
{
Parser.getTokens(1);
Parser >> gfx_lights_clustered;
}
else if (Token == "gfx.gpucull")
{
// yes: culled and drawn from the gpu, compare: culled on both, drawn by the cpu, anything else: cpu
Parser.getTokens(1);
std::string mode;
Parser >> mode;
gfx_gpucull = (mode == "yes" || mode == "true" || mode == "1") ? 1 : (mode == "compare" || mode == "2") ? 2 : 0;
}
else if (Token == "gfx.gpucull.occlusion")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_occlusion;
}
else if (Token == "gfx.gpucull.occlusion.instances")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_occlusion_instances;
}
else if (Token == "gfx.depthprepass")
{
Parser.getTokens(1);
Parser >> gfx_depthprepass;
}
else if (Token == "gfx.gpucull.multidraw")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_multidraw;
}
else if (Token == "gfx.gpucull.shadows")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_shadows;
}
else if (Token == "gfx.gpucull.reflections")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_reflections;
}
else if (Token == "gfx.gpucull.shadows.headlights")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_shadows_headlights;
}
else if (Token == "gfx.gpucull.shadows.lamps")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_shadows_lamps;
}
else if (Token == "gfx.gpucull.sleepers")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_sleepers;
}
else if (Token == "gfx.gpucull.models")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_models;
}
else if (Token == "gfx.gpucull.bucketrange")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_bucketrange;
}
else if (Token == "gfx.gpucull.walkcache")
{
Parser.getTokens(1);
Parser >> gfx_gpucull_walkcache;
}
else if (Token == "gfx.geometry.shared")
{
Parser.getTokens(1);
Parser >> gfx_geometry_shared;
}
else if (Token == "gfx.depthprepass.scene")
{
Parser.getTokens(1);
Parser >> gfx_depthprepass_scene;
}
else if (Token == "gfx.depthprepass.replay")
{
Parser.getTokens(1);
Parser >> gfx_depthprepass_replay;
}
else if (Token == "gfx.grass")
{
Parser.getTokens(1);
Parser >> gfx_grass;
}
else if (Token == "gfx.grass.distance")
{
Parser.getTokens(1);
Parser >> gfx_grass_distance;
gfx_grass_distance = std::clamp(gfx_grass_distance, 5.f, 500.f);
}
else if (Token == "gfx.grass.fadedistance")
{
Parser.getTokens(1);
Parser >> gfx_grass_fadedistance;
gfx_grass_fadedistance = std::clamp(gfx_grass_fadedistance, 5.f, 600.f);
}
else if (Token == "gfx.grass.density")
{
Parser.getTokens(1);
Parser >> gfx_grass_density;
gfx_grass_density = std::clamp(gfx_grass_density, 0.f, 4.f);
}
else if (Token == "gfx.smoke.gpu")
{
Parser.getTokens(1);
Parser >> gfx_smoke_gpu;
}
else if (Token == "gfx.smoke.lighting")
{
Parser.getTokens(1);
Parser >> gfx_smoke_lighting;
}
else if (Token == "gfx.particles.soft")
{
Parser.getTokens(1);
Parser >> gfx_particles_soft;
gfx_particles_soft = std::clamp(gfx_particles_soft, 0.f, 4.f);
}
else if (Token == "gfx.precipitation.gpu")
{
Parser.getTokens(1);
Parser >> gfx_precipitation_gpu;
}
else if (Token == "gfx.precipitation.particles")
{
Parser.getTokens(1);
Parser >> gfx_precipitation_particles;
gfx_precipitation_particles = std::clamp(gfx_precipitation_particles, 0, 1 << 20);
}
else if (Token == "gfx.bufferstreaming")
{
Parser.getTokens(1);
Parser >> gfx_bufferstreaming;
}
else if (Token == "gfx.lights.clusterheatmap")
{
Parser.getTokens(1);
Parser >> gfx_lights_clusterheatmap;
}
else if (Token == "gfx.postfx.motionblur.enabled")
{
Parser.getTokens(1);
Parser >> gfx_postfx_motionblur_enabled;
}
else if (Token == "gfx.postfx.motionblur.shutter")
{
Parser.getTokens(1);
Parser >> gfx_postfx_motionblur_shutter;
}
else if (Token == "gfx.postfx.motionblur.format")
{
Parser.getTokens(1);
std::string value;
Parser >> value;
if (value == "rg16f")
gfx_postfx_motionblur_format = GL_RG16F;
else if (value == "rg32f")
gfx_postfx_motionblur_format = GL_RG32F;
}
else if (Token == "gfx.postfx.chromaticaberration.enabled")
{
Parser.getTokens(1);
Parser >> gfx_postfx_chromaticaberration_enabled;
}
else if (Token == "gfx.format.color")
{
Parser.getTokens(1);
std::string value;
Parser >> value;
if (value == "rgb8")
gfx_format_color = GL_RGB8;
else if (value == "rgb16f")
gfx_format_color = GL_RGB16F;
else if (value == "rgb32f")
gfx_format_color = GL_RGB32F;
else if (value == "r11f_g11f_b10f")
gfx_format_color = GL_R11F_G11F_B10F;
}
else if (Token == "gfx.format.depth")
{
Parser.getTokens(1);
std::string value;
Parser >> value;
if (value == "z16")
gfx_format_depth = GL_DEPTH_COMPONENT16;
else if (value == "z24")
gfx_format_depth = GL_DEPTH_COMPONENT24;
else if (value == "z32")
gfx_format_depth = GL_DEPTH_COMPONENT32;
else if (value == "z32f")
gfx_format_depth = GL_DEPTH_COMPONENT32F;
}
else if (Token == "gfx.skiprendering")
{
Parser.getTokens(1);
Parser >> gfx_skiprendering;
}
else if (Token == "gfx.skippipeline")
{
Parser.getTokens(1);
Parser >> gfx_skippipeline;
}
else if (Token == "gfx.extraeffects")
{
Parser.getTokens(1);
Parser >> gfx_extraeffects;
}
else if (Token == "gfx.usegles")
{
// the OpenGL ES / ANGLE path was removed; read and ignore so old eu07.ini files still load
bool usegles{false};
Parser.getTokens(1);
Parser >> usegles;
WriteLog("eu07.ini: \"gfx.usegles\" is no longer supported and was ignored");
}
else if (Token == "gfx.shadergamma")
{
Parser.getTokens(1);
Parser >> gfx_shadergamma;
}
else if (Token == "gfx.shaders.binaries")
{
Parser.getTokens(1);
Parser >> gfx_shader_binaries;
}
else if (Token == "gfx.drawrange.factor.max")
{
Parser.getTokens(1);
Parser >> gfx_distance_factor_max;
}
else if (Token == "gfx.shadow.angle.min")
{
Parser.getTokens(1);
Parser >> gfx_shadow_angle_min;
// variable internally uses negative values, but is presented as positive in settings
// so it's likely it'll be supplied as positive number by external launcher
if( gfx_shadow_angle_min > 0 ) {
gfx_shadow_angle_min *= -1;
}
gfx_shadow_angle_min = std::clamp(gfx_shadow_angle_min, -1.f, -0.2f);
}
else if (Token == "gfx.shadow.rank.cutoff")
{
Parser.getTokens(1);
Parser >> gfx_shadow_rank_cutoff;
gfx_shadow_rank_cutoff = std::clamp(gfx_shadow_rank_cutoff, 1, 3);
}
else if (Token == "gfx.shadow.sdsm")
{
Parser.getTokens(1);
Parser >> gfx_shadow_sdsm;
}
else if (Token == "gfx.shadow.sdsm.split")
{
Parser.getTokens(1);
Parser >> gfx_shadow_sdsm_split;
gfx_shadow_sdsm_split = std::clamp(gfx_shadow_sdsm_split, 0.f, 1.f);
}
else if (Token == "gfx.vulkan.device")
{
// index of the gpu in the list of the log, or a part of its name
Parser.getTokens(1, false);
Parser >> gfx_vulkan_device;
}
else if (Token == "gfx.vulkan.validation")
{
// no/yes, 2: also gpu-assisted
std::string value;
Parser.getTokens(1);
Parser >> value;
gfx_vulkan_validation = (value == "2" ? 2 : (value == "yes" || value == "true" || value == "1") ? 1 : 0);
}
else if (Token == "gfx.vulkan.framesinflight")
{
Parser.getTokens(1);
Parser >> gfx_vulkan_framesinflight;
gfx_vulkan_framesinflight = std::clamp(gfx_vulkan_framesinflight, 2, 3);
}
else if (Token == "gfx.vulkan.renderthread")
{
Parser.getTokens(1);
Parser >> gfx_vulkan_renderthread;
}
else if (Token == "gfx.threads")
{
// 0: the cores less two
Parser.getTokens(1);
Parser >> gfx_threads;
gfx_threads = std::clamp(gfx_threads, 0, 64);
}
else if (Token == "gfx.vulkan.asyncresources")
{
Parser.getTokens(1);
Parser >> gfx_vulkan_asyncresources;
}
else if (Token == "gfx.vulkan.parallelpasses")
{
Parser.getTokens(1);
Parser >> gfx_vulkan_parallelpasses;
}
else if (Token == "gfx.vulkan.parallelmodels")
{
Parser.getTokens(1);
Parser >> gfx_vulkan_parallelmodels;
}
else if (Token == "gfx.vulkan.asynccompute")
{
Parser.getTokens(1);
Parser >> gfx_vulkan_asynccompute;
}
else if (Token == "gfx.vulkan.checkpoints")
{
Parser.getTokens(1);
Parser >> gfx_vulkan_checkpoints;
}
else if (ConfigParse_gfx_sky(Parser, Token))
{
// parsed
}
else
{
tokenparsed = false;
}
return tokenparsed;
}
bool
global_settings::ConfigParse_gfx_sky( cParser &Parser, std::string_view const Token ) {
// switches take yes/no (or true/false, 1/0), scales take a number. a missing entry keeps the default
auto const readswitch = [&]( bool &Value ) {
Parser.getTokens( 1 );
Parser >> Value; };
auto const readvalue = [&]( float &Value, float const Min, float const Max ) {
Parser.getTokens( 1 );
Parser >> Value;
Value = std::clamp( Value, Min, Max ); };
if( Token == "gfx.ambient.sh" ) { readswitch( gfx_ambient_sh ); }
else if( Token == "gfx.ambient.sh.strength" ) { readvalue( gfx_ambient_sh_strength, 0.f, 2.f ); }
else if( Token == "gfx.ambient.groundalbedo" ) { readvalue( gfx_ambient_groundalbedo, 0.f, 1.f ); }
else if( Token == "gfx.envmap.ggx" ) { readswitch( gfx_envmap_ggx ); }
else if( Token == "gfx.atmosphere" ) { readswitch( gfx_atmosphere ); }
else if( Token == "gfx.atmosphere.sky" ) { readvalue( gfx_atmosphere_sky, 0.f, 16.f ); }
else if( Token == "gfx.atmosphere.ambient" ) { readvalue( gfx_atmosphere_ambient, 0.f, 16.f ); }
else if( Token == "gfx.atmosphere.sun" ) { readvalue( gfx_atmosphere_sun, 0.f, 16.f ); }
else if( Token == "gfx.atmosphere.haze" ) { readvalue( gfx_atmosphere_haze, 0.f, 32.f ); }
else if( Token == "gfx.atmosphere.altitude" ) { readvalue( gfx_atmosphere_altitude, 0.f, 9000.f ); }
else if( Token == "gfx.postfx.autoexposure" ) { readswitch( gfx_postfx_autoexposure ); }
else if( Token == "gfx.postfx.autoexposure.key" ) { readvalue( gfx_postfx_autoexposure_key, 0.001f, 100.f ); }
else if( Token == "gfx.postfx.autoexposure.min" ) { readvalue( gfx_postfx_autoexposure_min, -16.f, 0.f ); }
else if( Token == "gfx.postfx.autoexposure.max" ) { readvalue( gfx_postfx_autoexposure_max, 0.f, 16.f ); }
else if( Token == "gfx.postfx.autoexposure.max.cab" ) { readvalue( gfx_postfx_autoexposure_max_cab, 0.f, 16.f ); }
else if( Token == "gfx.postfx.autoexposure.speed.dark" ) { readvalue( gfx_postfx_autoexposure_speed_dark, 0.01f, 100.f ); }
else if( Token == "gfx.postfx.autoexposure.speed.bright" ) { readvalue( gfx_postfx_autoexposure_speed_bright, 0.01f, 100.f ); }
else if( Token == "gfx.postfx.autoexposure.compensation" ) { readvalue( gfx_postfx_autoexposure_compensation, -16.f, 16.f ); }
else if( Token == "gfx.postfx.bloom" ) { readswitch( gfx_postfx_bloom ); }
else if( Token == "gfx.postfx.bloom.intensity" ) { readvalue( gfx_postfx_bloom_intensity, 0.f, 1.f ); }
else if( Token == "gfx.postfx.bloom.threshold" ) { readvalue( gfx_postfx_bloom_threshold, 0.f, 1000.f ); }
else if( Token == "gfx.postfx.whitebalance" ) { readswitch( gfx_postfx_whitebalance ); }
else if( Token == "gfx.postfx.whitebalance.temperature" ) { readvalue( gfx_postfx_whitebalance_temperature, 4000.f, 25000.f ); }
else if( Token == "gfx.postfx.whitebalance.tint" ) { readvalue( gfx_postfx_whitebalance_tint, -1.f, 1.f ); }
else if( Token == "gfx.postfx.ao" ) {
// yes/gtao: ground truth ambient occlusion, ssao: the older one, anything else: off
Parser.getTokens( 1 );
std::string mode;
Parser >> mode;
gfx_postfx_ao = ( mode == "yes" || mode == "true" || mode == "1" || mode == "gtao" ) ? 2 : ( mode == "ssao" ) ? 1 : 0; }
else if( Token == "gfx.postfx.ao.radius" ) { readvalue( gfx_postfx_ao_radius, 0.1f, 10.f ); }
else if( Token == "gfx.postfx.ao.strength" ) { readvalue( gfx_postfx_ao_strength, 0.f, 4.f ); }
else if( Token == "gfx.postfx.ao.bounce" ) { readvalue( gfx_postfx_ao_bounce, 0.f, 1.f ); }
else if( Token == "gfx.postfx.ao.cab" ) { readvalue( gfx_postfx_ao_cab, 0.f, 1.f ); }
else if( Token == "gfx.postfx.ao.quality" ) {
// slices and steps per side
Parser.getTokens( 2, false );
Parser >> gfx_postfx_ao_slices >> gfx_postfx_ao_steps;
gfx_postfx_ao_slices = std::clamp( gfx_postfx_ao_slices, 1, 8 );
gfx_postfx_ao_steps = std::clamp( gfx_postfx_ao_steps, 1, 16 ); }
else if( Token == "gfx.postfx.ao.lighting" ) { readswitch( gfx_postfx_ao_lighting ); }
else if( Token == "gfx.lights.scenery" ) { readswitch( gfx_lights_scenery ); }
else if( Token == "gfx.lights.vehicles" ) { readswitch( gfx_lights_vehicles ); }
else if( Token == "gfx.lights.headlights" ) { readswitch( gfx_lights_headlights ); }
else if( Token == "gfx.lights.cab" ) { readswitch( gfx_lights_cab ); }
else if( Token == "gfx.lights.freespot.intensity" ) { readvalue( gfx_lights_freespot_intensity, 0.f, 1000.f ); }
else if( Token == "gfx.lights.compartment.intensity" ) { readvalue( gfx_lights_compartment_intensity, 0.f, 100.f ); }
else if( Token == "gfx.lights.cab.intensity" ) { readvalue( gfx_lights_cab_intensity, 0.f, 100.f ); }
else if( Token == "gfx.lights.cab.bounce" ) { readvalue( gfx_lights_cab_bounce, 0.f, 1.f ); }
else if( Token == "gfx.cabprobe" ) {
// no/low/medium/high, or the number of the level
Parser.getTokens( 1 );
std::string level;
Parser >> level;
gfx_cabprobe =
( level == "low" || level == "1" ) ? 1 :
( level == "medium" || level == "yes" || level == "true" || level == "2" ) ? 2 :
( level == "high" || level == "3" ) ? 3 :
0; }
else if( Token == "gfx.cabprobe.interval" ) {
Parser.getTokens( 1 );
Parser >> gfx_cabprobe_interval;
gfx_cabprobe_interval = std::clamp( gfx_cabprobe_interval, 1, 120 ); }
else if( Token == "gfx.cabprobe.bounce" ) { readvalue( gfx_cabprobe_bounce, 0.f, 4.f ); }
else if( Token == "gfx.cabprobe.reflections" ) { readswitch( gfx_cabprobe_reflections ); }
else if( Token == "gfx.cabprobe.sun" ) { readvalue( gfx_cabprobe_sun, 0.f, 4.f ); }
else if( Token == "gfx.interior.bounce" ) { readvalue( gfx_interior_bounce, 0.f, 1.f ); }
else if( Token == "gfx.water.realistic" ) { readswitch( gfx_water_realistic ); }
else if( Token == "gfx.skyvisibility" ) {
// no/low/medium/high, or the number of the level
Parser.getTokens( 1 );
std::string level;
Parser >> level;
gfx_skyvisibility =
( level == "low" || level == "1" ) ? 1 :
( level == "medium" || level == "yes" || level == "true" || level == "2" ) ? 2 :
( level == "high" || level == "3" ) ? 3 :
0; }
else if( Token == "gfx.skyvisibility.sun" ) { readswitch( gfx_skyvisibility_sun ); }
else if( Token == "gfx.skyvisibility.fog" ) { readswitch( gfx_skyvisibility_fog ); }
else if( Token == "gfx.skyvisibility.tunnels" ) { readswitch( gfx_skyvisibility_tunnels ); }
else if( Token == "gfx.tunnelflags" ) { readswitch( gfx_tunnelflags ); }
else if( Token == "gfx.lights.range" ) { readvalue( gfx_lights_range, 0.f, 2000.f ); }
else if( Token == "gfx.lights.shadows" ) {
// no/low/medium/high, or the number of the level
Parser.getTokens( 1 );
std::string level;
Parser >> level;
gfx_lights_shadows =
( level == "low" || level == "1" ) ? 1 :
( level == "medium" || level == "yes" || level == "true" || level == "2" ) ? 2 :
( level == "high" || level == "3" ) ? 3 :
0; }
else if( Token == "gfx.lights.shadows.cab" ) {
Parser.getTokens( 1 );
Parser >> gfx_lights_shadows_cab;
gfx_lights_shadows_cab = std::clamp( gfx_lights_shadows_cab, 0, 16 ); }
else if( Token == "gfx.lights.shadows.lamps" ) {
Parser.getTokens( 1 );
Parser >> gfx_lights_shadows_lamps;
gfx_lights_shadows_lamps = std::clamp( gfx_lights_shadows_lamps, 0, 32 ); }
else if( Token == "gfx.lights.shadows.lamps.size" ) {
Parser.getTokens( 1 );
Parser >> gfx_lights_shadows_lamps_size;
gfx_lights_shadows_lamps_size = std::clamp( gfx_lights_shadows_lamps_size, 128, 2048 ); }
else if( Token == "gfx.lights.shadows.lamps.range" ) { readvalue( gfx_lights_shadows_lamps_range, 0.f, 1000.f ); }
else if( Token == "gfx.lights.shadows.vehicles.range" ) { readvalue( gfx_lights_shadows_vehicles_range, 0.f, 1000.f ); }
else if( Token == "gfx.lights.shadows.headlights" ) {
Parser.getTokens( 1 );
Parser >> gfx_lights_shadows_headlights;
gfx_lights_shadows_headlights = std::clamp( gfx_lights_shadows_headlights, 0, 4 ); }
else if( Token == "gfx.lights.shadows.headlights.range" ) { readvalue( gfx_lights_shadows_headlights_range, 10.f, 1000.f ); }
else if( Token == "gfx.contactshadows" ) {
// no/low/medium/high, or the number of the level
Parser.getTokens( 1 );
std::string level;
Parser >> level;
gfx_contactshadows =
( level == "low" || level == "1" ) ? 1 :
( level == "medium" || level == "yes" || level == "true" || level == "2" ) ? 2 :
( level == "high" || level == "3" ) ? 3 :
0; }
else if( Token == "gfx.contactshadows.length" ) { readvalue( gfx_contactshadows_length, 0.05f, 5.f ); }
else if( Token == "gfx.contactshadows.range" ) { readvalue( gfx_contactshadows_range, 1.f, 1000.f ); }
else if( Token == "gfx.ssr" ) {
// no/low/medium/high, or the number of the level
Parser.getTokens( 1 );
std::string level;
Parser >> level;
gfx_ssr =
( level == "low" || level == "1" ) ? 1 :
( level == "medium" || level == "yes" || level == "true" || level == "2" ) ? 2 :
( level == "high" || level == "3" ) ? 3 :
0; }
else if( Token == "gfx.ssr.range" ) { readvalue( gfx_ssr_range, 10.f, 2000.f ); }
else if( Token == "gfx.ssr.roughness" ) { readvalue( gfx_ssr_roughness, 0.f, 1.f ); }
else if( Token == "gfx.raytracing" ) { readswitch( gfx_raytracing ); }
else if( Token == "gfx.raytracing.range" ) { readvalue( gfx_raytracing_range, 10.f, 5000.f ); }
else if( Token == "gfx.fog" ) {
// volumetric (yes) or analytic (no, old): the same weather either way
Parser.getTokens( 1 );
std::string mode;
Parser >> mode;
gfx_fog = ( mode == "analytic" || mode == "old" || mode == "no" || mode == "false" || mode == "0" ) ? 0 : 1; }
else if( Token == "gfx.fog.quality" ) {
Parser.getTokens( 1 );
std::string level;
Parser >> level;
gfx_fog_quality = ( level == "low" || level == "1" ) ? 1 : ( level == "high" || level == "3" ) ? 3 : ( level == "ultra" || level == "4" ) ? 4 : 2; }
else if( Token == "gfx.antialiasing" ) {
// off, msaax2, msaax4, msaax8, taa, dlss or dlaa; it sets the multisampling too, the key which used to say it
Parser.getTokens( 1 );
std::string mode;
Parser >> mode;
std::transform( mode.begin(), mode.end(), mode.begin(), []( unsigned char c ) { return static_cast<char>( std::tolower( c ) ); } );
gfx_dlss_native = false;
if( mode == "taa" ) {
gfx_antialiasing = antialiasing_mode::taa;
iMultisampling = 0; }
else if( mode == "dlss" || mode == "dlaa" ) {
gfx_antialiasing = antialiasing_mode::dlss;
gfx_dlss_native = ( mode == "dlaa" );
iMultisampling = 0; }
else if( mode == "msaax2" || mode == "msaax4" || mode == "msaax8" || mode == "msaax16" ) {
gfx_antialiasing = antialiasing_mode::msaa;
iMultisampling = ( mode == "msaax2" ) ? 1 : ( mode == "msaax4" ) ? 2 : ( mode == "msaax8" ) ? 3 : 4; }
else if( mode == "off" || mode == "no" || mode == "none" || mode == "0" ) {
gfx_antialiasing = antialiasing_mode::off;
iMultisampling = 0; }
else {
ErrorLog( "Bad config: unknown gfx.antialiasing \"" + mode + "\", expected off, msaax2, msaax4, msaax8, taa, dlss or dlaa" ); } }
else if( Token == "gfx.dlss.preset" ) {
// the presets of the dlss sdk 310 (the others are gone, deprecated or reserved)
Parser.getTokens( 1 );
std::string preset;
Parser >> preset;
std::transform( preset.begin(), preset.end(), preset.begin(), []( unsigned char c ) { return static_cast<char>( std::tolower( c ) ); } );
gfx_dlss_preset = ( preset == "j" ) ? 10 : ( preset == "k" ) ? 11 : ( preset == "l" ) ? 12 : ( preset == "m" ) ? 13 : 0;
if( ( gfx_dlss_preset == 0 ) && ( preset != "default" ) ) {
ErrorLog( "Bad config: unknown gfx.dlss.preset \"" + preset + "\", expected default, j, k, l or m" ); } }
else if( Token == "gfx.dlss.autoexposure" ) { readswitch( gfx_dlss_autoexposure ); }
else if( Token == "gfx.dlss.lodbias" ) { readvalue( gfx_dlss_lodbias, -2.f, 2.f ); }
else if( Token == "gfx.dlss.developer" ) { readswitch( gfx_dlss_developer ); }
else if( Token == "gfx.framegeneration" ) {
Parser.getTokens( 1 );
std::string mode;
Parser >> mode;
std::transform( mode.begin(), mode.end(), mode.begin(), []( unsigned char c ) { return static_cast<char>( std::tolower( c ) ); } );
gfx_framegeneration = ( mode == "x2" || mode == "on" || mode == "yes" || mode == "2" ) ? 2 : ( mode == "x3" || mode == "3" ) ? 3 : ( mode == "x4" || mode == "4" ) ? 4 : 1;
if( ( gfx_framegeneration == 1 ) && ( mode != "off" ) && ( mode != "no" ) && ( mode != "1" ) ) {
ErrorLog( "Bad config: unknown gfx.framegeneration \"" + mode + "\", expected off, x2, x3 or x4" ); } }
else if( Token == "gfx.reflex" ) {
Parser.getTokens( 1 );
std::string mode;
Parser >> mode;
std::transform( mode.begin(), mode.end(), mode.begin(), []( unsigned char c ) { return static_cast<char>( std::tolower( c ) ); } );
gfx_reflex = ( mode == "on" || mode == "yes" || mode == "1" ) ? 1 : ( mode == "boost" || mode == "2" ) ? 2 : 0;
if( ( gfx_reflex == 0 ) && ( mode != "off" ) && ( mode != "no" ) && ( mode != "0" ) ) {
ErrorLog( "Bad config: unknown gfx.reflex \"" + mode + "\", expected off, on or boost" ); } }
else if( Token == "gfx.fog.range" ) { readvalue( gfx_fog_range, 100.f, 10000.f ); }
else if( Token == "gfx.fog.lights" ) { readvalue( gfx_fog_lights, 0.f, 10.f ); }
else if( Token == "gfx.fog.shadows" ) { readswitch( gfx_fog_shadows ); }
else if( Token == "gfx.fog.temporal" ) { readswitch( gfx_fog_temporal ); }
else if( Token == "gfx.fog.temporal.share" ) { readvalue( gfx_fog_temporal_share, 0.02f, 1.f ); }
else if( Token == "gfx.weather.occlusion" ) { readswitch( gfx_weather_occlusion ); }
else if( Token == "gfx.clouds.interleave" ) { readswitch( gfx_clouds_interleave ); }
else if( Token == "gfx.clouds" ) {
// no, or the quality: low, medium (yes), high, ultra
Parser.getTokens( 1 );
std::string level;
Parser >> level;
gfx_clouds =
( level == "low" || level == "1" ) ? 1 :
( level == "medium" || level == "yes" || level == "true" || level == "2" ) ? 2 :
( level == "high" || level == "3" ) ? 3 :
( level == "ultra" || level == "4" ) ? 4 :
0; }
else if( Token == "gfx.clouds.distance" ) { readvalue( gfx_clouds_distance, 5000.f, 200000.f ); }
else if( Token == "gfx.clouds.shadows" ) { readswitch( gfx_clouds_shadows ); }
else if( Token == "gfx.clouds.shadows.size" ) {
Parser.getTokens( 1 );
Parser >> gfx_clouds_shadows_size;
gfx_clouds_shadows_size = std::clamp( gfx_clouds_shadows_size, 64, 2048 ); }
else if( Token == "gfx.clouds.shadows.range" ) { readvalue( gfx_clouds_shadows_range, 1000.f, 100000.f ); }
else if( Token == "gfx.stars" ) { readswitch( gfx_stars ); }
else if( Token == "gfx.stars.brightness" ) { readvalue( gfx_stars_brightness, 0.f, 16.f ); }
else if( Token == "gfx.sun.disc" ) { readvalue( gfx_sun_disc, 0.f, 4.f ); }
else if( Token == "gfx.moon.disc" ) { readvalue( gfx_moon_disc, 0.f, 16.f ); }
else if( Token == "gfx.moonlight" ) { readvalue( gfx_moonlight, 0.f, 10.f ); }
else { return false; }
return true;
}
bool
global_settings::ConfigParse_gfx_lamps( cParser &Parser, std::string_view const Token ) {
// a list of names separated with |, or "no" for none
auto const readlist = [&Parser]( std::string &Value ) {
Parser.getTokens( 1 );
Parser >> Value;
if( Value == "no" ) { Value.clear(); } };
auto const readvalue = [&Parser]( float &Value, float const Min, float const Max ) {
Parser.getTokens( 1 );
Parser >> Value;
Value = std::clamp( Value, Min, Max ); };
if( Token == "gfx.lights.points.near" ) {
Parser.getTokens( 1 );
Parser >> gfx_lights_points_near; }
else if( Token == "gfx.lights.stars" ) { readlist( gfx_lights_stars ); }
else if( Token == "gfx.lights.freespot.mincone" ) { readvalue( gfx_lights_freespot_mincone, 0.f, 89.f ); }
else if( Token == "gfx.lights.lamps.gain" ) { readvalue( gfx_lights_lamps_gain, 0.1f, 10.f ); }
else if( Token == "gfx.lights.lamps.range" ) { readvalue( gfx_lights_lamps_range, 0.f, 10000.f ); }
else if( Token == "gfx.lights.hideglow" ) { readlist( gfx_lights_hideglow ); }
else { return false; }
return true;
}
void
global_settings::export_as_text( std::ostream &Output ) const {
export_as_text( Output, "sceneryfile", SceneryFile );
export_as_text( Output, "humanctrlvehicle", local_start_vehicle );
export_as_text( Output, "fieldofview", FieldOfView );
export_as_text( Output, "width", window_size.x );
export_as_text( Output, "height", window_size.y );
export_as_text( Output, "targetfps", targetfps );
export_as_text( Output, "basedrawrange", BaseDrawRange );
export_as_text( Output, "fullscreen", bFullScreen );
export_as_text( Output, "fullscreenmonitor", fullscreen_monitor );
export_as_text( Output, "fullscreenwindowed", fullscreen_windowed );
export_as_text( Output, "vsync", VSync );
// NOTE: values are changed dynamically during simulation. cache initial settings and export instead
if( FreeFlyModeFlag ) {
Output
<< "freefly yes "
<< FreeCameraInit[ 0 ].x << " "
<< FreeCameraInit[ 0 ].y << " "
<< FreeCameraInit[ 0 ].z << "\n";
}
else {
export_as_text( Output, "freefly", FreeFlyModeFlag );
}
export_as_text( Output, "wireframe", bWireFrame );
export_as_text( Output, "debugmode", DebugModeFlag );
export_as_text( Output, "soundenabled", bSoundEnabled );
export_as_text( Output, "sound.openal.renderer", AudioRenderer );
export_as_text( Output, "sound.volume", AudioVolume );
export_as_text( Output, "sound.volume.radio", DefaultRadioVolume );
export_as_text( Output, "sound.volume.vehicle", VehicleVolume );
export_as_text( Output, "sound.volume.positional", EnvironmentPositionalVolume );
export_as_text( Output, "sound.volume.ambient", EnvironmentAmbientVolume );
export_as_text( Output, "sound.asyncload", AudioAsyncLoad );
export_as_text( Output, "fmradio.enabled", fmradio_enabled );
export_as_text( Output, "fmradio.cleansound", fmradio_cleansound );
export_as_text( Output, "fmradio.stations", fmradio_stations );
export_as_text( Output, "sound.maxsources", audio_max_sources );
export_as_text( Output, "sound.outputmode", AudioOutputMode );
export_as_text( Output, "sound.hrtf", AudioHrtf );
export_as_text( Output, "sound.hrtf.profile", AudioHrtfProfile );
export_as_text( Output, "sound.resampler", AudioResampler );
export_as_text( Output, "sound.limiter", AudioLimiter );
export_as_text( Output, "sound.frequency", AudioFrequency );
export_as_text( Output, "sound.doppler", AudioDoppler );
export_as_text( Output, "sound.efx.lowpass", AudioLowpass );
export_as_text( Output, "sound.efx.airabsorption", AudioAirAbsorption );
export_as_text( Output, "physicslog", WriteLogFlag );
export_as_text( Output, "physicslog.trains", WriteTrainLogFlag );
export_as_text( Output, "odometer.expiry", odometer_expiry );
if( BlackBox ) {
export_as_text( Output, "blackbox", *BlackBox );
}
export_as_text( Output, "fullphysics", FullPhysics );
export_as_text( Output, "physics.sleepheld", physics_sleepheld );
export_as_text( Output, "physics.roadlod", physics_roadlod );
export_as_text( Output, "physics.pipewake", physics_pipewake );
export_as_text( Output, "performance.multithreading", performance_multithreading );
export_as_text( Output, "debug.memorystats", debug_memorystats );
export_as_text( Output, "debuglog", iWriteLogEnabled );
export_as_text( Output, "multiplelogs", MultipleLogs );
export_as_text( Output, "crashdump.full", crashdump_full );
export_as_text( Output, "showsystemconsole", ShowSystemConsole );
export_as_text( Output, "logs.filter", DisabledLogTypes );
Output
<< "mousescale "
<< fMouseXScale << " "
<< fMouseYScale << "\n";
export_as_text( Output, "mousecontrol", InputMouse );
export_as_text( Output, "consistviews", ConsistViews );
export_as_text( Output, "enabletraction", bEnableTraction );
export_as_text( Output, "loadtraction", bLoadTraction );
export_as_text( Output, "friction", fFriction );
export_as_text( Output, "livetraction", bLiveTraction );
export_as_text( Output, "skyenabled", asSky );
export_as_text( Output, "defaultext", szDefaultExt );
export_as_text( Output, "newaircouplers", bnewAirCouplers );
export_as_text( Output, "anisotropicfiltering", AnisotropicFiltering );
export_as_text( Output, "feedbackmode", iFeedbackMode );
export_as_text( Output, "feedbackport", iFeedbackPort );
export_as_text( Output, "multiplayer", iMultiplayer );
export_as_text( Output, "isolatedtrainnumber", bIsolatedTrainName);
export_as_text( Output, "maxtexturesize", iMaxTextureSize );
export_as_text( Output, "maxcabtexturesize", iMaxCabTextureSize );
export_as_text( Output, "movelight", fMoveLight );
export_as_text( Output, "dynamiclights", DynamicLightCount );
if( std::isnormal( ScenarioTimeOverride ) ) {
export_as_text( Output, "scenario.time.override", ScenarioTimeOverride );
}
export_as_text( Output, "scenario.time.offset", ScenarioTimeOffset );
export_as_text( Output, "scenario.time.current", ScenarioTimeCurrent );
export_as_text( Output, "scenario.weather.temperature", AirTemperature );
export_as_text( Output, "physics.trackbuckling", std::string{
track_buckling == track_buckling_mode::off ? "off" :
track_buckling == track_buckling_mode::automatic ? "auto" :
"scenery" } );
export_as_text( Output, "ai.trainman", AITrainman );
export_as_text( Output, "driverfigure.followsdirection", DriverFigureFollowsDirection );
export_as_text( Output, "controlcoupling.enginecheck", control_coupling_engine_check );
std::string couplerphysics { coupler_physics ? "yes" : "no" };
if( coupler_physics_all ) {
couplerphysics = "all";
}
export_as_text( Output, "couplerphysics", couplerphysics );
export_as_text( Output, "physics.derailment", std::string{ name_of( derailment ) } );
export_as_text( Output, "physics.trackcheck", track_check );
export_as_text( Output, "physics.collisions", std::string{ name_of( collisions ) } );
export_as_text( Output, "ai.brakesetting.cw1", AIBrakeSettingCw1 );
export_as_text( Output, "scalespeculars", ScaleSpecularValues );
export_as_text( Output, "gfxrenderer", GfxRenderer );
export_as_text( Output, "shadows", RenderShadows );
Output
<< "shadowtune "
<< shadowtune.map_size << " "
<< 0 << " "
<< shadowtune.range << " "
<< 0 << "\n";
export_as_text( Output, "gfx.shadows.cab.range", RenderCabShadowsRange );
export_as_text( Output, "gfx.smoke", Smoke );
export_as_text( Output, "gfx.smoke.fidelity", SmokeFidelity );
export_as_text( Output, "smoothtraction", bSmoothTraction );
export_as_text( Output, "catenary.procedural", CatenaryProcedural );
export_as_text( Output, "catenary.solidrange", CatenarySettings.solid_range );
export_as_text( Output, "splinefidelity", SplineFidelity );
export_as_text( Output, "sleeperdistance", SleeperDistance );
export_as_text( Output, "sleepers3d", ( Sleepers3D.empty() ? std::string{ "none" } : Sleepers3D ) );
export_as_text( Output, "sleepers3dbed", Sleepers3DBed );
Output << "sleepers3dplain " << ( Sleepers3DPlain.empty() ? std::string{ "none" } : Sleepers3DPlain ) << ' ' << ( Sleepers3DPlainSkin.empty() ? std::string{ "none" } : Sleepers3DPlainSkin ) << ' ' << Sleepers3DPlainSeat << '\n';
export_as_text( Output, "rendercab", render_cab );
export_as_text( Output, "createswitchtrackbeds", CreateSwitchTrackbeds );
export_as_text( Output, "frogs", Frogs );
export_as_text( Output, "gfx.resource.sweep", ResourceSweep );
export_as_text( Output, "gfx.resource.move", ResourceMove );
export_as_text( Output, "gfx.textures.streaming", gfx_texture_streaming );
export_as_text( Output, "gfx.textures.releasedistance", gfx_texture_releasedistance );
export_as_text( Output, "gfx.reflections.framerate", 1.0 / reflectiontune.update_interval );
export_as_text( Output, "gfx.reflections.fidelity", reflectiontune.fidelity );
export_as_text( Output, "timespeed", fTimeSpeed );
export_as_text( Output, "multisampling", iMultisampling );
export_as_text( Output, "gfx.antialiasing", std::string{ gfx_antialiasing == antialiasing_mode::taa ? "taa" : gfx_antialiasing == antialiasing_mode::dlss ? ( gfx_dlss_native ? "dlaa" : "dlss" ) : ( gfx_antialiasing == antialiasing_mode::off || iMultisampling == 0 ) ? "off" : "msaax" + std::to_string( 1 << iMultisampling ) } );
export_as_text( Output, "gfx.buffer.percent", gfx_buffer_scale );
export_as_text( Output, "gfx.dlss.preset", std::string{ gfx_dlss_preset == 10 ? "j" : gfx_dlss_preset == 11 ? "k" : gfx_dlss_preset == 12 ? "l" : gfx_dlss_preset == 13 ? "m" : "default" } );
export_as_text( Output, "gfx.dlss.autoexposure", gfx_dlss_autoexposure );
export_as_text( Output, "gfx.dlss.lodbias", gfx_dlss_lodbias );
export_as_text( Output, "gfx.dlss.developer", gfx_dlss_developer );
export_as_text( Output, "gfx.framegeneration", std::string{ gfx_framegeneration > 1 ? "x" + std::to_string( gfx_framegeneration ) : "off" } );
export_as_text( Output, "gfx.reflex", std::string{ gfx_reflex == 2 ? "boost" : gfx_reflex == 1 ? "on" : "off" } );
export_as_text( Output, "latitude", fLatitudeDeg );
export_as_text( Output, "convertmodels", iConvertModels );
export_as_text( Output, "file.binary.terrain", file_binary_terrain );
export_as_text( Output, "file.binary.terrain.checksum", std::string( file_binary_terrain_checksum == 0 ? "off" : file_binary_terrain_checksum == 1 ? "simple" : "full" ) );
export_as_text( Output, "inactivepause", bInactivePause );
export_as_text( Output, "slowmotion", iSlowMotionMask );
export_as_text( Output, "hideconsole", bHideConsole );
export_as_text( Output, "rollfix", bRollFix );
export_as_text( Output, "fpsaverage", fFpsAverage );
export_as_text( Output, "fpsdeviation", fFpsDeviation );
for( auto idx = 0; idx < 6; ++idx ) {
Output
<< "calibrate5din "
<< idx << " "
<< fCalibrateIn[ idx ][ 0 ] << " "
<< fCalibrateIn[ idx ][ 1 ] << " "
<< fCalibrateIn[ idx ][ 2 ] << " "
<< fCalibrateIn[ idx ][ 3 ] << " "
<< fCalibrateIn[ idx ][ 4 ] << " "
<< fCalibrateIn[ idx ][ 5 ] << "\n";
}
for( auto idx = 0; idx < 6; ++idx ) {
Output
<< "calibrate5dout "
<< idx << " "
<< fCalibrateOut[ idx ][ 0 ] << " "
<< fCalibrateOut[ idx ][ 1 ] << " "
<< fCalibrateOut[ idx ][ 2 ] << " "
<< fCalibrateOut[ idx ][ 3 ] << " "
<< fCalibrateOut[ idx ][ 4 ] << " "
<< fCalibrateOut[ idx ][ 5 ] << "\n";
}
Output
<< "calibrateoutmaxvalues "
<< fCalibrateOutMax[ 0 ] << " "
<< fCalibrateOutMax[ 1 ] << " "
<< fCalibrateOutMax[ 2 ] << " "
<< fCalibrateOutMax[ 3 ] << " "
<< fCalibrateOutMax[ 4 ] << " "
<< fCalibrateOutMax[ 5 ] << " "
<< fCalibrateOutMax[ 6 ] << "\n";
export_as_text( Output, "calibrateoutdebuginfo", iCalibrateOutDebugInfo );
for( auto idx = 0; idx < 7; ++idx ) {
Output
<< "pwm "
<< idx << " "
<< iPoKeysPWM[ idx ] << "\n";
}
export_as_text( Output, "brakestep", fBrakeStep );
export_as_text( Output, "joinduplicatedevents", bJoinEvents );
export_as_text( Output, "hiddenevents", iHiddenEvents );
export_as_text( Output, "pause", ( iPause & 1 ) != 0 );
export_as_text(Output, "priorityLoadText3D", priorityLoadText3D);
export_as_text(Output, "modelformat", std::string{modelformat_e4d ? "e4d" : "legacy"});
export_as_text( Output, "lang", asLang );
export_as_text( Output, "python.updatetime", PythonScreenUpdateRate );
Output
<< "uitextcolor "
<< UITextColor.r * 255 << " "
<< UITextColor.g * 255 << " "
<< UITextColor.b * 255 << "\n";
export_as_text( Output, "ui.bg.opacity", UIBgOpacity );
export_as_text( Output, "ui.viewports", ui_viewports );
export_as_text( Output, "input.gamepad", InputGamepad );
#ifdef WITH_UART
if( uart_conf.enable ) {
Output
<< "uart "
<< uart_conf.port << " "
<< uart_conf.baud << " "
<< uart_conf.updatetime << "\n";
}
Output
<< "uarttune "
<< uart_conf.mainbrakemin << " "
<< uart_conf.mainbrakemax << " "
<< uart_conf.localbrakemin << " "
<< uart_conf.localbrakemax << " "
<< uart_conf.tankmax << " "
<< uart_conf.tankuart << " "
<< uart_conf.pipemax << " "
<< uart_conf.pipeuart << " "
<< uart_conf.brakemax << " "
<< uart_conf.brakeuart << " "
<< uart_conf.pantographmax << " "
<< uart_conf.pipemax << " "
<< uart_conf.hvmax << " "
<< uart_conf.hvuart << " "
<< uart_conf.currentmax << " "
<< uart_conf.currentuart << " "
<< uart_conf.lvmax << " "
<< uart_conf.lvuart << "\n";
export_as_text( Output, "uarttachoscale", uart_conf.tachoscale );
std::vector<std::string> enabled_uartfeatures;
for(auto const &x : uartfeatures_map) {
if(*x.second) {
enabled_uartfeatures.push_back(x.first);
}
}
Output << "uartfeature ";
if(enabled_uartfeatures.empty()) {
Output << "none\n";
} else {
for(auto const &feature : enabled_uartfeatures) {
Output << feature;
if(&feature != &enabled_uartfeatures.back()) {
Output << "|";
}
}
Output << "\n";
}
export_as_text( Output, "uartdebug", uart_conf.debug );
#endif
export_as_text( Output, "extcam.cmd", extcam_cmd );
export_as_text( Output, "extcam.rec", extcam_rec );
Output
<< "extcam.res "
<< extcam_res.x << " "
<< extcam_res.y << "\n";
export_as_text( Output, "compresstex", compress_tex );
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.lights.clustered", gfx_lights_clustered );
export_as_text( Output, "gfx.lights.clusterheatmap", gfx_lights_clusterheatmap );
export_as_text( Output, "gfx.gpucull", std::string{ gfx_gpucull == 1 ? "yes" : gfx_gpucull == 2 ? "compare" : "no" } );
export_as_text( Output, "gfx.gpucull.occlusion", gfx_gpucull_occlusion );
export_as_text( Output, "gfx.gpucull.occlusion.instances", gfx_gpucull_occlusion_instances );
export_as_text( Output, "gfx.depthprepass", gfx_depthprepass );
export_as_text( Output, "gfx.gpucull.multidraw", gfx_gpucull_multidraw );
export_as_text( Output, "gfx.gpucull.shadows", gfx_gpucull_shadows );
export_as_text( Output, "gfx.gpucull.reflections", gfx_gpucull_reflections );
export_as_text( Output, "gfx.gpucull.shadows.headlights", gfx_gpucull_shadows_headlights );
export_as_text( Output, "gfx.gpucull.shadows.lamps", gfx_gpucull_shadows_lamps );
export_as_text( Output, "gfx.gpucull.sleepers", gfx_gpucull_sleepers );
export_as_text( Output, "gfx.gpucull.models", gfx_gpucull_models );
export_as_text( Output, "gfx.gpucull.bucketrange", gfx_gpucull_bucketrange );
export_as_text( Output, "gfx.gpucull.walkcache", gfx_gpucull_walkcache );
export_as_text( Output, "gfx.geometry.shared", gfx_geometry_shared );
export_as_text( Output, "gfx.depthprepass.scene", gfx_depthprepass_scene );
export_as_text( Output, "gfx.depthprepass.replay", gfx_depthprepass_replay );
export_as_text( Output, "gfx.grass", gfx_grass );
export_as_text( Output, "gfx.grass.distance", gfx_grass_distance );
export_as_text( Output, "gfx.grass.fadedistance", gfx_grass_fadedistance );
export_as_text( Output, "gfx.grass.density", gfx_grass_density );
export_as_text( Output, "gfx.smoke.gpu", gfx_smoke_gpu );
export_as_text( Output, "gfx.smoke.lighting", gfx_smoke_lighting );
export_as_text( Output, "gfx.particles.soft", gfx_particles_soft );
export_as_text( Output, "gfx.precipitation.gpu", gfx_precipitation_gpu );
export_as_text( Output, "gfx.precipitation.particles", gfx_precipitation_particles );
export_as_text( Output, "gfx.bufferstreaming", gfx_bufferstreaming );
export_as_text( Output, "gfx.postfx.motionblur.enabled", gfx_postfx_motionblur_enabled );
export_as_text( Output, "gfx.postfx.motionblur.shutter", gfx_postfx_motionblur_shutter );
// TODO: export gfx_postfx_motionblur_format
export_as_text( Output, "gfx.postfx.chromaticaberration.enabled", gfx_postfx_chromaticaberration_enabled );
// TODO: export gfx_format_color
// TODO: export gfx_format_depth
export_as_text( Output, "gfx.skiprendering", gfx_skiprendering );
export_as_text( Output, "gfx.skippipeline", gfx_skippipeline );
export_as_text( Output, "gfx.extraeffects", gfx_extraeffects );
export_as_text( Output, "gfx.shadergamma", gfx_shadergamma );
export_as_text( Output, "gfx.shaders.binaries", gfx_shader_binaries );
export_as_text( Output, "gfx.vulkan.device", gfx_vulkan_device );
export_as_text( Output, "gfx.vulkan.validation", gfx_vulkan_validation );
export_as_text( Output, "gfx.vulkan.framesinflight", gfx_vulkan_framesinflight );
export_as_text( Output, "gfx.vulkan.renderthread", gfx_vulkan_renderthread );
export_as_text( Output, "gfx.threads", gfx_threads );
export_as_text( Output, "gfx.vulkan.asyncresources", gfx_vulkan_asyncresources );
export_as_text( Output, "gfx.vulkan.parallelpasses", gfx_vulkan_parallelpasses );
export_as_text( Output, "gfx.vulkan.parallelmodels", gfx_vulkan_parallelmodels );
export_as_text( Output, "gfx.vulkan.asynccompute", gfx_vulkan_asynccompute );
export_as_text( Output, "gfx.vulkan.checkpoints", gfx_vulkan_checkpoints );
export_as_text( Output, "gfx.shadow.angle.min", gfx_shadow_angle_min );
export_as_text( Output, "gfx.shadow.rank.cutoff", gfx_shadow_rank_cutoff );
export_as_text( Output, "gfx.shadow.sdsm", gfx_shadow_sdsm );
export_as_text( Output, "gfx.shadow.sdsm.split", gfx_shadow_sdsm_split );
export_as_text( Output, "gfx.ambient.sh", gfx_ambient_sh );
export_as_text( Output, "gfx.ambient.sh.strength", gfx_ambient_sh_strength );
export_as_text( Output, "gfx.ambient.groundalbedo", gfx_ambient_groundalbedo );
export_as_text( Output, "gfx.envmap.ggx", gfx_envmap_ggx );
export_as_text( Output, "gfx.atmosphere", gfx_atmosphere );
export_as_text( Output, "gfx.atmosphere.sky", gfx_atmosphere_sky );
export_as_text( Output, "gfx.atmosphere.ambient", gfx_atmosphere_ambient );
export_as_text( Output, "gfx.atmosphere.sun", gfx_atmosphere_sun );
export_as_text( Output, "gfx.atmosphere.haze", gfx_atmosphere_haze );
export_as_text( Output, "gfx.atmosphere.altitude", gfx_atmosphere_altitude );
export_as_text( Output, "gfx.postfx.autoexposure", gfx_postfx_autoexposure );
export_as_text( Output, "gfx.postfx.autoexposure.key", gfx_postfx_autoexposure_key );
export_as_text( Output, "gfx.postfx.autoexposure.min", gfx_postfx_autoexposure_min );
export_as_text( Output, "gfx.postfx.autoexposure.max", gfx_postfx_autoexposure_max );
export_as_text( Output, "gfx.postfx.autoexposure.max.cab", gfx_postfx_autoexposure_max_cab );
export_as_text( Output, "gfx.postfx.autoexposure.speed.dark", gfx_postfx_autoexposure_speed_dark );
export_as_text( Output, "gfx.postfx.autoexposure.speed.bright", gfx_postfx_autoexposure_speed_bright );
export_as_text( Output, "gfx.postfx.autoexposure.compensation", gfx_postfx_autoexposure_compensation );
export_as_text( Output, "gfx.postfx.bloom", gfx_postfx_bloom );
export_as_text( Output, "gfx.postfx.bloom.intensity", gfx_postfx_bloom_intensity );
export_as_text( Output, "gfx.postfx.bloom.threshold", gfx_postfx_bloom_threshold );
export_as_text( Output, "gfx.postfx.whitebalance", gfx_postfx_whitebalance );
export_as_text( Output, "gfx.postfx.whitebalance.temperature", gfx_postfx_whitebalance_temperature );
export_as_text( Output, "gfx.postfx.whitebalance.tint", gfx_postfx_whitebalance_tint );
export_as_text( Output, "gfx.postfx.ao", std::string{ gfx_postfx_ao == 2 ? "gtao" : gfx_postfx_ao == 1 ? "ssao" : "no" } );
export_as_text( Output, "gfx.postfx.ao.radius", gfx_postfx_ao_radius );
export_as_text( Output, "gfx.postfx.ao.strength", gfx_postfx_ao_strength );
export_as_text( Output, "gfx.postfx.ao.bounce", gfx_postfx_ao_bounce );
export_as_text( Output, "gfx.postfx.ao.cab", gfx_postfx_ao_cab );
Output << "gfx.postfx.ao.quality " << gfx_postfx_ao_slices << " " << gfx_postfx_ao_steps << "\n";
export_as_text( Output, "gfx.postfx.ao.lighting", gfx_postfx_ao_lighting );
export_as_text( Output, "gfx.lights.scenery", gfx_lights_scenery );
export_as_text( Output, "gfx.lights.vehicles", gfx_lights_vehicles );
export_as_text( Output, "gfx.lights.headlights", gfx_lights_headlights );
export_as_text( Output, "gfx.lights.cab", gfx_lights_cab );
export_as_text( Output, "gfx.lights.freespot.intensity", gfx_lights_freespot_intensity );
export_as_text( Output, "gfx.lights.compartment.intensity", gfx_lights_compartment_intensity );
export_as_text( Output, "gfx.lights.cab.intensity", gfx_lights_cab_intensity );
export_as_text( Output, "gfx.lights.cab.bounce", gfx_lights_cab_bounce );
export_as_text( Output, "gfx.lights.points.near", gfx_lights_points_near );
export_as_text( Output, "gfx.lights.stars", gfx_lights_stars.empty() ? std::string{ "no" } : gfx_lights_stars );
export_as_text( Output, "gfx.lights.freespot.mincone", gfx_lights_freespot_mincone );
export_as_text( Output, "gfx.lights.lamps.gain", gfx_lights_lamps_gain );
export_as_text( Output, "gfx.lights.lamps.range", gfx_lights_lamps_range );
export_as_text( Output, "gfx.lights.hideglow", gfx_lights_hideglow.empty() ? std::string{ "no" } : gfx_lights_hideglow );
export_as_text( Output, "gfx.cabprobe", std::string{ gfx_cabprobe == 3 ? "high" : gfx_cabprobe == 2 ? "medium" : gfx_cabprobe == 1 ? "low" : "no" } );
export_as_text( Output, "gfx.cabprobe.interval", gfx_cabprobe_interval );
export_as_text( Output, "gfx.cabprobe.bounce", gfx_cabprobe_bounce );
export_as_text( Output, "gfx.cabprobe.reflections", gfx_cabprobe_reflections );
export_as_text( Output, "gfx.cabprobe.sun", gfx_cabprobe_sun );
export_as_text( Output, "gfx.interior.bounce", gfx_interior_bounce );
export_as_text( Output, "gfx.water.realistic", gfx_water_realistic );
export_as_text( Output, "gfx.skyvisibility", std::string{ gfx_skyvisibility == 3 ? "high" : gfx_skyvisibility == 2 ? "medium" : gfx_skyvisibility == 1 ? "low" : "no" } );
export_as_text( Output, "gfx.skyvisibility.sun", gfx_skyvisibility_sun );
export_as_text( Output, "gfx.skyvisibility.fog", gfx_skyvisibility_fog );
export_as_text( Output, "gfx.skyvisibility.tunnels", gfx_skyvisibility_tunnels );
export_as_text( Output, "gfx.tunnelflags", gfx_tunnelflags );
export_as_text( Output, "gfx.lights.range", gfx_lights_range );
export_as_text( Output, "gfx.lights.shadows", std::string{ gfx_lights_shadows == 3 ? "high" : gfx_lights_shadows == 2 ? "medium" : gfx_lights_shadows == 1 ? "low" : "no" } );
export_as_text( Output, "gfx.lights.shadows.cab", gfx_lights_shadows_cab );
export_as_text( Output, "gfx.lights.shadows.lamps", gfx_lights_shadows_lamps );
export_as_text( Output, "gfx.lights.shadows.lamps.size", gfx_lights_shadows_lamps_size );
export_as_text( Output, "gfx.lights.shadows.lamps.range", gfx_lights_shadows_lamps_range );
export_as_text( Output, "gfx.lights.shadows.vehicles.range", gfx_lights_shadows_vehicles_range );
export_as_text( Output, "gfx.lights.shadows.headlights", gfx_lights_shadows_headlights );
export_as_text( Output, "gfx.lights.shadows.headlights.range", gfx_lights_shadows_headlights_range );
export_as_text( Output, "gfx.contactshadows", std::string{ gfx_contactshadows == 3 ? "high" : gfx_contactshadows == 2 ? "medium" : gfx_contactshadows == 1 ? "low" : "no" } );
export_as_text( Output, "gfx.contactshadows.length", gfx_contactshadows_length );
export_as_text( Output, "gfx.contactshadows.range", gfx_contactshadows_range );
export_as_text( Output, "gfx.ssr", std::string{ gfx_ssr == 3 ? "high" : gfx_ssr == 2 ? "medium" : gfx_ssr == 1 ? "low" : "no" } );
export_as_text( Output, "gfx.ssr.range", gfx_ssr_range );
export_as_text( Output, "gfx.ssr.roughness", gfx_ssr_roughness );
export_as_text( Output, "gfx.raytracing", gfx_raytracing );
export_as_text( Output, "gfx.raytracing.range", gfx_raytracing_range );
export_as_text( Output, "gfx.fog", std::string{ gfx_fog == 1 ? "volumetric" : "analytic" } );
export_as_text( Output, "gfx.fog.quality", std::string{ gfx_fog_quality == 1 ? "low" : gfx_fog_quality == 3 ? "high" : gfx_fog_quality == 4 ? "ultra" : "medium" } );
export_as_text( Output, "gfx.fog.range", gfx_fog_range );
export_as_text( Output, "gfx.fog.lights", gfx_fog_lights );
export_as_text( Output, "gfx.fog.shadows", gfx_fog_shadows );
export_as_text( Output, "gfx.fog.temporal", gfx_fog_temporal );
export_as_text( Output, "gfx.fog.temporal.share", gfx_fog_temporal_share );
export_as_text( Output, "gfx.weather.occlusion", gfx_weather_occlusion );
export_as_text( Output, "gfx.clouds.interleave", gfx_clouds_interleave );
export_as_text( Output, "gfx.clouds", std::string{ gfx_clouds == 1 ? "low" : gfx_clouds == 2 ? "medium" : gfx_clouds == 3 ? "high" : gfx_clouds == 4 ? "ultra" : "no" } );
export_as_text( Output, "gfx.clouds.distance", gfx_clouds_distance );
export_as_text( Output, "gfx.clouds.shadows", gfx_clouds_shadows );
export_as_text( Output, "gfx.clouds.shadows.size", gfx_clouds_shadows_size );
export_as_text( Output, "gfx.clouds.shadows.range", gfx_clouds_shadows_range );
export_as_text( Output, "gfx.stars", gfx_stars );
export_as_text( Output, "gfx.stars.brightness", gfx_stars_brightness );
export_as_text( Output, "gfx.sun.disc", gfx_sun_disc );
export_as_text( Output, "gfx.moon.disc", gfx_moon_disc );
export_as_text( Output, "gfx.moonlight", gfx_moonlight );
export_as_text( Output, "python.enabled", python_enabled );
export_as_text( Output, "python.threadedupload", python_threadedupload );
export_as_text( Output, "python.uploadmain", python_uploadmain );
export_as_text( Output, "python.mipmaps", python_mipmaps );
export_as_text( Output, "luascreens.enabled", luascreens_enabled );
export_as_text( Output, "lua.fulllibraries", lua_fulllibraries );
export_as_text( Output, "wasm.enabled", wasm_enabled );
export_as_text( Output, "screens.cabframes", screens_cabframes );
export_as_text( Output, "screens.externalframes", screens_externalframes );
export_as_text( Output, "screens.gpupost", screens_gpupost );
export_as_text( Output, "async.trainThreads", trainThreads );
for( auto const &server : network_servers ) {
Output
<< "network.server "
<< server.first << " " << server.second << "\n";
}
if( network_client ) {
Output
<< "network.client "
<< network_client->first << " " << network_client->second << "\n";
}
export_as_text( Output, "execonexit", exec_on_exit );
}
template <>
void
global_settings::export_as_text( std::ostream &Output, std::string const Key, std::string const &Value ) const {
if( Value.empty() ) { return; }
if( contains( Value, ' ' ) ) {
Output << Key << " \"" << Value << "\"\n";
}
else {
Output << Key << " " << Value << "\n";
}
}
template <> void global_settings::export_as_text(std::ostream &Output, std::string const Key, bool const &Value) const
{
Output << Key << " " << (Value ? "yes" : "no") << "\n";
}
global_settings &GetGlobalSettings()
{
static global_settings global{};
return global;
}