Added start offset param to the field conversion methods, started implementing list conversions

This commit is contained in:
Samuele Lorefice
2025-03-06 19:11:50 +01:00
parent fb50e3fa44
commit 9e1d65d08d

View File

@@ -162,10 +162,10 @@ public class Reader {
var attrib = field.GetCustomAttribute<DNAAttribute>();
switch (attrib) {
case DNAFieldAttribute fieldAttribute:
value = ConvertNormalField(block, fieldAttribute);
value = ConvertNormalField(block, fieldAttribute, startOffset);
break;
case DNAListAttribute listAttribute:
value = ConvertListField(block, field, listAttribute);
value = ConvertListField(block, field, listAttribute, startOffset);
break;
default:
continue; //should never happen.
@@ -179,10 +179,10 @@ public class Reader {
objects.Add((block.MemAddr.ToPointer() + startOffset, obj!.GetType()), obj!);
}
private object? ConvertNormalField(FileBlock block, DNAFieldAttribute attrib) {
private object? ConvertNormalField(FileBlock block, DNAFieldAttribute attrib, IntPtr startOffset) {
//Calculate the offset from where the data of the field starts.
//Because the order of the fields is not guaranteed we need to compute it each time
IntPtr offset = attrib.MemoryOffset;
IntPtr offset = attrib.MemoryOffset + startOffset;
//Grab data size, create a container and copy the data from the block to the container
int size = attrib.Size;
@@ -219,8 +219,10 @@ public class Reader {
throw new NotSupportedException($"Unknown type \"{attrib.OriginalType}\"");
}
private object? ConvertListField(FileBlock block, FieldInfo field, DNAListAttribute attrib) {
private object? ConvertListField(FileBlock block, FieldInfo field, DNAListAttribute attrib, IntPtr startOffset) {
IntPtr offset = attrib.MemoryOffset + startOffset;
int size = Array.Copy((byte[])block.Body, startOffset+attrib.)
var data = new byte[]
return null;
}