Skip to content

Commit 853d507

Browse files
committed
Automatic merge of T1.6-145-g7915033ac and 11 pull requests
- Pull request #1082 at ebf0879: Allow variable water level in glass gauge - Pull request #570 at 1b6b22e: glTF 2.0 support with PBR lighting - Pull request #1091 at 492795a: Automatic speed control - Pull request #1122 at 73c47b4: Wagon Size and Centering Controls - Pull request #1124 at e241a0d: Built-in PBL2 brake controller - Pull request #1130 at 0f4342d: Fix F9 points to an incorrect car ID. - Pull request #1157 at 39cd994: Dynamic brake authorization by TCS - Pull request #1167 at 115325f: Fix: RunActivity slow to terminate because of long sleep in Host Process - Pull request #1168 at 6e2942f: Fix exception when exiting with MapForm or SoundDebugForm open. - Pull request #1169 at 6cf8c3e: Better Handling of Wagons with Invalid Bogie Configuration - Pull request #1171 at 8fd2066: no internet connection is available, not possible to open the Menu Content Form
13 parents 4cf7024 + 7915033 + ebf0879 + 1b6b22e + 492795a + 73c47b4 + e241a0d + 0f4342d + 39cd994 + 115325f + 6e2942f + 6cf8c3e + 8fd2066 commit 853d507

File tree

13 files changed

+524
-372
lines changed

13 files changed

+524
-372
lines changed

