Skip to content

Commit 9d94ed9

Browse files
committed
Automatic merge of T1.5.1-1201-g5d239654f2 and 17 pull requests
- Pull request #799 at dfc715e: Consolidated wind simulation - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #885 at 8f473ce: feat: Add notifications to Menu - Pull request #891 at 9a1d6b2: Auto save - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #952 at 8347095: Investigation - Pulsing graphics - Pull request #953 at a519452: Fix Lights Crash on Corrupt Shapes - Pull request #954 at e715fa4: Multiple Track Profiles & Superelevation Improvements - Pull request #962 at 46d0472: Fix pantographs on unpowered cars - Pull request #972 at e90a2aa: On Map window color changed switch or signal is not changed - Pull request #980 at a7406de: Downloading route content (Github, zip) second part - Pull request #981 at ef9b55d: Multiple type trainset lightglows - Pull request #982 at efcf19c: WEB based Switch Panel enhancement: Alerter - Pull request #983 at 202316e: WEB based Switch Panel bug: DPU window - Pull request #900 at c27f32d: DMI updates - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #984 at 6c841d1: Player train switching for timetable mode
19 parents 247cfb5 + 5d23965 + dfc715e + d00beb9 + 8f473ce + 9a1d6b2 + 1f5ba4c + 8347095 + a519452 + e715fa4 + 46d0472 + e90a2aa + a7406de + ef9b55d + efcf19c + 202316e + c27f32d + f92de76 + 6c841d1 commit 9d94ed9

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

