diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt index 19f2f21a..2ee4dc26 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt @@ -4,6 +4,7 @@ import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.expr.BinaryExpr import com.github.javaparser.ast.expr.Expression import com.github.javaparser.ast.expr.IntegerLiteralExpr +import com.github.javaparser.ast.expr.LiteralExpr import com.github.javaparser.ast.expr.LongLiteralExpr import com.github.javaparser.ast.expr.UnaryExpr import dev.openrs2.deob.ast.Library @@ -48,6 +49,15 @@ class AddSubTransformer : Transformer() { return@Comparator -1 } + // push literals to the right + val aLiteral = a is LiteralExpr + val bLiteral = b is LiteralExpr + if (aLiteral && !bLiteral) { + return@Comparator 1 + } else if (!aLiteral && bLiteral) { + return@Comparator -1 + } + return@Comparator 0 })