16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 18:39:18 +02:00

Poprawki do działania tabelki rozkładów. Poprawka funkcji konwersji int na string.

This commit is contained in:
firleju
2016-09-12 22:10:13 +02:00
parent 803cefc71d
commit 38f25f5235
5 changed files with 21 additions and 16 deletions

View File

@@ -39,6 +39,7 @@ class TRotation;
namespace Mtable namespace Mtable
{ {
class TTrainParameters; // rozk³ad jazdy class TTrainParameters; // rozk³ad jazdy
class TMtableTime; // czas dla danego posterunku
}; };
class TController; // obiekt steruj¹cy poci¹giem (AI) class TController; // obiekt steruj¹cy poci¹giem (AI)

View File

@@ -838,7 +838,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
// następny postój // następny postój
TrainParams->UpdateMTable( TrainParams->UpdateMTable(
GlobalTime->hh, GlobalTime->mm, GlobalTime->hh, GlobalTime->mm,
asNextStop.substr(20, asNextStop.length())); asNextStop.substr(19, asNextStop.length()));
TrainParams->StationIndexInc(); // przejście do następnej TrainParams->StationIndexInc(); // przejście do następnej
asNextStop = asNextStop =
TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania
@@ -5292,20 +5292,18 @@ TCommandType TController::BackwardScan()
std::string TController::NextStop() std::string TController::NextStop()
{ // informacja o następnym zatrzymaniu, wyświetlane pod [F1] { // 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 return ""; // nie zawiera nazwy stacji, gdy dojechał do końca
// dodać godzinę odjazdu // dodać godzinę odjazdu
if (!TrainParams) if (!TrainParams)
return ""; // tu nie powinno nigdy wejść return ""; // tu nie powinno nigdy wejść
TMTableLine *t = TrainParams->TimeTable + TrainParams->StationIndex; TMTableLine *t = TrainParams->TimeTable + TrainParams->StationIndex;
std::string tmp = "";
if (t->Dh >= 0) // jeśli jest godzina odjazdu if (t->Dh >= 0) // jeśli jest godzina odjazdu
return asNextStop.substr(20, 30) + " " + Global::to_string(t->Dh) + return asNextStop.substr(19, 30) + " " + Global::to_string(t->Dh) + ":" +
":" + Global::to_string(100 + t->Dm).substr(2, 2); // odjazd Global::to_string(t->Dm); // odjazd
else if (t->Ah >= 0) // przyjazd else if (t->Ah >= 0) // przyjazd
return asNextStop.substr(20, 30) + " (" + Global::to_string(t->Ah) + return asNextStop.substr(19, 30) + " (" + Global::to_string(t->Ah) + ":" +
":" + Global::to_string(100 + t->Am).substr(2, 2) + Global::to_string(t->Am) + ")"; // przyjazd
")"; // przyjazd
return ""; return "";
}; };

View File

@@ -23,7 +23,7 @@ http://mozilla.org/MPL/2.0/.
#include "Console.h" #include "Console.h"
#include <Controls.hpp> //do odczytu daty #include <Controls.hpp> //do odczytu daty
#include "World.h" #include "World.h"
#include <ostream>
// namespace Global { // namespace Global {
// parametry do u¿ytku wewnêtrznego // 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 Global::to_string(int _Val)
{ {
std::string str; std::ostringstream o;
int num = 3; o << _Val;
sprintf((char*)str.c_str(), "%d", _Val); return o.str();
return str;
}; };
#pragma package(smart_init) #pragma package(smart_init)

View File

@@ -14,7 +14,8 @@ http://mozilla.org/MPL/2.0/.
#include "mtable.h" #include "mtable.h"
#include <fstream> #include <fstream>
using namespace Mtable; //using namespace Mtable;
TMTableTime *Mtable::GlobalTime;
double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/ double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/
// zwraca ró¿nicê czasu // zwraca ró¿nicê czasu

View File

@@ -77,9 +77,10 @@ namespace Mtable
void StationIndexInc(); void StationIndexInc();
}; };
struct /*class*/ TMTableTime class TMTableTime
{ {
public:
double GameTime; double GameTime;
int dd; int dd;
int hh; int hh;
@@ -93,6 +94,11 @@ namespace Mtable
TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM); 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 #endif // MTABLE_H