Skip to content

Commit 2673493

Browse files
committed
Automatic merge of T1.5.1-1188-gd2c2ab5d66 and 16 pull requests
- Pull request #959 at 2452cb0: Fix TrackViewer crash on big zoom value - Pull request #972 at e90a2aa: On Map window color changed switch or signal is not changed - 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 #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 53e9cc6: Multiple Track Profiles & Superelevation Improvements - Pull request #962 at 46d0472: Fix pantographs on unpowered cars - Pull request #970 at 6fa5eed: feat: Remove unnecessary Windows.Forms usage - Pull request #973 at c35be87: fix: Using singular target framework to allow for different platforms across different projects - Pull request #974 at 5faea6f: Bug fix for https://bugs.launchpad.net/or/+bug/2076034 Doors remain open in AI trains - Pull request #978 at 91f3ee8: fix: adds MilepostUnitsMiles to Manual - Pull request #900 at c27f32d: DMI updates - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder
18 parents e11b601 + d2c2ab5 + 2452cb0 + e90a2aa + dfc715e + d00beb9 + 9a1d6b2 + 1f5ba4c + 8347095 + a519452 + 53e9cc6 + 46d0472 + 6fa5eed + c35be87 + 5faea6f + 91f3ee8 + c27f32d + f92de76 commit 2673493

File tree

25 files changed

+921
-580
lines changed

25 files changed

+921
-580
lines changed

Source/Menu/Options.Designer.cs

Lines changed: 73 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Menu/Options.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ public OptionsForm(UserSettings settings, UpdateManager updateManager, bool init
165165
comboPressureUnit.Text = Settings.PressureUnit;
166166
comboOtherUnits.Text = settings.Units;
167167
checkEnableTCSScripts.Checked = !Settings.DisableTCSScripts; // Inverted as "Enable scripts" is better UI than "Disable scripts"
168+
checkAutoSaveActive.Checked = Settings.AutoSaveActive;
169+
ButtonAutoSave15.Checked = checkAutoSaveActive.Checked & Settings.AutoSaveInterval == 15;
170+
ButtonAutoSave30.Checked = checkAutoSaveActive.Checked & Settings.AutoSaveInterval == 30;
171+
ButtonAutoSave60.Checked = checkAutoSaveActive.Checked & Settings.AutoSaveInterval == 60;
168172

169173
// Audio tab
170174
numericSoundVolumePercent.Value = Settings.SoundVolumePercent;
@@ -456,6 +460,8 @@ void buttonOK_Click(object sender, EventArgs e)
456460
Settings.PressureUnit = comboPressureUnit.SelectedValue.ToString();
457461
Settings.Units = comboOtherUnits.SelectedValue.ToString();
458462
Settings.DisableTCSScripts = !checkEnableTCSScripts.Checked; // Inverted as "Enable scripts" is better UI than "Disable scripts"
463+
Settings.AutoSaveActive = checkAutoSaveActive.Checked;
464+
Settings.AutoSaveInterval = ButtonAutoSave15.Checked ? 15 : ButtonAutoSave30.Checked ? 30 : 60;
459465

460466
// Audio tab
461467
Settings.SoundVolumePercent = (int)numericSoundVolumePercent.Value;
@@ -807,6 +813,50 @@ private void checkPerformanceTuner_Click(object sender, EventArgs e)
807813
labelPerformanceTunerTarget.Enabled = checkPerformanceTuner.Checked;
808814
}
809815

