Merge pull request #638 from Lucwousin/asasakksakaskaskksakasksakas
Add occluder raw injector
This commit is contained in:
@@ -48,6 +48,7 @@ import net.runelite.deob.deobfuscators.arithmetic.DMath;
|
||||
import net.runelite.injector.raw.ClearColorBuffer;
|
||||
import net.runelite.injector.raw.DrawAfterWidgets;
|
||||
import net.runelite.injector.raw.DrawMenu;
|
||||
import net.runelite.injector.raw.Occluder;
|
||||
import net.runelite.injector.raw.RasterizerHook;
|
||||
import net.runelite.injector.raw.RenderDraw;
|
||||
import net.runelite.injector.raw.ScriptVM;
|
||||
@@ -76,6 +77,7 @@ public class Inject
|
||||
private final ScriptVM scriptVM = new ScriptVM(this);
|
||||
private final ClearColorBuffer clearColorBuffer = new ClearColorBuffer(this);
|
||||
private final RenderDraw renderDraw = new RenderDraw(this);
|
||||
private final Occluder occluder = new Occluder(this);
|
||||
|
||||
// deobfuscated contains exports etc to apply to vanilla
|
||||
private final ClassGroup deobfuscated, vanilla;
|
||||
@@ -334,6 +336,7 @@ public class Inject
|
||||
clearColorBuffer.inject();
|
||||
renderDraw.inject();
|
||||
drawMenu.inject();
|
||||
occluder.inject();
|
||||
}
|
||||
|
||||
private java.lang.Class injectInterface(ClassFile cf, ClassFile other)
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package net.runelite.injector.raw;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import java.util.ListIterator;
|
||||
import net.runelite.asm.Method;
|
||||
import net.runelite.asm.attributes.Code;
|
||||
import net.runelite.asm.attributes.code.Instruction;
|
||||
import net.runelite.asm.attributes.code.Instructions;
|
||||
import net.runelite.asm.attributes.code.instructions.BiPush;
|
||||
import net.runelite.injector.Inject;
|
||||
import net.runelite.injector.InjectUtil;
|
||||
import net.runelite.injector.InjectionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Occluder
|
||||
{
|
||||
private final Inject inject;
|
||||
private static final Logger log = LoggerFactory.getLogger(Occluder.class);
|
||||
private static final byte OLDVALUE = 25;
|
||||
private static final byte NEWVALUE = 90;
|
||||
|
||||
public Occluder(Inject inject)
|
||||
{
|
||||
this.inject = inject;
|
||||
}
|
||||
|
||||
public void inject() throws InjectionException
|
||||
{
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
Method occlude = InjectUtil.findMethod(inject, "occlude");
|
||||
int replaced = 0;
|
||||
|
||||
if (occlude == null)
|
||||
{
|
||||
throw new InjectionException("Occlude couldn't be found");
|
||||
}
|
||||
|
||||
Code code = occlude.getCode();
|
||||
|
||||
if (code == null)
|
||||
{
|
||||
throw new InjectionException("Occlude code was null");
|
||||
}
|
||||
|
||||
Instructions ins = code.getInstructions();
|
||||
|
||||
ListIterator<Instruction> it = ins.getInstructions().listIterator();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
Instruction i = it.next();
|
||||
|
||||
if (!(i instanceof BiPush))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean shouldChange = (byte) ((BiPush) i).getConstant() == OLDVALUE;
|
||||
|
||||
if (!shouldChange)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
replaced++;
|
||||
|
||||
Instruction biPush = new BiPush(ins, NEWVALUE);
|
||||
|
||||
it.set(biPush);
|
||||
}
|
||||
|
||||
stopwatch.stop();
|
||||
|
||||
if (replaced != 10)
|
||||
{
|
||||
throw new InjectionException("Only found " + replaced + " 25's to replace in occlude instead of expected 10");
|
||||
}
|
||||
|
||||
log.info("Changed {} values in occlude()", replaced);
|
||||
log.info("occluder took {}", stopwatch.toString());
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RenderDraw
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(ClearColorBuffer.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(RenderDraw.class);
|
||||
private static final net.runelite.asm.pool.Method renderDraw = new net.runelite.asm.pool.Method(
|
||||
new Class("net.runelite.client.callback.Hooks"),
|
||||
"renderDraw",
|
||||
|
||||
Reference in New Issue
Block a user