From 8dd1ca19d41ae514cb010fa39ac41e30619e7e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=B3lik=20Uszasty?= Date: Mon, 21 Dec 2020 12:20:26 +0100 Subject: [PATCH] Added optional train category to the timetable --- mtable.cpp | 37 +++++++++++++++++++++++++++++++------ mtable.h | 1 + 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/mtable.cpp b/mtable.cpp index 2fce8841..fafc852e 100644 --- a/mtable.cpp +++ b/mtable.cpp @@ -310,14 +310,38 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax) // pliku} // ConversionError:=-7 {błąd niezgodności} TrainName = s; // nadanie nazwy z pliku TXT (bez ścieżki do pliku) + bool isCategory = false; + while (fin >> s || fin.bad()) + { + if (s.find("_______|") != std::string::npos) + { + break; + } + if (s == "Kategoria") + { + isCategory = true; + break; + } + } // while (!(s == "Seria")); + if (isCategory) + { + do + { + fin >> s; + } while (!((s == "|") || (fin.bad()))); + fin >> TrainCategory; + } // else { /*czytaj naglowek*/ - while (fin >> s || !fin.bad()) - { - if (s.find("_______|") != std::string::npos) - break; - // fin >> s; - } // while (!(s.find("_______|") != std::string::npos) || fin.eof()); + if (isCategory) + { + while (fin >> s || !fin.bad()) + { + if (s.find("_______|") != std::string::npos) + break; + // fin >> s; + } // while (!(s.find("_______|") != std::string::npos) || fin.eof()); + } while (fin >> s || !fin.bad()) { if (s == "[") @@ -622,6 +646,7 @@ bool TTrainParameters::DirectionChange() void TTrainParameters::serialize( dictionary_source *Output ) const { Output->insert( "trainnumber", TrainName ); + Output->insert( "traincategory", TrainCategory ); Output->insert( "train_brakingmassratio", BrakeRatio ); Output->insert( "train_enginetype", LocSeries ); Output->insert( "train_engineload", LocLoad ); diff --git a/mtable.h b/mtable.h index 353af85f..a30757b7 100644 --- a/mtable.h +++ b/mtable.h @@ -50,6 +50,7 @@ class TTrainParameters { public: std::string TrainName; + std::string TrainCategory; double TTVmax; std::string Relation1; std::string Relation2; // nazwy stacji danego odcinka