Skip to content

Commit e0f3c55

Browse files
committed
Add access to a curve squeal sms file
1 parent d0208cd commit e0f3c55

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Source/Orts.Formats.Msts/SoundManagmentFile.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class SharedSMSFileManager
3636
public static int SwitchSMSNumber;
3737
public static int CurveSMSNumber;
3838
public static int CurveSwitchSMSNumber;
39+
public static int CurveSquealSMSNumber;
3940
public static bool AutoTrackSound = false;
4041

4142
public static SoundManagmentFile Get(string path)
@@ -198,7 +199,7 @@ public struct CurvePoint
198199

199200
public class VolumeCurve
200201
{
201-
public enum Controls { None, DistanceControlled, SpeedControlled, Variable1Controlled, Variable1_2Controlled, Variable1_3Controlled, Variable1_4Controlled, Variable2Controlled, Variable2BoosterControlled, Variable3Controlled, BrakeCylControlled, CurveForceControlled };
202+
public enum Controls { None, DistanceControlled, SpeedControlled, Variable1Controlled, Variable1_2Controlled, Variable1_3Controlled, Variable1_4Controlled, Variable2Controlled, Variable2BoosterControlled, Variable3Controlled, BrakeCylControlled, CurveForceControlled, AngleofAttackControlled, CarFrictionControlled };
202203

203204
public Controls Control = Controls.None;
204205
public float Granularity = 1.0f;
@@ -222,6 +223,8 @@ public VolumeCurve(STFReader stf)
222223
case "variable3controlled": Control = Controls.Variable3Controlled; break;
223224
case "brakecylcontrolled": Control = Controls.BrakeCylControlled; break;
224225
case "curveforcecontrolled": Control = Controls.CurveForceControlled; break;
226+
case "angleofattackcontrolled": Control = Controls.AngleofAttackControlled; break;
227+
case "carfrictioncontrolled": Control = Controls.CarFrictionControlled; break;
225228
default: STFException.TraceWarning(stf, "Crash expected: Skipped unknown VolumeCurve/Frequencycurve type " + type); stf.SkipRestOfBlock(); return;
226229
}
227230
stf.ParseBlock(new STFReader.TokenProcessor[] {

Source/RunActivity/Viewer3D/Sound.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,14 @@ public bool UpdateCarOnSwitchAndCurve()
424424
// here check for curve
425425
var carPreviouslyOnCurve = CarOnCurve;
426426
CarOnCurve = false;
427-
if ((Car.CurrentCurveRadiusM > 0 && (Car.CurrentCurveRadiusM < 301
427+
428+
// Uses newer AoA approach
429+
if (SharedSMSFileManager.CurveSquealSMSNumber != -1 && Car.CurrentCurveRadiusM > 0)
430+
{
431+
CarOnCurve = true;
432+
}
433+
// Uses original curve sound system
434+
else if (SharedSMSFileManager.CurveSwitchSMSNumber != -1 && (Car.CurrentCurveRadiusM > 0 && (Car.CurrentCurveRadiusM < 301
428435
|| (Car.CurrentCurveRadiusM < 350 && Car.WagonType == TrainCar.WagonTypes.Freight))) ||
429436
(CarBehind.CurrentCurveRadiusM > 0 && (CarBehind.CurrentCurveRadiusM < 301
430437
|| (CarBehind.CurrentCurveRadiusM < 350 && Car.WagonType == TrainCar.WagonTypes.Freight))))
@@ -444,6 +451,12 @@ public bool UpdateCarOnSwitchAndCurve()
444451
{
445452
_curTType = SharedSMSFileManager.CurveSwitchSMSNumber;
446453
}
454+
// newer curve squeal sounds
455+
else if (CarOnCurve && SharedSMSFileManager.CurveSquealSMSNumber != -1)
456+
{
457+
_curTType = SharedSMSFileManager.CurveSquealSMSNumber;
458+
}
459+
// original curve squeal
447460
else if (CarOnCurve && SharedSMSFileManager.CurveSMSNumber != -1)
448461
{
449462
_curTType = SharedSMSFileManager.CurveSMSNumber;
@@ -1502,6 +1515,8 @@ private float ReadValue(Orts.Formats.Msts.VolumeCurve.Controls control, MSTSWago
15021515
case Orts.Formats.Msts.VolumeCurve.Controls.Variable3Controlled: return car.Variable3;
15031516
case Orts.Formats.Msts.VolumeCurve.Controls.BrakeCylControlled: return car.BrakeSystem.GetCylPressurePSI();
15041517
case Orts.Formats.Msts.VolumeCurve.Controls.CurveForceControlled: return car.CurveForceNFiltered;
1518+
case Orts.Formats.Msts.VolumeCurve.Controls.AngleofAttackControlled: return car.AngleOfAttackmRad;
1519+
case Orts.Formats.Msts.VolumeCurve.Controls.CarFrictionControlled: return car.Train.WagonCoefficientFriction;
15051520
default: return 0;
15061521
}
15071522
}

Source/RunActivity/Viewer3D/Viewer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,14 @@ public void InitializeAutomaticTrackSounds()
611611
}
612612
if (SharedSMSFileManager.CurveSMSNumber != -1) SharedSMSFileManager.AutoTrackSound = true;
613613

614+
SharedSMSFileManager.CurveSquealSMSNumber = Simulator.TRK.Tr_RouteFile.CurveSquealSMSNumber;
615+
if (SharedSMSFileManager.CurveSquealSMSNumber < -1 || SharedSMSFileManager.CurveSquealSMSNumber >= TrackTypes.Count)
616+
{
617+
SharedSMSFileManager.CurveSquealSMSNumber = -1;
618+
Trace.TraceInformation("Curve Squeal SMS Number out of range");
619+
}
620+
if (SharedSMSFileManager.CurveSMSNumber != -1) SharedSMSFileManager.AutoTrackSound = true;
621+
614622
SharedSMSFileManager.CurveSwitchSMSNumber = Simulator.TRK.Tr_RouteFile.CurveSwitchSMSNumber;
615623
if (SharedSMSFileManager.CurveSwitchSMSNumber < -1 || SharedSMSFileManager.CurveSwitchSMSNumber >= TrackTypes.Count)
616624
{

0 commit comments

Comments
 (0)