Rework MenuManager to only swap the top entry, once per client tick (#749)
* Rework MenuManager to only swap the top entry, once per client tick
This commit is contained in:
@@ -70,50 +70,52 @@ public class ClearColorBuffer
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((InvokeStatic) i).getMethod().equals(fillRectangle))
|
||||
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)
|
||||
continue;
|
||||
}
|
||||
|
||||
int indexToReturnTo = it.nextIndex();
|
||||
count++;
|
||||
it.previous();
|
||||
Instruction current = it.previous();
|
||||
if (current instanceof LDC && ((LDC) current).getConstantAsInt() == 0)
|
||||
{
|
||||
int varIdx = 0;
|
||||
for (; ; )
|
||||
{
|
||||
int varIdx = 0;
|
||||
for (; ; )
|
||||
current = it.previous();
|
||||
if (current instanceof ILoad && ((ILoad) current).getVariableIndex() == 3 - varIdx)
|
||||
{
|
||||
current = it.previous();
|
||||
if (current instanceof ILoad && ((ILoad) current).getVariableIndex() == 3 - varIdx)
|
||||
{
|
||||
varIdx++;
|
||||
log.debug(varIdx + " we can count yay");
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
varIdx++;
|
||||
log.debug(varIdx + " we can count yay");
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
while (it.nextIndex() != indexToReturnTo)
|
||||
if (varIdx == 4)
|
||||
{
|
||||
it.next();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,6 @@ public class Occluder
|
||||
}
|
||||
|
||||
log.info("Changed {} values in occlude()", replaced);
|
||||
log.info("occluder took {}", stopwatch.toString());
|
||||
log.info("Occluder took {}", stopwatch.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RasterizerHook
|
||||
{
|
||||
// TODO: Should probably make this better
|
||||
private static final Logger logger = LoggerFactory.getLogger(ClearColorBuffer.class);
|
||||
private static final int val = -16777216;
|
||||
|
||||
@@ -318,7 +319,7 @@ public class RasterizerHook
|
||||
{
|
||||
if ((int) ic.getPops().get(0).getValue().getValue() == 0)
|
||||
{
|
||||
logger.info("Didn't add hook in method {}.{}. {} added, {} total, value 0", method.getClassFile().getClassName(), method.getName(), count - startCount, count);
|
||||
logger.debug("Didn't add hook in method {}.{}. {} added, {} total, value 0", method.getClassFile().getClassName(), method.getName(), count - startCount, count);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -326,7 +327,7 @@ public class RasterizerHook
|
||||
ins.getInstructions().add(index, new IOr(ins, InstructionType.IOR)); // Add instructions backwards
|
||||
ins.getInstructions().add(index, new LDC(ins, val));
|
||||
count++;
|
||||
logger.info("Added hook in method {}.{}. {} added, {} total", method.getClassFile().getClassName(), method.getName(), count - startCount, count);
|
||||
logger.debug("Added hook in method {}.{}. {} added, {} total", method.getClassFile().getClassName(), method.getName(), count - startCount, count);
|
||||
});
|
||||
|
||||
ex.run();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.runelite.injector.raw;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.runelite.asm.attributes.code.Instruction;
|
||||
@@ -32,18 +33,18 @@ public class RenderDraw
|
||||
|
||||
public void inject() throws InjectionException
|
||||
{
|
||||
injectColorBufferHooks();
|
||||
}
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
|
||||
private void injectColorBufferHooks() throws InjectionException
|
||||
{
|
||||
net.runelite.asm.Method obmethod = findMethod(inject, "drawTile");
|
||||
Method renderDraw = findMethod(inject, "renderDraw").getPoolMethod();
|
||||
|
||||
Instructions ins = obmethod.getCode().getInstructions();
|
||||
replace(ins, renderDraw);
|
||||
|
||||
log.info("RenderDraw took {}", stopwatch.toString());
|
||||
}
|
||||
|
||||
private void replace(Instructions ins, net.runelite.asm.pool.Method meth)
|
||||
private void replace(Instructions ins, net.runelite.asm.pool.Method meth) throws InjectionException
|
||||
{
|
||||
List<Instruction> insList = new ArrayList<>();
|
||||
int count = 0;
|
||||
@@ -55,13 +56,27 @@ public class RenderDraw
|
||||
{
|
||||
int index = ins.getInstructions().indexOf(i);
|
||||
count++;
|
||||
log.info("Found renderDraw at index {}, {} found.", index, count);
|
||||
log.debug("Found renderDraw at index {}, {} found.", index, count);
|
||||
|
||||
insList.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count < 21)
|
||||
{
|
||||
throw new InjectionException("Not all renderDraws were found");
|
||||
}
|
||||
else if (count != 21)
|
||||
{
|
||||
log.warn("Found {} renderDraws while 21 were expected. Rev update?", count);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("RenderDraw replaced {} method calls", count);
|
||||
}
|
||||
|
||||
|
||||
for (Instruction i : insList)
|
||||
{
|
||||
Instruction invoke = new InvokeStatic(ins, renderDraw);
|
||||
|
||||
Reference in New Issue
Block a user