From 4e1fdc0a22cdf801187dc87ef40f8cdf4d8be0a7 Mon Sep 17 00:00:00 2001 From: CloneTrooper1019 Date: Wed, 3 Jul 2019 09:48:05 -0500 Subject: [PATCH] Bug fixes and improvements. - Fixed an issue pertaining to implicit value casting in the property reflection. - Removed some unnecessary generated whitespace in the class data. - Added some missing properties to the generated class data. - Moved the Quaternion type into the DataTypes namespace. --- BinaryFormat/Chunks/PROP.cs | 1 - DataTypes/CFrame.cs | 1 - DataTypes/Quaternion.cs | 3 +- Generated/Classes.cs | 10 ++-- Plugins/GenerateApiDump.rbxm | Bin 13172 -> 13301 bytes Plugins/GenerateApiDump/ApiPlugin.server.lua | 11 +++-- Plugins/GenerateApiDump/PropertyPatches.lua | 19 ++++++++ Tree/Instance.cs | 4 +- Tree/Property.cs | 48 ++++++++++++++++--- 9 files changed, 75 insertions(+), 22 deletions(-) diff --git a/BinaryFormat/Chunks/PROP.cs b/BinaryFormat/Chunks/PROP.cs index 4aa0102..fbcf33e 100644 --- a/BinaryFormat/Chunks/PROP.cs +++ b/BinaryFormat/Chunks/PROP.cs @@ -6,7 +6,6 @@ using System.Text; using RobloxFiles.Enums; using RobloxFiles.DataTypes; -using RobloxFiles.Utility; namespace RobloxFiles.BinaryFormat.Chunks { diff --git a/DataTypes/CFrame.cs b/DataTypes/CFrame.cs index 74903f2..9e9eb41 100644 --- a/DataTypes/CFrame.cs +++ b/DataTypes/CFrame.cs @@ -1,5 +1,4 @@ using System; -using RobloxFiles.Utility; namespace RobloxFiles.DataTypes { diff --git a/DataTypes/Quaternion.cs b/DataTypes/Quaternion.cs index 608027c..a6f9cce 100644 --- a/DataTypes/Quaternion.cs +++ b/DataTypes/Quaternion.cs @@ -1,7 +1,6 @@ using System; -using RobloxFiles.DataTypes; -namespace RobloxFiles.Utility +namespace RobloxFiles.DataTypes { /// /// Quaternion is a utility used by the CFrame DataType to handle rotation interpolation. diff --git a/Generated/Classes.cs b/Generated/Classes.cs index d6ae6be..e73a65e 100644 --- a/Generated/Classes.cs +++ b/Generated/Classes.cs @@ -644,7 +644,6 @@ namespace RobloxFiles { IsService = true; } - } public class ContextActionService : Instance @@ -723,6 +722,9 @@ namespace RobloxFiles public abstract class BevelMesh : DataModelMesh { + public float Bevel = 0; + public float Bevel_Roundness = 0; + public float Bulge = 0; } public class BlockMesh : BevelMesh @@ -1758,7 +1760,6 @@ namespace RobloxFiles { IsService = true; } - } public class LocalizationTable : Instance @@ -1866,7 +1867,6 @@ namespace RobloxFiles { IsService = true; } - } public abstract class PVInstance : Instance @@ -2065,6 +2065,7 @@ namespace RobloxFiles { public Content AssetId = ""; public byte[] ChildData = new byte[0]; + public FormFactor FormFactor = FormFactor.Custom; public byte[] MeshData = new byte[0]; public RenderFidelity RenderFidelity = RenderFidelity.Precise; public bool UsePartColor = false; @@ -2728,7 +2729,6 @@ namespace RobloxFiles { IsService = true; } - } public class StudioData : Instance @@ -2748,7 +2748,6 @@ namespace RobloxFiles { IsService = true; } - } public class Team : Instance @@ -2983,7 +2982,6 @@ namespace RobloxFiles { IsService = true; } - } public abstract class ValueBase : Instance diff --git a/Plugins/GenerateApiDump.rbxm b/Plugins/GenerateApiDump.rbxm index 8f53365f80f4f8290674d91e8352dbcfc7059132..1c77ae3b9a063254cecf8012edc3a6d3bffcb0c9 100644 GIT binary patch delta 3487 zcmXAs3v^V~xyS$C-ut{}GIQpY4D%p4nLrXqn9Kx<66BEwk7zK!08)IAAvuJB$xN7; zAc%G#DAKDUc(g*H&{l+^U83UcQcGRlmfKs!B2e{qSzjPkX>Fxmt-8GR-a~uV+UJ~g z)?WMk&$oZy|NG8ot3MxnGQ{LbVPM+y<2CGr%Ffguf7`Kxm3McT8_etiv$&>A?t6#~ z;9by)N_r10fL$vW=SOk_IkWg2)2fje$qv55lmNsL$Uc&uWz++NDshhMD*!$QdX^>0uUyN@Ejl{DUlYnS zq&w3?W+D9$!%QZ>N@tDDMrS@>7_dc^%r>F5Lu^91D_u%2$Pditj@doEUCU>nZ%%Gx zsI6y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8=^z~ex<%1;9|M2BJb7u{p#c&fj|8*P;MW0=LiJ8>9j0csT*=H!O_6#R2O zr2vs?&+w(y@&lw?2Bnsa4x_uge$m3564EY~vi5TJ0B}xnFUROVI+=rIN)s#B#t|@v z%K0iVTUz$l{eq~I^XK4cf5KR8SD$2tYSZI&@O5ajm}$4GhnbHZcCj@`Or;8csS`0I zr>CZ3sE)@YM8oj6Zh_cBbgQ7n2we3~5kwU1o@-D>;=QKr<6|LpKEn@G_A%iM(K4{} zkbe(e$;F>Q&nUbN%G1P7;^2f?Y&HsJu@_vy18Hk_+&7!9P>Yn%Cd{9y_N#dp=4%C; zI~_HxQKREr4WD32Kys}>U3}&3aIUuJ!4RbP?S6@41EEi)CkZzS?IFnLgt&q9PLRHr z+;ShDh;ClDwUEo0Mf0j*Cr&}$Pc|e1*h#iM zAN5Yv6_y(NqRl&iRn*IN+o#{@qjk`uXNx72E9b7=^-z?jXZ_xSNJ=1ldsiWG$ zL<58hnM?8p=#r%Pv=xw^ti&LROQDoyYZAsS8ey3dhqEVY}WJif!@nHc#4-&7$A<7ReOY<~Rz z{57%p4>u<2;>H7w^!0$Vu}Sj>^jiZ8JL9L5Vf|p>60|$qFZ;dmcYtYCYf#186<8m} zhdS!f*}l>&sx|>heCDSIq13r43101X%J-2t#xT$B2Q63YC9Y>nuoTpWvgVt@) zRJ<49c7lIaiI)Vu$l1%l^&G#fuW4w0%Y{FJw^%=DJ>XR;)W?T^1B>t8^8f$< diff --git a/Plugins/GenerateApiDump/ApiPlugin.server.lua b/Plugins/GenerateApiDump/ApiPlugin.server.lua index cbc3efd..9f45ea1 100644 --- a/Plugins/GenerateApiDump/ApiPlugin.server.lua +++ b/Plugins/GenerateApiDump/ApiPlugin.server.lua @@ -391,7 +391,6 @@ local function generateClasses() local firstLine = true table.sort(propNames) - if classTags.Service then writeLine("public %s()", className) openStack() @@ -399,8 +398,14 @@ local function generateClasses() writeLine("IsService = true;") closeStack() - if #propNames > 0 then - writeLine() + for i, propName in ipairs(propNames) do + local prop = propMap[propName] + local serial = prop.Serialization + + if serial.CanLoad then + writeLine() + break + end end end diff --git a/Plugins/GenerateApiDump/PropertyPatches.lua b/Plugins/GenerateApiDump/PropertyPatches.lua index 1f6ee6f..8448786 100644 --- a/Plugins/GenerateApiDump/PropertyPatches.lua +++ b/Plugins/GenerateApiDump/PropertyPatches.lua @@ -84,6 +84,23 @@ return } }; + BevelMesh = + { + Add = + { + Bevel = "float"; + Bevel_Roundness = "float"; + Bulge = "float"; + }; + + Defaults = + { + Bevel = 0; + Bevel_Roundness = 0; + Bulge = 0; + } + }; + BinaryStringValue = { Add = @@ -387,6 +404,7 @@ return AssetId = "Content"; ChildData = "BinaryString"; MeshData = "BinaryString"; + FormFactor = "Enum:FormFactor"; }; Defaults = @@ -394,6 +412,7 @@ return AssetId = ""; ChildData = ""; MeshData = ""; + FormFactor = Enum.FormFactor.Custom; }; }; diff --git a/Tree/Instance.cs b/Tree/Instance.cs index 1eb3ddf..0f05af7 100644 --- a/Tree/Instance.cs +++ b/Tree/Instance.cs @@ -21,7 +21,7 @@ namespace RobloxFiles /// The ClassName of this Instance. public string ClassName => GetType().Name; - /// Internal list of Properties that are under this Instance. + /// Internal list of properties that are under this Instance. private Dictionary props = new Dictionary(); /// A list of properties that are defined under this Instance. @@ -30,7 +30,7 @@ namespace RobloxFiles /// The raw list of children for this Instance. internal List Children = new List(); - /// Raw value of the Instance's parent. + /// The raw value of the Instance's parent. private Instance RawParent; /// The name of this Instance. diff --git a/Tree/Property.cs b/Tree/Property.cs index 01398c9..718ddde 100644 --- a/Tree/Property.cs +++ b/Tree/Property.cs @@ -6,7 +6,6 @@ using RobloxFiles.BinaryFormat; using RobloxFiles.BinaryFormat.Chunks; using RobloxFiles.DataTypes; -using RobloxFiles.Utility; namespace RobloxFiles { @@ -140,6 +139,12 @@ namespace RobloxFiles } } + if (Name.Contains(" ")) + { + var implicitName = Name.Replace(' ', '_'); + return implicitName; + } + return Name; } } @@ -188,13 +193,42 @@ namespace RobloxFiles FieldInfo field = Instance.GetType() .GetField(ImplicitName, BindingFlags); - try + if (field != null) { - field?.SetValue(Instance, value); - } - catch - { - Console.WriteLine($"RobloxFiles.Property - Failed to cast value {value} into property {Instance.ClassName}.{Name}"); + Type fieldType = field.FieldType; + Type valueType = value?.GetType(); + + if (fieldType == valueType || value == null) + { + try + { + field.SetValue(Instance, value); + } + catch + { + Console.WriteLine($"RobloxFiles.Property - Failed to cast value {value} into property {Instance.ClassName}.{Name}"); + } + } + else if (valueType != null) + { + var typeWrapper = new Type[] { valueType }; + MethodInfo implicitCast = fieldType.GetMethod("op_Implicit", typeWrapper); + + if (implicitCast != null) + { + var valueWrapper = new object[] { value }; + + try + { + object castedValue = implicitCast.Invoke(null, valueWrapper); + field.SetValue(Instance, castedValue); + } + catch + { + Console.WriteLine($"RobloxFiles.Property - Failed to implicitly cast value {value} into property {Instance.ClassName}.{Name}"); + } + } + } } } }