Skip to content

Commit

Permalink
sanity check in FFieldPath constructor (for kismet to fail nicely)
Browse files Browse the repository at this point in the history
  • Loading branch information
atenfyr committed Jan 19, 2025
1 parent b7d2637 commit 8f3735e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion UAssetAPI/AssetBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public KismetPropertyPointer XFER_PROP_POINTER()
allNames[i] = this.ReadFName();
}
FPackageIndex owner = this.XFER_OBJECT_POINTER();
return new KismetPropertyPointer(new FFieldPath(allNames, owner));
return new KismetPropertyPointer(new FFieldPath(allNames, owner, this.Asset.Exports.Count));
}
else
{
Expand Down
14 changes: 13 additions & 1 deletion UAssetAPI/Kismet/Bytecode/EExprToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,19 @@ public enum EExprToken
/// <summary>Sparse data variable</summary>
EX_ClassSparseDataVariable = 0x6C,
EX_FieldPathConst = 0x6D,
EX_Max = 0x100,
/// <summary>
/// AutoRTFM: run following code in a transaction
/// </summary>
EX_AutoRtfmTransact = 0x70,
/// <summary>
/// AutoRTFM: if in a transaction, abort or break, otherwise no operation
/// </summary>
EX_AutoRtfmStopTransact = 0x71,
/// <summary>
/// AutoRTFM: evaluate bool condition, abort transaction on false
/// </summary>
EX_AutoRtfmAbortIfNot = 0x72,
EX_Max = 0xFF
};

public enum ECastToken {
Expand Down
7 changes: 4 additions & 3 deletions UAssetAPI/UnrealTypes/FFieldPath.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Newtonsoft.Json;
using UAssetAPI.UnrealTypes;
using UAssetAPI.ExportTypes;
using System;

namespace UAssetAPI.UnrealTypes
Expand All @@ -20,10 +18,13 @@ public class FFieldPath
[JsonProperty]
public FPackageIndex ResolvedOwner;

public FFieldPath(FName[] path, FPackageIndex resolvedOwner)
public FFieldPath(FName[] path, FPackageIndex resolvedOwner, int numExports = -1)
{
Path = path;
ResolvedOwner = resolvedOwner;

// sanity check: throw if makes no sense
if (numExports > 0 && ResolvedOwner.Index > numExports) throw new FormatException("Received nonsensical FFieldPath ResolvedOwner: " + ResolvedOwner.Index);
}

public FFieldPath()
Expand Down

0 comments on commit 8f3735e

Please sign in to comment.