Source/Orts.Simulation/Simulation/Simulator.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,13 @@ private void StartSwitchPlayerTrain()
19201920
var playerTrain = PlayerLocomotive.Train as AITrain;
19211921
if (playerTrain != null)
19221922
{
1923+
if (TimetableMode && playerTrain.ControlMode == Train.TRAIN_CONTROL.MANUAL)
1924+
{
1925+
Confirmer.Message(ConfirmLevel.Warning, Catalog.GetString("Train can't be switched if in manual mode"));
1926+
TrainSwitcher.SuspendOldPlayer = false;
1927+
TrainSwitcher.ClickedSelectedAsPlayer = false;
1928+
return;
1929+
}
19231930
if (playerTrain.ControlMode == Train.TRAIN_CONTROL.MANUAL) TrainSwitcher.SuspendOldPlayer = true; // force suspend state to avoid disappearing of train;
19241931
if (TrainSwitcher.SuspendOldPlayer &&
19251932
(playerTrain.SpeedMpS < -0.025 || playerTrain.SpeedMpS > 0.025 || playerTrain.PresentPosition[0].TCOffset != playerTrain.PreviousPosition[0].TCOffset))
@@ -1929,14 +1936,14 @@ private void StartSwitchPlayerTrain()
19291936
TrainSwitcher.ClickedSelectedAsPlayer = false;
19301937
return;
19311938
}
1932-
if (playerTrain.TrainType == Train.TRAINTYPE.AI_PLAYERDRIVEN)
1939+
if (playerTrain.TrainType == Train.TRAINTYPE.AI_PLAYERDRIVEN || !playerTrain.Autopilot)
19331940
{
19341941
// it must be autopiloted first
19351942
playerTrain.SwitchToAutopilotControl();
19361943
}
19371944
// and now switch!
19381945
playerTrain.TrainType = Train.TRAINTYPE.AI;
1939-
AI.AITrains.Add(playerTrain);
1946+
playerTrain.Autopilot = false;
19401947
if (TrainSwitcher.SuspendOldPlayer)
19411948
{
19421949
playerTrain.MovementState = AITrain.AI_MOVEMENT_STATE.SUSPENDED;
@@ -2088,6 +2095,18 @@ private void StartSwitchPlayerTrain()
20882095
PlayerLocomotive = SetPlayerLocomotive(pathlessPlayerTrain);
20892096
if (oldPlayerTrain != null) oldPlayerTrain.LeadLocomotiveIndex = -1;
20902097
}
2098+
if (TimetableMode)
2099+
{
2100+
// In timetable mode player train must have number 0
2101+
(PlayerLocomotive.Train.Number, oldPlayerTrain.Number) = (oldPlayerTrain.Number, PlayerLocomotive.Train.Number);
2102+
var oldPlayerTrainIndex = Trains.IndexOf(oldPlayerTrain);
2103+
var playerTrainIndex = Trains.IndexOf(PlayerLocomotive.Train);
2104+
(Trains[oldPlayerTrainIndex], Trains[playerTrainIndex]) = (Trains[playerTrainIndex], Trains[oldPlayerTrainIndex]);
2105+
var index = AI.AITrains.IndexOf(PlayerLocomotive.Train as AITrain);
2106+
(AI.AITrains[0], AI.AITrains[index]) = (AI.AITrains[index], AI.AITrains[0]);
2107+
AI.aiListChanged = true;
2108+
PlayerLocomotive.Train.Autopilot = true;
2109+
}
20912110
playerSwitchOngoing = true;
20922111
if (MPManager.IsMultiPlayer())
20932112
{
@@ -2106,19 +2125,23 @@ private void CompleteSwitchPlayerTrain()
21062125
{
21072126
if (PlayerLocomotive.Train.TrainType != Train.TRAINTYPE.STATIC)
21082127
{
2128+
if (!TimetableMode)
21092129
AI.AITrains.Remove(PlayerLocomotive.Train as AITrain);
21102130
if ((PlayerLocomotive.Train as AITrain).MovementState == AITrain.AI_MOVEMENT_STATE.SUSPENDED)
21112131
{
21122132
PlayerLocomotive.Train.Reinitialize();
21132133
(PlayerLocomotive.Train as AITrain).MovementState = Math.Abs(PlayerLocomotive.Train.SpeedMpS) <= MaxStoppedMpS ?
21142134
AITrain.AI_MOVEMENT_STATE.INIT : AITrain.AI_MOVEMENT_STATE.BRAKING;
21152135
}
2136+
if (!TimetableMode)
21162137
(PlayerLocomotive.Train as AITrain).SwitchToPlayerControl();
21172138
}
21182139
else
21192140
{
21202141
PlayerLocomotive.Train.CreatePathlessPlayerTrain();
21212142
}
2143+
var playerLocomotive = PlayerLocomotive as MSTSLocomotive;
2144+
playerLocomotive.UsingRearCab = (PlayerLocomotive.Flipped ^ PlayerLocomotive.Train.MUDirection == Direction.Reverse) && (playerLocomotive.HasRearCab || playerLocomotive.HasRear3DCab);
21222145
OnPlayerLocomotiveChanged();
21232146
playerSwitchOngoing = false;
21242147
TrainSwitcher.ClickedSelectedAsPlayer = false;

Source/RunActivity/Viewer3D/Popups/TrainListWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected override ControlLayout Layout(ControlLayout layout)
9191
line.Add(viewed = new TrainLabel(Owner.TextFontDefault.Height, line.RemainingHeight, Owner.Viewer, thisTrain, "*", LabelAlignment.Right));
9292
viewed.Color = Color.Red;
9393
}
94-
if (Owner.Viewer.Simulator.IsAutopilotMode && !Owner.Viewer.Simulator.TimetableMode)
94+
if (Owner.Viewer.Simulator.IsAutopilotMode)
9595
{
9696
number.Color = thisTrain.IsPlayable ? Color.LightGreen : Color.White;
9797
name.Color = thisTrain.IsPlayable ? Color.LightGreen : Color.White;
@@ -110,7 +110,7 @@ protected override ControlLayout Layout(ControlLayout layout)
110110
}
111111

112112
// Now list static trains with loco and cab
113-
if (Owner.Viewer.Simulator.IsAutopilotMode && !Owner.Viewer.Simulator.TimetableMode)
113+
if (Owner.Viewer.Simulator.IsAutopilotMode)
114114
{
115115
foreach (var thisTrain in Owner.Viewer.Simulator.Trains)
116116
{
@@ -181,7 +181,7 @@ void TrainListLabel_Click(Control arg1, Point arg2)
181181
}
182182
if (PickedTrainFromList != null && (PickedTrainFromList == Viewer.SelectedTrain || (PickedTrainFromList.TrainType == Train.TRAINTYPE.AI_INCORPORATED &&
183183
(PickedTrainFromList as AITrain).IncorporatingTrain.IsPathless && (PickedTrainFromList as AITrain).IncorporatingTrain == Viewer.SelectedTrain)) && !PickedTrainFromList.IsActualPlayerTrain &&
184-
Viewer.Simulator.IsAutopilotMode && PickedTrainFromList.IsPlayable && !Viewer.Simulator.TimetableMode)
184+
Viewer.Simulator.IsAutopilotMode && PickedTrainFromList.IsPlayable && !(Viewer.Simulator.TimetableMode && (Viewer.PlayerTrain as AITrain).MovementState == AITrain.AI_MOVEMENT_STATE.AI_STATIC))
185185
{
186186
if (UserInput.IsDown(UserCommand.GameSuspendOldPlayer) && !Viewer.Simulator.TimetableMode)
187187
Viewer.Simulator.TrainSwitcher.SuspendOldPlayer = true;

Source/RunActivity/Viewer3D/Processes/GameStateRunActivity.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,7 @@ void InitSimulator(UserSettings settings, string[] args, string mode, string act
11291129
// for resume and replay : set timetable file and selected train info
11301130
Simulator.TimetableFileName = System.IO.Path.GetFileNameWithoutExtension(args[0]);
11311131
Simulator.PathName = args[1];
1132+
Simulator.IsAutopilotMode = true;
11321133
}
11331134
break;
11341135
}

0 commit comments

Comments
 (0)