From 38f25f5235f29565dac503aee3b6db130ce5a2b1 Mon Sep 17 00:00:00 2001 From: firleju Date: Mon, 12 Sep 2016 22:10:13 +0200 Subject: [PATCH] =?UTF-8?q?Poprawki=20do=20dzia=C5=82ania=20tabelki=20rozk?= =?UTF-8?q?=C5=82ad=C3=B3w.=20Poprawka=20funkcji=20konwersji=20int=20na=20?= =?UTF-8?q?string.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes.h | 1 + Driver.cpp | 14 ++++++-------- Globals.cpp | 9 ++++----- mtable.cpp | 3 ++- mtable.h | 10 ++++++++-- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Classes.h b/Classes.h index 90e875d1..10bc28ef 100644 --- a/Classes.h +++ b/Classes.h @@ -39,6 +39,7 @@ class TRotation; namespace Mtable { class TTrainParameters; // rozkład jazdy +class TMtableTime; // czas dla danego posterunku }; class TController; // obiekt sterujący pociągiem (AI) diff --git a/Driver.cpp b/Driver.cpp index 2af01f53..42dc44b3 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -838,7 +838,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN // następny postój TrainParams->UpdateMTable( GlobalTime->hh, GlobalTime->mm, - asNextStop.substr(20, asNextStop.length())); + asNextStop.substr(19, asNextStop.length())); TrainParams->StationIndexInc(); // przejście do następnej asNextStop = TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania @@ -5292,20 +5292,18 @@ TCommandType TController::BackwardScan() std::string TController::NextStop() { // informacja o następnym zatrzymaniu, wyświetlane pod [F1] - if (asNextStop.length() < 20) + if (asNextStop.length() < 19) return ""; // nie zawiera nazwy stacji, gdy dojechał do końca // dodać godzinę odjazdu if (!TrainParams) return ""; // tu nie powinno nigdy wejść TMTableLine *t = TrainParams->TimeTable + TrainParams->StationIndex; - std::string tmp = ""; if (t->Dh >= 0) // jeśli jest godzina odjazdu - return asNextStop.substr(20, 30) + " " + Global::to_string(t->Dh) + - ":" + Global::to_string(100 + t->Dm).substr(2, 2); // odjazd + return asNextStop.substr(19, 30) + " " + Global::to_string(t->Dh) + ":" + + Global::to_string(t->Dm); // odjazd else if (t->Ah >= 0) // przyjazd - return asNextStop.substr(20, 30) + " (" + Global::to_string(t->Ah) + - ":" + Global::to_string(100 + t->Am).substr(2, 2) + - ")"; // przyjazd + return asNextStop.substr(19, 30) + " (" + Global::to_string(t->Ah) + ":" + + Global::to_string(t->Am) + ")"; // przyjazd return ""; }; diff --git a/Globals.cpp b/Globals.cpp index f4953ddf..dd40315d 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -23,7 +23,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include //do odczytu daty #include "World.h" - +#include // namespace Global { // parametry do użytku wewnętrznego @@ -921,10 +921,9 @@ double Global::CutValueToRange(double min, double value, double max) std::string Global::to_string(int _Val) { - std::string str; - int num = 3; - sprintf((char*)str.c_str(), "%d", _Val); - return str; + std::ostringstream o; + o << _Val; + return o.str(); }; #pragma package(smart_init) diff --git a/mtable.cpp b/mtable.cpp index 0f169e25..6c0476f5 100644 --- a/mtable.cpp +++ b/mtable.cpp @@ -14,7 +14,8 @@ http://mozilla.org/MPL/2.0/. #include "mtable.h" #include -using namespace Mtable; +//using namespace Mtable; +TMTableTime *Mtable::GlobalTime; double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/ // zwraca różnicę czasu diff --git a/mtable.h b/mtable.h index 95350c85..327d4b5e 100644 --- a/mtable.h +++ b/mtable.h @@ -77,9 +77,10 @@ namespace Mtable void StationIndexInc(); }; - struct /*class*/ TMTableTime + class TMTableTime { + public: double GameTime; int dd; int hh; @@ -93,6 +94,11 @@ namespace Mtable TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM); }; - TMTableTime *GlobalTime; + extern TMTableTime *GlobalTime; } + +#if !defined(NO_IMPLICIT_NAMESPACE_USE) +using namespace Mtable; +#endif + #endif // MTABLE_H