Bug fixes, debug tools for binary chunks.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
{
|
||||
@ -79,5 +80,18 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteInfo(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine($"- ClassIndex: {ClassIndex}");
|
||||
builder.AppendLine($"- ClassName: {ClassName}");
|
||||
builder.AppendLine($"- IsService: {IsService}");
|
||||
|
||||
if (IsService && RootedServices != null)
|
||||
builder.AppendLine($"- RootedServices: `{string.Join(", ", RootedServices)}`");
|
||||
|
||||
builder.AppendLine($"- NumInstances: {NumInstances}");
|
||||
builder.AppendLine($"- InstanceIds: `{string.Join(", ", InstanceIds)}`");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
{
|
||||
@ -31,5 +32,18 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
writer.WriteString(pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteInfo(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine($"- NumEntries: {Data.Count}");
|
||||
|
||||
foreach (var pair in Data)
|
||||
{
|
||||
string key = pair.Key,
|
||||
value = pair.Value;
|
||||
|
||||
builder.AppendLine($" - {key}: {value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
{
|
||||
public class PRNT : IBinaryFileChunk
|
||||
{
|
||||
private const byte FORMAT = 0;
|
||||
private BinaryRobloxFile File;
|
||||
|
||||
public void Load(BinaryRobloxFileReader reader)
|
||||
{
|
||||
BinaryRobloxFile file = reader.File;
|
||||
File = file;
|
||||
|
||||
byte format = reader.ReadByte();
|
||||
int idCount = reader.ReadInt32();
|
||||
@ -32,6 +35,9 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
|
||||
public void Save(BinaryRobloxFileWriter writer)
|
||||
{
|
||||
var file = writer.File;
|
||||
File = file;
|
||||
|
||||
var postInstances = writer.PostInstances;
|
||||
var idCount = postInstances.Count;
|
||||
|
||||
@ -58,5 +64,29 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
writer.WriteInstanceIds(childIds);
|
||||
writer.WriteInstanceIds(parentIds);
|
||||
}
|
||||
|
||||
public void WriteInfo(StringBuilder builder)
|
||||
{
|
||||
var childIds = new List<int>();
|
||||
var parentIds = new List<int>();
|
||||
|
||||
foreach (Instance inst in File.GetDescendants())
|
||||
{
|
||||
Instance parent = inst.Parent;
|
||||
|
||||
int childId = int.Parse(inst.Referent);
|
||||
int parentId = -1;
|
||||
|
||||
if (parent != null)
|
||||
parentId = int.Parse(parent.Referent);
|
||||
|
||||
childIds.Add(childId);
|
||||
parentIds.Add(parentId);
|
||||
}
|
||||
|
||||
builder.AppendLine($"- Format: {FORMAT}");
|
||||
builder.AppendLine($"- ChildIds: {string.Join(", ", childIds)}");
|
||||
builder.AppendLine($"- ParentIds: {string.Join(", ", parentIds)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,15 @@ using System.Text;
|
||||
|
||||
using RobloxFiles.Enums;
|
||||
using RobloxFiles.DataTypes;
|
||||
using RobloxFiles.Utility;
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
{
|
||||
public class PROP : IBinaryFileChunk
|
||||
{
|
||||
private BinaryRobloxFile File;
|
||||
public string Name { get; internal set; }
|
||||
|
||||
public int ClassIndex { get; internal set; }
|
||||
@ -33,6 +36,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
public void Load(BinaryRobloxFileReader reader)
|
||||
{
|
||||
BinaryRobloxFile file = reader.File;
|
||||
File = file;
|
||||
|
||||
ClassIndex = reader.ReadInt32();
|
||||
Name = reader.ReadString();
|
||||
@ -87,28 +91,32 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
// Check if this is going to be casted as a BinaryString.
|
||||
// BinaryStrings should use a type of byte[] instead.
|
||||
|
||||
if (Name == "AttributesSerialize")
|
||||
return buffer;
|
||||
|
||||
Property prop = props[i];
|
||||
Instance instance = prop.Instance;
|
||||
|
||||
Type instType = instance.GetType();
|
||||
FieldInfo field = instType.GetField(Name);
|
||||
|
||||
if (field != null)
|
||||
switch (Name)
|
||||
{
|
||||
object result = value;
|
||||
Type fieldType = field.FieldType;
|
||||
case "Tags":
|
||||
case "AttributesSerialize":
|
||||
return buffer;
|
||||
default:
|
||||
{
|
||||
Property prop = props[i];
|
||||
Instance instance = prop.Instance;
|
||||
|
||||
if (fieldType == typeof(byte[]))
|
||||
result = buffer;
|
||||
Type instType = instance.GetType();
|
||||
var member = ImplicitMember.Get(instType, Name);
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return value;
|
||||
if (member != null)
|
||||
{
|
||||
object result = value;
|
||||
Type memberType = member.MemberType;
|
||||
|
||||
if (memberType == typeof(byte[]))
|
||||
result = buffer;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -345,8 +353,8 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
|
||||
try
|
||||
{
|
||||
FieldInfo info = instType.GetField(Name, Property.BindingFlags);
|
||||
return Enum.Parse(info.FieldType, value.ToInvariantString());
|
||||
var info = ImplicitMember.Get(instType, Name);
|
||||
return Enum.Parse(info.MemberType, value.ToInvariantString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -362,12 +370,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
readProperties(i =>
|
||||
{
|
||||
int instId = instIds[i];
|
||||
Instance result = null;
|
||||
|
||||
if (instId >= 0)
|
||||
result = file.Instances[instId];
|
||||
|
||||
return result;
|
||||
return instId >= 0 ? file.Instances[instId] : null;
|
||||
});
|
||||
|
||||
break;
|
||||
@ -540,6 +543,12 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
|
||||
foreach (string propName in props.Keys)
|
||||
{
|
||||
if (propName == "Archivable")
|
||||
continue;
|
||||
|
||||
if (propName.Contains("__"))
|
||||
continue;
|
||||
|
||||
if (!propMap.ContainsKey(propName))
|
||||
{
|
||||
Property prop = props[propName];
|
||||
@ -549,6 +558,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
Name = prop.Name,
|
||||
Type = prop.Type,
|
||||
|
||||
ClassName = inst.ClassName,
|
||||
ClassIndex = inst.ClassIndex
|
||||
};
|
||||
|
||||
@ -563,6 +573,7 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
public void Save(BinaryRobloxFileWriter writer)
|
||||
{
|
||||
BinaryRobloxFile file = writer.File;
|
||||
File = file;
|
||||
|
||||
INST inst = file.Classes[ClassIndex];
|
||||
var props = new List<Property>();
|
||||
@ -1054,5 +1065,40 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteInfo(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine($"- Name: {Name}");
|
||||
builder.AppendLine($"- Type: {Type}");
|
||||
builder.AppendLine($"- TypeId: {TypeId}");
|
||||
builder.AppendLine($"- ClassName: {ClassName}");
|
||||
builder.AppendLine($"- ClassIndex: {ClassIndex}");
|
||||
|
||||
builder.AppendLine($"| InstanceId | Value |");
|
||||
builder.AppendLine($"|-----------:|---------------------------|");
|
||||
|
||||
INST inst = File.Classes[ClassIndex];
|
||||
|
||||
foreach (var instId in inst.InstanceIds)
|
||||
{
|
||||
Instance instance = File.Instances[instId];
|
||||
Property prop = instance?.GetProperty(Name);
|
||||
|
||||
object value = prop?.Value;
|
||||
string str = value?.ToInvariantString() ?? "null";
|
||||
|
||||
if (value is byte[])
|
||||
str = Convert.ToBase64String(value as byte[]);
|
||||
|
||||
if (str.Length > 25)
|
||||
str = str.Substring(0, 22) + "...";
|
||||
|
||||
str = str.Replace('\r', ' ');
|
||||
str = str.Replace('\n', ' ');
|
||||
|
||||
string row = string.Format("| {0, 10} | {1, -25} |", instId, str);
|
||||
builder.AppendLine(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
{
|
||||
public struct Signature
|
||||
{
|
||||
@ -52,5 +55,29 @@
|
||||
writer.Write(signature.Data);
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteInfo(StringBuilder builder)
|
||||
{
|
||||
int numSignatures = Signatures.Length;
|
||||
builder.AppendLine($"NumSignatures: {numSignatures}");
|
||||
|
||||
for (int i = 0; i < numSignatures; i++)
|
||||
{
|
||||
var signature = Signatures[i];
|
||||
builder.AppendLine($"## Signature {i}");
|
||||
|
||||
var version = signature.Version;
|
||||
builder.AppendLine($"- Version: {version}");
|
||||
|
||||
var id = signature.Id;
|
||||
builder.AppendLine($"- Id: {id}");
|
||||
|
||||
var length = signature.Length;
|
||||
builder.AppendLine($"- Length: {length}");
|
||||
|
||||
var data = Convert.ToBase64String(signature.Data);
|
||||
builder.AppendLine($"- Data: {data}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using RobloxFiles.DataTypes;
|
||||
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
@ -55,5 +57,19 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
||||
writer.Write(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteInfo(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine($"Format: {FORMAT}");
|
||||
builder.AppendLine($"NumStrings: {Lookup.Count}");
|
||||
|
||||
builder.AppendLine($"## Keys");
|
||||
|
||||
foreach (var pair in Lookup)
|
||||
{
|
||||
string key = pair.Key;
|
||||
builder.AppendLine($"- `{key}`");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user