This commit is contained in:
PKLite
2019-07-24 03:50:41 -04:00
2741 changed files with 386829 additions and 65174 deletions

3
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,3 @@
# These are supported funding model platforms
patreon: RuneLitePlus

7
.gitignore vendored
View File

@@ -12,3 +12,10 @@ runelite-client/src/main/resources/META-INF/MANIFEST.MF
git
classes/artifacts/client_jar/run.bat
classes/artifacts/client_jar/client.jar
*.jar
.live/
*/build/
*/out/
.gradle/
runelite-client/src/main/resources/runelite/*
.staging/

View File

@@ -1 +0,0 @@
-Xmx512m

View File

@@ -1,11 +1,13 @@
install: gradle wrapper --gradle-version 4.2
language: java
sudo: false
dist: xenial
dist: trusty
cache:
directories:
- $HOME/.m2
jdk:
- openjdk8
- openjdk11
install: true
script: ./travis/build.sh
- oraclejdk8
script: ./travis/build.sh
before_install:
- chmod +x ./travis/build.sh

View File

@@ -2,20 +2,45 @@
# RuneLitePlus [![Build Status](https://travis-ci.org/runelite-extended/runelite.svg?branch=master)](https://travis-ci.org/runelite-extended/runelite) [![Discord](https://img.shields.io/discord/373382904769675265.svg)](https://discord.gg/HN5gf3m)
# RuneLitePlus
[![Build Status](https://travis-ci.org/runelite-extended/runelite.svg?branch=master)](https://travis-ci.org/runelite-extended/runelite)
[![HitCount](http://hits.dwyl.io/runelite-extended/runelite.svg)](http://hits.dwyl.io/runelite-extended/runelite)
[RuneLitePlus](https://runelitepl.us) is an extended version of [RuneLite](https://github.com/runelite/runelite) that provides more functionality and less restrictions while staying more open-source. We are not affiliated with RuneLite.
[RuneLitePlus](https://runelitepl.us) is a fork of [RuneLite](https://github.com/runelite/runelite) that provides more functionality and less restrictions while staying open source. This is meant to directly compete with 3rd party RL clients that are trying to sell their code.
## Discord
[![Discord](https://img.shields.io/discord/373382904769675265.svg)](https://discord.gg/HN5gf3m)
## Project Layout
- [cache](cache/src/main/java/net/runelite/cache) - Libraries used for reading/writing cache files, as well as the data in it
- [http-api](http-api/src/main/java/net/runelite/http/api) - API for api.runelite.net
- [http-service](http-service/src/main/java/net/runelite/http/service) - Service for api.runelite.net
- [deobfuscator](deobfuscator/src/main/java/net/runelite/deob) - Can decompile and cleanup gamepacks as well as map updates to newer revs
- [http-api](http-api/src/main/java/net/runelite/http/api) - API for runelite and runeliteplus
- [http-service](http-service/src/main/java/net/runelite/http/service) - Service for https://api.runelitepl.us
- [injector-plugin](injector-plugin/src/main/java/net/runelite/injector) - Tool for implementing our modifications to the gamepack
- [runelite-api](runelite-api/src/main/java/net/runelite/api) - RuneLite API, interfaces for accessing the client
- [runelite-mixins](runelite-mixins/src/main/java/net/runelite) - Mixins which are injected into the injected client's classes
- [runelite-mixins](runelite-mixins/src/main/java/net/runelite) - Classes containing the Objects to be injected using the injector-plugin
- [runescape-api](runescape-api/src/main/java/net/runelite) - Mappings correspond to these interfaces, runelite-api is a subset of this
- [runelite-client](runelite-client/src/main/java/net/runelite/client) - Game client with plugins
## Private Servers
Currently we support RSMod which can be found at: https://github.com/Tomm0017/rsmod but should work with any server that follows osrs protocol.
```
Jar/IntelliJ
Use -private-server arg.
Exe
Use --clientargs="--private-server" arg.
Using modified mixins is possible using -local-injected arg, but it looks in a very specific location.
(./injected-client/target/injected-client-X.X.XX-SNAPSHOT.jar) (X.X.XX must match current API version)
-----
Set codebase in ./codebase or in Private Server plugin and restart.
Update modulus in Private Server plugin.
Disable Default World plugin if you have it enabled, this causes issues with codebase.
```
## License
RuneLitePlus is licensed under the BSD 2-clause license. See the license header in the respective file to be sure.

34
build.gradle Normal file
View File

@@ -0,0 +1,34 @@
allprojects {
apply plugin: 'maven'
apply plugin: 'checkstyle'
group = 'net.runelite'
version = '1.5.30-SNAPSHOT'
}
subprojects {
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
mavenLocal()
maven { url "http://repo1.maven.org/maven2" }
maven { url "http://repo.runelite.net" }
maven { url "http://repo.maven.apache.org/maven2" }
maven { url "https://raw.githubusercontent.com/runelite-extended/maven-repo/master" }
}
checkstyle {
toolVersion = '6.4.1'
sourceSets = [sourceSets.main]
configFile = rootProject.file("./checkstyle/checkstyle.xml");
showViolations = true
ignoreFailures = false
}
}

View File

@@ -0,0 +1,9 @@
description = 'Cache Client'
dependencies {
compile project(':cache')
compile project(':protocol')
testCompile group: 'junit', name: 'junit', version:'4.12'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version:'1.7.26'
testCompile project(':cache')
}

View File

@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2016-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.
-->
<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.5.23-SNAPSHOT</version>
</parent>
<artifactId>cache-client</artifactId>
<name>Cache Client</name>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>protocol</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,12 @@
description = 'Cache Updater'
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version:'1.5.6.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version:'1.5.6.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-devtools', version:'1.5.6.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version:'8.0.16'
compile project(':cache-client')
compile group: 'org.sql2o', name: 'sql2o', version:'1.6.0'
compile group: 'io.minio', name: 'minio', version:'3.0.6'
compileOnly group: 'org.projectlombok', name: 'lombok', version:'1.18.8'
}

View File

@@ -1,105 +0,0 @@
<?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.5.23-SNAPSHOT</version>
</parent>
<name>Cache Updater</name>
<artifactId>cache-updater</artifactId>
<properties>
<spring.boot.version>1.5.6.RELEASE</spring.boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${spring.boot.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.45</version>
</dependency>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>cache-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.sql2o</groupId>
<artifactId>sql2o</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>net.runelite.cache.updater.CacheUpdater</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -69,7 +69,7 @@ public class CacheUploader implements Runnable
archive.setHash(hash);
String path = new StringBuilder()
.append(hashStr.substring(0, 2))
.append(hashStr, 0, 2)
.append('/')
.append(hashStr.substring(2))
.toString();

22
cache/build.gradle vendored Normal file
View File

@@ -0,0 +1,22 @@
description = 'Cache'
dependencies {
compile project(':http-api')
compile group: 'com.google.guava', name: 'guava', version:'28.0-jre'
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.25'
compile group: 'org.apache.commons', name: 'commons-compress', version:'1.18'
compile group: 'com.google.code.gson', name: 'gson', version:'2.8.5'
compile group: 'io.netty', name: 'netty-buffer', version:'4.1.37.Final'
compile group: 'org.antlr', name: 'antlr4-runtime', version:'4.6'
compile group: 'commons-cli', name: 'commons-cli', version:'1.4'
testCompile group: 'junit', name: 'junit', version:'4.12'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version:'1.7.26'
testCompile group: 'net.runelite.rs', name: 'cache', version:'165'
compileOnly group: 'org.projectlombok', name: 'lombok', version:'1.18.8'
}
task packageTests(type: Jar) {
from sourceSets.test.output
classifier = 'tests'
}
artifacts.archives packageTests

171
cache/pom.xml vendored
View File

@@ -1,171 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2016-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.
-->
<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.5.23-SNAPSHOT</version>
</parent>
<artifactId>cache</artifactId>
<name>Cache</name>
<properties>
<cache.version>165</cache.version>
<antlr4.version>4.6</antlr4.version>
</properties>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>http-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr4.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.runelite.rs</groupId>
<artifactId>cache</artifactId>
<version>${cache.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<enableAssertions>true</enableAssertions>
<argLine>-Xmx2048m</argLine>
<systemProperties>
<cache.tmpdir>${cache.tmpdir}</cache.tmpdir>
</systemProperties>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr4.version}</version>
<executions>
<execution>
<id>process-resources</id>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,62 @@
/*
* 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.definitions.loaders.sound;
import net.runelite.cache.definitions.sound.AudioEnvelopeDefinition;
import net.runelite.cache.io.InputStream;
public class AudioEnvelopeLoader
{
public AudioEnvelopeDefinition load(InputStream in)
{
AudioEnvelopeDefinition audioEnvelope = new AudioEnvelopeDefinition();
load(audioEnvelope, in);
return audioEnvelope;
}
private void load(AudioEnvelopeDefinition audioEnvelope, InputStream in)
{
audioEnvelope.form = in.readUnsignedByte();
audioEnvelope.start = in.readInt();
audioEnvelope.end = in.readInt();
this.loadSegments(audioEnvelope, in);
}
final void loadSegments(AudioEnvelopeDefinition audioEnvelope, InputStream in)
{
audioEnvelope.segments = in.readUnsignedByte();
audioEnvelope.durations = new int[audioEnvelope.segments];
audioEnvelope.phases = new int[audioEnvelope.segments];
for (int i = 0; i < audioEnvelope.segments; ++i)
{
audioEnvelope.durations[i] = in.readUnsignedShort();
audioEnvelope.phases[i] = in.readUnsignedShort();
}
}
}

View File

@@ -0,0 +1,93 @@
/*
* 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.definitions.loaders.sound;
import net.runelite.cache.definitions.sound.InstrumentDefinition;
import net.runelite.cache.definitions.sound.AudioEnvelopeDefinition;
import net.runelite.cache.io.InputStream;
public class InstrumentLoader
{
private final AudioEnvelopeLoader aeLoader = new AudioEnvelopeLoader();
private final SoundEffectLoader seLoader = new SoundEffectLoader();
public InstrumentDefinition load(InputStream in)
{
InstrumentDefinition instrument = new InstrumentDefinition();
load(instrument, in);
return instrument;
}
private void load(InstrumentDefinition instrument, InputStream in)
{
instrument.pitch = aeLoader.load(in);
instrument.volume = aeLoader.load(in);
int volume = in.readUnsignedByte();
if (volume != 0)
{
in.setOffset(in.getOffset() - 1);
instrument.pitchModifier = aeLoader.load(in);
instrument.pitchModifierAmplitude = aeLoader.load(in);
}
volume = in.readUnsignedByte();
if (volume != 0)
{
in.setOffset(in.getOffset() - 1);
instrument.volumeMultiplier = aeLoader.load(in);
instrument.volumeMultiplierAmplitude = aeLoader.load(in);
}
volume = in.readUnsignedByte();
if (volume != 0)
{
in.setOffset(in.getOffset() - 1);
instrument.release = aeLoader.load(in);
instrument.field1175 = aeLoader.load(in);
}
for (int i = 0; i < 10; ++i)
{
int vol = in.readUnsignedShortSmart();
if (vol == 0)
{
break;
}
instrument.oscillatorVolume[i] = vol;
instrument.oscillatorPitch[i] = in.readShortSmart();
instrument.oscillatorDelays[i] = in.readUnsignedShortSmart();
}
instrument.delayTime = in.readUnsignedShortSmart();
instrument.delayDecay = in.readUnsignedShortSmart();
instrument.duration = in.readUnsignedShort();
instrument.offset = in.readUnsignedShort();
instrument.filterEnvelope = new AudioEnvelopeDefinition();
instrument.filter = seLoader.load(in, instrument.filterEnvelope);
}
}

View File

@@ -1,93 +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.definitions.loaders.sound;
import net.runelite.cache.definitions.sound.SoundEffect1Definition;
import net.runelite.cache.definitions.sound.SoundEffect2Definition;
import net.runelite.cache.io.InputStream;
public class SoundEffect1Loader
{
private final SoundEffect2Loader se2Loader = new SoundEffect2Loader();
private final SoundEffect3Loader se3Loader = new SoundEffect3Loader();
public SoundEffect1Definition load(InputStream in)
{
SoundEffect1Definition se = new SoundEffect1Definition();
load(se, in);
return se;
}
private void load(SoundEffect1Definition se, InputStream var1)
{
se.field1181 = se2Loader.load(var1);
se.field1173 = se2Loader.load(var1);
int var2 = var1.readUnsignedByte();
if (var2 != 0)
{
var1.setOffset(var1.getOffset() - 1);
se.field1174 = se2Loader.load(var1);
se.field1193 = se2Loader.load(var1);
}
var2 = var1.readUnsignedByte();
if (var2 != 0)
{
var1.setOffset(var1.getOffset() - 1);
se.field1183 = se2Loader.load(var1);
se.field1192 = se2Loader.load(var1);
}
var2 = var1.readUnsignedByte();
if (var2 != 0)
{
var1.setOffset(var1.getOffset() - 1);
se.field1178 = se2Loader.load(var1);
se.field1175 = se2Loader.load(var1);
}
for (int var3 = 0; var3 < 10; ++var3)
{
int var4 = var1.readUnsignedShortSmart();
if (var4 == 0)
{
break;
}
se.field1180[var3] = var4;
se.field1179[var3] = var1.readShortSmart();
se.field1177[var3] = var1.readUnsignedShortSmart();
}
se.field1187 = var1.readUnsignedShortSmart();
se.field1184 = var1.readUnsignedShortSmart();
se.field1176 = var1.readUnsignedShort();
se.field1188 = var1.readUnsignedShort();
se.field1186 = new SoundEffect2Definition();
se.field1182 = se3Loader.load(var1, se.field1186);
}
}

View File

@@ -1,95 +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.definitions.loaders.sound;
import net.runelite.cache.definitions.sound.SoundEffect2Definition;
import net.runelite.cache.definitions.sound.SoundEffect3Definition;
import net.runelite.cache.io.InputStream;
public class SoundEffect3Loader
{
private final SoundEffect2Loader se2Loader = new SoundEffect2Loader();
public SoundEffect3Definition load(InputStream in, SoundEffect2Definition var2)
{
SoundEffect3Definition se = new SoundEffect3Definition();
load(se, in, var2);
return se;
}
private void load(SoundEffect3Definition se, InputStream var1, SoundEffect2Definition var2)
{
int var3 = var1.readUnsignedByte();
se.field1155[0] = var3 >> 4;
se.field1155[1] = var3 & 15;
if (var3 != 0)
{
se.field1156[0] = var1.readUnsignedShort();
se.field1156[1] = var1.readUnsignedShort();
int var4 = var1.readUnsignedByte();
int var5;
int var6;
for (var5 = 0; var5 < 2; ++var5)
{
for (var6 = 0; var6 < se.field1155[var5]; ++var6)
{
se.field1154[var5][0][var6] = var1.readUnsignedShort();
se.field1159[var5][0][var6] = var1.readUnsignedShort();
}
}
for (var5 = 0; var5 < 2; ++var5)
{
for (var6 = 0; var6 < se.field1155[var5]; ++var6)
{
if ((var4 & 1 << var5 * 4 << var6) != 0)
{
se.field1154[var5][1][var6] = var1.readUnsignedShort();
se.field1159[var5][1][var6] = var1.readUnsignedShort();
}
else
{
se.field1154[var5][1][var6] = se.field1154[var5][0][var6];
se.field1159[var5][1][var6] = se.field1159[var5][0][var6];
}
}
}
if (var4 != 0 || se.field1156[1] != se.field1156[0])
{
se2Loader.method1144(var2, var1);
}
}
else
{
int[] var7 = se.field1156;
se.field1156[1] = 0;
var7[0] = 0;
}
}
}

View File

@@ -24,39 +24,70 @@
*/
package net.runelite.cache.definitions.loaders.sound;
import net.runelite.cache.definitions.sound.AudioEnvelopeDefinition;
import net.runelite.cache.definitions.sound.SoundEffectDefinition;
import net.runelite.cache.definitions.sound.SoundEffect1Definition;
import net.runelite.cache.io.InputStream;
public class SoundEffectLoader
{
public SoundEffectDefinition load(byte[] b)
private final AudioEnvelopeLoader audioEnvelopeLoader = new AudioEnvelopeLoader();
public SoundEffectDefinition load(InputStream in, AudioEnvelopeDefinition audioEnvelope)
{
SoundEffectDefinition se = new SoundEffectDefinition();
InputStream in = new InputStream(b);
SoundEffectDefinition soundEffect = new SoundEffectDefinition();
load(se, in);
load(soundEffect, audioEnvelope, in);
return se;
return soundEffect;
}
private void load(SoundEffectDefinition se, InputStream var1)
private void load(SoundEffectDefinition soundEffect, AudioEnvelopeDefinition audioEnvelope, InputStream in)
{
for (int var2 = 0; var2 < 10; ++var2)
int id = in.readUnsignedByte();
soundEffect.pairs[0] = id >> 4;
soundEffect.pairs[1] = id & 15;
if (id != 0)
{
int var3 = var1.readUnsignedByte();
if (var3 != 0)
soundEffect.unity[0] = in.readUnsignedShort();
soundEffect.unity[1] = in.readUnsignedShort();
int track = in.readUnsignedByte();
for (int i = 0; i < 2; ++i)
{
var1.setOffset(var1.getOffset() - 1);
for (int j = 0; j < soundEffect.pairs[i]; ++j)
{
soundEffect.phases[i][0][j] = in.readUnsignedShort();
soundEffect.magnitudes[i][0][j] = in.readUnsignedShort();
}
}
SoundEffect1Loader se1Loader = new SoundEffect1Loader();
SoundEffect1Definition se1 = se1Loader.load(var1);
for (int i = 0; i < 2; ++i)
{
for (int j = 0; j < soundEffect.pairs[i]; ++j)
{
if ((track & 1 << i * 4 << j) != 0)
{
soundEffect.phases[i][1][j] = in.readUnsignedShort();
soundEffect.magnitudes[i][1][j] = in.readUnsignedShort();
}
else
{
soundEffect.phases[i][1][j] = soundEffect.phases[i][0][j];
soundEffect.magnitudes[i][1][j] = soundEffect.magnitudes[i][0][j];
}
}
}
se.field1008[var2] = se1;
if (track != 0 || soundEffect.unity[1] != soundEffect.unity[0])
{
audioEnvelopeLoader.loadSegments(audioEnvelope, in);
}
}
se.field1006 = var1.readUnsignedShort();
se.field1009 = var1.readUnsignedShort();
else
{
int[] clean = soundEffect.unity;
soundEffect.unity[1] = 0;
clean[0] = 0;
}
}
}
}

View File

@@ -24,39 +24,39 @@
*/
package net.runelite.cache.definitions.loaders.sound;
import net.runelite.cache.definitions.sound.SoundEffect2Definition;
import net.runelite.cache.definitions.sound.SoundEffectTrackDefinition;
import net.runelite.cache.definitions.sound.InstrumentDefinition;
import net.runelite.cache.io.InputStream;
public class SoundEffect2Loader
public class SoundEffectTrackLoader
{
public SoundEffect2Definition load(InputStream in)
public SoundEffectTrackDefinition load(byte[] b)
{
SoundEffect2Definition se = new SoundEffect2Definition();
SoundEffectTrackDefinition soundEffect = new SoundEffectTrackDefinition();
InputStream in = new InputStream(b);
load(se, in);
load(soundEffect, in);
return se;
return soundEffect;
}
private void load(SoundEffect2Definition se, InputStream var1)
private void load(SoundEffectTrackDefinition soundEffect, InputStream in)
{
se.field1087 = var1.readUnsignedByte();
se.field1088 = var1.readInt();
se.field1089 = var1.readInt();
this.method1144(se, var1);
}
final void method1144(SoundEffect2Definition se, InputStream var1)
{
se.field1092 = var1.readUnsignedByte();
se.field1086 = new int[se.field1092];
se.field1090 = new int[se.field1092];
for (int var2 = 0; var2 < se.field1092; ++var2)
for (int i = 0; i < 10; ++i)
{
se.field1086[var2] = var1.readUnsignedShort();
se.field1090[var2] = var1.readUnsignedShort();
int volume = in.readUnsignedByte();
if (volume != 0)
{
in.setOffset(in.getOffset() - 1);
InstrumentLoader instrumentLoader = new InstrumentLoader();
InstrumentDefinition instrument = instrumentLoader.load(in);
soundEffect.instruments[i] = instrument;
}
}
soundEffect.start = in.readUnsignedShort();
soundEffect.end = in.readUnsignedShort();
}
}
}

