Skip to content

Commit 5e26116

Browse files
committed
Automatic merge of T1.6-rc2-41-gacd714487 and 8 pull requests
- Pull request #1086 at e10390b: Add Settings Exporter tool (copy settings to INI, etc) - Pull request #1091 at 2391bc0: Automatic speed control - Pull request #1107 at f5eb3dc: Fix DPMode when last remote is moved to front. - Pull request #1110 at 387388e: Fix Activity Runner persists after loading exception - Pull request #1112 at 1224807: update for V1.6 - Pull request #1082 at 5845a1a: Allow variable water level in glass gauge - Pull request #1104 at f40920a: Handle simple adhesion within the axle module - Pull request #1081 at 689494b: Brake cuts power unification
10 parents 5cf62c9 + acd7144 + e10390b + 2391bc0 + f5eb3dc + 387388e + 1224807 + 5845a1a + f40920a + 689494b commit 5e26116

File tree

2 files changed

+29
-39
lines changed

2 files changed

+29
-39
lines changed

Source/Orts.Simulation/Simulation/Activity.cs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,6 @@ 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
889887
}
890888
else
891889
{
@@ -902,30 +900,29 @@ public override void NotifyEvent(ActivityEventType EventType)
902900
if (BoardingS > 0 || ((double)(SchDepart - SchArrive).TotalSeconds > 0 &&
903901
MyPlayerTrain.PassengerCarsNumber == 1 && MyPlayerTrain.Cars.Count > 10 ))
904902
{
905-
// accepted station stop because either freight train or passenger train or fake passenger train with passenger car on platform or fake passenger train
903+
// accepted station stop because either freight train or passenger train or fake passenger train with passenger car on platform or fake passenger train
906904
// with Scheduled Depart > Scheduled Arrive
907-
// ActArrive is usually same as ClockTime
908-
BoardingEndS = Simulator.ClockTime + BoardingS;
905+
// ActArrive is usually same as ClockTime
906+
BoardingEndS = Simulator.ClockTime + BoardingS;
909907

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

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);
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);
922920

921+
}
923922
}
924-
925-
ldbfevaldepartbeforeboarding = false; // reset flag. Debrief Eval
926-
}
927923
if (MyPlayerTrain.NextSignalObject[0] != null)
928924
distanceToNextSignal = MyPlayerTrain.NextSignalObject[0].DistanceTo(MyPlayerTrain.FrontTDBTraveller);
925+
929926
}
930927
}
931928
else if (EventType == ActivityEventType.TrainStart)
@@ -940,15 +937,6 @@ public override void NotifyEvent(ActivityEventType EventType)
940937
if (MyPlayerTrain.TrainType != Train.TRAINTYPE.AI_PLAYERHOSTING)
941938
MyPlayerTrain.ClearStation(PlatformEnd1.LinkedPlatformItemId, PlatformEnd2.LinkedPlatformItemId, true);
942939

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-
952940
if (LogStationStops)
953941
{
954942
StringBuilder stringBuild = new StringBuilder();
@@ -993,6 +981,15 @@ public override void NotifyEvent(ActivityEventType EventType)
993981
{
994982
DisplayMessage = Simulator.Catalog.GetStringFmt("Passenger boarding completes in {0:D2}:{1:D2}",
995983
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+
}
996993
}
997994
// May depart
998995
else if (!maydepart)
@@ -1011,6 +1008,8 @@ public override void NotifyEvent(ActivityEventType EventType)
10111008
if (MyPlayerTrain.IsActualPlayerTrain) Simulator.SoundNotify = Event.PermissionToDepart;
10121009
}
10131010

1011+
ldbfevaldepartbeforeboarding = false;//reset flag. Debrief Eval
1012+
10141013
// if last task, show closure window
10151014
// also set times in logfile
10161015

Source/RunActivity/Viewer3D/Lights.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ bool UpdateState()
300300
Debug.Assert(Viewer.PlayerTrain.LeadLocomotive == Viewer.PlayerLocomotive ||Viewer.PlayerTrain.TrainType == Train.TRAINTYPE.AI_PLAYERHOSTING || Viewer.PlayerTrain.Autopilot ||
301301
Viewer.PlayerTrain.TrainType == Train.TRAINTYPE.REMOTE || Viewer.PlayerTrain.TrainType == Train.TRAINTYPE.STATIC, "PlayerTrain.LeadLocomotive must be PlayerLocomotive.");
302302
var leadLocomotiveCar = Car.Train?.LeadLocomotive; // Note: Will return null for AI trains, this is intended behavior
303-
var leadLocomotive = leadLocomotiveCar as MSTSLocomotive;
303+
var leadLocomotive = leadLocomotiveCar as MSTSLocomotive;
304304

305305
// There are a lot of conditions now! IgnoredConditions[] stores which conditions are ignored, allowing shortcutting of many of these calculations
306306
// Should prevent some unneeded computation, but is a little messy. May revise in the future
@@ -318,7 +318,7 @@ bool UpdateState()
318318
&& leadLocomotive != null && leadLocomotive.TrainBrakeController.EmergencyBraking;
319319
// Control
320320
bool newCarIsPlayer = !Car.Lights.IgnoredConditions[3] && Car.Train != null && (Car.Train == Viewer.PlayerTrain || Car.Train.TrainType == Train.TRAINTYPE.REMOTE);
321-
// Service - if a player or AI train, then will considered to be in service, loose consists will not be considered to be in service.
321+
// Service - if a player or AI train, then will considered to be in servie, loose consists will not be considered to be in service.
322322
bool newCarInService = !Car.Lights.IgnoredConditions[4] && Car.Train != null
323323
&& (Car.Train == Viewer.PlayerTrain || Car.Train.TrainType == Train.TRAINTYPE.REMOTE || Car.Train.TrainType == Train.TRAINTYPE.AI);
324324
// Time of day
@@ -346,15 +346,6 @@ bool UpdateState()
346346
// Passenger doors
347347
bool newLeftDoorOpen = !Car.Lights.IgnoredConditions[11] && Car.Train?.DoorState(DoorSide.Left) != DoorState.Closed;
348348
bool newRightDoorOpen = !Car.Lights.IgnoredConditions[11] && Car.Train?.DoorState(DoorSide.Right) != DoorState.Closed;
349-
// AI trains don't have a lead locomotive, but the upcoming lighting calculations want a lead locomotive, try to determine a lead locomotive to use
350-
if (leadLocomotive == null && Car.Train != null)
351-
{
352-
// If first car is flipped, the 'lead' vehicle is actually at the rear
353-
if (Car.Train.FirstCar.Flipped && Car.Train.LastCar is MSTSLocomotive)
354-
leadLocomotive = Car.Train.LastCar as MSTSLocomotive;
355-
else if (Car.Train.FirstCar is MSTSLocomotive)
356-
leadLocomotive = Car.Train.FirstCar as MSTSLocomotive;
357-
}
358349
// Horn and bell (for flashing ditch lights)
359350
bool newHornOn = !Car.Lights.IgnoredConditions[12] && leadLocomotive != null && leadLocomotive.HornRecent;
360351
bool newBellOn = !Car.Lights.IgnoredConditions[13] && leadLocomotive != null && leadLocomotive.BellRecent;

0 commit comments

Comments
 (0)