Skip to content

Commit 9484f2d

Browse files
authored
Building object fields#27 (#28)
* remove spammy logging * update var_AD and var_AE fields * correct type for AnimationSequences
1 parent 86ced9e commit 9484f2d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Core/Objects/BuildingObject.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel;
1+
using System.ComponentModel;
22
using Core.Objects;
33
using OpenLoco.ObjectEditor.Data;
44
using OpenLoco.ObjectEditor.DatFileParsing;
@@ -38,15 +38,15 @@ public record BuildingObject(
3838
[property: LocoStructOffset(0x9D)] Colour ScaffoldingColour,
3939
[property: LocoStructOffset(0x9E)] uint8_t GeneratorFunction,
4040
[property: LocoStructOffset(0x9F)] uint8_t var_9F,
41-
//[property: LocoStructOffset(0xA0), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> ProducedQuantity,
42-
//[property: LocoStructOffset(0xA2), LocoStructVariableLoad, LocoArrayLength(MaxProducedCargoType)] List<uint8_t> ProducedCargoType,
43-
//[property: LocoStructOffset(0xA4), LocoStructVariableLoad, LocoArrayLength(MaxRequiredCargoType)] List<uint8_t> RequiredCargoType,
41+
[property: LocoStructOffset(0xA0), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> _ProducedQuantity,
42+
[property: LocoStructOffset(0xA2), LocoStructVariableLoad, LocoArrayLength(BuildingObject.MaxProducedCargoType), Browsable(false)] List<object_id> _ProducedCargoType,
43+
[property: LocoStructOffset(0xA4), LocoStructVariableLoad, LocoArrayLength(BuildingObject.MaxRequiredCargoType), Browsable(false)] List<object_id> _RequiredCargoType,
4444
[property: LocoStructOffset(0xA6), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> var_A6,
4545
[property: LocoStructOffset(0xA8), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> var_A8,
4646
[property: LocoStructOffset(0xA4), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> var_A4, // Some type of Cargo
4747
[property: LocoStructOffset(0xAA)] int16_t DemolishRatingReduction,
4848
[property: LocoStructOffset(0xAC)] uint8_t var_AC,
49-
[property: LocoStructOffset(0xAD)] uint8_t var_AD
49+
[property: LocoStructOffset(0xAD)] uint8_t NumAnimationSequences
5050
//[property: LocoStructOffset(0xAE), LocoStructVariableLoad, LocoArrayLength(4)] uint8_t[][] var_AE // 0xAE ->0xB2->0xB6->0xBA->0xBE (4 byte pointers)
5151
) : ILocoStruct, ILocoStructVariableData
5252
{
@@ -57,7 +57,7 @@ public record BuildingObject(
5757
public List<S5Header> ProducedCargo { get; set; } = [];
5858
public List<S5Header> RequiredCargo { get; set; } = [];
5959

60-
public List<uint8_t[]> var_AE { get; set; } = [];
60+
public List<uint8_t[]> AnimationSequences { get; set; } = [];
6161

6262
// known issues:
6363
// HOSPITL1.dat - loads without error but graphics are bugged
@@ -100,14 +100,14 @@ public ReadOnlySpan<byte> Load(ReadOnlySpan<byte> remainingData)
100100
RequiredCargo = SawyerStreamReader.LoadVariableCountS5Headers(remainingData, MaxRequiredCargoType);
101101
remainingData = remainingData[(S5Header.StructLength * MaxRequiredCargoType)..];
102102

103-
// load ??
104-
var_AE.Clear();
105-
for (var i = 0; i < var_AD; ++i)
103+
// animation sequences
104+
AnimationSequences.Clear();
105+
for (var i = 0; i < NumAnimationSequences; ++i)
106106
{
107107
var size = BitConverter.ToUInt16(remainingData[..2]);
108108
remainingData = remainingData[2..];
109109

110-
var_AE.Add(remainingData[..size].ToArray());
110+
AnimationSequences.Add(remainingData[..size].ToArray());
111111
remainingData = remainingData[size..];
112112
}
113113

@@ -150,7 +150,7 @@ public ReadOnlySpan<byte> Save()
150150
ms.Write(obj.Write());
151151
}
152152

153-
foreach (var unk in var_AE)
153+
foreach (var unk in AnimationSequences)
154154
{
155155
ms.Write(BitConverter.GetBytes((uint16_t)unk.Length));
156156
foreach (var x in unk)

Tests/LoadSaveTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void assertFunc(ILocoObject obj, BuildingObject struc) => Assert.Multiple(() =>
179179
// CollectionAssert.AreEqual(struc.var_A4, Array.CreateInstance(typeof(byte), 2), nameof(struc.var_A4));
180180
Assert.That(struc.DemolishRatingReduction, Is.EqualTo(0), nameof(struc.DemolishRatingReduction));
181181
Assert.That(struc.var_AC, Is.EqualTo(255), nameof(struc.var_AC));
182-
Assert.That(struc.var_AD, Is.EqualTo(0), nameof(struc.var_AD));
182+
Assert.That(struc.NumAnimationSequences, Is.EqualTo(0), nameof(struc.NumAnimationSequences));
183183
});
184184
LoadSaveGenericTest<BuildingObject>(objectName, assertFunc);
185185
}

0 commit comments

Comments
 (0)