Skip to content

Commit 9cca367

Browse files
committed
update vehicle sound property names, fix bug saving acceleration base frequency
1 parent 14242c6 commit 9cca367

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

Dat/Objects/Vehicle/SimpleMotorSound.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public record SimpleMotorSound(
1313
[property: LocoStructOffset(0x04)] uint16_t CoastingFrequency,
1414
[property: LocoStructOffset(0x06)] uint8_t CoastingVolume,
1515
[property: LocoStructOffset(0x07)] uint16_t AccelerationBaseFrequency,
16-
[property: LocoStructOffset(0x08)] uint8_t AccelerationVolume,
16+
[property: LocoStructOffset(0x09)] uint8_t AccelerationVolume,
1717
[property: LocoStructOffset(0x0A)] uint16_t FreqIncreaseStep,
1818
[property: LocoStructOffset(0x0C)] uint16_t FreqDecreaseStep,
1919
[property: LocoStructOffset(0x0E)] uint8_t VolumeIncreaseStep,

Dat/Objects/Vehicle/VehicleObject.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,10 @@ public record VehicleObject(
6767
public VehicleObject() : this(0, TransportMode.Rail, VehicleType.Train, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, [], [], [], [], [], 0, 0, 0, 0, VehicleObjectFlags.None, [], [[], []], [], 0, [], 0, 0, 0, 0, DrivingSoundType.None, [], [], 0, [])
6868
{ }
6969

70-
//public static object? GetSoundAs(DrivingSoundType soundType, ReadOnlySpan<byte> soundPropertiesData)
71-
// => soundType switch
72-
// {
73-
// DrivingSoundType.None => default,
74-
// DrivingSoundType.Friction => ByteReader.ReadLocoStruct<FrictionSound>(soundPropertiesData[..ObjectAttributes.StructSize<FrictionSound>()]),
75-
// DrivingSoundType.Engine1 => ByteReader.ReadLocoStruct<Engine1Sound>(soundPropertiesData[..ObjectAttributes.StructSize<Engine1Sound>()]),
76-
// DrivingSoundType.Engine2 => ByteReader.ReadLocoStruct<Engine2Sound>(soundPropertiesData[..ObjectAttributes.StructSize<Engine2Sound>()]),
77-
// _ => throw new ArgumentOutOfRangeException()
78-
// };
79-
8070
public T GetSoundAs<T>() where T : ILocoStruct
8171
=> (T)ByteReader.ReadLocoStruct(SoundPropertiesData.AsSpan()[..ObjectAttributes.StructSize<T>()], typeof(T));
8272

83-
public FrictionSound? SoundPropertyFriction
73+
public FrictionSound? FrictionSound
8474
{
8575
get => DrivingSoundType == DrivingSoundType.Friction ? GetSoundAs<FrictionSound>() : null;
8676
set
@@ -92,7 +82,7 @@ public FrictionSound? SoundPropertyFriction
9282
}
9383
}
9484

95-
public SimpleMotorSound? SoundPropertyEngine1
85+
public SimpleMotorSound? SimpleMotorSound
9686
{
9787
get => DrivingSoundType == DrivingSoundType.SimpleMotor ? GetSoundAs<SimpleMotorSound>() : null;
9888
set
@@ -104,7 +94,7 @@ public SimpleMotorSound? SoundPropertyEngine1
10494
}
10595
}
10696

107-
public GearboxMotorSound? SoundPropertyEngine2
97+
public GearboxMotorSound? GearboxMotorSound
10898
{
10999
get => DrivingSoundType == DrivingSoundType.GearboxMotor ? GetSoundAs<GearboxMotorSound>() : null;
110100
set

Gui/ViewModels/DatTypes/Objects/VehicleViewModel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ public VehicleViewModel(VehicleObject vo)
8585
Sound = vo.Sound == null ? null : new(vo.Sound);
8686
StartSounds = new(vo.StartSounds.ConvertAll(x => new S5HeaderViewModel(x)));
8787
SoundType = vo.DrivingSoundType;
88-
FrictionSound = vo.SoundPropertyFriction;
89-
SimpleMotorSound = vo.SoundPropertyEngine1;
90-
GearboxMotorSound = vo.SoundPropertyEngine2;
88+
FrictionSound = vo.FrictionSound;
89+
SimpleMotorSound = vo.SimpleMotorSound;
90+
GearboxMotorSound = vo.GearboxMotorSound;
9191
}
9292

9393
public override VehicleObject GetAsStruct(VehicleObject vo)
@@ -124,9 +124,9 @@ public override VehicleObject GetAsStruct(VehicleObject vo)
124124
RequiredTrackExtras = RequiredTrackExtras.ToList().ConvertAll(x => x.GetAsUnderlyingType()),
125125
AnimationHeaders = AnimationHeaders.ToList().ConvertAll(x => x.GetAsUnderlyingType()),
126126
DrivingSoundType = SoundType,
127-
SoundPropertyFriction = FrictionSound,
128-
SoundPropertyEngine1 = SimpleMotorSound,
129-
SoundPropertyEngine2 = GearboxMotorSound,
127+
FrictionSound = FrictionSound,
128+
SimpleMotorSound = SimpleMotorSound,
129+
GearboxMotorSound = GearboxMotorSound,
130130
NumCompatibleVehicles = (uint8_t)CompatibleVehicles.Count,
131131
NumRequiredTrackExtras = (uint8_t)RequiredTrackExtras.Count,
132132
NumStartSounds = (uint8_t)StartSounds.Count,

0 commit comments

Comments
 (0)