Skip to content

Commit

Permalink
Add support for OptionalProperty in Usmap parser
Browse files Browse the repository at this point in the history
  • Loading branch information
hypermodule committed Jan 5, 2025
1 parent 3d259eb commit 481c3e3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions UAssetAPI.Tests/AssetUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,18 @@ public void TestRepak()
}
}

/// <summary>
/// In this test, we parse a .usmap containing an OptionalProperty (as currently produced by Dumper-7) to verify compatibility.
/// </summary>
[TestMethod]
public void TestUsmapWithOptionalProperty()
{
var usmap = new Usmap(Path.Combine("TestAssets", "TestUE5_4", "BlankGame", "BlankGame_Dumper-7.usmap"));
Assert.AreEqual(31948, usmap.NameMap.Count);
Assert.AreEqual(1565, usmap.EnumMap.Count);
Assert.AreEqual(7657, usmap.Schemas.Count);
}

public static MemoryStream PathToStream(string p)
{
using (FileStream origStream = File.Open(p, FileMode.Open, new FileInfo(p).IsReadOnly ? FileAccess.Read : FileAccess.ReadWrite))
Expand Down
Binary file not shown.
3 changes: 3 additions & 0 deletions UAssetAPI.Tests/UAssetAPI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,8 @@
<None Update="TestAssets\TestManyAssets\SnakePass\MP00_Intro.uasset">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestAssets\TestUE5_4\BlankGame\BlankGame_Dumper-7.usmap">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions UAssetAPI/Unversioned/Usmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public enum EPropertyType
SetProperty,
EnumProperty,
FieldPathProperty,
OptionalProperty,
Utf8StrProperty,
AnsiStrProperty,

Unknown = 0xFF
};
Expand Down Expand Up @@ -906,6 +909,7 @@ private UsmapPropertyData InitPropData(EPropertyType typ)
return new UsmapStructData();
case EPropertyType.SetProperty:
case EPropertyType.ArrayProperty:
case EPropertyType.OptionalProperty:
return new UsmapArrayData(typ);
case EPropertyType.MapProperty:
return new UsmapMapData();
Expand All @@ -928,6 +932,7 @@ private UsmapPropertyData DeserializePropData(UsmapBinaryReader reader)
break;
case EPropertyType.SetProperty:
case EPropertyType.ArrayProperty:
case EPropertyType.OptionalProperty:
((UsmapArrayData)res).InnerType = DeserializePropData(reader);
break;
case EPropertyType.MapProperty:
Expand Down

0 comments on commit 481c3e3

Please sign in to comment.