Make sure we get all fillRectangles for clearColorBuffer

This commit is contained in:
Lucas
2019-06-08 19:54:17 +02:00
parent b1da8e510a
commit 2337d3ea55
6 changed files with 92 additions and 38 deletions

View File

@@ -1,12 +1,14 @@
package net.runelite.injector.raw; package net.runelite.injector.raw;
import java.util.ArrayList; import java.util.ListIterator;
import java.util.List;
import net.runelite.asm.ClassFile; import net.runelite.asm.ClassFile;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Code;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.Instructions; import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instructions.ILoad;
import net.runelite.asm.attributes.code.instructions.InvokeStatic; import net.runelite.asm.attributes.code.instructions.InvokeStatic;
import net.runelite.asm.attributes.code.instructions.LDC;
import net.runelite.asm.pool.Class; import net.runelite.asm.pool.Class;
import net.runelite.asm.signature.Signature; import net.runelite.asm.signature.Signature;
import net.runelite.deob.DeobAnnotations; import net.runelite.deob.DeobAnnotations;
@@ -37,34 +39,85 @@ public class ClearColorBuffer
private void injectColorBufferHooks() throws InjectionException private void injectColorBufferHooks() throws InjectionException
{ {
Method obmethod = findStaticMethod("drawEntities");
net.runelite.asm.pool.Method fillRectangle = findStaticMethod("Rasterizer2D_fillRectangle").getPoolMethod(); net.runelite.asm.pool.Method fillRectangle = findStaticMethod("Rasterizer2D_fillRectangle").getPoolMethod();
Instructions ins = obmethod.getCode().getInstructions();
replace(ins, fillRectangle);
}
private void replace(Instructions ins, net.runelite.asm.pool.Method meth) int count = 0;
{ int replaced = 0;
List<Instruction> insList = new ArrayList<>();
for (Instruction i : ins.getInstructions()) for (ClassFile cf : inject.getVanilla().getClasses())
{ {
if (i instanceof InvokeStatic) for (Method m : cf.getMethods())
{ {
if (((InvokeStatic) i).getMethod().equals(meth)) if (!m.isStatic())
{ {
int index = ins.getInstructions().indexOf(i); continue;
log.info("Found drawRectangle at index {}", index); }
insList.add(i); Code c = m.getCode();
if (c == null)
{
continue;
}
Instructions ins = c.getInstructions();
ListIterator<Instruction> it = ins.getInstructions().listIterator();
for (; it.hasNext(); )
{
Instruction i = it.next();
if (!(i instanceof InvokeStatic))
{
continue;
}
if (((InvokeStatic) i).getMethod().equals(fillRectangle))
{
int indexToReturnTo = it.nextIndex();
count++;
it.previous();
Instruction current = it.previous();
if (current instanceof LDC && ((LDC) current).getConstantAsInt() == 0)
{
int varIdx = 0;
for (; ;)
{
current = it.previous();
if (current instanceof ILoad && ((ILoad) current).getVariableIndex() == 3 - varIdx)
{
varIdx++;
log.debug(varIdx + " we can count yay");
continue;
}
break;
}
if (varIdx == 4)
{
for (; !(current instanceof InvokeStatic); )
{
current = it.next();
}
assert it.nextIndex() == indexToReturnTo;
it.set(new InvokeStatic(ins, clearBuffer));
replaced++;
log.debug("Found drawRectangle at {}. Found: {}, replaced {}", m.getName(), count, replaced);
}
else
{
log.debug("Welp, guess this wasn't it chief " + m);
}
}
while (it.nextIndex() != indexToReturnTo)
{
it.next();
}
}
} }
} }
} }
for (Instruction i : insList)
{
Instruction invoke = new InvokeStatic(ins, clearBuffer);
ins.replace(i, invoke);
}
} }
private Method findStaticMethod(String name) throws InjectionException private Method findStaticMethod(String name) throws InjectionException

View File

