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

View File

@@ -5910,7 +5910,7 @@ TDynamicObject::ConnectedEnginePowerSource( TDynamicObject const *Caller ) const
// NOTE: the order should be reversed in flipped vehicles, but we ignore this out of laziness
if( ( nullptr != NextConnected )
&& ( NextConnected != Caller )
&& ( MoverParameters->Couplers[1].CouplingFlag & ctrain_controll == ctrain_controll ) ) {
&& ( ( MoverParameters->Couplers[1].CouplingFlag & ctrain_controll ) == ctrain_controll ) ) {
auto source = NextConnected->ConnectedEnginePowerSource( this );
if( source != TPowerSource::NotDefined ) {
@@ -5921,7 +5921,7 @@ TDynamicObject::ConnectedEnginePowerSource( TDynamicObject const *Caller ) const
// ...then rear...
if( ( nullptr != PrevConnected )
&& ( PrevConnected != Caller )
&& ( MoverParameters->Couplers[ 0 ].CouplingFlag & ctrain_controll == ctrain_controll ) ) {
&& ( ( MoverParameters->Couplers[ 0 ].CouplingFlag & ctrain_controll ) == ctrain_controll ) ) {
auto source = PrevConnected->ConnectedEnginePowerSource( this );
if( source != TPowerSource::NotDefined ) {

View File

@@ -316,7 +316,7 @@ void TEvent::Load(cParser *parser, vector3 *org)
if (token.substr(0, 19) == "PassengerStopPoint:")
{
if (token.find('#') != std::string::npos)
token = token.substr(0, token.find('#') - 1); // obcięcie unikatowości
token.erase(token.find('#')); // obcięcie unikatowości
bEnabled = false; // nie do kolejki (dla SetVelocity też, ale jak jest do toru
// dowiązany)
Params[6].asCommand = cm_PassengerStopPoint;

View File

@@ -2551,9 +2551,8 @@ void TTrain::UpdateMechPosition(double dt)
// ABu: rzucamy kabina tylko przy duzym FPS!
// Mala histereza, zeby bez przerwy nie przelaczalo przy FPS~17
// Granice mozna ustalic doswiadczalnie. Ja proponuje 14:20
double iVel = DynamicObject->GetVelocity();
if (iVel > 150.0)
iVel = 150.0;
double const iVel = std::min(DynamicObject->GetVelocity(), 150.0);
if (!Global::iSlowMotion // musi być pełna prędkość
&& (pMechOffset.y < 4.0)) // Ra 15-01: przy oglądaniu pantografu bujanie przeszkadza
{
@@ -2561,12 +2560,12 @@ void TTrain::UpdateMechPosition(double dt)
// acceleration-driven base shake
shake += 1.5 * MechSpring.ComputateForces(
vector3(
-mvControlled->AccN * dt * 7.5, // highlight side sway
mvControlled->AccV * dt * 15,
-mvControlled->AccS * dt ),
-mvControlled->AccN * dt * 5.0, // highlight side sway
mvControlled->AccV * dt,
-mvControlled->AccS * dt * 2.5 ), // accent acceleration/deceleration
pMechShake );
if( Random( iVel ) > 30.0 ) {
if( Random( iVel ) > 25.0 ) {
// extra shake at increased velocity
shake += MechSpring.ComputateForces(
vector3(
@@ -2576,7 +2575,7 @@ void TTrain::UpdateMechPosition(double dt)
pMechShake );
// * (( 200 - DynamicObject->MyTrack->iQualityFlag ) * 0.0075 ); // scale to 75-150% based on track quality
}
shake *= 1.35;
shake *= 1.25;
}
vMechVelocity -= (shake + vMechVelocity * 100) * (fMechSpringX + fMechSpringY + fMechSpringZ) / (200);
// shake *= 0.95 * dt; // shake damping

View File

@@ -1930,16 +1930,11 @@ TWorld::Render_UI() {
if( Global::iTextMode == VK_F1 ) { // tekst pokazywany po wciśnięciu [F1]
// Global::iViewMode=VK_F1;
glColor3f( 1.0f, 1.0f, 1.0f ); // a, damy białym
OutText1 = "Time: " + to_string( (int)GlobalTime->hh ) + ":";
int i = GlobalTime->mm; // bo inaczej potrafi zrobić "hh:010"
if( i < 10 )
OutText1 += "0";
OutText1 += to_string( i ); // minuty
OutText1 += ":";
i = floor( GlobalTime->mr ); // bo inaczej potrafi zrobić "hh:mm:010"
if( i < 10 )
OutText1 += "0";
OutText1 += to_string( i );
OutText1 =
"Time: "
+ to_string( (int)GlobalTime->hh ) + ":"
+ ( GlobalTime->mm < 10 ? "0" : "" ) + to_string( GlobalTime->mm ) + ":"
+ ( GlobalTime->mr < 10 ? "0" : "" ) + to_string( std::floor( GlobalTime->mr ) );
if( Global::iPause )
OutText1 += " - paused";
if( Controlled )

View File

@@ -59,7 +59,7 @@ double TTrainParameters::WatchMTable(double DistCounter)
std::string TTrainParameters::NextStop()
{ // pobranie nazwy następnego miejsca zatrzymania
if (StationIndex <= StationCount)
return "PassengerStopPoint:" + NextStationName; // nazwa następnego przystanku;
return NextStationName; // nazwa następnego przystanku;
else
return "[End of route]"; //że niby koniec
}