Background info - For the game 7 Days To Die, there is a C# wrapper that implements the Harmony API, which allows us to intercept the game's function calls, as well as changing the IL instructions themselves.
I originally used the Transpiler functionality to remove a condition that's used in two checks. Which was easy enough, as I just needed to remove three instructions. Here's a screenshot showing them:
On the left is the old code, which was easy enough to modify. I just needed to remove the instructions at indexes 79, 80, and 81. Which changes the C# code from:
this.cmds[1].enabled = (_world.IsEditor() && flag);
To:
this.cmds[1].enabled = (flag);
Which worked perfectly. However, the DLL was changed in an update. The C# code is the exact same, but the IL instructions differ at this very last condition check. And I can't quite wrap my head around it.
The original was easy enough. IL 79
prepares something for the next function call, IL 80
makes the call, and IL 81
jumps past the next couple of instructions if it returns false. In ASM, the three instructions would basically be pop
(call class' function via a pointer), cmp
(check the boolean result), and jz
(jump if false).
But the updated IL instructions on the right don't make any sense to me. There's no branch, there's no jump. How do I work with that to remove the _world.IsEditor()
condition?