From f80d6942cc7ca140c28d3c8f2defd7f8728a75a2 Mon Sep 17 00:00:00 2001 From: Max G Date: Sun, 24 Feb 2019 21:17:53 -0600 Subject: [PATCH] Consistency adjustments --- BinaryFormat/ChunkTypes/PROP.cs | 55 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/BinaryFormat/ChunkTypes/PROP.cs b/BinaryFormat/ChunkTypes/PROP.cs index 24baccb..3439b1e 100644 --- a/BinaryFormat/ChunkTypes/PROP.cs +++ b/BinaryFormat/ChunkTypes/PROP.cs @@ -31,7 +31,6 @@ namespace RobloxFiles.BinaryFormat.Chunks { Type = PropertyType.Unknown; } - } public void ReadProperties(BinaryRobloxFile file) @@ -57,6 +56,9 @@ namespace RobloxFiles.BinaryFormat.Chunks } // Setup some short-hand functions for actions frequently used during the read procedure. + var readInts = new Func(() => Reader.ReadInts(instCount)); + var readFloats = new Func(() => Reader.ReadFloats(instCount)); + var loadProperties = new Action>(read => { for (int i = 0; i < instCount; i++) @@ -65,9 +67,6 @@ namespace RobloxFiles.BinaryFormat.Chunks props[i].Value = result; } }); - - var readInts = new Func(() => Reader.ReadInts(instCount)); - var readFloats = new Func(() => Reader.ReadFloats(instCount)); // Read the property data based on the property type. switch (Type) @@ -161,11 +160,11 @@ namespace RobloxFiles.BinaryFormat.Chunks break; case PropertyType.BrickColor: - int[] brickColors = readInts(); + int[] BrickColorIds = readInts(); loadProperties(i => { - int number = brickColors[i]; + int number = BrickColorIds[i]; return BrickColor.FromNumber(number); }); @@ -186,28 +185,28 @@ namespace RobloxFiles.BinaryFormat.Chunks break; case PropertyType.Vector2: - float[] vector2_X = readFloats(), - vector2_Y = readFloats(); + float[] Vector2_X = readFloats(), + Vector2_Y = readFloats(); loadProperties(i => { - float x = vector2_X[i], - y = vector2_Y[i]; + float x = Vector2_X[i], + y = Vector2_Y[i]; return new Vector2(x, y); }); break; case PropertyType.Vector3: - float[] vector3_X = readFloats(), - vector3_Y = readFloats(), - vector3_Z = readFloats(); + float[] Vector3_X = readFloats(), + Vector3_Y = readFloats(), + Vector3_Z = readFloats(); loadProperties(i => { - float x = vector3_X[i], - y = vector3_Y[i], - z = vector3_Z[i]; + float x = Vector3_X[i], + y = Vector3_Y[i], + z = Vector3_Z[i]; return new Vector3(x, y, z); }); @@ -268,17 +267,17 @@ namespace RobloxFiles.BinaryFormat.Chunks } }); - float[] cframe_X = readFloats(), - cframe_Y = readFloats(), - cframe_Z = readFloats(); + float[] CFrame_X = readFloats(), + CFrame_Y = readFloats(), + CFrame_Z = readFloats(); loadProperties(i => { float[] matrix = props[i].Value as float[]; - float x = cframe_X[i], - y = cframe_Y[i], - z = cframe_Z[i]; + float x = CFrame_X[i], + y = CFrame_Y[i], + z = CFrame_Z[i]; float[] position = new float[3] { x, y, z }; float[] components = position.Concat(matrix).ToArray(); @@ -409,15 +408,15 @@ namespace RobloxFiles.BinaryFormat.Chunks break; case PropertyType.Color3uint8: - byte[] color3uint8_R = Reader.ReadBytes(instCount), - color3uint8_G = Reader.ReadBytes(instCount), - color3uint8_B = Reader.ReadBytes(instCount); + byte[] Color3uint8_R = Reader.ReadBytes(instCount), + Color3uint8_G = Reader.ReadBytes(instCount), + Color3uint8_B = Reader.ReadBytes(instCount); loadProperties(i => { - byte r = color3uint8_R[i], - g = color3uint8_G[i], - b = color3uint8_B[i]; + byte r = Color3uint8_R[i], + g = Color3uint8_G[i], + b = Color3uint8_B[i]; return Color3.FromRGB(r, g, b); });