0.462.0.416719

This commit is contained in:
CloneTrooper1019 2021-01-20 14:45:58 -06:00
parent 1a34e9c849
commit 1acb895eaf
17 changed files with 63 additions and 70 deletions

View File

@ -33,9 +33,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
if (instType == null) if (instType == null)
{ {
if (RobloxFile.LogErrors) RobloxFile.LogError($"INST - Unknown class: {ClassName} while reading INST chunk.");
Console.Error.WriteLine($"INST - Unknown class: {ClassName} while reading INST chunk.");
return; return;
} }

View File

@ -33,17 +33,13 @@ namespace RobloxFiles.BinaryFormat.Chunks
if (child == null) if (child == null)
{ {
if (RobloxFile.LogErrors) RobloxFile.LogError($"PRNT: could not parent {childId} to {parentId} because child {childId} was null.");
Console.Error.WriteLine($"PRNT: could not parent {childId} to {parentId} because child {childId} was null.");
continue; continue;
} }
if (parentId >= 0 && parent == null) if (parentId >= 0 && parent == null)
{ {
if (RobloxFile.LogErrors) RobloxFile.LogError($"PRNT: could not parent {childId} to {parentId} because parent {parentId} was null.");
Console.Error.WriteLine($"PRNT: could not parent {childId} to {parentId} because parent {parentId} was null.");
continue; continue;
} }

View File

@ -58,9 +58,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
if (instance == null) if (instance == null)
{ {
if (RobloxFile.LogErrors) RobloxFile.LogError($"PROP: No instance @{id} for property {ClassName}.{Name}");
Console.Error.WriteLine($"PROP: No instance @{id} for property {ClassName}.{Name}");
continue; continue;
} }
@ -368,9 +366,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
if (info == null) if (info == null)
{ {
if (RobloxFile.LogErrors) RobloxFile.LogError($"Enum cast failed for {inst.ClassName}.{Name} using value {value}!");
Console.Error.WriteLine($"Enum cast failed for {inst.ClassName}.{Name} using value {value}!");
return value; return value;
} }
@ -378,9 +374,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
} }
catch catch
{ {
if (RobloxFile.LogErrors) RobloxFile.LogError($"Enum cast failed for {inst.ClassName}.{Name} using value {value}!");
Console.Error.WriteLine($"Enum cast failed for {inst.ClassName}.{Name} using value {value}!");
return value; return value;
} }
}); });
@ -545,9 +539,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
break; break;
default: default:
if (RobloxFile.LogErrors) RobloxFile.LogError($"Unhandled property type: {Type}!");
Console.Error.WriteLine("Unhandled property type: {0}!", Type);
break; break;
// //
} }

View File

