mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-08 11:34:19 +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:
@@ -427,11 +427,15 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
|
||||
}
|
||||
else if (str == "tributary")
|
||||
{
|
||||
eType = tt_Tributary;
|
||||
// dopływ: no path of it was ever made, the simulator falling over it as it loaded. a river of its first path now, the
|
||||
// second one kept and written back
|
||||
ErrorLog("Bad track: tributary \"" + m_name + "\" in file \"" + parser->Name() + "\" (line " + std::to_string(parser->Line()) + ") is drawn and run on as a river of its first path");
|
||||
eType = tt_Normal;
|
||||
iCategoryFlag = 4;
|
||||
m_tributary = true;
|
||||
}
|
||||
else
|
||||
eType = tt_Unknown;
|
||||
eType = tt_Unknown; // left out by the loader
|
||||
if (Global.iWriteLogEnabled & 4)
|
||||
WriteLog(str);
|
||||
parser->getTokens(4);
|
||||
@@ -517,6 +521,11 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( m_tributary ) {
|
||||
// the second path of a tributary, kept to be written back
|
||||
m_paths.emplace_back();
|
||||
m_paths.back().deserialize( *parser, pOrigin );
|
||||
}
|
||||
|
||||
init_segments( true );
|
||||
|
||||
@@ -681,6 +690,10 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
|
||||
m_name = m_name.substr(0, i - 1); // usunięcie z nazwy
|
||||
}
|
||||
|
||||
if( CurrentSegment() == nullptr ) {
|
||||
// of an unknown type, no path of it is made
|
||||
return;
|
||||
}
|
||||
update_location();
|
||||
// sleeper transforms are baked later in create_geometry(), once the owning cell has
|
||||
// assigned this track its m_origin (otherwise the local-space matrices would be relative
|
||||
@@ -2314,6 +2327,7 @@ TTrack::export_as_text_( std::ostream &Output ) const {
|
||||
// type
|
||||
Output << (
|
||||
eType == tt_Normal ? (
|
||||
m_tributary ? "tributary" :
|
||||
iCategoryFlag == 1 ? "normal" :
|
||||
iCategoryFlag == 2 ? "road" :
|
||||
iCategoryFlag == 4 ? "river" :
|
||||
|
||||
Reference in New Issue
Block a user