@@ -1736,7 +1736,7 @@ public final class Client extends GameShell implements Usernamed {
class214.__hf_u = null; class214.__hf_u = null;
} }
class13.method163(); class13.playPcmPlayers();
class171.method3498(); class171.method3498();
MouseHandler var47 = MouseHandler.MouseHandler_instance; MouseHandler var47 = MouseHandler.MouseHandler_instance;
synchronized(MouseHandler.MouseHandler_instance) { synchronized(MouseHandler.MouseHandler_instance) {
@@ -1820,7 +1820,7 @@ public final class Client extends GameShell implements Usernamed {
class68.drawLoadingMessage("Loading - please wait." + "<br>" + " (" + 100 + "%" + ")", true); class68.drawLoadingMessage("Loading - please wait." + "<br>" + " (" + 100 + "%" + ")", true);
} }
class13.method163(); class13.playPcmPlayers();
class65.scene.clear(); class65.scene.clear();
for(var48 = 0; var48 < 4; ++var48) { for(var48 = 0; var48 < 4; ++var48) {
@@ -1836,7 +1836,7 @@ public final class Client extends GameShell implements Usernamed {
} }
} }
class13.method163(); class13.playPcmPlayers();
Tiles.Tiles_minPlane = 99; Tiles.Tiles_minPlane = 99;
Tiles.__bq_w = new byte[4][104][104]; Tiles.__bq_w = new byte[4][104][104];
Fonts.__kz_o = new byte[4][104][104]; Fonts.__kz_o = new byte[4][104][104];
@@ -1874,7 +1874,7 @@ public final class Client extends GameShell implements Usernamed {
var5 = (class308.regions[var49] & 255) * 64 - GraphicsObject.baseY; var5 = (class308.regions[var49] & 255) * 64 - GraphicsObject.baseY;
var6 = class40.regionLandArchives[var49]; var6 = class40.regionLandArchives[var49];
if(var6 != null) { if(var6 != null) {
class13.method163(); class13.playPcmPlayers();
Varcs.method2166(var6, var4, var5, GameObject.__eh_fy * 8 - 48, WorldMapLabelSize.__s_fi * 8 - 48, collisionMaps); Varcs.method2166(var6, var4, var5, GameObject.__eh_fy * 8 - 48, WorldMapLabelSize.__s_fi * 8 - 48, collisionMaps);
} }
} }
@@ -1884,7 +1884,7 @@ public final class Client extends GameShell implements Usernamed {
var5 = (class308.regions[var49] & 255) * 64 - GraphicsObject.baseY; var5 = (class308.regions[var49] & 255) * 64 - GraphicsObject.baseY;
var6 = class40.regionLandArchives[var49]; var6 = class40.regionLandArchives[var49];
if(var6 == null && WorldMapLabelSize.__s_fi < 800) { if(var6 == null && WorldMapLabelSize.__s_fi < 800) {
class13.method163(); class13.playPcmPlayers();
UserComparator6.method3390(var4, var5, 64, 64); UserComparator6.method3390(var4, var5, 64, 64);
} }
} }
@@ -1896,7 +1896,7 @@ public final class Client extends GameShell implements Usernamed {
if(var50 != null) { if(var50 != null) {
var5 = (class308.regions[var49] >> 8) * 64 - class50.baseX; var5 = (class308.regions[var49] >> 8) * 64 - class50.baseX;
var51 = (class308.regions[var49] & 255) * 64 - GraphicsObject.baseY; var51 = (class308.regions[var49] & 255) * 64 - GraphicsObject.baseY;
class13.method163(); class13.playPcmPlayers();
Scene var7 = class65.scene; Scene var7 = class65.scene;
CollisionMap[] var8 = collisionMaps; CollisionMap[] var8 = collisionMaps;
Buffer var9 = new Buffer(var50); Buffer var9 = new Buffer(var50);
@@ -1971,7 +1971,7 @@ public final class Client extends GameShell implements Usernamed {
break label1186; break label1186;
} }
class13.method163(); class13.playPcmPlayers();
for(var4 = 0; var4 < 13; ++var4) { for(var4 = 0; var4 < 13; ++var4) {
for(var5 = 0; var5 < 13; ++var5) { for(var5 = 0; var5 < 13; ++var5) {
@@ -1997,7 +1997,7 @@ public final class Client extends GameShell implements Usernamed {
} }
} }
class13.method163(); class13.playPcmPlayers();
for(var4 = 0; var4 < 13; ++var4) { for(var4 = 0; var4 < 13; ++var4) {
for(var5 = 0; var5 < 13; ++var5) { for(var5 = 0; var5 < 13; ++var5) {
@@ -2058,7 +2058,7 @@ public final class Client extends GameShell implements Usernamed {
} }
UserComparator10.method3352(true); UserComparator10.method3352(true);
class13.method163(); class13.playPcmPlayers();
Scene var65 = class65.scene; Scene var65 = class65.scene;
CollisionMap[] var71 = collisionMaps; CollisionMap[] var71 = collisionMaps;
@@ -2548,7 +2548,7 @@ public final class Client extends GameShell implements Usernamed {
} }
} }
class13.method163(); class13.playPcmPlayers();
ScriptEvent.method1179(); ScriptEvent.method1179();
ObjectDefinition.__jr_o.clear(); ObjectDefinition.__jr_o.clear();
PacketBufferNode var67; PacketBufferNode var67;
@@ -2575,7 +2575,7 @@ public final class Client extends GameShell implements Usernamed {
} }
GameShell.updateGameState(30); GameShell.updateGameState(30);
class13.method163(); class13.playPcmPlayers();
BufferedSink.method3603(); BufferedSink.method3603();
var67 = Interpreter.method1915(ClientPacket.__gs_bv, packetWriter.isaacCipher); var67 = Interpreter.method1915(ClientPacket.__gs_bv, packetWriter.isaacCipher);
packetWriter.__q_167(var67); packetWriter.__q_167(var67);

View File

@@ -265,7 +265,7 @@ public class MouseRecorder implements Runnable {
garbageValue = "-335916694" garbageValue = "-335916694"
) )
static final void method1189(Widget var0, int var1, int var2, int var3) { static final void method1189(Widget var0, int var1, int var2, int var3) {
class13.method163(); class13.playPcmPlayers();
SpriteMask var4 = var0.getSpriteMask(false); SpriteMask var4 = var0.getSpriteMask(false);
if(var4 != null) { if(var4 != null) {
Rasterizer2D.Rasterizer2D_setClip(var1, var2, var4.width + var1, var2 + var4.height); Rasterizer2D.Rasterizer2D_setClip(var1, var2, var4.width + var1, var2 + var4.height);

View File

@@ -37,7 +37,7 @@ public class UserComparator10 extends AbstractUserComparator {
garbageValue = "653874364" garbageValue = "653874364"
) )
static final void method3352(boolean var0) { static final void method3352(boolean var0) {
class13.method163(); class13.playPcmPlayers();
++Client.packetWriter.__d; ++Client.packetWriter.__d;
if(Client.packetWriter.__d >= 50 || var0) { if(Client.packetWriter.__d >= 50 || var0) {
Client.packetWriter.__d = 0; Client.packetWriter.__d = 0;

View File

@@ -35,7 +35,8 @@ public class class13 {
signature = "(B)V", signature = "(B)V",
garbageValue = "63" garbageValue = "63"
) )
static final void method163() { @Export("playPcmPlayers")
static final void playPcmPlayers() {
if(AbstractIndexCache.pcmPlayer1 != null) { if(AbstractIndexCache.pcmPlayer1 != null) {
AbstractIndexCache.pcmPlayer1.run(); AbstractIndexCache.pcmPlayer1.run();
} }

View File

@@ -835,14 +835,14 @@ public class class40 {
ViewportMouse.ViewportMouse_entityCount = 0; ViewportMouse.ViewportMouse_entityCount = 0;
} }
class13.method163(); class13.playPcmPlayers();
Rasterizer2D.Rasterizer2D_fillRectangle(var0, var1, var2, var3, 0); Rasterizer2D.Rasterizer2D_fillRectangle(var0, var1, var2, var3, 0);
class13.method163(); class13.playPcmPlayers();
var12 = Rasterizer3D.Rasterizer3D_zoom; var12 = Rasterizer3D.Rasterizer3D_zoom;
Rasterizer3D.Rasterizer3D_zoom = Client.viewportZoom; Rasterizer3D.Rasterizer3D_zoom = Client.viewportZoom;
class65.scene.draw(WorldMapSection1.cameraX, GrandExchangeEvents.cameraY, class11.cameraZ, WorldMapIcon1.cameraPitch, MusicPatchNode.cameraYaw, var4); class65.scene.draw(WorldMapSection1.cameraX, GrandExchangeEvents.cameraY, class11.cameraZ, WorldMapIcon1.cameraPitch, MusicPatchNode.cameraYaw, var4);
Rasterizer3D.Rasterizer3D_zoom = var12; Rasterizer3D.Rasterizer3D_zoom = var12;
class13.method163(); class13.playPcmPlayers();
class65.scene.clearTempGameObjects(); class65.scene.clearTempGameObjects();
UrlRequester.method3258(var0, var1, var2, var3); UrlRequester.method3258(var0, var1, var2, var3);
UnitPriceComparator.method136(var0, var1); UnitPriceComparator.method136(var0, var1);