Merge pull request #470 from Adam-/zoom

Add zoom plugin
This commit is contained in:
Adam
2018-01-28 09:37:54 -05:00
committed by GitHub
62 changed files with 1552 additions and 1217 deletions

View File

@@ -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 ;
@@ -59,5 +61,6 @@ NEWLINE: '\n'+ ;
INT: '-'? [0-9]+ ;
QSTRING: '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"' ;
INSTRUCTION: [a-z0-9_]+ ;
COMMENT: ';' ~( '\r' | '\n' )* -> channel(HIDDEN) ;
WS: (' ' | '\t')+ -> channel(HIDDEN) ;

View File

@@ -30,14 +30,11 @@ import static net.runelite.cache.script.Opcodes.*;
public class Instructions
{
private static final Map<Integer, Instruction> instructions = new HashMap<>();
private static final Map<String, Instruction> instructionsByName = new HashMap<>();
private final Map<Integer, Instruction> instructions = new HashMap<>();
private final Map<String, Instruction> 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);
@@ -466,16 +463,16 @@ public class Instructions
add(5504, 2, 0);
add(5505, 0, 1);
add(GET_MAPANGLE, "get_mapangle", 0, 1);
add(5530, 1, 0);
add(5531, 0, 1);
add(SET_CAMERA_FOCAL_POINT_HEIGHT, "set_camera_focal_point_height", 1, 0);
add(GET_CAMERA_FOCAL_POINT_HEIGHT, "get_camera_focal_point_height", 0, 1);
// 5600-5700
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);
add(GET_ZOOM_DISTANCE, "get_zoom_distance", 0, 2);
add(6205, 0, 2);
// 6300-6600
add(LOAD_WORLDS, "load_worlds", 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);
}

View File

@@ -361,8 +361,12 @@ 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 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;
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;

View File

@@ -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();

View File

@@ -39,8 +39,10 @@ public class ScriptWriter extends rs2asmBaseListener
{
private static final Logger logger = LoggerFactory.getLogger(ScriptWriter.class);
private final Instructions instructions;
private final LabelVisitor labelVisitor;
private int id;
private int pos;
private int intStackCount;
private int stringStackCount;
@@ -51,11 +53,19 @@ public class ScriptWriter extends rs2asmBaseListener
private List<String> sops = new ArrayList<>();
private List<LookupSwitch> switches = new ArrayList<>();
public ScriptWriter(LabelVisitor labelVisitor)
public ScriptWriter(Instructions instructions, LabelVisitor labelVisitor)
{
this.instructions = instructions;
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)
{
@@ -94,7 +104,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);
@@ -207,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);

View File

@@ -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());

View File

@@ -1,98 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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;
}
}

View File

@@ -1,80 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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);
}
}
}

View File

@@ -1,101 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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<StackContext> ipops = new ArrayList<>();
private final List<StackContext> spops = new ArrayList<>();
private final List<StackContext> ipushes = new ArrayList<>();
private final List<StackContext> 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<StackContext> getIpops()
{
return ipops;
}
public List<StackContext> getSpops()
{
return spops;
}
public List<StackContext> getIpushes()
{
return ipushes;
}
public List<StackContext> getSpushes()
{
return spushes;
}
}

View File

@@ -1,30 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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);
}

View File

@@ -1,78 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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<Integer, InstructionHandler> 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);
}
}

View File

@@ -1,111 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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<Frame> 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);
}
}

View File

@@ -1,68 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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;
}
}

View File

@@ -1,62 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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<InstructionContext> 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<InstructionContext> getPopped()
{
return popped;
}
public Object getValue()
{
return value;
}
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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);
}
}

View File

@@ -1,30 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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
{
}

View File

@@ -1,30 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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
{
}

View File

@@ -1,30 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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
{
}

View File

@@ -1,50 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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");
}
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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);
}
}

View File

@@ -1,46 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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);
}
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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.
}
}

View File

@@ -1,56 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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);
}
}

View File

@@ -1,62 +0,0 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* 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<Integer, Integer> 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);
}
}
}

View File

@@ -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);

View File

@@ -31,7 +31,7 @@ public class InstructionsTest
@Test
public void testInit()
{
Instructions.init();
new Instructions().init();
}
}

View File

@@ -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

View File

@@ -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();

View File

@@ -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

View File

@@ -119,6 +119,8 @@
<module>runelite-api</module>
<module>runelite-client</module>
<module>runelite-mixins</module>
<module>runelite-script-assembler-plugin</module>
<module>runelite-scripts</module>
<module>runescape-api</module>
<module>runescape-client</module>
<module>runescape-client-injector</module>

View File

@@ -37,6 +37,11 @@
<name>RuneLite API</name>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>

View File