View File

@@ -24,32 +24,58 @@
*/
package net.runelite.cache.definitions.sound;
public class SoundEffect1Definition
public class AudioEnvelopeDefinition
{
public SoundEffect2Definition field1173;
public SoundEffect2Definition field1174;
public SoundEffect2Definition field1175;
public int field1176 = 500;
public int[] field1177 = new int[]
public int segments = 2;
public int[] durations = new int[2];
public int[] phases = new int[2];
public int start;
public int end;
public int form;
public int ticks;
public int phaseIndex;
public int step;
public int amplitude;
public int max;
public AudioEnvelopeDefinition()
{
0, 0, 0, 0, 0
};
public SoundEffect2Definition field1178;
public int[] field1179 = new int[]
this.durations[0] = 0;
this.durations[1] = '\uffff';
this.phases[0] = 0;
this.phases[1] = '\uffff';
}
public final int step(int var1)
{
0, 0, 0, 0, 0
};
public int[] field1180 = new int[]
if (this.max >= this.ticks)
{
this.amplitude = this.phases[this.phaseIndex++] << 15;
if (this.phaseIndex >= this.segments)
{
this.phaseIndex = this.segments - 1;
}
this.ticks = (int) ((double) this.durations[this.phaseIndex] / 65536.0 * (double) var1);
if (this.ticks > this.max)
{
this.step = ((this.phases[this.phaseIndex] << 15) - this.amplitude) / (this.ticks - this.max);
}
}
this.amplitude += this.step;
++this.max;
return this.amplitude - this.step >> 15;
}
public final void reset()
{
0, 0, 0, 0, 0
};
public SoundEffect2Definition field1181;
public SoundEffect3Definition field1182;
public SoundEffect2Definition field1183;
public int field1184 = 100;
public SoundEffect2Definition field1186;
public int field1187 = 0;
public int field1188 = 0;
public SoundEffect2Definition field1192;
public SoundEffect2Definition field1193;
}
this.ticks = 0;
this.phaseIndex = 0;
this.step = 0;
this.amplitude = 0;
this.max = 0;
}
}

View File

@@ -0,0 +1,356 @@
/*
* 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.definitions.sound;
import java.util.Random;
public class InstrumentDefinition
{
public AudioEnvelopeDefinition volume;
public AudioEnvelopeDefinition pitchModifier;
public AudioEnvelopeDefinition field1175;
public AudioEnvelopeDefinition release;
public AudioEnvelopeDefinition volumeMultiplier;
public AudioEnvelopeDefinition volumeMultiplierAmplitude;
public AudioEnvelopeDefinition pitchModifierAmplitude;
public AudioEnvelopeDefinition pitch;
public int[] oscillatorDelays = new int[]
{
0, 0, 0, 0, 0
};
public int[] oscillatorPitch = new int[]
{
0, 0, 0, 0, 0
};
public int[] oscillatorVolume = new int[]
{
0, 0, 0, 0, 0
};
public SoundEffectDefinition filter;
public AudioEnvelopeDefinition filterEnvelope;
static int[] samples = new int[220500];
static int[] NOISE = new int[32768];
static int[] AUDIO_SINE = new int[32768];
static int[] phases = new int[5];
static int[] delays = new int[5];
static int[] volumeSteps = new int[5];
static int[] pitchSteps = new int[5];
static int[] pitchBaseSteps = new int[5];
public int duration = 500;
public int delayDecay = 100;
public int delayTime = 0;
public int offset = 0;
static
{
Random random = new Random(0);
for (int i = 0; i < 32768; ++i)
{
InstrumentDefinition.NOISE[i] = (random.nextInt() & 2) - 1;
InstrumentDefinition.AUDIO_SINE[i] = (int) (Math.sin((double) i / 5215.1903) * 16384.0);
}
}
public final int[] synthesize(int var1, int var2)
{
int var16;
int var15;
int var14;
int var11;
int var12;
int var13;
InstrumentDefinition.method3854(samples, 0, var1);
if (var2 < 10)
{
return samples;
}
double var3 = (double) var1 / ((double) var2 + 0.0);
this.pitch.reset();
this.volume.reset();
int var5 = 0;
int var6 = 0;
int var7 = 0;
if (this.pitchModifier != null)
{
this.pitchModifier.reset();
this.pitchModifierAmplitude.reset();
var5 = (int) ((double) (this.pitchModifier.end - this.pitchModifier.start) * 32.768 / var3);
var6 = (int) ((double) this.pitchModifier.start * 32.768 / var3);
}
int var8 = 0;
int var9 = 0;
int var10 = 0;
if (this.volumeMultiplier != null)
{
this.volumeMultiplier.reset();
this.volumeMultiplierAmplitude.reset();
var8 = (int) ((double) (this.volumeMultiplier.end - this.volumeMultiplier.start) * 32.768 / var3);
var9 = (int) ((double) this.volumeMultiplier.start * 32.768 / var3);
}
for (var11 = 0; var11 < 5; ++var11)
{
if (this.oscillatorVolume[var11] == 0)
{
continue;
}
InstrumentDefinition.phases[var11] = 0;
InstrumentDefinition.delays[var11] = (int) ((double) this.oscillatorDelays[var11] * var3);
InstrumentDefinition.volumeSteps[var11] = (this.oscillatorVolume[var11] << 14) / 100;
InstrumentDefinition.pitchSteps[var11] = (int) ((double) (this.pitch.end - this.pitch.start) * 32.768 * Math.pow(1.0057929410678534, this.oscillatorPitch[var11]) / var3);
InstrumentDefinition.pitchBaseSteps[var11] = (int) ((double) this.pitch.start * 32.768 / var3);
}
for (var11 = 0; var11 < var1; ++var11)
{
var12 = this.pitch.step(var1);
var13 = this.volume.step(var1);
if (this.pitchModifier != null)
{
var14 = this.pitchModifier.step(var1);
var15 = this.pitchModifierAmplitude.step(var1);
var12 += this.evaluateWave(var7, var15, this.pitchModifier.form) >> 1;
var7 = var7 + var6 + (var14 * var5 >> 16);
}
if (this.volumeMultiplier != null)
{
var14 = this.volumeMultiplier.step(var1);
var15 = this.volumeMultiplierAmplitude.step(var1);
var13 = var13 * ((this.evaluateWave(var10, var15, this.volumeMultiplier.form) >> 1) + 32768) >> 15;
var10 = var10 + var9 + (var14 * var8 >> 16);
}
for (var14 = 0; var14 < 5; ++var14)
{
if (this.oscillatorVolume[var14] == 0 || (var15 = delays[var14] + var11) >= var1)
{
continue;
}
int[] arrn = samples;
int n = var15;
arrn[n] = arrn[n] + this.evaluateWave(phases[var14], var13 * volumeSteps[var14] >> 15, this.pitch.form);
int[] arrn2 = phases;
int n2 = var14;
arrn2[n2] = arrn2[n2] + ((var12 * pitchSteps[var14] >> 16) + pitchBaseSteps[var14]);
}
}
if (this.release != null)
{
this.release.reset();
this.field1175.reset();
var11 = 0;
boolean var20 = true;
for (var14 = 0; var14 < var1; ++var14)
{
var15 = this.release.step(var1);
var16 = this.field1175.step(var1);
var12 = var20 ? (var15 * (this.release.end - this.release.start) >> 8) + this.release.start : (var16 * (this.release.end - this.release.start) >> 8) + this.release.start;
if ((var11 += 256) >= var12)
{
var11 = 0;
}
if (!var20)
{
continue;
}
InstrumentDefinition.samples[var14] = 0;
}
}
if (this.delayTime > 0 && this.delayDecay > 0)
{
for (var12 = var11 = (int) ((double) this.delayTime * var3); var12 < var1; ++var12)
{
int[] arrn = samples;
int n = var12;
arrn[n] = arrn[n] + samples[var12 - var11] * this.delayDecay / 100;
}
}
if (this.filter.pairs[0] > 0 || this.filter.pairs[1] > 0)
{
this.filterEnvelope.reset();
var11 = this.filterEnvelope.step(var1 + 1);
var12 = this.filter.compute(0, (float) var11 / 65536.0f);
var13 = this.filter.compute(1, (float) var11 / 65536.0f);
if (var1 >= var12 + var13)
{
int var17;
var14 = 0;
var15 = var13;
if (var13 > var1 - var12)
{
var15 = var1 - var12;
}
while (var14 < var15)
{
var16 = (int) ((long) samples[var14 + var12] * (long) SoundEffectDefinition.fowardMultiplier >> 16);
for (var17 = 0; var17 < var12; ++var17)
{
var16 += (int) ((long) samples[var14 + var12 - 1 - var17] * (long) SoundEffectDefinition.coefficients[0][var17] >> 16);
}
for (var17 = 0; var17 < var14; ++var17)
{
var16 -= (int) ((long) samples[var14 - 1 - var17] * (long) SoundEffectDefinition.coefficients[1][var17] >> 16);
}
InstrumentDefinition.samples[var14] = var16;
var11 = this.filterEnvelope.step(var1 + 1);
++var14;
}
var15 = 128;
do
{
int var18;
if (var15 > var1 - var12)
{
var15 = var1 - var12;
}
while (var14 < var15)
{
var17 = (int) ((long) samples[var14 + var12] * (long) SoundEffectDefinition.fowardMultiplier >> 16);
for (var18 = 0; var18 < var12; ++var18)
{
var17 += (int) ((long) samples[var14 + var12 - 1 - var18] * (long) SoundEffectDefinition.coefficients[0][var18] >> 16);
}
for (var18 = 0; var18 < var13; ++var18)
{
var17 -= (int) ((long) samples[var14 - 1 - var18] * (long) SoundEffectDefinition.coefficients[1][var18] >> 16);
}
InstrumentDefinition.samples[var14] = var17;
var11 = this.filterEnvelope.step(var1 + 1);
++var14;
}
if (var14 >= var1 - var12)
{
while (var14 < var1)
{
var17 = 0;
for (var18 = var14 + var12 - var1; var18 < var12; ++var18)
{
var17 += (int) ((long) samples[var14 + var12 - 1 - var18]
* (long) SoundEffectDefinition.coefficients[0][var18] >> 16);
}
for (var18 = 0; var18 < var13; ++var18)
{
var17 -= (int) ((long) samples[var14 - 1 - var18]
* (long) SoundEffectDefinition.coefficients[1][var18] >> 16);
}
InstrumentDefinition.samples[var14] = var17;
this.filterEnvelope.step(var1 + 1);
++var14;
}
break;
}
var12 = this.filter.compute(0, (float) var11 / 65536.0f);
var13 = this.filter.compute(1, (float) var11 / 65536.0f);
var15 += 128;
}
while (true);
}
}
for (var11 = 0; var11 < var1; ++var11)
{
if (samples[var11] < -32768)
{
InstrumentDefinition.samples[var11] = -32768;
}
if (samples[var11] <= 32767)
{
continue;
}
InstrumentDefinition.samples[var11] = 32767;
}
return samples;
}
private static void method3854(int[] var1, int var2, int var3)
{
var3 = var3 + var2 - 7;
while (var2 < var3)
{
var1[var2++] = 0;
var1[var2++] = 0;
var1[var2++] = 0;
var1[var2++] = 0;
var1[var2++] = 0;
var1[var2++] = 0;
var1[var2++] = 0;
var1[var2++] = 0;
}
while (var2 < (var3 += 7))
{
var1[var2++] = 0;
}
}
public final int evaluateWave(int var1, int var2, int var3)
{
return var3 == 1 ? ((var1 & 32767) < 16384 ? var2 : -var2) : (var3 == 2 ? AUDIO_SINE[var1 & 32767] * var2 >> 14 : (var3 == 3 ? (var2 * (var1 & 32767) >> 14) - var2 : (var3 == 4 ? var2 * NOISE[var1 / 2607 & 32767] : 0)));
}
}

View File

@@ -26,7 +26,102 @@ package net.runelite.cache.definitions.sound;
public class SoundEffectDefinition
{
public int field1006;
public SoundEffect1Definition[] field1008 = new SoundEffect1Definition[10];
public int field1009;
}
public int[][][] phases = new int[2][2][4];
public int[] pairs = new int[2];
public int[] unity = new int[2];
public int[][][] magnitudes = new int[2][2][4];
public static float[][] minCoefficients = new float[2][8];
public static int[][] coefficients = new int[2][8];
public static float fowardMinCoefficientMultiplier;
public static int fowardMultiplier;
public int compute(int var1, float var2)
{
float var3;
int var4;
if (var1 == 0)
{
var3 = (float) this.unity[0] + (float) (this.unity[1] - this.unity[0]) * var2;
fowardMinCoefficientMultiplier = (float) Math.pow(0.1, (var3 *= 0.0030517578f) / 20.0f);
fowardMultiplier = (int) (fowardMinCoefficientMultiplier * 65536.0f);
}
if (this.pairs[var1] == 0)
{
return 0;
}
var3 = this.interpolateMagniture(var1, 0, var2);
minCoefficients[var1][0] = -2.0f * var3 * (float) Math.cos(this.interpolatePhase(var1, 0, var2));
minCoefficients[var1][1] = var3 * var3;
for (var4 = 1; var4 < this.pairs[var1]; ++var4)
{
var3 = this.interpolateMagniture(var1, var4, var2);
float var5 = -2.0f * var3 * (float) Math.cos(this.interpolatePhase(var1, var4, var2));
float var6 = var3 * var3;
minCoefficients[var1][var4 * 2 + 1] = minCoefficients[var1][var4 * 2 - 1] * var6;
minCoefficients[var1][var4 * 2] = minCoefficients[var1][var4 * 2 - 1] * var5 + minCoefficients[var1][var4 * 2 - 2] * var6;
for (int var7 = var4 * 2 - 1; var7 >= 2; --var7)
{
float[] arrf = minCoefficients[var1];
int n = var7;
arrf[n] = arrf[n] + (minCoefficients[var1][var7 - 1] * var5 + minCoefficients[var1][var7 - 2] * var6);
}
float[] arrf = minCoefficients[var1];
arrf[1] = arrf[1] + (minCoefficients[var1][0] * var5 + var6);
float[] arrf2 = minCoefficients[var1];
arrf2[0] = arrf2[0] + var5;
}
if (var1 == 0)
{
var4 = 0;
while (var4 < this.pairs[0] * 2)
{
float[] arrf = minCoefficients[0];
int n = var4++;
arrf[n] = arrf[n] * fowardMinCoefficientMultiplier;
}
}
for (var4 = 0; var4 < this.pairs[var1] * 2; ++var4)
{
coefficients[var1][var4] = (int) (minCoefficients[var1][var4] * 65536.0f);
}
return this.pairs[var1] * 2;
}
public float interpolateMagniture(int var1, int var2, float var3)
{
float var4 = (float) this.magnitudes[var1][0][var2] + var3 * (float) (this.magnitudes[var1][1][var2] - this.magnitudes[var1][0][var2]);
return 1.0f - (float) Math.pow(10.0, (-(var4 *= 0.0015258789f)) / 20.0f);
}
public float interpolatePhase(int var1, int var2, float var3)
{
float var4 = (float) this.phases[var1][0][var2] + var3 * (float) (this.phases[var1][1][var2] - this.phases[var1][0][var2]);
return normalise(var4 *= 1.2207031E-4f);
}
public static float normalise(float var1)
{
float var2 = 32.703197f * (float) Math.pow(2.0, var1);
return var2 * 3.1415927f / 11025.0f;
}
}

View File

@@ -24,25 +24,61 @@
*/
package net.runelite.cache.definitions.sound;
public class SoundEffect2Definition
public class SoundEffectTrackDefinition
{
public int field1085;
public int[] field1086 = new int[2];
public int field1087;
public int field1088;
public int field1089;
public int[] field1090 = new int[2];
public int field1091;
public int field1092 = 2;
public int field1093;
public int field1094;
public int field1095;
public int start;
public InstrumentDefinition[] instruments = new InstrumentDefinition[10];
public int end;
public SoundEffect2Definition()
public final byte[] mix()
{
this.field1086[0] = 0;
this.field1086[1] = '\uffff';
this.field1090[0] = 0;
this.field1090[1] = '\uffff';
int var2;
int var1 = 0;
for (var2 = 0; var2 < 10; ++var2)
{
if (this.instruments[var2] == null || this.instruments[var2].duration + this.instruments[var2].offset <= var1)
{
continue;
}
var1 = this.instruments[var2].duration + this.instruments[var2].offset;
}
if (var1 == 0)
{
return new byte[0];
}
var2 = var1 * 22050 / 1000;
byte[] var3 = new byte[var2];
for (int i = 0; i < 10; ++i)
{
if (this.instruments[i] == null)
{
continue;
}
int var5 = this.instruments[i].duration * 22050 / 1000;
int var6 = this.instruments[i].offset * 22050 / 1000;
int[] var7 = this.instruments[i].synthesize(var5, this.instruments[i].duration);
for (int j = 0; j < var5; ++j)
{
int var9 = (var7[j] >> 8) + var3[j + var6];
if ((var9 + 128 & -256) != 0)
{
var9 = var9 >> 31 ^ 127;
}
var3[j + var6] = (byte) var9;
}
}
return var3;
}
}
}

View File

@@ -116,7 +116,7 @@ public class FlatStorage implements Storage
{
int lidx = line.indexOf('=');
String key = line.substring(0, lidx);
String value = line.substring(lidx + 1, line.length());
String value = line.substring(lidx + 1);
if ("file".equals(key))
{
@@ -128,7 +128,7 @@ public class FlatStorage implements Storage
int vidx = value.indexOf('=');
FileData fd = new FileData();
fd.setId(Integer.parseInt(value.substring(0, vidx)));
fd.setNameHash(Integer.parseInt(value.substring(vidx + 1, value.length())));
fd.setNameHash(Integer.parseInt(value.substring(vidx + 1)));
fileData.add(fd);
continue;
}

View File

@@ -26,8 +26,10 @@ package net.runelite.cache.io;
import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
public final class OutputStream extends java.io.OutputStream
{
@@ -181,22 +183,23 @@ public final class OutputStream extends java.io.OutputStream
public void writeString(String str)
{
byte[] b;
try
{
b = str.getBytes("ISO-8859-1");
}
catch (UnsupportedEncodingException ex)
{
throw new RuntimeException(ex);
}
writeBytes(b);
Charset utf8charset = Charset.forName("UTF-8");
Charset cp1252charset = Charset.forName("Cp1252");
ByteBuffer inputBuffer = ByteBuffer.wrap(str.getBytes());
CharBuffer data = utf8charset.decode(inputBuffer);
ByteBuffer outputBuffer = cp1252charset.encode(data);
byte[] outputData = outputBuffer.array();
writeBytes(outputData);
writeByte(0);
}
public byte[] flip()
{
buffer.flip();
((Buffer) buffer).flip();
byte[] b = new byte[buffer.limit()];
buffer.get(b);
return b;
@@ -208,4 +211,4 @@ public final class OutputStream extends java.io.OutputStream
buffer.put((byte) b);
}
}
}

View File

