Skip to content

Commit

Permalink
project: set GameDrawingMode
Browse files Browse the repository at this point in the history
  • Loading branch information
Owain94 committed Dec 22, 2021
1 parent 7ad3563 commit 18050c6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions injector/src/main/java/com/openosrs/injector/Injector.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.openosrs.injector.injectors.raw.AddPlayerToMenu;
import com.openosrs.injector.injectors.raw.ClearColorBuffer;
import com.openosrs.injector.injectors.raw.DrawMenu;
import com.openosrs.injector.injectors.raw.GameDrawingMode;
import com.openosrs.injector.injectors.raw.GraphicsObject;
import com.openosrs.injector.injectors.raw.Occluder;
import com.openosrs.injector.injectors.raw.RasterizerAlpha;
Expand Down Expand Up @@ -149,6 +150,8 @@ public void injectVanilla()

inject(new DrawMenu(this));

inject(new GameDrawingMode(this));

inject(new AddPlayerToMenu(this));

inject(new RuneliteMenuEntry(this));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.openosrs.injector.injectors.raw;

import com.openosrs.injector.InjectUtil;
import com.openosrs.injector.injection.InjectData;
import com.openosrs.injector.injectors.AbstractInjector;
import java.util.ListIterator;
import net.runelite.asm.ClassFile;
import net.runelite.asm.Method;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instructions.LDC;
import net.runelite.asm.attributes.code.instructions.PutStatic;
import net.runelite.asm.pool.Field;

public class GameDrawingMode extends AbstractInjector
{
public GameDrawingMode(InjectData inject)
{
super(inject);
}

public void inject()
{
final ClassFile clientVanilla = inject.toVanilla(
inject.getDeobfuscated()
.findClass("Client")
);
final Field gameDrawingMode = InjectUtil.findField(inject, "gameDrawingMode", "Client").getPoolField();

Method clinit = clientVanilla.findMethod("<clinit>");

Instructions ins = clinit.getCode().getInstructions();
ListIterator<Instruction> iterator = ins.getInstructions().listIterator();
while (iterator.hasNext())
{
Instruction i = iterator.next();

if (i instanceof PutStatic)
{
Field field = ((PutStatic) i).getField();

if (field.getName().equals(gameDrawingMode.getName()))
{
iterator.add(new LDC(ins, 2));
iterator.add(new PutStatic(ins, gameDrawingMode));
}
}
}
}
}

0 comments on commit 18050c6

Please sign in to comment.