Skip to content

Commit 2709126

Browse files
committed
misc fixes and renames
1 parent 72f90a7 commit 2709126

File tree

11 files changed

+23
-28
lines changed

11 files changed

+23
-28
lines changed

Dat/Objects/Sound/SoundObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace OpenLoco.Dat.Objects.Sound
1212
public record SoundObject(
1313
[property: LocoStructOffset(0x00), LocoString, Browsable(false)] string_id Name,
1414
[property: LocoStructOffset(0x02), Browsable(false)] uint32_t SoundObjectDataPtr,
15-
[property: LocoStructOffset(0x06)] uint8_t var_06,
15+
[property: LocoStructOffset(0x06)] uint8_t LoopCount, // 0 means no loop, any other number means loop
1616
[property: LocoStructOffset(0x07)] uint8_t var_07,
1717
[property: LocoStructOffset(0x08)] uint32_t Volume
1818
) : ILocoStruct, ILocoStructVariableData

Dat/Types/SCV5/S5File.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace OpenLoco.Dat.Types.SCV5
66
[TypeConverter(typeof(ExpandableObjectConverter))]
77
[LocoStructSize(StructLength)]
88
public record S5File(
9-
[property: LocoStructOffset(0x00)] Header Header,
9+
[property: LocoStructOffset(0x00)] S5FileHeader Header,
1010
[property: LocoStructOffset(0x20)] LandscapeDetails? LandscapeOptions,
1111
[property: LocoStructOffset(0x433A)] SaveDetails? SaveDetails,
1212
[property: LocoStructOffset(0x10952), LocoArrayLength(859), Browsable(false)] List<S5Header> RequiredObjects,
@@ -21,7 +21,7 @@ public record S5File(
2121

2222
public static S5File Read(ReadOnlySpan<byte> data)
2323
{
24-
var header = SawyerStreamReader.ReadChunk<Header>(ref data);
24+
var header = SawyerStreamReader.ReadChunk<S5FileHeader>(ref data);
2525

2626
SaveDetails? saveDetails = null;
2727
LandscapeDetails? landscapeDetails = null;

Dat/Types/SCV5/Header.cs renamed to Dat/Types/SCV5/S5FileHeader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace OpenLoco.Dat.Types.SCV5
55
{
66
[TypeConverter(typeof(ExpandableObjectConverter))]
77
[LocoStructSize(StructLength)]
8-
public record Header(
8+
public record S5FileHeader(
99
[property: LocoStructOffset(0x00)] S5Type Type,
1010
[property: LocoStructOffset(0x01)] HeaderFlags Flags,
1111
[property: LocoStructOffset(0x02)] uint16_t NumPackedObjects,

DatabaseSeeder/Program.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,3 @@ static void SeedDb(LocoDb db, bool deleteExisting)
169169

170170
Console.WriteLine("Finished seeding");
171171
}
172-
173-
static string? uint32_t_LittleToBigEndian(string input)
174-
{
175-
var r = new string(input.Chunk(2).Reverse().SelectMany(x => x).ToArray());
176-
return Convert.ToUInt32(r, 16).ToString();
177-
}

Gui/Models/MetadataModel.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@
66

77
namespace OpenLoco.Gui.Models
88
{
9-
public class MetadataModel
9+
public class MetadataModel(string uniqueName, string datName, uint datChecksum)
1010
{
11-
public MetadataModel(string uniqueName, string datName, uint datChecksum)
12-
{
13-
UniqueName = uniqueName;
14-
DatName = datName;
15-
DatChecksum = datChecksum;
16-
}
11+
public string UniqueName { get; init; } = uniqueName;
1712

18-
public string UniqueName { get; init; }
13+
public string DatName { get; init; } = datName;
14+
15+
public uint DatChecksum { get; init; } = datChecksum;
1916

20-
public string DatName { get; init; }
21-
public uint DatChecksum { get; init; }
2217
public string? Description { get; set; }
2318

2419
[Browsable(false)]

Gui/Models/ObjectEditorModel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ void LoadSettings()
9292
{
9393
Logger.Error("Unable to validate settings file - please delete it and it will be recreated on next editor start-up.");
9494
}
95-
9695
}
9796

9897
void InitialiseDownloadDirectory()
@@ -321,7 +320,7 @@ async Task LoadObjDirectoryAsyncCore(string directory, IProgress<float> progress
321320

322321
async Task RecreateIndex(string directory, IProgress<float> progress)
323322
{
324-
Logger.Info("Recreating index file");
323+
Logger.Info($"Recreating index file for {directory}");
325324
ObjectIndex = await ObjectIndex.CreateIndexAsync(directory, Logger, progress);
326325
ObjectIndex?.SaveIndex(Settings.IndexFileName);
327326
}

Gui/ViewModels/DatTypes/Objects/VehicleViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class VehicleViewModel : ReactiveObject, IObjectViewModel<ILocoStruct>
2121
[Reactive, Category("Stats")] public uint16_t ObsoleteYear { get; set; }
2222
[Reactive, Category("Stats")] public uint8_t Reliability { get; set; }
2323
[Reactive] public VehicleObjectFlags Flags { get; set; }
24-
[Reactive] public S5Header TrackType { get; set; }
25-
[Reactive] public S5Header RackRail { get; set; }
24+
[Reactive] public S5Header? TrackType { get; set; }
25+
[Reactive] public S5Header? RackRail { get; set; }
2626
[Reactive, Length(0, 8)] public BindingList<S5Header> CompatibleVehicles { get; set; }
2727
[Reactive, Length(0, 4)] public BindingList<S5Header> RequiredTrackExtras { get; set; }
2828
[Reactive, Category("Cost"), Range(0, 32)] public uint8_t CostIndex { get; set; }
@@ -41,7 +41,7 @@ public class VehicleViewModel : ReactiveObject, IObjectViewModel<ILocoStruct>
4141
[Reactive, Category("Cargo")] public BindingList<CargoCategory> CompatibleCargoCategories1 { get; set; }
4242
[Reactive, Category("Cargo")] public BindingList<CargoCategory> CompatibleCargoCategories2 { get; set; }
4343
[Reactive, Category("Cargo"), Length(0, 32)] public BindingList<CargoTypeSpriteOffset> CargoTypeSpriteOffsets { get; set; } // this is a dictionary type
44-
[Reactive, Category("Sound")] public S5Header Sound { get; set; }
44+
[Reactive, Category("Sound")] public S5Header? Sound { get; set; }
4545
[Reactive, Category("Sound")] public DrivingSoundType SoundType { get; set; }
4646
// SoundPropertiesData
4747
// these next 3 properties are a union in the dat file

Gui/ViewModels/SubObjectTypes/ImageTableViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,12 @@ public async Task ImportImages()
223223
{
224224
// found blender folder
225225
var offsets = JsonSerializer.Deserialize<ICollection<SpriteOffset>>(File.ReadAllText(offsetsFile)); // sprites.json is an unnamed array so we need ICollection here, not IEnumerable
226+
ArgumentNullException.ThrowIfNull(offsets);
226227
Logger.Debug("Found sprites.json file, using that");
227228

228-
if (offsets?.Count != G1Provider.G1Elements.Count)
229+
if (offsets.Count != G1Provider.G1Elements.Count)
229230
{
230-
Logger.Warning($"Expected {G1Provider.G1Elements.Count} offsets, got {offsets?.Count} offsets. Continue at your peril.");
231+
Logger.Warning($"Expected {G1Provider.G1Elements.Count} offsets, got {offsets.Count} offsets. Continue at your peril.");
231232
}
232233

233234
foreach (var offset in offsets)

Gui/ViewModels/SubObjectTypes/SoundViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ public void PlaySound()
9797
public async Task ImportSound()
9898
{
9999
var fsi = await MainWindowViewModel.GetFileSystemItemFromUser(PlatformSpecific.WavFileTypes);
100+
if (fsi == null)
101+
{
102+
return;
103+
}
104+
100105
var (header, pcmData) = SawyerStreamReader.LoadWavFile(fsi.Filename);
101106
Header = header;
102107
Data = pcmData;

ObjectService/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
}
6767

6868
var objRoot = builder.Configuration["ObjectService:RootFolder"];
69+
ArgumentNullException.ThrowIfNull(objRoot);
6970
var server = new Server(new ServerSettings(objRoot) { RootFolder = objRoot! });
7071

7172
// GET

0 commit comments

Comments
 (0)