@@ -1199,7 +1199,7 @@ public virtual void Save(BinaryWriter outf)
11991199 {
12001200 outf.Write(1);
12011201 EOT.Save(outf);
1202- }
1202+ }
12031203 else
12041204 outf.Write(-1);*/
12051205 }
@@ -1211,7 +1211,7 @@ private void SaveCars(BinaryWriter outf)
12111211 {
12121212 outf.Write(wagon.WagFilePath);
12131213 wagon.Save(outf);
1214- }
1214+ }
12151215 }
12161216
12171217 static void SaveTrafficSDefinition(BinaryWriter outf, Traffic_Service_Definition thisTSD)
@@ -2109,39 +2109,39 @@ public void UpdateWindComponents()
21092109 //These will be representative of the train whilst it is on a straight track, but each wagon will vary when going around a curve.
21102110 // Note both train and wind direction will be positive between 0 (north) and 180 (south) through east, and negative between 0 (north) and 180 (south) through west
21112111 // Wind and train direction to be converted to an angle between 0 and 360 deg.
2112- // Calculate Wind speed and direction, and train direction
2113- // Update the value of the Wind Speed and Direction for the train
2114- PhysicsWindDirectionDeg = MathHelper.ToDegrees(Simulator.Weather.WindDirection);
2115- PhysicsWindSpeedMpS = Simulator.Weather.WindSpeed;
2116- float TrainSpeedMpS = Math.Abs(SpeedMpS);
2117-
2118- // If a westerly direction (ie -ve) convert to an angle between 0 and 360
2119- if (PhysicsWindDirectionDeg < 0)
2120- PhysicsWindDirectionDeg += 360;
2121-
2122- if (PhysicsTrainLocoDirectionDeg < 0)
2123- PhysicsTrainLocoDirectionDeg += 360;
2124-
2125- // calculate angle between train and eind direction
2126- if (PhysicsWindDirectionDeg > PhysicsTrainLocoDirectionDeg)
2127- ResultantWindComponentDeg = PhysicsWindDirectionDeg - PhysicsTrainLocoDirectionDeg;
2128- else if (PhysicsTrainLocoDirectionDeg > PhysicsWindDirectionDeg)
2129- ResultantWindComponentDeg = PhysicsTrainLocoDirectionDeg - PhysicsWindDirectionDeg;
2130- else
2131- ResultantWindComponentDeg = 0.0f;
2112+ // Calculate Wind speed and direction, and train direction
2113+ // Update the value of the Wind Speed and Direction for the train
2114+ PhysicsWindDirectionDeg = MathHelper.ToDegrees(Simulator.Weather.WindDirection);
2115+ PhysicsWindSpeedMpS = Simulator.Weather.WindSpeed;
2116+ float TrainSpeedMpS = Math.Abs(SpeedMpS);
2117+
2118+ // If a westerly direction (ie -ve) convert to an angle between 0 and 360
2119+ if (PhysicsWindDirectionDeg < 0)
2120+ PhysicsWindDirectionDeg += 360;
2121+
2122+ if (PhysicsTrainLocoDirectionDeg < 0)
2123+ PhysicsTrainLocoDirectionDeg += 360;
2124+
2125+ // calculate angle between train and eind direction
2126+ if (PhysicsWindDirectionDeg > PhysicsTrainLocoDirectionDeg)
2127+ ResultantWindComponentDeg = PhysicsWindDirectionDeg - PhysicsTrainLocoDirectionDeg;
2128+ else if (PhysicsTrainLocoDirectionDeg > PhysicsWindDirectionDeg)
2129+ ResultantWindComponentDeg = PhysicsTrainLocoDirectionDeg - PhysicsWindDirectionDeg;
2130+ else
2131+ ResultantWindComponentDeg = 0.0f;
21322132
2133- // Correct wind direction if it is greater then 360 deg, then correct to a value less then 360
2134- if (Math.Abs(ResultantWindComponentDeg) > 360)
2135- ResultantWindComponentDeg = ResultantWindComponentDeg - 360.0f;
2133+ // Correct wind direction if it is greater then 360 deg, then correct to a value less then 360
2134+ if (Math.Abs(ResultantWindComponentDeg) > 360)
2135+ ResultantWindComponentDeg = ResultantWindComponentDeg - 360.0f;
21362136
2137- // Wind angle should be kept between 0 and 180 the formulas do not cope with angles > 180. If angle > 180, denotes wind of "other" side of train
2138- if (ResultantWindComponentDeg > 180)
2139- ResultantWindComponentDeg = 360 - ResultantWindComponentDeg;
2137+ // Wind angle should be kept between 0 and 180 the formulas do not cope with angles > 180. If angle > 180, denotes wind of "other" side of train
2138+ if (ResultantWindComponentDeg > 180)
2139+ ResultantWindComponentDeg = 360 - ResultantWindComponentDeg;
21402140
2141- float WindAngleRad = MathHelper.ToRadians(ResultantWindComponentDeg);
2141+ float WindAngleRad = MathHelper.ToRadians(ResultantWindComponentDeg);
21422142
2143- WindResultantSpeedMpS = (float)Math.Sqrt(TrainSpeedMpS * TrainSpeedMpS + PhysicsWindSpeedMpS * PhysicsWindSpeedMpS + 2.0f * TrainSpeedMpS * PhysicsWindSpeedMpS * (float)Math.Cos(WindAngleRad));
2144- }
2143+ WindResultantSpeedMpS = (float)Math.Sqrt(TrainSpeedMpS * TrainSpeedMpS + PhysicsWindSpeedMpS * PhysicsWindSpeedMpS + 2.0f * TrainSpeedMpS * PhysicsWindSpeedMpS * (float)Math.Cos(WindAngleRad));
2144+ }
21452145
21462146
21472147 //================================================================================================//
@@ -2884,8 +2884,10 @@ public void UpdateManual(float elapsedClockSeconds)
28842884
28852885 //the following is added by CSantucci, applying also to manual mode what Jtang implemented for activity mode: after passing a manually forced signal,
28862886 // system will take back control of the signal
2887- if (signalObject.holdState == SignalObject.HoldState.ManualPass ||
2888- signalObject.holdState == SignalObject.HoldState.ManualApproach) signalObject.holdState = SignalObject.HoldState.None;
2887+ if (signalObject.holdState == HoldState.ManualPass || signalObject.holdState == HoldState.ManualApproach)
2888+ {
2889+ signalObject.holdState = HoldState.None;
2890+ }
28892891 }
28902892 UpdateSectionStateManual(); // update track occupation //
28912893 UpdateManualMode(SignalObjIndex); // update route clearance //
@@ -2911,8 +2913,10 @@ public void UpdateExplorer(float elapsedClockSeconds)
29112913
29122914 //the following is added by CSantucci, applying also to explorer mode what Jtang implemented for activity mode: after passing a manually forced signal,
29132915 // system will take back control of the signal
2914- if (signalObject.holdState == SignalObject.HoldState.ManualPass ||
2915- signalObject.holdState == SignalObject.HoldState.ManualApproach) signalObject.holdState = SignalObject.HoldState.None;
2916+ if (signalObject.holdState == HoldState.ManualPass || signalObject.holdState == HoldState.ManualApproach)
2917+ {
2918+ signalObject.holdState = HoldState.None;
2919+ }
29162920 }
29172921 UpdateSectionStateExplorer(); // update track occupation //
29182922 UpdateExplorerMode(SignalObjIndex); // update route clearance //
@@ -7559,10 +7563,9 @@ public void UpdateRouteClearanceAhead(int signalObjectIndex, int backward, float
75597563 var signalObject = signalRef.SignalObjects[signalObjectIndex];
75607564
75617565 //the following is added by JTang, passing a hold signal, will take back control by the system
7562- if (signalObject.holdState == SignalObject.HoldState.ManualPass ||
7563- signalObject.holdState == SignalObject.HoldState.ManualApproach)
7566+ if (signalObject.holdState == HoldState.ManualPass || signalObject.holdState == HoldState.ManualApproach)
75647567 {
7565- signalObject.holdState = SignalObject. HoldState.None;
7568+ signalObject.holdState = HoldState.None;
75667569 }
75677570
75687571 signalObject.resetSignalEnabled();
@@ -7769,7 +7772,7 @@ public bool CheckTrainWaitingForSignal(SignalObject thisSignal, int direction)
77697772
77707773 if (signalRouteIndex < 0)
77717774 {
7772- return ( false) ;
7775+ return false;
77737776 }
77747777
77757778 // check if any other trains in section ahead of this train
@@ -7786,7 +7789,7 @@ public bool CheckTrainWaitingForSignal(SignalObject thisSignal, int direction)
77867789 // check if train is closer as signal
77877790 if (!DistanceToSignal.HasValue || foundTrain.Value < DistanceToSignal)
77887791 {
7789- return ( false) ;
7792+ return false;
77907793 }
77917794 }
77927795
@@ -7801,7 +7804,7 @@ public bool CheckTrainWaitingForSignal(SignalObject thisSignal, int direction)
78017804
78027805 if (nextSection.CircuitState.HasTrainsOccupying()) // train is ahead - it's not our signal //
78037806 {
7804- return ( false) ;
7807+ return false;
78057808 }
78067809 else if (!nextSection.IsAvailable(this)) // is section really available to us? //
78077810
@@ -7817,30 +7820,24 @@ public bool CheckTrainWaitingForSignal(SignalObject thisSignal, int direction)
78177820 }
78187821 SwitchToNodeControl(thisSection.Index);
78197822
7820- return ( false) ;
7823+ return false;
78217824 }
78227825 }
78237826 }
78247827
78257828 // we are waiting, but is signal clearance requested ?
7826-
78277829 if (thisSignal.enabledTrain == null)
78287830 {
78297831 thisSignal.requestClearSignal(ValidRoute[0], thisRouted, 0, false, null);
78307832 }
7831-
78327833 // we are waiting, but is it really our signal ?
7833-
78347834 else if (thisSignal.enabledTrain != thisRouted)
78357835 {
7836-
78377836 // something is wrong - we are waiting, but it is not our signal - give warning, reset signal and clear route
7838-
78397837 Trace.TraceWarning("Train {0} ({1}) waiting for signal which is enabled to train {2}",
78407838 Name, Number, thisSignal.enabledTrain.Train.Number);
78417839
78427840 // stop other train - switch other train to node control
7843-
78447841 Train otherTrain = thisSignal.enabledTrain.Train;
78457842 otherTrain.LastReservedSection[0] = -1;
78467843 if (Math.Abs(otherTrain.SpeedMpS) > 0)
@@ -7850,29 +7847,27 @@ public bool CheckTrainWaitingForSignal(SignalObject thisSignal, int direction)
78507847 otherTrain.SwitchToNodeControl(-1);
78517848
78527849 // reset signal and clear route
7853-
78547850 thisSignal.ResetSignal(false);
78557851 thisSignal.requestClearSignal(ValidRoute[0], thisRouted, 0, false, null);
7856- return ( false) ; // do not yet set to waiting, signal might clear //
7852+ return false; // do not yet set to waiting, signal might clear //
78577853 }
78587854
78597855 // signal is in holding list - so not really waiting - but remove from list if held for station stop
7860-
7861- if (thisSignal.holdState == SignalObject.HoldState.ManualLock)
7856+ if (thisSignal.holdState == HoldState.ManualLock)
78627857 {
7863- return ( false) ;
7858+ return false;
78647859 }
7865- else if (thisSignal.holdState == SignalObject. HoldState.StationStop && HoldingSignals.Contains(thisSignal.thisRef))
7860+ else if (thisSignal.holdState == HoldState.StationStop && HoldingSignals.Contains(thisSignal.thisRef))
78667861 {
78677862 if (StationStops != null && StationStops.Count > 0 && StationStops[0].ExitSignal != thisSignal.thisRef) // not present station stop
78687863 {
78697864 HoldingSignals.Remove(thisSignal.thisRef);
7870- thisSignal.holdState = SignalObject. HoldState.None;
7871- return ( false) ;
7865+ thisSignal.holdState = HoldState.None;
7866+ return false;
78727867 }
78737868 }
78747869
7875- return ( true) ; // it is our signal and we are waiting //
7870+ return true; // it is our signal and we are waiting //
78767871 }
78777872
78787873 //================================================================================================//
@@ -8057,8 +8052,10 @@ public void UpdateManualMode(int signalObjectIndex)
80578052 var thisSignal = signalRef.SignalObjects[signalObjectIndex];
80588053 thisSignal.hasPermission = SignalObject.Permission.Denied;
80598054 //the following is added by JTang, passing a hold signal, will take back control by the system
8060- if (thisSignal.holdState == SignalObject.HoldState.ManualPass ||
8061- thisSignal.holdState == SignalObject.HoldState.ManualApproach) thisSignal.holdState = SignalObject.HoldState.None;
8055+ if (thisSignal.holdState == HoldState.ManualPass || thisSignal.holdState == HoldState.ManualApproach)
8056+ {
8057+ thisSignal.holdState = HoldState.None;
8058+ }
80628059
80638060 thisSignal.resetSignalEnabled();
80648061 }
@@ -8574,7 +8571,7 @@ public void RequestManualSignalPermission(ref TCSubpathRoute selectedRoute, int
85748571
85758572 requestedSignal.enabledTrain = routeIndex == 0 ? routedForward : routedBackward;
85768573 requestedSignal.signalRoute.Clear();
8577- requestedSignal.holdState = SignalObject. HoldState.None;
8574+ requestedSignal.holdState = HoldState.None;
85788575 requestedSignal.hasPermission = SignalObject.Permission.Requested;
85798576
85808577 // get route from next signal - extend to next signal or maximum length
@@ -9238,7 +9235,7 @@ public void UpdateExplorerMode(int signalObjectIndex)
92389235 {
92399236 distanceToSignalForward += thisSection.Length - lengthOffset;
92409237 lengthOffset = 0;
9241- }
9238+ }
92429239 }
92439240
92449241 // backward
@@ -9255,7 +9252,7 @@ public void UpdateExplorerMode(int signalObjectIndex)
92559252 {
92569253 lengthOffset = -PresentPosition[1].TCOffset + signalRef.TrackCircuitList[PresentPosition[1].TCSectionIndex].Length;
92579254 presentIndex = iindex;
9258- }
9255+ }
92599256 if (presentIndex != -1 && presentIndex <= iindex)
92609257 {
92619258 distanceToSignalBackward += thisSection.Length - lengthOffset;
0 commit comments