@@ -38,19 +38,19 @@ import net.runelite.cache.models.VertexNormal;
public class ItemSpriteFactory
{
public static final BufferedImage createSprite(ItemProvider itemProvider, ModelProvider modelProvider,
SpriteProvider spriteProvider, TextureProvider textureProvider,
int itemId, int quantity, int border, int shadowColor,
boolean noted) throws IOException
SpriteProvider spriteProvider, TextureProvider textureProvider,
int itemId, int quantity, int border, int shadowColor,
boolean noted) throws IOException
{
SpritePixels spritePixels = createSpritePixels(itemProvider, modelProvider, spriteProvider, textureProvider,
itemId, quantity, border, shadowColor, noted);
Sprite spritePixels = createSpritePixels(itemProvider, modelProvider, spriteProvider, textureProvider,
itemId, quantity, border, shadowColor, noted);
return spritePixels == null ? null : spritePixels.toBufferedImage();
}
private static final SpritePixels createSpritePixels(ItemProvider itemProvider, ModelProvider modelProvider,
SpriteProvider spriteProvider, TextureProvider textureProvider,
int itemId, int quantity, int border, int shadowColor,
boolean noted) throws IOException
private static final Sprite createSpritePixels(ItemProvider itemProvider, ModelProvider modelProvider,
SpriteProvider spriteProvider, TextureProvider textureProvider,
int itemId, int quantity, int border, int shadowColor,
boolean noted) throws IOException
{
ItemDefinition item = itemProvider.provide(itemId);
@@ -83,11 +83,11 @@ public class ItemSpriteFactory
return null;
}
SpritePixels auxSpritePixels = null;
Sprite auxSpritePixels = null;
if (item.notedTemplate != -1)
{
auxSpritePixels = createSpritePixels(itemProvider, modelProvider, spriteProvider, textureProvider,
item.notedID, 10, 1, 0, true);
item.notedID, 10, 1, 0, true);
if (auxSpritePixels == null)
{
return null;
@@ -96,7 +96,7 @@ public class ItemSpriteFactory
else if (item.boughtTemplateId != -1)
{
auxSpritePixels = createSpritePixels(itemProvider, modelProvider, spriteProvider, textureProvider,
item.boughtId, quantity, border, shadowColor, false);
item.boughtId, quantity, border, shadowColor, false);
if (auxSpritePixels == null)
{
return null;
@@ -105,7 +105,7 @@ public class ItemSpriteFactory
else if (item.placeholderTemplateId != -1)
{
auxSpritePixels = createSpritePixels(itemProvider, modelProvider, spriteProvider, textureProvider,
item.placeholderId, quantity, 0, 0, false);
item.placeholderId, quantity, 0, 0, false);
if (auxSpritePixels == null)
{
return null;
@@ -114,7 +114,7 @@ public class ItemSpriteFactory
RSTextureProvider rsTextureProvider = new RSTextureProvider(textureProvider, spriteProvider);
SpritePixels spritePixels = new SpritePixels(36, 32);
Sprite spritePixels = new Sprite(36, 32);
Graphics3D graphics = new Graphics3D(rsTextureProvider);
graphics.setBrightness(0.6d);
graphics.setRasterBuffer(spritePixels.pixels, 36, 32);
@@ -142,12 +142,12 @@ public class ItemSpriteFactory
itemModel.calculateBoundsCylinder();
itemModel.rotateAndProject(graphics, 0,
item.yan2d,
item.zan2d,
item.xan2d,
item.xOffset2d,
itemModel.modelHeight / 2 + var17 + item.yOffset2d,
var18 + item.yOffset2d);
item.yan2d,
item.zan2d,
item.xan2d,
item.xOffset2d,
itemModel.modelHeight / 2 + var17 + item.yOffset2d,
var18 + item.yOffset2d);
if (item.boughtTemplateId != -1)
{
auxSpritePixels.drawAtOn(graphics, 0, 0);
@@ -175,8 +175,8 @@ public class ItemSpriteFactory
}
graphics.setRasterBuffer(graphics.graphicsPixels,
graphics.graphicsPixelsWidth,
graphics.graphicsPixelsHeight);
graphics.graphicsPixelsWidth,
graphics.graphicsPixelsHeight);
graphics.setRasterClipping();
graphics.rasterGouraudLowRes = true;

View File

@@ -26,7 +26,7 @@ package net.runelite.cache.item;
import java.awt.image.BufferedImage;
class SpritePixels
class Sprite
{
public int[] pixels;
public int width;
@@ -34,7 +34,7 @@ class SpritePixels
public int offsetX;
int offsetY;
public SpritePixels(int[] var1, int var2, int var3)
public Sprite(int[] var1, int var2, int var3)
{
this.pixels = var1;
this.width = var2;
@@ -43,7 +43,7 @@ class SpritePixels
this.offsetX = 0;
}
public SpritePixels(int var1, int var2)
public Sprite(int var1, int var2)
{
this(new int[var2 * var1], var1, var2);
}

View File

@@ -78,6 +78,7 @@ public class Instructions
add(CC_SETSIZE, "cc_setsize");
add(CC_SETHIDE, "cc_sethide");
add(CC_SETNOCLICKTHROUGH, "cc_setnoclickthrough");
add(CC_SETNOSCROLLTHROUGH, "cc_setnoscrollthrough");
add(CC_SETSCROLLPOS, "cc_setscrollpos");
add(CC_SETCOLOUR, "cc_setcolour");
add(CC_SETFILL, "cc_setfill");
@@ -102,6 +103,7 @@ public class Instructions
add(CC_RESUME_PAUSEBUTTON, "cc_resume_pausebutton");
add(CC_SETFILLCOLOUR, "cc_setfillcolour");
add(CC_SETLINEDIRECTION, "cc_setlinedirection");
add(CC_SETMODELTRANSPARENT, "cc_setmodeltransparent");
add(CC_SETOBJECT, "cc_setobject");
add(CC_SETNPCHEAD, "cc_setnpchead");
add(CC_SETPLAYERHEAD_SELF, "cc_setplayerhead_self");
@@ -115,6 +117,12 @@ public class Instructions
add(CC_SETOPBASE, "cc_setopbase");
add(CC_SETTARGETVERB, "cc_settargetverb");
add(CC_CLEAROPS, "cc_clearops");
add(CC_SETOPKEY, "cc_setopkey");
add(CC_SETOPTKEY, "cc_setoptkey");
add(CC_SETOPKEYRATE, "cc_setopkeyrate");
add(CC_SETOPTKEYRATE, "cc_setoptkeyrate");
add(CC_SETOPKEYIGNOREHELD, "cc_setopkeyignoreheld");
add(CC_SETOPTKEYIGNOREHELD, "cc_setoptkeyignoreheld");
add(CC_SETONCLICK, "cc_setonclick");
add(CC_SETONHOLD, "cc_setonhold");
add(CC_SETONRELEASE, "cc_setonrelease");
@@ -159,6 +167,7 @@ public class Instructions
add(CC_GETTRANS, "cc_gettrans");
add(CC_GETCOLOUR, "cc_getcolour");
add(CC_GETFILLCOLOUR, "cc_getfillcolour");
add(CC_GETMODELTRANSPARENT, "cc_getmodeltransparent");
add(CC_GETINVOBJECT, "cc_getinvobject");
add(CC_GETINVCOUNT, "cc_getinvcount");
add(CC_GETID, "cc_getid");
@@ -194,6 +203,7 @@ public class Instructions
add(IF_RESUME_PAUSEBUTTON, "if_resume_pausebutton");
add(IF_SETFILLCOLOUR, "if_setfillcolour");
add(IF_SETLINEDIRECTION, "if_setlinedirection");
add(IF_SETMODELTRANSPARENT, "if_setmodeltransparent");
add(IF_SETOBJECT, "if_setobject");
add(IF_SETNPCHEAD, "if_setnpchead");
add(IF_SETPLAYERHEAD_SELF, "if_setplayerhead_self");
@@ -257,6 +267,7 @@ public class Instructions
add(IF_GETTRANS, "if_gettrans");
add(IF_GETCOLOUR, "if_getcolour");
add(IF_GETFILLCOLOUR, "if_getfillcolour");
add(IF_GETMODELTRANSPARENT, "if_getmodeltransparent");
add(IF_GETINVOBJECT, "if_getinvobject");
add(IF_GETINVCOUNT, "if_getinvcount");
add(IF_HASSUB, "if_hassub");
@@ -287,11 +298,17 @@ public class Instructions
add(SETSHOWLOADINGMESSAGES, "setshowloadingmessages");
add(SETTAPTODROP, "settaptodrop");
add(GETTAPTODROP, "gettaptodrop");
add(SETOCULUSORBSPEED, "setoculusorbspeed");
add(GETCANVASSIZE, "getcanvassize");
add(MOBILE_SETFPS, "mobile_setfps");
add(MOBILE_OPENSTORE, "mobile_openstore");
add(MOBILE_OPENSTORECATEGORY, "mobile_openstorecategory");
add(SETHIDEUSERNAME, "sethideusername");
add(GETHIDEUSERNAME, "gethideusername");
add(SETREMEMBERUSERNAME, "setrememberusername");
add(GETREMEMBERUSERNAME, "getrememberusername");
add(SETTITLEMUSICENABLED, "settitlemusicenabled");
add(GETTITLEMUSICENABLED, "gettitlemusicenabled");
add(SOUND_SYNTH, "sound_synth");
add(SOUND_SONG, "sound_song");
add(SOUND_JINGLE, "sound_jingle");
@@ -411,6 +428,7 @@ public class Instructions
add(REMOVETAGS, "removetags");
add(STRING_INDEXOF_CHAR, "string_indexof_char");
add(STRING_INDEXOF_STRING, "string_indexof_string");
add(UPPERCASE, "uppercase");
add(OC_NAME, "oc_name");
add(OC_OP, "oc_op");
add(OC_IOP, "oc_iop");
@@ -461,6 +479,7 @@ public class Instructions
add(WORLDLIST_NEXT, "worldlist_next");
add(WORLDLIST_SPECIFIC, "worldlist_specific");
add(WORLDLIST_SORT, "worldlist_sort");
add(GETWORLDINFO, "getworldinfo");
add(SETFOLLOWEROPSLOWPRIORITY, "setfolloweropslowpriority");
add(NC_PARAM, "nc_param");
add(LC_PARAM, "lc_param");
@@ -468,6 +487,7 @@ public class Instructions
add(STRUCT_PARAM, "struct_param");
add(ON_MOBILE, "on_mobile");
add(CLIENTTYPE, "clienttype");
add(MOBILE_KEYBOARDHIDE, "mobile_keyboardhide");
add(BATTERYLEVEL, "batterylevel");
add(BATTERYCHARGING, "batterycharging");
add(WIFIAVAILABLE, "wifiavailable");
@@ -505,6 +525,8 @@ public class Instructions
add(MEC_TEXTSIZE, "mec_textsize");
add(MEC_CATEGORY, "mec_category");
add(MEC_SPRITE, "mec_sprite");
add(WORLDMAP_ELEMENT, "worldmap_element");
add(WORLDMAP_ELEMENTCOORD, "worldmap_elementcoord");
}
protected void add(int opcode, String name)

View File

@@ -69,6 +69,7 @@ public class Opcodes
public static final int CC_SETSIZE = 1001;
public static final int CC_SETHIDE = 1003;
public static final int CC_SETNOCLICKTHROUGH = 1005;
public static final int CC_SETNOSCROLLTHROUGH = 1006;
public static final int CC_SETSCROLLPOS = 1100;
public static final int CC_SETCOLOUR = 1101;
public static final int CC_SETFILL = 1102;
@@ -93,6 +94,7 @@ public class Opcodes
public static final int CC_RESUME_PAUSEBUTTON = 1121;
public static final int CC_SETFILLCOLOUR = 1123;
public static final int CC_SETLINEDIRECTION = 1126;
public static final int CC_SETMODELTRANSPARENT = 1127;
public static final int CC_SETOBJECT = 1200;
public static final int CC_SETNPCHEAD = 1201;
public static final int CC_SETPLAYERHEAD_SELF = 1202;
@@ -106,6 +108,12 @@ public class Opcodes
public static final int CC_SETOPBASE = 1305;
public static final int CC_SETTARGETVERB = 1306;
public static final int CC_CLEAROPS = 1307;
public static final int CC_SETOPKEY = 1350;
public static final int CC_SETOPTKEY = 1351;
public static final int CC_SETOPKEYRATE = 1352;
public static final int CC_SETOPTKEYRATE = 1353;
public static final int CC_SETOPKEYIGNOREHELD = 1354;
public static final int CC_SETOPTKEYIGNOREHELD = 1355;
public static final int CC_SETONCLICK = 1400;
public static final int CC_SETONHOLD = 1401;
public static final int CC_SETONRELEASE = 1402;
@@ -150,6 +158,7 @@ public class Opcodes
public static final int CC_GETTRANS = 1609;
public static final int CC_GETCOLOUR = 1611;
public static final int CC_GETFILLCOLOUR = 1612;
public static final int CC_GETMODELTRANSPARENT = 1614;
public static final int CC_GETINVOBJECT = 1700;
public static final int CC_GETINVCOUNT = 1701;
public static final int CC_GETID = 1702;
@@ -185,6 +194,7 @@ public class Opcodes
public static final int IF_RESUME_PAUSEBUTTON = 2121;
public static final int IF_SETFILLCOLOUR = 2123;
public static final int IF_SETLINEDIRECTION = 2126;
public static final int IF_SETMODELTRANSPARENT = 2127;
public static final int IF_SETOBJECT = 2200;
public static final int IF_SETNPCHEAD = 2201;
public static final int IF_SETPLAYERHEAD_SELF = 2202;
@@ -248,6 +258,7 @@ public class Opcodes
public static final int IF_GETTRANS = 2609;
public static final int IF_GETCOLOUR = 2611;
public static final int IF_GETFILLCOLOUR = 2612;
public static final int IF_GETMODELTRANSPARENT = 2614;
public static final int IF_GETINVOBJECT = 2700;
public static final int IF_GETINVCOUNT = 2701;
public static final int IF_HASSUB = 2702;
@@ -278,11 +289,17 @@ public class Opcodes
public static final int SETSHOWLOADINGMESSAGES = 3126;
public static final int SETTAPTODROP = 3127;
public static final int GETTAPTODROP = 3128;
public static final int SETOCULUSORBSPEED = 3129;
public static final int GETCANVASSIZE = 3132;
public static final int MOBILE_SETFPS = 3133;
public static final int MOBILE_OPENSTORE = 3134;
public static final int MOBILE_OPENSTORECATEGORY = 3135;
public static final int SETHIDEUSERNAME = 3141;
public static final int GETHIDEUSERNAME = 3142;
public static final int SETREMEMBERUSERNAME = 3143;
public static final int GETREMEMBERUSERNAME = 3144;
public static final int SETTITLEMUSICENABLED = 3146;
public static final int GETTITLEMUSICENABLED = 3147;
public static final int SOUND_SYNTH = 3200;
public static final int SOUND_SONG = 3201;
public static final int SOUND_JINGLE = 3202;
@@ -402,6 +419,7 @@ public class Opcodes
public static final int REMOVETAGS = 4119;
public static final int STRING_INDEXOF_CHAR = 4120;
public static final int STRING_INDEXOF_STRING = 4121;
public static final int UPPERCASE = 4122;
public static final int OC_NAME = 4200;
public static final int OC_OP = 4201;
public static final int OC_IOP = 4202;
@@ -452,6 +470,7 @@ public class Opcodes
public static final int WORLDLIST_NEXT = 6502;
public static final int WORLDLIST_SPECIFIC = 6506;
public static final int WORLDLIST_SORT = 6507;
public static final int GETWORLDINFO = 6511;
public static final int SETFOLLOWEROPSLOWPRIORITY = 6512;
public static final int NC_PARAM = 6513;
public static final int LC_PARAM = 6514;
@@ -459,6 +478,7 @@ public class Opcodes
public static final int STRUCT_PARAM = 6516;
public static final int ON_MOBILE = 6518;
public static final int CLIENTTYPE = 6519;
public static final int MOBILE_KEYBOARDHIDE = 6521;
public static final int BATTERYLEVEL = 6524;
public static final int BATTERYCHARGING = 6525;
public static final int WIFIAVAILABLE = 6526;
@@ -496,4 +516,6 @@ public class Opcodes
public static final int MEC_TEXTSIZE = 6694;
public static final int MEC_CATEGORY = 6695;
public static final int MEC_SPRITE = 6696;
public static final int WORLDMAP_ELEMENT = 6697;
public static final int WORLDMAP_ELEMENTCOORD = 6699;
}

View File

