diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/If0.java b/src/main/java/net/runelite/deob/attributes/code/instructions/If0.java index c43eb7694a..865ebee32f 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/If0.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/If0.java @@ -105,7 +105,8 @@ public abstract class If0 extends Instruction implements JumpingInstruction, Com // we can map these if they are getfield instructions? - assert ctx.getInstruction().getClass().equals(other.getInstruction().getClass()); + // this is already checked before this + //assert ctx.getInstruction().getClass().equals(other.getInstruction().getClass()); Frame branch1 = ctx.getBranches().get(0), branch2 = other.getBranches().get(0); diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IfNe.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IfNe.java index 4b5fcc1620..b8ebe87fba 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IfNe.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IfNe.java @@ -3,7 +3,9 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; import net.runelite.deob.attributes.code.instruction.types.MappableInstruction; +import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction; import net.runelite.deob.execution.InstructionContext; +import net.runelite.deob.execution.StackContext; public class IfNe extends If0 { @@ -21,6 +23,29 @@ public class IfNe extends If0 if (otherIc.getInstruction() instanceof IfCmpNe) { // check for one side being 0 + StackContext s1 = otherIc.getPops().get(0), + s2 = otherIc.getPops().get(1); + + if (s1.getPushed().getInstruction() instanceof PushConstantInstruction) + { + PushConstantInstruction pci = (PushConstantInstruction) s1.getPushed().getInstruction(); + Object o = pci.getConstant().getObject(); + + if (o.equals(0)) + { + return true; + } + } + if (s2.getPushed().getInstruction() instanceof PushConstantInstruction) + { + PushConstantInstruction pci = (PushConstantInstruction) s2.getPushed().getInstruction(); + Object o = pci.getConstant().getObject(); + + if (o.equals(0)) + { + return true; + } + } } return false; diff --git a/src/main/java/net/runelite/deob/attributes/code/instructions/IfNull.java b/src/main/java/net/runelite/deob/attributes/code/instructions/IfNull.java index c17aeb76ed..239ace8a75 100644 --- a/src/main/java/net/runelite/deob/attributes/code/instructions/IfNull.java +++ b/src/main/java/net/runelite/deob/attributes/code/instructions/IfNull.java @@ -2,6 +2,8 @@ package net.runelite.deob.attributes.code.instructions; import net.runelite.deob.attributes.code.InstructionType; import net.runelite.deob.attributes.code.Instructions; +import net.runelite.deob.execution.InstructionContext; +import net.runelite.deob.execution.StackContext; public class IfNull extends If0 { @@ -10,4 +12,27 @@ public class IfNull extends If0 super(instructions, type, pc); } + @Override + public boolean isSame(InstructionContext thisIc, InstructionContext otherIc) + { + if (super.isSame(thisIc, otherIc)) + return true; + + if (otherIc.getInstruction() instanceof IfCmpEq) + { + StackContext s1 = otherIc.getPops().get(0), + s2 = otherIc.getPops().get(1); + + if (s1.getPushed().getInstruction() instanceof AConstNull) + { + return true; + } + if (s2.getPushed().getInstruction() instanceof AConstNull) + { + return true; + } + } + + return false; + } }