mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 10:09:17 +02:00
Obsługa rozkładu jazdy przetłumaczona na C++.
This commit is contained in:
58
Driver.cpp
58
Driver.cpp
@@ -17,7 +17,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma hdrstop
|
||||
|
||||
#include "Driver.h"
|
||||
#include <mtable.hpp>
|
||||
#include "mtable.h"
|
||||
#include "DynObj.h"
|
||||
#include <math.h>
|
||||
#include "Globals.h"
|
||||
@@ -810,7 +810,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
{ // o ile dana pozycja tabelki jest istotna
|
||||
if (sSpeedTable[i].iFlags & spPassengerStopPoint)
|
||||
{ // jeśli przystanek, trzeba obsłużyć wg rozkładu
|
||||
if (sSpeedTable[i].evEvent->CommandGet() != asNextStop)
|
||||
if (sSpeedTable[i].evEvent->CommandGet() != AnsiString(asNextStop.c_str()))
|
||||
{ // jeśli nazwa nie jest zgodna
|
||||
if (sSpeedTable[i].fDist < -fLength) // jeśli został przejechany
|
||||
sSpeedTable[i].iFlags =
|
||||
@@ -828,9 +828,9 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
{ // zaliczamy posterunek w pewnej odległości przed (choć W4 nie zasłania
|
||||
// już semafora)
|
||||
#if LOGSTOPS
|
||||
WriteLog(pVehicle->asName + " as " + TrainParams->TrainName + ": at " +
|
||||
WriteLog(pVehicle->asName + " as " + TrainParams->TrainName.c_str() + ": at " +
|
||||
AnsiString(GlobalTime->hh) + ":" + AnsiString(GlobalTime->mm) +
|
||||
" skipped " + asNextStop); // informacja
|
||||
" skipped " + AnsiString(asNextStop.c_str())); // informacja
|
||||
#endif
|
||||
fLastStopExpDist = mvOccupied->DistCounter + 0.250 +
|
||||
0.001 * fLength; // przy jakim dystansie (stanie
|
||||
@@ -838,7 +838,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
// następny postój
|
||||
TrainParams->UpdateMTable(
|
||||
GlobalTime->hh, GlobalTime->mm,
|
||||
asNextStop.SubString(20, asNextStop.Length()));
|
||||
asNextStop.substr(20, asNextStop.length()));
|
||||
TrainParams->StationIndexInc(); // przejście do następnej
|
||||
asNextStop =
|
||||
TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania
|
||||
@@ -938,7 +938,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
}
|
||||
if (TrainParams->UpdateMTable(
|
||||
GlobalTime->hh, GlobalTime->mm,
|
||||
asNextStop.SubString(20, asNextStop.Length())))
|
||||
asNextStop.substr(20, asNextStop.length())))
|
||||
{ // to się wykona tylko raz po zatrzymaniu na W4
|
||||
if (TrainParams->CheckTrainLatency() < 0.0)
|
||||
iDrivigFlags |= moveLate; // odnotowano spóźnienie
|
||||
@@ -1000,10 +1000,10 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
->NextStop(); // pobranie kolejnego miejsca zatrzymania
|
||||
// TableClear(); //aby od nowa sprawdziło W4 z inną nazwą już - to nie jest dobry pomysł
|
||||
#if LOGSTOPS
|
||||
WriteLog(pVehicle->asName + " as " + TrainParams->TrainName +
|
||||
WriteLog(pVehicle->asName + " as " + AnsiString(TrainParams->TrainName.c_str()) +
|
||||
": at " + AnsiString(GlobalTime->hh) + ":" +
|
||||
AnsiString(GlobalTime->mm) + " next " +
|
||||
asNextStop); // informacja
|
||||
AnsiString(asNextStop.c_str())); // informacja
|
||||
#endif
|
||||
if (int(floor(sSpeedTable[i].evEvent->ValueGet(1))) & 1)
|
||||
iDrivigFlags |= moveStopHere; // nie podjeżdżać do semafora,
|
||||
@@ -1027,7 +1027,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
else
|
||||
{ // jeśli dojechaliśmy do końca rozkładu
|
||||
#if LOGSTOPS
|
||||
WriteLog(pVehicle->asName + " as " + TrainParams->TrainName +
|
||||
WriteLog(pVehicle->asName + " as " + AnsiString(TrainParams->TrainName.c_str()) +
|
||||
": at " + AnsiString(GlobalTime->hh) + ":" +
|
||||
AnsiString(GlobalTime->mm) +
|
||||
" end of route."); // informacja
|
||||
@@ -1875,7 +1875,7 @@ bool TController::CheckVehicles(TOrders user)
|
||||
{
|
||||
if (TrainParams)
|
||||
if (p->asDestination == "none")
|
||||
p->DestinationSet(TrainParams->Relation2); // relacja docelowa, jeśli nie było
|
||||
p->DestinationSet(AnsiString(TrainParams->Relation2.c_str())); // relacja docelowa, jeśli nie było
|
||||
if (AIControllFlag) // jeśli prowadzi komputer
|
||||
p->RaLightsSet(0, 0); // gasimy światła
|
||||
if (p->MoverParameters->EnginePowerSource.SourceType == CurrentCollector)
|
||||
@@ -2933,15 +2933,15 @@ bool TController::PutCommand(AnsiString NewCommand, double NewValue1, double New
|
||||
WriteLog("New timetable for " + pVehicle->asName + ": " + NewCommand); // informacja
|
||||
#endif
|
||||
if (!TrainParams)
|
||||
TrainParams = new TTrainParameters(NewCommand); // rozkład jazdy
|
||||
TrainParams = new TTrainParameters(std::string(NewCommand.c_str())); // rozkład jazdy
|
||||
else
|
||||
TrainParams->NewName(NewCommand); // czyści tabelkę przystanków
|
||||
TrainParams->NewName(std::string(NewCommand.c_str())); // czyści tabelkę przystanków
|
||||
delete tsGuardSignal;
|
||||
tsGuardSignal = NULL; // wywalenie kierownika
|
||||
if (NewCommand != "none")
|
||||
{
|
||||
if (!TrainParams->LoadTTfile(
|
||||
Global::asCurrentSceneryPath, floor(NewValue2 + 0.5),
|
||||
std::string(Global::asCurrentSceneryPath.c_str()), floor(NewValue2 + 0.5),
|
||||
NewValue1)) // pierwszy parametr to przesunięcie rozkładu w czasie
|
||||
{
|
||||
if (ConversionError == -8)
|
||||
@@ -2980,7 +2980,7 @@ bool TController::PutCommand(AnsiString NewCommand, double NewValue1, double New
|
||||
iGuardRadio = iRadioChannel;
|
||||
}
|
||||
}
|
||||
NewCommand = TrainParams->Relation2; // relacja docelowa z rozkładu
|
||||
NewCommand = AnsiString(TrainParams->Relation2.c_str()); // relacja docelowa z rozkładu
|
||||
}
|
||||
// jeszcze poustawiać tekstury na wyświetlaczach
|
||||
TDynamicObject *p = pVehicles[0];
|
||||
@@ -4903,7 +4903,7 @@ void TController::OrdersInit(double fVel)
|
||||
// OrderPos=OrderTop=0; //wypełniamy od pozycji 0
|
||||
OrdersClear(); // usunięcie poprzedniej tabeli
|
||||
OrderPush(Prepare_engine); // najpierw odpalenie silnika
|
||||
if (TrainParams->TrainName == AnsiString("none"))
|
||||
if (TrainParams->TrainName == "none")
|
||||
{ // brak rozkładu to jazda manewrowa
|
||||
if (fVel > 0.05) // typowo 0.1 oznacza gotowość do jazdy, 0.01 tylko załączenie silnika
|
||||
OrderPush(Shunt); // jeśli nie ma rozkładu, to manewruje
|
||||
@@ -4913,8 +4913,7 @@ void TController::OrdersInit(double fVel)
|
||||
if ((fVel > 0.0) && (fVel < 0.02))
|
||||
OrderPush(Shunt); // dla prędkości 0.01 włączamy jazdę manewrową
|
||||
else if (TrainParams ?
|
||||
(TrainParams->TimeTable[1].StationWare.Pos(
|
||||
"@") ? // jeśli obrót na pierwszym przystanku
|
||||
(TrainParams->DirectionChange() ? // jeśli obrót na pierwszym przystanku
|
||||
((iDrivigFlags &
|
||||
movePushPull) ? // SZT również! SN61 zależnie od wagonów...
|
||||
(TrainParams->TimeTable[1].StationName == TrainParams->Relation1) :
|
||||
@@ -4933,10 +4932,10 @@ void TController::OrdersInit(double fVel)
|
||||
{
|
||||
t = TrainParams->TimeTable + i;
|
||||
if (DebugModeFlag) // normalnie nie ma po co tego wypisywać
|
||||
WriteLog(AnsiString(t->StationName) + " " + AnsiString((int)t->Ah) + ":" +
|
||||
WriteLog(AnsiString(t->StationName.c_str()) + " " + AnsiString((int)t->Ah) + ":" +
|
||||
AnsiString((int)t->Am) + ", " + AnsiString((int)t->Dh) + ":" +
|
||||
AnsiString((int)t->Dm) + " " + AnsiString(t->StationWare));
|
||||
if (AnsiString(t->StationWare).Pos("@"))
|
||||
AnsiString((int)t->Dm) + " " + AnsiString(t->StationWare.c_str()));
|
||||
if (AnsiString(t->StationWare.c_str()).Pos("@"))
|
||||
{ // zmiana kierunku i dalsza jazda wg rozkładu
|
||||
if (iDrivigFlags & movePushPull) // SZT również! SN61 zależnie od wagonów...
|
||||
{ // jeśli skład zespolony, wystarczy zmienić kierunek jazdy
|
||||
@@ -5291,21 +5290,22 @@ TCommandType TController::BackwardScan()
|
||||
return cm_Unknown; // nic
|
||||
};
|
||||
|
||||
AnsiString TController::NextStop()
|
||||
std::string TController::NextStop()
|
||||
{ // informacja o następnym zatrzymaniu, wyświetlane pod [F1]
|
||||
if (asNextStop.Length() < 20)
|
||||
if (asNextStop.length() < 20)
|
||||
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.SubString(20, 30) + AnsiString(" ") + AnsiString(int(t->Dh)) +
|
||||
AnsiString(":") + AnsiString(int(100 + t->Dm)).SubString(2, 2); // odjazd
|
||||
return asNextStop.substr(20, 30) + " " + Global::to_string(t->Dh) +
|
||||
":" + Global::to_string(100 + t->Dm).substr(2, 2); // odjazd
|
||||
else if (t->Ah >= 0) // przyjazd
|
||||
return asNextStop.SubString(20, 30) + AnsiString(" (") + AnsiString(int(t->Ah)) +
|
||||
AnsiString(":") + AnsiString(int(100 + t->Am)).SubString(2, 2) +
|
||||
AnsiString(")"); // przyjazd
|
||||
return asNextStop.substr(20, 30) + " (" + Global::to_string(t->Ah) +
|
||||
":" + Global::to_string(100 + t->Am).substr(2, 2) +
|
||||
")"; // przyjazd
|
||||
return "";
|
||||
};
|
||||
|
||||
@@ -5382,12 +5382,12 @@ void TController::DirectionForward(bool forward)
|
||||
mvControlling->IncMainCtrl(1); //żeby nie zgasł
|
||||
};
|
||||
|
||||
AnsiString TController::Relation()
|
||||
std::string TController::Relation()
|
||||
{ // zwraca relację pociągu
|
||||
return TrainParams->ShowRelation();
|
||||
};
|
||||
|
||||
AnsiString TController::TrainName()
|
||||
std::string TController::TrainName()
|
||||
{ // zwraca numer pociągu
|
||||
return TrainParams->TrainName;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user