17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 10:31:01 +01:00

fix(track): a tributary loads as a river of its first path keeping the second, a track of an unknown type is left out, where both made the simulator fall over as it loaded

On master neither got a segment: update_location() dereferenced the missing one of a track of an unknown type, and
a tributary went to Switch(0), which logged "Cannot switch normal track", with no segment under it either.

A tributary is now a river of its first path. Its second path is kept in m_paths, isn't drawn nor run on, and is
written back with the type "tributary". A track of an unknown type is logged and left out by the loader; as it is no
node, its text stays in the file when the editor saves the scenery.
This commit is contained in:
maj00r
2026-11-03 23:03:52 +01:00
parent ed0ff36a69
commit 8523316006
3 changed files with 23 additions and 2 deletions

View File

@@ -543,6 +543,12 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
else if( nodedata.type == "track" ) {
auto *path { deserialize_path( Input, Scratchpad, nodedata ) };
if( path->eType == tt_Unknown ) {
// with no path made it can't be joined nor drawn, and nothing could run on it
ErrorLog( "Bad scenario: track \"" + path->name() + "\" of an unknown type defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ") left out" );
delete path;
return;
}
// duplicates of named tracks are currently experimentally allowed
if( false == simulation::Paths.insert( path ) ) {
ErrorLog( "Bad scenario: duplicate track name \"" + path->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );