mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 21:49:19 +02:00
Przewijanie do prawidłowego przystanku
This commit is contained in:
@@ -764,7 +764,14 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
// first 19 chars of the command is expected to be "PassengerStopPoint:" so we skip them
|
||||
if ( ToLower(sSpeedTable[i].evEvent->CommandGet()).compare( 19, sizeof(asNextStop), ToLower(asNextStop)) != 0 )
|
||||
{ // jeśli nazwa nie jest zgodna
|
||||
if( sSpeedTable[ i ].fDist < -fLength ) {
|
||||
if (sSpeedTable[i].fDist < 300.0 && sSpeedTable[i].fDist > 0) // tylko jeśli W4 jest blisko, przy dwóch może zaczać szaleć
|
||||
{
|
||||
// porównuje do następnej stacji, więc trzeba przewinąć do poprzedniej
|
||||
// nastepnie ustawić następną na aktualną tak żeby prawidłowo ją obsłużył w następnym kroku
|
||||
TrainParams->RewindTimeTable(sSpeedTable[i].evEvent->CommandGet());
|
||||
asNextStop = TrainParams->NextStop();
|
||||
}
|
||||
else if( sSpeedTable[ i ].fDist < -fLength ) {
|
||||
// jeśli został przejechany
|
||||
sSpeedTable[ i ].iFlags = 0; // to można usunąć (nie mogą być usuwane w skanowaniu)
|
||||
}
|
||||
|
||||
28
mtable.cpp
28
mtable.cpp
@@ -104,6 +104,34 @@ bool TTrainParameters::UpdateMTable(double hh, double mm, std::string const &New
|
||||
return OK; /*czy jest nastepna stacja*/
|
||||
}
|
||||
|
||||
void Mtable::TTrainParameters::RewindTimeTable(std::string actualStationName)
|
||||
{
|
||||
//actualStationName = ToLower(actualStationName); // na małe znaki
|
||||
if (int s = actualStationName.find("PassengerStopPoint:") != std::string::npos)
|
||||
{
|
||||
actualStationName = ToLower(actualStationName.substr(s + 19));
|
||||
}
|
||||
for (int i = 1; i <= StationCount; i++)
|
||||
{ // przechodzimy po całej tabelce i sprawdzamy nazwy stacji (bez pierwszej)
|
||||
if (ToLower(TimeTable[i].StationName) == actualStationName)
|
||||
{ // nazwa stacji zgodna
|
||||
// więc ustawiamy na poprzednią, żeby w następnym kroku poprawnie obsłużyć
|
||||
StationIndex = i - 1;
|
||||
if (StationIndex <
|
||||
StationCount) // Ra: "<", bo dodaje 1 przy przejściu do następnej stacji
|
||||
{ // jeśli nie ostatnia stacja
|
||||
NextStationName = TimeTable[StationIndex + 1].StationName; // zapamiętanie nazwy
|
||||
TTVmax = TimeTable[StationIndex + 1]
|
||||
.vmax; // Ra: nowa prędkość rozkładowa na kolejnym odcinku
|
||||
}
|
||||
else // gdy ostatnia stacja
|
||||
NextStationName = ""; // nie ma następnej stacji
|
||||
break; // znaleźliśmy więc kończymy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TTrainParameters::StationIndexInc()
|
||||
{ // przejście do następnej pozycji StationIndex<=StationCount
|
||||
++StationIndex;
|
||||
|
||||
1
mtable.h
1
mtable.h
@@ -76,6 +76,7 @@ class TTrainParameters
|
||||
bool IsTimeToGo(double hh, double mm);
|
||||
bool UpdateMTable(double hh, double mm, std::string const &NewName);
|
||||
bool UpdateMTable( simulation_time const &Time, std::string const &NewName );
|
||||
void RewindTimeTable(std::string actualStationName);
|
||||
TTrainParameters( std::string const &NewTrainName );
|
||||
void NewName(std::string const &NewTrainName);
|
||||
void UpdateVelocity(int StationCount, double vActual);
|
||||
|
||||
Reference in New Issue
Block a user