mirror of
https://github.com/kwsch/NHSE.git
synced 2026-08-27 21:34:15 -05:00
Turn on nullable checks for parse project
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NHSE.Parsing
|
||||
{
|
||||
@@ -8,5 +9,9 @@ public class LBL1 : MSBTSection
|
||||
|
||||
public readonly List<MSBTGroup> Groups = new List<MSBTGroup>();
|
||||
public readonly List<MSBTLabel> Labels = new List<MSBTLabel>();
|
||||
|
||||
public LBL1() : base(string.Empty, Array.Empty<byte>())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +75,10 @@ private void ReadLBL1(BinaryReaderX br)
|
||||
|
||||
for (int i = 0; i < grp.NumberOfLabels; i++)
|
||||
{
|
||||
MSBTLabel lbl = new MSBTLabel {Length = Convert.ToUInt32(br.ReadByte())};
|
||||
lbl.Name = br.ReadString((int)lbl.Length);
|
||||
lbl.Index = br.ReadUInt32();
|
||||
var length = Convert.ToUInt32(br.ReadByte());
|
||||
var name = br.ReadString((int)length);
|
||||
var index = br.ReadUInt32();
|
||||
var lbl = new MSBTLabel(name) {Index = index, Length = length};
|
||||
LBL1.Labels.Add(lbl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,15 @@ namespace NHSE.Parsing
|
||||
public class MSBTLabel
|
||||
{
|
||||
public uint Length;
|
||||
public string Name;
|
||||
public readonly string Name;
|
||||
public MSBTTextString String;
|
||||
|
||||
public MSBTLabel(string name)
|
||||
{
|
||||
Name = name;
|
||||
String = MSBTTextString.Empty;
|
||||
}
|
||||
|
||||
public uint Index { get; set; }
|
||||
public override string ToString() => Length > 0 ? Name : (Index + 1).ToString();
|
||||
public string ToString(Encoding encoding) => encoding.GetString(String.Value);
|
||||
|
||||
@@ -5,5 +5,11 @@ public class MSBTSection
|
||||
public string Identifier;
|
||||
public uint SectionSize; // Begins after Unknown1
|
||||
public byte[] Padding1; // Always 0x0000 0000
|
||||
|
||||
public MSBTSection(string identifier, byte[] padding)
|
||||
{
|
||||
Identifier = identifier;
|
||||
Padding1 = padding;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace NHSE.Parsing
|
||||
{
|
||||
@@ -7,6 +8,8 @@ public class MSBTTextString
|
||||
public readonly byte[] Value;
|
||||
public readonly uint Index;
|
||||
|
||||
public static readonly MSBTTextString Empty = new MSBTTextString(Array.Empty<byte>(), 0);
|
||||
|
||||
public MSBTTextString(byte[] v, uint i)
|
||||
{
|
||||
Value = v;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NHSE.Parsing
|
||||
{
|
||||
@@ -7,5 +8,9 @@ public class TXT2 : MSBTSection
|
||||
public uint NumberOfStrings;
|
||||
|
||||
public readonly List<MSBTTextString> Strings = new List<MSBTTextString>();
|
||||
|
||||
public TXT2() : base(string.Empty, Array.Empty<byte>())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>8</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user