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

Merge pull request #244 from MaSzyna-EU07/split/1-small-fixes

Split/1 small fixes
This commit is contained in:
2026-11-07 11:19:45 +00:00
committed by GitHub
24 changed files with 282 additions and 66 deletions

View File

@@ -29,6 +29,8 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/Logs.h"
#include "rendering/renderer.h"
#include <format>
// 101206 Ra: trapezoidalne drogi i tory
// 110720 Ra: rozprucie zwrotnicy i odcinki izolowane
@@ -432,11 +434,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(std::format("Bad track: tributary \"{}\" in file \"{}\" (line {}) is drawn and run on as a river of its first path", m_name, parser->Name(), parser->Line()));
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);
@@ -522,6 +528,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 );
@@ -697,6 +708,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
@@ -2336,24 +2351,37 @@ TTrack::deserialize_( std::istream &Input ) {
// TODO: implement
}
// the keyword the track is written with, by its type and for a plain one by what runs on it
char const *
TTrack::type_keyword() const {
if( eType == tt_Normal && m_tributary ) {
return "tributary";
}
if( eType == tt_Normal ) {
switch( iCategoryFlag ) {
case 1: { return "normal"; }
case 2: { return "road"; }
case 4: { return "river"; }
default: { return "none"; }
}
}
switch( eType ) {
case tt_Switch: { return "switch"; }
case tt_Cross: { return "cross"; }
case tt_Table: { return "turn"; }
case tt_Tributary: { return "tributary"; }
default: { return "none"; }
}
}
// export() subclass details, sends basic content of the class in legacy (text) format to provided stream
void
TTrack::export_as_text_( std::ostream &Output ) const {
// header
Output << "track ";
// type
Output << (
eType == tt_Normal ? (
iCategoryFlag == 1 ? "normal" :
iCategoryFlag == 2 ? "road" :
iCategoryFlag == 4 ? "river" :
"none" ) :
eType == tt_Switch ? "switch" :
eType == tt_Cross ? "cross" :
eType == tt_Table ? "turn" :
eType == tt_Tributary ? "tributary" :
"none" )
<< ' ';
Output << type_keyword() << ' ';
// basic attributes
Output
<< Length() << ' '