mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-20 15:44:22 +01:00
Fix havok parsing for non-ANSI user paths
Also improve parsing because otter is better at c# than me
This commit is contained in:
parent
cc2f72b73d
commit
1bc3bb17c9
2 changed files with 6 additions and 9 deletions
|
|
@ -71,8 +71,7 @@ public static unsafe class HavokConverter
|
||||||
/// <param name="filePath"> Path to a file on the filesystem. </param>
|
/// <param name="filePath"> Path to a file on the filesystem. </param>
|
||||||
private static hkResource* Read(string filePath)
|
private static hkResource* Read(string filePath)
|
||||||
{
|
{
|
||||||
var path = Marshal.StringToHGlobalAnsi(filePath);
|
var path = Encoding.UTF8.GetBytes(filePath);
|
||||||
|
|
||||||
var builtinTypeRegistry = hkBuiltinTypeRegistry.Instance();
|
var builtinTypeRegistry = hkBuiltinTypeRegistry.Instance();
|
||||||
|
|
||||||
var loadOptions = stackalloc hkSerializeUtil.LoadOptions[1];
|
var loadOptions = stackalloc hkSerializeUtil.LoadOptions[1];
|
||||||
|
|
@ -81,8 +80,7 @@ public static unsafe class HavokConverter
|
||||||
loadOptions->TypeInfoRegistry = builtinTypeRegistry->GetTypeInfoRegistry();
|
loadOptions->TypeInfoRegistry = builtinTypeRegistry->GetTypeInfoRegistry();
|
||||||
|
|
||||||
// TODO: probably can use LoadFromBuffer for this.
|
// TODO: probably can use LoadFromBuffer for this.
|
||||||
var resource = hkSerializeUtil.LoadFromFile((byte*)path, null, loadOptions);
|
return hkSerializeUtil.LoadFromFile(path, null, loadOptions);
|
||||||
return resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Serializes an hkResource* to a temporary file. </summary>
|
/// <summary> Serializes an hkResource* to a temporary file. </summary>
|
||||||
|
|
@ -94,9 +92,9 @@ public static unsafe class HavokConverter
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var tempFile = CreateTempFile();
|
var tempFile = CreateTempFile();
|
||||||
var path = Marshal.StringToHGlobalAnsi(tempFile);
|
var path = Encoding.UTF8.GetBytes(tempFile);
|
||||||
var oStream = new hkOstream();
|
var oStream = new hkOstream();
|
||||||
oStream.Ctor((byte*)path);
|
oStream.Ctor(path);
|
||||||
|
|
||||||
var result = stackalloc hkResult[1];
|
var result = stackalloc hkResult[1];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,8 @@ public static class SkeletonConverter
|
||||||
.Where(n => n.NodeType != XmlNodeType.Comment)
|
.Where(n => n.NodeType != XmlNodeType.Comment)
|
||||||
.Select(n =>
|
.Select(n =>
|
||||||
{
|
{
|
||||||
var text = n.InnerText.Trim()[1..];
|
var text = n.InnerText.AsSpan().Trim()[1..];
|
||||||
// TODO: surely there's a less shit way to do this I mean seriously
|
return BitConverter.Int32BitsToSingle(int.Parse(text, NumberStyles.HexNumber));
|
||||||
return BitConverter.ToSingle(BitConverter.GetBytes(int.Parse(text, NumberStyles.HexNumber)));
|
|
||||||
})
|
})
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue