Skip to content

Commit 0190043

Browse files
committed
Tweak check for early departure to prevent false positives during deceleration
1 parent d0c2856 commit 0190043

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

Source/Orts.Simulation/Simulation/Activity.cs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,8 @@ public override void NotifyEvent(ActivityEventType EventType)
884884
double sinceActArriveS = (new DateTime().Add(TimeSpan.FromSeconds(Simulator.ClockTime))
885885
- ActArrive).Value.TotalSeconds;
886886
BoardingEndS -= sinceActArriveS;
887+
888+
ldbfevaldepartbeforeboarding = false; // reset flag. Debrief Eval
887889
}
888890
else
889891
{
@@ -900,29 +902,30 @@ public override void NotifyEvent(ActivityEventType EventType)
900902
if (BoardingS > 0 || ((double)(SchDepart - SchArrive).TotalSeconds > 0 &&
901903
MyPlayerTrain.PassengerCarsNumber == 1 && MyPlayerTrain.Cars.Count > 10 ))
902904
{
903-
// accepted station stop because either freight train or passenger train or fake passenger train with passenger car on platform or fake passenger train
905+
// accepted station stop because either freight train or passenger train or fake passenger train with passenger car on platform or fake passenger train
904906
// with Scheduled Depart > Scheduled Arrive
905-
// ActArrive is usually same as ClockTime
906-
BoardingEndS = Simulator.ClockTime + BoardingS;
907+
// ActArrive is usually same as ClockTime
908+
BoardingEndS = Simulator.ClockTime + BoardingS;
907909

908-
if (ActArrive == null)
909-
{
910-
ActArrive = new DateTime().Add(TimeSpan.FromSeconds(Simulator.ClockTime));
911-
}
910+
if (ActArrive == null)
911+
{
912+
ActArrive = new DateTime().Add(TimeSpan.FromSeconds(Simulator.ClockTime));
913+
}
912914

913-
arrived = true;
914-
// But not if game starts after scheduled arrival. In which case actual arrival is assumed to be same as schedule arrival.
915-
double sinceActArriveS = (new DateTime().Add(TimeSpan.FromSeconds(Simulator.ClockTime))
916-
- ActArrive).Value.TotalSeconds;
917-
BoardingEndS -= sinceActArriveS;
918-
double SchDepartS = SchDepart.Subtract(new DateTime()).TotalSeconds;
919-
BoardingEndS = CompareTimes.LatestTime((int)SchDepartS, (int)BoardingEndS);
915+
arrived = true;
916+
// But not if game starts after scheduled arrival. In which case actual arrival is assumed to be same as schedule arrival.
917+
double sinceActArriveS = (new DateTime().Add(TimeSpan.FromSeconds(Simulator.ClockTime))
918+
- ActArrive).Value.TotalSeconds;
919+
BoardingEndS -= sinceActArriveS;
920+
double SchDepartS = SchDepart.Subtract(new DateTime()).TotalSeconds;
921+
BoardingEndS = CompareTimes.LatestTime((int)SchDepartS, (int)BoardingEndS);
920922

921-
}
922923
}
924+
925+
ldbfevaldepartbeforeboarding = false; // reset flag. Debrief Eval
926+
}
923927
if (MyPlayerTrain.NextSignalObject[0] != null)
924928
distanceToNextSignal = MyPlayerTrain.NextSignalObject[0].DistanceTo(MyPlayerTrain.FrontTDBTraveller);
925-
926929
}
927930
}
928931
else if (EventType == ActivityEventType.TrainStart)
@@ -937,6 +940,15 @@ public override void NotifyEvent(ActivityEventType EventType)
937940
if (MyPlayerTrain.TrainType != Train.TRAINTYPE.AI_PLAYERHOSTING)
938941
MyPlayerTrain.ClearStation(PlatformEnd1.LinkedPlatformItemId, PlatformEnd2.LinkedPlatformItemId, true);
939942

943+
// Debrief Eval: departure before boarding completed
944+
if (!maydepart && !ldbfevaldepartbeforeboarding)
945+
{
946+
var train = Simulator.PlayerLocomotive.Train;
947+
ldbfevaldepartbeforeboarding = true;
948+
DbfEvalDepartBeforeBoarding.Add(PlatformEnd1.Station);
949+
train.DbfEvalValueChanged = true;
950+
}
951+
940952
if (LogStationStops)
941953
{
942954
StringBuilder stringBuild = new StringBuilder();
@@ -981,15 +993,6 @@ public override void NotifyEvent(ActivityEventType EventType)
981993
{
982994
DisplayMessage = Simulator.Catalog.GetStringFmt("Passenger boarding completes in {0:D2}:{1:D2}",
983995
remaining / 60, remaining % 60);
984-
985-
//Debrief Eval
986-
if (Simulator.PlayerLocomotive.SpeedMpS > 0 && !ldbfevaldepartbeforeboarding)
987-
{
988-
var train = Simulator.PlayerLocomotive.Train;
989-
ldbfevaldepartbeforeboarding = true;
990-
DbfEvalDepartBeforeBoarding.Add(PlatformEnd1.Station);
991-
train.DbfEvalValueChanged = true;
992-
}
993996
}
994997
// May depart
995998
else if (!maydepart)
@@ -1008,8 +1011,6 @@ public override void NotifyEvent(ActivityEventType EventType)
10081011
if (MyPlayerTrain.IsActualPlayerTrain) Simulator.SoundNotify = Event.PermissionToDepart;
10091012
}
10101013

1011-
ldbfevaldepartbeforeboarding = false;//reset flag. Debrief Eval
1012-
10131014
// if last task, show closure window
10141015
// also set times in logfile
10151016

0 commit comments

Comments
 (0)