Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building object fields#27 #28

Merged
merged 3 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Core/Objects/BuildingObject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;
using Core.Objects;
using OpenLoco.ObjectEditor.Data;
using OpenLoco.ObjectEditor.DatFileParsing;
Expand Down Expand Up @@ -38,15 +38,15 @@
[property: LocoStructOffset(0x9D)] Colour ScaffoldingColour,
[property: LocoStructOffset(0x9E)] uint8_t GeneratorFunction,
[property: LocoStructOffset(0x9F)] uint8_t var_9F,
//[property: LocoStructOffset(0xA0), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> ProducedQuantity,
//[property: LocoStructOffset(0xA2), LocoStructVariableLoad, LocoArrayLength(MaxProducedCargoType)] List<uint8_t> ProducedCargoType,
//[property: LocoStructOffset(0xA4), LocoStructVariableLoad, LocoArrayLength(MaxRequiredCargoType)] List<uint8_t> RequiredCargoType,
[property: LocoStructOffset(0xA0), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> _ProducedQuantity,
[property: LocoStructOffset(0xA2), LocoStructVariableLoad, LocoArrayLength(BuildingObject.MaxProducedCargoType), Browsable(false)] List<object_id> _ProducedCargoType,
[property: LocoStructOffset(0xA4), LocoStructVariableLoad, LocoArrayLength(BuildingObject.MaxRequiredCargoType), Browsable(false)] List<object_id> _RequiredCargoType,
[property: LocoStructOffset(0xA6), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> var_A6,
[property: LocoStructOffset(0xA8), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> var_A8,
[property: LocoStructOffset(0xA4), LocoStructVariableLoad, LocoArrayLength(2)] List<uint8_t> var_A4, // Some type of Cargo
[property: LocoStructOffset(0xAA)] int16_t DemolishRatingReduction,
[property: LocoStructOffset(0xAC)] uint8_t var_AC,
[property: LocoStructOffset(0xAD)] uint8_t var_AD
[property: LocoStructOffset(0xAD)] uint8_t NumAnimationSequences
//[property: LocoStructOffset(0xAE), LocoStructVariableLoad, LocoArrayLength(4)] uint8_t[][] var_AE // 0xAE ->0xB2->0xB6->0xBA->0xBE (4 byte pointers)
) : ILocoStruct, ILocoStructVariableData
{
Expand All @@ -57,7 +57,7 @@
public List<S5Header> ProducedCargo { get; set; } = [];
public List<S5Header> RequiredCargo { get; set; } = [];

public List<uint8_t[]> var_AE { get; set; } = [];
public List<uint8_t[]> AnimationSequences { get; set; } = [];

// known issues:
// HOSPITL1.dat - loads without error but graphics are bugged
Expand Down Expand Up @@ -100,14 +100,14 @@
RequiredCargo = SawyerStreamReader.LoadVariableCountS5Headers(remainingData, MaxRequiredCargoType);
remainingData = remainingData[(S5Header.StructLength * MaxRequiredCargoType)..];

// load ??
var_AE.Clear();
for (var i = 0; i < var_AD; ++i)
// animation sequences
AnimationSequences.Clear();
for (var i = 0; i < NumAnimationSequences; ++i)
{
var size = BitConverter.ToUInt16(remainingData[..2]);
remainingData = remainingData[2..];

var_AE.Add(remainingData[..size].ToArray());
AnimationSequences.Add(remainingData[..size].ToArray());
remainingData = remainingData[size..];
}

Expand Down Expand Up @@ -141,7 +141,7 @@
// produced cargo
foreach (var obj in ProducedCargo.Fill(MaxProducedCargoType, S5Header.NullHeader))
{
ms.Write(obj.Write());

Check warning on line 144 in Core/Objects/BuildingObject.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Dereference of a possibly null reference.
}

// required cargo
Expand All @@ -150,7 +150,7 @@
ms.Write(obj.Write());
}

foreach (var unk in var_AE)
foreach (var unk in AnimationSequences)
{
ms.Write(BitConverter.GetBytes((uint16_t)unk.Length));
foreach (var x in unk)
Expand Down
22 changes: 11 additions & 11 deletions Gui/MainFormModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,17 @@ public void LoadObjDirectory(string directory, IProgress<float>? progress, bool
if (a.Any() || b.Any())
{
logger.Warning("Selected directory had an index file but it was outdated; suggest recreating it when you have a moment");
logger.Warning("Files in index that weren't in the directory:");
foreach (var aa in a)
{
logger.Warning($" {aa}");
}

logger.Warning("Files in directory that weren't in the index:");
foreach (var bb in b)
{
logger.Warning($" {bb}");
}
//logger.Warning("Files in index that weren't in the directory:");
//foreach (var aa in a)
//{
// logger.Warning($" {aa}");
//}

//logger.Warning("Files in directory that weren't in the index:");
//foreach (var bb in b)
//{
// logger.Warning($" {bb}");
//}
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion Tests/LoadSaveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void assertFunc(ILocoObject obj, BuildingObject struc) => Assert.Multiple(() =>
// CollectionAssert.AreEqual(struc.var_A4, Array.CreateInstance(typeof(byte), 2), nameof(struc.var_A4));
Assert.That(struc.DemolishRatingReduction, Is.EqualTo(0), nameof(struc.DemolishRatingReduction));
Assert.That(struc.var_AC, Is.EqualTo(255), nameof(struc.var_AC));
Assert.That(struc.var_AD, Is.EqualTo(0), nameof(struc.var_AD));
Assert.That(struc.NumAnimationSequences, Is.EqualTo(0), nameof(struc.NumAnimationSequences));
});
LoadSaveGenericTest<BuildingObject>(objectName, assertFunc);
}
Expand Down
Loading