From 9e1d65d08d890833f80398806f0091e79fffe955 Mon Sep 17 00:00:00 2001 From: Samuele Lorefice Date: Thu, 6 Mar 2025 19:11:50 +0100 Subject: [PATCH] Added start offset param to the field conversion methods, started implementing list conversions --- BlendFile/Reader.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/BlendFile/Reader.cs b/BlendFile/Reader.cs index 6812db0..7a14929 100644 --- a/BlendFile/Reader.cs +++ b/BlendFile/Reader.cs @@ -162,10 +162,10 @@ public class Reader { var attrib = field.GetCustomAttribute(); 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; }