@ -181,7 +181,7 @@ namespace RobloxFiles.DataTypes
internal CFrame(Attribute attr) internal CFrame(Attribute attr)
{ {
Vector3 pos = new Vector3(attr); Vector3 pos = new Vector3(attr);
byte rawOrientId = attr.readByte(); byte rawOrientId = attr.ReadByte();
if (rawOrientId > 0) if (rawOrientId > 0)
{ {

View File

@ -21,8 +21,8 @@ namespace RobloxFiles.DataTypes
internal Vector2int16(Attribute attr) internal Vector2int16(Attribute attr)
{ {
X = attr.readShort(); X = attr.ReadShort();
Y = attr.readShort(); Y = attr.ReadShort();
} }
private delegate Vector2int16 Operator(Vector2int16 a, Vector2int16 b); private delegate Vector2int16 Operator(Vector2int16 a, Vector2int16 b);

View File

@ -27,9 +27,9 @@ namespace RobloxFiles.DataTypes
internal Vector3int16(Attribute attr) internal Vector3int16(Attribute attr)
{ {
X = attr.readShort(); X = attr.ReadShort();
Y = attr.readShort(); Y = attr.ReadShort();
Z = attr.readShort(); Z = attr.ReadShort();
} }
private delegate Vector3int16 Operator(Vector3int16 a, Vector3int16 b); private delegate Vector3int16 Operator(Vector3int16 a, Vector3int16 b);

View File

@ -1,5 +1,5 @@
// Auto-generated list of creatable Roblox classes. // Auto-generated list of creatable Roblox classes.
// Updated as of 0.460.0.416222 // Updated as of 0.462.0.416719
using System; using System;
@ -732,6 +732,14 @@ namespace RobloxFiles
public Vector3 Torque_ = new Vector3(); public Vector3 Torque_ = new Vector3();
} }
public class UniversalConstraint : Constraint
{
public bool LimitsEnabled;
public float MaxAngle = 45;
public float Radius = 0.2f;
public float Restitution;
}
public class VectorForce : Constraint public class VectorForce : Constraint
{ {
public bool ApplyAtCenterOfMass; public bool ApplyAtCenterOfMass;

View File

@ -1,5 +1,5 @@
// Auto-generated list of Roblox enums. // Auto-generated list of Roblox enums.
// Updated as of 0.460.0.416222 // Updated as of 0.462.0.416719
namespace RobloxFiles.Enums namespace RobloxFiles.Enums
{ {

View File

@ -137,5 +137,17 @@ namespace RobloxFiles
{ {
return Task.Run(() => Save(filePath)); return Task.Run(() => Save(filePath));
} }
/// <summary>
/// Logs an error that occurred while opening a RobloxFile if logs are enabled.
/// </summary>
/// <param name="message"></param>
internal static void LogError(string message)
{
if (!LogErrors)
return;
Console.Error.WriteLine(message);
}
} }
} }

Binary file not shown.

View File

@ -57,9 +57,9 @@ namespace RobloxFiles
// internal BinaryWriter writer; // internal BinaryWriter writer;
internal int ReadInt() => reader.ReadInt32(); internal int ReadInt() => reader.ReadInt32();
internal byte readByte() => reader.ReadByte(); internal byte ReadByte() => reader.ReadByte();
internal bool readBool() => reader.ReadBoolean(); internal bool ReadBool() => reader.ReadBoolean();
internal short readShort() => reader.ReadInt16(); internal short ReadShort() => reader.ReadInt16();
internal float ReadFloat() => reader.ReadSingle(); internal float ReadFloat() => reader.ReadSingle();
internal double ReadDouble() => reader.ReadDouble(); internal double ReadDouble() => reader.ReadDouble();
internal string ReadString() => reader.ReadString(true); internal string ReadString() => reader.ReadString(true);
@ -103,14 +103,13 @@ namespace RobloxFiles
switch (DataType) switch (DataType)
{ {
//////////////////////////
case AttributeType.Null: case AttributeType.Null:
break; break;
case AttributeType.String: case AttributeType.String:
Value = ReadString(); Value = ReadString();
break; break;
case AttributeType.Bool: case AttributeType.Bool:
Value = readBool(); Value = ReadBool();
break; break;
case AttributeType.Int: case AttributeType.Int:
Value = ReadInt(); Value = ReadInt();
@ -185,7 +184,7 @@ namespace RobloxFiles
Value = new Rect(this); Value = new Rect(this);
break; break;
case AttributeType.PhysicalProperties: case AttributeType.PhysicalProperties:
bool custom = readBool(); bool custom = ReadBool();
if (custom) if (custom)
Value = new PhysicalProperties(this); Value = new PhysicalProperties(this);
@ -197,9 +196,7 @@ namespace RobloxFiles
case AttributeType.Region3int16: case AttributeType.Region3int16:
Value = new Region3int16(this); Value = new Region3int16(this);
break; break;
default: default: throw new InvalidDataException($"Cannot handle AttributeType {DataType}!");
throw new InvalidDataException($"Cannot handle AttributeType {DataType}!");
//////////////////////////
} }
reader = null; reader = null;

View File

@ -18,6 +18,7 @@ namespace RobloxFiles
public Instance() public Instance()
{ {
Name = ClassName; Name = ClassName;
RefreshProperties();
} }
/// <summary>The ClassName of this Instance.</summary> /// <summary>The ClassName of this Instance.</summary>
@ -506,12 +507,11 @@ namespace RobloxFiles
/// <param name="prop">A reference to the property that will be added.</param> /// <param name="prop">A reference to the property that will be added.</param>
internal void AddProperty(ref Property prop) internal void AddProperty(ref Property prop)
{ {
string name = prop.Name;
RemoveProperty(name);
prop.Instance = this; prop.Instance = this;
props.Add(name, prop);
if (props.ContainsKey(prop.Name))
props.Remove(prop.Name);
props.Add(prop.Name, prop);
} }
/// <summary> /// <summary>

View File

@ -211,10 +211,7 @@ namespace RobloxFiles
} }
else else
{ {
if (!RobloxFile.LogErrors) RobloxFile.LogError($"RobloxFiles.Property - Property {Instance.ClassName}.{Name} does not exist!");
return false;
Console.Error.WriteLine($"RobloxFiles.Property - Property {Instance.ClassName}.{Name} does not exist!");
} }
} }
} }
@ -248,10 +245,7 @@ namespace RobloxFiles
} }
catch catch
{ {
if (!RobloxFile.LogErrors) RobloxFile.LogError($"RobloxFiles.Property - Failed to cast value {value} into property {Instance.ClassName}.{Name}");
return;
Console.Error.WriteLine($"RobloxFiles.Property - Failed to cast value {value} into property {Instance.ClassName}.{Name}");
} }
} }
else if (valueType != null) else if (valueType != null)
@ -267,10 +261,7 @@ namespace RobloxFiles
} }
catch catch
{ {
if (!RobloxFile.LogErrors) RobloxFile.LogError($"RobloxFiles.Property - Failed to implicitly cast value {value} into property {Instance.ClassName}.{Name}");
return;
Console.Error.WriteLine($"RobloxFiles.Property - Failed to implicitly cast value {value} into property {Instance.ClassName}.{Name}");
} }
} }
} }

