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

refactor: the Sonar remarks on the small fixes taken care of

- the log stops through a flag kept in a function, not a global one
- the messages are put together with std::format
- a vehicle dropped on a trainset in the launcher goes in once the
  trainset is drawn, so the vehicles are gone through with a plain loop
  again; the drop split into a new vehicle and a moved one
- the scenario that can't be opened is caught as the runtime error it
  is, a file name outside of the code page as the system error it is
- a track of an unknown type is left out through the pointer owning it
- the keyword of a track type written out by a function of its own
- the picked node forgotten with ranges::replace_if, the empty
  Forget_Node of the base renderer told why it is empty
- FileCased takes the path it works on
This commit is contained in:
maj00r
2026-11-06 19:54:54 +01:00
parent 8523316006
commit a6778c9fe2
14 changed files with 140 additions and 75 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
@@ -429,7 +431,7 @@ void TTrack::Load(cParser *parser, glm::dvec3 const &pOrigin)
{
// 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");
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;
@@ -2319,25 +2321,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 ? (
m_tributary ? "tributary" :
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() << ' '

View File

@@ -358,6 +358,8 @@ private:
void deserialize_( std::istream &Input );
// export() subclass details, sends basic content of the class in legacy (text) format to provided stream
void export_as_text_( std::ostream &Output ) const;
// the keyword the track is written with, by its type and for a plain one by what runs on it
char const *type_keyword() const;
// locates specified profile in the profile database, potentially loading it from a file
static std::pair<std::string, int> fetch_track_rail_profile( std::string const &Profile );
// loads content of specified file and converts it into a vertex array