mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-28 16:12:05 +01:00
Merge staging into feat/gl46-migration
origin/staging7ac2472c3into feat/gl46-migrationdb26a33ed, so that #468 merges into staging. Merge base037158104. Staging carries master up to571487612(squashed in #514); this branch had merged master up to7c12b83ba. Conflicts, file by file: - README.md: WITH_BETTER_RENDERER row dropped (gl46), USE_SYSTEM_JSON row kept (staging) - CMakeLists.txt: gl46 lists, plus staging's new core sources (hardwareinfo, sn_utils, regionfile, inionlysettings, fieldshunting, gaugewrap, drivingaid, signalpassing, brakereleaser, crew, brakecharge); none listed twice - tests/unit/CMakeLists.txt: both (texturealpha, freecameramotion; editorSwitchDrives, Camera) - vehicle/brakingcurve.{h,cpp}, tests/unit/test_braking_curve.cpp (add/add): staging (#479 brake_acting on the same #409 code) - editor/editorHttp.cpp: staging (it has gl46's #432 and certificate fixes, plus #439 libcurl loaded at run time) - tests/unit/test_editor_http.cpp (add/add): staging (adds the available() case of #439) - utilities/Globals.h: gl46 crashdump_full (staging's CrashDumpFull is #425, replaced here by utilities/crashdump.cpp); fmradio and staging's OpenAL options both; gfx_headlights_beamwidth (#481) not taken - utilities/Globals.cpp: both (odometer.expiry, OpenAL keys, fmradio, gl46 gfx keys); gfx.headlights.beamwidth (#481) not taken - utilities/Logs.cpp: staging's log_file_name() for both files, with gl46's crashdump_set_log_file() for both - utilities/utilities.h: gl46 set_thread_random_engine(); Random(int, int) gone on both sides - tests/unit/test_utilities.cpp: staging's includes - simulation/simulationtest.cpp: gl46 (no NvRenderer, LegacyRenderer, BasicRenderer here) - ci_shadervalidator/* (incl. add/add utilities/Logs.h): gl46's validator of shaders/ogl46 and shaders/vk14; staging's #437 fixed the GL 3.3 one - gl/shader.cpp, gl/glsl_common.cpp: gl46 (shaders come from rendering/common/shadersource.cpp); HEADLIGHT_BEAM_WIDTH (#481) not taken - shaders/mat_wire.frag: gl46. Rename detection paired staging's mat_colored.frag (#481) with it - lang/editor_pl.po: union; the 12 camera speed / orthophoto entries staging adds are here already (master #312) - audio/audiorenderer.{h,cpp}: both (fmradio; startsample and the low-pass filter); the destructor releases the radio, then the filter - application/editormode.h, application/editormodeswitchdrive.cpp: staging (#509 on #330, which is all this side had) - application/application.cpp: gl46's start sequence (no init_ogl, ANGLE or NvRenderer; crash window after init_ui) with staging's hardware::log_system() (#389) - EU07.cpp: gl46 (crash reports of utilities/crashdump.cpp); staging's side was #425's handler, replaced here - model/Texture.{h,cpp}: gl46 (texture_source); staging's side is master #399/#411/#362/#386, merged here before - world/Track.h, world/TrackSleepers.h: both (TrackBlend, lay(Fastened)/fasten; TrackBuckle, pack_models) - world/Segment.cpp: staging's track buckling on the split stray factors both sides have - vehicle/Driver.h: staging's additions (#444, #494, #473, #346, timetable flags) - vehicle/Driver.cpp: staging's file, with this branch'sf4f8c75e4(road orders measured along the lane) and8fbf05674(a holding road order blocks the ones past it) applied again; #409's SeenAheadTolerance gives way to #473 - vehicle/DynObj.h: friend opengl46_renderer and friend class vehicle_table - vehicle/DynObj.cpp: gl46's vehicle_table::update() with staging's update_off_track_contacts() and update_brake_pipes() - McZapkie/Mover.cpp: staging's function splits (#239) and hose exchange (#388); every line this branch added to Mover.cpp/MOVER.h is kept - .github/workflows/build_bin.yml: staging's apt-install step (#497) and pinned download-artifact (#331) Modify/delete, kept deleted: - rendering/opengl33renderer.{cpp,h}, rendering/openglparticles.cpp, rendering/openglrenderer.{cpp,h}: staging's versions are master's, and every master change to them is in this branch's history already - shaders/light_common.glsl, shaders/mat_sunlessnormalmap_specgloss.frag: see below Carried into this branch's code: - the hose exchange after each sub-step (#387/#388) also in update_steps_parallel(), per group of vehicles, as update() does it single-threaded - physics.pipewake (pipe_wakes(), wake_cause::scndpipe) in staging's GetScndDVc(), where the main reservoir hose exchange went - hardware::log_gl_context() (#389) in after_window() of the GL 4.6 backend, init_ogl() being gone Taken back out of the auto-merge (renderers this branch removed): - shaders/vk14/tonemapping.glsl: #481's switch to ACES, applied there by rename detection - environment/skydome.cpp, simulation/simulationenvironment.cpp: #415, the sky of the legacy renderer - application/application.cpp: #384's fallback of an unknown gfxrenderer, which this branch had dropped Not carried from staging (renderer files removed here): - master #481 (571487612): old assets drawn as in 26.05 (metal diffuse, sun highlight tint, ACES, SUN_DIFFUSE_SCALE 2.5, untinted Diffuse, mat_colored base) and gfx.headlights.beamwidth. Made for the GL 3.3 shaders; the PBR shaders of shaders/ogl46 and vk14 (and their SPIR-V binaries) are the author's call - #437: the unique temporary file of the shader validator (Sonar S5443); gl46's validator still writes /tmp/shader* Unit tests: 1133 of 1137 cases pass. Four staging tests fail (derailment: a repaired vehicle is back on the rails; three pullee cases): the vehicle stands, and with physics.sleepheld (on by default here) its physics sleeps with the Fb / FStand of before. With physics.sleepheld off they pass. Left to the author.
This commit is contained in:
@@ -25,6 +25,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities/Logs.h"
|
||||
#include "utilities/physicslog.h"
|
||||
#include "utilities/utilities.h"
|
||||
#include "world/stationnames.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
@@ -392,8 +393,9 @@ void blackbox_recorder::write_map() {
|
||||
if (values == nullptr)
|
||||
continue;
|
||||
auto const &text{values->input_text()};
|
||||
// the name in the form the station records and the rows of the timetable have theirs, as it always was
|
||||
if (text.starts_with(stoppoint))
|
||||
m_writer->stop_point(stoppoints++, text_of(std::string_view{text}.substr(stoppoint.size())), values->input_location(),
|
||||
m_writer->stop_point(stoppoints++, text_of(timetable::station_ascii(text.substr(stoppoint.size()))), values->input_location(),
|
||||
static_cast<float>(values->input_value(1)), static_cast<float>(values->input_value(2)), heading_of(values->input_location()));
|
||||
else if (text == "Warning_signal")
|
||||
m_writer->horn_point(hornpoints++, text_of(values->name()), values->input_location(), static_cast<float>(values->input_value(1)),
|
||||
@@ -542,6 +544,7 @@ void blackbox_recorder::look_around(bool const Keyframe) {
|
||||
look_at_vehicles(Keyframe);
|
||||
auto const vehicles{clock::now()};
|
||||
look_at_couplers();
|
||||
look_at_derailments();
|
||||
auto const couplers{clock::now()};
|
||||
look_at_switches();
|
||||
auto const switches{clock::now()};
|
||||
@@ -555,6 +558,59 @@ void blackbox_recorder::look_around(bool const Keyframe) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::uint8_t cause_of(derail_motion::cause const Cause) {
|
||||
switch (Cause) {
|
||||
case derail_motion::cause::overturned:
|
||||
return blackbox::derailment_causes::overturned;
|
||||
case derail_motion::cause::end_of_track:
|
||||
return blackbox::derailment_causes::end_of_track;
|
||||
case derail_motion::cause::pulled_off:
|
||||
return blackbox::derailment_causes::pulled_off;
|
||||
case derail_motion::cause::collision:
|
||||
return blackbox::derailment_causes::collision;
|
||||
default:
|
||||
return blackbox::derailment_causes::flange_climbed;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void blackbox_recorder::look_at_derailments() {
|
||||
for (auto *vehicle : simulation::Vehicles.sequence()) {
|
||||
if (false == vehicle->bEnabled)
|
||||
continue;
|
||||
auto const &motion{vehicle->MoverParameters->OffTrack};
|
||||
auto const id{vehicle_id(vehicle)};
|
||||
auto &entry{m_vehicles[vehicle]};
|
||||
if (false == motion.active()) {
|
||||
entry.derailment = 0;
|
||||
continue;
|
||||
}
|
||||
auto const phase{motion.at_rest() ? 2 : 1};
|
||||
if (entry.derailment >= phase)
|
||||
continue;
|
||||
blackbox::derailment_state state;
|
||||
state.time = m_time;
|
||||
state.vehicle = id;
|
||||
state.cause = cause_of(motion.reason());
|
||||
state.position = vehicle->GetPosition();
|
||||
state.heading = static_cast<float>(std::atan2(vehicle->VectorFront().x, vehicle->VectorFront().z));
|
||||
state.speed_kmh = static_cast<float>(vehicle->MoverParameters->V * 3.6);
|
||||
state.offset = static_cast<float>(vehicle->off_track_offset());
|
||||
state.roll = static_cast<float>(motion.roll());
|
||||
state.travelled = static_cast<float>(motion.travelled());
|
||||
state.lying = motion.lying();
|
||||
// seen first at rest, it left the track before
|
||||
for (auto written = entry.derailment + 1; written <= phase; ++written) {
|
||||
state.phase = (written == 1 ? blackbox::derailment_phases::left_track : blackbox::derailment_phases::at_rest);
|
||||
m_writer->derailment(state);
|
||||
}
|
||||
entry.derailment = phase;
|
||||
}
|
||||
}
|
||||
|
||||
void blackbox_recorder::look_at_couplers() {
|
||||
for (auto *vehicle : simulation::Vehicles.sequence()) {
|
||||
if (false == vehicle->bEnabled)
|
||||
@@ -720,8 +776,9 @@ std::uint32_t blackbox_recorder::known_id(TDynamicObject const *Vehicle) {
|
||||
return Vehicle != nullptr && Vehicle->bEnabled ? vehicle_id(Vehicle) : blackbox::no_vehicle;
|
||||
}
|
||||
|
||||
std::uint32_t blackbox_recorder::signal_at(glm::dvec3 const &Location) const {
|
||||
auto const found{std::ranges::find_if(m_signals, [&Location](signal_entry const &Signal) { return glm::distance(Signal.location, Location) < 0.01; })};
|
||||
std::uint32_t blackbox_recorder::signal_of(TMemCell const *Cell) const {
|
||||
// by the memory cell, not by its position: two signals can have their cells at one point
|
||||
auto const found{std::ranges::find(m_signals, Cell, &signal_entry::cell)};
|
||||
if (found == m_signals.end())
|
||||
return blackbox::no_signal;
|
||||
return static_cast<std::uint32_t>(std::distance(m_signals.begin(), found));
|
||||
@@ -750,7 +807,7 @@ void blackbox_recorder::signal_passed(TDynamicObject const *Vehicle, basic_event
|
||||
if (m_writer == nullptr || Vehicle == nullptr)
|
||||
return;
|
||||
auto const location{Event.input_location()};
|
||||
m_writer->signal_passed({m_time, vehicle_id(Vehicle), signal_at(location), text_of(Event.name()), location, static_cast<float>(Speed1), static_cast<float>(Speed2),
|
||||
m_writer->signal_passed({m_time, vehicle_id(Vehicle), signal_of(Event.input_cell()), text_of(Event.name()), location, static_cast<float>(Speed1), static_cast<float>(Speed2),
|
||||
static_cast<float>(Trainspeed), static_cast<float>(Overrun), Flags});
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,8 @@ private:
|
||||
bool listed{false};
|
||||
std::array<coupler_entry, 2> couplers; // as seen last
|
||||
bool couplers_known{false};
|
||||
// off the track: 0 not, 1 written as leaving it, 2 written as at rest
|
||||
int derailment{0};
|
||||
};
|
||||
struct switch_entry {
|
||||
TTrack *track{nullptr};
|
||||
@@ -99,6 +101,8 @@ private:
|
||||
void look_at_signals();
|
||||
// the couplers of every vehicle against the last look: those coupled at the first look, then the changes
|
||||
void look_at_couplers();
|
||||
// the vehicles leaving the track and coming to rest off it (physics.derailment new)
|
||||
void look_at_derailments();
|
||||
void write_camera();
|
||||
// the timetable of the train the user is in, written again when it is another one; none isn't written
|
||||
void look_at_timetable(TDynamicObject const &Vehicle, std::uint32_t Id);
|
||||
@@ -106,7 +110,8 @@ private:
|
||||
std::uint32_t vehicle_id(TDynamicObject const *Vehicle);
|
||||
// the number of a vehicle still on the scenery, no_vehicle for none or one taken off it
|
||||
std::uint32_t known_id(TDynamicObject const *Vehicle);
|
||||
std::uint32_t signal_at(glm::dvec3 const &Location) const;
|
||||
// the number of the signal whose aspect the memory cell tells, no_signal for one which isn't on the map
|
||||
std::uint32_t signal_of(TMemCell const *Cell) const;
|
||||
|
||||
std::mutex m_mutex;
|
||||
std::array<char, 256 * 1024> m_filebuffer{};
|
||||
|
||||
@@ -148,6 +148,8 @@ state_manager::update( double const Deltatime, int Iterationcount ) {
|
||||
simulation::Roadpoints.update( totaltime );
|
||||
Timer::subsystem.sim_roads.stop();
|
||||
simulation::Vehicles.update( Deltatime, Iterationcount );
|
||||
// the tracks the heat buckles, by itself or under the trains just moved
|
||||
TTrack::update_buckling( totaltime );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -432,12 +434,10 @@ void state_manager::process_commands() {
|
||||
}
|
||||
|
||||
while (vehicle) {
|
||||
vehicle->MoverParameters->DamageFlag = 0;
|
||||
vehicle->MoverParameters->EngDmgFlag = 0;
|
||||
// no damage, back on the rails with the state of the derailment cleared
|
||||
vehicle->MoverParameters->repair_damage();
|
||||
vehicle->MoverParameters->V = 0.000001; // HACK: force vehicle position re-calculation
|
||||
vehicle->MoverParameters->DistCounter = 0.0;
|
||||
vehicle->MoverParameters->WheelFlat = 0.0;
|
||||
vehicle->MoverParameters->AlarmChainFlag = false;
|
||||
vehicle->MoverParameters->OffsetTrackH = 0.0;
|
||||
vehicle->MoverParameters->OffsetTrackV = 0.0;
|
||||
|
||||
|
||||
@@ -272,8 +272,8 @@ state_serializer::deserialize_assignment( cParser &Input, scene::scratch_data &S
|
||||
while( false == token.empty()
|
||||
&& token != "endassignment" ) {
|
||||
// assignment is expected to come as string pairs: language id and the actual assignment enclosed in quotes to form a single token
|
||||
auto assignment{ Input.getToken<std::string>() };
|
||||
win1250_to_ascii( assignment );
|
||||
// the assignment is only shown to the player, so it's kept with its letters, in utf-8 as the user interface takes it
|
||||
auto const assignment{ data_text_to_utf8( Input.getToken<std::string>() ) };
|
||||
Scratchpad.trainset.assignment.emplace( token, assignment );
|
||||
token = Input.getToken<std::string>();
|
||||
}
|
||||
@@ -384,8 +384,9 @@ state_serializer::deserialize_camera( cParser &Input, scene::scratch_data &Scrat
|
||||
void
|
||||
state_serializer::deserialize_config( cParser &Input, scene::scratch_data &Scratchpad ) {
|
||||
|
||||
// config parameters (re)definition
|
||||
Global.ConfigParse( Input );
|
||||
// config parameters (re)definition, but for what only eu07.ini sets: programs to run, connections, the sandbox of
|
||||
// the scripts (utilities/inionlysettings.h)
|
||||
Global.ConfigParse( Input, config_source::scenery );
|
||||
if( Global.test.enabled ) {
|
||||
// a scenery doesn't get to turn on what a test keeps off
|
||||
simulation::apply_test_mode_settings();
|
||||
@@ -427,7 +428,8 @@ void state_serializer::deserialize_lua( cParser &Input, scene::scratch_data &Scr
|
||||
std::string file;
|
||||
Input >> file;
|
||||
#ifdef WITH_LUA
|
||||
simulation::Lua.interpret(Global.asCurrentSceneryPath + file);
|
||||
// the file is relative to the scenery folder, and stays inside it
|
||||
simulation::Lua.interpret(Global.asCurrentSceneryPath, file);
|
||||
#else
|
||||
ErrorLog(file + ": lua scripts not supported in this build.");
|
||||
#endif
|
||||
@@ -446,7 +448,13 @@ state_serializer::deserialize_firstinit( cParser &Input, scene::scratch_data &Sc
|
||||
// TBD: postpone loading furter and only load required blocks during the simulation?
|
||||
if (false == Scratchpad.binary.terrain_included)
|
||||
{
|
||||
Region->deserialize(Scratchpad.name);
|
||||
if (false == Region->deserialize(Scratchpad.name))
|
||||
{
|
||||
// the file looked whole to is_scene() but its content is damaged. the geometry it holds is missing from this
|
||||
// session, as the text definitions were skipped already. the file is the game's own copy of the text, so it
|
||||
// goes, and the next start loads the text and writes it anew
|
||||
Region->discard_scene(Scratchpad.name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -467,6 +475,9 @@ state_serializer::deserialize_firstinit( cParser &Input, scene::scratch_data &Sc
|
||||
Scratchpad.binary.terrain_binaryfiles.clear();
|
||||
|
||||
simulation::Paths.InitTracks();
|
||||
if( Global.track_check ) {
|
||||
simulation::Paths.CheckTracks();
|
||||
}
|
||||
// the roads tie up their own lanes where they gain or lose some, the junctions tie the lanes of the roads together,
|
||||
// what's left loose after that gets closed by the roads
|
||||
simulation::Roads.InitLanes();
|
||||
@@ -598,7 +609,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
||||
else if( nodedata.type == "road" ) {
|
||||
|
||||
auto *road { new road_node( nodedata ) };
|
||||
road->import(
|
||||
road->import_from(
|
||||
Input,
|
||||
( Scratchpad.location.offset.empty() ?
|
||||
glm::dvec3 { 0.0 } :
|
||||
@@ -637,7 +648,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
||||
else if( nodedata.type == "sweep" ) {
|
||||
|
||||
auto *sweep { new sweep_node( nodedata ) };
|
||||
sweep->import(
|
||||
sweep->import_from(
|
||||
Input,
|
||||
( Scratchpad.location.offset.empty() ?
|
||||
glm::dvec3 { 0.0 } :
|
||||
@@ -651,7 +662,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
||||
else if( nodedata.type == "junction" ) {
|
||||
|
||||
auto *junction { new junction_node( nodedata ) };
|
||||
junction->import(
|
||||
junction->import_from(
|
||||
Input,
|
||||
( Scratchpad.location.offset.empty() ?
|
||||
glm::dvec3 { 0.0 } :
|
||||
@@ -683,7 +694,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
||||
else if( roadpoint_node::is_keyword( nodedata.type ) ) {
|
||||
// level crossing, or a point where road vehicles appear or are taken away
|
||||
auto *point { new roadpoint_node( nodedata ) };
|
||||
point->import(
|
||||
point->import_from(
|
||||
Input,
|
||||
( Scratchpad.location.offset.empty() ?
|
||||
glm::dvec3 { 0.0 } :
|
||||
@@ -784,7 +795,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
||||
if( false == skip ) {
|
||||
|
||||
++Scratchpad.binary.geometry_imported;
|
||||
auto shape { scene::shape_node().import( Input, nodedata ) };
|
||||
auto shape { scene::shape_node().import_from( Input, nodedata ) };
|
||||
material = shape.data().material;
|
||||
if( true == Global.editor_session ) {
|
||||
shape.source_file( scene::terrain_file::reference_of( Input.Name() ) );
|
||||
@@ -822,7 +833,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
|
||||
|
||||
++Scratchpad.binary.geometry_imported;
|
||||
simulation::Region->insert(
|
||||
scene::lines_node().import(
|
||||
scene::lines_node().import_from(
|
||||
Input, nodedata ),
|
||||
Scratchpad );
|
||||
}
|
||||
|
||||
@@ -90,8 +90,10 @@ void apply_test_mode_settings()
|
||||
Global.iMultiplayer = 0;
|
||||
Global.exec_on_exit.clear();
|
||||
// and the same way every time, unless given another seed (-seed, or randomseed in the settings)
|
||||
if (!Global.random_seed)
|
||||
if (false == Global.random_seed_given) {
|
||||
Global.random_seed = seed_of("test");
|
||||
Global.random_seed_given = true;
|
||||
}
|
||||
// the real time limit, which the scenery may set too
|
||||
test().watch_wall_clock(wall_clock_limit(Global.test.wall_timeout, Global.test.timeout));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user