Source/Orts.Simulation/Common/Scripting/PowerSupply/ControlCarPowerSupply.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ protected override void SetCurrentMainPowerSupplyState(PowerSupplyState state) {
4949
protected override void SetCurrentAuxiliaryPowerSupplyState(PowerSupplyState state) {}
5050
protected override void SetCurrentElectricTrainSupplyState(PowerSupplyState state) {}
5151
protected override void SetCurrentDynamicBrakeAvailability(bool avail) {}
52-
public override PowerSupplyState GetPowerStatus() => PowerSupplyState.Unavailable;
5352
public void SignalEventToControlActiveLocomotive(PowerSupplyEvent evt)
5453
{
5554
ControlActiveLocomotive?.LocomotivePowerSupply.HandleEvent(evt);

Source/Orts.Simulation/Common/Scripting/PowerSupply/DieselPowerSupply.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,7 @@ public float DieselEngineMinRpm
9090
/// Closing authorization of the traction cut-off relay
9191
/// </summary>
9292
public bool TractionCutOffRelayClosingAuthorization() => TractionCutOffRelay.ClosingAuthorization;
93-
94-
public override PowerSupplyState GetPowerStatus()
95-
{
96-
var status = base.GetPowerStatus();
97-
PowerSupplyState engineStatus;
98-
switch (CurrentDieselEnginesState())
99-
{
100-
case DieselEngineState.Running:
101-
engineStatus = PowerSupplyState.PowerOn;
102-
break;
103-
case DieselEngineState.Starting:
104-
engineStatus = PowerSupplyState.PowerOnOngoing;
105-
break;
106-
default:
107-
engineStatus = PowerSupplyState.PowerOff;
108-
break;
109-
}
110-
if (status == engineStatus) return status;
111-
return PowerSupplyState.PowerOnOngoing;
112-
}
113-
93+
11494
/// <summary>
11595
/// Sends an event to all diesel engines
11696
/// </summary>

Source/Orts.Simulation/Common/Scripting/PowerSupply/ElectricPowerSupply.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -128,34 +128,6 @@ protected float PantographVoltageVDC
128128
/// </summary>
129129
protected void SetFilterVoltageV(float voltage) => EpsHost.FilterVoltageV = voltage;
130130

131-
public override PowerSupplyState GetPowerStatus()
132-
{
133-
var status = base.GetPowerStatus();
134-
PowerSupplyState electricStatus;
135-
switch (CurrentPantographState())
136-
{
137-
case PantographState.Up:
138-
switch (CurrentCircuitBreakerState())
139-
{
140-
case CircuitBreakerState.Closed:
141-
electricStatus = PowerSupplyState.PowerOn;
142-
break;
143-
default:
144-
electricStatus = PowerSupplyState.PowerOnOngoing;
145-
break;
146-
}
147-
break;
148-
case PantographState.Raising:
149-
electricStatus = PowerSupplyState.PowerOnOngoing;
150-
break;
151-
default:
152-
electricStatus = PowerSupplyState.PowerOff;
153-
break;
154-
}
155-
if (status == electricStatus) return status;
156-
return PowerSupplyState.PowerOnOngoing;
157-
}
158-
159131
/// <summary>
160132
/// Sends an event to the circuit breaker
161133
/// </summary>

Source/Orts.Simulation/Common/Scripting/PowerSupply/LocomotivePowerSupply.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,20 +293,6 @@ protected void SetCustomizedCabviewControlName(int index, string name)
293293
/// </summary>
294294
protected virtual void SetCurrentDynamicBrakeAvailability(bool avail) => LpsHost.DynamicBrakeAvailable = avail;
295295

296-
/// <summary>
297-
/// Called by other subsystems to determine whether the locomotive is powered
298-
/// </summary>
299-
/// <returns>
300-
/// PowerSupplyState.PowerOff if the locomotive is unpowered
301-
/// PowerSupplyState.PowerOnOngoing if the locomotive is in a power on sequence, but not all subsystems are ready
302-
/// PowerSupplyState.PowerOn if the locomotive is ready for service (all necessary subystems are connected)
303-
/// </returns>
304-
public virtual PowerSupplyState GetPowerStatus()
305-
{
306-
if (LpsHost.MainPowerSupplyState == LpsHost.AuxiliaryPowerSupplyState) return LpsHost.MainPowerSupplyState;
307-
return PowerSupplyState.PowerOnOngoing;
308-
}
309-
310296
/// <summary>
311297
/// Sends an event to the master switch
312298
/// </summary>

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/ILocomotivePowerSupply.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ public interface ILocomotivePowerSupply : IPowerSupply
4747
bool ServiceRetentionCancellationButton { get; set; }
4848
bool ServiceRetentionActive { get; set; }
4949

50-
PowerSupplyState GetPowerStatus();
51-
5250
void HandleEventFromTcs(PowerSupplyEvent evt);
5351
void HandleEventFromTcs(PowerSupplyEvent evt, int id);
5452
void HandleEventFromTcs(PowerSupplyEvent evt, string message);

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/PowerSupplies/LocomotivePowerSupply.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ public virtual void Update(float elapsedClockSeconds)
266266
ElectricTrainSupplySwitch.Update(elapsedClockSeconds);
267267
}
268268

269-
public PowerSupplyState GetPowerStatus() => AbstractScript?.GetPowerStatus() ?? PowerSupplyState.Unavailable;
270-
271269
public void HandleEvent(PowerSupplyEvent evt)
272270
{
273271
AbstractScript?.HandleEvent(evt);

Source/Orts.Simulation/Simulation/Simulator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1840,14 +1840,15 @@ public void UncoupleBehind(TrainCar car, bool keepFront)
18401840
train.activityClearingDistanceM = train.Cars.Count < Train.standardTrainMinCarNo ? Train.shortClearingDistanceM : Train.standardClearingDistanceM;
18411841
train2.activityClearingDistanceM = train2.Cars.Count < Train.standardTrainMinCarNo ? Train.shortClearingDistanceM : Train.standardClearingDistanceM;
18421842

1843-
18441843
train.UncoupledFrom = train2;
18451844
train2.UncoupledFrom = train;
18461845

18471846
train2.SpeedMpS = train.SpeedMpS;
18481847

1848+
train.Cars[0].BrakeSystem.FrontBrakeHoseConnected = false;
18491849
train.Cars[train.Cars.Count - 1].BrakeSystem.RearBrakeHoseConnected = false;
18501850
train2.Cars[0].BrakeSystem.FrontBrakeHoseConnected = false;
1851+
train2.Cars[train2.Cars.Count - 1].BrakeSystem.RearBrakeHoseConnected = false;
18511852

18521853
train2.AITrainDirectionForward = train.AITrainDirectionForward;
18531854

-8.01 KB
Loading

Source/RunActivity/Viewer3D/Cameras.cs

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using Orts.Simulation.Physics;
3030
using Orts.Simulation.RollingStocks;
3131
using Orts.Simulation.Signalling;
32+
using Orts.Viewer3D;
3233
using Orts.Viewer3D.Popups;
3334
using ORTS.Common;
3435
using ORTS.Common.Input;
@@ -1016,6 +1017,14 @@ public enum AttachedTo { Front, Rear }
10161017
protected float HighWagonOffsetLimit;
10171018
public int oldCarPosition;
10181019
public bool IsCameraFront;
1020+
public bool IsVisibleTrainCarViewerOrWebpage;
1021+
public bool IsVisibleTrainCarWebPage;
1022+
public bool IsDownCameraOutsideFront;
1023+
public bool IsDownCameraOutsideRear;
1024+
public UserCommand? CameraCommand;
1025+
private static UserCommand? GetPressedKey(params UserCommand[] keysToTest) => keysToTest
1026+
.Where((UserCommand key) => UserInput.IsDown(key))
1027+
.FirstOrDefault();
10191028
public override bool IsUnderground
10201029
{
10211030
get
@@ -1096,30 +1105,64 @@ protected override void OnActivate(bool sameCamera)
10961105
var isDownCameraOutsideFront = UserInput.IsDown(UserCommand.CameraOutsideFront);
10971106
var isDownCameraOutsideRear = UserInput.IsDown(UserCommand.CameraOutsideRear);
10981107

1099-
bool isVisibleTrainCarViewerOrWebpage;
11001108
if (Viewer.TrainCarOperationsWebpage == null)
11011109
{
11021110
// when starting Open Rails by means of a restore Viewer.TrainCarOperationsWebpage not yet available
1103-
isVisibleTrainCarViewerOrWebpage = Viewer.TrainCarOperationsViewerWindow.Visible;
1111+
IsVisibleTrainCarViewerOrWebpage = Viewer.TrainCarOperationsViewerWindow.Visible;
11041112
}
11051113
else
11061114
{
1107-
isVisibleTrainCarViewerOrWebpage = (Viewer.TrainCarOperationsWindow.Visible && !Viewer.TrainCarOperationsViewerWindow.Visible) || Viewer.TrainCarOperationsViewerWindow.Visible || (Viewer.TrainCarOperationsWebpage?.Connections > 0 && Viewer.TrainCarOperationsWebpage.TrainCarSelected);
1115+
IsVisibleTrainCarViewerOrWebpage = (Viewer.TrainCarOperationsWindow.Visible && !Viewer.TrainCarOperationsViewerWindow.Visible) || Viewer.TrainCarOperationsViewerWindow.Visible || (Viewer.TrainCarOperationsWebpage?.Connections > 0 && Viewer.TrainCarOperationsWebpage.TrainCarSelected);
11081116
}
11091117

1118+
if (IsVisibleTrainCarViewerOrWebpage)
1119+
{
11101120
// Update the camera view
11111121
oldCarPosition = oldCarPosition == 0 && carPosition == 0 ? -1 : oldCarPosition;
1122+
}
1123+
1124+
if (attachedCar != null && !IsVisibleTrainCarViewerOrWebpage)
1125+
{ // Reset behaviour of camera 2 and camera 3, after closing F9-window and F9-web.
1126+
var attachedCarPosition = Front ? Viewer.CameraOutsideFrontPosition : Viewer.CameraOutsideRearPosition;
1127+
1128+
Viewer.FirstLoop = false;
1129+
if (Front)
1130+
{
1131+
SetCameraCar(trainCars[Viewer.CameraOutsideFrontPosition]);
1132+
Viewer.CameraFrontUpdated = true;
1133+
}
1134+
else
1135+
{
1136+
if (Viewer.CameraOutsideRearPosition == 0)
1137+
{
1138+
SetCameraCar(GetCameraCars().Last());
1139+
}
1140+
else
1141+
{
1142+
if (Viewer.CameraOutsideRearPosition < trainCars.Count)
1143+
{
1144+
SetCameraCar(trainCars[Viewer.CameraOutsideRearPosition]);
1145+
}
1146+
else
1147+
{
1148+
SetCameraCar(trainCars[trainCars.Count - 1]);
1149+
}
1150+
}
1151+
Viewer.CameraRearUpdated = true;
1152+
}
1153+
Viewer.IsCameraPositionUpdated = Viewer.CameraFrontUpdated && Viewer.CameraRearUpdated;
1154+
}
11121155

11131156
if (attachedCar == null || attachedCar.Train != Viewer.SelectedTrain || carPosition != oldCarPosition)
11141157
{
11151158
if (Front)
11161159
{
1117-
if (!isVisibleTrainCarViewerOrWebpage && isDownCameraOutsideFront)
1160+
if (!IsVisibleTrainCarViewerOrWebpage && isDownCameraOutsideFront)
11181161
{
1119-
SetCameraCar(GetCameraCars().First());
1162+
if (Viewer.CameraOutsideFrontPosition == 0) SetCameraCar(GetCameraCars().First());
11201163
oldCarPosition = 0;
11211164
}
1122-
else if (isVisibleTrainCarViewerOrWebpage && carPosition >= 0)
1165+
else if (IsVisibleTrainCarViewerOrWebpage && carPosition >= 0)
11231166
{
11241167
if (carPosition < trainCars.Count)
11251168
{
@@ -1138,12 +1181,12 @@ protected override void OnActivate(bool sameCamera)
11381181
}
11391182
else
11401183
{
1141-
if (!isVisibleTrainCarViewerOrWebpage && isDownCameraOutsideRear)
1184+
if (!IsVisibleTrainCarViewerOrWebpage && isDownCameraOutsideRear)
11421185
{
1143-
SetCameraCar(GetCameraCars().Last());
1186+
if (Viewer.CameraOutsideRearPosition == 0) SetCameraCar(GetCameraCars().Last());
11441187
oldCarPosition = 0;
11451188
}
1146-
else if (carPosition < trainCars.Count && isVisibleTrainCarViewerOrWebpage && carPosition >= 0)
1189+
else if (carPosition < trainCars.Count && IsVisibleTrainCarViewerOrWebpage && carPosition >= 0)
11471190
{
11481191
SetCameraCar(trainCars[carPosition]);
11491192
oldCarPosition = carPosition;
@@ -1159,6 +1202,24 @@ protected override void OnActivate(bool sameCamera)
11591202
BrowseDistance = attachedCar.CarLengthM * 0.5f;
11601203
}
11611204
base.OnActivate(sameCamera);
1205+
CameraOutsidePosition();
1206+
}
1207+
1208+
public void CameraOutsidePosition()
1209+
{
1210+
if (!IsVisibleTrainCarViewerOrWebpage)
1211+
{
1212+
var attachedCarIdPos = attachedCar.Train.Cars.TakeWhile(x => x.CarID != attachedCar.CarID).Count();
1213+
if (Front)
1214+
{
1215+
Viewer.CameraOutsideFrontPosition = attachedCarIdPos;
1216+
}
1217+
else if (!Front)
1218+
{
1219+
Viewer.CameraOutsideRearPosition = attachedCarIdPos;
1220+
}
1221+
}
1222+
Viewer.IsCameraPositionUpdated = !IsVisibleTrainCarViewerOrWebpage;
11621223
}
11631224

11641225
protected override bool IsCameraFlipped()
@@ -1238,6 +1299,16 @@ public override void HandleUserInput(ElapsedTime elapsedTime)
12381299
new ToggleBrowseBackwardsCommand(Viewer.Log);
12391300
if (UserInput.IsPressed(UserCommand.CameraBrowseForwards))
12401301
new ToggleBrowseForwardsCommand(Viewer.Log);
1302+
1303+
UserCommand? CameraCommand = GetPressedKey(UserCommand.CameraCarPrevious, UserCommand.CameraCarNext,
1304+
UserCommand.CameraCarFirst, UserCommand.CameraCarLast);
1305+
1306+
if (CameraCommand == UserCommand.CameraCarPrevious || CameraCommand == UserCommand.CameraCarNext || CameraCommand == UserCommand.CameraCarFirst
1307+
|| CameraCommand == UserCommand.CameraCarLast)
1308+
{ // updates camera out side car position
1309+
CameraOutsidePosition();
1310+
Viewer.IsDownCameraChanged = IsDownCameraOutsideFront = IsDownCameraOutsideRear = false;
1311+
}
12411312
}
12421313

12431314
public override void Update(ElapsedTime elapsedTime)

0 commit comments

Comments
 (0)