Correct UniqueId/FontFace implementations.

This commit is contained in:
Max
2022-10-12 21:19:43 -05:00
parent 583d69713d
commit 619b89d2a9
17 changed files with 3045 additions and 2687 deletions

View File

@ -66,9 +66,9 @@ namespace RobloxFiles.Tokens
var style = (FontWeight)attribute.ReadByte();
var family = attribute.ReadString();
_ = attribute.ReadInt(); // Reserved
var cachedFaceId = attribute.ReadString();
return new FontFace(family, style, weight);
return new FontFace(family, style, weight, cachedFaceId);
}
public void WriteAttribute(RbxAttribute attribute, FontFace value)

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Xml;
using RobloxFiles.DataTypes;
@ -14,13 +15,21 @@ namespace RobloxFiles.Tokens
if (Guid.TryParse(hex, out var guid))
{
var bytes = guid.ToByteArray();
var random = BitConverter.ToUInt64(bytes, 0);
var bytes = new byte[16];
var time = BitConverter.ToUInt32(bytes, 8);
var index = BitConverter.ToUInt32(bytes, 12);
for (int i = 0; i < 16; i++)
{
var hexChar = hex.Substring(i * 2, 2);
bytes[15 - i] = Convert.ToByte(hexChar, 16);
}
var rand = BitConverter.ToInt64(bytes, 8);
var time = BitConverter.ToUInt32(bytes, 4);
var index = BitConverter.ToUInt32(bytes, 0);
var uniqueId = new UniqueId(rand, time, index);
prop.Value = uniqueId;
prop.Value = new UniqueId(time, index, random);
return true;
}
@ -30,8 +39,8 @@ namespace RobloxFiles.Tokens
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node)
{
var uniqueId = prop.CastValue<UniqueId>();
var random = BitConverter.GetBytes(uniqueId.Random);
var random = BitConverter.GetBytes(uniqueId.Random);
var time = BitConverter.GetBytes(uniqueId.Time);
var index = BitConverter.GetBytes(uniqueId.Index);