Skip to content

Commit

Permalink
SkipParsingExports should instead read all exports as rawexport
Browse files Browse the repository at this point in the history
  • Loading branch information
atenfyr committed Dec 10, 2024
1 parent fa03826 commit a9dd131
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions UAssetAPI/UAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum CustomSerializationFlags : int
SkipPreloadDependencyLoading = 4,

/// <summary>
/// Skip parsing exports at read time. Entries in the export map will still be converted to their respective sub-types. You can manually parse exports with the <see cref="UnrealPackage.ParseExport(AssetBinaryReader, int)"/> method.
/// Skip parsing exports at read time. Entries in the export map will be read as raw exports. You can manually parse exports with the <see cref="UnrealPackage.ParseExport(AssetBinaryReader, int)"/> method.
/// </summary>
SkipParsingExports = 8
}
Expand Down Expand Up @@ -1057,8 +1057,10 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in
}
}

if (reader.LoadUexp && !CustomSerializationFlags.HasFlag(CustomSerializationFlags.SkipParsingExports))
if (reader.LoadUexp)
{
bool skipParsingExports = CustomSerializationFlags.HasFlag(CustomSerializationFlags.SkipParsingExports);

// load dependencies, if needed and available
Dictionary<int, IList<int>> depsMap = new Dictionary<int, IList<int>>();
for (int i = 0; i < Exports.Count; i++)
Expand Down Expand Up @@ -1099,7 +1101,7 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in
int i = exportIdx - 1;

reader.BaseStream.Seek(Exports[i].SerialOffset, SeekOrigin.Begin);
if (manualSkips != null && manualSkips.Contains(i) && (forceReads == null || !forceReads.Contains(i)))
if (skipParsingExports || (manualSkips != null && manualSkips.Contains(i) && (forceReads == null || !forceReads.Contains(i))))
{
Exports[i] = Exports[i].ConvertToChildExport<RawExport>();
((RawExport)Exports[i]).Data = reader.ReadBytes((int)Exports[i].SerialSize);
Expand All @@ -1115,7 +1117,7 @@ public override void Read(AssetBinaryReader reader, int[] manualSkips = null, in
if (Exports[i].alreadySerialized) continue;

reader.BaseStream.Seek(Exports[i].SerialOffset, SeekOrigin.Begin);
if (manualSkips != null && manualSkips.Contains(i) && (forceReads == null || !forceReads.Contains(i)))
if (skipParsingExports || (manualSkips != null && manualSkips.Contains(i) && (forceReads == null || !forceReads.Contains(i))))
{
Exports[i] = Exports[i].ConvertToChildExport<RawExport>();
((RawExport)Exports[i]).Data = reader.ReadBytes((int)Exports[i].SerialSize);
Expand Down
2 changes: 1 addition & 1 deletion UAssetAPI/UnrealPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ internal string InternalAssetPath
/// </summary>
/// <param name="reader">The binary reader.</param>
/// <param name="i">The index of the export in the export map to read.</param>
/// <param name="read">Whether or not to serialize the body of the export. If false, simply convert to the respective sub-type.</param>
/// <param name="read">Whether or not to serialize the body of the export. If false, simply converts to the respective sub-type.</param>
public void ParseExport(AssetBinaryReader reader, int i, bool read = true)
{
#pragma warning disable CS0168 // Variable is declared but never used
Expand Down

0 comments on commit a9dd131

Please sign in to comment.