@@ -0,0 +1,554 @@
// Generated from net\runelite\cache\script\assembler\rs2asm.g4 by ANTLR 4.6
package net.runelite.cache.script.assembler;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ErrorNode;
import org.antlr.v4.runtime.tree.TerminalNode;
/**
* This class provides an empty implementation of {@link rs2asmListener},
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
public class rs2asmBaseListener implements rs2asmListener
{
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterProg(rs2asmParser.ProgContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitProg(rs2asmParser.ProgContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterHeader(rs2asmParser.HeaderContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitHeader(rs2asmParser.HeaderContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterId(rs2asmParser.IdContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitId(rs2asmParser.IdContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterInt_stack_count(rs2asmParser.Int_stack_countContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitInt_stack_count(rs2asmParser.Int_stack_countContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterString_stack_count(rs2asmParser.String_stack_countContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitString_stack_count(rs2asmParser.String_stack_countContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterInt_var_count(rs2asmParser.Int_var_countContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitInt_var_count(rs2asmParser.Int_var_countContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterString_var_count(rs2asmParser.String_var_countContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitString_var_count(rs2asmParser.String_var_countContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterId_value(rs2asmParser.Id_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitId_value(rs2asmParser.Id_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterInt_stack_value(rs2asmParser.Int_stack_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitInt_stack_value(rs2asmParser.Int_stack_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterString_stack_value(rs2asmParser.String_stack_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitString_stack_value(rs2asmParser.String_stack_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterInt_var_value(rs2asmParser.Int_var_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitInt_var_value(rs2asmParser.Int_var_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterString_var_value(rs2asmParser.String_var_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitString_var_value(rs2asmParser.String_var_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterLine(rs2asmParser.LineContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitLine(rs2asmParser.LineContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterInstruction(rs2asmParser.InstructionContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitInstruction(rs2asmParser.InstructionContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterLabel(rs2asmParser.LabelContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitLabel(rs2asmParser.LabelContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterInstruction_name(rs2asmParser.Instruction_nameContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitInstruction_name(rs2asmParser.Instruction_nameContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterName_string(rs2asmParser.Name_stringContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitName_string(rs2asmParser.Name_stringContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterName_opcode(rs2asmParser.Name_opcodeContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitName_opcode(rs2asmParser.Name_opcodeContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterInstruction_operand(rs2asmParser.Instruction_operandContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitInstruction_operand(rs2asmParser.Instruction_operandContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterOperand_int(rs2asmParser.Operand_intContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitOperand_int(rs2asmParser.Operand_intContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterOperand_qstring(rs2asmParser.Operand_qstringContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitOperand_qstring(rs2asmParser.Operand_qstringContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterOperand_label(rs2asmParser.Operand_labelContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitOperand_label(rs2asmParser.Operand_labelContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterSwitch_lookup(rs2asmParser.Switch_lookupContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitSwitch_lookup(rs2asmParser.Switch_lookupContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterSwitch_key(rs2asmParser.Switch_keyContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitSwitch_key(rs2asmParser.Switch_keyContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterSwitch_value(rs2asmParser.Switch_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitSwitch_value(rs2asmParser.Switch_valueContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void visitTerminal(TerminalNode node)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void visitErrorNode(ErrorNode node)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void enterEveryRule(ParserRuleContext ctx)
{
}
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void exitEveryRule(ParserRuleContext ctx)
{
}
}

View File

@@ -0,0 +1,171 @@
// Generated from net\runelite\cache\script\assembler\rs2asm.g4 by ANTLR 4.6
package net.runelite.cache.script.assembler;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.RuntimeMetaData;
import org.antlr.v4.runtime.Vocabulary;
import org.antlr.v4.runtime.VocabularyImpl;
import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNDeserializer;
import org.antlr.v4.runtime.atn.LexerATNSimulator;
import org.antlr.v4.runtime.atn.PredictionContextCache;
import org.antlr.v4.runtime.dfa.DFA;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class rs2asmLexer extends Lexer
{
public static final int
T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, NEWLINE = 7, INT = 8, QSTRING = 9,
IDENTIFIER = 10, COMMENT = 11, WS = 12;
public static final String[] ruleNames = {
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "NEWLINE", "INT", "QSTRING",
"IDENTIFIER", "COMMENT", "WS"
};
/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
public static final String _serializedATN =
"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2\16\u0099\b\1\4\2" +
"\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4" +
"\13\t\13\4\f\t\f\4\r\t\r\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3" +
"\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4" +
"\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\5\3\5\3" +
"\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6" +
"\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3" +
"\b\6\bn\n\b\r\b\16\bo\3\t\5\ts\n\t\3\t\6\tv\n\t\r\t\16\tw\3\n\3\n\3\n" +
"\3\n\7\n~\n\n\f\n\16\n\u0081\13\n\3\n\3\n\3\13\6\13\u0086\n\13\r\13\16" +
"\13\u0087\3\f\3\f\7\f\u008c\n\f\f\f\16\f\u008f\13\f\3\f\3\f\3\r\6\r\u0094" +
"\n\r\r\r\16\r\u0095\3\r\3\r\2\2\16\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n" +
"\23\13\25\f\27\r\31\16\3\2\b\4\2\f\f\17\17\3\2\62;\6\2\f\f\17\17$$^^\4" +
"\2$$^^\6\2\62;C\\aac|\4\2\13\13\"\"\u00a0\2\3\3\2\2\2\2\5\3\2\2\2\2\7" +
"\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2" +
"\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\3\33\3\2\2\2\5" +
" \3\2\2\2\7\62\3\2\2\2\tG\3\2\2\2\13W\3\2\2\2\rj\3\2\2\2\17m\3\2\2\2\21" +
"r\3\2\2\2\23y\3\2\2\2\25\u0085\3\2\2\2\27\u0089\3\2\2\2\31\u0093\3\2\2" +
"\2\33\34\7\60\2\2\34\35\7k\2\2\35\36\7f\2\2\36\37\7\"\2\2\37\4\3\2\2\2" +
" !\7\60\2\2!\"\7k\2\2\"#\7p\2\2#$\7v\2\2$%\7a\2\2%&\7u\2\2&\'\7v\2\2\'" +
"(\7c\2\2()\7e\2\2)*\7m\2\2*+\7a\2\2+,\7e\2\2,-\7q\2\2-.\7w\2\2./\7p\2" +
"\2/\60\7v\2\2\60\61\7\"\2\2\61\6\3\2\2\2\62\63\7\60\2\2\63\64\7u\2\2\64" +
"\65\7v\2\2\65\66\7t\2\2\66\67\7k\2\2\678\7p\2\289\7i\2\29:\7a\2\2:;\7" +
"u\2\2;<\7v\2\2<=\7c\2\2=>\7e\2\2>?\7m\2\2?@\7a\2\2@A\7e\2\2AB\7q\2\2B" +
"C\7w\2\2CD\7p\2\2DE\7v\2\2EF\7\"\2\2F\b\3\2\2\2GH\7\60\2\2HI\7k\2\2IJ" +
"\7p\2\2JK\7v\2\2KL\7a\2\2LM\7x\2\2MN\7c\2\2NO\7t\2\2OP\7a\2\2PQ\7e\2\2" +
"QR\7q\2\2RS\7w\2\2ST\7p\2\2TU\7v\2\2UV\7\"\2\2V\n\3\2\2\2WX\7\60\2\2X" +
"Y\7u\2\2YZ\7v\2\2Z[\7t\2\2[\\\7k\2\2\\]\7p\2\2]^\7i\2\2^_\7a\2\2_`\7x" +
"\2\2`a\7c\2\2ab\7t\2\2bc\7a\2\2cd\7e\2\2de\7q\2\2ef\7w\2\2fg\7p\2\2gh" +
"\7v\2\2hi\7\"\2\2i\f\3\2\2\2jk\7<\2\2k\16\3\2\2\2ln\t\2\2\2ml\3\2\2\2" +
"no\3\2\2\2om\3\2\2\2op\3\2\2\2p\20\3\2\2\2qs\7/\2\2rq\3\2\2\2rs\3\2\2" +
"\2su\3\2\2\2tv\t\3\2\2ut\3\2\2\2vw\3\2\2\2wu\3\2\2\2wx\3\2\2\2x\22\3\2" +
"\2\2y\177\7$\2\2z~\n\4\2\2{|\7^\2\2|~\t\5\2\2}z\3\2\2\2}{\3\2\2\2~\u0081" +
"\3\2\2\2\177}\3\2\2\2\177\u0080\3\2\2\2\u0080\u0082\3\2\2\2\u0081\177" +
"\3\2\2\2\u0082\u0083\7$\2\2\u0083\24\3\2\2\2\u0084\u0086\t\6\2\2\u0085" +
"\u0084\3\2\2\2\u0086\u0087\3\2\2\2\u0087\u0085\3\2\2\2\u0087\u0088\3\2" +
"\2\2\u0088\26\3\2\2\2\u0089\u008d\7=\2\2\u008a\u008c\n\2\2\2\u008b\u008a" +
"\3\2\2\2\u008c\u008f\3\2\2\2\u008d\u008b\3\2\2\2\u008d\u008e\3\2\2\2\u008e" +
"\u0090\3\2\2\2\u008f\u008d\3\2\2\2\u0090\u0091\b\f\2\2\u0091\30\3\2\2" +
"\2\u0092\u0094\t\7\2\2\u0093\u0092\3\2\2\2\u0094\u0095\3\2\2\2\u0095\u0093" +
"\3\2\2\2\u0095\u0096\3\2\2\2\u0096\u0097\3\2\2\2\u0097\u0098\b\r\2\2\u0098" +
"\32\3\2\2\2\13\2orw}\177\u0087\u008d\u0095\3\2\3\2";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
private static final String[] _LITERAL_NAMES = {
null, "'.id '", "'.int_stack_count '", "'.string_stack_count '", "'.int_var_count '",
"'.string_var_count '", "':'"
};
private static final String[] _SYMBOLIC_NAMES = {
null, null, null, null, null, null, null, "NEWLINE", "INT", "QSTRING",
"IDENTIFIER", "COMMENT", "WS"
};
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
public static String[] modeNames = {
"DEFAULT_MODE"
};
static
{
RuntimeMetaData.checkVersion("4.6", RuntimeMetaData.VERSION);
}
static
{
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++)
{
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null)
{
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}
if (tokenNames[i] == null)
{
tokenNames[i] = "<INVALID>";
}
}
}
static
{
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++)
{
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
}
}
public rs2asmLexer(CharStream input)
{
super(input);
_interp = new LexerATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
}
@Override
public String[] getRuleNames()
{
return ruleNames;
}
@Override
public Vocabulary getVocabulary()
{
return VOCABULARY;
}
@Override
public String getSerializedATN()
{
return _serializedATN;
}
@Override
public String getGrammarFileName()
{
return "rs2asm.g4";
}
@Override
public ATN getATN()
{
return _ATN;
}
@Override
public String[] getModeNames()
{
return modeNames;
}
@Override
@Deprecated
public String[] getTokenNames()
{
return tokenNames;
}
}

View File

@@ -0,0 +1,361 @@
// Generated from net\runelite\cache\script\assembler\rs2asm.g4 by ANTLR 4.6
package net.runelite.cache.script.assembler;
import org.antlr.v4.runtime.tree.ParseTreeListener;
/**
* This interface defines a complete listener for a parse tree produced by
* {@link rs2asmParser}.
*/
public interface rs2asmListener extends ParseTreeListener
{
/**
* Enter a parse tree produced by {@link rs2asmParser#prog}.
*
* @param ctx the parse tree
*/
void enterProg(rs2asmParser.ProgContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#prog}.
*
* @param ctx the parse tree
*/
void exitProg(rs2asmParser.ProgContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#header}.
*
* @param ctx the parse tree
*/
void enterHeader(rs2asmParser.HeaderContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#header}.
*
* @param ctx the parse tree
*/
void exitHeader(rs2asmParser.HeaderContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#id}.
*
* @param ctx the parse tree
*/
void enterId(rs2asmParser.IdContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#id}.
*
* @param ctx the parse tree
*/
void exitId(rs2asmParser.IdContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#int_stack_count}.
*
* @param ctx the parse tree
*/
void enterInt_stack_count(rs2asmParser.Int_stack_countContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#int_stack_count}.
*
* @param ctx the parse tree
*/
void exitInt_stack_count(rs2asmParser.Int_stack_countContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#string_stack_count}.
*
* @param ctx the parse tree
*/
void enterString_stack_count(rs2asmParser.String_stack_countContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#string_stack_count}.
*
* @param ctx the parse tree
*/
void exitString_stack_count(rs2asmParser.String_stack_countContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#int_var_count}.
*
* @param ctx the parse tree
*/
void enterInt_var_count(rs2asmParser.Int_var_countContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#int_var_count}.
*
* @param ctx the parse tree
*/
void exitInt_var_count(rs2asmParser.Int_var_countContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#string_var_count}.
*
* @param ctx the parse tree
*/
void enterString_var_count(rs2asmParser.String_var_countContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#string_var_count}.
*
* @param ctx the parse tree
*/
void exitString_var_count(rs2asmParser.String_var_countContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#id_value}.
*
* @param ctx the parse tree
*/
void enterId_value(rs2asmParser.Id_valueContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#id_value}.
*
* @param ctx the parse tree
*/
void exitId_value(rs2asmParser.Id_valueContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#int_stack_value}.
*
* @param ctx the parse tree
*/
void enterInt_stack_value(rs2asmParser.Int_stack_valueContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#int_stack_value}.
*
* @param ctx the parse tree
*/
void exitInt_stack_value(rs2asmParser.Int_stack_valueContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#string_stack_value}.
*
* @param ctx the parse tree
*/
void enterString_stack_value(rs2asmParser.String_stack_valueContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#string_stack_value}.
*
* @param ctx the parse tree
*/
void exitString_stack_value(rs2asmParser.String_stack_valueContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#int_var_value}.
*
* @param ctx the parse tree
*/
void enterInt_var_value(rs2asmParser.Int_var_valueContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#int_var_value}.
*
* @param ctx the parse tree
*/
void exitInt_var_value(rs2asmParser.Int_var_valueContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#string_var_value}.
*
* @param ctx the parse tree
*/
void enterString_var_value(rs2asmParser.String_var_valueContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#string_var_value}.
*
* @param ctx the parse tree
*/
void exitString_var_value(rs2asmParser.String_var_valueContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#line}.
*
* @param ctx the parse tree
*/
void enterLine(rs2asmParser.LineContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#line}.
*
* @param ctx the parse tree
*/
void exitLine(rs2asmParser.LineContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#instruction}.
*
* @param ctx the parse tree
*/
void enterInstruction(rs2asmParser.InstructionContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#instruction}.
*
* @param ctx the parse tree
*/
void exitInstruction(rs2asmParser.InstructionContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#label}.
*
* @param ctx the parse tree
*/
void enterLabel(rs2asmParser.LabelContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#label}.
*
* @param ctx the parse tree
*/
void exitLabel(rs2asmParser.LabelContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#instruction_name}.
*
* @param ctx the parse tree
*/
void enterInstruction_name(rs2asmParser.Instruction_nameContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#instruction_name}.
*
* @param ctx the parse tree
*/
void exitInstruction_name(rs2asmParser.Instruction_nameContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#name_string}.
*
* @param ctx the parse tree
*/
void enterName_string(rs2asmParser.Name_stringContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#name_string}.
*
* @param ctx the parse tree
*/
void exitName_string(rs2asmParser.Name_stringContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#name_opcode}.
*
* @param ctx the parse tree
*/
void enterName_opcode(rs2asmParser.Name_opcodeContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#name_opcode}.
*
* @param ctx the parse tree
*/
void exitName_opcode(rs2asmParser.Name_opcodeContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#instruction_operand}.
*
* @param ctx the parse tree
*/
void enterInstruction_operand(rs2asmParser.Instruction_operandContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#instruction_operand}.
*
* @param ctx the parse tree
*/
void exitInstruction_operand(rs2asmParser.Instruction_operandContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#operand_int}.
*
* @param ctx the parse tree
*/
void enterOperand_int(rs2asmParser.Operand_intContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#operand_int}.
*
* @param ctx the parse tree
*/
void exitOperand_int(rs2asmParser.Operand_intContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#operand_qstring}.
*
* @param ctx the parse tree
*/
void enterOperand_qstring(rs2asmParser.Operand_qstringContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#operand_qstring}.
*
* @param ctx the parse tree
*/
void exitOperand_qstring(rs2asmParser.Operand_qstringContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#operand_label}.
*
* @param ctx the parse tree
*/
void enterOperand_label(rs2asmParser.Operand_labelContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#operand_label}.
*
* @param ctx the parse tree
*/
void exitOperand_label(rs2asmParser.Operand_labelContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#switch_lookup}.
*
* @param ctx the parse tree
*/
void enterSwitch_lookup(rs2asmParser.Switch_lookupContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#switch_lookup}.
*
* @param ctx the parse tree
*/
void exitSwitch_lookup(rs2asmParser.Switch_lookupContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#switch_key}.
*
* @param ctx the parse tree
*/
void enterSwitch_key(rs2asmParser.Switch_keyContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#switch_key}.
*
* @param ctx the parse tree
*/
void exitSwitch_key(rs2asmParser.Switch_keyContext ctx);
/**
* Enter a parse tree produced by {@link rs2asmParser#switch_value}.
*
* @param ctx the parse tree
*/
void enterSwitch_value(rs2asmParser.Switch_valueContext ctx);
/**
* Exit a parse tree produced by {@link rs2asmParser#switch_value}.
*
* @param ctx the parse tree
*/
void exitSwitch_value(rs2asmParser.Switch_valueContext ctx);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
NEWLINE=7
INT=8
QSTRING=9
IDENTIFIER=10
COMMENT=11
WS=12
'.id '=1
'.int_stack_count '=2
'.string_stack_count '=3
'.int_var_count '=4
'.string_var_count '=5
':'=6

View File

@@ -0,0 +1,18 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
NEWLINE=7
INT=8
QSTRING=9
IDENTIFIER=10
COMMENT=11
WS=12
'.id '=1
'.int_stack_count '=2
'.string_stack_count '=3
'.int_var_count '=4
'.string_var_count '=5
':'=6

View File

@@ -82,19 +82,18 @@ public enum ScriptVarType
}
}
public static ScriptVarType forCharKey(char key)
{
return keyToTypeMap.get(key);
}
/**
* The character used when encoding or decoding types.
*/
private final char keyChar;
/**
* The full name of the var type.
*/
private final String fullName;
public static ScriptVarType forCharKey(char key)
{
return keyToTypeMap.get(key);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -64,7 +64,7 @@ public class AreaDumper
for (AreaDefinition area : areaManager.getAreas())
{
Files.write(gson.toJson(area), new File(outDir, area.id + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, area.id + ".json"), Charset.defaultCharset()).write(gson.toJson(area));
++count;
}
}

View File

@@ -30,7 +30,7 @@ import java.util.Properties;
public class CacheProperties
{
private static Properties getProperies() throws IOException
private static Properties getProperties() throws IOException
{
Properties properties = new Properties();
InputStream resourceAsStream = StoreLocation.class.getResourceAsStream("/cache.properties");
@@ -40,11 +40,11 @@ public class CacheProperties
public static int getRsVersion() throws IOException
{
return Integer.parseInt(getProperies().getProperty("rs.version"));
return Integer.parseInt(getProperties().getProperty("rs.version"));
}
public static int getCacheVersion() throws IOException
{
return Integer.parseInt(getProperies().getProperty("cache.version"));
return Integer.parseInt(getProperties().getProperty("cache.version"));
}
}

View File

@@ -80,7 +80,7 @@ public class EnumDumperTest
if (def != null)
{
Files.write(gson.toJson(def), new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(def));
++count;
}
}

View File

@@ -88,7 +88,7 @@ public class FrameDumper
int framemapArchiveId = (contents[0] & 0xff) << 8 | contents[1] & 0xff;
Archive framemapArchive = framemapIndex.getArchives().get(framemapArchiveId);
Archive framemapArchive = framemapIndex.getArchive(framemapArchiveId);
archiveData = storage.loadArchive(framemapArchive);
byte[] framemapContents = framemapArchive.decompress(archiveData);
@@ -101,7 +101,7 @@ public class FrameDumper
frames.add(frame);
}
Files.write(gson.toJson(frames), new File(outDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, archive.getArchiveId() + ".json"), Charset.defaultCharset()).write(gson.toJson(frames));
++count;
}
}

View File

@@ -74,7 +74,7 @@ public class FramemapDumper
FramemapLoader loader = new FramemapLoader();
FramemapDefinition framemap = loader.load(0, contents);
Files.write(gson.toJson(framemap), new File(outDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, archive.getArchiveId() + ".json"), Charset.defaultCharset()).write(gson.toJson(framemap));
++count;
}
}

View File

@@ -77,7 +77,7 @@ public class InventoryDumper
InventoryLoader loader = new InventoryLoader();
InventoryDefinition inv = loader.load(file.getFileId(), file.getContents());
Files.write(gson.toJson(inv), new File(outDir, inv.id + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, inv.id + ".json"), Charset.defaultCharset()).write(gson.toJson(inv));
++count;
}
}

View File

@@ -78,7 +78,7 @@ public class KitDumperTest
KitDefinition def = loader.load(file.getFileId(), b);
Files.write(gson.toJson(def), new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(dumpDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(def));
++count;
}
}

View File

@@ -165,7 +165,7 @@ public class MapDumperTest
@Test
@Ignore
public void dunpJson() throws IOException
public void dumpJson() throws IOException
{
File base = StoreLocation.LOCATION,
outDir = folder.newFolder();

View File

@@ -77,7 +77,7 @@ public class OverlayDumper
OverlayLoader loader = new OverlayLoader();
OverlayDefinition overlay = loader.load(file.getFileId(), file.getContents());
Files.write(gson.toJson(overlay), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(overlay));
++count;
}
}

View File

@@ -77,7 +77,7 @@ public class SequenceDumper
SequenceLoader loader = new SequenceLoader();
SequenceDefinition seq = loader.load(file.getFileId(), file.getContents());
Files.write(gson.toJson(seq), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(seq));
++count;
}
}

View File

@@ -27,11 +27,16 @@ package net.runelite.cache;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.IOException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.nio.charset.Charset;
import net.runelite.cache.definitions.loaders.sound.SoundEffectLoader;
import net.runelite.cache.definitions.sound.SoundEffectDefinition;
import net.runelite.cache.definitions.loaders.sound.SoundEffectTrackLoader;
import net.runelite.cache.definitions.sound.SoundEffectTrackDefinition;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
@@ -42,6 +47,11 @@ import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
public class SoundEffectsDumperTest
{
private static final Logger logger = LoggerFactory.getLogger(SoundEffectsDumperTest.class);
@@ -68,8 +78,8 @@ public class SoundEffectsDumperTest
{
byte[] contents = archive.decompress(storage.loadArchive(archive));
SoundEffectLoader soundEffectLoader = new SoundEffectLoader();
SoundEffectDefinition soundEffect = soundEffectLoader.load(contents);
SoundEffectTrackLoader setLoader = new SoundEffectTrackLoader();
SoundEffectTrackDefinition soundEffect = setLoader.load(contents);
Files.write(gson.toJson(soundEffect), new File(dumpDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
++count;
@@ -78,4 +88,58 @@ public class SoundEffectsDumperTest
logger.info("Dumped {} sound effects to {}", count, dumpDir);
}
}
@Test
public void extractWavTest() throws IOException
{
File dumpDir = folder.newFolder();
int count = 0;
try (Store store = new Store(StoreLocation.LOCATION))
{
store.load();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.SOUNDEFFECTS);
for (Archive archive : index.getArchives())
{
byte[] contents = archive.decompress(storage.loadArchive(archive));
SoundEffectTrackLoader setLoader = new SoundEffectTrackLoader();
SoundEffectTrackDefinition soundEffect = setLoader.load(contents);
try
{
Object audioStream;
byte[] data = soundEffect.mix();
AudioFormat audioFormat = new AudioFormat(22050.0f, 8, 1, true, false);
audioStream = new AudioInputStream(new ByteArrayInputStream(data), audioFormat, data.length);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
AudioSystem.write((AudioInputStream) audioStream, AudioFileFormat.Type.WAVE, bos);
data = bos.toByteArray();
FileOutputStream fos = new FileOutputStream(new File(dumpDir, archive.getArchiveId() + ".wav"));
try
{
fos.write(data);
}
finally
{
fos.close();
}
++count;
}
catch (Exception e)
{
continue;
}
}
}
logger.info("Dumped {} sound effects to {}", count, dumpDir);
}
}

View File

@@ -64,7 +64,7 @@ public class StructManagerTest
{
StructDefinition def = struct.getValue();
Files.write(gson.toJson(def), new File(dumpDir, struct.getKey() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(dumpDir, struct.getKey() + ".json"), Charset.defaultCharset()).write(gson.toJson(def));
++count;
}
}

View File

@@ -64,7 +64,7 @@ public class TextureDumper
for (TextureDefinition texture : tm.getTextures())
{
Files.write(gson.toJson(texture), new File(outDir, texture.getId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, texture.getId() + ".json"), Charset.defaultCharset()).write(gson.toJson(texture));
++count;
}
}

View File

@@ -77,7 +77,7 @@ public class UnderlayDumper
UnderlayLoader loader = new UnderlayLoader();
UnderlayDefinition underlay = loader.load(file.getFileId(), file.getContents());
Files.write(gson.toJson(underlay), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(underlay));
++count;
}
}

View File

@@ -77,7 +77,7 @@ public class VarbitDumper
VarbitLoader loader = new VarbitLoader();
VarbitDefinition varbit = loader.load(file.getFileId(), file.getContents());
Files.write(gson.toJson(varbit), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(varbit));
++count;
}
}

View File

@@ -77,7 +77,7 @@ public class WorldMapDumperTest
WorldMapLoader loader = new WorldMapLoader();
WorldMapDefinition def = loader.load(file.getContents(), file.getFileId());
Files.write(gson.toJson(def), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset()).write(gson.toJson(def));
++count;
}
}

View File

@@ -1,65 +1,65 @@
/*
* 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.definitions.savers;
import java.io.File;
import net.runelite.cache.IndexType;
import net.runelite.cache.StoreLocation;
import net.runelite.cache.definitions.InterfaceDefinition;
import net.runelite.cache.definitions.loaders.InterfaceLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
public class InterfaceSaverTest
{
@Test
public void testSave() throws Exception
{
File base = StoreLocation.LOCATION;
try (Store store = new Store(base))
{
store.load();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.INTERFACES);
Archive archive = index.getArchive(31);
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
FSFile file = files.findFile(76);
byte[] contents = file.getContents();
InterfaceDefinition def = new InterfaceLoader().load(0, contents);
byte[] b = new InterfaceSaver().save(def);
assertArrayEquals(contents, b);
}
}
}
/*
* 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.definitions.savers;
import java.io.File;
import net.runelite.cache.IndexType;
import net.runelite.cache.StoreLocation;
import net.runelite.cache.definitions.InterfaceDefinition;
import net.runelite.cache.definitions.loaders.InterfaceLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
public class InterfaceSaverTest
{
@Test
public void testSave() throws Exception
{
File base = StoreLocation.LOCATION;
try (Store store = new Store(base))
{
store.load();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.INTERFACES);
Archive archive = index.getArchive(31);
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
FSFile file = files.findFile(76);
byte[] contents = file.getContents();
InterfaceDefinition def = new InterfaceLoader().load(0, contents);
byte[] b = new InterfaceSaver().save(def);
assertArrayEquals(contents, b);
}
}
}

View File

@@ -1,66 +1,66 @@
/*
* 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.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;
/**
*
* @author Adam
*/
public class ScriptSaverTest
{
private static final String SCRIPT_RESOURCE = "/net/runelite/cache/script/assembler/91.rs2asm";
private static final String SCRIPT_RESOURCE_UNICODE = "/net/runelite/cache/script/assembler/Unicode.rs2asm";
@Test
public void testSave() throws IOException
{
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(91, saved);
assertEquals(script, loadedScripot);
}
@Test
public void testSaveUnicode() throws IOException
{
Instructions instructions = new Instructions();
instructions.init();
ScriptDefinition script = new Assembler(instructions).assemble(getClass().getResourceAsStream(SCRIPT_RESOURCE_UNICODE));
byte[] saved = new ScriptSaver().save(script);
ScriptDefinition loadedScripot = new ScriptLoader().load(1001, saved);
assertEquals(script, loadedScripot);
}
}
/*
* 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.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;
/**
*
* @author Adam
*/
public class ScriptSaverTest
{
private static final String SCRIPT_RESOURCE = "/net/runelite/cache/script/assembler/91.rs2asm";
private static final String SCRIPT_RESOURCE_UNICODE = "/net/runelite/cache/script/assembler/Unicode.rs2asm";
@Test
public void testSave() throws IOException
{
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(91, saved);
assertEquals(script, loadedScripot);
}
@Test
public void testSaveUnicode() throws IOException
{
Instructions instructions = new Instructions();
instructions.init();
ScriptDefinition script = new Assembler(instructions).assemble(getClass().getResourceAsStream(SCRIPT_RESOURCE_UNICODE));
byte[] saved = new ScriptSaver().save(script);
ScriptDefinition loadedScripot = new ScriptLoader().load(1001, saved);
assertEquals(script, loadedScripot);
}
}

View File

@@ -1,55 +1,55 @@
/*
* Copyright (c) 2016-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.fs;
import java.io.IOException;
import java.util.Random;
import static net.runelite.cache.fs.jagex.CompressionType.GZ;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
public class ContainerTest
{
@Test
public void testCompress() throws IOException
{
int[] keys = new int[]
{
4, 8, 15, 16
};
Random random = new Random(42L);
byte[] data = new byte[1024];
random.nextBytes(data);
Container container = new Container(GZ, -1);
container.compress(data, keys);
byte[] compressedData = container.data;
container = Container.decompress(compressedData, keys);
assertArrayEquals(data, container.data);
}
}
/*
* Copyright (c) 2016-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.fs;
import java.io.IOException;
import java.util.Random;
import static net.runelite.cache.fs.jagex.CompressionType.GZ;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
public class ContainerTest
{
@Test
public void testCompress() throws IOException
{
int[] keys = new int[]
{
4, 8, 15, 16
};
Random random = new Random(42L);
byte[] data = new byte[1024];
random.nextBytes(data);
Container container = new Container(GZ, -1);
container.compress(data, keys);
byte[] compressedData = container.data;
container = Container.decompress(compressedData, keys);
assertArrayEquals(data, container.data);
}
}

View File

@@ -1,102 +1,102 @@
/*
* Copyright (c) 2016-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.fs.jagex;
import java.io.File;
import net.runelite.cache.StoreLocation;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.Container;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Store;
import net.runelite.cache.index.FileData;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public class DiskStorageTest
{
@Rule
public TemporaryFolder folder = StoreLocation.getTemporaryFolder();
@Test
public void testSaveArchive() throws Exception
{
File file = folder.newFolder();
DiskStorage storage = new DiskStorage(file);
Archive archive;
Archive archive2;
try (Store store = new Store(storage))
{
Index index = store.addIndex(0);
archive = index.addArchive(0);
archive2 = index.addArchive(1);
FileData[] fileData = new FileData[1];
archive.setFileData(fileData);
fileData[0] = new FileData();
FileData[] fileData2 = new FileData[1];
archive2.setFileData(fileData2);
fileData2[0] = new FileData();
byte[] data = "test".getBytes();
Container container = new Container(archive.getCompression(), -1);
container.compress(data, null);
byte[] compressedData = container.data;
storage.saveArchive(archive, compressedData);
container = new Container(archive.getCompression(), 42);
container.compress(data, null);
compressedData = container.data;
archive2.setRevision(42);
storage.saveArchive(archive2, compressedData);
store.save();
}
storage = new DiskStorage(file);
try (Store store = new Store(storage))
{
store.load();
Index index = store.findIndex(0);
Archive archive2_1 = index.getArchive(0);
Archive archive2_2 = index.getArchive(1);
byte[] comprsesedData = storage.loadArchive(archive2_1);
byte[] data = archive2_1.decompress(comprsesedData);
assertArrayEquals("test".getBytes(), data);
assertEquals(archive.getCrc(), archive2_1.getCrc());
assertEquals(archive.getRevision(), archive2_1.getRevision());
comprsesedData = storage.loadArchive(archive2_2);
data = archive2_2.decompress(comprsesedData);
assertArrayEquals("test".getBytes(), data);
assertEquals(archive2.getCrc(), archive2_2.getCrc());
assertEquals(archive2.getRevision(), archive2_2.getRevision());
}
}
}
/*
* Copyright (c) 2016-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.fs.jagex;
import java.io.File;
import net.runelite.cache.StoreLocation;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.Container;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Store;
import net.runelite.cache.index.FileData;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public class DiskStorageTest
{
@Rule
public TemporaryFolder folder = StoreLocation.getTemporaryFolder();
@Test
public void testSaveArchive() throws Exception
{
File file = folder.newFolder();
DiskStorage storage = new DiskStorage(file);
Archive archive;
Archive archive2;
try (Store store = new Store(storage))
{
Index index = store.addIndex(0);
archive = index.addArchive(0);
archive2 = index.addArchive(1);
FileData[] fileData = new FileData[1];
archive.setFileData(fileData);
fileData[0] = new FileData();
FileData[] fileData2 = new FileData[1];
archive2.setFileData(fileData2);
fileData2[0] = new FileData();
byte[] data = "test".getBytes();
Container container = new Container(archive.getCompression(), -1);
container.compress(data, null);
byte[] compressedData = container.data;
storage.saveArchive(archive, compressedData);
container = new Container(archive.getCompression(), 42);
container.compress(data, null);
compressedData = container.data;
archive2.setRevision(42);
storage.saveArchive(archive2, compressedData);
store.save();
}
storage = new DiskStorage(file);
try (Store store = new Store(storage))
{
store.load();
Index index = store.findIndex(0);
Archive archive2_1 = index.getArchive(0);
Archive archive2_2 = index.getArchive(1);
byte[] comprsesedData = storage.loadArchive(archive2_1);
byte[] data = archive2_1.decompress(comprsesedData);
assertArrayEquals("test".getBytes(), data);
assertEquals(archive.getCrc(), archive2_1.getCrc());
assertEquals(archive.getRevision(), archive2_1.getRevision());
comprsesedData = storage.loadArchive(archive2_2);
data = archive2_2.decompress(comprsesedData);
assertArrayEquals("test".getBytes(), data);
assertEquals(archive2.getCrc(), archive2_2.getCrc());
assertEquals(archive2.getRevision(), archive2_2.getRevision());
}
}
}

View File

@@ -1,59 +1,59 @@
/*
* 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.io;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class OutputStreamTest
{
@Test
public void testWriteBigSmart()
{
OutputStream os = new OutputStream();
os.writeBigSmart(42);
os.writeBigSmart(70000);
os.writeBigSmart(65535);
InputStream is = new InputStream(os.getArray());
assertEquals(42, is.readBigSmart());
assertEquals(70000, is.readBigSmart());
assertEquals(65535, is.readBigSmart());
}
@Test
public void testWriteString()
{
char[] c = new char[]{32, 160};
String str = new String(c, 0, c.length);
OutputStream os = new OutputStream();
os.writeString(str);
// 1 byte length + 32 + 160
assertEquals(3, os.getOffset());
}
}
/*
* 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.io;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class OutputStreamTest
{
@Test
public void testWriteBigSmart()
{
OutputStream os = new OutputStream();
os.writeBigSmart(42);
os.writeBigSmart(70000);
os.writeBigSmart(65535);
InputStream is = new InputStream(os.getArray());
assertEquals(42, is.readBigSmart());
assertEquals(70000, is.readBigSmart());
assertEquals(65535, is.readBigSmart());
}
@Test
public void testWriteString()
{
char[] c = new char[]{32, 160};
String str = new String(c, 0, c.length);
OutputStream os = new OutputStream();
os.writeString(str);
// 1 byte length + 32 + 160
assertEquals(3, os.getOffset());
}
}

View File

@@ -1,118 +0,0 @@
/*
* 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.cache.item;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import lombok.extern.slf4j.Slf4j;
import net.runelite.cache.IndexType;
import net.runelite.cache.ItemManager;
import net.runelite.cache.SpriteManager;
import net.runelite.cache.StoreLocation;
import net.runelite.cache.TextureManager;
import net.runelite.cache.definitions.ItemDefinition;
import net.runelite.cache.definitions.ModelDefinition;
import net.runelite.cache.definitions.loaders.ModelLoader;
import net.runelite.cache.definitions.providers.ModelProvider;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Store;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@Slf4j
public class ItemSpriteFactoryTest
{
@Rule
public TemporaryFolder folder = StoreLocation.getTemporaryFolder();
@Test
@Ignore
public void test() throws IOException
{
File base = StoreLocation.LOCATION,
outDir = folder.newFolder();
int count = 0;
try (Store store = new Store(base))
{
store.load();
ItemManager itemManager = new ItemManager(store);
itemManager.load();
ModelProvider modelProvider = new ModelProvider()
{
@Override
public ModelDefinition provide(int modelId) throws IOException
{
Index models = store.getIndex(IndexType.MODELS);
Archive archive = models.getArchive(modelId);
byte[] data = archive.decompress(store.getStorage().loadArchive(archive));
ModelDefinition inventoryModel = new ModelLoader().load(modelId, data);
return inventoryModel;
}
};
SpriteManager spriteManager = new SpriteManager(store);
spriteManager.load();
TextureManager textureManager = new TextureManager(store);
textureManager.load();
for (ItemDefinition itemDef : itemManager.getItems())
{
if (itemDef.name == null || itemDef.name.equalsIgnoreCase("null"))
{
continue;
}
try
{
BufferedImage sprite = ItemSpriteFactory.createSprite(itemManager, modelProvider, spriteManager, textureManager,
itemDef.id, 1, 1, 3153952, false);
File out = new File(outDir, itemDef.id + ".png");
BufferedImage img = sprite;
ImageIO.write(img, "PNG", out);
++count;
}
catch (Exception ex)
{
log.warn("error dumping item {}", itemDef.id, ex);
}
}
}
log.info("Dumped {} item images to {}", count, outDir);
}
}

View File

@@ -1,40 +1,40 @@
/*
* 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.util;
import org.junit.Test;
import static org.junit.Assert.*;
public class Djb2Test
{
@Test
public void testHash()
{
int hash = Djb2.hash("l49_52");
assertEquals(-1153204821, hash);
}
}
/*
* 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.util;
import org.junit.Test;
import static org.junit.Assert.*;
public class Djb2Test
{
@Test
public void testHash()
{
int hash = Djb2.hash("l49_52");
assertEquals(-1153204821, hash);
}
}

View File

@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2017, Adam <Adam@sigterm.info>
Copyright (c) 2019, ThatGamerBlue <thatgamerblue@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -40,6 +41,11 @@
<property name="message" value="Indent must use tab characters"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="import (?!static|java\.awt).*\*"/>
<property name="message" value="Multiline imports are disallowed if they are not static"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="WhitespaceAround"/>
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA"/>

63
checkstyle/checkstyle.xml Normal file
View File

@@ -0,0 +1,63 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2017, Adam <Adam@sigterm.info>
Copyright (c) 2019, ThatGamerBlue <thatgamerblue@gmail.com>
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.
-->
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="SuppressionCommentFilter"/>
<module name="TreeWalker">
<module name="LeftCurly">
<property name="option" value="nl"/>
</module>
<module name="RightCurly">
<property name="option" value="alone"/>
</module>
<!-- require tabs for indenting - https://stackoverflow.com/a/28550141 -->
<module name="RegexpSinglelineJava">
<property name="format" value="^\t* "/>
<property name="message" value="Indent must use tab characters"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="import (?!static|java\.awt).*\*"/>
<property name="message" value="Multiline imports are disallowed if they are not static"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="WhitespaceAround"/>
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA"/>
</module>
<module name="UnusedImports"/>
</module>
<module name="RegexpMultiline">
<property name="format" value="else[ \t]*[\r\n]+[ \t]*if"/>
<property name="message" value="Newline should not be between else and if"/>
</module>
<module name="SuppressionFilter">
<property name="file" value="suppressions.xml"/>
</module>
</module>

1
codebase Normal file
View File

@@ -0,0 +1 @@
http://oldschool17.runescape.com/

22
deobfuscator/build.gradle Normal file
View File

@@ -0,0 +1,22 @@
description = 'Deobfuscator'
dependencies {
compile project(':runelite-api')
compile project(':runescape-api')
compile group: 'net.runelite', name: 'fernflower', version:'20171017'
compile group: 'com.google.guava', name: 'guava', version:'28.0-jre'
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.25'
compile group: 'com.google.code.gson', name: 'gson', version:'2.8.5'
compile group: 'org.ow2.asm', name: 'asm-debug-all', version:'5.2'
runtime group: 'org.slf4j', name: 'slf4j-simple', version:'1.7.26'
testCompile project(':rs-client')
testCompile group: 'net.runelite.rs', name: 'vanilla', version:'181'
testCompile group: 'junit', name: 'junit', version:'4.12'
testCompile group: 'org.mockito', name: 'mockito-all', version:'1.10.19'
}
task packageTests(type: Jar) {
from sourceSets.test.output
classifier = 'tests'
}
artifacts.archives packageTests

View File

@@ -0,0 +1,446 @@
/*
* Copyright (c) 2016-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.asm;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.pool.Class;
import net.runelite.asm.signature.Signature;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class ClassFile
{
private ClassGroup group;
private ClassFile parent; // super class
private final List<ClassFile> children = new ArrayList<>(); // classes which inherit from this
private int version;
private int access;
private Class name;
private Class super_class;
private String source;
private final Interfaces interfaces;
private final List<Field> fields = new ArrayList<>();
private final List<Method> methods = new ArrayList<>();
private final Annotations annotations;
public ClassFile(ClassGroup group)
{
this.group = group;
interfaces = new Interfaces(this);
annotations = new Annotations();
}
public ClassFile()
{
this(null);
}
@Override
public String toString()
{
return "ClassFile{" + "name=" + name + '}';
}
public int getVersion()
{
return version;
}
public void setVersion(int version)
{
this.version = version;
}
public int getAccess()
{
return access;
}
public void setAccess(int access)
{
this.access = access;
}
public void accept(ClassVisitor visitor)
{
String[] ints = interfaces.getInterfaces().stream().map(Class::getName).toArray(String[]::new);
visitor.visit(version, access, name.getName(), null, super_class.getName(), ints);
visitor.visitSource(source, null);
for (Annotation annotation : annotations.getAnnotations())
{
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
}
for (Field field : fields)
{
FieldVisitor fv = visitor.visitField(field.getAccessFlags(), field.getName(), field.getType().toString(), null, field.getValue());
field.accept(fv);
}
for (Method method : methods)
{
String[] exceptions = method.getExceptions().getExceptions().stream().map(Class::getName).toArray(String[]::new);
if (exceptions.length == 0)
{
exceptions = null;
}
MethodVisitor mv = visitor.visitMethod(method.getAccessFlags(), method.getName(), method.getDescriptor().toString(), null, exceptions);
method.accept(mv);
}
visitor.visitEnd();
}
public ClassGroup getGroup()
{
return group;
}
public void setGroup(ClassGroup group)
{
this.group = group;
}
public Interfaces getInterfaces()
{
return interfaces;
}
public List<Field> getFields()
{
return fields;
}
public void addField(Field field)
{
fields.add(field);
}
public void removeField(Field field)
{
fields.remove(field);
}
public List<Method> getMethods()
{
return methods;
}
public void addMethod(Method method)
{
methods.add(method);
}
public void removeMethod(Method method)
{
methods.remove(method);
}
public Annotations getAnnotations()
{
return annotations;
}
public String getName()
{
return name.getName();
}
public void setName(String name)
{
// Must be removed from the class group map first
assert group == null || this.name == null || group.findClass(this.name.getName()) == null;
this.name = new Class(name);
}
public String getClassName()
{
String n = getName();
int i = n.lastIndexOf('/');
return n.substring(i + 1);
}
public String getSuperName()
{
return super_class.getName();
}
public void setSuperName(String name)
{
super_class = new Class(name);
}
public String getSource()
{
return source;
}
public void setSource(String source)
{
this.source = source;
}
public Class getParentClass()
{
return this.super_class;
}
public void setParentClass(Class c)
{
super_class = c;
}
public ClassFile getParent()
{
return parent;
}
public List<ClassFile> getChildren()
{
return children;
}
public Field findField(String name, Type type)
{
for (Field f : fields)
{
if (f.getName().equals(name) && f.getType().equals(type))
{
return f;
}
}
return null;
}
public Field findField(String name)
{
for (Field f : fields)
{
if (f.getName().equals(name))
{
return f;
}
}
return null;
}
public Class getPoolClass()
{
return name;
}
public Field findFieldDeep(String name, Type type)
{
Field f = findField(name, type);
if (f != null)
{
return f;
}
ClassFile parent = getParent();
if (parent != null)
{
return parent.findFieldDeep(name, type);
}
return null;
}
public Method findMethod(String name, Signature type)
{
for (Method m : methods)
{
if (m.getName().equals(name) && m.getDescriptor().equals(type))
{
return m;
}
}
return null;
}
public Method findStaticMethod(String name, Signature type)
{
for (Method m : methods)
{
if (m.isStatic() &&
m.getName().equals(name) &&
m.getDescriptor().equals(type))
{
return m;
}
}
return null;
}
public Method findMethod(String name)
{
for (Method m : methods)
{
if (m.getName().equals(name))
{
return m;
}
}
return null;
}
public Method findStaticMethod(String name)
{
for (Method m : methods)
{
if (m.isStatic() && m.getName().equals(name))
{
return m;
}
}
return null;
}
public Method findMethodDeep(String name, Signature type)
{
Method m = findMethod(name, type);
if (m != null)
{
return m;
}
ClassFile parent = getParent();
if (parent != null)
{
return parent.findMethodDeep(name, type);
}
return null;
}
public Method findMethodDeepStatic(String name, Signature type)
{
Method m = findStaticMethod(name, type);
if (m != null)
{
return m;
}
ClassFile parent = getParent();
if (parent != null)
{
return parent.findMethodDeepStatic(name, type);
}
return null;
}
public Method findMethodDeep(String name)
{
Method m = findMethod(name);
if (m != null)
{
return m;
}
ClassFile parent = getParent();
if (parent != null)
{
return parent.findMethodDeep(name);
}
return null;
}
public void clearClassGraph()
{
parent = null;
children.clear();
}
public void buildClassGraph()
{
ClassFile other = group.findClass(super_class.getName());
if (other != null)
{
this.parent = other;
parent.children.add(this);
}
for (ClassFile i : interfaces.getMyInterfaces())
{
i.children.add(this);
}
}
public boolean instanceOf(ClassFile other)
{
return this == other || interfaces.instanceOf(other) || (getParent() != null && getParent().instanceOf(other));
}
public boolean isAbstract()
{
return (this.access & Opcodes.ACC_ABSTRACT) != 0;
}
public boolean isFinal()
{
return (this.access & Opcodes.ACC_FINAL) != 0;
}
public boolean isInterface()
{
return (this.access & Opcodes.ACC_INTERFACE) != 0;
}
public boolean isEnum()
{
return (this.access & Opcodes.ACC_ENUM) != 0;
}
public void setEnum()
{
this.access |= Opcodes.ACC_ENUM;
}
public void clearFinal()
{
this.access &= ~Opcodes.ACC_FINAL;
}
public void clearAbstract()
{
this.access &= ~Opcodes.ACC_ABSTRACT;
}
}

View File

@@ -0,0 +1,145 @@
/*
* Copyright (c) 2016-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.asm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.runelite.asm.attributes.Code;
import net.runelite.asm.signature.Signature;
public class ClassGroup
{
private final List<ClassFile> classes = new ArrayList<>(); // to keep order
private final Map<String, ClassFile> classMap = new HashMap<>();
public void addClass(ClassFile cf)
{
assert cf.getGroup() == this || cf.getGroup() == null;
cf.setGroup(this);
classes.add(cf);
classMap.put(cf.getName(), cf);
}
public void removeClass(ClassFile cf)
{
classes.remove(cf);
classMap.remove(cf.getName());
}
public void renameClass(ClassFile cf, String newName)
{
assert classes.contains(cf);
assert classMap.get(cf.getName()) == cf;
classMap.remove(cf.getName());
cf.setName(newName);
classMap.put(cf.getName(), cf);
}
public List<ClassFile> getClasses()
{
return Collections.unmodifiableList(classes);
}
public ClassFile findClass(String name)
{
return classMap.get(name);
}
public void initialize()
{
buildClassGraph();
lookup();
}
public void buildClassGraph()
{
for (ClassFile c : classes)
{
c.clearClassGraph();
}
for (ClassFile c : classes)
{
c.buildClassGraph();
}
}
public void lookup()
{
for (ClassFile cf : this.getClasses())
{
for (Method m : cf.getMethods())
{
Code code = m.getCode();
if (code == null)
{
continue;
}
code.getInstructions().lookup();
}
}
}
public Method findStaticMethod(String name, Signature type)
{
Method m = null;
for (ClassFile cf : classes)
{
m = cf.findStaticMethod(name, type);
if (m != null)
{
break;
}
}
return m;
}
public Method findStaticMethod(String name)
{
Method m = null;
for (ClassFile cf : classes)
{
m = cf.findStaticMethod(name);
if (m != null)
{
break;
}
}
return m;
}
}

View File

@@ -0,0 +1,163 @@
/*
* Copyright (c) 2016-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.asm;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.annotation.Annotation;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.objectweb.asm.Opcodes.ACC_PROTECTED;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
public class Field
{
public static final int ACCESS_MODIFIERS = ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED;
private final ClassFile classFile;
private int accessFlags;
private String name;
private Type type;
private Object value; // ConstantValue
private final Annotations annotations;
public Field(ClassFile classFile, String name, Type type)
{
this.classFile = classFile;
this.name = name;
this.type = type;
annotations = new Annotations();
}
public void accept(FieldVisitor visitor)
{
for (Annotation annotation : annotations.getAnnotations())
{
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
}
visitor.visitEnd();
}
public ClassFile getClassFile()
{
return classFile;
}
public int getAccessFlags()
{
return accessFlags;
}
public void setAccessFlags(int accessFlags)
{
this.accessFlags = accessFlags;
}
public boolean isPublic()
{
return (accessFlags & Opcodes.ACC_PUBLIC) != 0;
}
public void setPublic()
{
accessFlags = (short) ((accessFlags & ~ACCESS_MODIFIERS) | ACC_PUBLIC);
}
public boolean isStatic()
{
return (accessFlags & Opcodes.ACC_STATIC) != 0;
}
public void setStatic()
{
accessFlags |= Opcodes.ACC_STATIC;
}
public boolean isSynthetic()
{
return (accessFlags & Opcodes.ACC_SYNTHETIC) != 0;
}
public void setEnum()
{
accessFlags |= Opcodes.ACC_ENUM;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Type getType()
{
return type;
}
public void setType(Type type)
{
this.type = type;
}
public Object getValue()
{
return value;
}
public void setValue(Object value)
{
this.value = value;
}
public Annotations getAnnotations()
{
return annotations;
}
public net.runelite.asm.pool.Field getPoolField()
{
return new net.runelite.asm.pool.Field(
new net.runelite.asm.pool.Class(classFile.getName()),
this.getName(),
this.getType()
);
}
@Override
public String toString()
{
return (this.isStatic() ? "static " : "") + this.type + " " + classFile.getName() + "." + this.getName();
}
}

View File

@@ -0,0 +1,110 @@
/*
* Copyright (c) 2016-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.asm;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import net.runelite.asm.pool.Class;
import net.runelite.deob.DeobAnnotations;
public class Interfaces
{
private final ClassFile classFile;
private final List<Class> interfaces = new ArrayList<>();
Interfaces(ClassFile c)
{
classFile = c;
}
public void addInterface(Class clazz)
{
if (!interfaces.contains(clazz))
{
interfaces.add(clazz);
}
}
public List<Class> getInterfaces()
{
return interfaces;
}
public void clear()
{
interfaces.clear();
}
public List<ClassFile> getMyInterfaces()
{
List<ClassFile> l = new ArrayList<>();
for (Class clazz : interfaces)
{
ClassFile iface = classFile.getGroup().findClass(clazz.getName());
if (iface != null)
{
l.add(iface);
}
}
return l;
}
public List<Class> getNonMyInterfaces()
{
return interfaces.stream().filter(clazz -> classFile.getGroup().findClass(clazz.getName()) == null).collect(Collectors.toList());
}
public boolean instanceOf(ClassFile cf)
{
for (Class clazz : interfaces)
{
ClassFile iface = classFile.getGroup().findClass(clazz.getName());
if (iface.instanceOf(cf))
{
return true;
}
}
return false;
}
public List<String> getIntfNames()
{
final List<String> names = new ArrayList<>();
for (ClassFile c : getMyInterfaces())
{
String name = DeobAnnotations.getObfuscatedName(c.getAnnotations());
if (name == null)
{
continue;
}
names.add(name);
}
return names;
}
}

View File

@@ -0,0 +1,321 @@
/*
* Copyright (c) 2016-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.asm;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.Code;
import net.runelite.asm.attributes.Exceptions;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.LocalVariable;
import net.runelite.asm.attributes.code.Parameter;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.signature.Signature;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import static org.objectweb.asm.Opcodes.ACC_FINAL;
import static org.objectweb.asm.Opcodes.ACC_NATIVE;
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.objectweb.asm.Opcodes.ACC_PROTECTED;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACC_STATIC;
import static org.objectweb.asm.Opcodes.ACC_SYNCHRONIZED;
public class Method
{
public static final int ACCESS_MODIFIERS = ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED;
private final ClassFile classFile;
private int accessFlags;
private String name;
private Signature arguments;
private Exceptions exceptions;
private Annotations annotations;
private List<Parameter> parameters;
private Code code;
public Method(ClassFile classFile, String name, Signature signature)
{
this.classFile = classFile;
this.name = name;
this.arguments = signature;
exceptions = new Exceptions();
annotations = new Annotations();
parameters = new ArrayList<>();
}
public ClassFile getClassFile()
{
return classFile;
}
@Override
public String toString()
{
return (this.isStatic() ? "static " : "") + classFile.getName() + "." + this.name + this.arguments;
}
public void accept(MethodVisitor visitor)
{
//This is required to name unused parameters
for (Parameter p : parameters)
{
visitor.visitParameter(p.getName(), p.getAccess());
}
for (Annotation annotation : annotations.getAnnotations())
{
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
}
if (code != null)
{
code.getInstructions().rebuildLabels();
visitor.visitCode();
net.runelite.asm.attributes.code.Exceptions exceptions = code.getExceptions();
for (net.runelite.asm.attributes.code.Exception exception : exceptions.getExceptions())
{
assert exception.getStart().getLabel() != null;
assert exception.getEnd().getLabel() != null;
assert exception.getHandler().getLabel() != null;
int idxStart = code.getInstructions().getInstructions().indexOf(exception.getStart());
int idxEnd = code.getInstructions().getInstructions().indexOf(exception.getEnd());
assert idxStart != -1;
assert idxEnd != -1;
assert code.getInstructions().getInstructions().contains(exception.getHandler());
assert idxEnd > idxStart;
visitor.visitTryCatchBlock(
exception.getStart().getLabel(),
exception.getEnd().getLabel(),
exception.getHandler().getLabel(),
exception.getCatchType() != null ? exception.getCatchType().getName() : null
);
}
for (Instruction i : code.getInstructions().getInstructions())
{
i.accept(visitor);
}
//Find first and last label for this method
if (parameters.size() > 0)
{
Label startLabel = null;
Label endLabel = null;
for (Instruction i : code.getInstructions().getInstructions())
{
if (i instanceof net.runelite.asm.attributes.code.Label)
{
if (startLabel == null)
{
startLabel = ((net.runelite.asm.attributes.code.Label) i).getLabel();
}
endLabel = ((net.runelite.asm.attributes.code.Label) i).getLabel();
}
}
for (Parameter p : parameters)
{
LocalVariable lv = p.getLocalVariable();
if (lv != null)
{
visitor.visitLocalVariable(lv.getName(), lv.getDesc(), lv.getSignature(), startLabel, endLabel, lv.getIndex());
}
}
}
visitor.visitMaxs(code.getMaxStack(), code.getMaxLocals());
}
visitor.visitEnd();
}
public int getAccessFlags()
{
return accessFlags;
}
public void setAccessFlags(int accessFlags)
{
this.accessFlags = accessFlags;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Signature getDescriptor()
{
return arguments;
}
public void setDescriptor(Signature signature)
{
this.arguments = signature;
}
public boolean isNative()
{
return (accessFlags & ACC_NATIVE) != 0;
}
public boolean isStatic()
{
return (accessFlags & ACC_STATIC) != 0;
}
public void setStatic(boolean s)
{
if (s)
{
accessFlags |= ACC_STATIC;
}
else
{
accessFlags &= ~ACC_STATIC;
}
}
public boolean isSynchronized()
{
return (accessFlags & ACC_SYNCHRONIZED) != 0;
}
public boolean isFinal()
{
return (accessFlags & ACC_FINAL) != 0;
}
public void setFinal(boolean f)
{
if (f)
{
accessFlags |= ACC_FINAL;
}
else
{
accessFlags &= ~ACC_FINAL;
}
}
public boolean isPrivate()
{
return (accessFlags & ACC_PRIVATE) != 0;
}
public void setPrivate()
{
accessFlags = (short) ((accessFlags & ~ACCESS_MODIFIERS) | ACC_PRIVATE);
}
public void setPublic()
{
accessFlags = (short) ((accessFlags & ~ACCESS_MODIFIERS) | ACC_PUBLIC);
}
public Exceptions getExceptions()
{
return exceptions;
}
public Code getCode()
{
return code;
}
public void setCode(Code code)
{
this.code = code;
}
public Annotations getAnnotations()
{
return annotations;
}
@SuppressWarnings("unchecked")
public <T extends Instruction & LVTInstruction> List<T> findLVTInstructionsForVariable(int index)
{
List<T> list = new ArrayList<>();
if (getCode() == null)
{
return null;
}
for (Instruction ins : getCode().getInstructions().getInstructions())
{
if (ins instanceof LVTInstruction)
{
LVTInstruction lv = (LVTInstruction) ins;
if (lv.getVariableIndex() != index)
{
continue;
}
list.add((T) ins);
}
}
return list;
}
public net.runelite.asm.pool.Method getPoolMethod()
{
return new net.runelite.asm.pool.Method(
new net.runelite.asm.pool.Class(classFile.getName()),
name,
arguments
);
}
public List<Parameter> getParameters()
{
return parameters;
}
public void setParameters(List<Parameter> parameters)
{
this.parameters = parameters;
}
}

View File

@@ -0,0 +1,228 @@
/*
* Copyright (c) 2016-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.asm;
import net.runelite.asm.pool.Class;
/**
* Created by Kyle Fricilone on 8/20/2017
*/
public class Type
{
public static final Type VOID = new Type("V");
public static final Type BOOLEAN = new Type("Z");
public static final Type CHAR = new Type("C");
public static final Type BYTE = new Type("B");
public static final Type SHORT = new Type("S");
public static final Type INT = new Type("I");
public static final Type FLOAT = new Type("F");
public static final Type LONG = new Type("J");
public static final Type DOUBLE = new Type("D");
public static final Type OBJECT = new Type("Ljava/lang/Object;");
public static final Type STRING = new Type("Ljava/lang/String;");
public static final Type THROWABLE = new Type("Ljava/lang/Throwable;");
public static final Type EXCEPTION = new Type("Ljava/lang/Exception;");
private final String type;
public Type(String type)
{
this.type = type;
}
public boolean isPrimitive()
{
return this.equals(BOOLEAN) || this.equals(BYTE) || this.equals(SHORT) || this.equals(CHAR) || this.equals(INT)
|| this.equals(VOID) || this.equals(LONG) || this.equals(FLOAT) || this.equals(DOUBLE);
}
public boolean isObject()
{
return this.equals(OBJECT);
}
public boolean isArray()
{
return getDimensions() > 0;
}
public boolean isStackInt()
{
return this.equals(BOOLEAN) || this.equals(BYTE) || this.equals(SHORT) || this.equals(CHAR) || this.equals(INT);
}
public int getSize()
{
if (this.equals(LONG) || this.equals(DOUBLE))
{
return 2;
}
if (this.equals(VOID))
{
return 0;
}
return 1;
}
public int getDimensions()
{
return getDimensions(type);
}
public Type getSubtype()
{
if (!type.startsWith("["))
{
throw new IllegalStateException(type + " is not an array");
}
return new Type(type.substring(1));
}
public String getInternalName()
{
String s = type;
while (s.startsWith("["))
{
s = s.substring(1);
}
if (s.startsWith("L") && s.endsWith(";"))
{
return s.substring(1, s.length() - 1);
}
else
{
return s;
}
}
@Override
public boolean equals(Object o)
{
if (!(o instanceof Type))
{
return false;
}
Type other = (Type) o;
return type.equals(other.type);
}
@Override
public int hashCode()
{
return type.hashCode();
}
@Override
public String toString()
{
return type;
}
public String toAsmString()
{
if (type.startsWith("L") && type.endsWith(";"))
{
return type.substring(1, type.length() - 1);
}
else
{
return type;
}
}
public static Type fromAsmString(String str)
{
if (str.startsWith("["))
{
// array type
return new Type(str);
}
else
{
// object type
return new Type("L" + str + ";");
}
}
private static int getDimensions(String type)
{
if (!type.startsWith("["))
{
return 0;
}
return (int) type.chars().filter(i -> i == '[').count();
}
public static Type getType(String type, int dims)
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < dims; i++)
{
builder.append('[');
}
return new Type(builder.append(type).toString());
}
public static Type getType(Object object)
{
Type type;
if (object instanceof Double)
{
type = DOUBLE;
}
else if (object instanceof Float)
{
type = FLOAT;
}
else if (object instanceof Integer)
{
type = INT;
}
else if (object instanceof Long)
{
type = LONG;
}
else if (object instanceof String)
{
type = STRING;
}
else if (object instanceof Class)
{
type = new Type("L" + ((Class) object).getName() + ";");
}
else
{
throw new IllegalArgumentException("Unexpected object type: " + object.getClass());
}
return type;
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 2016-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.asm.attributes;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.annotation.Element;
public class Annotations
{
private final List<Annotation> annotations = new ArrayList<>();
public List<Annotation> getAnnotations()
{
return annotations;
}
public void addAnnotation(Annotation annotation)
{
annotations.add(annotation);
}
public void removeAnnotation(Annotation annotation)
{
annotations.remove(annotation);
}
public void clearAnnotations()
{
annotations.clear();
}
public Annotation find(Type type)
{
for (Annotation a : annotations)
if (a.getType().equals(type))
return a;
return null;
}
public int size()
{
return annotations.size();
}
public Annotation addAnnotation(Type type, String name, Object value)
{
Annotation annotation = new Annotation(this);
annotation.setType(type);
addAnnotation(annotation);
Element element = new Element(annotation);
element.setName(name);
element.setValue(value);
annotation.addElement(element);
return annotation;
}
}

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 2016-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.asm.attributes;
import net.runelite.asm.Method;
import net.runelite.asm.attributes.code.Exceptions;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.signature.Signature;
public class Code
{
private Method method;
private int maxStack;
private Instructions instructions;
private final Exceptions exceptions;
public Code(Method method)
{
this.method = method;
exceptions = new Exceptions(this);
instructions = new Instructions(this);
}
public Method getMethod()
{
return method;
}
public int getMaxStack()
{
return maxStack;
}
public void setMaxStack(int maxStack)
{
this.maxStack = maxStack;
}
private int getMaxLocalsFromSig()
{
Method m = getMethod();
int num = m.isStatic() ? 0 : 1;
Signature sig = m.getDescriptor();
for (int i = 0; i < sig.size(); ++i)
num += sig.getTypeOfArg(i).getSize();
return num;
}
/**
* calculates the size of the lvt required for this method
* @return
*/
public int getMaxLocals()
{
int max = -1;
for (Instruction ins : instructions.getInstructions())
{
if (ins instanceof LVTInstruction)
{
LVTInstruction lvt = (LVTInstruction) ins;
int sizeRequired = lvt.getVariableIndex() + lvt.type().getSlots();
if (sizeRequired > max)
{
max = sizeRequired;
}
}
}
int fromSig = getMaxLocalsFromSig();
if (fromSig > max)
max = fromSig;
return max;
}
public Exceptions getExceptions()
{
return exceptions;
}
public Instructions getInstructions()
{
return instructions;
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2016-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.asm.attributes;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.ClassFile;
import net.runelite.asm.pool.Class;
public class Exceptions
{
private final List<Class> classes = new ArrayList<>();
public void addException(Class cl)
{
classes.add(cl);
}
public List<Class> getExceptions()
{
return classes;
}
public void renameClass(ClassFile cf, String name)
{
for (Class c : new ArrayList<>(classes))
{
if (c.getName().equals(cf.getName()))
{
int idx = classes.indexOf(c);
classes.remove(idx);
classes.add(idx, new Class(name));
}
}
}
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2016-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.asm.attributes.annotation;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotations;
import org.objectweb.asm.AnnotationVisitor;
public class Annotation
{
private final Annotations annotations;
private Type type;
private final List<Element> elements = new ArrayList<>();
public Annotation(Annotations annotations)
{
this.annotations = annotations;
}
public Annotations getAnnotations()
{
return annotations;
}
public void setType(Type type)
{
this.type = type;
}
public Type getType()
{
return type;
}
public List<Element> getElements()
{
return elements;
}
public Element getElement()
{
return elements.get(0);
}
public void addElement(Element element)
{
elements.add(element);
}
public void accept(AnnotationVisitor visitor)
{
for (Element element : elements)
visitor.visit(element.getName(), element.getValue());
visitor.visitEnd();
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 2016-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.asm.attributes.annotation;
public class Element
{
private final Annotation annotation;
private String name;
private Object value;
public Element(Annotation annotation)
{
this.annotation = annotation;
}
public Annotation getAnnotation()
{
return annotation;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Object getValue()
{
return value;
}
public void setValue(Object value)
{
this.value = value;
}
public String getString()
{
return value.toString();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Cameron <https://github.com/noremac201>
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,63 +22,90 @@
* (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.batools;
import java.util.HashMap;
import java.util.Map;
package net.runelite.asm.attributes.code;
public enum Calls
import net.runelite.asm.ClassFile;
import net.runelite.asm.pool.Class;
public class Exception implements Cloneable
{
//Attacker Calls
RED_EGG("Red egg", "Tell-red"),
GREEN_EGG("Green egg", "Tell-green"),
BLUE_EGG("Blue egg", "Tell-blue"),
//Collector Calls
CONTROLLED("Controlled/Bullet/Wind", "Tell-controlled"),
ACCURATE("Accurate/Field/Water", "Tell-accurate"),
AGGRESSIVE("Aggressive/Blunt/Earth", "Tell-aggressive"),
DEFENSIVE("Defensive/Barbed/Fire", "Tell-defensive"),
//Healer Calls
TOFU("Tofu", "Tell-tofu"),
CRACKERS("Crackers", "Tell-crackers"),
WORMS("Worms", "Tell-worms"),
//Defender Calls
POIS_WORMS("Pois. Worms", "Tell-worms"),
POIS_TOFU("Pois. Tofu", "Tell-tofu"),
POIS_MEAT("Pois. Meat", "Tell-meat");
private Exceptions exceptions;
private final String call;
private final String option;
private Label start, end, handler;
private Class catchType;
private static final Map<String, String> CALL_MENU = new HashMap<>();
static
public Exception(Exceptions exceptions)
{
for (Calls s : values())
this.exceptions = exceptions;
}
@Override
public Exception clone()
{
try
{
CALL_MENU.put(s.getCall(), s.getOption());
return (Exception) super.clone();
}
catch (CloneNotSupportedException ex)
{
throw new RuntimeException();
}
}
Calls(String call, String option)
public Exceptions getExceptions()
{
this.call = call;
this.option = option;
return exceptions;
}
public void setExceptions(Exceptions exceptions)
{
this.exceptions = exceptions;
}
public Label getStart()
{
return start;
}
public void setStart(Label ins)
{
start = ins;
}
public Label getEnd()
{
return end;
}
public String getCall()
public void setEnd(Label end)
{
return call;
this.end = end;
}
public Label getHandler()
{
return handler;
}
public String getOption()
public void setHandler(Label handler)
{
return option;
this.handler = handler;
}
public Class getCatchType()
{
return catchType;
}
public static String getOption(String call)
public void setCatchType(Class catchType)
{
return CALL_MENU.get(call);
this.catchType = catchType;
}
public void renameClass(ClassFile cf, String name)
{
if (catchType != null && cf.getName().equals(catchType.getName()))
catchType = new Class(name);
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2016-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.asm.attributes.code;
import java.util.ArrayList;
import java.util.List;
import net.runelite.asm.ClassFile;
import net.runelite.asm.attributes.Code;
public class Exceptions
{
private Code code;
private List<Exception> exceptions = new ArrayList<Exception>();
public Exceptions(Code code)
{
this.code = code;
}
public void add(Exception e)
{
exceptions.add(e);
}
public void remove(Exception e)
{
exceptions.remove(e);
}
public void clear()
{
exceptions.clear();
}
public Code getCode()
{
return code;
}
public List<Exception> getExceptions()
{
return exceptions;
}
public void renameClass(ClassFile cf, String name)
{
for (Exception e : exceptions)
e.renameClass(cf, name);
}
}

View File

@@ -0,0 +1,144 @@
/*
* Copyright (c) 2016-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.asm.attributes.code;
import net.runelite.asm.Method;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import org.objectweb.asm.MethodVisitor;
public abstract class Instruction implements Cloneable
{
private Instructions instructions;
private InstructionType type;
public Instruction(Instructions instructions, InstructionType type)
{
this.instructions = instructions;
this.type = type;
}
@Override
public String toString()
{
if (this.getInstructions() != null)
{
Method m = this.getInstructions().getCode().getMethod();
return super.toString() + " in " + m;// + " at pc 0x" + Integer.toHexString(this.getPc());
}
else
{
return super.toString() + " <unattached>";
}
}
@Override
public Instruction clone()
{
Instruction i;
try
{
i = (Instruction) super.clone();
}
catch (CloneNotSupportedException ex)
{
throw new RuntimeException(ex);
}
return i;
}
protected void remove()
{
Exceptions exceptions = instructions.getCode().getExceptions();
for (Exception e : exceptions.getExceptions())
{
assert this != e.getStart();
assert this != e.getEnd();
assert this != e.getHandler();
}
}
public boolean removeStack()
{
assert instructions != null;
this.getInstructions().remove(this); // calls remove()
return true;
}
// resolve jumps
public void resolve()
{
}
public void accept(MethodVisitor visitor)
{
visitor.visitInsn(this.getType().getCode());
}
public Instructions getInstructions()
{
return instructions;
}
public void setInstructions(Instructions instructions)
{
this.instructions = instructions;
}
public InstructionType getType()
{
return type;
}
protected void setType(InstructionType type)
{
this.type = type;
}
public abstract InstructionContext execute(Frame e);
/* does this terminate a block? */
public boolean isTerminal()
{
return false;
}
// look up symbols from pool
public void lookup()
{
}
// instructions keep resolved method/field/class names, this updates the pool value (if the underlying resolved object changes)
public void regeneratePool()
{
}
public void renameClass(String oldName, String newName)
{
}
}

View File

@@ -0,0 +1,348 @@
/*
* Copyright (c) 2016-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.asm.attributes.code;
import net.runelite.asm.attributes.code.instructions.AALoad;
import net.runelite.asm.attributes.code.instructions.AAStore;
import net.runelite.asm.attributes.code.instructions.AConstNull;
import net.runelite.asm.attributes.code.instructions.ALoad;
import net.runelite.asm.attributes.code.instructions.ANewArray;
import net.runelite.asm.attributes.code.instructions.AStore;
import net.runelite.asm.attributes.code.instructions.AThrow;
import net.runelite.asm.attributes.code.instructions.ArrayLength;
import net.runelite.asm.attributes.code.instructions.BALoad;
import net.runelite.asm.attributes.code.instructions.BAStore;
import net.runelite.asm.attributes.code.instructions.BiPush;
import net.runelite.asm.attributes.code.instructions.CALoad;
import net.runelite.asm.attributes.code.instructions.CAStore;
import net.runelite.asm.attributes.code.instructions.CheckCast;
import net.runelite.asm.attributes.code.instructions.D2F;
import net.runelite.asm.attributes.code.instructions.D2I;
import net.runelite.asm.attributes.code.instructions.D2L;
import net.runelite.asm.attributes.code.instructions.DALoad;
import net.runelite.asm.attributes.code.instructions.DAStore;
import net.runelite.asm.attributes.code.instructions.DAdd;
import net.runelite.asm.attributes.code.instructions.DCmpG;
import net.runelite.asm.attributes.code.instructions.DCmpL;
import net.runelite.asm.attributes.code.instructions.DDiv;
import net.runelite.asm.attributes.code.instructions.DLoad;
import net.runelite.asm.attributes.code.instructions.DMul;
import net.runelite.asm.attributes.code.instructions.DNeg;
import net.runelite.asm.attributes.code.instructions.DRem;
import net.runelite.asm.attributes.code.instructions.DStore;
import net.runelite.asm.attributes.code.instructions.DSub;
import net.runelite.asm.attributes.code.instructions.Dup;
import net.runelite.asm.attributes.code.instructions.Dup2;
import net.runelite.asm.attributes.code.instructions.Dup2_X1;
import net.runelite.asm.attributes.code.instructions.Dup2_X2;
import net.runelite.asm.attributes.code.instructions.Dup_X1;
import net.runelite.asm.attributes.code.instructions.Dup_X2;
import net.runelite.asm.attributes.code.instructions.F2D;
import net.runelite.asm.attributes.code.instructions.F2I;
import net.runelite.asm.attributes.code.instructions.F2L;
import net.runelite.asm.attributes.code.instructions.FALoad;
import net.runelite.asm.attributes.code.instructions.FAStore;
import net.runelite.asm.attributes.code.instructions.FAdd;
import net.runelite.asm.attributes.code.instructions.FCmpG;
import net.runelite.asm.attributes.code.instructions.FCmpL;
import net.runelite.asm.attributes.code.instructions.FDiv;
import net.runelite.asm.attributes.code.instructions.FLoad;
import net.runelite.asm.attributes.code.instructions.FMul;
import net.runelite.asm.attributes.code.instructions.FNeg;
import net.runelite.asm.attributes.code.instructions.FRem;
import net.runelite.asm.attributes.code.instructions.FStore;
import net.runelite.asm.attributes.code.instructions.FSub;
import net.runelite.asm.attributes.code.instructions.GetField;
import net.runelite.asm.attributes.code.instructions.GetStatic;
import net.runelite.asm.attributes.code.instructions.Goto;
import net.runelite.asm.attributes.code.instructions.GotoW;
import net.runelite.asm.attributes.code.instructions.I2B;
import net.runelite.asm.attributes.code.instructions.I2C;
import net.runelite.asm.attributes.code.instructions.I2D;
import net.runelite.asm.attributes.code.instructions.I2F;
import net.runelite.asm.attributes.code.instructions.I2L;
import net.runelite.asm.attributes.code.instructions.I2S;
import net.runelite.asm.attributes.code.instructions.IALoad;
import net.runelite.asm.attributes.code.instructions.IAStore;
import net.runelite.asm.attributes.code.instructions.IAdd;
import net.runelite.asm.attributes.code.instructions.IAnd;
import net.runelite.asm.attributes.code.instructions.IDiv;
import net.runelite.asm.attributes.code.instructions.IInc;
import net.runelite.asm.attributes.code.instructions.ILoad;
import net.runelite.asm.attributes.code.instructions.IMul;
import net.runelite.asm.attributes.code.instructions.INeg;
import net.runelite.asm.attributes.code.instructions.IOr;
import net.runelite.asm.attributes.code.instructions.IRem;
import net.runelite.asm.attributes.code.instructions.IShL;
import net.runelite.asm.attributes.code.instructions.IShR;
import net.runelite.asm.attributes.code.instructions.IStore;
import net.runelite.asm.attributes.code.instructions.ISub;
import net.runelite.asm.attributes.code.instructions.IUShR;
import net.runelite.asm.attributes.code.instructions.IXor;
import net.runelite.asm.attributes.code.instructions.IfACmpEq;
import net.runelite.asm.attributes.code.instructions.IfACmpNe;
import net.runelite.asm.attributes.code.instructions.IfCmpGe;
import net.runelite.asm.attributes.code.instructions.IfCmpGt;
import net.runelite.asm.attributes.code.instructions.IfCmpLe;
import net.runelite.asm.attributes.code.instructions.IfCmpLt;
import net.runelite.asm.attributes.code.instructions.IfEq;
import net.runelite.asm.attributes.code.instructions.IfGe;
import net.runelite.asm.attributes.code.instructions.IfGt;
import net.runelite.asm.attributes.code.instructions.IfICmpEq;
import net.runelite.asm.attributes.code.instructions.IfICmpNe;
import net.runelite.asm.attributes.code.instructions.IfLe;
import net.runelite.asm.attributes.code.instructions.IfLt;
import net.runelite.asm.attributes.code.instructions.IfNe;
import net.runelite.asm.attributes.code.instructions.IfNonNull;
import net.runelite.asm.attributes.code.instructions.IfNull;
import net.runelite.asm.attributes.code.instructions.InstanceOf;
import net.runelite.asm.attributes.code.instructions.InvokeDynamic;
import net.runelite.asm.attributes.code.instructions.InvokeInterface;
import net.runelite.asm.attributes.code.instructions.InvokeSpecial;
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
import net.runelite.asm.attributes.code.instructions.InvokeVirtual;
import net.runelite.asm.attributes.code.instructions.L2D;
import net.runelite.asm.attributes.code.instructions.L2F;
import net.runelite.asm.attributes.code.instructions.L2I;
import net.runelite.asm.attributes.code.instructions.LALoad;
import net.runelite.asm.attributes.code.instructions.LAStore;
import net.runelite.asm.attributes.code.instructions.LAdd;
import net.runelite.asm.attributes.code.instructions.LAnd;
import net.runelite.asm.attributes.code.instructions.LCmp;
import net.runelite.asm.attributes.code.instructions.LDC;
import net.runelite.asm.attributes.code.instructions.LDiv;
import net.runelite.asm.attributes.code.instructions.LLoad;
import net.runelite.asm.attributes.code.instructions.LMul;
import net.runelite.asm.attributes.code.instructions.LNeg;
import net.runelite.asm.attributes.code.instructions.LOr;
import net.runelite.asm.attributes.code.instructions.LRem;
import net.runelite.asm.attributes.code.instructions.LShL;
import net.runelite.asm.attributes.code.instructions.LShR;
import net.runelite.asm.attributes.code.instructions.LStore;
import net.runelite.asm.attributes.code.instructions.LSub;
import net.runelite.asm.attributes.code.instructions.LUShR;
import net.runelite.asm.attributes.code.instructions.LXor;
import net.runelite.asm.attributes.code.instructions.LookupSwitch;
import net.runelite.asm.attributes.code.instructions.MonitorEnter;
import net.runelite.asm.attributes.code.instructions.MonitorExit;
import net.runelite.asm.attributes.code.instructions.MultiANewArray;
import net.runelite.asm.attributes.code.instructions.NOP;
import net.runelite.asm.attributes.code.instructions.New;
import net.runelite.asm.attributes.code.instructions.NewArray;
import net.runelite.asm.attributes.code.instructions.Pop;
import net.runelite.asm.attributes.code.instructions.Pop2;
import net.runelite.asm.attributes.code.instructions.PutField;
import net.runelite.asm.attributes.code.instructions.PutStatic;
import net.runelite.asm.attributes.code.instructions.Return;
import net.runelite.asm.attributes.code.instructions.SALoad;
import net.runelite.asm.attributes.code.instructions.SAStore;
import net.runelite.asm.attributes.code.instructions.SiPush;
import net.runelite.asm.attributes.code.instructions.Swap;
import net.runelite.asm.attributes.code.instructions.TableSwitch;
import net.runelite.asm.attributes.code.instructions.VReturn;
public enum InstructionType
{
NOP(0x00, "nop", NOP.class),
ACONST_NULL(0x01, "aconst_null", AConstNull.class),
BIPUSH(0x10, "bipush", BiPush.class),
SIPUSH(0x11, "sipush", SiPush.class),
LDC(-1, "ldc", LDC.class),
ILOAD(0x15, "iload", ILoad.class),
LLOAD(0x16, "lload", LLoad.class),
FLOAD(0x17, "fload", FLoad.class),
DLOAD(0x18, "dload", DLoad.class),
ALOAD(0x19, "aload", ALoad.class),
IALOAD(0x2e, "iaload", IALoad.class),
LALOAD(0x2f, "laload", LALoad.class),
FALOAD(0x30, "faload", FALoad.class),
DALOAD(0x31, "daload", DALoad.class),
AALOAD(0x32, "aaload", AALoad.class),
BALOAD(0x33, "baload", BALoad.class),
CALOAD(0x34, "caload", CALoad.class),
SALOAD(0x35, "saload", SALoad.class),
ISTORE(0x36, "istore", IStore.class),
LSTORE(0x37, "lstore", LStore.class),
FSTORE(0x38, "fstore", FStore.class),
DSTORE(0x39, "dstore", DStore.class),
ASTORE(0x3a, "astore", AStore.class),
IASTORE(0x4f, "iastore", IAStore.class),
LASTORE(0x50, "lastore", LAStore.class),
FASTORE(0x51, "fastore", FAStore.class),
DASTORE(0x52, "dastore", DAStore.class),
AASTORE(0x53, "aastore", AAStore.class),
BASTORE(0x54, "bastore", BAStore.class),
CASTORE(0x55, "castore", CAStore.class),
SASTORE(0x56, "sastore", SAStore.class),
POP(0x57, "pop", Pop.class),
POP2(0x58, "pop2", Pop2.class),
DUP(0x59, "dup", Dup.class),
DUP_X1(0x5a, "dup_x1", Dup_X1.class),
DUP_X2(0x5b, "dup_x2", Dup_X2.class),
DUP2(0x5c, "dup2", Dup2.class),
DUP2_X1(0x5d, "dup2_x1", Dup2_X1.class),
DUP2_X2(0x5e, "dup2_x2", Dup2_X2.class),
SWAP(0x5f, "swap", Swap.class),
IADD(0x60, "iadd", IAdd.class),
LADD(0x61, "ladd", LAdd.class),
FADD(0x62, "fadd", FAdd.class),
DADD(0x63, "dadd", DAdd.class),
ISUB(0x64, "isub", ISub.class),
LSUB(0x65, "lsub", LSub.class),
FSUB(0x66, "fsub", FSub.class),
DSUB(0x67, "dsub", DSub.class),
IMUL(0x68, "imul", IMul.class),
LMUL(0x69, "lmul", LMul.class),
FMUL(0x6a, "fmul", FMul.class),
DMUL(0x6b, "dmul", DMul.class),
IDIV(0x6c, "idiv", IDiv.class),
LDIV(0x6d, "ldiv", LDiv.class),
FDIV(0x6e, "fdiv", FDiv.class),
DDIV(0x6f, "ddiv", DDiv.class),
IREM(0x70, "irem", IRem.class),
LREM(0x71, "lrem", LRem.class),
FREM(0x72, "frem", FRem.class),
DREM(0x73, "drem", DRem.class),
INEG(0x74, "ineg", INeg.class),
LNEG(0x75, "lneg", LNeg.class),
FNEG(0x76, "fneg", FNeg.class),
DNEG(0x77, "dneg", DNeg.class),
ISHL(0x78, "ishl", IShL.class),
LSHL(0x79, "lshl", LShL.class),
ISHR(0x7a, "ishr", IShR.class),
LSHR(0x7b, "lshr", LShR.class),
IUSHR(0x7c, "iushr", IUShR.class),
LUSHR(0x7d, "lushr", LUShR.class),
IAND(0x7e, "iand", IAnd.class),
LAND(0x7f, "land", LAnd.class),
IOR(0x80, "ior", IOr.class),
LOR(0x81, "lor", LOr.class),
IXOR(0x82, "ixor", IXor.class),
LXOR(0x83, "lxor", LXor.class),
IINC(0x84, "iinc", IInc.class),
I2L(0x85, "i2l", I2L.class),
I2F(0x86, "i2f", I2F.class),
I2D(0x87, "i2d", I2D.class),
L2I(0x88, "l2i", L2I.class),
L2F(0x89, "l2f", L2F.class),
L2D(0x8a, "l2d", L2D.class),
F2I(0x8b, "f2i", F2I.class),
F2L(0x8c, "f2l", F2L.class),
F2D(0x8d, "f2d", F2D.class),
D2I(0x8e, "d2i", D2I.class),
D2L(0x8f, "d2l", D2L.class),
D2F(0x90, "d2f", D2F.class),
I2B(0x91, "i2b", I2B.class),
I2C(0x92, "i2c", I2C.class),
I2S(0x93, "i2s", I2S.class),
LCMP(0x94, "lcmp", LCmp.class),
FCMPL(0x95, "fcmpl", FCmpL.class),
FCMPG(0x96, "fcmpg", FCmpG.class),
DCMPL(0x97, "dcmpl", DCmpL.class),
DCMPG(0x98, "dcmpg", DCmpG.class),
IFEQ(0x99, "ifeq", IfEq.class),
IFNE(0x9a, "ifne", IfNe.class),
IFLT(0x9b, "iflt", IfLt.class),
IFGE(0x9c, "ifge", IfGe.class),
IFGT(0x9d, "ifgt", IfGt.class),
IFLE(0x9e, "ifle", IfLe.class),
IF_ICMPEQ(0x9f, "if_icmpeq", IfICmpEq.class),
IF_ICMPNE(0xa0, "if_icmpne", IfICmpNe.class),
IF_ICMPLT(0xa1, "if_cmplt", IfCmpLt.class),
IF_ICMPGE(0xa2, "if_icmpge", IfCmpGe.class),
IF_ICMPGT(0xa3, "if_icmpgt", IfCmpGt.class),
IF_ICMPLE(0xa4, "if_icmple", IfCmpLe.class),
IF_ACMPEQ(0xa5, "if_acmpeq", IfACmpEq.class),
IF_ACMPNE(0xa6, "if_acmpne", IfACmpNe.class),
GOTO(0xa7, "goto", Goto.class),
TABLESWITCH(0xaa, "tableswitch", TableSwitch.class),
LOOKUPSWITCH(0xab, "lookupswitch", LookupSwitch.class),
IRETURN(0xac, "ireturn", Return.class),
LRETURN(0xad, "lreturn", Return.class),
FRETURN(0xae, "freturn", Return.class),
DRETURN(0xaf, "dreturn", Return.class),
ARETURN(0xb0, "areturn", Return.class),
RETURN(0xb1, "return", VReturn.class),
GETSTATIC(0xb2, "getstatic", GetStatic.class),
PUTSTATIC(0xb3, "putstatic", PutStatic.class),
GETFIELD(0xb4, "getfield", GetField.class),
PUTFIELD(0xb5, "putfield", PutField.class),
INVOKEVIRTUAL(0xb6, "invokevirtual", InvokeVirtual.class),
INVOKESPECIAL(0xb7, "invokespecial", InvokeSpecial.class),
INVOKESTATIC(0xb8, "invokestatic", InvokeStatic.class),
INVOKEINTERFACE(0xb9, "invokeinterface", InvokeInterface.class),
INVOKEDYNAMIC(0xba, "invokedynamic", InvokeDynamic.class),
NEW(0xbb, "new", New.class),
NEWARRAY(0xbc, "newarray", NewArray.class),
ANEWARRAY(0xbd, "anewarray", ANewArray.class),
ARRAYLENGTH(0xbe, "arraylength", ArrayLength.class),
ATHROW(0xbf, "athrow", AThrow.class),
CHECKCAST(0xc0, "checkcast", CheckCast.class),
INSTANCEOf(0xc1, "instanceof", InstanceOf.class),
MONITORENTER(0xc2, "monitorenter", MonitorEnter.class),
MONITOREXIT(0xc3, "monitorexit", MonitorExit.class),
MULTIANEWARRAY(0xc5, "multianewarray", MultiANewArray.class),
IFNULL(0xc6, "ifnull", IfNull.class),
IFNONNULL(0xc7, "ifnonnull", IfNonNull.class),
GOTO_W(0xc8, "goto_w", GotoW.class);
private final int code;
private final String name;
private final Class<? extends Instruction> clazz;
InstructionType(int op, String name, Class<? extends Instruction> clazz)
{
this.code = op;
this.name = name;
this.clazz = clazz;
}
public int getCode()
{
return code;
}
public String getName()
{
return name;
}
public Class<? extends Instruction> getInstructionClass()
{
return clazz;
}
public static InstructionType findInstructionFromCode(int code)
{
for (InstructionType t : InstructionType.values())
{
if (t.getCode() == code)
{
return t;
}
}
return null;
}
}

View File

@@ -0,0 +1,189 @@
/*
* Copyright (c) 2016-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.asm.attributes.code;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.runelite.asm.attributes.Code;
public class Instructions
{
private final Code code;
private final List<Instruction> instructions = new ArrayList<>();
private final Map<org.objectweb.asm.Label, Label> labelMap = new HashMap<>();
public Instructions(Code code)
{
this.code = code;
}
public Label createLabelFor(Instruction target)
{
return createLabelFor(target, false);
}
public Label createLabelFor(Instruction target, boolean forceCreate)
{
assert target.getInstructions() == this;
assert instructions.contains(target);
if (target instanceof Label)
{
return (Label) target;
}
int i = instructions.indexOf(target);
if (i > 0)
{
Instruction before = instructions.get(i - 1);
if (!forceCreate && before instanceof Label)
{
return (Label) before;
}
}
Label label = new Label(this);
label.setLabel(new org.objectweb.asm.Label());
instructions.add(i, label);
labelMap.put(label.getLabel(), label);
return label;
}
public Label findLabel(org.objectweb.asm.Label l)
{
Label label = labelMap.get(l);
assert label != null;
return label;
}
public Label findOrCreateLabel(org.objectweb.asm.Label l)
{
Label label = labelMap.get(l);
if (label != null)
{
return label;
}
label = new Label(this, l);
labelMap.put(l, label);
return label;
}
public void rebuildLabels()
{
labelMap.clear();
// ow2 asm requires new Labels each time you write out a class
// with ClassWriter, or else it crytpically fails
for (Instruction i : instructions)
{
if (i instanceof Label)
{
org.objectweb.asm.Label label = new org.objectweb.asm.Label();
((Label) i).setLabel(label);
labelMap.put(label, (Label) i);
}
}
}
public List<Instruction> getInstructions()
{
return instructions;
}
public void addInstruction(Instruction i)
{
assert i.getInstructions() == this;
instructions.add(i);
}
public void addInstruction(int idx, Instruction i)
{
assert i.getInstructions() == this;
instructions.add(idx, i);
}
public void remove(Instruction ins)
{
assert ins.getInstructions() == this;
ins.remove();
instructions.remove(ins);
ins.setInstructions(null);
}
public void clear()
{
for (Instruction ins : instructions)
{
ins.remove();
ins.setInstructions(null);
}
instructions.clear();
}
public Code getCode()
{
return code;
}
public void lookup()
{
for (Instruction i : instructions)
{
i.lookup();
}
}
public void regeneratePool()
{
for (Instruction i : instructions)
{
i.regeneratePool();
}
}
public int replace(Instruction oldi, Instruction newi)
{
assert oldi != newi;
assert oldi.getInstructions() == this;
assert newi.getInstructions() == this;
assert instructions.contains(oldi);
assert !instructions.contains(newi);
int i = instructions.indexOf(oldi);
instructions.remove(oldi);
oldi.setInstructions(null);
instructions.add(i, newi);
return i;
}
}

View File

@@ -0,0 +1,128 @@
/*
* Copyright (c) 2016-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.asm.attributes.code;
import net.runelite.asm.attributes.code.instructions.NOP;
import org.objectweb.asm.MethodVisitor;
public class Label extends NOP
{
private org.objectweb.asm.Label label;
private Integer lineNumber;
public Label(Instructions instructions)
{
super(instructions);
}
public Label(Instructions instructions, org.objectweb.asm.Label label)
{
super(instructions);
this.label = label;
}
@Override
public String toString()
{
String string;
if (this.getInstructions() == null)
{
string = "label <unattached>";
}
else
{
Instruction next = next();
if (next == null)
{
string = "label with no next instruction";
}
else
{
string = "label " + next.toString();
}
}
if (lineNumber != null)
{
string += " on line number " + lineNumber;
}
return string;
}
@Override
public Instruction clone()
{
Label l = (Label) super.clone();
l.label = new org.objectweb.asm.Label();
l.lineNumber = lineNumber;
return l;
}
@Override
public void accept(MethodVisitor visitor)
{
visitor.visitLabel(label);
if (lineNumber != null)
{
visitor.visitLineNumber(lineNumber, label);
}
}
public org.objectweb.asm.Label getLabel()
{
return label;
}
public void setLabel(org.objectweb.asm.Label label)
{
this.label = label;
}
public void setLineNumber(Integer lineNumber)
{
this.lineNumber = lineNumber;
}
public Instruction next()
{
Instructions ins = this.getInstructions();
int i = ins.getInstructions().indexOf(this);
assert i != -1;
Instruction next;
do
{
next = ins.getInstructions().get(i + 1);
++i;
}
while (next instanceof Label);
return next;
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2018 Morgan Lewis <http://github.com/MESLewis>
* 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.asm.attributes.code;
import org.objectweb.asm.Label;
public class LocalVariable
{
private final String name;
private final String desc;
private final String signature;
private final Label start;
private final Label end;
private final int index;
public LocalVariable(String name, String desc, String signature, Label start, Label end, int index)
{
this.name = name;
this.desc = desc;
this.signature = signature;
this.start = start;
this.end = end;
this.index = index;
}
public String getName()
{
return name;
}
public String getDesc()
{
return desc;
}
public String getSignature()
{
return signature;
}
public Label getStart()
{
return start;
}
public Label getEnd()
{
return end;
}
public int getIndex()
{
return index;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* Copyright (c) 2018 Morgan Lewis <http://github.com/MESLewis>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,28 +22,37 @@
* (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;
package net.runelite.asm.attributes.code;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSIgnore;
import net.runelite.rs.api.RSName;
@Mixin(RSIgnore.class)
public abstract class RSIgnoreMixin implements RSIgnore
public class Parameter
{
@Override
@Inject
private final String name;
private final int access;
private LocalVariable localVariable;
public Parameter(String name, int access)
{
this.name = name;
this.access = access;
}
public String getName()
{
return getRsName().getName();
return name;
}
@Override
@Inject
public String getPrevName()
public int getAccess()
{
RSName prevName = getRsPrevName();
return prevName == null ? null : prevName.getName();
return access;
}
public LocalVariable getLocalVariable()
{
return localVariable;
}
public void setLocalVariable(LocalVariable localVariable)
{
this.localVariable = localVariable;
}
}

View File

@@ -0,0 +1,121 @@
/*
* 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.asm.attributes.code.instruction.types;
import net.runelite.asm.Field;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
import net.runelite.deob.deobfuscators.mapping.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public interface AdditionInstruction extends MappableInstruction
{
default InstructionContext findArrayLoad(InstructionContext ic1, InstructionContext ic2)
{
Instruction i1 = ic1.getInstruction();
Instruction i2 = ic2.getInstruction();
if (i1 instanceof ArrayLoad && !(i2 instanceof ArrayLoad))
{
return ic1;
}
if (i2 instanceof ArrayLoad && !(i1 instanceof ArrayLoad))
{
return ic2;
}
return null;
}
@Override
default void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other)
{
/* lhs/rhs of addition instructions are randomally swapped, but
* we still map if each side is recognizable
*
* N.B. since the lhs/rhs of nested iadds can be swapped, and
* the mapper maps the first that it encounters, this can certainly
* attempt to map the wrong instructions even when mapping the correct
* method, so be careful.
*/
StackContext ctx1 = ctx.getPops().get(0);
StackContext ctx2 = ctx.getPops().get(1);
StackContext other1 = other.getPops().get(0);
StackContext other2 = other.getPops().get(1);
InstructionContext rc1 = ctx1.getPushed().resolve(ctx1);
InstructionContext rc2 = ctx2.getPushed().resolve(ctx2); //iaload
InstructionContext ro1 = other1.getPushed().resolve(other1);
InstructionContext ro2 = other2.getPushed().resolve(other2); //iaload
// There are a couple static final arrays that are only ever read from 1 or 2 places.. and never written
InstructionContext al1 = findArrayLoad(rc1, rc2);
InstructionContext al2 = findArrayLoad(ro1, ro2);
if (al1 == null || al2 == null)
{
return;
}
StackContext array1 = al1.getPops().get(1);
StackContext array2 = al2.getPops().get(1);
InstructionContext field1 = array1.getPushed().resolve(array1);
InstructionContext field2 = array2.getPushed().resolve(array2);
if (!(field1.getInstruction() instanceof GetFieldInstruction) || !(field2.getInstruction() instanceof GetFieldInstruction))
{
return;
}
GetFieldInstruction gf1 = (GetFieldInstruction) field1.getInstruction();
GetFieldInstruction gf2 = (GetFieldInstruction) field2.getInstruction();
Field f1 = gf1.getMyField();
Field f2 = gf2.getMyField();
if (f1 == null || f2 == null || !MappingExecutorUtil.isMaybeEqual(f1, f2))
{
return;
}
mappings.map((Instruction) this, f1, f2);
}
@Override
default boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
return this.getClass() == otherIc.getInstruction().getClass();
}
@Override
default boolean canMap(InstructionContext thisIc)
{
return true;
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
import net.runelite.deob.deobfuscators.mapping.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public interface ArrayLoad extends MappableInstruction
{
@Override
default void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other)
{
StackContext index1 = ctx.getPops().get(0),
index2 = other.getPops().get(0);
InstructionContext ctx1 = MappingExecutorUtil.resolve(index1.getPushed(), index1),
ctx2 = MappingExecutorUtil.resolve(index2.getPushed(), index2);
assert ctx1.getInstruction() instanceof GetFieldInstruction;
assert ctx2.getInstruction() instanceof GetFieldInstruction;
GetFieldInstruction gf1 = (GetFieldInstruction) ctx1.getInstruction();
GetFieldInstruction gf2 = (GetFieldInstruction) ctx2.getInstruction();
mappings.map((Instruction) this, gf1.getMyField(), gf2.getMyField());
}
@Override
default boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
if (thisIc.getInstruction().getType() != otherIc.getInstruction().getType())
{
return false;
}
StackContext index1 = thisIc.getPops().get(0),
index2 = otherIc.getPops().get(0);
InstructionContext ctx1 = MappingExecutorUtil.resolve(index1.getPushed(), index1),
ctx2 = MappingExecutorUtil.resolve(index2.getPushed(), index2);
assert ctx1.getInstruction() instanceof GetFieldInstruction;
assert ctx2.getInstruction() instanceof GetFieldInstruction;
GetFieldInstruction gf1 = (GetFieldInstruction) ctx1.getInstruction();
GetFieldInstruction gf2 = (GetFieldInstruction) ctx2.getInstruction();
return MappingExecutorUtil.isMaybeEqual(gf1.getMyField(), gf2.getMyField());
}
@Override
default boolean canMap(InstructionContext thisIc)
{
// assume that obfuscation can't remove a load with a variable
// index. map field access.
StackContext index = thisIc.getPops().get(0);
InstructionContext ctx = MappingExecutorUtil.resolve(index.getPushed(), index);
return ctx.getInstruction() instanceof GetFieldInstruction;
}
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
public interface ArrayStoreInstruction extends MappableInstruction
{
}

View File

@@ -22,10 +22,10 @@
* (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.ClanMember;
package net.runelite.asm.attributes.code.instruction.types;
public interface RSClanMember extends RSChatPlayer, ClanMember
public interface ComparisonInstruction
{
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
public interface ConversionInstruction
{
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
import net.runelite.asm.Field;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
import net.runelite.deob.deobfuscators.mapping.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public interface DivisionInstruction extends MappableInstruction
{
@Override
default void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other)
{
StackContext s1 = ctx.getPops().get(0),
s2 = ctx.getPops().get(1);
StackContext o1 = other.getPops().get(0),
o2 = other.getPops().get(1);
InstructionContext i1 = MappingExecutorUtil.resolve(s1.getPushed(), s1);
InstructionContext i2 = MappingExecutorUtil.resolve(s2.getPushed(), s2);
InstructionContext io1 = MappingExecutorUtil.resolve(o1.getPushed(), o1);
InstructionContext io2 = MappingExecutorUtil.resolve(o2.getPushed(), o2);
if (i1.getInstruction() instanceof GetFieldInstruction && io1.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction f1 = (GetFieldInstruction) i1.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io1.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
if (fi1 != null && fi2 != null)
mappings.map((Instruction) this, fi1, fi2);
}
if (i2.getInstruction() instanceof GetFieldInstruction && io2.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction f1 = (GetFieldInstruction) i2.getInstruction();
GetFieldInstruction f2 = (GetFieldInstruction) io2.getInstruction();
Field fi1 = f1.getMyField(), fi2 = f2.getMyField();
if (fi1 != null && fi2 != null)
mappings.map((Instruction) this, fi1, fi2);
}
}
@Override
default boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
{
return this.getClass() == otherIc.getInstruction().getClass();
}
@Override
default boolean canMap(InstructionContext thisIc)
{
return true;
}
}

View File

@@ -22,38 +22,30 @@
* (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.ObjectComposition;
import net.runelite.mapping.Import;
package net.runelite.asm.attributes.code.instruction.types;
public interface RSObjectComposition extends ObjectComposition
import java.util.List;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.StackContext;
public interface DupInstruction
{
@Import("id")
@Override
int getId();
StackContext getOriginal(StackContext sctx);
StackContext getOtherBranch(StackContext sctx);
@Import("name")
@Override
String getName();
/**
* get the duplicated stackcontexts (which is popped from this)
* @param ictx instruction context for this instruction
* @return
*/
List<StackContext> getDuplicated(InstructionContext ictx);
@Import("actions")
@Override
String[] getActions();
@Import("mapSceneId")
@Override
int getMapSceneId();
@Import("mapIconId")
@Override
int getMapIconId();
@Import("impostorIds")
@Override
int[] getImpostorIds();
@Import("getImpostor")
@Override
RSObjectComposition getImpostor();
/**
* get the copied stackcontexts (pushed from this)
* @param ictx
* @return
*/
List<StackContext> getCopies(InstructionContext ictx);
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
import net.runelite.asm.pool.Field;
public interface FieldInstruction
{
Field getField();
void setField(Field field);
net.runelite.asm.Field getMyField();
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
public interface GetFieldInstruction extends FieldInstruction
{
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
public interface IntInstruction
{
int getOperand();
void setOperand(int operand);
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
import java.util.List;
import net.runelite.asm.Method;
public interface InvokeInstruction extends MappableInstruction
{
void removeParameter(int idx);
net.runelite.asm.pool.Method getMethod();
void setMethod(net.runelite.asm.pool.Method method);
List<Method> getMethods();
}

View File

@@ -22,20 +22,16 @@
* (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;
package net.runelite.asm.attributes.code.instruction.types;
import net.runelite.api.HashTable;
import net.runelite.mapping.Import;
import java.util.List;
import net.runelite.asm.attributes.code.Label;
public interface RSHashTable extends HashTable
public interface JumpingInstruction
{
@Import("get")
@Override
RSNode get(long value);
List<Label> getJumps();
@Import("size")
int getSize();
void setJumps(List<Label> labels);
@Import("buckets")
RSNode[] getBuckets();
void setLabel(org.objectweb.asm.Label label);
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
import net.runelite.asm.attributes.code.Instruction;
public interface LVTInstruction
{
int getVariableIndex();
Instruction setVariableIndex(int idx);
boolean store();
LVTInstructionType type();
}

View File

@@ -1,6 +1,5 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,12 +22,25 @@
* (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.questhelper;
package net.runelite.asm.attributes.code.instruction.types;
public class QuestInstantiationException extends Exception
public enum LVTInstructionType
{
public QuestInstantiationException(Throwable cause)
INT(1),
LONG(2),
FLOAT(1),
DOUBLE(2),
OBJECT(1);
private final int slots;
LVTInstructionType(int slots)
{
super(cause);
this.slots = slots;
}
public int getSlots()
{
return slots;
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping;
public interface MappableInstruction
{
void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other);
boolean isSame(InstructionContext thisIc, InstructionContext otherIc);
boolean canMap(InstructionContext thisIc);
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
import net.runelite.asm.attributes.code.Instruction;
public interface PushConstantInstruction
{
Object getConstant();
Instruction setConstant(Object entry);
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2016-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.asm.attributes.code.instruction.types;
public interface ReturnInstruction
{
}

Some files were not shown because too many files have changed in this diff Show More