Formatting (again)

This commit is contained in:
Samuele Lorefice
2025-05-02 16:25:03 +02:00
parent a7337dd1d6
commit f03d907441

View File

@@ -49,9 +49,7 @@ public class Reader {
/// </summary> /// </summary>
/// <param name="memAddr">memory address in current system endianness</param> /// <param name="memAddr">memory address in current system endianness</param>
/// <returns>A <see cref="Kaitai.BlendFile.FileBlock"/> object</returns> /// <returns>A <see cref="Kaitai.BlendFile.FileBlock"/> object</returns>
public FileBlock? GetBlock(long memAddr) public FileBlock? GetBlock(long memAddr) {
{
var blocks = OrderedBlocks.Where(x => var blocks = OrderedBlocks.Where(x =>
memAddr >= x.MemAddr.ToPointer() && memAddr < x.MemAddr.ToPointer() + x.LenBody); memAddr >= x.MemAddr.ToPointer() && memAddr < x.MemAddr.ToPointer() + x.LenBody);
@@ -299,8 +297,7 @@ public class Reader {
return null; return null;
} }
private static int[] CalculateArrayIndices(List<int> sizes, int index) private static int[] CalculateArrayIndices(List<int> sizes, int index) {
{
int[] indexArray = new int[sizes.Count]; int[] indexArray = new int[sizes.Count];
for (int k = 0; k < sizes.Count; k++) { for (int k = 0; k < sizes.Count; k++) {
indexArray[k] = index / sizes[(k + 1) ..].Aggregate(1, (a, b) => a * b) % sizes[k]; indexArray[k] = index / sizes[(k + 1) ..].Aggregate(1, (a, b) => a * b) % sizes[k];
@@ -310,8 +307,7 @@ public class Reader {
} }
private Array FillPointersArray(DNAArrayAttribute arrayAttribute, byte[] data, private Array FillPointersArray(DNAArrayAttribute arrayAttribute, byte[] data,
Type type, List<int> sizes) Type type, List<int> sizes) {
{
//Create the array //Create the array
var array = Array.CreateInstance(type, sizes.ToArray()); var array = Array.CreateInstance(type, sizes.ToArray());
@@ -330,8 +326,8 @@ public class Reader {
return array; return array;
} }
private Array FillNormalTypeArray(DNAArrayAttribute arrayAttribute, byte[] data, FileBlock block, Type type, List<int> sizes, int itemLenght, int offset) private Array FillNormalTypeArray(DNAArrayAttribute arrayAttribute, byte[] data, FileBlock block, Type type,
{ List<int> sizes, int itemLenght, int offset) {
var array = Array.CreateInstance(type, sizes.ToArray()); var array = Array.CreateInstance(type, sizes.ToArray());
for (int i = 0; i < arrayAttribute.Size; i += itemLenght) { for (int i = 0; i < arrayAttribute.Size; i += itemLenght) {
@@ -347,8 +343,8 @@ public class Reader {
return array; return array;
} }
private Array FillCustomTypeArray(DNAArrayAttribute arrayAttribute, byte[] data, FileBlock block, Type type, List<int> sizes, int itemLenght, int offset) private Array FillCustomTypeArray(DNAArrayAttribute arrayAttribute, byte[] data, FileBlock block, Type type,
{ List<int> sizes, int itemLenght, int offset) {
var array = Array.CreateInstance(type, sizes.ToArray()); var array = Array.CreateInstance(type, sizes.ToArray());
for (int i = 0; i < arrayAttribute.Size; i += itemLenght) { for (int i = 0; i < arrayAttribute.Size; i += itemLenght) {
@@ -385,14 +381,13 @@ public class Reader {
} }
if (!dnaTypesDb.ContainsKey(arrayAttribute.OriginalType)) { if (!dnaTypesDb.ContainsKey(arrayAttribute.OriginalType)) {
return FillNormalTypeArray(arrayAttribute, data, block, type, sizes,
return FillNormalTypeArray(arrayAttribute, data, block, type, sizes, arrayAttribute.OriginalType.ParseFSize()!.Value, offset.ToInt32()); arrayAttribute.OriginalType.ParseFSize()!.Value, offset.ToInt32());
} }
int itemLenght = type.GetCustomAttribute<DNAFieldAttribute>()?.Size ?? int itemLenght = type.GetCustomAttribute<DNAFieldAttribute>()?.Size ??
type.GetCustomAttribute<DNAClassAttribute>()!.Size; type.GetCustomAttribute<DNAClassAttribute>()!.Size;
return FillCustomTypeArray(arrayAttribute, data, block, type, sizes, itemLenght, offset.ToInt32()); return FillCustomTypeArray(arrayAttribute, data, block, type, sizes, itemLenght, offset.ToInt32());
} }
private object? ConvertListField(FileBlock block, FieldInfo field, DNAListAttribute attrib, IntPtr startOffset) { private object? ConvertListField(FileBlock block, FieldInfo field, DNAListAttribute attrib, IntPtr startOffset) {