Skip to content

Commit 9dc3f34

Browse files
committed
add company colour type enum for vehicles
1 parent 879ff4a commit 9dc3f34

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Dat/Objects/Vehicle/VehicleObject.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55

66
namespace OpenLoco.Dat.Objects
77
{
8+
public enum CompanyColourType : uint8_t
9+
{
10+
None = 0,
11+
SteamLoco = 1,
12+
DieselLoco = 2,
13+
ElectricLoco = 3,
14+
MultipleUnit = 4,
15+
PassengerRailcar = 5,
16+
FreightRailcar = 6,
17+
BusAndTram = 7,
18+
FreightTruck = 8,
19+
Airplane = 9,
20+
Ship = 10,
21+
}
22+
823
[TypeConverter(typeof(ExpandableObjectConverter))]
924
[LocoStructSize(0x15E)]
1025
[LocoStructType(ObjectType.Vehicle)]
@@ -21,7 +36,7 @@ public record VehicleObject(
2136
[property: LocoStructOffset(0x0A)] uint8_t Reliability,
2237
[property: LocoStructOffset(0x0B)] uint8_t RunCostIndex,
2338
[property: LocoStructOffset(0x0C)] int16_t RunCostFactor,
24-
[property: LocoStructOffset(0x0E)] uint8_t SpecialColourSchemeIndex, // this is an instance property and doesn't need to be saved in the definition as it can be calculated from other properties
39+
[property: LocoStructOffset(0x0E)] CompanyColourType SpecialColourSchemeIndex, // this is an instance property and doesn't need to be saved in the definition as it can be calculated from other properties
2540
[property: LocoStructOffset(0x0F)] uint8_t NumCompatibleVehicles,
2641
[property: LocoStructOffset(0x10), LocoArrayLength(8), LocoStructVariableLoad] List<S5Header> CompatibleVehicles,
2742
[property: LocoStructOffset(0x20), LocoArrayLength(4), LocoStructVariableLoad] List<S5Header> RequiredTrackExtras,

Gui/ViewModels/DatTypes/Objects/VehicleViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class VehicleViewModel : LocoObjectViewModel<VehicleObject>
3030
[Reactive, Category("Cost"), Range(0, int16_t.MaxValue)] public int16_t RunCostFactor { get; set; }
3131
[Reactive, Category("<unknown>")] public uint8_t var_04 { get; set; }
3232
[Reactive, Category("<unknown>")] public uint8_t var_113 { get; set; }
33-
[Reactive, Category("Sprites")] public uint8_t SpecialColourSchemeIndex { get; set; } // called "ColourType" in the loco codebase
33+
[Reactive, Category("Sprites")] public CompanyColourType SpecialColourSchemeIndex { get; set; } // called "ColourType" in the loco codebase
3434
[Reactive, Category("Sprites"), Editable(false)] public BindingList<VehicleObjectCar> CarComponents { get; set; }
3535
[Reactive, Category("Sprites"), Editable(false)] public BindingList<BodySprite> BodySprites { get; set; }
3636
[Reactive, Category("Sprites"), Editable(false)] public BindingList<BogieSprite> BogieSprites { get; set; }

Tests/LoadSaveTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ void assertFunc(ILocoObject obj, VehicleObject struc) => Assert.Multiple(() =>
10061006
Assert.That(struc.Reliability, Is.EqualTo(88), nameof(struc.Reliability));
10071007
Assert.That(struc.RunCostIndex, Is.EqualTo(4), nameof(struc.RunCostIndex));
10081008
Assert.That(struc.RunCostFactor, Is.EqualTo(55), nameof(struc.RunCostFactor));
1009-
Assert.That(struc.SpecialColourSchemeIndex, Is.EqualTo(9), nameof(struc.SpecialColourSchemeIndex));
1009+
Assert.That(struc.SpecialColourSchemeIndex, Is.EqualTo(CompanyColourType.Airplane), nameof(struc.SpecialColourSchemeIndex));
10101010
Assert.That(struc.NumCompatibleVehicles, Is.EqualTo(0), nameof(struc.NumCompatibleVehicles));
10111011
//CollectionAssert.AreEqual(Enumerable.Repeat(0, 8).ToArray(), struc.CompatibleVehicles, nameof(struc.CompatibleVehicles));
10121012
//CollectionAssert.AreEqual(Enumerable.Repeat(0, 4).ToArray(), struc.RequiredTrackExtras, nameof(struc.RequiredTrackExtras));

0 commit comments

Comments
 (0)