From 4624371bf94c047c0fa488daac8686ec7a39b1f8 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 20:30:52 -0500 Subject: [PATCH 01/17] cache: remove script interpreter It is unfinished and probably not something I want to complete soon --- .../cache/script/interpreter/Frame.java | 98 ---------------- .../GenericInstructionHandler.java | 80 ------------- .../interpreter/InstructionContext.java | 101 ---------------- .../interpreter/InstructionHandler.java | 30 ----- .../interpreter/InstructionHandlers.java | 78 ------------ .../cache/script/interpreter/Interpreter.java | 111 ------------------ .../script/interpreter/ScriptInstruction.java | 68 ----------- .../cache/script/interpreter/Stack.java | 57 --------- .../script/interpreter/StackContext.java | 62 ---------- .../script/interpreter/VariableContext.java | 30 ----- .../cache/script/interpreter/Variables.java | 42 ------- .../script/interpreter/instructions/If.java | 51 -------- .../interpreter/instructions/If_ICmpEQ.java | 30 ----- .../interpreter/instructions/If_ICmpGE.java | 30 ----- .../interpreter/instructions/If_ICmpGT.java | 30 ----- .../interpreter/instructions/If_ICmpLE.java | 30 ----- .../interpreter/instructions/If_ICmpLT.java | 30 ----- .../interpreter/instructions/If_ICmpNE.java | 30 ----- .../interpreter/instructions/Invoke.java | 50 -------- .../script/interpreter/instructions/Jump.java | 40 ------- .../interpreter/instructions/LoadInt.java | 46 -------- .../interpreter/instructions/Return.java | 41 ------- .../instructions/StringAppend.java | 56 --------- .../interpreter/instructions/Switch.java | 62 ---------- .../script/interpreter/InterpreterTest.java | 49 -------- .../cache/script/interpreter/397.rs2asm | 54 --------- 26 files changed, 1386 deletions(-) delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/Frame.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/GenericInstructionHandler.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/InstructionContext.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandler.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandlers.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/Interpreter.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/ScriptInstruction.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/Stack.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/StackContext.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/VariableContext.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/Variables.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpEQ.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGE.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGT.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLE.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLT.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpNE.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Invoke.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Jump.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/LoadInt.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Return.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/StringAppend.java delete mode 100644 cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Switch.java delete mode 100644 cache/src/test/java/net/runelite/cache/script/interpreter/InterpreterTest.java delete mode 100644 cache/src/test/resources/net/runelite/cache/script/interpreter/397.rs2asm diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/Frame.java b/cache/src/main/java/net/runelite/cache/script/interpreter/Frame.java deleted file mode 100644 index 62d2b2253b..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/Frame.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import net.runelite.cache.definitions.ScriptDefinition; - -public class Frame -{ - private final Interpreter interpreter; - private final ScriptDefinition script; - private final Stack intStack; - private final Stack stringStack; - private final Variables intVariables; - private final Variables stringVariables; - - private boolean running = true; - int pc; - - public Frame(Interpreter interpreter, ScriptDefinition script) - { - this.interpreter = interpreter; - this.script = script; - this.intStack = new Stack(); - this.stringStack = new Stack(); - this.intVariables = new Variables(script.getLocalIntCount()); - this.stringVariables = new Variables(script.getLocalStringCount()); - } - - public Frame(Interpreter interpreter, Frame other) - { - this.interpreter = interpreter; - this.script = other.script; - this.intStack = new Stack(other.intStack); - this.stringStack = new Stack(other.stringStack); - this.intVariables = new Variables(other.intVariables); - this.stringVariables = new Variables(other.stringVariables); - this.pc = other.pc; - } - - public Stack getIntStack() - { - return intStack; - } - - public Stack getStringStack() - { - return stringStack; - } - - public ScriptDefinition getScript() - { - return script; - } - - public Frame dup() - { - Frame frame = new Frame(interpreter, this); - interpreter.addFrame(this); - return frame; - } - - public boolean isRunning() - { - return running; - } - - public void stop() - { - running = false; - } - - public void jump(int offset) - { - pc += offset + 1; - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/GenericInstructionHandler.java b/cache/src/main/java/net/runelite/cache/script/interpreter/GenericInstructionHandler.java deleted file mode 100644 index ff93744fcb..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/GenericInstructionHandler.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import net.runelite.cache.script.Instruction; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GenericInstructionHandler extends InstructionHandler -{ - private static final Logger logger = LoggerFactory.getLogger(GenericInstructionHandler.class); - - @Override - public void execute(Frame frame, InstructionContext ctx) - { - Instruction i = ctx.getScriptInstruction().getInstruction(); - Stack istack = frame.getIntStack(); - Stack sstack = frame.getStringStack(); - - int ipops = i.getIntStackPops(); - for (int j = 0; j < ipops; ++j) - { - StackContext value = istack.pop(); - ctx.popsInt(value); - value.poppedBy(ctx); - } - - int spops = i.getStringStackPops(); - for (int j = 0; j < spops; ++j) - { - StackContext value = sstack.pop(); - ctx.popsString(value); - value.poppedBy(ctx); - } - - int ipushes = i.getIntStackPushes(); - for (int j = 0; j < ipushes; ++j) - { - StackContext sctx = new StackContext(ctx, null); - istack.push(sctx); - ctx.pushesInt(sctx); - } - - int spushes = i.getStringStackPushes(); - for (int j = 0; j < spushes; ++j) - { - StackContext sctx = new StackContext(ctx, null); - sstack.push(sctx); - ctx.pushesString(sctx); - } - - if (ipushes > 0 || spushes > 0) - { - logger.debug("Executed instruction {} with {}/{} pushes!", i, ipushes, spushes); - } - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionContext.java b/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionContext.java deleted file mode 100644 index 9387346a67..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionContext.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.ArrayList; -import java.util.List; - -public class InstructionContext -{ - private final ScriptInstruction scriptInstruction; - - private final List ipops = new ArrayList<>(); - private final List spops = new ArrayList<>(); - private final List ipushes = new ArrayList<>(); - private final List spushes = new ArrayList<>(); - - public InstructionContext(ScriptInstruction scriptInstruction) - { - this.scriptInstruction = scriptInstruction; - } - - public ScriptInstruction getScriptInstruction() - { - return scriptInstruction; - } - - public void popsInt(StackContext... ctx) - { - for (StackContext s : ctx) - { - ipops.add(s); - } - } - - public void popsString(StackContext... ctx) - { - for (StackContext s : ctx) - { - spops.add(s); - } - } - - public void pushesInt(StackContext... ctx) - { - for (StackContext s : ctx) - { - ipushes.add(s); - } - } - - public void pushesString(StackContext... ctx) - { - for (StackContext s : ctx) - { - spushes.add(s); - } - - } - - public List getIpops() - { - return ipops; - } - - public List getSpops() - { - return spops; - } - - public List getIpushes() - { - return ipushes; - } - - public List getSpushes() - { - return spushes; - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandler.java b/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandler.java deleted file mode 100644 index 82f468d1b8..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -public abstract class InstructionHandler -{ - public abstract void execute(Frame frame, InstructionContext ctx); -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandlers.java b/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandlers.java deleted file mode 100644 index 0aca6ff803..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/InstructionHandlers.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.HashMap; -import java.util.Map; -import net.runelite.cache.script.Opcodes; -import net.runelite.cache.script.interpreter.instructions.If_ICmpEQ; -import net.runelite.cache.script.interpreter.instructions.If_ICmpGE; -import net.runelite.cache.script.interpreter.instructions.If_ICmpGT; -import net.runelite.cache.script.interpreter.instructions.If_ICmpLE; -import net.runelite.cache.script.interpreter.instructions.If_ICmpLT; -import net.runelite.cache.script.interpreter.instructions.If_ICmpNE; -import net.runelite.cache.script.interpreter.instructions.Invoke; -import net.runelite.cache.script.interpreter.instructions.Jump; -import net.runelite.cache.script.interpreter.instructions.LoadInt; -import net.runelite.cache.script.interpreter.instructions.Return; -import net.runelite.cache.script.interpreter.instructions.StringAppend; -import net.runelite.cache.script.interpreter.instructions.Switch; - -public class InstructionHandlers -{ - private static final Map handlers = new HashMap<>(); - - static - { - init(); - } - - private static void init() - { - add(Opcodes.LOAD_INT, new LoadInt()); - add(Opcodes.JUMP, new Jump()); - add(Opcodes.IF_ICMPNE, new If_ICmpNE()); - add(Opcodes.IF_ICMPEQ, new If_ICmpEQ()); - add(Opcodes.IF_ICMPLT, new If_ICmpLT()); - add(Opcodes.IF_ICMPGT, new If_ICmpGT()); - add(Opcodes.IF_ICMPLE, new If_ICmpLE()); - add(Opcodes.IF_ICMPGE, new If_ICmpGE()); - add(Opcodes.INVOKE, new Invoke()); - add(Opcodes.RETURN, new Return()); - add(Opcodes.SWITCH, new Switch()); - add(Opcodes.STRING_APPEND, new StringAppend()); - } - - private static void add(int opcode, InstructionHandler handler) - { - assert handlers.containsKey(opcode) == false; - handlers.put(opcode, handler); - } - - public static InstructionHandler find(int opcode) - { - return handlers.get(opcode); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/Interpreter.java b/cache/src/main/java/net/runelite/cache/script/interpreter/Interpreter.java deleted file mode 100644 index 6e923f4db4..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/Interpreter.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.ArrayDeque; -import java.util.Queue; -import net.runelite.cache.definitions.ScriptDefinition; -import net.runelite.cache.script.Instruction; -import net.runelite.cache.script.Instructions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Interpreter -{ - private static final Logger logger = LoggerFactory.getLogger(Interpreter.class); - - private final Queue frames = new ArrayDeque<>(); - private final GenericInstructionHandler genericInstructionHandler = new GenericInstructionHandler(); - - public void run(ScriptDefinition script) - { - Instructions.init(); - - Frame frame = new Frame(this, script); - frames.add(frame); - - int count = 0; - - while (!frames.isEmpty()) - { - frame = frames.remove(); - run(frame); - ++count; - } - - logger.info("Processed {} frames", count); - } - - private void run(Frame frame) - { - ScriptDefinition script = frame.getScript(); - - int[] instructions = script.getInstructions(); - int[] iops = script.getIntOperands(); - String[] sops = script.getStringOperands(); - - while (frame.isRunning()) - { - if (frame.pc >= instructions.length) - { - throw new RuntimeException("PC went past end of instructions - maybe missing return"); - } - - int opcode = instructions[frame.pc]; - int iop = iops[frame.pc]; - String sop = sops[frame.pc]; - - Instruction i = Instructions.find(opcode); - if (i == null) - { - throw new RuntimeException("Unknown instruction " + opcode + " in script at pc " + frame.pc); - } - - ScriptInstruction scriptInstruction = new ScriptInstruction(frame.pc, i, iop, sop); - InstructionContext ctx = new InstructionContext(scriptInstruction); - - InstructionHandler handler = InstructionHandlers.find(opcode); - if (handler == null) - { - handler = genericInstructionHandler; - } - - int old = frame.pc; - - handler.execute(frame, ctx); - - if (old == frame.pc) - { - // not a jump - ++frame.pc; - } - } - } - - public void addFrame(Frame frame) - { - frames.add(frame); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/ScriptInstruction.java b/cache/src/main/java/net/runelite/cache/script/interpreter/ScriptInstruction.java deleted file mode 100644 index d59ddc2640..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/ScriptInstruction.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import net.runelite.cache.script.Instruction; - -/** - * an instruction in a script - * - * @author Adam - */ -public class ScriptInstruction -{ - private final int pc; - private final Instruction instruction; - private final int iop; - private final String sop; - - public ScriptInstruction(int pc, Instruction instruction, int iop, String sop) - { - this.pc = pc; - this.instruction = instruction; - this.iop = iop; - this.sop = sop; - } - - public int getPc() - { - return pc; - } - - public Instruction getInstruction() - { - return instruction; - } - - public int getIop() - { - return iop; - } - - public String getSop() - { - return sop; - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/Stack.java b/cache/src/main/java/net/runelite/cache/script/interpreter/Stack.java deleted file mode 100644 index 49fd0010e4..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/Stack.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.ArrayList; -import java.util.List; - -public class Stack -{ - private final List stack = new ArrayList<>(); - - public Stack() - { - } - - public Stack(Stack other) - { - stack.addAll(other.stack); - } - - public void push(StackContext ctx) - { - stack.add(ctx); - } - - public StackContext pop() - { - if (stack.isEmpty()) - { - throw new RuntimeException("stack underflow"); - } - - return stack.remove(stack.size() - 1); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/StackContext.java b/cache/src/main/java/net/runelite/cache/script/interpreter/StackContext.java deleted file mode 100644 index 63349240ae..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/StackContext.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.ArrayList; -import java.util.List; - -public class StackContext -{ - private final InstructionContext pushed; - private final List popped = new ArrayList<>(); - private final Object value; - - public StackContext(InstructionContext pushed, Object value) - { - assert value == null || value instanceof String || value instanceof Integer; - this.pushed = pushed; - this.value = value; - } - - public void poppedBy(InstructionContext ctx) - { - popped.add(ctx); - } - - public InstructionContext getPushed() - { - return pushed; - } - - public List getPopped() - { - return popped; - } - - public Object getValue() - { - return value; - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/VariableContext.java b/cache/src/main/java/net/runelite/cache/script/interpreter/VariableContext.java deleted file mode 100644 index 44c05fb14e..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/VariableContext.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -public class VariableContext -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/Variables.java b/cache/src/main/java/net/runelite/cache/script/interpreter/Variables.java deleted file mode 100644 index 4bb38ed436..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/Variables.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.util.Arrays; - -public class Variables -{ - private final VariableContext[] variables; - - public Variables(int count) - { - variables = new VariableContext[count]; - } - - public Variables(Variables other) - { - variables = Arrays.copyOf(other.variables, other.variables.length); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If.java deleted file mode 100644 index b949fb95ef..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.Stack; -import net.runelite.cache.script.interpreter.StackContext; - -public abstract class If extends InstructionHandler -{ - @Override - public final void execute(Frame frame, InstructionContext ctx) - { - Stack intStack = frame.getIntStack(); - int iop = ctx.getScriptInstruction().getIop(); - - StackContext sctx1 = intStack.pop(); - StackContext sctx2 = intStack.pop(); - - ctx.popsInt(sctx1, sctx2); - sctx1.poppedBy(ctx); - sctx2.poppedBy(ctx); - - Frame dup = frame.dup(); - dup.jump(iop); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpEQ.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpEQ.java deleted file mode 100644 index ca6fc4a731..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpEQ.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpEQ extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGE.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGE.java deleted file mode 100644 index 9f0ae98e3c..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGE.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpGE extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGT.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGT.java deleted file mode 100644 index d3e0fcbe61..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpGT.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpGT extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLE.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLE.java deleted file mode 100644 index 0e2b87e4d1..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLE.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpLE extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLT.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLT.java deleted file mode 100644 index 29d63ab4a0..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpLT.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpLT extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpNE.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpNE.java deleted file mode 100644 index e155845379..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/If_ICmpNE.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -public class If_ICmpNE extends If -{ - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Invoke.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Invoke.java deleted file mode 100644 index e32665ee8a..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Invoke.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.ScriptInstruction; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Invoke extends InstructionHandler -{ - private static final Logger logger = LoggerFactory.getLogger(Invoke.class); - - @Override - public void execute(Frame frame, InstructionContext ctx) - { - ScriptInstruction scriptInstruction = ctx.getScriptInstruction(); - - int scriptToInvoke = scriptInstruction.getIop(); - - // copy new script's intStackCount/stringStackCount to the new LVT, and pop from caller's stack - - logger.warn("Invoke not implemented yet"); - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Jump.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Jump.java deleted file mode 100644 index e88d8febd7..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Jump.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; - -public class Jump extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - int iop = ctx.getScriptInstruction().getIop(); - frame.jump(iop); - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/LoadInt.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/LoadInt.java deleted file mode 100644 index 7122bdb523..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/LoadInt.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.Stack; -import net.runelite.cache.script.interpreter.StackContext; - -public class LoadInt extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - Stack intStack = frame.getIntStack(); - int iop = ctx.getScriptInstruction().getIop(); - - StackContext sctx = new StackContext(ctx, iop); - ctx.pushesInt(sctx); - - intStack.push(sctx); - } -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Return.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Return.java deleted file mode 100644 index a123c4e40f..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Return.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; - -public class Return extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - frame.stop(); - - // restore lvt from calling script. return value is on the stack. - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/StringAppend.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/StringAppend.java deleted file mode 100644 index 1cdc88a4f8..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/StringAppend.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.ScriptInstruction; -import net.runelite.cache.script.interpreter.Stack; -import net.runelite.cache.script.interpreter.StackContext; - -public class StringAppend extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - Stack stringStack = frame.getStringStack(); - ScriptInstruction scriptInstruction = ctx.getScriptInstruction(); - int number = scriptInstruction.getIop(); - - for (int i = 0; i < number; ++i) - { - StackContext sctx = stringStack.pop(); - ctx.popsString(sctx); - sctx.poppedBy(ctx); - } - - // push appended string - StackContext sctx = new StackContext(ctx, null); - stringStack.push(sctx); - ctx.pushesString(sctx); - } - -} diff --git a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Switch.java b/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Switch.java deleted file mode 100644 index 519c91a4ee..0000000000 --- a/cache/src/main/java/net/runelite/cache/script/interpreter/instructions/Switch.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter.instructions; - -import java.util.Map; -import net.runelite.cache.definitions.ScriptDefinition; -import net.runelite.cache.script.interpreter.Frame; -import net.runelite.cache.script.interpreter.InstructionContext; -import net.runelite.cache.script.interpreter.InstructionHandler; -import net.runelite.cache.script.interpreter.ScriptInstruction; -import net.runelite.cache.script.interpreter.Stack; -import net.runelite.cache.script.interpreter.StackContext; - -public class Switch extends InstructionHandler -{ - @Override - public void execute(Frame frame, InstructionContext ctx) - { - Stack intStack = frame.getIntStack(); - ScriptInstruction scriptInstruction = ctx.getScriptInstruction(); - ScriptDefinition script = frame.getScript(); - int switchTableIndex = scriptInstruction.getIop(); - - // value -> pc - Map switchTable = script.getSwitches()[switchTableIndex]; - - // pop value off stack - StackContext sctx = intStack.pop(); - ctx.popsInt(sctx); - sctx.poppedBy(ctx); - - // jump to targets - for (int target : switchTable.values()) - { - Frame dup = frame.dup(); - dup.jump(target); - } - } - -} diff --git a/cache/src/test/java/net/runelite/cache/script/interpreter/InterpreterTest.java b/cache/src/test/java/net/runelite/cache/script/interpreter/InterpreterTest.java deleted file mode 100644 index 61012a70f2..0000000000 --- a/cache/src/test/java/net/runelite/cache/script/interpreter/InterpreterTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.cache.script.interpreter; - -import java.io.IOException; -import java.io.InputStream; -import net.runelite.cache.definitions.ScriptDefinition; -import net.runelite.cache.script.assembler.Assembler; -import org.junit.Assert; -import org.junit.Test; - -public class InterpreterTest -{ - @Test - public void testRun() throws IOException - { - InputStream in = InterpreterTest.class.getResourceAsStream("397.rs2asm"); - Assert.assertNotNull(in); - - Assembler assembler = new Assembler(); - ScriptDefinition script = assembler.assemble(in); - - Interpreter interpreter = new Interpreter(); - interpreter.run(script); - } - -} diff --git a/cache/src/test/resources/net/runelite/cache/script/interpreter/397.rs2asm b/cache/src/test/resources/net/runelite/cache/script/interpreter/397.rs2asm deleted file mode 100644 index c71842b4f3..0000000000 --- a/cache/src/test/resources/net/runelite/cache/script/interpreter/397.rs2asm +++ /dev/null @@ -1,54 +0,0 @@ -.int_stack_count 3 -.string_stack_count 0 -.int_var_count 3 -.string_var_count 0 - iload 0 - load_int 1 - if_icmpne LABEL4 - jump LABEL5 -LABEL4: - return -LABEL5: - load_int 2871 - load_int 1 - load_int 0 - 3200 - iload 1 - load_int 1 - if_icmpeq LABEL13 - jump LABEL20 -LABEL13: - get_varbit 3985 - iload 2 - iadd - load_int 4 - modulo - set_varbit 3985 - jump LABEL41 -LABEL20: - iload 1 - load_int 2 - if_icmpeq LABEL24 - jump LABEL31 -LABEL24: - get_varbit 3986 - iload 2 - iadd - load_int 4 - modulo - set_varbit 3986 - jump LABEL41 -LABEL31: - iload 1 - load_int 3 - if_icmpeq LABEL35 - jump LABEL41 -LABEL35: - get_varbit 3987 - iload 2 - iadd - load_int 4 - modulo - set_varbit 3987 -LABEL41: - return From e6506371768407622866cd3de45099c0ab72ee53 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 20:31:31 -0500 Subject: [PATCH 02/17] cache: allow passing instruction set to assembler --- .../runelite/cache/script/Instructions.java | 21 ++++++++----------- .../cache/script/assembler/Assembler.java | 11 +++++++--- .../cache/script/assembler/ScriptWriter.java | 6 ++++-- .../script/disassembler/Disassembler.java | 9 +++++++- .../definitions/savers/ScriptSaverTest.java | 5 ++++- .../cache/script/InstructionsTest.java | 2 +- .../cache/script/assembler/AssemblerTest.java | 6 +++++- .../script/disassembler/DisassemblerTest.java | 3 --- 8 files changed, 39 insertions(+), 24 deletions(-) diff --git a/cache/src/main/java/net/runelite/cache/script/Instructions.java b/cache/src/main/java/net/runelite/cache/script/Instructions.java index c167b1bfdc..0a906bbebb 100644 --- a/cache/src/main/java/net/runelite/cache/script/Instructions.java +++ b/cache/src/main/java/net/runelite/cache/script/Instructions.java @@ -30,14 +30,11 @@ import static net.runelite.cache.script.Opcodes.*; public class Instructions { - private static final Map instructions = new HashMap<>(); - private static final Map instructionsByName = new HashMap<>(); + private final Map instructions = new HashMap<>(); + private final Map instructionsByName = new HashMap<>(); - public static void init() + public void init() { - instructions.clear(); - instructionsByName.clear(); - add(LOAD_INT, "load_int", 0, 1); add(GET_SETTINGS, "get_settings", 0, 1); add(PUT_SETTINGS, "put_settings", 0, 1); @@ -536,7 +533,7 @@ public class Instructions add(6699, 0, 1); } - private static void add(int opcode, String name, int ipops, int ipushes, int spops, int spushes) + protected void add(int opcode, String name, int ipops, int ipushes, int spops, int spushes) { Instruction i = new Instruction(opcode); i.setName(name); @@ -555,27 +552,27 @@ public class Instructions } } - private static void add(int opcode, int ipops, int ipushes) + protected void add(int opcode, int ipops, int ipushes) { add(opcode, null, ipops, ipushes, 0, 0); } - private static void add(int opcode, int ipops, int ipushes, int spops, int spushes) + protected void add(int opcode, int ipops, int ipushes, int spops, int spushes) { add(opcode, null, ipops, ipushes, spops, spushes); } - private static void add(int opcode, String name, int ipops, int ipushes) + protected void add(int opcode, String name, int ipops, int ipushes) { add(opcode, name, ipops, ipushes, 0, 0); } - public static Instruction find(int opcode) + public Instruction find(int opcode) { return instructions.get(opcode); } - public static Instruction find(String name) + public Instruction find(String name) { return instructionsByName.get(name); } diff --git a/cache/src/main/java/net/runelite/cache/script/assembler/Assembler.java b/cache/src/main/java/net/runelite/cache/script/assembler/Assembler.java index 3cd20f43ba..643057911e 100644 --- a/cache/src/main/java/net/runelite/cache/script/assembler/Assembler.java +++ b/cache/src/main/java/net/runelite/cache/script/assembler/Assembler.java @@ -35,10 +35,15 @@ import org.antlr.v4.runtime.tree.ParseTreeWalker; public class Assembler { + private final Instructions instructions; + + public Assembler(Instructions instructions) + { + this.instructions = instructions; + } + public ScriptDefinition assemble(InputStream in) throws IOException { - Instructions.init(); - // Get our lexer rs2asmLexer lexer = new rs2asmLexer(new ANTLRInputStream(in)); @@ -66,7 +71,7 @@ public class Assembler LabelVisitor labelVisitor = new LabelVisitor(); walker.walk(labelVisitor, progContext); - ScriptWriter listener = new ScriptWriter(labelVisitor); + ScriptWriter listener = new ScriptWriter(instructions, labelVisitor); walker.walk(listener, progContext); return listener.buildScript(); diff --git a/cache/src/main/java/net/runelite/cache/script/assembler/ScriptWriter.java b/cache/src/main/java/net/runelite/cache/script/assembler/ScriptWriter.java index 8627a5ea23..39e314d499 100644 --- a/cache/src/main/java/net/runelite/cache/script/assembler/ScriptWriter.java +++ b/cache/src/main/java/net/runelite/cache/script/assembler/ScriptWriter.java @@ -39,6 +39,7 @@ public class ScriptWriter extends rs2asmBaseListener { private static final Logger logger = LoggerFactory.getLogger(ScriptWriter.class); + private final Instructions instructions; private final LabelVisitor labelVisitor; private int pos; @@ -51,8 +52,9 @@ public class ScriptWriter extends rs2asmBaseListener private List sops = new ArrayList<>(); private List switches = new ArrayList<>(); - public ScriptWriter(LabelVisitor labelVisitor) + public ScriptWriter(Instructions instructions, LabelVisitor labelVisitor) { + this.instructions = instructions; this.labelVisitor = labelVisitor; } @@ -94,7 +96,7 @@ public class ScriptWriter extends rs2asmBaseListener public void enterName_string(rs2asmParser.Name_stringContext ctx) { String text = ctx.getText(); - Instruction i = Instructions.find(text); + Instruction i = instructions.find(text); if (i == null) { logger.warn("Unknown instruction {}", text); diff --git a/cache/src/main/java/net/runelite/cache/script/disassembler/Disassembler.java b/cache/src/main/java/net/runelite/cache/script/disassembler/Disassembler.java index 0bf99f4fd9..7e69ed3e38 100644 --- a/cache/src/main/java/net/runelite/cache/script/disassembler/Disassembler.java +++ b/cache/src/main/java/net/runelite/cache/script/disassembler/Disassembler.java @@ -38,6 +38,13 @@ public class Disassembler { private static final Logger logger = LoggerFactory.getLogger(Disassembler.class); + private final Instructions instructions = new Instructions(); + + public Disassembler() + { + instructions.init(); + } + private boolean isJump(int opcode) { switch (opcode) @@ -120,7 +127,7 @@ public class Disassembler int iop = iops[i]; String sop = sops[i]; - Instruction ins = Instructions.find(opcode); + Instruction ins = this.instructions.find(opcode); if (ins == null) { logger.warn("Unknown instruction {} in script {}", opcode, script.getId()); diff --git a/cache/src/test/java/net/runelite/cache/definitions/savers/ScriptSaverTest.java b/cache/src/test/java/net/runelite/cache/definitions/savers/ScriptSaverTest.java index c485016854..a4a5ca1b6a 100644 --- a/cache/src/test/java/net/runelite/cache/definitions/savers/ScriptSaverTest.java +++ b/cache/src/test/java/net/runelite/cache/definitions/savers/ScriptSaverTest.java @@ -27,6 +27,7 @@ package net.runelite.cache.definitions.savers; import java.io.IOException; import net.runelite.cache.definitions.ScriptDefinition; import net.runelite.cache.definitions.loaders.ScriptLoader; +import net.runelite.cache.script.Instructions; import net.runelite.cache.script.assembler.Assembler; import static org.junit.Assert.assertEquals; import org.junit.Test; @@ -42,7 +43,9 @@ public class ScriptSaverTest @Test public void testSave() throws IOException { - ScriptDefinition script = new Assembler().assemble(getClass().getResourceAsStream(SCRIPT_RESOURCE)); + Instructions instructions = new Instructions(); + instructions.init(); + ScriptDefinition script = new Assembler(instructions).assemble(getClass().getResourceAsStream(SCRIPT_RESOURCE)); byte[] saved = new ScriptSaver().save(script); ScriptDefinition loadedScripot = new ScriptLoader().load(42, saved); assertEquals(script, loadedScripot); diff --git a/cache/src/test/java/net/runelite/cache/script/InstructionsTest.java b/cache/src/test/java/net/runelite/cache/script/InstructionsTest.java index 9f7df6e888..477845c5e8 100644 --- a/cache/src/test/java/net/runelite/cache/script/InstructionsTest.java +++ b/cache/src/test/java/net/runelite/cache/script/InstructionsTest.java @@ -31,7 +31,7 @@ public class InstructionsTest @Test public void testInit() { - Instructions.init(); + new Instructions().init(); } } diff --git a/cache/src/test/java/net/runelite/cache/script/assembler/AssemblerTest.java b/cache/src/test/java/net/runelite/cache/script/assembler/AssemblerTest.java index eb0005dcca..48503d27ae 100644 --- a/cache/src/test/java/net/runelite/cache/script/assembler/AssemblerTest.java +++ b/cache/src/test/java/net/runelite/cache/script/assembler/AssemblerTest.java @@ -26,6 +26,7 @@ package net.runelite.cache.script.assembler; import java.io.InputStream; import net.runelite.cache.definitions.ScriptDefinition; +import net.runelite.cache.script.Instructions; import net.runelite.cache.script.disassembler.Disassembler; import org.apache.commons.compress.utils.IOUtils; import org.junit.Assert; @@ -60,7 +61,10 @@ public class AssemblerTest InputStream in = AssemblerTest.class.getResourceAsStream(script); Assert.assertNotNull(in); - Assembler assembler = new Assembler(); + Instructions instructions = new Instructions(); + instructions.init(); + + Assembler assembler = new Assembler(instructions); ScriptDefinition script = assembler.assemble(in); // compare with disassembler diff --git a/cache/src/test/java/net/runelite/cache/script/disassembler/DisassemblerTest.java b/cache/src/test/java/net/runelite/cache/script/disassembler/DisassemblerTest.java index e883a26f52..30f6fd46d9 100644 --- a/cache/src/test/java/net/runelite/cache/script/disassembler/DisassemblerTest.java +++ b/cache/src/test/java/net/runelite/cache/script/disassembler/DisassemblerTest.java @@ -35,7 +35,6 @@ import net.runelite.cache.fs.Archive; import net.runelite.cache.fs.Index; import net.runelite.cache.fs.Storage; import net.runelite.cache.fs.Store; -import net.runelite.cache.script.Instructions; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -55,8 +54,6 @@ public class DisassemblerTest File outDir = folder.newFolder(); int count = 0; - Instructions.init(); - try (Store store = new Store(StoreLocation.LOCATION)) { store.load(); From 96eb258410c624303c5782464968ea458bf74a7c Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 20:37:41 -0500 Subject: [PATCH 03/17] runelite-api: add Script --- .../main/java/net/runelite/api/Script.java | 32 +++++++++++++++ .../net/runelite/rs/api/RSCacheableNode.java | 2 +- .../java/net/runelite/rs/api/RSScript.java | 39 +++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 runelite-api/src/main/java/net/runelite/api/Script.java create mode 100644 runescape-api/src/main/java/net/runelite/rs/api/RSScript.java diff --git a/runelite-api/src/main/java/net/runelite/api/Script.java b/runelite-api/src/main/java/net/runelite/api/Script.java new file mode 100644 index 0000000000..eefe0dd08a --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/Script.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api; + +public interface Script extends Node +{ + int[] getIntOperands(); + + int[] getInstructions(); +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSCacheableNode.java b/runescape-api/src/main/java/net/runelite/rs/api/RSCacheableNode.java index 53882ccb73..2b9f3a7030 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSCacheableNode.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSCacheableNode.java @@ -26,7 +26,7 @@ package net.runelite.rs.api; import net.runelite.mapping.Import; -public interface RSCacheableNode +public interface RSCacheableNode extends RSNode { @Import("next") RSCacheableNode getNext(); diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSScript.java b/runescape-api/src/main/java/net/runelite/rs/api/RSScript.java new file mode 100644 index 0000000000..5bf9a0d094 --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSScript.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.rs.api; + +import net.runelite.api.Script; +import net.runelite.mapping.Import; + +public interface RSScript extends Script, RSCacheableNode +{ + @Import("intOperands") + @Override + int[] getIntOperands(); + + @Import("instructions") + @Override + int[] getInstructions(); +} From 4ca7ee20149cea69532f78e6da324eff0f9d377a Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 20:45:55 -0500 Subject: [PATCH 04/17] cache: add set_zoom_distance --- cache/src/main/java/net/runelite/cache/script/Instructions.java | 2 +- cache/src/main/java/net/runelite/cache/script/Opcodes.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cache/src/main/java/net/runelite/cache/script/Instructions.java b/cache/src/main/java/net/runelite/cache/script/Instructions.java index 0a906bbebb..bf601aa3a9 100644 --- a/cache/src/main/java/net/runelite/cache/script/Instructions.java +++ b/cache/src/main/java/net/runelite/cache/script/Instructions.java @@ -469,7 +469,7 @@ public class Instructions add(CANCEL_LOGIN, "cancel_login", 0, 0); // 5700-6300 add(6200, 2, 0); - add(6201, 2, 0); + add(SET_ZOOM_DISTANCE, "set_zoom_distance", 2, 0); add(6202, 4, 0); add(GET_VIEWPORT_SIZE, "get_viewport_size", 0, 2); add(6204, 0, 2); diff --git a/cache/src/main/java/net/runelite/cache/script/Opcodes.java b/cache/src/main/java/net/runelite/cache/script/Opcodes.java index bed72d845b..9ff963b244 100644 --- a/cache/src/main/java/net/runelite/cache/script/Opcodes.java +++ b/cache/src/main/java/net/runelite/cache/script/Opcodes.java @@ -362,6 +362,7 @@ public class Opcodes public static final int SET_SCREENTYPE = 5309; public static final int GET_MAPANGLE = 5506; public static final int CANCEL_LOGIN = 5630; + public static final int SET_ZOOM_DISTANCE = 6201; public static final int GET_VIEWPORT_SIZE = 6203; public static final int LOAD_WORLDS = 6500; public static final int GET_FIRST_WORLD = 6501; From cdfc7c549a27ac5621789541c5095d3f5d6bd1f8 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 20:47:13 -0500 Subject: [PATCH 05/17] cache: add get_zoom_distance --- cache/src/main/java/net/runelite/cache/script/Instructions.java | 2 +- cache/src/main/java/net/runelite/cache/script/Opcodes.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cache/src/main/java/net/runelite/cache/script/Instructions.java b/cache/src/main/java/net/runelite/cache/script/Instructions.java index bf601aa3a9..a9b1b783cc 100644 --- a/cache/src/main/java/net/runelite/cache/script/Instructions.java +++ b/cache/src/main/java/net/runelite/cache/script/Instructions.java @@ -472,7 +472,7 @@ public class Instructions add(SET_ZOOM_DISTANCE, "set_zoom_distance", 2, 0); add(6202, 4, 0); add(GET_VIEWPORT_SIZE, "get_viewport_size", 0, 2); - add(6204, 0, 2); + add(GET_ZOOM_DISTANCE, "get_zoom_distance", 0, 2); add(6205, 0, 2); // 6300-6600 add(LOAD_WORLDS, "load_worlds", 0, 1); diff --git a/cache/src/main/java/net/runelite/cache/script/Opcodes.java b/cache/src/main/java/net/runelite/cache/script/Opcodes.java index 9ff963b244..a5d8fcd806 100644 --- a/cache/src/main/java/net/runelite/cache/script/Opcodes.java +++ b/cache/src/main/java/net/runelite/cache/script/Opcodes.java @@ -364,6 +364,7 @@ public class Opcodes public static final int CANCEL_LOGIN = 5630; public static final int SET_ZOOM_DISTANCE = 6201; public static final int GET_VIEWPORT_SIZE = 6203; + public static final int GET_ZOOM_DISTANCE = 6204; public static final int LOAD_WORLDS = 6500; public static final int GET_FIRST_WORLD = 6501; public static final int GET_NEXT_WORLD = 6502; From 7b3c8c34e9e675ee90342928a77edb89e22852cc Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 21:09:20 -0500 Subject: [PATCH 06/17] cache: add comment to rs2asm grammar --- .../main/antlr4/net/runelite/cache/script/assembler/rs2asm.g4 | 1 + 1 file changed, 1 insertion(+) diff --git a/cache/src/main/antlr4/net/runelite/cache/script/assembler/rs2asm.g4 b/cache/src/main/antlr4/net/runelite/cache/script/assembler/rs2asm.g4 index 150c6a7e16..7d0717dbcd 100644 --- a/cache/src/main/antlr4/net/runelite/cache/script/assembler/rs2asm.g4 +++ b/cache/src/main/antlr4/net/runelite/cache/script/assembler/rs2asm.g4 @@ -59,5 +59,6 @@ NEWLINE: '\n'+ ; INT: '-'? [0-9]+ ; QSTRING: '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"' ; INSTRUCTION: [a-z0-9_]+ ; +COMMENT: ';' ~( '\r' | '\n' )* -> channel(HIDDEN) ; WS: (' ' | '\t')+ -> channel(HIDDEN) ; \ No newline at end of file From d53200cb1469cc1f272d9b15b10a60f92d1c7c14 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 21:40:16 -0500 Subject: [PATCH 07/17] cache: add set_camera_focal_point_height --- cache/src/main/java/net/runelite/cache/script/Instructions.java | 2 +- cache/src/main/java/net/runelite/cache/script/Opcodes.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cache/src/main/java/net/runelite/cache/script/Instructions.java b/cache/src/main/java/net/runelite/cache/script/Instructions.java index a9b1b783cc..5bf125fbfd 100644 --- a/cache/src/main/java/net/runelite/cache/script/Instructions.java +++ b/cache/src/main/java/net/runelite/cache/script/Instructions.java @@ -463,7 +463,7 @@ public class Instructions add(5504, 2, 0); add(5505, 0, 1); add(GET_MAPANGLE, "get_mapangle", 0, 1); - add(5530, 1, 0); + add(SET_CAMERA_FOCAL_POINT_HEIGHT, "set_camera_focal_point_height", 1, 0); add(5531, 0, 1); // 5600-5700 add(CANCEL_LOGIN, "cancel_login", 0, 0); diff --git a/cache/src/main/java/net/runelite/cache/script/Opcodes.java b/cache/src/main/java/net/runelite/cache/script/Opcodes.java index a5d8fcd806..066f909953 100644 --- a/cache/src/main/java/net/runelite/cache/script/Opcodes.java +++ b/cache/src/main/java/net/runelite/cache/script/Opcodes.java @@ -361,6 +361,7 @@ public class Opcodes public static final int GET_SCREENTYPE = 5308; public static final int SET_SCREENTYPE = 5309; public static final int GET_MAPANGLE = 5506; + public static final int SET_CAMERA_FOCAL_POINT_HEIGHT = 5530; public static final int CANCEL_LOGIN = 5630; public static final int SET_ZOOM_DISTANCE = 6201; public static final int GET_VIEWPORT_SIZE = 6203; From 6353bb0138132241d6c99efcc7f98db1a7530fec Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 21:41:17 -0500 Subject: [PATCH 08/17] cache: add get_camera_focal_point_height --- cache/src/main/java/net/runelite/cache/script/Instructions.java | 2 +- cache/src/main/java/net/runelite/cache/script/Opcodes.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cache/src/main/java/net/runelite/cache/script/Instructions.java b/cache/src/main/java/net/runelite/cache/script/Instructions.java index 5bf125fbfd..39a7c8b95b 100644 --- a/cache/src/main/java/net/runelite/cache/script/Instructions.java +++ b/cache/src/main/java/net/runelite/cache/script/Instructions.java @@ -464,7 +464,7 @@ public class Instructions add(5505, 0, 1); add(GET_MAPANGLE, "get_mapangle", 0, 1); add(SET_CAMERA_FOCAL_POINT_HEIGHT, "set_camera_focal_point_height", 1, 0); - add(5531, 0, 1); + add(GET_CAMERA_FOCAL_POINT_HEIGHT, "get_camera_focal_point_height", 0, 1); // 5600-5700 add(CANCEL_LOGIN, "cancel_login", 0, 0); // 5700-6300 diff --git a/cache/src/main/java/net/runelite/cache/script/Opcodes.java b/cache/src/main/java/net/runelite/cache/script/Opcodes.java index 066f909953..4f87b70ccc 100644 --- a/cache/src/main/java/net/runelite/cache/script/Opcodes.java +++ b/cache/src/main/java/net/runelite/cache/script/Opcodes.java @@ -362,6 +362,7 @@ public class Opcodes public static final int SET_SCREENTYPE = 5309; public static final int GET_MAPANGLE = 5506; public static final int SET_CAMERA_FOCAL_POINT_HEIGHT = 5530; + public static final int GET_CAMERA_FOCAL_POINT_HEIGHT = 5531; public static final int CANCEL_LOGIN = 5630; public static final int SET_ZOOM_DISTANCE = 6201; public static final int GET_VIEWPORT_SIZE = 6203; From 049ab218191354ecfac9fe3d37c8a82c1b349e7e Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jan 2018 22:32:54 -0500 Subject: [PATCH 09/17] cache: add script id to grammar --- .../antlr4/net/runelite/cache/script/assembler/rs2asm.g4 | 4 +++- .../runelite/cache/script/assembler/ScriptWriter.java | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cache/src/main/antlr4/net/runelite/cache/script/assembler/rs2asm.g4 b/cache/src/main/antlr4/net/runelite/cache/script/assembler/rs2asm.g4 index 7d0717dbcd..ce445596a6 100644 --- a/cache/src/main/antlr4/net/runelite/cache/script/assembler/rs2asm.g4 +++ b/cache/src/main/antlr4/net/runelite/cache/script/assembler/rs2asm.g4 @@ -26,13 +26,15 @@ grammar rs2asm; prog: (header NEWLINE)* (line NEWLINE)+ ; -header: int_stack_count | string_stack_count | int_var_count | string_var_count ; +header: id | int_stack_count | string_stack_count | int_var_count | string_var_count ; +id: '.id ' id_value ; int_stack_count: '.int_stack_count ' int_stack_value ; string_stack_count: '.string_stack_count ' string_stack_value ; int_var_count: '.int_var_count ' int_var_value ; string_var_count: '.string_var_count ' string_var_value ; +id_value: INT ; int_stack_value: INT ; string_stack_value: INT ; int_var_value: INT ; diff --git a/cache/src/main/java/net/runelite/cache/script/assembler/ScriptWriter.java b/cache/src/main/java/net/runelite/cache/script/assembler/ScriptWriter.java index 39e314d499..4201619e05 100644 --- a/cache/src/main/java/net/runelite/cache/script/assembler/ScriptWriter.java +++ b/cache/src/main/java/net/runelite/cache/script/assembler/ScriptWriter.java @@ -42,6 +42,7 @@ public class ScriptWriter extends rs2asmBaseListener private final Instructions instructions; private final LabelVisitor labelVisitor; + private int id; private int pos; private int intStackCount; private int stringStackCount; @@ -58,6 +59,13 @@ public class ScriptWriter extends rs2asmBaseListener this.labelVisitor = labelVisitor; } + @Override + public void enterId_value(rs2asmParser.Id_valueContext ctx) + { + int value = Integer.parseInt(ctx.getText()); + id = value; + } + @Override public void enterInt_stack_value(rs2asmParser.Int_stack_valueContext ctx) { @@ -209,6 +217,7 @@ public class ScriptWriter extends rs2asmBaseListener public ScriptDefinition buildScript() { ScriptDefinition script = new ScriptDefinition(); + script.setId(id); script.setIntStackCount(intStackCount); script.setStringStackCount(stringStackCount); script.setLocalIntCount(localIntCount); From 3d9542a8b46b93a4e0d83ffbbe475fd71e9c5410 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jan 2018 12:38:38 -0500 Subject: [PATCH 10/17] runescape-api: add IndexData and IndexDataBase --- .../java/net/runelite/rs/api/RSIndexData.java | 33 +++++++++++++++++++ .../net/runelite/rs/api/RSIndexDataBase.java | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 runescape-api/src/main/java/net/runelite/rs/api/RSIndexData.java create mode 100644 runescape-api/src/main/java/net/runelite/rs/api/RSIndexDataBase.java diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSIndexData.java b/runescape-api/src/main/java/net/runelite/rs/api/RSIndexData.java new file mode 100644 index 0000000000..6ec1b9d3b6 --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSIndexData.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.rs.api; + +import net.runelite.mapping.Import; + +public interface RSIndexData extends RSIndexDataBase +{ + @Import("index") + int getIndex(); +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSIndexDataBase.java b/runescape-api/src/main/java/net/runelite/rs/api/RSIndexDataBase.java new file mode 100644 index 0000000000..d90bc34f58 --- /dev/null +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSIndexDataBase.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.rs.api; + +import net.runelite.mapping.Import; + +public interface RSIndexDataBase +{ + @Import("getConfigData") + byte[] getConfigData(int archiveId, int fileId); +} From e467ebdcf8f432b03b1c51b40c617512f66b944a Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jan 2018 12:41:50 -0500 Subject: [PATCH 11/17] Add slf4j to mixins and expose logger in Hooks for them --- .../src/main/java/net/runelite/client/callback/Hooks.java | 7 +++++-- runelite-mixins/pom.xml | 6 ++++++ .../src/main/java/net/runelite/client/callback/Hooks.java | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java index 2ab5179f52..4b1b2cd296 100644 --- a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java +++ b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java @@ -35,7 +35,6 @@ import com.google.inject.Injector; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.image.BufferedImage; -import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.MainBufferProvider; @@ -52,10 +51,14 @@ import net.runelite.client.task.Scheduler; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayRenderer; import net.runelite.client.ui.overlay.infobox.InfoBoxManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Slf4j public class Hooks { + // must be public as the mixins use it + public static final Logger log = LoggerFactory.getLogger(Hooks.class); + private static final long CHECK = 600; // ms - how often to run checks private static final Injector injector = RuneLite.getInjector(); diff --git a/runelite-mixins/pom.xml b/runelite-mixins/pom.xml index 7fa14e3834..492a7188da 100644 --- a/runelite-mixins/pom.xml +++ b/runelite-mixins/pom.xml @@ -37,6 +37,12 @@ RuneLite Mixins + + org.slf4j + slf4j-api + 1.7.21 + provided + net.runelite.rs api diff --git a/runelite-mixins/src/main/java/net/runelite/client/callback/Hooks.java b/runelite-mixins/src/main/java/net/runelite/client/callback/Hooks.java index e0e0c51ae8..03d5b49020 100644 --- a/runelite-mixins/src/main/java/net/runelite/client/callback/Hooks.java +++ b/runelite-mixins/src/main/java/net/runelite/client/callback/Hooks.java @@ -25,6 +25,7 @@ package net.runelite.client.callback; import com.google.common.eventbus.EventBus; +import org.slf4j.Logger; /** * Dummy class to make the mixins to compile. @@ -33,5 +34,7 @@ import com.google.common.eventbus.EventBus; */ public class Hooks { + public static Logger log; + public static EventBus eventBus; } From c4d838b10c685c1af70b4f586912fd2166c5e433 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jan 2018 12:57:27 -0500 Subject: [PATCH 12/17] Add ability to overlay cache archives --- runelite-api/pom.xml | 5 + .../runelite/api/overlay/OverlayIndex.java | 61 ++++++++++++ .../runelite/mixins/RSIndexDataBaseMixin.java | 99 +++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 runelite-api/src/main/java/net/runelite/api/overlay/OverlayIndex.java create mode 100644 runelite-mixins/src/main/java/net/runelite/mixins/RSIndexDataBaseMixin.java diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index 20427e8399..ff91c0ad46 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -37,6 +37,11 @@ RuneLite API + + org.slf4j + slf4j-api + 1.7.21 + org.projectlombok lombok diff --git a/runelite-api/src/main/java/net/runelite/api/overlay/OverlayIndex.java b/runelite-api/src/main/java/net/runelite/api/overlay/OverlayIndex.java new file mode 100644 index 0000000000..6aec875181 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/overlay/OverlayIndex.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api.overlay; + +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashSet; +import java.util.Set; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class OverlayIndex +{ + private static final Set overlays = new HashSet<>(); + + static + { + InputStream indexStream = OverlayIndex.class.getResourceAsStream("/runelite/index"); + + try (DataInputStream in = new DataInputStream(indexStream)) + { + int id; + while ((id = in.readInt()) != -1) + { + overlays.add(id); + } + } + catch (IOException ex) + { + log.warn("unable to load overlay index", ex); + } + } + + public static boolean hasOverlay(int indexId, int archiveId) + { + return overlays.contains(indexId << 16 | archiveId); + } +} diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSIndexDataBaseMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSIndexDataBaseMixin.java new file mode 100644 index 0000000000..e4c953bd12 --- /dev/null +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSIndexDataBaseMixin.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.mixins; + +import com.google.common.hash.HashCode; +import com.google.common.hash.Hashing; +import com.google.common.io.BaseEncoding; +import com.google.common.io.ByteStreams; +import com.google.common.io.CharStreams; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import net.runelite.api.mixins.Copy; +import net.runelite.api.mixins.Mixin; +import net.runelite.api.mixins.Replace; +import net.runelite.api.overlay.OverlayIndex; +import static net.runelite.client.callback.Hooks.log; +import net.runelite.rs.api.RSIndexData; +import net.runelite.rs.api.RSIndexDataBase; + +@Mixin(RSIndexDataBase.class) +public abstract class RSIndexDataBaseMixin implements RSIndexDataBase +{ + @Copy("getConfigData") + abstract byte[] rs$getConfigData(int archiveId, int fileId); + + @Replace("getConfigData") + public byte[] rl$getConfigData(int archiveId, int fileId) + { + byte[] rsData = rs$getConfigData(archiveId, fileId); + RSIndexData indexData = (RSIndexData) this; + + if (!OverlayIndex.hasOverlay(indexData.getIndex(), archiveId)) + { + return rsData; + } + + InputStream in = getClass().getResourceAsStream("/runelite/" + indexData.getIndex() + "/" + archiveId); + if (in == null) + { + log.warn("Missing overlay data for {}/{}", indexData.getIndex(), archiveId); + return rsData; + } + + HashCode rsDataHash = Hashing.sha256().hashBytes(rsData); + + String rsHash = BaseEncoding.base16().encode(rsDataHash.asBytes()); + + InputStream in2 = getClass().getResourceAsStream("/runelite/" + indexData.getIndex() + "/" + archiveId + ".hash"); + if (in2 == null) + { + log.warn("Missing hash file for {}/{}", indexData.getIndex(), archiveId); + return rsData; + } + + try + { + String replaceHash = CharStreams.toString(new InputStreamReader(in2)); + + if (replaceHash.equals(rsHash)) + { + log.debug("Replacing archive {}/{}", + indexData.getIndex(), archiveId); + return ByteStreams.toByteArray(in); + } + + log.warn("Mismatch in overlaid cache archive hash for {}/{}: {} != {}", + indexData.getIndex(), archiveId, replaceHash, rsHash); + } + catch (IOException ex) + { + log.warn("error checking hash", ex); + } + + return rsData; + } +} From 41f005827c8739ff0875c50f3d8081bdd1aa2082 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jan 2018 13:01:11 -0500 Subject: [PATCH 13/17] Add runelite vm opcode and event --- .../main/java/net/runelite/api/Opcodes.java | 30 +++++++++++ .../net/runelite/api/events/ScriptEvent.java | 35 ++++++++++++ .../net/runelite/client/callback/Hooks.java | 24 +++++++++ .../net/runelite/client/callback/Hooks.java | 6 +++ .../java/net/runelite/mixins/VmMixin.java | 53 +++++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 runelite-api/src/main/java/net/runelite/api/Opcodes.java create mode 100644 runelite-api/src/main/java/net/runelite/api/events/ScriptEvent.java create mode 100644 runelite-mixins/src/main/java/net/runelite/mixins/VmMixin.java diff --git a/runelite-api/src/main/java/net/runelite/api/Opcodes.java b/runelite-api/src/main/java/net/runelite/api/Opcodes.java new file mode 100644 index 0000000000..6cb4bfcbfb --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/Opcodes.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api; + +public class Opcodes +{ + public static final int RUNELITE_EXECUTE = 6599; +} diff --git a/runelite-api/src/main/java/net/runelite/api/events/ScriptEvent.java b/runelite-api/src/main/java/net/runelite/api/events/ScriptEvent.java new file mode 100644 index 0000000000..db6887c25e --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/events/ScriptEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.api.events; + +import lombok.Data; +import net.runelite.api.Script; + +@Data +public class ScriptEvent +{ + private Script script; + private String eventName; +} diff --git a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java index 4b1b2cd296..d9a73fb7ac 100644 --- a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java +++ b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java @@ -44,6 +44,8 @@ import net.runelite.api.PacketBuffer; import net.runelite.api.Point; import net.runelite.api.Projectile; import net.runelite.api.Region; +import net.runelite.api.Script; +import net.runelite.api.events.ScriptEvent; import net.runelite.client.RuneLite; import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.game.DeathChecker; @@ -151,6 +153,28 @@ public class Hooks } } + /** + * + * @param opcode + * @param script + * @param isOne + * @return 0 halts, 1 continues, 2 throws + */ + public static int runeliteExecute(int opcode, Script script, boolean isOne) + { + String[] stringStack = client.getStringStack(); + int stackSize = client.getStringStackSize(); + String eventName = stringStack[--stackSize]; + client.setStringStackSize(stackSize); + + ScriptEvent event = new ScriptEvent(); + event.setScript(script); + event.setEventName(eventName); + eventBus.post(event); + + return 1; + } + public static void menuActionHook(int actionParam, int widgetId, int menuAction, int id, String menuOption, String menuTarget, int var6, int var7) { /* Along the way, the RuneScape client may change a menuAction by incrementing it with 2000. diff --git a/runelite-mixins/src/main/java/net/runelite/client/callback/Hooks.java b/runelite-mixins/src/main/java/net/runelite/client/callback/Hooks.java index 03d5b49020..a904a09c54 100644 --- a/runelite-mixins/src/main/java/net/runelite/client/callback/Hooks.java +++ b/runelite-mixins/src/main/java/net/runelite/client/callback/Hooks.java @@ -25,6 +25,7 @@ package net.runelite.client.callback; import com.google.common.eventbus.EventBus; +import net.runelite.api.Script; import org.slf4j.Logger; /** @@ -37,4 +38,9 @@ public class Hooks public static Logger log; public static EventBus eventBus; + + public static int runeliteExecute(int opcode, Script script, boolean isOne) + { + throw new RuntimeException(); + } } diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/VmMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/VmMixin.java new file mode 100644 index 0000000000..c81b206c41 --- /dev/null +++ b/runelite-mixins/src/main/java/net/runelite/mixins/VmMixin.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.mixins; + +import static net.runelite.api.Opcodes.RUNELITE_EXECUTE; +import net.runelite.api.Script; +import net.runelite.api.mixins.Copy; +import net.runelite.api.mixins.Mixin; +import net.runelite.api.mixins.Replace; +import net.runelite.client.callback.Hooks; +import net.runelite.rs.api.RSClient; + +@Mixin(RSClient.class) +public abstract class VmMixin +{ + @Copy("execute6500") + static int rs$execute6500(int opcode, Script script, boolean isOne) + { + throw new RuntimeException(); + } + + @Replace("execute6500") + static int rl$execute6500(int opcode, Script script, boolean isOne) + { + if (opcode == RUNELITE_EXECUTE) + { + return Hooks.runeliteExecute(opcode, script, isOne); + } + return rs$execute6500(opcode, script, isOne); + } +} From 4bfa22448dcb6d8fec43f393a0fd7b8672629a64 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jan 2018 13:01:56 -0500 Subject: [PATCH 14/17] Add int and string script stack to api --- .../main/java/net/runelite/api/Client.java | 12 ++++++++++ .../java/net/runelite/rs/api/RSClient.java | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 12aee0a545..3acfd9d038 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -255,4 +255,16 @@ public interface Client extends GameEngine * @return */ ItemContainer getItemContainer(InventoryID inventory); + + int getIntStackSize(); + + void setIntStackSize(int stackSize); + + int[] getIntStack(); + + int getStringStackSize(); + + void setStringStackSize(int stackSize); + + String[] getStringStack(); } diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java index 06f89c20b7..78bd9a84e0 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java @@ -436,4 +436,28 @@ public interface RSClient extends RSGameEngine, Client @Construct RSItem createItem(); + + @Import("intStackSize") + @Override + int getIntStackSize(); + + @Import("intStackSize") + @Override + void setIntStackSize(int stackSize); + + @Import("intStack") + @Override + int[] getIntStack(); + + @Import("scriptStringStackSize") + @Override + int getStringStackSize(); + + @Import("scriptStringStackSize") + @Override + void setStringStackSize(int stackSize); + + @Import("scriptStringStack") + @Override + String[] getStringStack(); } From edabf9ea71181acded5aa20a3190e96d6d42243c Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jan 2018 13:04:38 -0500 Subject: [PATCH 15/17] Add script assembler plugin for packing scripts at build time --- pom.xml | 1 + runelite-script-assembler-plugin/pom.xml | 79 ++++++++++++++ .../net/runelite/script/AssembleMojo.java | 101 ++++++++++++++++++ .../java/net/runelite/script/IndexMojo.java | 86 +++++++++++++++ .../runelite/script/RuneLiteInstructions.java | 38 +++++++ 5 files changed, 305 insertions(+) create mode 100644 runelite-script-assembler-plugin/pom.xml create mode 100644 runelite-script-assembler-plugin/src/main/java/net/runelite/script/AssembleMojo.java create mode 100644 runelite-script-assembler-plugin/src/main/java/net/runelite/script/IndexMojo.java create mode 100644 runelite-script-assembler-plugin/src/main/java/net/runelite/script/RuneLiteInstructions.java diff --git a/pom.xml b/pom.xml index 9e3b4a79f0..7680458c37 100644 --- a/pom.xml +++ b/pom.xml @@ -119,6 +119,7 @@ runelite-api runelite-client runelite-mixins + runelite-script-assembler-plugin runescape-api runescape-client runescape-client-injector diff --git a/runelite-script-assembler-plugin/pom.xml b/runelite-script-assembler-plugin/pom.xml new file mode 100644 index 0000000000..865d8e9875 --- /dev/null +++ b/runelite-script-assembler-plugin/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + + net.runelite + runelite-parent + 1.2.14-SNAPSHOT + + + net.runelite + script-assembler-plugin + Script Assembler Plugin + maven-plugin + + + + net.runelite + cache + ${project.version} + + + net.runelite + api + ${project.version} + + + + org.apache.maven + maven-plugin-api + 3.0.5 + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.4 + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.4 + + + default-descriptor + process-classes + + + + + + diff --git a/runelite-script-assembler-plugin/src/main/java/net/runelite/script/AssembleMojo.java b/runelite-script-assembler-plugin/src/main/java/net/runelite/script/AssembleMojo.java new file mode 100644 index 0000000000..9ee058d690 --- /dev/null +++ b/runelite-script-assembler-plugin/src/main/java/net/runelite/script/AssembleMojo.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.script; + +import com.google.common.io.Files; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import net.runelite.cache.IndexType; +import net.runelite.cache.definitions.ScriptDefinition; +import net.runelite.cache.definitions.savers.ScriptSaver; +import net.runelite.cache.script.assembler.Assembler; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + +@Mojo( + name = "assemble", + defaultPhase = LifecyclePhase.GENERATE_RESOURCES +) +public class AssembleMojo extends AbstractMojo +{ + @Parameter(required = true) + private File scriptDirectory; + + @Parameter(required = true) + private File outputDirectory; + + private final Log log = getLog(); + + @Override + public void execute() throws MojoExecutionException, MojoFailureException + { + RuneLiteInstructions instructions = new RuneLiteInstructions(); + instructions.init(); + + Assembler assembler = new Assembler(instructions); + ScriptSaver saver = new ScriptSaver(); + + int count = 0; + File scriptOut = new File(outputDirectory, Integer.toString(IndexType.CLIENTSCRIPT.getNumber())); + scriptOut.mkdirs(); + + for (File scriptFile : scriptDirectory.listFiles((dir, name) -> name.endsWith(".rs2asm"))) + { + log.debug("Assembling " + scriptFile); + + try (FileInputStream fin = new FileInputStream(scriptFile)) + { + File hashFile = new File(scriptDirectory, Files.getNameWithoutExtension(scriptFile.getName()) + ".hash"); + if (!hashFile.exists()) + { + throw new MojoExecutionException("Unable to find hash file for " + scriptFile); + } + + ScriptDefinition script = assembler.assemble(fin); + byte[] packedScript = saver.save(script); + + File targetFile = new File(scriptOut, Integer.toString(script.getId())); + Files.write(packedScript, targetFile); + + // Copy hash file + Files.copy(hashFile, new File(scriptOut, Integer.toString(script.getId()) + ".hash")); + + ++count; + } + catch (IOException ex) + { + throw new MojoFailureException("unable to open file", ex); + } + } + + log.info("Assembled " + count + " scripts"); + } +} diff --git a/runelite-script-assembler-plugin/src/main/java/net/runelite/script/IndexMojo.java b/runelite-script-assembler-plugin/src/main/java/net/runelite/script/IndexMojo.java new file mode 100644 index 0000000000..fa41a2f064 --- /dev/null +++ b/runelite-script-assembler-plugin/src/main/java/net/runelite/script/IndexMojo.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.script; + +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import static java.lang.Integer.parseInt; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + +@Mojo( + name = "build-index", + defaultPhase = LifecyclePhase.GENERATE_RESOURCES +) +public class IndexMojo extends AbstractMojo +{ + @Parameter(required = true) + private File archiveOverlayDirectory; + + @Parameter(required = true) + private File indexFile; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException + { + try (DataOutputStream fout = new DataOutputStream(new FileOutputStream(indexFile))) + { + for (File indexFolder : archiveOverlayDirectory.listFiles()) + { + if (indexFolder.isDirectory()) + { + int indexId = parseInt(indexFolder.getName()); + for (File archiveFile : indexFolder.listFiles()) + { + int archiveId; + try + { + archiveId = parseInt(archiveFile.getName()); + } + catch (NumberFormatException ex) + { + continue; + } + + fout.writeInt(indexId << 16 | archiveId); + } + } + } + + fout.writeInt(-1); + } + catch (IOException ex) + { + throw new MojoExecutionException("error build index file", ex); + } + } + +} diff --git a/runelite-script-assembler-plugin/src/main/java/net/runelite/script/RuneLiteInstructions.java b/runelite-script-assembler-plugin/src/main/java/net/runelite/script/RuneLiteInstructions.java new file mode 100644 index 0000000000..654e5e407c --- /dev/null +++ b/runelite-script-assembler-plugin/src/main/java/net/runelite/script/RuneLiteInstructions.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.script; + +import static net.runelite.api.Opcodes.RUNELITE_EXECUTE; +import net.runelite.cache.script.Instructions; + +public class RuneLiteInstructions extends Instructions +{ + @Override + public void init() + { + super.init(); + add(RUNELITE_EXECUTE, "runelite_callback", 0, 0, 1, 0); + } +} From 7e4bbf66cb27d3c598e90a1e875b21ce9a162437 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jan 2018 13:05:31 -0500 Subject: [PATCH 16/17] Add runelite-scripts project for packaging overlaid scripts and dependency --- pom.xml | 1 + runelite-client/pom.xml | 6 ++++ runelite-scripts/pom.xml | 70 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 runelite-scripts/pom.xml diff --git a/pom.xml b/pom.xml index 7680458c37..7dc6fdb5e9 100644 --- a/pom.xml +++ b/pom.xml @@ -120,6 +120,7 @@ runelite-client runelite-mixins runelite-script-assembler-plugin + runelite-scripts runescape-api runescape-client runescape-client-injector diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index b27feb8080..1448ad7f04 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -109,6 +109,12 @@ ${project.version} runtime + + net.runelite + scripts + ${project.version} + runtime + net.runelite http-api diff --git a/runelite-scripts/pom.xml b/runelite-scripts/pom.xml new file mode 100644 index 0000000000..86545a7827 --- /dev/null +++ b/runelite-scripts/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + + net.runelite + runelite-parent + 1.2.14-SNAPSHOT + + + net.runelite + scripts + RuneLite Scripts + + + + + net.runelite + script-assembler-plugin + ${project.version} + + + assemble + + assemble + + + ${project.basedir}/scripts + ${project.build.outputDirectory}/runelite + + + + build-index + + build-index + + + ${project.build.outputDirectory}/runelite + ${project.build.outputDirectory}/runelite/index + + + + + + + From f8baca7be53d15aa0756ee0a994f397961bb5403 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jan 2018 13:05:53 -0500 Subject: [PATCH 17/17] Add zoom plugin --- .../client/plugins/zoom/ZoomConfig.java | 47 ++ .../client/plugins/zoom/ZoomPlugin.java | 84 ++++ .../scripts/OptionsPanelRebuilder.hash | 1 + .../scripts/OptionsPanelRebuilder.rs2asm | 451 ++++++++++++++++++ .../OptionsPanelZoomMouseListener.hash | 1 + .../OptionsPanelZoomMouseListener.rs2asm | 70 +++ .../scripts/OptionsPanelZoomUpdater.hash | 1 + .../scripts/OptionsPanelZoomUpdater.rs2asm | 67 +++ .../scripts/ScrollWheelZoomHandler.hash | 1 + .../scripts/ScrollWheelZoomHandler.rs2asm | 87 ++++ 10 files changed, 810 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java create mode 100644 runelite-scripts/scripts/OptionsPanelRebuilder.hash create mode 100644 runelite-scripts/scripts/OptionsPanelRebuilder.rs2asm create mode 100644 runelite-scripts/scripts/OptionsPanelZoomMouseListener.hash create mode 100644 runelite-scripts/scripts/OptionsPanelZoomMouseListener.rs2asm create mode 100644 runelite-scripts/scripts/OptionsPanelZoomUpdater.hash create mode 100644 runelite-scripts/scripts/OptionsPanelZoomUpdater.rs2asm create mode 100644 runelite-scripts/scripts/ScrollWheelZoomHandler.hash create mode 100644 runelite-scripts/scripts/ScrollWheelZoomHandler.rs2asm diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java new file mode 100644 index 0000000000..03ed25f33c --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zoom; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup( + keyName = "zoom", + name = "Zoom Unlimiter", + description = "Configuration for the camera zoom limit" +) +public interface ZoomConfig extends Config +{ + @ConfigItem( + keyName = "enabled", + name = "Enabled", + description = "Configures whether or not the zoom limit is reduced" + ) + default boolean enabled() + { + return false; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java new file mode 100644 index 0000000000..4dd0a42ad0 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zoom/ZoomPlugin.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2018 Abex + * Copyright (c) 2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.zoom; + +import com.google.common.eventbus.Subscribe; +import com.google.inject.Inject; +import com.google.inject.Provides; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Client; +import net.runelite.api.events.ScriptEvent; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; + +@PluginDescriptor( + name = "Camera zoom unlimiter" +) +@Slf4j +public class ZoomPlugin extends Plugin +{ + private static final int INCREASED_RESIZABLE_ZOOM_LIMIT = 70; + private static final int INCREASED_FIXED_ZOOM_LIMIT = 95; + + @Inject + private Client client; + + @Inject + private ZoomConfig zoomConfig; + + @Provides + ZoomConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(ZoomConfig.class); + } + + @Subscribe + public void onScriptEvent(ScriptEvent event) + { + if (!zoomConfig.enabled()) + { + return; + } + + switch (event.getEventName()) + { + case "fixedOuterZoomLimit": + popAndReplace(INCREASED_FIXED_ZOOM_LIMIT); + break; + case "resizableOuterZoomLimit": + popAndReplace(INCREASED_RESIZABLE_ZOOM_LIMIT); + break; + } + } + + private void popAndReplace(int newValue) + { + int[] intStack = client.getIntStack(); + int intStackSize = client.getIntStackSize(); + intStack[intStackSize - 1] = newValue; + } +} diff --git a/runelite-scripts/scripts/OptionsPanelRebuilder.hash b/runelite-scripts/scripts/OptionsPanelRebuilder.hash new file mode 100644 index 0000000000..42276b0941 --- /dev/null +++ b/runelite-scripts/scripts/OptionsPanelRebuilder.hash @@ -0,0 +1 @@ +775947F74263107B801155B8D1DB27DBA42F08CE7A14CB07526C5D88288D89F5 \ No newline at end of file diff --git a/runelite-scripts/scripts/OptionsPanelRebuilder.rs2asm b/runelite-scripts/scripts/OptionsPanelRebuilder.rs2asm new file mode 100644 index 0000000000..9b6b1458e7 --- /dev/null +++ b/runelite-scripts/scripts/OptionsPanelRebuilder.rs2asm @@ -0,0 +1,451 @@ +.id 909 +.int_stack_count 2 +.string_stack_count 0 +.int_var_count 15 +.string_var_count 0 + load_int 73 + load_int 73 + iload 1 + load_int 10551298 + get_enum_value + istore 2 + load_int 73 + load_int 73 + iload 1 + load_int 10551306 + get_enum_value + istore 3 + load_int 73 + load_int 73 + iload 1 + load_int 10551301 + get_enum_value + istore 4 + load_int 73 + load_int 73 + iload 1 + load_int 10551308 + get_enum_value + istore 5 + load_int 103 + load_int 105 + load_int 1135 + iload 1 + get_enum_value + istore 6 + load_int 103 + load_int 105 + load_int 1136 + iload 1 + get_enum_value + istore 7 + load_int 0 + istore 8 + load_int 0 + istore 9 + load_int 0 + istore 10 + load_int 0 + istore 11 + load_int 0 + istore 12 + load_int 0 + istore 13 + get_varbit 4606 + load_int 0 + if_icmpne LABEL52 + jump LABEL198 +LABEL52: + get_varbit 4606 + load_int 2 + if_icmpeq LABEL56 + jump LABEL70 +LABEL56: + load_int 256 + load_int 180 + 6200 + load_int 256 + load_int 180 + set_zoom_distance + load_int 0 + load_int 0 + load_int 0 + load_int 0 + 6202 + load_int 50 + set_camera_focal_point_height + jump LABEL83 +LABEL70: + load_int 256 + load_int 256 + 6200 + load_int 256 + load_int 256 + set_zoom_distance + load_int 256 + load_int 256 + load_int 256 + load_int 256 + 6202 + load_int 50 + set_camera_focal_point_height +LABEL83: + iload 2 + load_int -1 + if_icmpne LABEL87 + jump LABEL197 +LABEL87: + iload 3 + load_int -1 + if_icmpne LABEL91 + jump LABEL197 +LABEL91: + get_viewport_size + istore 9 + istore 8 + iload 8 + iload 9 + load_int 0 + load_int 0 + iload 2 + widget_put_size_widget + iload 8 + iload 9 + load_int 0 + load_int 0 + iload 3 + widget_put_size_widget + iload 4 + load_int -1 + if_icmpne LABEL110 + jump LABEL187 +LABEL110: + iload 5 + load_int -1 + if_icmpne LABEL114 + jump LABEL187 +LABEL114: + iload 0 + widget_get_width_widget + istore 10 + iload 0 + widget_get_height_widget + istore 11 + iload 10 + iload 8 + isub + istore 12 + iload 11 + iload 9 + isub + istore 13 + iload 12 + load_int 0 + if_icmplt LABEL132 + jump LABEL134 +LABEL132: + load_int 0 + istore 12 +LABEL134: + iload 13 + load_int 0 + if_icmplt LABEL138 + jump LABEL140 +LABEL138: + load_int 0 + istore 13 +LABEL140: + iload 6 + iload 12 + load_int 2 + idiv + isub + iload 7 + iload 13 + load_int 2 + idiv + isub + istore 7 + istore 6 + iload 6 + load_int 0 + if_icmplt LABEL156 + jump LABEL158 +LABEL156: + load_int 0 + istore 6 +LABEL158: + iload 7 + load_int 0 + if_icmplt LABEL162 + jump LABEL164 +LABEL162: + load_int 0 + istore 7 +LABEL164: + iload 6 + iload 7 + load_int 1 + load_int 1 + iload 4 + widget_put_size_widget + iload 6 + iload 7 + load_int 1 + load_int 1 + iload 5 + widget_put_size_widget + iload 1 + load_int 73 + load_int 73 + iload 1 + load_int 10551307 + get_enum_value + iload 5 + iload 6 + iload 7 + invoke 910 + jump LABEL197 +LABEL187: + iload 1 + load_int 73 + load_int 73 + iload 1 + load_int 10551307 + get_enum_value + iload 3 + load_int 0 + load_int 0 + invoke 910 +LABEL197: + jump LABEL293 +LABEL198: + load_int 0 + load_int 0 + 6200 + load_int 0 + load_int 0 + load_int 0 + load_int 0 + 6202 + get_varc 73 + load_int 195 + load_string "fixedOuterZoomLimit" + runelite_callback + if_icmpge LABEL210 + jump LABEL226 +LABEL210: + get_varc 73 + load_int 700 + if_icmple LABEL214 + jump LABEL226 +LABEL214: + get_varc 74 + load_int 175 + load_string "resizableOuterZoomLimit" + runelite_callback + if_icmpge LABEL218 + jump LABEL226 +LABEL218: + get_varc 74 + load_int 715 + if_icmple LABEL222 + jump LABEL226 +LABEL222: + get_varc 73 + get_varc 74 + invoke 42 + jump LABEL229 +LABEL226: + load_int 256 + load_int 320 + invoke 42 +LABEL229: + get_viewport_size + istore 9 + istore 8 + iload 2 + load_int -1 + if_icmpne LABEL236 + jump LABEL293 +LABEL236: + iload 3 + load_int -1 + if_icmpne LABEL240 + jump LABEL293 +LABEL240: + iload 8 + iload 9 + load_int 0 + load_int 0 + iload 2 + widget_put_size_widget + iload 8 + iload 9 + load_int 0 + load_int 0 + iload 3 + widget_put_size_widget + iload 4 + load_int -1 + if_icmpne LABEL256 + jump LABEL283 +LABEL256: + iload 5 + load_int -1 + if_icmpne LABEL260 + jump LABEL283 +LABEL260: + iload 6 + iload 7 + load_int 1 + load_int 1 + iload 4 + widget_put_size_widget + iload 6 + iload 7 + load_int 1 + load_int 1 + iload 5 + widget_put_size_widget + iload 1 + load_int 73 + load_int 73 + iload 1 + load_int 10551307 + get_enum_value + iload 5 + iload 6 + iload 7 + invoke 910 + jump LABEL293 +LABEL283: + iload 1 + load_int 73 + load_int 73 + iload 1 + load_int 10551307 + get_enum_value + iload 3 + load_int 0 + load_int 0 + invoke 910 +LABEL293: + load_int 73 + load_int 73 + iload 1 + load_int 10551309 + get_enum_value + istore 14 + iload 14 + load_int -1 + if_icmpne LABEL303 + jump LABEL347 +LABEL303: + invoke 1972 + load_int 0 + if_icmpeq LABEL307 + jump LABEL341 +LABEL307: + iload 14 + widget_get_index_widget + load_int 1 + if_icmpeq LABEL312 + jump LABEL341 +LABEL312: + get_varc 173 + load_int -2 + if_icmpeq LABEL316 + jump LABEL323 +LABEL316: + load_int 512 + load_int 0 + load_int 0 + load_int 1 + iload 14 + widget_put_size_widget + jump LABEL340 +LABEL323: + get_varc 173 + load_int -3 + if_icmpeq LABEL327 + jump LABEL334 +LABEL327: + load_int 0 + load_int 0 + load_int 1 + load_int 1 + iload 14 + widget_put_size_widget + jump LABEL340 +LABEL334: + load_int 512 + load_int 334 + load_int 0 + load_int 0 + iload 14 + widget_put_size_widget +LABEL340: + jump LABEL347 +LABEL341: + load_int 512 + load_int 334 + load_int 0 + load_int 0 + iload 14 + widget_put_size_widget +LABEL347: + load_int 73 + load_int 73 + iload 1 + load_int 10551311 + get_enum_value + istore 14 + iload 14 + load_int -1 + if_icmpne LABEL357 + jump LABEL390 +LABEL357: + load_int 73 + load_int 73 + iload 1 + load_int 10551303 + get_enum_value + widget_get_index_widget + load_int 1 + if_icmpeq LABEL366 + jump LABEL384 +LABEL366: + get_varbit 4692 + load_int 0 + if_icmpne LABEL370 + jump LABEL377 +LABEL370: + load_int 0 + load_int 0 + load_int 2 + load_int 0 + iload 14 + widget_put_position_widget + jump LABEL383 +LABEL377: + load_int 0 + load_int 36 + load_int 2 + load_int 0 + iload 14 + widget_put_position_widget +LABEL383: + jump LABEL390 +LABEL384: + load_int 0 + load_int 0 + load_int 2 + load_int 0 + iload 14 + widget_put_position_widget +LABEL390: + iload 0 + iload 1 + invoke 920 + return diff --git a/runelite-scripts/scripts/OptionsPanelZoomMouseListener.hash b/runelite-scripts/scripts/OptionsPanelZoomMouseListener.hash new file mode 100644 index 0000000000..bdef54ddee --- /dev/null +++ b/runelite-scripts/scripts/OptionsPanelZoomMouseListener.hash @@ -0,0 +1 @@ +3DAFC5BFBE17305C5FA503EB6D749299500F9FAF6549309649C3AC5CEC4A8FCC \ No newline at end of file diff --git a/runelite-scripts/scripts/OptionsPanelZoomMouseListener.rs2asm b/runelite-scripts/scripts/OptionsPanelZoomMouseListener.rs2asm new file mode 100644 index 0000000000..b5c6874084 --- /dev/null +++ b/runelite-scripts/scripts/OptionsPanelZoomMouseListener.rs2asm @@ -0,0 +1,70 @@ +.id 1048 +.int_stack_count 3 +.string_stack_count 0 +.int_var_count 8 +.string_var_count 0 + get_varbit 4606 + load_int 0 + if_icmpne LABEL4 + jump LABEL5 +LABEL4: + return +LABEL5: + load_int 320 + istore 3 + load_int 256 + istore 4 + iload 1 + widget_get_width_widget + iload 0 + widget_get_width_widget + isub + istore 5 + load_int 0 + iload 2 + invoke 1045 + istore 2 + iload 1 + widget_get_width_widget + iload 0 + widget_get_width_widget + isub + iload 2 + invoke 1046 + istore 2 + load_int 715 + load_int 175 + load_string "resizableOuterZoomLimit" + runelite_callback + isub + istore 6 + load_int 700 + load_int 195 + load_string "fixedOuterZoomLimit" + runelite_callback + isub + istore 7 + iload 2 + iload 6 + imul + iload 5 + idiv + load_int 175 + load_string "resizableOuterZoomLimit" + runelite_callback + iadd + istore 3 + iload 2 + iload 7 + imul + iload 5 + idiv + load_int 195 + load_string "fixedOuterZoomLimit" + runelite_callback + iadd + istore 4 + iload 4 + iload 3 + invoke 42 + return diff --git a/runelite-scripts/scripts/OptionsPanelZoomUpdater.hash b/runelite-scripts/scripts/OptionsPanelZoomUpdater.hash new file mode 100644 index 0000000000..43d94ad611 --- /dev/null +++ b/runelite-scripts/scripts/OptionsPanelZoomUpdater.hash @@ -0,0 +1 @@ +91C88AB544E934FB542E358885AB7A0F467D19E03595EDDFC9209FF02BFE5A5F \ No newline at end of file diff --git a/runelite-scripts/scripts/OptionsPanelZoomUpdater.rs2asm b/runelite-scripts/scripts/OptionsPanelZoomUpdater.rs2asm new file mode 100644 index 0000000000..2d4fead69d --- /dev/null +++ b/runelite-scripts/scripts/OptionsPanelZoomUpdater.rs2asm @@ -0,0 +1,67 @@ +.id 1049 +.int_stack_count 0 +.string_stack_count 0 +.int_var_count 6 +.string_var_count 0 + load_int 715 + load_int 175 + load_string "resizableOuterZoomLimit" + runelite_callback + isub + istore 0 + load_int 700 + load_int 195 + load_string "fixedOuterZoomLimit" + runelite_callback + isub + istore 1 + load_int 17104904 + widget_get_width_widget + load_int 17104909 + widget_get_width_widget + isub + istore 2 + load_int 0 + istore 3 + load_int 0 + istore 4 + get_viewport_size + istore 4 + istore 3 + load_int 0 + istore 5 + iload 3 + load_int 334 + if_icmpgt LABEL27 + jump LABEL36 +LABEL27: + get_varc 74 + load_int 175 + load_string "resizableOuterZoomLimit" + runelite_callback + isub + iload 2 + imul + iload 0 + idiv + istore 5 + jump LABEL44 +LABEL36: + get_varc 73 + load_int 195 + load_string "fixedOuterZoomLimit" + runelite_callback + isub + iload 2 + imul + iload 1 + idiv + istore 5 +LABEL44: + iload 5 + load_int 0 + load_int 0 + load_int 0 + load_int 17104909 + widget_put_position_widget + return diff --git a/runelite-scripts/scripts/ScrollWheelZoomHandler.hash b/runelite-scripts/scripts/ScrollWheelZoomHandler.hash new file mode 100644 index 0000000000..a4dbd8b6d7 --- /dev/null +++ b/runelite-scripts/scripts/ScrollWheelZoomHandler.hash @@ -0,0 +1 @@ +E9536E0A6FD51C058A40D644FD0AD28A93778FD53873601DCCE04C97DD835BB0 \ No newline at end of file diff --git a/runelite-scripts/scripts/ScrollWheelZoomHandler.rs2asm b/runelite-scripts/scripts/ScrollWheelZoomHandler.rs2asm new file mode 100644 index 0000000000..15c4098b3c --- /dev/null +++ b/runelite-scripts/scripts/ScrollWheelZoomHandler.rs2asm @@ -0,0 +1,87 @@ +.id 42 +.int_stack_count 2 +.string_stack_count 0 +.int_var_count 6 +.string_var_count 0 + get_varbit 4606 + load_int 0 + if_icmpne LABEL4 + jump LABEL5 +LABEL4: + return +LABEL5: + load_int 700 + iload 0 + invoke 1046 + istore 0 + load_int 195 + load_string "fixedOuterZoomLimit" + runelite_callback + iload 0 + invoke 1045 + istore 0 + load_int 715 + iload 1 + invoke 1046 + istore 1 + load_int 175 + load_string "resizableOuterZoomLimit" + runelite_callback + iload 1 + invoke 1045 + istore 1 + iload 0 + iload 1 + set_zoom_distance + load_int 0 + istore 2 + load_int 0 + istore 3 + get_viewport_size + istore 3 + istore 2 + iload 3 + load_int 334 + isub + istore 4 + iload 4 + load_int 0 + if_icmplt LABEL39 + jump LABEL42 +LABEL39: + load_int 0 + istore 4 + jump LABEL48 +LABEL42: + iload 4 + load_int 100 + if_icmpgt LABEL46 + jump LABEL48 +LABEL46: + load_int 100 + istore 4 +LABEL48: + iload 0 + iload 1 + iload 0 + isub + iload 4 + imul + load_int 100 + idiv + iadd + istore 5 + load_int 25 + load_int 25 + iload 5 + imul + load_int 256 + idiv + iadd + set_camera_focal_point_height + iload 0 + iload 1 + put_varc 74 + put_varc 73 + invoke 1049 + return