View File

@ -109,7 +109,7 @@ namespace RobloxFiles.XmlFormat
if (!tokenHandler.ReadProperty(prop, propNode) && RobloxFile.LogErrors) if (!tokenHandler.ReadProperty(prop, propNode) && RobloxFile.LogErrors)
{ {
var readError = error($"Could not read property: {prop.GetFullName()}!"); var readError = error($"Could not read property: {prop.GetFullName()}!");
Console.Error.WriteLine(readError.Message); RobloxFile.LogError(readError.Message);
} }
instance.AddProperty(ref prop); instance.AddProperty(ref prop);
@ -117,7 +117,7 @@ namespace RobloxFiles.XmlFormat
else if (RobloxFile.LogErrors) else if (RobloxFile.LogErrors)
{ {
var tokenError = error($"No {nameof(IXmlPropertyToken)} found for property type: {propType}!"); var tokenError = error($"No {nameof(IXmlPropertyToken)} found for property type: {propType}!");
Console.Error.WriteLine(tokenError.Message); RobloxFile.LogError(tokenError.Message);
} }
} }
} }
@ -142,7 +142,7 @@ namespace RobloxFiles.XmlFormat
if (RobloxFile.LogErrors) if (RobloxFile.LogErrors)
{ {
var typeError = error($"Unknown class {className} while reading Item."); var typeError = error($"Unknown class {className} while reading Item.");
Console.Error.WriteLine(typeError.Message); RobloxFile.LogError(typeError.Message);
} }
return null; return null;

View File

@ -94,9 +94,7 @@ namespace RobloxFiles.XmlFormat
if (handler == null) if (handler == null)
{ {
if (RobloxFile.LogErrors) RobloxFile.LogError($"XmlRobloxFileWriter.WriteProperty: No token handler found for property type: {propType}");
Console.Error.WriteLine("XmlDataWriter.WriteProperty: No token handler found for property type: {0}", propType);
return null; return null;
} }

View File

@ -30,10 +30,7 @@ namespace RobloxFiles.XmlFormat.PropertyTokens
} }
catch catch
{ {
if (!RobloxFile.LogErrors) RobloxFile.LogError($"ContentToken: Got illegal base64 string: {data}");
return true;
Console.Error.WriteLine("ContentToken: Got illegal base64 string: {0}", data);
} }
} }
} }

View File

@ -97,11 +97,7 @@ namespace RobloxFiles
} }
else if (refId != "null") else if (refId != "null")
{ {
string name = refProp.GetFullName(); LogError($"XmlRobloxFile: Could not resolve reference for {refProp.GetFullName()}");
if (LogErrors)
Console.Error.WriteLine("XmlRobloxFile: Could not resolve reference for {0}", name);
refProp.Value = null; refProp.Value = null;
} }
} }
@ -112,6 +108,14 @@ namespace RobloxFiles
foreach (Property sharedProp in sharedProps) foreach (Property sharedProp in sharedProps)
{ {
SharedString shared = sharedProp.CastValue<SharedString>(); SharedString shared = sharedProp.CastValue<SharedString>();
if (shared == null)
{
var nullBuffer = Array.Empty<byte>();
shared = SharedString.FromBuffer(nullBuffer);
sharedProp.Value = shared;
}
SharedStrings.Add(shared.Key); SharedStrings.Add(shared.Key);
} }
} }