816+
private void checkAutoSave_checkchanged(object sender, EventArgs e)
817+
{
818+
if (checkAutoSaveActive.Checked)
819+
{
820+
ButtonAutoSave15.Enabled = true;
821+
ButtonAutoSave15.Checked = Settings.AutoSaveInterval == 15;
822+
ButtonAutoSave30.Enabled = true;
823+
ButtonAutoSave30.Checked = Settings.AutoSaveInterval == 30;
824+
ButtonAutoSave60.Enabled = true;
825+
ButtonAutoSave60.Checked = Settings.AutoSaveInterval == 60;
826+
}
827+
else
828+
{
829+
ButtonAutoSave15.Checked = false;
830+
ButtonAutoSave15.Enabled = false;
831+
ButtonAutoSave30.Checked = false;
832+
ButtonAutoSave30.Enabled = false;
833+
ButtonAutoSave60.Checked = false;
834+
ButtonAutoSave60.Enabled = false;
835+
}
836+
}
837+
838+
private void buttonAutoSaveInterval_checkchanged(object sender, EventArgs e)
839+
{
840+
if (ButtonAutoSave15.Checked)
841+
{
842+
Settings.AutoSaveInterval = 15;
843+
ButtonAutoSave30.Checked = false;
844+
ButtonAutoSave60.Checked = false;
845+
}
846+
else if (ButtonAutoSave30.Checked)
847+
{
848+
Settings.AutoSaveInterval = 30;
849+
ButtonAutoSave15.Checked = false;
850+
ButtonAutoSave60.Checked = false;
851+
}
852+
else if (ButtonAutoSave60.Checked)
853+
{
854+
Settings.AutoSaveInterval = 60;
855+
ButtonAutoSave15.Checked = false;
856+
ButtonAutoSave30.Checked = false;
857+
}
858+
}
859+
810860
#region Help for Options
811861
// The icons all share the same code which assumes they are named according to a simple scheme as follows:
812862
// 1. To add a new Help Icon, copy an existing one and paste it onto the tab.

Source/ORTS.Common/Conversions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ public static class FormatStrings
576576
public static string kN = Catalog.GetString("kN");
577577
public static string lbf = Catalog.GetString("lbf");
578578
public static string klbf = Catalog.GetString("klbf");
579+
public static string deg = Catalog.GetString("°");
579580

580581
/// <summary>
581582
/// Formatted unlocalized speed string, used in reports and logs.
@@ -845,6 +846,11 @@ public static string FormatAirFlow(float flowM3pS, bool isMetric)
845846
return String.Format(CultureInfo.CurrentCulture, "{0:F0} {1}", flow, isMetric ? lps : cfm);
846847
}
847848

849+
public static string FormatAngleDeg(float angleDeg)
850+
{
851+
return String.Format(CultureInfo.CurrentCulture, "{0:F0} {1}", angleDeg, deg);
852+
}
853+
848854
/// <summary>
849855
/// Converts duration in floating-point seconds to whole hours, minutes and seconds (rounded down).
850856
/// </summary>

Source/ORTS.Settings/UserSettings.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ public enum DirectXFeature
168168
public String Units { get; set; }
169169
[Default(false)]
170170
public bool DisableTCSScripts { get; set; }
171+
[Default(false)]
172+
public bool AutoSaveActive { get; set; }
173+
[Default (15)]
174+
public int AutoSaveInterval { get; set; }
171175

172176
// Audio settings:
173177
[Default(100)]
@@ -312,12 +316,6 @@ public enum DirectXFeature
312316
public bool AdhesionProportionalToWeather { get; set; }
313317
[Default(false)]
314318
public bool NoForcedRedAtStationStops { get; set; }
315-
[Default(100)]
316-
public int PrecipitationBoxHeight { get; set; }
317-
[Default(500)]
318-
public int PrecipitationBoxWidth { get; set; }
319-
[Default(500)]
320-
public int PrecipitationBoxLength { get; set; }
321319
[Default(false)]
322320
public bool CorrectQuestionableBrakingParams { get; set; }
323321
[Default(false)]

