0.454.0.413308
This commit is contained in:
@ -28,6 +28,17 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
NumInstances = reader.ReadInt32();
|
||||
InstanceIds = reader.ReadInstanceIds(NumInstances);
|
||||
|
||||
Type instType = Type.GetType($"RobloxFiles.{ClassName}");
|
||||
file.Classes[ClassIndex] = this;
|
||||
|
||||
if (instType == null)
|
||||
{
|
||||
if (RobloxFile.LogErrors)
|
||||
Console.Error.WriteLine($"INST - Unknown class: {ClassName} while reading INST chunk.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsService)
|
||||
{
|
||||
RootedServices = new List<bool>();
|
||||
@ -42,8 +53,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
for (int i = 0; i < NumInstances; i++)
|
||||
{
|
||||
int instId = InstanceIds[i];
|
||||
Type instType = Type.GetType($"RobloxFiles.{ClassName}") ?? typeof(Instance);
|
||||
|
||||
|
||||
var inst = Activator.CreateInstance(instType) as Instance;
|
||||
inst.Referent = instId.ToString();
|
||||
inst.IsService = IsService;
|
||||
@ -56,8 +66,6 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
|
||||
file.Instances[instId] = inst;
|
||||
}
|
||||
|
||||
file.Classes[ClassIndex] = this;
|
||||
}
|
||||
|
||||
public void Save(BinaryRobloxFileWriter writer)
|
||||
|
@ -29,6 +29,24 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
int parentId = parentIds[i];
|
||||
|
||||
Instance child = file.Instances[childId];
|
||||
Instance parent = (parentId >= 0 ? file.Instances[parentId] : file);
|
||||
|
||||
if (child == null)
|
||||
{
|
||||
if (RobloxFile.LogErrors)
|
||||
Console.Error.WriteLine($"PRNT: could not parent {childId} to {parentId} because child {childId} was null.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (parentId >= 0 && parent == null)
|
||||
{
|
||||
if (RobloxFile.LogErrors)
|
||||
Console.Error.WriteLine($"PRNT: could not parent {childId} to {parentId} because parent {parentId} was null.");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
child.Parent = (parentId >= 0 ? file.Instances[parentId] : file);
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,14 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
int id = ids[i];
|
||||
Instance instance = file.Instances[id];
|
||||
|
||||
if (instance == null)
|
||||
{
|
||||
if (RobloxFile.LogErrors)
|
||||
Console.Error.WriteLine($"PROP: No instance @{id} for property {ClassName}.{Name}");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
Property prop = new Property(instance, this);
|
||||
props[i] = prop;
|
||||
|
||||
@ -71,6 +79,10 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
for (int i = 0; i < instCount; i++)
|
||||
{
|
||||
var prop = props[i];
|
||||
|
||||
if (prop == null)
|
||||
continue;
|
||||
|
||||
prop.Value = read(i);
|
||||
}
|
||||
});
|
||||
@ -593,9 +605,9 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
foreach (int instId in inst.InstanceIds)
|
||||
{
|
||||
Instance instance = file.Instances[instId];
|
||||
Property prop = instance.Properties[Name];
|
||||
var instProps = instance.Properties;
|
||||
|
||||
if (prop == null)
|
||||
if (!instProps.TryGetValue(Name, out Property prop))
|
||||
throw new Exception($"Property {Name} must be defined in {instance.GetFullName()}!");
|
||||
else if (prop.Type != Type)
|
||||
throw new Exception($"Property {Name} is not using the correct type in {instance.GetFullName()}!");
|
||||
|
Reference in New Issue
Block a user