diff --git a/src/ByteCodeDecompiler.cs b/src/ByteCodeDecompiler.cs index 7ad1634c..66dd0f83 100644 --- a/src/ByteCodeDecompiler.cs +++ b/src/ByteCodeDecompiler.cs @@ -188,7 +188,7 @@ private void AlignObjectSize() { 0x44, (byte)ExprToken.PrimitiveCast }, { 0x45, (byte)ExprToken.GlobalFunction }, { 0x46, (byte)ExprToken.VectorConst }, - { 0x47, (byte)ExprToken.RotatorConst }, + { 0x47, (byte)ExprToken.RotationConst }, { 0x48, (byte)ExprToken.Unused }, { 0x49, (byte)ExprToken.Unused }, { 0x4A, (byte)ExprToken.Unused }, @@ -252,7 +252,7 @@ private void AlignObjectSize() { 0x23, (byte)ExprToken.IntZero }, { 0x24, (byte)ExprToken.ObjectConst }, { 0x25, (byte)ExprToken.ByteConst }, - { 0x26, (byte)ExprToken.RotatorConst }, + { 0x26, (byte)ExprToken.RotationConst }, { 0x27, (byte)ExprToken.False }, { 0x28, (byte)ExprToken.True }, { 0x29, (byte)ExprToken.NoObject }, @@ -416,7 +416,7 @@ private byte FixToken(byte tokenCode) if (Package.Version >= 184 && ( - tokenCode >= (byte)ExprToken.Unused35 && tokenCode < (byte)ExprToken.ReturnNothing + tokenCode >= (byte)ExprToken.RangeConst && tokenCode < (byte)ExprToken.ReturnNothing || tokenCode > (byte)ExprToken.NoDelegate && tokenCode < (byte)ExprToken.ExtendedNative) ) ++tokenCode; @@ -983,14 +983,18 @@ private Token DeserializeNext(byte tokenCode = byte.MaxValue) token = new UniStringConstToken(); break; - case (byte)ExprToken.RotatorConst: - token = new RotatorConstToken(); + case (byte)ExprToken.RotationConst: + token = new RotationConstToken(); break; case (byte)ExprToken.VectorConst: token = new VectorConstToken(); break; + case (byte)ExprToken.RangeConst: + token = new RangeConstToken(); + break; + #endregion #region Functions diff --git a/src/Core/Tokens/ConstTokens.cs b/src/Core/Tokens/ConstTokens.cs index fe9f2f30..731362e2 100644 --- a/src/Core/Tokens/ConstTokens.cs +++ b/src/Core/Tokens/ConstTokens.cs @@ -230,7 +230,7 @@ public override string Decompile() } } - public class RotatorConstToken : Token + public class RotationConstToken : Token { public struct Rotator { @@ -276,6 +276,25 @@ public override string Decompile() $"vect({PropertyDisplay.FormatLiteral(X)}, {PropertyDisplay.FormatLiteral(Y)}, {PropertyDisplay.FormatLiteral(Z)})"; } } + + public class RangeConstToken : Token + { + public float A, B; + + public override void Deserialize(IUnrealStream stream) + { + A = stream.UR.ReadSingle(); + Decompiler.AlignSize(sizeof(float)); + B = stream.UR.ReadSingle(); + Decompiler.AlignSize(sizeof(float)); + } + + public override string Decompile() + { + return + $"rng({PropertyDisplay.FormatLiteral(A)}, {PropertyDisplay.FormatLiteral(B)})"; + } + } } } } \ No newline at end of file diff --git a/src/UnrealTokens.cs b/src/UnrealTokens.cs index 18964050..e678152f 100644 --- a/src/UnrealTokens.cs +++ b/src/UnrealTokens.cs @@ -61,8 +61,7 @@ public enum ExprToken : ushort StringConst = 0x1F, // "String" ObjectConst = 0x20, NameConst = 0x21, // 'Name' - // RotationConst - RotatorConst = 0x22, + RotationConst = 0x22, VectorConst = 0x23, ByteConst = 0x24, IntZero = 0x25, @@ -91,9 +90,10 @@ public enum ExprToken : ushort #region FixedByteCodes /// /// UE1: ??? - /// UE2: Deprecated (Bad Expr Token) + /// UE2: RangeConst or Deprecated (Bad Expr Token) + /// UE3: ??? /// - Unused35 = 0x35, + RangeConst = 0x35, StructMember = 0x36, // Struct.Property DynArrayLength = 0x37, // ARRAY.Length GlobalFunction = 0x38, // Global.