Source/Orts.Simulation/Simulation/AIs/AITrain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ public void AIUpdate(float elapsedClockSeconds, double clockTime, bool preUpdate
710710

711711
if (Cars[0] is MSTSLocomotive leadingLoco)
712712
{
713-
var isRainingOrSnowing = Simulator.Weather.PricipitationIntensityPPSPM2 > 0;
713+
var isRainingOrSnowing = Simulator.Weather.PrecipitationIntensityPPSPM2 > 0;
714714
if (leadingLoco.Wiper && !isRainingOrSnowing)
715715
leadingLoco.SignalEvent(Event.WiperOff);
716716
else if (!leadingLoco.Wiper && isRainingOrSnowing)

Source/Orts.Simulation/Simulation/Physics/Train.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,14 +2205,14 @@ public virtual void physicsUpdate(float elapsedClockSeconds)
22052205
public void UpdateWindComponents()
22062206
{
22072207
// Gets wind direction and speed, and determines HUD display values for the train as a whole.
2208-
//These will be representative of the train whilst it is on a straight track, but each wagon will vary when going around a curve.
2208+
// These will be representative of the train whilst it is on a straight track, but each wagon will vary when going around a curve.
22092209
// 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
22102210
// Wind and train direction to be converted to an angle between 0 and 360 deg.
22112211
// Calculate Wind speed and direction, and train direction
22122212
// Update the value of the Wind Speed and Direction for the train
2213-
PhysicsWindDirectionDeg = MathHelper.ToDegrees(Simulator.Weather.WindDirection);
2214-
PhysicsWindSpeedMpS = Simulator.Weather.WindSpeed;
2215-
float TrainSpeedMpS = Math.Abs(SpeedMpS);
2213+
PhysicsWindDirectionDeg = MathHelper.ToDegrees(Simulator.Weather.WindInstantaneousDirectionRad);
2214+
PhysicsWindSpeedMpS = Simulator.Weather.WindInstantaneousSpeedMpS;
2215+
var speedMpS = Math.Abs(SpeedMpS);
22162216

22172217
// If a westerly direction (ie -ve) convert to an angle between 0 and 360
22182218
if (PhysicsWindDirectionDeg < 0)
@@ -2221,7 +2221,7 @@ public void UpdateWindComponents()
22212221
if (PhysicsTrainLocoDirectionDeg < 0)
22222222
PhysicsTrainLocoDirectionDeg += 360;
22232223

2224-
// calculate angle between train and eind direction
2224+
// Calculate angle between train and wind direction
22252225
if (PhysicsWindDirectionDeg > PhysicsTrainLocoDirectionDeg)
22262226
ResultantWindComponentDeg = PhysicsWindDirectionDeg - PhysicsTrainLocoDirectionDeg;
22272227
else if (PhysicsTrainLocoDirectionDeg > PhysicsWindDirectionDeg)
@@ -2237,9 +2237,8 @@ public void UpdateWindComponents()
22372237
if (ResultantWindComponentDeg > 180)
22382238
ResultantWindComponentDeg = 360 - ResultantWindComponentDeg;
22392239

2240-
float WindAngleRad = MathHelper.ToRadians(ResultantWindComponentDeg);
2241-
2242-
WindResultantSpeedMpS = (float)Math.Sqrt(TrainSpeedMpS * TrainSpeedMpS + PhysicsWindSpeedMpS * PhysicsWindSpeedMpS + 2.0f * TrainSpeedMpS * PhysicsWindSpeedMpS * (float)Math.Cos(WindAngleRad));
2240+
var windAngleRad = MathHelper.ToRadians(ResultantWindComponentDeg);
2241+
WindResultantSpeedMpS = (float)Math.Sqrt(speedMpS * speedMpS + PhysicsWindSpeedMpS * PhysicsWindSpeedMpS + 2.0f * speedMpS * PhysicsWindSpeedMpS * (float)Math.Cos(windAngleRad));
22432242
}
22442243

22452244

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,7 +3263,7 @@ public virtual void UpdateFrictionCoefficient(float elapsedClockSeconds)
32633263
{
32643264
var fogBaseFrictionCoefficientFactor = 1.0f;
32653265
var pricBaseFrictionCoefficientFactor = 1.0f;
3266-
float pric = Simulator.Weather.PricipitationIntensityPPSPM2 * 1000;
3266+
float pric = Simulator.Weather.PrecipitationIntensityPPSPM2 * 1000;
32673267
// precipitation will calculate a base coefficient value between 60% (light rain) and 90% (heavy rain) - this will be a factor that is used to adjust the base value
32683268
// assume linear value between upper and lower precipitation values. Limits are set in the weather module, ie Rain = 0.01ppm (10) and Snow = 0.005ppm (5)
32693269
float precGrad = (0.2f - 0) / (10f - 5f);
@@ -3279,7 +3279,7 @@ public virtual void UpdateFrictionCoefficient(float elapsedClockSeconds)
32793279
}
32803280

32813281
// Adjust adhesion for impact of fog - default = 20000m = 20km
3282-
float fog = Simulator.Weather.FogDistance;
3282+
float fog = Simulator.Weather.VisibilityM;
32833283
if (fog < 20000) // as fog thickens then decrease adhesion
32843284
{
32853285
fogBaseFrictionCoefficientFactor = Math.Min((fog * 2.75e-4f + 0.6f), 1.0f); // If fog is less then 2km then it will impact friction, decrease adhesion to 60% (same as light rain transition)

0 commit comments

Comments
 (0)