16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 02:09:17 +02:00

fixed recognition of train stops.

This commit is contained in:
tmj-fstate
2017-02-05 00:58:24 +01:00
parent 589b6d5301
commit fdb95d3b63
6 changed files with 42 additions and 42 deletions

View File

@@ -160,7 +160,7 @@ void TSpeedPos::CommandCheck()
case cm_PassengerStopPoint:
// nie ma dostępu do rozkładu
// przystanek, najwyżej AI zignoruje przy analizie tabelki
if ((iFlags & spPassengerStopPoint) == 0)
// if ((iFlags & spPassengerStopPoint) == 0)
fVelNext = 0.0; // TrainParams->IsStop()?0.0:-1.0; //na razie tak
iFlags |= spPassengerStopPoint; // niestety nie da się w tym miejscu współpracować z rozkładem
break;
@@ -829,7 +829,8 @@ 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)
// 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) // jeśli został przejechany
sSpeedTable[i].iFlags =
@@ -856,8 +857,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
// licznika) ma przesunąć na
// następny postój
TrainParams->UpdateMTable(
GlobalTime->hh, GlobalTime->mm,
asNextStop.substr(19, asNextStop.length()));
GlobalTime->hh, GlobalTime->mm, asNextStop);
TrainParams->StationIndexInc(); // przejście do następnej
asNextStop =
TrainParams->NextStop(); // pobranie kolejnego miejsca zatrzymania
@@ -956,8 +956,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
// opóźnia również kierownika
}
if (TrainParams->UpdateMTable(
GlobalTime->hh, GlobalTime->mm,
asNextStop.substr(19, asNextStop.length())))
GlobalTime->hh, GlobalTime->mm, asNextStop) )
{ // to się wykona tylko raz po zatrzymaniu na W4
if (TrainParams->CheckTrainLatency() < 0.0)
iDrivigFlags |= moveLate; // odnotowano spóźnienie
@@ -2438,7 +2437,8 @@ bool TController::IncSpeed()
if (tsGuardSignal->GetStatus() & DSBSTATUS_PLAYING) // jeśli gada, to nie jedziemy
return false;
bool OK = true;
if (iDrivigFlags & moveDoorOpened)
if ((iDrivigFlags & moveDoorOpened)
&&(mvOccupied->Vel > 0.1)) // added velocity threshold to prevent door shuffle on stop
Doors(false); // zamykanie drzwi - tutaj wykonuje tylko AI (zmienia fActionTime)
if (fActionTime < 0.0) // gdy jest nakaz poczekać z jazdą, to nie ruszać
return false;
@@ -4184,6 +4184,12 @@ bool TController::UpdateSituation(double dt)
{ // komunikat od kierownika tu, bo musi być wolna droga i odczekany czas
// stania
iDrivigFlags &= ~moveGuardSignal; // tylko raz nadać
if( iDrivigFlags & moveDoorOpened ) // jeśli drzwi otwarte
if( !mvOccupied
->DoorOpenCtrl ) // jeśli drzwi niesterowane przez maszynistę
Doors( false ); // a EZT zamknie dopiero po odegraniu komunikatu kierownika
tsGuardSignal->Stop();
// w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy
// bezpośrednim
@@ -4207,11 +4213,6 @@ bool TController::UpdateSituation(double dt)
1.0, 0, true,
pVehicle->GetPosition()); // dźwięk niby przez radio
}
if (iDrivigFlags & moveDoorOpened) // jeśli drzwi otwarte
if (!mvOccupied
->DoorOpenCtrl) // jeśli drzwi niesterowane przez maszynistę
Doors(false); // a EZT zamknie dopiero po odegraniu komunikatu
// kierownika
}
if (mvOccupied->V == 0.0)
AbsAccS = fAccGravity; // Ra 2014-03: jesli skład stoi, to działa na niego
@@ -5238,19 +5239,24 @@ TCommandType TController::BackwardScan()
std::string TController::NextStop()
{ // informacja o następnym zatrzymaniu, wyświetlane pod [F1]
if (asNextStop.length() < 19)
if (asNextStop == "[End of route]")
return ""; // nie zawiera nazwy stacji, gdy dojechał do końca
// dodać godzinę odjazdu
if (!TrainParams)
return ""; // tu nie powinno nigdy wejść
std::string nextstop = asNextStop;
TMTableLine *t = TrainParams->TimeTable + TrainParams->StationIndex;
if (t->Dh >= 0) // jeśli jest godzina odjazdu
return asNextStop.substr(19, 30) + " " + std::to_string(t->Dh) + ":" +
std::to_string(t->Dm); // odjazd
else if (t->Ah >= 0) // przyjazd
return asNextStop.substr(19, 30) + " (" + std::to_string(t->Ah) + ":" +
std::to_string(t->Am) + ")"; // przyjazd
return "";
if( t->Ah >= 0 ) {
// przyjazd
nextstop += " przyj." + std::to_string( t->Ah ) + ":"
+ ( t->Am < 10 ? "0" : "" ) + std::to_string( t->Am );
}
if( t->Dh >= 0 ) {
// jeśli jest godzina odjazdu
nextstop += " odj." + std::to_string( t->Dh ) + ":"
+ ( t->Dm < 10 ? "0" : "" ) + std::to_string( t->Dm );
}
return nextstop;
};
//-----------koniec skanowania semaforow