Skip to content

Commit

Permalink
add usmap SkipBlueprintSchemas for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
atenfyr committed Jun 23, 2024
1 parent df994ee commit f06dc28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion UAssetAPI.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public static void Run(string[] args)
if (Path.GetExtension(assetPath) == ".usmap")
{
timer.Start();
mappings = new Usmap(assetPath);
mappings = new Usmap();
mappings.SkipBlueprintSchemas = true;
mappings.Read(mappings.PathToReader(assetPath));
timer.Stop();
Console.WriteLine("Mappings parsed in " + NumberToTwoDecimalPlaces(timer.Elapsed.TotalMilliseconds) + " ms");
break;
Expand Down
16 changes: 13 additions & 3 deletions UAssetAPI/Unversioned/Usmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ public bool AreFNamesCaseInsensitive
}
}

/// <summary>
/// Whether or not to skip blueprint schemas serialized in this mappings file. Only useful for testing.
/// </summary>
public bool SkipBlueprintSchemas = false;

/// <summary>
/// .usmap name map
/// </summary>
Expand Down Expand Up @@ -612,7 +617,7 @@ public bool TryGetPropertyData<T>(FName propertyName, AncestryInfo ancestry, Unr
/// </summary>
/// <param name="p">The path to the input file.</param>
/// <returns>A new MemoryStream that stores the binary data of the input file.</returns>
public MemoryStream PathToStream(string p)
public static MemoryStream PathToStream(string p)
{
using (FileStream origStream = File.Open(p, FileMode.Open))
{
Expand Down Expand Up @@ -802,6 +807,11 @@ public void Read(UsmapBinaryReader compressedReader)
}
}

if (SkipBlueprintSchemas && schemaName.Length >= 2 && schemaName.EndsWith("_C"))
{
continue;
}

var newSchema = new UsmapSchema(schemaName, schemaSuperName, numProps, props);
schemaIndexMap[i] = newSchema;
Schemas[schemaName] = newSchema;
Expand Down Expand Up @@ -943,9 +953,9 @@ public Usmap(string path)
}

/// <summary>
/// Reads a .usmap file from a BinaryReader and initializes a new instance of the <see cref="Usmap"/> class to store its data in memory.
/// Reads a .usmap file from a UsmapBinaryReader and initializes a new instance of the <see cref="Usmap"/> class to store its data in memory.
/// </summary>
/// <param name="reader">The file's BinaryReader that this instance will read from.</param>
/// <param name="reader">The file's UsmapBinaryReader that this instance will read from.</param>
/// <exception cref="FormatException">Throw when the asset cannot be parsed correctly.</exception>
public Usmap(UsmapBinaryReader reader)
{
Expand Down

0 comments on commit f06dc28

Please sign in to comment.