@@ -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();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,9 +22,9 @@
* (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;
package net.runelite.api;
public class If_ICmpGE extends If
public class Opcodes
{
public static final int RUNELITE_EXECUTE = 6599;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2018 Abex
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,9 +22,11 @@
* (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;
package net.runelite.api;
public class VariableContext
public interface Script extends Node
{
int[] getIntOperands();
int[] getInstructions();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,9 +22,14 @@
* (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;
package net.runelite.api.events;
public class If_ICmpGT extends If
import lombok.Data;
import net.runelite.api.Script;
@Data
public class ScriptEvent
{
private Script script;
private String eventName;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,28 +22,40 @@
* (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;
package net.runelite.api.overlay;
import java.io.DataInputStream;
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;
import java.util.HashSet;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
public class InterpreterTest
@Slf4j
public class OverlayIndex
{
@Test
public void testRun() throws IOException
private static final Set<Integer> overlays = new HashSet<>();
static
{
InputStream in = InterpreterTest.class.getResourceAsStream("397.rs2asm");
Assert.assertNotNull(in);
InputStream indexStream = OverlayIndex.class.getResourceAsStream("/runelite/index");
Assembler assembler = new Assembler();
ScriptDefinition script = assembler.assemble(in);
Interpreter interpreter = new Interpreter();
interpreter.run(script);
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);
}
}

View File

@@ -109,6 +109,12 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>scripts</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>http-api</artifactId>

View File

@@ -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;
@@ -45,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;
@@ -52,10 +53,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();
@@ -148,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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2018 Abex
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,21 +22,26 @@
* (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;
package net.runelite.client.plugins.zoom;
import java.util.Arrays;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
public class Variables
@ConfigGroup(
keyName = "zoom",
name = "Zoom Unlimiter",
description = "Configuration for the camera zoom limit"
)
public interface ZoomConfig extends Config
{
private final VariableContext[] variables;
public Variables(int count)
@ConfigItem(
keyName = "enabled",
name = "Enabled",
description = "Configures whether or not the zoom limit is reduced"
)
default boolean enabled()
{
variables = new VariableContext[count];
}
public Variables(Variables other)
{
variables = Arrays.copyOf(other.variables, other.variables.length);
return false;
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2018 Abex
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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;
}
}

View File

@@ -37,6 +37,12 @@
<name>RuneLite Mixins</name>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.runelite.rs</groupId>
<artifactId>api</artifactId>

View File

@@ -25,6 +25,8 @@
package net.runelite.client.callback;
import com.google.common.eventbus.EventBus;
import net.runelite.api.Script;
import org.slf4j.Logger;
/**
* Dummy class to make the mixins to compile.
@@ -33,5 +35,12 @@ import com.google.common.eventbus.EventBus;
*/
public class Hooks
{
public static Logger log;
public static EventBus eventBus;
public static int runeliteExecute(int opcode, Script script, boolean isOne)
{
throw new RuntimeException();
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,36 +22,32 @@
* (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;
package net.runelite.mixins;
import java.util.ArrayList;
import java.util.List;
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;
public class Stack
@Mixin(RSClient.class)
public abstract class VmMixin
{
private final List<StackContext> stack = new ArrayList<>();
public Stack()
@Copy("execute6500")
static int rs$execute6500(int opcode, Script script, boolean isOne)
{
throw new RuntimeException();
}
public Stack(Stack other)
@Replace("execute6500")
static int rl$execute6500(int opcode, Script script, boolean isOne)
{
stack.addAll(other.stack);
}
public void push(StackContext ctx)
{
stack.add(ctx);
}
public StackContext pop()
{
if (stack.isEmpty())
if (opcode == RUNELITE_EXECUTE)
{
throw new RuntimeException("stack underflow");
return Hooks.runeliteExecute(opcode, script, isOne);
}
return stack.remove(stack.size() - 1);
return rs$execute6500(opcode, script, isOne);
}
}

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018, Adam <Adam@sigterm.info>
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.runelite</groupId>
<artifactId>runelite-parent</artifactId>
<version>1.2.14-SNAPSHOT</version>
</parent>
<groupId>net.runelite</groupId>
<artifactId>script-assembler-plugin</artifactId>
<name>Script Assembler Plugin</name>
<packaging>maven-plugin</packaging>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.4</version>
<executions>
<execution>
<id>default-descriptor</id>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,101 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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");
}
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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);
}
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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);
}
}

70
runelite-scripts/pom.xml Normal file
View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018, Adam <Adam@sigterm.info>
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.runelite</groupId>
<artifactId>runelite-parent</artifactId>
<version>1.2.14-SNAPSHOT</version>
</parent>
<groupId>net.runelite</groupId>
<artifactId>scripts</artifactId>
<name>RuneLite Scripts</name>
<build>
<plugins>
<plugin>
<groupId>net.runelite</groupId>
<artifactId>script-assembler-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>assemble</id>
<goals>
<goal>assemble</goal>
</goals>
<configuration>
<scriptDirectory>${project.basedir}/scripts</scriptDirectory>
<outputDirectory>${project.build.outputDirectory}/runelite</outputDirectory>
</configuration>
</execution>
<execution>
<id>build-index</id>
<goals>
<goal>build-index</goal>
</goals>
<configuration>
<archiveOverlayDirectory>${project.build.outputDirectory}/runelite</archiveOverlayDirectory>
<indexFile>${project.build.outputDirectory}/runelite/index</indexFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1 @@
775947F74263107B801155B8D1DB27DBA42F08CE7A14CB07526C5D88288D89F5

View File

@@ -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

View File

@@ -0,0 +1 @@
3DAFC5BFBE17305C5FA503EB6D749299500F9FAF6549309649C3AC5CEC4A8FCC

View File

@@ -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

View File

@@ -0,0 +1 @@
91C88AB544E934FB542E358885AB7A0F467D19E03595EDDFC9209FF02BFE5A5F

View File

@@ -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

View File

@@ -0,0 +1 @@
E9536E0A6FD51C058A40D644FD0AD28A93778FD53873601DCCE04C97DD835BB0

View File

@@ -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

View File

@@ -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();

View File

@@ -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();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,9 +22,12 @@
* (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;
package net.runelite.rs.api;
public class If_ICmpEQ extends If
import net.runelite.mapping.Import;
public interface RSIndexData extends RSIndexDataBase
{
@Import("index")
int getIndex();
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* 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);
}

View File

@@ -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();
}