├── .github └── workflows │ └── build.yaml ├── .gitignore ├── README.md ├── buildWithoutGradle.bat ├── client ├── build.gradle └── src │ └── main │ └── java │ ├── Playground.java │ ├── client.java │ └── sign │ └── signlink.java ├── deob-annotations ├── build.gradle └── src │ └── main │ └── java │ └── org │ └── openrs2 │ └── deob │ └── annotation │ ├── OriginalArg.java │ ├── OriginalClass.java │ ├── OriginalMember.java │ └── Pc.java ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── loader ├── build.gradle └── src │ └── main │ └── java │ ├── cloader.java │ └── loader.java ├── mapview ├── build.gradle └── src │ └── main │ └── java │ ├── WorldmapFont.java │ ├── mapview.java │ └── sig.java ├── ref ├── loader186.jar ├── loader245.jar └── runescape.jar ├── runetek3 ├── build.gradle └── src │ └── main │ └── java │ └── jagex2 │ ├── client │ ├── GameShell.java │ ├── InputTracking.java │ └── ViewBox.java │ ├── config │ ├── Component.java │ ├── FloType.java │ ├── IdkType.java │ ├── LocType.java │ ├── NpcType.java │ ├── ObjType.java │ ├── SeqType.java │ ├── SpotAnimType.java │ └── VarpType.java │ ├── dash3d │ ├── CollisionMap.java │ ├── Occlude.java │ ├── World.java │ ├── World3D.java │ ├── entity │ │ ├── Entity.java │ │ ├── LocAddEntity.java │ │ ├── LocEntity.java │ │ ├── LocMergeEntity.java │ │ ├── NpcEntity.java │ │ ├── ObjStackEntity.java │ │ ├── PathingEntity.java │ │ ├── PlayerEntity.java │ │ ├── ProjectileEntity.java │ │ └── SpotAnimEntity.java │ └── type │ │ ├── Decor.java │ │ ├── Ground.java │ │ ├── GroundDecor.java │ │ ├── GroundObject.java │ │ ├── Location.java │ │ ├── TileOverlay.java │ │ ├── TileUnderlay.java │ │ └── Wall.java │ ├── datastruct │ ├── DoublyLinkList.java │ ├── DoublyLinkable.java │ ├── HashTable.java │ ├── JString.java │ ├── LinkList.java │ ├── Linkable.java │ └── LruCache.java │ ├── graphics │ ├── AnimBase.java │ ├── AnimFrame.java │ ├── Model.java │ ├── Pix2D.java │ ├── Pix32.java │ ├── Pix3D.java │ ├── Pix8.java │ ├── PixFont.java │ └── PixMap.java │ ├── io │ ├── BZip2.java │ ├── ClientStream.java │ ├── Isaac.java │ ├── Jagfile.java │ ├── Packet.java │ └── Protocol.java │ ├── sound │ └── Wave.java │ └── wordenc │ ├── WordFilter.java │ └── WordPack.java ├── settings.gradle └── tools ├── build.gradle └── src └── main └── java └── lostcity ├── tools ├── LoaderSig.java ├── MapviewConvert.java ├── MapviewSig.java └── RemoveAnnotations.java └── utils └── FileUtils.java /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | 6 | jobs: 7 | loader-client: 8 | name: Build Projects 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | 13 | - uses: actions/setup-java@v4 14 | with: 15 | distribution: 'temurin' 16 | java-version: 8 17 | 18 | - uses: gradle/actions/setup-gradle@v4 19 | 20 | - name: Make code compatible with old Java 21 | run: gradle -p tools removeAnnotations 22 | 23 | - name: Run Gradle build 24 | run: gradle build -x :deob-annotations:build 25 | 26 | - name: Upload Loader-Client Artifact 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: loader-client 30 | path: | 31 | loader/build/libs/* 32 | 33 | - name: Upload Mapview Artifact 34 | uses: actions/upload-artifact@v3 35 | with: 36 | name: mapview 37 | path: | 38 | mapview/build/libs/* 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle/ 2 | /.idea/ 3 | 4 | build/ 5 | *.class 6 | 7 | loader/src/main/java/sig.java 8 | loader/src/main/java/sign/signlink.java 9 | 10 | mapview/src/main/java/sig.java 11 | 12 | /worldmap.jag 13 | /*.png 14 | /*.raw 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |

2004Scape Client - May 18, 2004

4 | 5 | [Website](https://2004scape.org) | [Discord](https://discord.2004scape.org) | [Rune-Server](https://www.rune-server.ee/runescape-development/rs2-server/projects/701698-lost-city-225-emulation.html) 6 | 7 | **status: completely refactored** 8 | 9 | **The client code was decompiled, deobfuscated, and refactored by us.** 10 | **Jagex has never had any source code leaks.** 11 |
12 | 13 | ## Project Structure 14 | 15 | `client` - Decompiled client source code. 16 | 17 | `runetek3` - Decompiled client engine source code. Some class names are original. 18 | 19 | `deob-annotations` - OpenRS2 dedobfuscator annotations library. Useful for making the namings of everything reusable if starting again from scratch or comparing to the original bytecode. 20 | 21 | `loader` - Decompiled loader source code. Class names are all original. 22 | 23 | `mapview` - Decompiled mapview source code. 24 | 25 | `tools` - Tooling specific to the client or loader. 26 | 27 | ## Sources 28 | 29 | Thanks to these individuals' projects for shedding light on some things - this would've taken a lot longer to complete without their efforts. 30 | 31 | * [Dane's 317 refactor](https://github.com/thedaneeffect/RuneScape-317) 32 | * [Dane's 186 refactor](https://github.com/thedaneeffect/RuneScape-Beta-Public) 33 | * [James Monger's 317 refactor](https://github.com/Jameskmonger/317refactor) 34 | 35 | ## Running 36 | 37 | Because there are multiple entry points, instead of `gradle run` you have to execute `gradle client:run` or `gradle mapview:run` else it will launch both sequentially. 38 | 39 | ### Mapview Applet 40 | 41 | 1. Copy worldmap.jag to the root folder. 42 | 2. Run `gradle mapSig --args="worldmap.jag"` 43 | 3. Run `gradle mapview:run` 44 | -------------------------------------------------------------------------------- /buildWithoutGradle.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @rem Manual build script for really old JDKs 3 | 4 | cd client 5 | if exist build rmdir /s /q build 6 | mkdir build 7 | 8 | javac -encoding utf8 -d build -sourcepath src/main/java/ src/main/java/client.java 9 | 10 | java -cp build client 11 | 12 | cd .. 13 | -------------------------------------------------------------------------------- /client/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'application' 4 | } 5 | 6 | dependencies { 7 | compileOnly project(':deob-annotations') 8 | implementation project(':runetek3') 9 | } 10 | 11 | java { 12 | sourceCompatibility = JavaVersion.VERSION_1_8 13 | targetCompatibility = JavaVersion.VERSION_1_8 14 | } 15 | 16 | application { 17 | mainClass = "client" 18 | } 19 | 20 | jar { 21 | from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } } 22 | duplicatesStrategy = DuplicatesStrategy.INCLUDE 23 | } 24 | 25 | tasks.withType(JavaCompile) { 26 | options.encoding = 'UTF-8' 27 | options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' 28 | } 29 | 30 | tasks.withType(JavaExec) { 31 | workingDir = project.rootDir 32 | } 33 | -------------------------------------------------------------------------------- /client/src/main/java/Playground.java: -------------------------------------------------------------------------------- 1 | import jagex2.client.GameShell; 2 | import jagex2.client.InputTracking; 3 | import jagex2.config.Component; 4 | import jagex2.config.*; 5 | import jagex2.dash3d.CollisionMap; 6 | import jagex2.dash3d.World; 7 | import jagex2.dash3d.World3D; 8 | import jagex2.dash3d.entity.*; 9 | import jagex2.dash3d.type.Ground; 10 | import jagex2.datastruct.JString; 11 | import jagex2.datastruct.LinkList; 12 | import jagex2.graphics.*; 13 | import jagex2.io.*; 14 | import jagex2.sound.Wave; 15 | import jagex2.wordenc.WordFilter; 16 | import jagex2.wordenc.WordPack; 17 | import org.openrs2.deob.annotation.OriginalArg; 18 | import org.openrs2.deob.annotation.OriginalClass; 19 | import org.openrs2.deob.annotation.OriginalMember; 20 | import org.openrs2.deob.annotation.Pc; 21 | import sign.signlink; 22 | 23 | import java.awt.*; 24 | import java.io.DataInputStream; 25 | import java.io.IOException; 26 | import java.math.BigInteger; 27 | import java.net.InetAddress; 28 | import java.net.Socket; 29 | import java.net.URL; 30 | import java.util.zip.CRC32; 31 | 32 | public class Playground extends GameShell { 33 | public static void main(String[] args) { 34 | try { 35 | signlink.startpriv(InetAddress.getByName("w1.225.2004scape.org")); 36 | 37 | Playground app = new Playground(); 38 | app.initApplication(789, 532); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | } 42 | } 43 | 44 | public static int portOffset; 45 | 46 | @Override 47 | public URL getCodeBase() { 48 | if (signlink.mainapp != null) { 49 | return signlink.mainapp.getCodeBase(); 50 | } 51 | 52 | try { 53 | if (super.frame != null) { 54 | return new URL("http://w1.225.2004scape.org:" + (portOffset + 80)); 55 | } 56 | } catch (@Pc(21) Exception ex) { 57 | } 58 | 59 | return super.getCodeBase(); 60 | } 61 | 62 | private final CRC32 crc32 = new CRC32(); 63 | private final int[] archiveChecksum = new int[9]; 64 | 65 | private PixFont fontPlain11; 66 | private PixFont fontPlain12; 67 | private PixFont fontBold12; 68 | private PixFont fontQuill8; 69 | 70 | int eyeX = 0; 71 | int eyeY = 0; 72 | int eyeZ = 0; 73 | int eyePitch = 0; 74 | int eyeYaw = 0; 75 | 76 | int modifier = 2; 77 | 78 | Model model = null; 79 | int modelId = 0; 80 | int modelX = 0; 81 | int modelY = 0; 82 | int modelZ = 420; 83 | int modelYaw = 0; 84 | 85 | @Override 86 | protected void load() { 87 | try { 88 | int retry = 5; 89 | this.archiveChecksum[8] = 0; 90 | while (this.archiveChecksum[8] == 0) { 91 | this.drawProgress("Connecting to fileserver", 10); 92 | 93 | try { 94 | DataInputStream stream = this.openUrl("crc" + (int) (Math.random() * 9.9999999E7D)); 95 | Packet checksums = new Packet(new byte[36]); 96 | stream.readFully(checksums.data, 0, 36); 97 | for (int i = 0; i < 9; i++) { 98 | this.archiveChecksum[i] = checksums.g4(); 99 | } 100 | stream.close(); 101 | } catch (IOException ex) { 102 | for (int i = retry; i > 0; i--) { 103 | this.drawProgress("Error loading - Will retry in " + i + " secs.", 10); 104 | 105 | try { 106 | Thread.sleep(1000L); 107 | } catch (Exception ignored) { 108 | } 109 | } 110 | 111 | retry *= 2; 112 | if (retry > 60) { 113 | retry = 60; 114 | } 115 | } 116 | } 117 | 118 | Jagfile title = this.loadArchive("title", this.archiveChecksum[1], "title screen", 10); 119 | this.fontPlain11 = new PixFont(title, "p11"); 120 | this.fontPlain12 = new PixFont(title, "p12"); 121 | this.fontBold12 = new PixFont(title, "b12"); 122 | this.fontQuill8 = new PixFont(title, "q8"); 123 | 124 | Jagfile config = this.loadArchive("config", this.archiveChecksum[2], "config", 15); 125 | Jagfile inter = this.loadArchive("interface", this.archiveChecksum[3], "interface", 20); 126 | Jagfile media = this.loadArchive("media", this.archiveChecksum[4], "2d graphics", 30); 127 | Jagfile models = this.loadArchive("models", this.archiveChecksum[5], "3d graphics", 40); 128 | Jagfile textures = this.loadArchive("textures", this.archiveChecksum[6], "textures", 60); 129 | Jagfile wordenc = this.loadArchive("wordenc", this.archiveChecksum[7], "chat system", 65); 130 | Jagfile sounds = this.loadArchive("sounds", this.archiveChecksum[8], "sound effects", 70); 131 | 132 | Pix3D.unpackTextures(textures); 133 | Pix3D.setBrightness(0.8); 134 | Pix3D.initPool(20); 135 | 136 | Model.unpack(models); 137 | AnimBase.unpack(models); 138 | AnimFrame.unpack(models); 139 | 140 | SeqType.unpack(config); 141 | LocType.unpack(config); 142 | FloType.unpack(config); 143 | ObjType.unpack(config); 144 | NpcType.unpack(config); 145 | IdkType.unpack(config); 146 | SpotAnimType.unpack(config); 147 | VarpType.unpack(config); 148 | 149 | byte[] data = sounds.read("sounds.dat", null); 150 | Packet soundDat = new Packet(data); 151 | Wave.unpack(soundDat); 152 | 153 | PixFont[] fonts = new PixFont[] { this.fontPlain11, this.fontPlain12, this.fontBold12, this.fontQuill8 }; 154 | Component.unpack(inter, media, fonts); 155 | 156 | WordFilter.unpack(wordenc); 157 | 158 | this.drawArea.bind(); 159 | Pix3D.init2D(); 160 | 161 | this.model = new Model(this.modelId); 162 | this.model.calculateNormals(64, 850, -30, -50, -30, true); 163 | } catch (Exception e) { 164 | e.printStackTrace(); 165 | } 166 | } 167 | 168 | @Override 169 | protected void update() { 170 | } 171 | 172 | @Override 173 | protected void draw() { 174 | Pix2D.clear(); 175 | Pix2D.fillRect(0, 0, 0x555555, this.screenWidth, this.screenHeight); 176 | 177 | this.model.draw(this.modelYaw, Pix3D.sinTable[this.eyePitch], Pix3D.cosTable[this.eyePitch], Pix3D.sinTable[this.eyeYaw], Pix3D.cosTable[this.eyeYaw], this.modelX - this.eyeX, this.modelY - this.eyeY, this.modelZ - this.eyeZ, 0); 178 | 179 | this.fontBold12.drawStringRight(this.screenWidth, this.fontBold12.height, "FPS: " + super.fps, 0xFFFF00, true); 180 | 181 | this.drawArea.draw(super.graphics, 0, 0); 182 | } 183 | 184 | private Jagfile loadArchive(String name, int crc, String displayName, int displayProgress) { 185 | int retry = 5; 186 | byte[] data = signlink.cacheload(name); 187 | if (data != null) { 188 | this.crc32.reset(); 189 | this.crc32.update(data); 190 | int crcValue = (int) this.crc32.getValue(); 191 | if (crcValue != crc) { 192 | data = null; 193 | } 194 | } 195 | 196 | if (data != null) { 197 | return new Jagfile(data); 198 | } 199 | 200 | while (data == null) { 201 | this.drawProgress("Requesting " + displayName, displayProgress); 202 | 203 | try { 204 | int lastProgress = 0; 205 | DataInputStream stream = this.openUrl(name + crc); 206 | byte[] header = new byte[6]; 207 | stream.readFully(header, 0, 6); 208 | Packet head = new Packet(header); 209 | head.pos = 3; 210 | int length = head.g3() + 6; 211 | int offset = 6; 212 | data = new byte[length]; 213 | System.arraycopy(header, 0, data, 0, 6); 214 | while (offset < length) { 215 | int remaining = length - offset; 216 | if (remaining > 1000) { 217 | remaining = 1000; 218 | } 219 | 220 | offset += stream.read(data, offset, remaining); 221 | int progress = offset * 100 / length; 222 | if (progress != lastProgress) { 223 | this.drawProgress("Loading " + displayName + " - " + progress + "%", displayProgress); 224 | } 225 | lastProgress = progress; 226 | } 227 | stream.close(); 228 | } catch (IOException ex) { 229 | data = null; 230 | for (int i = retry; i > 0; i--) { 231 | this.drawProgress("Error loading - Will retry in " + i + " secs.", displayProgress); 232 | try { 233 | Thread.sleep(1000L); 234 | } catch (Exception ignored) { 235 | } 236 | } 237 | 238 | retry *= 2; 239 | if (retry > 60) { 240 | retry = 60; 241 | } 242 | } 243 | } 244 | 245 | signlink.cachesave(name, data); 246 | return new Jagfile(data); 247 | } 248 | 249 | private DataInputStream openUrl(String url) throws IOException { 250 | if (signlink.mainapp != null) { 251 | return signlink.openurl(url); 252 | } 253 | 254 | return new DataInputStream((new URL(this.getCodeBase(), url)).openStream()); 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /deob-annotations/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'java-library' 4 | } 5 | 6 | java { 7 | sourceCompatibility = JavaVersion.VERSION_1_8 8 | } 9 | 10 | tasks.withType(JavaCompile) { 11 | options.encoding = 'UTF-8' 12 | options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' 13 | } 14 | -------------------------------------------------------------------------------- /deob-annotations/src/main/java/org/openrs2/deob/annotation/OriginalArg.java: -------------------------------------------------------------------------------- 1 | package org.openrs2.deob.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target({ ElementType.PARAMETER }) 7 | public @interface OriginalArg { 8 | int value(); 9 | } 10 | -------------------------------------------------------------------------------- /deob-annotations/src/main/java/org/openrs2/deob/annotation/OriginalClass.java: -------------------------------------------------------------------------------- 1 | package org.openrs2.deob.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target({ ElementType.TYPE }) 7 | public @interface OriginalClass { 8 | String value(); 9 | } 10 | -------------------------------------------------------------------------------- /deob-annotations/src/main/java/org/openrs2/deob/annotation/OriginalMember.java: -------------------------------------------------------------------------------- 1 | package org.openrs2.deob.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target({ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD }) 7 | public @interface OriginalMember { 8 | String owner(); 9 | String name(); 10 | String descriptor(); 11 | } 12 | -------------------------------------------------------------------------------- /deob-annotations/src/main/java/org/openrs2/deob/annotation/Pc.java: -------------------------------------------------------------------------------- 1 | package org.openrs2.deob.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Target; 5 | 6 | @Target({ ElementType.LOCAL_VARIABLE, ElementType.PARAMETER }) 7 | public @interface Pc { 8 | int value(); 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2004Scape/Client/67f5eda79588149043170088a53465fe3b00aa1a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /loader/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | dependencies { 6 | compileOnly project(':deob-annotations') 7 | } 8 | 9 | java { 10 | sourceCompatibility = JavaVersion.VERSION_1_8 11 | targetCompatibility = JavaVersion.VERSION_1_8 12 | } 13 | 14 | tasks.withType(JavaCompile) { 15 | options.encoding = 'UTF-8' 16 | options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' 17 | 18 | dependsOn("copySignlink") 19 | dependsOn(":client:build") 20 | dependsOn(":tools:sig") 21 | } 22 | 23 | tasks.withType(JavaExec) { 24 | workingDir = project.rootDir 25 | } 26 | 27 | tasks.register("copySignlink", Copy) { 28 | from("../client/src/main/java/sign/signlink.java") 29 | into("src/main/java/sign/") 30 | } 31 | -------------------------------------------------------------------------------- /loader/src/main/java/cloader.java: -------------------------------------------------------------------------------- 1 | import java.io.DataInputStream; 2 | import java.util.Hashtable; 3 | import java.util.zip.ZipEntry; 4 | import java.util.zip.ZipFile; 5 | 6 | public class cloader extends ClassLoader { 7 | private Hashtable cache = new Hashtable(); 8 | ZipFile jar; 9 | Class link; 10 | 11 | public synchronized Class loadClass(String name, boolean resolve) { 12 | Class instance = (Class) cache.get(name); 13 | if (instance != null) { 14 | return instance; 15 | } 16 | 17 | Class found; 18 | try { 19 | instance = super.findSystemClass(name); 20 | found = instance; 21 | } catch (ClassNotFoundException _ex1) { 22 | if (name.indexOf("signlink") != -1) { 23 | return this.link; 24 | } 25 | 26 | try { 27 | ZipEntry entry = (this).jar.getEntry(name.replace('.', '/') + ".class"); 28 | int size = (int) entry.getSize(); 29 | 30 | DataInputStream stream = new DataInputStream(this.jar.getInputStream(entry)); 31 | byte[] is = new byte[size]; 32 | stream.readFully(is); 33 | stream.close(); 34 | 35 | instance = defineClass(is, 0, is.length); 36 | if (resolve) { 37 | resolveClass(instance); 38 | } 39 | 40 | cache.put(name, instance); 41 | } catch (Exception _ex2) { 42 | /* empty */ 43 | } 44 | 45 | return instance; 46 | } 47 | 48 | return found; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /loader/src/main/java/loader.java: -------------------------------------------------------------------------------- 1 | import sign.signlink; 2 | 3 | import java.applet.Applet; 4 | import java.awt.*; 5 | import java.io.InputStream; 6 | import java.net.InetAddress; 7 | import java.net.URL; 8 | import java.security.MessageDigest; 9 | import java.util.zip.ZipFile; 10 | 11 | public class loader extends Applet implements Runnable { 12 | private static final int swid = 789; 13 | private static final int shei = 532; 14 | 15 | private boolean maxpri = false; 16 | private Applet inner; 17 | 18 | public void init() { 19 | try { 20 | signlink.mainapp = this; 21 | signlink.startpriv(InetAddress.getByName(getCodeBase().getHost())); 22 | 23 | String vendor = System.getProperties().getProperty("java.vendor"); 24 | if (vendor.toLowerCase().indexOf("sun") != -1 || vendor.toLowerCase().indexOf("apple") != -1) { 25 | signlink.sunjava = true; 26 | } 27 | 28 | new Thread(this).start(); 29 | } catch (Exception ex) { 30 | ex.printStackTrace(); 31 | } 32 | } 33 | 34 | public void run() { 35 | try { 36 | byte[] jar = signlink.cacheload("runescape.jar"); 37 | 38 | if (!verify(jar)) { 39 | updatecache(); 40 | 41 | jar = signlink.cacheload("runescape.jar"); 42 | if (!verify(jar)) { 43 | return; 44 | } 45 | } 46 | 47 | String cachedir = signlink.findcachedir(); 48 | if (cachedir == null) { 49 | showprogress("No writable cache directory", 0); 50 | return; 51 | } 52 | 53 | cloader classLoader = new cloader(); 54 | classLoader.jar = new ZipFile(cachedir + "/" + signlink.gethash("runescape.jar")); 55 | classLoader.link = Class.forName("sign.signlink"); 56 | 57 | inner = (Applet) classLoader.loadClass("client").newInstance(); 58 | inner.init(); 59 | inner.start(); 60 | } catch (Exception ex) { 61 | ex.printStackTrace(); 62 | } 63 | } 64 | 65 | private void showprogress(String message, int percent) { 66 | Graphics g = getGraphics(); 67 | 68 | Font bold = new Font("Helvetica", Font.BOLD, 13); 69 | FontMetrics boldMetrics = getFontMetrics(bold); 70 | Font plain = new Font("Helvetica", Font.PLAIN, 13); 71 | FontMetrics plainMetrics = getFontMetrics(plain); 72 | 73 | Color barColor = new Color(140, 17, 17); 74 | 75 | g.setColor(Color.black); 76 | g.fillRect(0, 0, loader.swid, loader.shei); 77 | 78 | g.setColor(barColor); 79 | g.drawRect(242, 248, 304, 34); 80 | 81 | String str = message + " - " + percent + "%"; 82 | g.setFont(bold); 83 | g.setColor(Color.white); 84 | g.drawString(str, ((loader.swid - boldMetrics.stringWidth(str)) / 2), 270); 85 | } 86 | 87 | private void updatecache() throws Exception { 88 | // name + sha has a benefit of cache busting in addition to being harder to find 89 | byte[] src = new byte[sig.len]; 90 | String uriSha = ""; 91 | for (int i = 0; i < 10; i++) { 92 | uriSha += sig.sha[i]; 93 | } 94 | InputStream stream = new URL(getCodeBase(), "runescape" + uriSha + ".jar").openStream(); 95 | 96 | int lastPercent = 0; 97 | int read = 0; 98 | while (read < sig.len) { 99 | int remaining = sig.len - read; 100 | if (remaining > 1000) { 101 | remaining = 1000; 102 | } 103 | 104 | read += stream.read(src, read, remaining); 105 | 106 | int percent = read * 100 / sig.len; 107 | if (percent != lastPercent) { 108 | showprogress("Loading game code", percent); 109 | 110 | lastPercent = percent; 111 | } 112 | } 113 | 114 | stream.close(); 115 | signlink.cachesave("runescape.jar", src); 116 | } 117 | 118 | private boolean verify(byte[] src) throws Exception { 119 | if (src == null) { 120 | return false; 121 | } 122 | 123 | MessageDigest shasum = MessageDigest.getInstance("SHA"); 124 | shasum.reset(); 125 | shasum.update(src); 126 | 127 | byte[] sha = shasum.digest(); 128 | for (int i = 0; i < 20; i++) { 129 | if (sha[i] != sig.sha[i]) { 130 | return false; 131 | } 132 | } 133 | 134 | return true; 135 | } 136 | 137 | public void start() { 138 | if (inner != null) { 139 | inner.start(); 140 | } 141 | } 142 | 143 | public void stop() { 144 | if (inner != null) { 145 | inner.stop(); 146 | } 147 | } 148 | 149 | public void destroy() { 150 | if (inner != null) { 151 | inner.destroy(); 152 | } 153 | } 154 | 155 | public void update(Graphics g) { 156 | if (inner != null) { 157 | inner.update(g); 158 | } 159 | } 160 | 161 | public void paint(Graphics g) { 162 | if (inner != null) { 163 | inner.paint(g); 164 | } 165 | } 166 | 167 | public String getmidi() { 168 | if (signlink.midi == null) { 169 | return "none"; 170 | } 171 | 172 | String str = signlink.midi; 173 | signlink.midi = null; 174 | return str; 175 | } 176 | 177 | public int getmidivol() { 178 | return signlink.midivol; 179 | } 180 | 181 | public int getmidifade() { 182 | return signlink.midifade; 183 | } 184 | 185 | public String getwave() { 186 | if (signlink.wave == null) { 187 | return "none"; 188 | } 189 | 190 | String str = signlink.wave; 191 | signlink.wave = null; 192 | return str; 193 | } 194 | 195 | public int getwavevol() { 196 | return signlink.wavevol; 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /mapview/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'application' 4 | } 5 | 6 | dependencies { 7 | compileOnly project(':deob-annotations') 8 | implementation project(':runetek3') 9 | } 10 | 11 | java { 12 | sourceCompatibility = JavaVersion.VERSION_1_8 13 | targetCompatibility = JavaVersion.VERSION_1_8 14 | } 15 | 16 | application { 17 | mainClass = "mapview" 18 | } 19 | 20 | jar { 21 | from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } } 22 | duplicatesStrategy = DuplicatesStrategy.INCLUDE 23 | } 24 | 25 | tasks.withType(JavaCompile) { 26 | options.encoding = 'UTF-8' 27 | options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' 28 | } 29 | 30 | tasks.withType(JavaExec) { 31 | workingDir = project.rootDir 32 | } 33 | -------------------------------------------------------------------------------- /mapview/src/main/java/sig.java: -------------------------------------------------------------------------------- 1 | public class sig { 2 | public static final int len = 325557; 3 | 4 | public static final int[] sha = { -97, -86, -83, -84, -114, 88, -21, 25, 35, -40, 108, 11, 121, -27, -59, -40, -108, 126, -92, -23 }; 5 | } -------------------------------------------------------------------------------- /ref/loader186.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2004Scape/Client/67f5eda79588149043170088a53465fe3b00aa1a/ref/loader186.jar -------------------------------------------------------------------------------- /ref/loader245.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2004Scape/Client/67f5eda79588149043170088a53465fe3b00aa1a/ref/loader245.jar -------------------------------------------------------------------------------- /ref/runescape.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/2004Scape/Client/67f5eda79588149043170088a53465fe3b00aa1a/ref/runescape.jar -------------------------------------------------------------------------------- /runetek3/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'java-library' 4 | } 5 | 6 | dependencies { 7 | compileOnly project(':deob-annotations') 8 | } 9 | 10 | java { 11 | sourceCompatibility = JavaVersion.VERSION_1_8 12 | targetCompatibility = JavaVersion.VERSION_1_8 13 | } 14 | 15 | tasks.withType(JavaCompile) { 16 | options.encoding = 'UTF-8' 17 | options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' 18 | } 19 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/client/InputTracking.java: -------------------------------------------------------------------------------- 1 | package jagex2.client; 2 | 3 | import jagex2.io.Packet; 4 | import org.openrs2.deob.annotation.OriginalArg; 5 | import org.openrs2.deob.annotation.OriginalClass; 6 | import org.openrs2.deob.annotation.OriginalMember; 7 | import org.openrs2.deob.annotation.Pc; 8 | 9 | @OriginalClass("client!e") 10 | public class InputTracking { 11 | 12 | @OriginalMember(owner = "client!e", name = "e", descriptor = "Z") 13 | public static boolean enabled; 14 | 15 | @OriginalMember(owner = "client!e", name = "f", descriptor = "Lclient!kb;") 16 | private static Packet outBuffer = null; 17 | 18 | @OriginalMember(owner = "client!e", name = "g", descriptor = "Lclient!kb;") 19 | private static Packet oldBuffer = null; 20 | 21 | @OriginalMember(owner = "client!e", name = "h", descriptor = "J") 22 | private static long lastTime; 23 | 24 | @OriginalMember(owner = "client!e", name = "i", descriptor = "I") 25 | private static int trackedCount; 26 | 27 | @OriginalMember(owner = "client!e", name = "j", descriptor = "J") 28 | private static long lastMoveTime; 29 | 30 | @OriginalMember(owner = "client!e", name = "k", descriptor = "I") 31 | private static int lastX; 32 | 33 | @OriginalMember(owner = "client!e", name = "l", descriptor = "I") 34 | private static int lastY; 35 | 36 | @OriginalMember(owner = "client!e", name = "a", descriptor = "(I)V") 37 | public static synchronized void setEnabled() { 38 | outBuffer = Packet.alloc(1); 39 | oldBuffer = null; 40 | lastTime = System.currentTimeMillis(); 41 | enabled = true; 42 | } 43 | 44 | @OriginalMember(owner = "client!e", name = "a", descriptor = "(B)V") 45 | public static synchronized void setDisabled() { 46 | enabled = false; 47 | outBuffer = null; 48 | } 49 | 50 | @OriginalMember(owner = "client!e", name = "b", descriptor = "(I)Lclient!kb;") 51 | public static synchronized Packet flush() { 52 | @Pc(1) Packet buffer = null; 53 | if (oldBuffer != null && enabled) { 54 | buffer = oldBuffer; 55 | } 56 | oldBuffer = null; 57 | return buffer; 58 | } 59 | 60 | @OriginalMember(owner = "client!e", name = "c", descriptor = "(I)Lclient!kb;") 61 | public static synchronized Packet stop() { 62 | @Pc(9) Packet buffer = null; 63 | if (outBuffer != null && outBuffer.pos > 0 && enabled) { 64 | buffer = outBuffer; 65 | } 66 | setDisabled(); 67 | return buffer; 68 | } 69 | 70 | @OriginalMember(owner = "client!e", name = "a", descriptor = "(II)V") 71 | private static synchronized void ensureCapacity(@OriginalArg(1) int n) { 72 | if (outBuffer.pos + n >= 500) { 73 | @Pc(15) Packet buffer = outBuffer; 74 | outBuffer = Packet.alloc(1); 75 | oldBuffer = buffer; 76 | } 77 | } 78 | 79 | @OriginalMember(owner = "client!e", name = "a", descriptor = "(IIIB)V") 80 | public static synchronized void mousePressed(@OriginalArg(0) int x, @OriginalArg(2) int y, @OriginalArg(1) int button) { 81 | if (enabled && (x >= 0 && x < 789 && y >= 0 && y < 532)) { 82 | trackedCount++; 83 | 84 | @Pc(19) long now = System.currentTimeMillis(); 85 | @Pc(25) long delta = (now - lastTime) / 10L; 86 | if (delta > 250L) { 87 | delta = 250L; 88 | } 89 | 90 | lastTime = now; 91 | ensureCapacity(5); 92 | 93 | if (button == 1) { 94 | outBuffer.p1(1); 95 | } else { 96 | outBuffer.p1(2); 97 | } 98 | 99 | outBuffer.p1((int) delta); 100 | outBuffer.p3(x + (y << 10)); 101 | } 102 | } 103 | 104 | @OriginalMember(owner = "client!e", name = "b", descriptor = "(II)V") 105 | public static synchronized void mouseReleased(@OriginalArg(0) int button) { 106 | if (enabled) { 107 | trackedCount++; 108 | 109 | @Pc(8) long now = System.currentTimeMillis(); 110 | @Pc(14) long delta = (now - lastTime) / 10L; 111 | if (delta > 250L) { 112 | delta = 250L; 113 | } 114 | 115 | lastTime = now; 116 | ensureCapacity(2); 117 | 118 | if (button == 1) { 119 | outBuffer.p1(3); 120 | } else { 121 | outBuffer.p1(4); 122 | } 123 | 124 | outBuffer.p1((int) delta); 125 | } 126 | } 127 | 128 | @OriginalMember(owner = "client!e", name = "a", descriptor = "(IZI)V") 129 | public static synchronized void mouseMoved(@OriginalArg(2) int x, @OriginalArg(0) int y) { 130 | if (enabled && (x >= 0 && x < 789 && y >= 0 && y < 532)) { 131 | @Pc(17) long now = System.currentTimeMillis(); 132 | 133 | if (now - lastMoveTime >= 50L) { 134 | lastMoveTime = now; 135 | trackedCount++; 136 | 137 | @Pc(39) long delta = (now - lastTime) / 10L; 138 | if (delta > 250L) { 139 | delta = 250L; 140 | } 141 | 142 | lastTime = now; 143 | if (x - lastX < 8 && x - lastX >= -8 && y - lastY < 8 && y - lastY >= -8) { 144 | ensureCapacity(3); 145 | outBuffer.p1(5); 146 | outBuffer.p1((int) delta); 147 | outBuffer.p1(x + (y - lastY + 8 << 4) + 8 - lastX); 148 | } else if (x - lastX < 128 && x - lastX >= -128 && y - lastY < 128 && y - lastY >= -128) { 149 | ensureCapacity(4); 150 | outBuffer.p1(6); 151 | outBuffer.p1((int) delta); 152 | outBuffer.p1(x + 128 - lastX); 153 | outBuffer.p1(y + 128 - lastY); 154 | } else { 155 | ensureCapacity(5); 156 | outBuffer.p1(7); 157 | outBuffer.p1((int) delta); 158 | outBuffer.p3(x + (y << 10)); 159 | } 160 | 161 | lastX = x; 162 | lastY = y; 163 | } 164 | } 165 | } 166 | 167 | @OriginalMember(owner = "client!e", name = "a", descriptor = "(IZ)V") 168 | public static synchronized void keyPressed(@OriginalArg(0) int key) { 169 | if (enabled) { 170 | trackedCount++; 171 | 172 | @Pc(8) long now = System.currentTimeMillis(); 173 | @Pc(14) long delta = (now - lastTime) / 10L; 174 | if (delta > 250L) { 175 | delta = 250L; 176 | } 177 | 178 | lastTime = now; 179 | if (key == 1000) { 180 | key = 11; 181 | } else if (key == 1001) { 182 | key = 12; 183 | } else if (key == 1002) { 184 | key = 14; 185 | } else if (key == 1003) { 186 | key = 15; 187 | } else if (key >= 1008) { 188 | key -= 992; 189 | } 190 | 191 | ensureCapacity(3); 192 | outBuffer.p1(8); 193 | outBuffer.p1((int) delta); 194 | outBuffer.p1(key); 195 | } 196 | } 197 | 198 | @OriginalMember(owner = "client!e", name = "c", descriptor = "(II)V") 199 | public static synchronized void keyReleased(@OriginalArg(0) int key) { 200 | if (enabled) { 201 | trackedCount++; 202 | 203 | @Pc(8) long now = System.currentTimeMillis(); 204 | @Pc(14) long delta = (now - lastTime) / 10L; 205 | if (delta > 250L) { 206 | delta = 250L; 207 | } 208 | 209 | lastTime = now; 210 | if (key == 1000) { 211 | key = 11; 212 | } else if (key == 1001) { 213 | key = 12; 214 | } else if (key == 1002) { 215 | key = 14; 216 | } else if (key == 1003) { 217 | key = 15; 218 | } else if (key >= 1008) { 219 | key -= 992; 220 | } 221 | 222 | ensureCapacity(3); 223 | outBuffer.p1(9); 224 | outBuffer.p1((int) delta); 225 | outBuffer.p1(key); 226 | } 227 | } 228 | 229 | @OriginalMember(owner = "client!e", name = "d", descriptor = "(I)V") 230 | public static synchronized void focusGained() { 231 | if (enabled) { 232 | trackedCount++; 233 | 234 | @Pc(11) long now = System.currentTimeMillis(); 235 | @Pc(17) long delta = (now - lastTime) / 10L; 236 | if (delta > 250L) { 237 | delta = 250L; 238 | } 239 | 240 | lastTime = now; 241 | ensureCapacity(2); 242 | outBuffer.p1(10); 243 | outBuffer.p1((int) delta); 244 | } 245 | } 246 | 247 | @OriginalMember(owner = "client!e", name = "e", descriptor = "(I)V") 248 | public static synchronized void focusLost() { 249 | if (enabled) { 250 | trackedCount++; 251 | 252 | @Pc(8) long now = System.currentTimeMillis(); 253 | @Pc(14) long delta = (now - lastTime) / 10L; 254 | if (delta > 250L) { 255 | delta = 250L; 256 | } 257 | 258 | lastTime = now; 259 | ensureCapacity(2); 260 | outBuffer.p1(11); 261 | outBuffer.p1((int) delta); 262 | } 263 | } 264 | 265 | @OriginalMember(owner = "client!e", name = "f", descriptor = "(I)V") 266 | public static synchronized void mouseEntered() { 267 | if (enabled) { 268 | trackedCount++; 269 | 270 | @Pc(8) long now = System.currentTimeMillis(); 271 | @Pc(14) long delta = (now - lastTime) / 10L; 272 | if (delta > 250L) { 273 | delta = 250L; 274 | } 275 | 276 | lastTime = now; 277 | ensureCapacity(2); 278 | outBuffer.p1(12); 279 | outBuffer.p1((int) delta); 280 | } 281 | } 282 | 283 | @OriginalMember(owner = "client!e", name = "a", descriptor = "(Z)V") 284 | public static synchronized void mouseExited() { 285 | if (enabled) { 286 | trackedCount++; 287 | 288 | @Pc(11) long now = System.currentTimeMillis(); 289 | @Pc(17) long delta = (now - lastTime) / 10L; 290 | if (delta > 250L) { 291 | delta = 250L; 292 | } 293 | 294 | lastTime = now; 295 | ensureCapacity(2); 296 | outBuffer.p1(13); 297 | outBuffer.p1((int) delta); 298 | } 299 | } 300 | } 301 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/client/ViewBox.java: -------------------------------------------------------------------------------- 1 | package jagex2.client; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | import java.awt.*; 9 | 10 | // name taken from rsc 11 | @OriginalClass("client!b") 12 | public class ViewBox extends Frame { 13 | 14 | @OriginalMember(owner = "client!b", name = "b", descriptor = "Lclient!a;") 15 | private final GameShell shell; 16 | 17 | public Insets insets; 18 | 19 | @OriginalMember(owner = "client!b", name = "", descriptor = "(IILclient!a;I)V") 20 | public ViewBox(@OriginalArg(2) GameShell shell, @OriginalArg(3) int width, @OriginalArg(0) int height) { 21 | this.shell = shell; 22 | this.setTitle("Jagex"); 23 | this.setResizable(false); 24 | this.show(); 25 | this.toFront(); 26 | this.insets = this.getInsets(); 27 | this.resize(width + this.insets.left + this.insets.bottom, height + this.insets.top + this.insets.bottom); 28 | } 29 | 30 | @OriginalMember(owner = "client!b", name = "getGraphics", descriptor = "()Ljava/awt/Graphics;") 31 | @Override 32 | public Graphics getGraphics() { 33 | @Pc(2) Graphics g = super.getGraphics(); 34 | if (this.insets != null) { 35 | g.translate(this.insets.left, this.insets.top); 36 | } 37 | return g; 38 | } 39 | 40 | @OriginalMember(owner = "client!b", name = "update", descriptor = "(Ljava/awt/Graphics;)V") 41 | @Override 42 | public void update(@OriginalArg(0) Graphics g) { 43 | this.shell.update(g); 44 | } 45 | 46 | @OriginalMember(owner = "client!b", name = "paint", descriptor = "(Ljava/awt/Graphics;)V") 47 | @Override 48 | public void paint(@OriginalArg(0) Graphics g) { 49 | this.shell.paint(g); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/config/FloType.java: -------------------------------------------------------------------------------- 1 | package jagex2.config; 2 | 3 | import jagex2.io.Jagfile; 4 | import jagex2.io.Packet; 5 | import org.openrs2.deob.annotation.OriginalArg; 6 | import org.openrs2.deob.annotation.OriginalClass; 7 | import org.openrs2.deob.annotation.OriginalMember; 8 | import org.openrs2.deob.annotation.Pc; 9 | 10 | // name taken from rs3 11 | @OriginalClass("client!fc") 12 | public class FloType { 13 | 14 | @OriginalMember(owner = "client!fc", name = "c", descriptor = "I") 15 | public static int count; 16 | 17 | @OriginalMember(owner = "client!fc", name = "d", descriptor = "[Lclient!fc;") 18 | public static FloType[] instances; 19 | 20 | @OriginalMember(owner = "client!fc", name = "e", descriptor = "I") 21 | public int rgb; 22 | 23 | @OriginalMember(owner = "client!fc", name = "f", descriptor = "I") 24 | public int texture = -1; 25 | 26 | @OriginalMember(owner = "client!fc", name = "g", descriptor = "Z") 27 | private boolean overlay = false; 28 | 29 | @OriginalMember(owner = "client!fc", name = "h", descriptor = "Z") 30 | public boolean occlude = true; 31 | 32 | @OriginalMember(owner = "client!fc", name = "i", descriptor = "Ljava/lang/String;") 33 | public String name; 34 | 35 | @OriginalMember(owner = "client!fc", name = "j", descriptor = "I") 36 | public int hue; 37 | 38 | @OriginalMember(owner = "client!fc", name = "k", descriptor = "I") 39 | public int saturation; 40 | 41 | @OriginalMember(owner = "client!fc", name = "l", descriptor = "I") 42 | public int lightness; 43 | 44 | @OriginalMember(owner = "client!fc", name = "m", descriptor = "I") 45 | public int chroma; 46 | 47 | @OriginalMember(owner = "client!fc", name = "n", descriptor = "I") 48 | public int luminance; 49 | 50 | @OriginalMember(owner = "client!fc", name = "o", descriptor = "I") 51 | public int hsl; 52 | 53 | @OriginalMember(owner = "client!fc", name = "a", descriptor = "(Lclient!ub;I)V") 54 | public static void unpack(@OriginalArg(0) Jagfile config) { 55 | @Pc(9) Packet dat = new Packet(config.read("flo.dat", null)); 56 | count = dat.g2(); 57 | 58 | if (instances == null) { 59 | instances = new FloType[count]; 60 | } 61 | 62 | for (@Pc(23) int id = 0; id < count; id++) { 63 | if (instances[id] == null) { 64 | instances[id] = new FloType(); 65 | } 66 | 67 | instances[id].decode(dat); 68 | } 69 | } 70 | 71 | @OriginalMember(owner = "client!fc", name = "a", descriptor = "(ZLclient!kb;)V") 72 | public void decode(@OriginalArg(1) Packet dat) { 73 | while (true) { 74 | @Pc(10) int code = dat.g1(); 75 | if (code == 0) { 76 | return; 77 | } 78 | 79 | if (code == 1) { 80 | this.rgb = dat.g3(); 81 | this.setColor(this.rgb); 82 | } else if (code == 2) { 83 | this.texture = dat.g1(); 84 | } else if (code == 3) { 85 | this.overlay = true; 86 | } else if (code == 5) { 87 | this.occlude = false; 88 | } else if (code == 6) { 89 | this.name = dat.gjstr(); 90 | } else { 91 | System.out.println("Error unrecognised flo config code: " + code); 92 | } 93 | } 94 | } 95 | 96 | @OriginalMember(owner = "client!fc", name = "a", descriptor = "(II)V") 97 | private void setColor(@OriginalArg(1) int rgb) { 98 | @Pc(10) double red = (double) (rgb >> 16 & 0xFF) / 256.0D; 99 | @Pc(28) double green = (double) (rgb >> 8 & 0xFF) / 256.0D; 100 | @Pc(35) double blue = (double) (rgb & 0xFF) / 256.0D; 101 | 102 | @Pc(37) double min = red; 103 | if (green < red) { 104 | min = green; 105 | } 106 | if (blue < min) { 107 | min = blue; 108 | } 109 | 110 | @Pc(51) double max = red; 111 | if (green > red) { 112 | max = green; 113 | } 114 | if (blue > max) { 115 | max = blue; 116 | } 117 | 118 | @Pc(65) double h = 0.0D; 119 | @Pc(67) double s = 0.0D; 120 | @Pc(73) double l = (min + max) / 2.0D; 121 | 122 | if (min != max) { 123 | if (l < 0.5D) { 124 | s = (max - min) / (max + min); 125 | } 126 | if (l >= 0.5D) { 127 | s = (max - min) / (2.0D - max - min); 128 | } 129 | 130 | if (red == max) { 131 | h = (green - blue) / (max - min); 132 | } else if (green == max) { 133 | h = (blue - red) / (max - min) + 2.0D; 134 | } else if (blue == max) { 135 | h = (red - green) / (max - min) + 4.0D; 136 | } 137 | } 138 | 139 | h /= 6.0D; 140 | 141 | this.hue = (int) (h * 256.0D); 142 | this.saturation = (int) (s * 256.0D); 143 | this.lightness = (int) (l * 256.0D); 144 | 145 | if (this.saturation < 0) { 146 | this.saturation = 0; 147 | } else if (this.saturation > 255) { 148 | this.saturation = 255; 149 | } 150 | 151 | if (this.lightness < 0) { 152 | this.lightness = 0; 153 | } else if (this.lightness > 255) { 154 | this.lightness = 255; 155 | } 156 | 157 | if (l > 0.5D) { 158 | this.luminance = (int) ((1.0D - l) * s * 512.0D); 159 | } else { 160 | this.luminance = (int) (l * s * 512.0D); 161 | } 162 | 163 | if (this.luminance < 1) { 164 | this.luminance = 1; 165 | } 166 | 167 | this.chroma = (int) (h * (double) this.luminance); 168 | 169 | @Pc(248) int hue = this.hue + (int) (Math.random() * 16.0D) - 8; 170 | if (hue < 0) { 171 | hue = 0; 172 | } else if (hue > 255) { 173 | hue = 255; 174 | } 175 | 176 | @Pc(269) int saturation = this.saturation + (int) (Math.random() * 48.0D) - 24; 177 | if (saturation < 0) { 178 | saturation = 0; 179 | } else if (saturation > 255) { 180 | saturation = 255; 181 | } 182 | 183 | @Pc(290) int lightness = this.lightness + (int) (Math.random() * 48.0D) - 24; 184 | if (lightness < 0) { 185 | lightness = 0; 186 | } else if (lightness > 255) { 187 | lightness = 255; 188 | } 189 | 190 | this.hsl = this.hsl24to16(hue, saturation, lightness); 191 | } 192 | 193 | @OriginalMember(owner = "client!fc", name = "a", descriptor = "(III)I") 194 | private int hsl24to16(@OriginalArg(0) int hue, @OriginalArg(1) int saturation, @OriginalArg(2) int lightness) { 195 | if (lightness > 179) { 196 | saturation /= 2; 197 | } 198 | 199 | if (lightness > 192) { 200 | saturation /= 2; 201 | } 202 | 203 | if (lightness > 217) { 204 | saturation /= 2; 205 | } 206 | 207 | if (lightness > 243) { 208 | saturation /= 2; 209 | } 210 | 211 | return (hue / 4 << 10) + (saturation / 32 << 7) + lightness / 2; 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/config/IdkType.java: -------------------------------------------------------------------------------- 1 | package jagex2.config; 2 | 3 | import jagex2.graphics.Model; 4 | import jagex2.io.Jagfile; 5 | import jagex2.io.Packet; 6 | import org.openrs2.deob.annotation.OriginalArg; 7 | import org.openrs2.deob.annotation.OriginalClass; 8 | import org.openrs2.deob.annotation.OriginalMember; 9 | import org.openrs2.deob.annotation.Pc; 10 | 11 | // name taken from rs3 12 | @OriginalClass("client!gc") 13 | public class IdkType { 14 | 15 | @OriginalMember(owner = "client!gc", name = "d", descriptor = "I") 16 | public static int count; 17 | 18 | @OriginalMember(owner = "client!gc", name = "e", descriptor = "[Lclient!gc;") 19 | public static IdkType[] instances; 20 | 21 | @OriginalMember(owner = "client!gc", name = "f", descriptor = "I") 22 | public int type = -1; 23 | 24 | @OriginalMember(owner = "client!gc", name = "g", descriptor = "[I") 25 | private int[] models; 26 | 27 | @OriginalMember(owner = "client!gc", name = "h", descriptor = "[I") 28 | private final int[] recol_s = new int[6]; 29 | 30 | @OriginalMember(owner = "client!gc", name = "i", descriptor = "[I") 31 | private final int[] recol_d = new int[6]; 32 | 33 | @OriginalMember(owner = "client!gc", name = "j", descriptor = "[I") 34 | private final int[] heads = new int[] { -1, -1, -1, -1, -1 }; 35 | 36 | @OriginalMember(owner = "client!gc", name = "k", descriptor = "Z") 37 | public boolean disable = false; 38 | 39 | @OriginalMember(owner = "client!gc", name = "a", descriptor = "(Lclient!ub;I)V") 40 | public static void unpack(@OriginalArg(0) Jagfile config) { 41 | @Pc(9) Packet dat = new Packet(config.read("idk.dat", null)); 42 | count = dat.g2(); 43 | 44 | if (instances == null) { 45 | instances = new IdkType[count]; 46 | } 47 | 48 | for (@Pc(19) int id = 0; id < count; id++) { 49 | if (instances[id] == null) { 50 | instances[id] = new IdkType(); 51 | } 52 | 53 | instances[id].decode(dat); 54 | } 55 | } 56 | 57 | @OriginalMember(owner = "client!gc", name = "a", descriptor = "(ZLclient!kb;)V") 58 | public void decode(@OriginalArg(1) Packet dat) { 59 | while (true) { 60 | @Pc(8) int code = dat.g1(); 61 | if (code == 0) { 62 | break; 63 | } 64 | 65 | if (code == 1) { 66 | this.type = dat.g1(); 67 | } else if (code == 2) { 68 | @Pc(26) int count = dat.g1(); 69 | this.models = new int[count]; 70 | 71 | for (@Pc(32) int i = 0; i < count; i++) { 72 | this.models[i] = dat.g2(); 73 | } 74 | } else if (code == 3) { 75 | this.disable = true; 76 | } else if (code >= 40 && code < 50) { 77 | this.recol_s[code - 40] = dat.g2(); 78 | } else if (code >= 50 && code < 60) { 79 | this.recol_d[code - 50] = dat.g2(); 80 | } else if (code >= 60 && code < 70) { 81 | this.heads[code - 60] = dat.g2(); 82 | } else { 83 | System.out.println("Error unrecognised idk config code: " + code); 84 | } 85 | } 86 | } 87 | 88 | @OriginalMember(owner = "client!gc", name = "a", descriptor = "()Lclient!eb;") 89 | public Model getModel() { 90 | if (this.models == null) { 91 | return null; 92 | } 93 | 94 | @Pc(11) Model[] models = new Model[this.models.length]; 95 | for (@Pc(13) int i = 0; i < this.models.length; i++) { 96 | models[i] = new Model(this.models[i]); 97 | } 98 | 99 | @Pc(40) Model model; 100 | if (models.length == 1) { 101 | model = models[0]; 102 | } else { 103 | model = new Model(models, models.length); 104 | } 105 | 106 | for (@Pc(52) int i = 0; i < 6 && this.recol_s[i] != 0; i++) { 107 | model.recolor(this.recol_s[i], this.recol_d[i]); 108 | } 109 | 110 | return model; 111 | } 112 | 113 | @OriginalMember(owner = "client!gc", name = "a", descriptor = "(Z)Lclient!eb;") 114 | public Model getHeadModel() { 115 | @Pc(4) Model[] models = new Model[5]; 116 | 117 | @Pc(6) int count = 0; 118 | for (@Pc(8) int i = 0; i < 5; i++) { 119 | if (this.heads[i] != -1) { 120 | models[count++] = new Model(this.heads[i]); 121 | } 122 | } 123 | 124 | @Pc(39) Model model = new Model(models, count); 125 | for (@Pc(41) int i = 0; i < 6 && this.recol_s[i] != 0; i++) { 126 | model.recolor(this.recol_s[i], this.recol_d[i]); 127 | } 128 | 129 | return model; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/config/NpcType.java: -------------------------------------------------------------------------------- 1 | package jagex2.config; 2 | 3 | import jagex2.datastruct.LruCache; 4 | import jagex2.graphics.Model; 5 | import jagex2.io.Jagfile; 6 | import jagex2.io.Packet; 7 | import org.openrs2.deob.annotation.OriginalArg; 8 | import org.openrs2.deob.annotation.OriginalClass; 9 | import org.openrs2.deob.annotation.OriginalMember; 10 | import org.openrs2.deob.annotation.Pc; 11 | 12 | // name taken from rs3 13 | @OriginalClass("client!bc") 14 | public class NpcType { 15 | 16 | @OriginalMember(owner = "client!bc", name = "b", descriptor = "I") 17 | private static int count; 18 | 19 | @OriginalMember(owner = "client!bc", name = "c", descriptor = "[I") 20 | private static int[] offsets; 21 | 22 | @OriginalMember(owner = "client!bc", name = "d", descriptor = "Lclient!kb;") 23 | private static Packet dat; 24 | 25 | @OriginalMember(owner = "client!bc", name = "e", descriptor = "[Lclient!bc;") 26 | private static NpcType[] cache; 27 | 28 | @OriginalMember(owner = "client!bc", name = "f", descriptor = "I") 29 | private static int cachePos; 30 | 31 | @OriginalMember(owner = "client!bc", name = "g", descriptor = "J") 32 | public long index = -1L; 33 | 34 | @OriginalMember(owner = "client!bc", name = "h", descriptor = "Ljava/lang/String;") 35 | public String name; 36 | 37 | @OriginalMember(owner = "client!bc", name = "i", descriptor = "[B") 38 | public String desc; 39 | 40 | @OriginalMember(owner = "client!bc", name = "j", descriptor = "B") 41 | public byte size = 1; 42 | 43 | @OriginalMember(owner = "client!bc", name = "k", descriptor = "[I") 44 | private int[] models; 45 | 46 | @OriginalMember(owner = "client!bc", name = "l", descriptor = "[I") 47 | private int[] heads; 48 | 49 | @OriginalMember(owner = "client!bc", name = "m", descriptor = "I") 50 | public int readyanim = -1; 51 | 52 | @OriginalMember(owner = "client!bc", name = "n", descriptor = "I") 53 | public int walkanim = -1; 54 | 55 | @OriginalMember(owner = "client!bc", name = "o", descriptor = "I") 56 | public int walkanim_b = -1; 57 | 58 | @OriginalMember(owner = "client!bc", name = "p", descriptor = "I") 59 | public int walkanim_r = -1; 60 | 61 | @OriginalMember(owner = "client!bc", name = "q", descriptor = "I") 62 | public int walkanim_l = -1; 63 | 64 | @OriginalMember(owner = "client!bc", name = "r", descriptor = "Z") 65 | private boolean animHasAlpha = false; 66 | 67 | @OriginalMember(owner = "client!bc", name = "s", descriptor = "[I") 68 | private int[] recol_s; 69 | 70 | @OriginalMember(owner = "client!bc", name = "t", descriptor = "[I") 71 | private int[] recol_d; 72 | 73 | @OriginalMember(owner = "client!bc", name = "u", descriptor = "[Ljava/lang/String;") 74 | public String[] op; 75 | 76 | @OriginalMember(owner = "client!bc", name = "v", descriptor = "I") 77 | private int resizex = -1; 78 | 79 | @OriginalMember(owner = "client!bc", name = "w", descriptor = "I") 80 | private int resizey = -1; 81 | 82 | @OriginalMember(owner = "client!bc", name = "x", descriptor = "I") 83 | private int resizez = -1; 84 | 85 | @OriginalMember(owner = "client!bc", name = "y", descriptor = "Z") 86 | public boolean minimap = true; 87 | 88 | @OriginalMember(owner = "client!bc", name = "z", descriptor = "I") 89 | public int vislevel = -1; 90 | 91 | @OriginalMember(owner = "client!bc", name = "A", descriptor = "I") 92 | private int resizeh = 128; 93 | 94 | @OriginalMember(owner = "client!bc", name = "B", descriptor = "I") 95 | private int resizev = 128; 96 | 97 | @OriginalMember(owner = "client!bc", name = "C", descriptor = "Lclient!s;") 98 | public static LruCache modelCache = new LruCache(30); 99 | 100 | @OriginalMember(owner = "client!bc", name = "a", descriptor = "(Lclient!ub;)V") 101 | public static void unpack(@OriginalArg(0) Jagfile config) { 102 | dat = new Packet(config.read("npc.dat", null)); 103 | @Pc(21) Packet idx = new Packet(config.read("npc.idx", null)); 104 | 105 | count = idx.g2(); 106 | offsets = new int[count]; 107 | 108 | @Pc(29) int offset = 2; 109 | for (@Pc(31) int id = 0; id < count; id++) { 110 | offsets[id] = offset; 111 | offset += idx.g2(); 112 | } 113 | 114 | cache = new NpcType[20]; 115 | for (@Pc(51) int id = 0; id < 20; id++) { 116 | cache[id] = new NpcType(); 117 | } 118 | } 119 | 120 | @OriginalMember(owner = "client!bc", name = "a", descriptor = "(Z)V") 121 | public static void unload() { 122 | modelCache = null; 123 | offsets = null; 124 | cache = null; 125 | dat = null; 126 | } 127 | 128 | @OriginalMember(owner = "client!bc", name = "a", descriptor = "(I)Lclient!bc;") 129 | public static NpcType get(@OriginalArg(0) int id) { 130 | for (@Pc(1) int i = 0; i < 20; i++) { 131 | if (cache[i].index == (long) id) { 132 | return cache[i]; 133 | } 134 | } 135 | 136 | cachePos = (cachePos + 1) % 20; 137 | @Pc(33) NpcType npc = cache[cachePos] = new NpcType(); 138 | dat.pos = offsets[id]; 139 | npc.index = id; 140 | npc.decode(dat); 141 | return npc; 142 | } 143 | 144 | @OriginalMember(owner = "client!bc", name = "a", descriptor = "(ZLclient!kb;)V") 145 | public void decode(@OriginalArg(1) Packet dat) { 146 | while (true) { 147 | @Pc(10) int code = dat.g1(); 148 | if (code == 0) { 149 | return; 150 | } 151 | 152 | if (code == 1) { 153 | int count = dat.g1(); 154 | this.models = new int[count]; 155 | 156 | for (int i = 0; i < count; i++) { 157 | this.models[i] = dat.g2(); 158 | } 159 | } else if (code == 2) { 160 | this.name = dat.gjstr(); 161 | } else if (code == 3) { 162 | this.desc = dat.gjstr(); 163 | } else if (code == 12) { 164 | this.size = dat.g1b(); 165 | } else if (code == 13) { 166 | this.readyanim = dat.g2(); 167 | } else if (code == 14) { 168 | this.walkanim = dat.g2(); 169 | } else if (code == 16) { 170 | this.animHasAlpha = true; 171 | } else if (code == 17) { 172 | this.walkanim = dat.g2(); 173 | this.walkanim_b = dat.g2(); 174 | this.walkanim_r = dat.g2(); 175 | this.walkanim_l = dat.g2(); 176 | } else if (code >= 30 && code < 40) { 177 | if (this.op == null) { 178 | this.op = new String[5]; 179 | } 180 | 181 | this.op[code - 30] = dat.gjstr(); 182 | if (this.op[code - 30].equalsIgnoreCase("hidden")) { 183 | this.op[code - 30] = null; 184 | } 185 | } else if (code == 40) { 186 | int count = dat.g1(); 187 | this.recol_s = new int[count]; 188 | this.recol_d = new int[count]; 189 | 190 | for (int i = 0; i < count; i++) { 191 | this.recol_s[i] = dat.g2(); 192 | this.recol_d[i] = dat.g2(); 193 | } 194 | } else if (code == 60) { 195 | int count = dat.g1(); 196 | this.heads = new int[count]; 197 | 198 | for (int i = 0; i < count; i++) { 199 | this.heads[i] = dat.g2(); 200 | } 201 | } else if (code == 90) { 202 | // unused 203 | this.resizex = dat.g2(); 204 | } else if (code == 91) { 205 | // unused 206 | this.resizey = dat.g2(); 207 | } else if (code == 92) { 208 | // unused 209 | this.resizez = dat.g2(); 210 | } else if (code == 93) { 211 | this.minimap = false; 212 | } else if (code == 95) { 213 | this.vislevel = dat.g2(); 214 | } else if (code == 97) { 215 | this.resizeh = dat.g2(); 216 | } else if (code == 98) { 217 | this.resizev = dat.g2(); 218 | } else { 219 | System.out.println("Error unrecognised npc config code: " + code); 220 | } 221 | } 222 | } 223 | 224 | @OriginalMember(owner = "client!bc", name = "a", descriptor = "(II[I)Lclient!eb;") 225 | public Model getSequencedModel(@OriginalArg(0) int primaryTransformId, @OriginalArg(1) int secondaryTransformId, @OriginalArg(2) int[] seqMask) { 226 | @Pc(3) Model tmp = null; 227 | @Pc(9) Model model = (Model) modelCache.get(this.index); 228 | 229 | if (model == null) { 230 | @Pc(16) Model[] models = new Model[this.models.length]; 231 | for (@Pc(18) int i = 0; i < this.models.length; i++) { 232 | models[i] = new Model(this.models[i]); 233 | } 234 | 235 | if (models.length == 1) { 236 | model = models[0]; 237 | } else { 238 | model = new Model(models, models.length); 239 | } 240 | 241 | if (this.recol_s != null) { 242 | for (@Pc(60) int i = 0; i < this.recol_s.length; i++) { 243 | model.recolor(this.recol_s[i], this.recol_d[i]); 244 | } 245 | } 246 | 247 | model.createLabelReferences(); 248 | model.calculateNormals(64, 850, -30, -50, -30, true); 249 | modelCache.put(this.index, model); 250 | } 251 | 252 | tmp = new Model(model, !this.animHasAlpha); 253 | 254 | if (primaryTransformId != -1 && secondaryTransformId != -1) { 255 | tmp.applyTransforms(primaryTransformId, secondaryTransformId, seqMask); 256 | } else if (primaryTransformId != -1) { 257 | tmp.applyTransform(primaryTransformId); 258 | } 259 | 260 | if (this.resizeh != 128 || this.resizev != 128) { 261 | tmp.scale(this.resizeh, this.resizev, this.resizeh); 262 | } 263 | 264 | tmp.calculateBoundsCylinder(); 265 | tmp.labelFaces = null; 266 | tmp.labelVertices = null; 267 | 268 | if (this.size == 1) { 269 | tmp.pickable = true; 270 | } 271 | 272 | return tmp; 273 | } 274 | 275 | @OriginalMember(owner = "client!bc", name = "b", descriptor = "(Z)Lclient!eb;") 276 | public Model getHeadModel() { 277 | if (this.heads == null) { 278 | return null; 279 | } 280 | 281 | @Pc(17) Model[] models = new Model[this.heads.length]; 282 | for (@Pc(19) int i = 0; i < this.heads.length; i++) { 283 | models[i] = new Model(this.heads[i]); 284 | } 285 | 286 | @Pc(46) Model model; 287 | if (models.length == 1) { 288 | model = models[0]; 289 | } else { 290 | model = new Model(models, models.length); 291 | } 292 | 293 | if (this.recol_s != null) { 294 | for (@Pc(61) int i = 0; i < this.recol_s.length; i++) { 295 | model.recolor(this.recol_s[i], this.recol_d[i]); 296 | } 297 | } 298 | 299 | return model; 300 | } 301 | } 302 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/config/SeqType.java: -------------------------------------------------------------------------------- 1 | package jagex2.config; 2 | 3 | import jagex2.graphics.AnimFrame; 4 | import jagex2.io.Jagfile; 5 | import jagex2.io.Packet; 6 | import org.openrs2.deob.annotation.OriginalArg; 7 | import org.openrs2.deob.annotation.OriginalClass; 8 | import org.openrs2.deob.annotation.OriginalMember; 9 | import org.openrs2.deob.annotation.Pc; 10 | 11 | // name taken from rs3 12 | @OriginalClass("client!jc") 13 | public class SeqType { 14 | 15 | @OriginalMember(owner = "client!jc", name = "c", descriptor = "I") 16 | private static int count; 17 | 18 | @OriginalMember(owner = "client!jc", name = "d", descriptor = "[Lclient!jc;") 19 | public static SeqType[] instances; 20 | 21 | @OriginalMember(owner = "client!jc", name = "e", descriptor = "I") 22 | public int frameCount; 23 | 24 | @OriginalMember(owner = "client!jc", name = "f", descriptor = "[I") 25 | public int[] frames; 26 | 27 | @OriginalMember(owner = "client!jc", name = "g", descriptor = "[I") 28 | public int[] iframes; 29 | 30 | @OriginalMember(owner = "client!jc", name = "h", descriptor = "[I") 31 | public int[] delay; 32 | 33 | @OriginalMember(owner = "client!jc", name = "i", descriptor = "I") 34 | public int replayoff = -1; 35 | 36 | @OriginalMember(owner = "client!jc", name = "j", descriptor = "[I") 37 | public int[] walkmerge; 38 | 39 | @OriginalMember(owner = "client!jc", name = "k", descriptor = "Z") 40 | public boolean stretches = false; 41 | 42 | @OriginalMember(owner = "client!jc", name = "l", descriptor = "I") 43 | public int priority = 5; 44 | 45 | @OriginalMember(owner = "client!jc", name = "m", descriptor = "I") 46 | public int righthand = -1; 47 | 48 | @OriginalMember(owner = "client!jc", name = "n", descriptor = "I") 49 | public int lefthand = -1; 50 | 51 | @OriginalMember(owner = "client!jc", name = "o", descriptor = "I") 52 | public int replaycount = 99; 53 | 54 | @OriginalMember(owner = "client!jc", name = "a", descriptor = "(Lclient!ub;I)V") 55 | public static void unpack(@OriginalArg(0) Jagfile config) { 56 | @Pc(9) Packet dat = new Packet(config.read("seq.dat", null)); 57 | count = dat.g2(); 58 | 59 | if (instances == null) { 60 | instances = new SeqType[count]; 61 | } 62 | 63 | for (@Pc(27) int id = 0; id < count; id++) { 64 | if (instances[id] == null) { 65 | instances[id] = new SeqType(); 66 | } 67 | 68 | instances[id].decode(dat); 69 | } 70 | } 71 | 72 | @OriginalMember(owner = "client!jc", name = "a", descriptor = "(ZLclient!kb;)V") 73 | public void decode(@OriginalArg(1) Packet dat) { 74 | while (true) { 75 | @Pc(5) int code = dat.g1(); 76 | if (code == 0) { 77 | break; 78 | } 79 | 80 | if (code == 1) { 81 | this.frameCount = dat.g1(); 82 | this.frames = new int[this.frameCount]; 83 | this.iframes = new int[this.frameCount]; 84 | this.delay = new int[this.frameCount]; 85 | 86 | for (int i = 0; i < this.frameCount; i++) { 87 | this.frames[i] = dat.g2(); 88 | 89 | this.iframes[i] = dat.g2(); 90 | if (this.iframes[i] == 65535) { 91 | this.iframes[i] = -1; 92 | } 93 | 94 | this.delay[i] = dat.g2(); 95 | if (this.delay[i] == 0) { 96 | this.delay[i] = AnimFrame.instances[this.frames[i]].delay; 97 | } 98 | 99 | if (this.delay[i] == 0) { 100 | this.delay[i] = 1; 101 | } 102 | } 103 | } else if (code == 2) { 104 | this.replayoff = dat.g2(); 105 | } else if (code == 3) { 106 | int count = dat.g1(); 107 | this.walkmerge = new int[count + 1]; 108 | 109 | for (@Pc(127) int i = 0; i < count; i++) { 110 | this.walkmerge[i] = dat.g1(); 111 | } 112 | 113 | this.walkmerge[count] = 9999999; 114 | } else if (code == 4) { 115 | this.stretches = true; 116 | } else if (code == 5) { 117 | this.priority = dat.g1(); 118 | } else if (code == 6) { 119 | // later RS (think RS3) this becomes mainhand 120 | this.righthand = dat.g2(); 121 | } else if (code == 7) { 122 | // later RS (think RS3) this becomes offhand 123 | this.lefthand = dat.g2(); 124 | } else if (code == 8) { 125 | this.replaycount = dat.g1(); 126 | } else { 127 | System.out.println("Error unrecognised seq config code: " + code); 128 | } 129 | } 130 | 131 | if (this.frameCount == 0) { 132 | this.frameCount = 1; 133 | 134 | this.frames = new int[1]; 135 | this.frames[0] = -1; 136 | 137 | this.iframes = new int[1]; 138 | this.iframes[0] = -1; 139 | 140 | this.delay = new int[1]; 141 | this.delay[0] = -1; 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/config/SpotAnimType.java: -------------------------------------------------------------------------------- 1 | package jagex2.config; 2 | 3 | import jagex2.datastruct.LruCache; 4 | import jagex2.graphics.Model; 5 | import jagex2.io.Jagfile; 6 | import jagex2.io.Packet; 7 | import org.openrs2.deob.annotation.OriginalArg; 8 | import org.openrs2.deob.annotation.OriginalClass; 9 | import org.openrs2.deob.annotation.OriginalMember; 10 | import org.openrs2.deob.annotation.Pc; 11 | 12 | // name derived from other types + spotanim.dat (it's been renamed in NXT) 13 | @OriginalClass("client!kc") 14 | public class SpotAnimType { 15 | 16 | @OriginalMember(owner = "client!kc", name = "b", descriptor = "I") 17 | private static int count; 18 | 19 | @OriginalMember(owner = "client!kc", name = "c", descriptor = "[Lclient!kc;") 20 | public static SpotAnimType[] instances; 21 | 22 | @OriginalMember(owner = "client!kc", name = "d", descriptor = "I") 23 | public int index; 24 | 25 | @OriginalMember(owner = "client!kc", name = "e", descriptor = "I") 26 | private int model; 27 | 28 | @OriginalMember(owner = "client!kc", name = "f", descriptor = "I") 29 | private int anim = -1; 30 | 31 | @OriginalMember(owner = "client!kc", name = "g", descriptor = "Lclient!jc;") 32 | public SeqType seq; 33 | 34 | @OriginalMember(owner = "client!kc", name = "h", descriptor = "Z") 35 | public boolean animHasAlpha = false; 36 | 37 | @OriginalMember(owner = "client!kc", name = "i", descriptor = "[I") 38 | private final int[] recol_s = new int[6]; 39 | 40 | @OriginalMember(owner = "client!kc", name = "j", descriptor = "[I") 41 | private final int[] recol_d = new int[6]; 42 | 43 | @OriginalMember(owner = "client!kc", name = "k", descriptor = "I") 44 | public int resizeh = 128; 45 | 46 | @OriginalMember(owner = "client!kc", name = "l", descriptor = "I") 47 | public int resizev = 128; 48 | 49 | @OriginalMember(owner = "client!kc", name = "m", descriptor = "I") 50 | public int orientation; 51 | 52 | @OriginalMember(owner = "client!kc", name = "n", descriptor = "I") 53 | public int ambient; 54 | 55 | @OriginalMember(owner = "client!kc", name = "o", descriptor = "I") 56 | public int contrast; 57 | 58 | @OriginalMember(owner = "client!kc", name = "p", descriptor = "Lclient!s;") 59 | public static LruCache modelCache = new LruCache(30); 60 | 61 | @OriginalMember(owner = "client!kc", name = "a", descriptor = "(Lclient!ub;I)V") 62 | public static void unpack(@OriginalArg(0) Jagfile config) { 63 | @Pc(13) Packet dat = new Packet(config.read("spotanim.dat", null)); 64 | count = dat.g2(); 65 | 66 | if (instances == null) { 67 | instances = new SpotAnimType[count]; 68 | } 69 | 70 | for (@Pc(23) int id = 0; id < count; id++) { 71 | if (instances[id] == null) { 72 | instances[id] = new SpotAnimType(); 73 | } 74 | 75 | instances[id].index = id; 76 | instances[id].decode(dat); 77 | } 78 | } 79 | 80 | @OriginalMember(owner = "client!kc", name = "a", descriptor = "(ZLclient!kb;)V") 81 | public void decode(@OriginalArg(1) Packet dat) { 82 | while (true) { 83 | @Pc(5) int code = dat.g1(); 84 | if (code == 0) { 85 | break; 86 | } 87 | 88 | if (code == 1) { 89 | this.model = dat.g2(); 90 | } else if (code == 2) { 91 | this.anim = dat.g2(); 92 | 93 | if (SeqType.instances != null) { 94 | this.seq = SeqType.instances[this.anim]; 95 | } 96 | } else if (code == 3) { 97 | this.animHasAlpha = true; 98 | } else if (code == 4) { 99 | this.resizeh = dat.g2(); 100 | } else if (code == 5) { 101 | this.resizev = dat.g2(); 102 | } else if (code == 6) { 103 | this.orientation = dat.g2(); 104 | } else if (code == 7) { 105 | this.ambient = dat.g1(); 106 | } else if (code == 8) { 107 | this.contrast = dat.g1(); 108 | } else if (code >= 40 && code < 50) { 109 | this.recol_s[code - 40] = dat.g2(); 110 | } else if (code >= 50 && code < 60) { 111 | this.recol_d[code - 50] = dat.g2(); 112 | } else { 113 | System.out.println("Error unrecognised spotanim config code: " + code); 114 | } 115 | } 116 | } 117 | 118 | @OriginalMember(owner = "client!kc", name = "a", descriptor = "()Lclient!eb;") 119 | public Model getModel() { 120 | @Pc(6) Model model = (Model) modelCache.get(this.index); 121 | if (model != null) { 122 | return model; 123 | } 124 | 125 | model = new Model(this.model); 126 | for (@Pc(19) int i = 0; i < 6; i++) { 127 | if (this.recol_s[0] != 0) { 128 | model.recolor(this.recol_s[i], this.recol_d[i]); 129 | } 130 | } 131 | 132 | modelCache.put(this.index, model); 133 | return model; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/config/VarpType.java: -------------------------------------------------------------------------------- 1 | package jagex2.config; 2 | 3 | import jagex2.io.Jagfile; 4 | import jagex2.io.Packet; 5 | import org.openrs2.deob.annotation.OriginalArg; 6 | import org.openrs2.deob.annotation.OriginalClass; 7 | import org.openrs2.deob.annotation.OriginalMember; 8 | import org.openrs2.deob.annotation.Pc; 9 | 10 | // name derived from other types + varp.dat (rs3 has this as VarPlayerType) 11 | @OriginalClass("client!lc") 12 | public class VarpType { 13 | 14 | @OriginalMember(owner = "client!lc", name = "c", descriptor = "I") 15 | private static int count; 16 | 17 | @OriginalMember(owner = "client!lc", name = "d", descriptor = "[Lclient!lc;") 18 | public static VarpType[] instances; 19 | 20 | @OriginalMember(owner = "client!lc", name = "e", descriptor = "I") 21 | public static int code3Count; 22 | 23 | @OriginalMember(owner = "client!lc", name = "f", descriptor = "[I") 24 | public static int[] code3; 25 | 26 | @OriginalMember(owner = "client!lc", name = "g", descriptor = "Ljava/lang/String;") 27 | private String code10; 28 | 29 | @OriginalMember(owner = "client!lc", name = "h", descriptor = "I") 30 | private int code1; 31 | 32 | @OriginalMember(owner = "client!lc", name = "i", descriptor = "I") 33 | private int code2; 34 | 35 | @OriginalMember(owner = "client!lc", name = "j", descriptor = "Z") 36 | private boolean hasCode3 = false; 37 | 38 | @OriginalMember(owner = "client!lc", name = "k", descriptor = "Z") 39 | private boolean code4 = true; 40 | 41 | @OriginalMember(owner = "client!lc", name = "l", descriptor = "I") 42 | public int clientcode; 43 | 44 | @OriginalMember(owner = "client!lc", name = "n", descriptor = "I") 45 | private int code7; 46 | 47 | @OriginalMember(owner = "client!lc", name = "m", descriptor = "Z") 48 | private boolean code6 = false; 49 | 50 | @OriginalMember(owner = "client!lc", name = "o", descriptor = "Z") 51 | private boolean code8 = false; 52 | 53 | @OriginalMember(owner = "client!lc", name = "a", descriptor = "(Lclient!ub;I)V") 54 | public static void unpack(@OriginalArg(0) Jagfile config) { 55 | @Pc(9) Packet dat = new Packet(config.read("varp.dat", null)); 56 | code3Count = 0; 57 | count = dat.g2(); 58 | 59 | if (instances == null) { 60 | instances = new VarpType[count]; 61 | } 62 | 63 | if (code3 == null) { 64 | code3 = new int[count]; 65 | } 66 | 67 | for (@Pc(30) int id = 0; id < count; id++) { 68 | if (instances[id] == null) { 69 | instances[id] = new VarpType(); 70 | } 71 | 72 | instances[id].decode(id, dat); 73 | } 74 | } 75 | 76 | @OriginalMember(owner = "client!lc", name = "a", descriptor = "(IILclient!kb;)V") 77 | public void decode(@OriginalArg(1) int id, @OriginalArg(2) Packet dat) { 78 | while (true) { 79 | @Pc(8) int code = dat.g1(); 80 | if (code == 0) { 81 | return; 82 | } 83 | 84 | if (code == 1) { 85 | this.code1 = dat.g1(); 86 | } else if (code == 2) { 87 | this.code2 = dat.g1(); 88 | } else if (code == 3) { 89 | this.hasCode3 = true; 90 | VarpType.code3[VarpType.code3Count++] = id; 91 | } else if (code == 4) { 92 | this.code4 = false; 93 | } else if (code == 5) { 94 | this.clientcode = dat.g2(); 95 | } else if (code == 6) { 96 | this.code6 = true; 97 | } else if (code == 7) { 98 | this.code7 = dat.g4(); 99 | } else if (code == 8) { 100 | this.code8 = true; 101 | } else if (code == 10) { 102 | this.code10 = dat.gjstr(); 103 | } else { 104 | System.out.println("Error unrecognised varp config code: " + code); 105 | } 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/Occlude.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d; 2 | 3 | import org.openrs2.deob.annotation.OriginalClass; 4 | import org.openrs2.deob.annotation.OriginalMember; 5 | 6 | @OriginalClass("client!m") 7 | public class Occlude { 8 | 9 | @OriginalMember(owner = "client!m", name = "a", descriptor = "I") 10 | public int minTileX; 11 | 12 | @OriginalMember(owner = "client!m", name = "b", descriptor = "I") 13 | public int maxTileX; 14 | 15 | @OriginalMember(owner = "client!m", name = "c", descriptor = "I") 16 | public int minTileZ; 17 | 18 | @OriginalMember(owner = "client!m", name = "d", descriptor = "I") 19 | public int maxTileZ; 20 | 21 | @OriginalMember(owner = "client!m", name = "e", descriptor = "I") 22 | public int type; 23 | 24 | @OriginalMember(owner = "client!m", name = "f", descriptor = "I") 25 | public int minX; 26 | 27 | @OriginalMember(owner = "client!m", name = "g", descriptor = "I") 28 | public int maxX; 29 | 30 | @OriginalMember(owner = "client!m", name = "h", descriptor = "I") 31 | public int minZ; 32 | 33 | @OriginalMember(owner = "client!m", name = "i", descriptor = "I") 34 | public int maxZ; 35 | 36 | @OriginalMember(owner = "client!m", name = "j", descriptor = "I") 37 | public int minY; 38 | 39 | @OriginalMember(owner = "client!m", name = "k", descriptor = "I") 40 | public int maxY; 41 | 42 | @OriginalMember(owner = "client!m", name = "l", descriptor = "I") 43 | public int mode; 44 | 45 | @OriginalMember(owner = "client!m", name = "m", descriptor = "I") 46 | public int minDeltaX; 47 | 48 | @OriginalMember(owner = "client!m", name = "n", descriptor = "I") 49 | public int maxDeltaX; 50 | 51 | @OriginalMember(owner = "client!m", name = "o", descriptor = "I") 52 | public int minDeltaZ; 53 | 54 | @OriginalMember(owner = "client!m", name = "p", descriptor = "I") 55 | public int maxDeltaZ; 56 | 57 | @OriginalMember(owner = "client!m", name = "q", descriptor = "I") 58 | public int minDeltaY; 59 | 60 | @OriginalMember(owner = "client!m", name = "r", descriptor = "I") 61 | public int maxDeltaY; 62 | } 63 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/entity/Entity.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.entity; 2 | 3 | import jagex2.datastruct.Linkable; 4 | import jagex2.graphics.Model; 5 | import org.openrs2.deob.annotation.OriginalClass; 6 | import org.openrs2.deob.annotation.OriginalMember; 7 | 8 | @OriginalClass("client!w") 9 | public class Entity extends Linkable { 10 | 11 | @OriginalMember(owner = "client!w", name = "a", descriptor = "(Z)Lclient!eb;") 12 | public Model draw(int loopCycle) { 13 | return null; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/entity/LocAddEntity.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.entity; 2 | 3 | import jagex2.datastruct.Linkable; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | 7 | @OriginalClass("client!lb") 8 | public class LocAddEntity extends Linkable { 9 | 10 | @OriginalMember(owner = "client!lb", name = "e", descriptor = "I") 11 | public int plane; 12 | 13 | @OriginalMember(owner = "client!lb", name = "f", descriptor = "I") 14 | public int layer; 15 | 16 | @OriginalMember(owner = "client!lb", name = "g", descriptor = "I") 17 | public int x; 18 | 19 | @OriginalMember(owner = "client!lb", name = "h", descriptor = "I") 20 | public int z; 21 | 22 | @OriginalMember(owner = "client!lb", name = "i", descriptor = "I") 23 | public int locIndex; 24 | 25 | @OriginalMember(owner = "client!lb", name = "j", descriptor = "I") 26 | public int angle; 27 | 28 | @OriginalMember(owner = "client!lb", name = "k", descriptor = "I") 29 | public int shape; 30 | 31 | @OriginalMember(owner = "client!lb", name = "l", descriptor = "I") 32 | public int lastLocIndex; 33 | 34 | @OriginalMember(owner = "client!lb", name = "m", descriptor = "I") 35 | public int lastAngle; 36 | 37 | @OriginalMember(owner = "client!lb", name = "n", descriptor = "I") 38 | public int lastShape; 39 | } 40 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/entity/LocEntity.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.entity; 2 | 3 | import jagex2.config.SeqType; 4 | import jagex2.datastruct.Linkable; 5 | import org.openrs2.deob.annotation.OriginalArg; 6 | import org.openrs2.deob.annotation.OriginalClass; 7 | import org.openrs2.deob.annotation.OriginalMember; 8 | 9 | @OriginalClass("client!nb") 10 | public class LocEntity extends Linkable { 11 | 12 | @OriginalMember(owner = "client!nb", name = "e", descriptor = "I") 13 | public int level; 14 | 15 | @OriginalMember(owner = "client!nb", name = "f", descriptor = "I") 16 | public final int type; 17 | 18 | @OriginalMember(owner = "client!nb", name = "g", descriptor = "I") 19 | public final int x; 20 | 21 | @OriginalMember(owner = "client!nb", name = "h", descriptor = "I") 22 | public final int z; 23 | 24 | @OriginalMember(owner = "client!nb", name = "i", descriptor = "I") 25 | public final int index; 26 | 27 | @OriginalMember(owner = "client!nb", name = "j", descriptor = "Lclient!jc;") 28 | public final SeqType seq; 29 | 30 | @OriginalMember(owner = "client!nb", name = "k", descriptor = "I") 31 | public int seqFrame; 32 | 33 | @OriginalMember(owner = "client!nb", name = "l", descriptor = "I") 34 | public int seqCycle; 35 | 36 | @OriginalMember(owner = "client!nb", name = "", descriptor = "(ZIIIILclient!jc;II)V") 37 | public LocEntity(@OriginalArg(1) int index, @OriginalArg(2) int level, @OriginalArg(4) int type, @OriginalArg(7) int x, @OriginalArg(6) int z, @OriginalArg(5) SeqType seq, @OriginalArg(0) boolean randomFrame) { 38 | this.level = level; 39 | this.type = type; 40 | this.x = x; 41 | this.z = z; 42 | this.index = index; 43 | this.seq = seq; 44 | 45 | if (randomFrame && seq.replayoff != -1) { 46 | this.seqFrame = (int) (Math.random() * (double) this.seq.frameCount); 47 | this.seqCycle = (int) (Math.random() * (double) this.seq.delay[this.seqFrame]); 48 | } else { 49 | this.seqFrame = -1; 50 | this.seqCycle = 0; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/entity/LocMergeEntity.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.entity; 2 | 3 | import jagex2.datastruct.Linkable; 4 | import org.openrs2.deob.annotation.OriginalArg; 5 | import org.openrs2.deob.annotation.OriginalClass; 6 | import org.openrs2.deob.annotation.OriginalMember; 7 | 8 | @OriginalClass("client!mb") 9 | public class LocMergeEntity extends Linkable { 10 | 11 | @OriginalMember(owner = "client!mb", name = "f", descriptor = "I") 12 | public final int plane; 13 | 14 | @OriginalMember(owner = "client!mb", name = "g", descriptor = "I") 15 | public final int layer; 16 | 17 | @OriginalMember(owner = "client!mb", name = "h", descriptor = "I") 18 | public final int x; 19 | 20 | @OriginalMember(owner = "client!mb", name = "i", descriptor = "I") 21 | public final int z; 22 | 23 | @OriginalMember(owner = "client!mb", name = "j", descriptor = "I") 24 | public final int locIndex; 25 | 26 | @OriginalMember(owner = "client!mb", name = "k", descriptor = "I") 27 | public final int angle; 28 | 29 | @OriginalMember(owner = "client!mb", name = "l", descriptor = "I") 30 | public final int shape; 31 | 32 | @OriginalMember(owner = "client!mb", name = "m", descriptor = "I") 33 | public final int lastCycle; 34 | 35 | @OriginalMember(owner = "client!mb", name = "", descriptor = "(IIIIIIIII)V") 36 | public LocMergeEntity(@OriginalArg(0) int plane, @OriginalArg(8) int layer, @OriginalArg(7) int x, @OriginalArg(2) int z, @OriginalArg(6) int locIndex, @OriginalArg(1) int angle, @OriginalArg(5) int shape, @OriginalArg(3) int lastCycle) { 37 | this.plane = plane; 38 | this.layer = layer; 39 | this.x = x; 40 | this.z = z; 41 | this.locIndex = locIndex; 42 | this.angle = angle; 43 | this.shape = shape; 44 | this.lastCycle = lastCycle; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/entity/NpcEntity.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.entity; 2 | 3 | import jagex2.config.NpcType; 4 | import jagex2.config.SeqType; 5 | import jagex2.config.SpotAnimType; 6 | import jagex2.graphics.Model; 7 | import org.openrs2.deob.annotation.OriginalClass; 8 | import org.openrs2.deob.annotation.OriginalMember; 9 | import org.openrs2.deob.annotation.Pc; 10 | 11 | @OriginalClass("client!y") 12 | public class NpcEntity extends PathingEntity { 13 | 14 | @OriginalMember(owner = "client!y", name = "ib", descriptor = "Lclient!bc;") 15 | public NpcType type; 16 | 17 | @OriginalMember(owner = "client!y", name = "a", descriptor = "(Z)Lclient!eb;") 18 | @Override 19 | public Model draw(int loopCycle) { 20 | if (this.type == null) { 21 | return null; 22 | } 23 | 24 | if (super.spotanimId == -1 || super.spotanimFrame == -1) { 25 | return this.getSequencedModel(); 26 | } 27 | 28 | @Pc(20) Model model = this.getSequencedModel(); 29 | @Pc(25) SpotAnimType spotanim = SpotAnimType.instances[super.spotanimId]; 30 | 31 | @Pc(41) Model model1 = new Model(spotanim.getModel(), true, !spotanim.animHasAlpha, false); 32 | model1.translate(-super.spotanimOffset, 0, 0); 33 | model1.createLabelReferences(); 34 | model1.applyTransform(spotanim.seq.frames[super.spotanimFrame]); 35 | model1.labelFaces = null; 36 | model1.labelVertices = null; 37 | 38 | if (spotanim.resizeh != 128 || spotanim.resizev != 128) { 39 | model1.scale(spotanim.resizeh, spotanim.resizev, spotanim.resizeh); 40 | } 41 | 42 | model1.calculateNormals(64 + spotanim.ambient, 850 + spotanim.contrast, -30, -50, -30, true); 43 | @Pc(115) Model[] models = new Model[] { model, model1 }; 44 | 45 | @Pc(123) Model tmp = new Model(models, 2, true); 46 | if (this.type.size == 1) { 47 | tmp.pickable = true; 48 | } 49 | 50 | return tmp; 51 | } 52 | 53 | @OriginalMember(owner = "client!y", name = "c", descriptor = "(Z)Lclient!eb;") 54 | private Model getSequencedModel() { 55 | if (super.primarySeqId >= 0 && super.primarySeqDelay == 0) { 56 | @Pc(14) int primaryTransformId = SeqType.instances[super.primarySeqId].frames[super.primarySeqFrame]; 57 | @Pc(16) int secondaryTransformId = -1; 58 | if (super.secondarySeqId >= 0 && super.secondarySeqId != super.seqStandId) { 59 | secondaryTransformId = SeqType.instances[super.secondarySeqId].frames[super.secondarySeqFrame]; 60 | } 61 | return this.type.getSequencedModel(primaryTransformId, secondaryTransformId, SeqType.instances[super.primarySeqId].walkmerge); 62 | } 63 | 64 | int transformId = -1; 65 | if (super.secondarySeqId >= 0) { 66 | transformId = SeqType.instances[super.secondarySeqId].frames[super.secondarySeqFrame]; 67 | } 68 | 69 | @Pc(71) Model model = this.type.getSequencedModel(transformId, -1, null); 70 | super.height = model.maxY; 71 | return model; 72 | } 73 | 74 | @OriginalMember(owner = "client!y", name = "b", descriptor = "(Z)Z") 75 | @Override 76 | public boolean isVisible() { 77 | return this.type != null; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/entity/ObjStackEntity.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.entity; 2 | 3 | import jagex2.datastruct.Linkable; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | 7 | @OriginalClass("client!v") 8 | public class ObjStackEntity extends Linkable { 9 | 10 | @OriginalMember(owner = "client!v", name = "e", descriptor = "I") 11 | public int index; 12 | 13 | @OriginalMember(owner = "client!v", name = "f", descriptor = "I") 14 | public int count; 15 | } 16 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/entity/PathingEntity.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.entity; 2 | 3 | import jagex2.config.SeqType; 4 | import org.openrs2.deob.annotation.OriginalArg; 5 | import org.openrs2.deob.annotation.OriginalClass; 6 | import org.openrs2.deob.annotation.OriginalMember; 7 | import org.openrs2.deob.annotation.Pc; 8 | 9 | @OriginalClass("client!x") 10 | public class PathingEntity extends Entity { 11 | 12 | @OriginalMember(owner = "client!x", name = "g", descriptor = "I") 13 | public int x; 14 | 15 | @OriginalMember(owner = "client!x", name = "h", descriptor = "I") 16 | public int z; 17 | 18 | @OriginalMember(owner = "client!x", name = "i", descriptor = "I") 19 | public int yaw; 20 | 21 | @OriginalMember(owner = "client!x", name = "j", descriptor = "Z") 22 | public boolean seqStretches = false; 23 | 24 | @OriginalMember(owner = "client!x", name = "k", descriptor = "I") 25 | public int size = 1; 26 | 27 | @OriginalMember(owner = "client!x", name = "l", descriptor = "I") 28 | public int seqStandId = -1; 29 | 30 | @OriginalMember(owner = "client!x", name = "m", descriptor = "I") 31 | public int seqTurnId = -1; 32 | 33 | @OriginalMember(owner = "client!x", name = "n", descriptor = "I") 34 | public int seqWalkId = -1; 35 | 36 | @OriginalMember(owner = "client!x", name = "o", descriptor = "I") 37 | public int seqTurnAroundId = -1; 38 | 39 | @OriginalMember(owner = "client!x", name = "p", descriptor = "I") 40 | public int seqTurnLeftId = -1; 41 | 42 | @OriginalMember(owner = "client!x", name = "q", descriptor = "I") 43 | public int seqTurnRightId = -1; 44 | 45 | @OriginalMember(owner = "client!x", name = "r", descriptor = "I") 46 | public int seqRunId = -1; 47 | 48 | @OriginalMember(owner = "client!x", name = "s", descriptor = "Ljava/lang/String;") 49 | public String chat; 50 | 51 | @OriginalMember(owner = "client!x", name = "t", descriptor = "I") 52 | public int chatTimer = 100; 53 | 54 | @OriginalMember(owner = "client!x", name = "u", descriptor = "I") 55 | public int chatColor; 56 | 57 | @OriginalMember(owner = "client!x", name = "v", descriptor = "I") 58 | public int chatStyle; 59 | 60 | @OriginalMember(owner = "client!x", name = "w", descriptor = "I") 61 | public int damage; 62 | 63 | @OriginalMember(owner = "client!x", name = "x", descriptor = "I") 64 | public int damageType; 65 | 66 | @OriginalMember(owner = "client!x", name = "y", descriptor = "I") 67 | public int combatCycle = -1000; 68 | 69 | @OriginalMember(owner = "client!x", name = "z", descriptor = "I") 70 | public int health; 71 | 72 | @OriginalMember(owner = "client!x", name = "A", descriptor = "I") 73 | public int totalHealth; 74 | 75 | @OriginalMember(owner = "client!x", name = "B", descriptor = "I") 76 | public int targetId = -1; 77 | 78 | @OriginalMember(owner = "client!x", name = "C", descriptor = "I") 79 | public int targetTileX; 80 | 81 | @OriginalMember(owner = "client!x", name = "D", descriptor = "I") 82 | public int targetTileZ; 83 | 84 | @OriginalMember(owner = "client!x", name = "E", descriptor = "I") 85 | public int secondarySeqId = -1; 86 | 87 | @OriginalMember(owner = "client!x", name = "F", descriptor = "I") 88 | public int secondarySeqFrame; 89 | 90 | @OriginalMember(owner = "client!x", name = "G", descriptor = "I") 91 | public int secondarySeqCycle; 92 | 93 | @OriginalMember(owner = "client!x", name = "H", descriptor = "I") 94 | public int primarySeqId = -1; 95 | 96 | @OriginalMember(owner = "client!x", name = "I", descriptor = "I") 97 | public int primarySeqFrame; 98 | 99 | @OriginalMember(owner = "client!x", name = "J", descriptor = "I") 100 | public int primarySeqCycle; 101 | 102 | @OriginalMember(owner = "client!x", name = "K", descriptor = "I") 103 | public int primarySeqDelay; 104 | 105 | @OriginalMember(owner = "client!x", name = "L", descriptor = "I") 106 | public int primarySeqLoop; 107 | 108 | @OriginalMember(owner = "client!x", name = "M", descriptor = "I") 109 | public int spotanimId = -1; 110 | 111 | @OriginalMember(owner = "client!x", name = "N", descriptor = "I") 112 | public int spotanimFrame; 113 | 114 | @OriginalMember(owner = "client!x", name = "O", descriptor = "I") 115 | public int spotanimCycle; 116 | 117 | @OriginalMember(owner = "client!x", name = "P", descriptor = "I") 118 | public int spotanimLastCycle; 119 | 120 | @OriginalMember(owner = "client!x", name = "Q", descriptor = "I") 121 | public int spotanimOffset; 122 | 123 | @OriginalMember(owner = "client!x", name = "R", descriptor = "I") 124 | public int forceMoveStartSceneTileX; 125 | 126 | @OriginalMember(owner = "client!x", name = "S", descriptor = "I") 127 | public int forceMoveEndSceneTileX; 128 | 129 | @OriginalMember(owner = "client!x", name = "T", descriptor = "I") 130 | public int forceMoveStartSceneTileZ; 131 | 132 | @OriginalMember(owner = "client!x", name = "U", descriptor = "I") 133 | public int forceMoveEndSceneTileZ; 134 | 135 | @OriginalMember(owner = "client!x", name = "V", descriptor = "I") 136 | public int forceMoveEndCycle; 137 | 138 | @OriginalMember(owner = "client!x", name = "W", descriptor = "I") 139 | public int forceMoveStartCycle; 140 | 141 | @OriginalMember(owner = "client!x", name = "X", descriptor = "I") 142 | public int forceMoveFaceDirection; 143 | 144 | @OriginalMember(owner = "client!x", name = "Y", descriptor = "I") 145 | public int cycle; 146 | 147 | @OriginalMember(owner = "client!x", name = "Z", descriptor = "I") 148 | public int height; 149 | 150 | @OriginalMember(owner = "client!x", name = "ab", descriptor = "I") 151 | public int dstYaw; 152 | 153 | @OriginalMember(owner = "client!x", name = "bb", descriptor = "I") 154 | public int pathLength; 155 | 156 | @OriginalMember(owner = "client!x", name = "cb", descriptor = "[I") 157 | public final int[] pathTileX = new int[10]; 158 | 159 | @OriginalMember(owner = "client!x", name = "db", descriptor = "[I") 160 | public final int[] pathTileZ = new int[10]; 161 | 162 | @OriginalMember(owner = "client!x", name = "eb", descriptor = "[Z") 163 | public final boolean[] pathRunning = new boolean[10]; 164 | 165 | @OriginalMember(owner = "client!x", name = "fb", descriptor = "I") 166 | public int seqTrigger; 167 | 168 | public int lastMask = -1; 169 | public int lastMaskCycle = -1; 170 | public int lastFaceX = -1; 171 | public int lastFaceZ = -1; 172 | 173 | @OriginalMember(owner = "client!x", name = "a", descriptor = "(ZZII)V") 174 | public final void teleport(@OriginalArg(1) boolean jump, @OriginalArg(2) int x, @OriginalArg(3) int z) { 175 | if (this.primarySeqId != -1 && SeqType.instances[this.primarySeqId].priority <= 1) { 176 | this.primarySeqId = -1; 177 | } 178 | 179 | if (!jump) { 180 | @Pc(22) int dx = x - this.pathTileX[0]; 181 | @Pc(29) int dz = z - this.pathTileZ[0]; 182 | 183 | if (dx >= -8 && dx <= 8 && dz >= -8 && dz <= 8) { 184 | if (this.pathLength < 9) { 185 | this.pathLength++; 186 | } 187 | 188 | for (@Pc(54) int i = this.pathLength; i > 0; i--) { 189 | this.pathTileX[i] = this.pathTileX[i - 1]; 190 | this.pathTileZ[i] = this.pathTileZ[i - 1]; 191 | this.pathRunning[i] = this.pathRunning[i - 1]; 192 | } 193 | 194 | this.pathTileX[0] = x; 195 | this.pathTileZ[0] = z; 196 | this.pathRunning[0] = false; 197 | return; 198 | } 199 | } 200 | 201 | this.pathLength = 0; 202 | this.seqTrigger = 0; 203 | this.pathTileX[0] = x; 204 | this.pathTileZ[0] = z; 205 | this.x = this.pathTileX[0] * 128 + this.size * 64; 206 | this.z = this.pathTileZ[0] * 128 + this.size * 64; 207 | } 208 | 209 | @OriginalMember(owner = "client!x", name = "a", descriptor = "(ZIB)V") 210 | public final void moveAlongRoute(@OriginalArg(0) boolean running, @OriginalArg(1) int direction) { 211 | @Pc(6) int nextX = this.pathTileX[0]; 212 | @Pc(11) int nextZ = this.pathTileZ[0]; 213 | 214 | if (direction == 0) { 215 | nextX--; 216 | nextZ++; 217 | } else if (direction == 1) { 218 | nextZ++; 219 | } else if (direction == 2) { 220 | nextX++; 221 | nextZ++; 222 | } else if (direction == 3) { 223 | nextX--; 224 | } else if (direction == 4) { 225 | nextX++; 226 | } else if (direction == 5) { 227 | nextX--; 228 | nextZ--; 229 | } else if (direction == 6) { 230 | nextZ--; 231 | } else if (direction == 7) { 232 | nextX++; 233 | nextZ--; 234 | } 235 | 236 | if (this.primarySeqId != -1 && SeqType.instances[this.primarySeqId].priority <= 1) { 237 | this.primarySeqId = -1; 238 | } 239 | 240 | if (this.pathLength < 9) { 241 | this.pathLength++; 242 | } 243 | 244 | for (@Pc(83) int i = this.pathLength; i > 0; i--) { 245 | this.pathTileX[i] = this.pathTileX[i - 1]; 246 | this.pathTileZ[i] = this.pathTileZ[i - 1]; 247 | this.pathRunning[i] = this.pathRunning[i - 1]; 248 | } 249 | 250 | this.pathTileX[0] = nextX; 251 | this.pathTileZ[0] = nextZ; 252 | this.pathRunning[0] = running; 253 | } 254 | 255 | @OriginalMember(owner = "client!x", name = "b", descriptor = "(Z)Z") 256 | public boolean isVisible() { 257 | return false; 258 | } 259 | } 260 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/entity/ProjectileEntity.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.entity; 2 | 3 | import jagex2.config.SpotAnimType; 4 | import jagex2.graphics.Model; 5 | import org.openrs2.deob.annotation.OriginalArg; 6 | import org.openrs2.deob.annotation.OriginalClass; 7 | import org.openrs2.deob.annotation.OriginalMember; 8 | import org.openrs2.deob.annotation.Pc; 9 | 10 | @OriginalClass("client!ab") 11 | public class ProjectileEntity extends Entity { 12 | 13 | @OriginalMember(owner = "client!ab", name = "g", descriptor = "Lclient!kc;") 14 | private final SpotAnimType spotanim; 15 | 16 | @OriginalMember(owner = "client!ab", name = "h", descriptor = "I") 17 | public final int level; 18 | 19 | @OriginalMember(owner = "client!ab", name = "i", descriptor = "I") 20 | private final int srcX; 21 | 22 | @OriginalMember(owner = "client!ab", name = "j", descriptor = "I") 23 | private final int srcZ; 24 | 25 | @OriginalMember(owner = "client!ab", name = "k", descriptor = "I") 26 | private final int srcY; 27 | 28 | @OriginalMember(owner = "client!ab", name = "l", descriptor = "I") 29 | public final int offsetY; 30 | 31 | @OriginalMember(owner = "client!ab", name = "m", descriptor = "I") 32 | public final int startCycle; 33 | 34 | @OriginalMember(owner = "client!ab", name = "n", descriptor = "I") 35 | public final int lastCycle; 36 | 37 | @OriginalMember(owner = "client!ab", name = "o", descriptor = "I") 38 | private final int peakPitch; 39 | 40 | @OriginalMember(owner = "client!ab", name = "p", descriptor = "I") 41 | private final int arc; 42 | 43 | @OriginalMember(owner = "client!ab", name = "q", descriptor = "I") 44 | public final int target; 45 | 46 | @OriginalMember(owner = "client!ab", name = "r", descriptor = "Z") 47 | private boolean mobile = false; 48 | 49 | @OriginalMember(owner = "client!ab", name = "s", descriptor = "D") 50 | public double x; 51 | 52 | @OriginalMember(owner = "client!ab", name = "t", descriptor = "D") 53 | public double z; 54 | 55 | @OriginalMember(owner = "client!ab", name = "u", descriptor = "D") 56 | public double y; 57 | 58 | @OriginalMember(owner = "client!ab", name = "v", descriptor = "D") 59 | private double velocityX; 60 | 61 | @OriginalMember(owner = "client!ab", name = "w", descriptor = "D") 62 | private double velocityZ; 63 | 64 | @OriginalMember(owner = "client!ab", name = "x", descriptor = "D") 65 | private double velocity; 66 | 67 | @OriginalMember(owner = "client!ab", name = "y", descriptor = "D") 68 | private double velocityY; 69 | 70 | @OriginalMember(owner = "client!ab", name = "z", descriptor = "D") 71 | private double accelerationY; 72 | 73 | @OriginalMember(owner = "client!ab", name = "A", descriptor = "I") 74 | public int yaw; 75 | 76 | @OriginalMember(owner = "client!ab", name = "B", descriptor = "I") 77 | private int pitch; 78 | 79 | @OriginalMember(owner = "client!ab", name = "C", descriptor = "I") 80 | private int seqFrame; 81 | 82 | @OriginalMember(owner = "client!ab", name = "D", descriptor = "I") 83 | private int seqCycle; 84 | 85 | @OriginalMember(owner = "client!ab", name = "", descriptor = "(IIIIIIIIIIII)V") 86 | public ProjectileEntity(@OriginalArg(10) int spotanim, @OriginalArg(4) int level, @OriginalArg(11) int srcX, @OriginalArg(9) int srcY, @OriginalArg(2) int srcZ, @OriginalArg(6) int startCycle, @OriginalArg(3) int lastCycle, @OriginalArg(1) int peakPitch, @OriginalArg(7) int arc, @OriginalArg(5) int target, @OriginalArg(0) int offsetY) { 87 | this.spotanim = SpotAnimType.instances[spotanim]; 88 | this.level = level; 89 | this.srcX = srcX; 90 | this.srcZ = srcZ; 91 | this.srcY = srcY; 92 | this.startCycle = startCycle; 93 | this.lastCycle = lastCycle; 94 | this.peakPitch = peakPitch; 95 | this.arc = arc; 96 | this.target = target; 97 | this.offsetY = offsetY; 98 | this.mobile = false; 99 | } 100 | 101 | @OriginalMember(owner = "client!ab", name = "a", descriptor = "(IIIII)V") 102 | public void updateVelocity(@OriginalArg(2) int dstX, @OriginalArg(0) int dstY, @OriginalArg(1) int dstZ, @OriginalArg(4) int cycle) { 103 | if (!this.mobile) { 104 | @Pc(8) double dx = dstX - this.srcX; 105 | @Pc(14) double dz = dstZ - this.srcZ; 106 | @Pc(23) double d = Math.sqrt(dx * dx + dz * dz); 107 | 108 | this.x = (double) this.srcX + dx * (double) this.arc / d; 109 | this.z = (double) this.srcZ + dz * (double) this.arc / d; 110 | this.y = this.srcY; 111 | } 112 | 113 | double dt = this.lastCycle + 1 - cycle; 114 | this.velocityX = ((double) dstX - this.x) / dt; 115 | this.velocityZ = ((double) dstZ - this.z) / dt; 116 | this.velocity = Math.sqrt(this.velocityX * this.velocityX + this.velocityZ * this.velocityZ); 117 | 118 | if (!this.mobile) { 119 | this.velocityY = -this.velocity * Math.tan((double) this.peakPitch * 0.02454369D); 120 | } 121 | 122 | this.accelerationY = ((double) dstY - this.y - this.velocityY * dt) * 2.0D / (dt * dt); 123 | } 124 | 125 | @OriginalMember(owner = "client!ab", name = "a", descriptor = "(BI)V") 126 | public void update(@OriginalArg(1) int delta) { 127 | this.mobile = true; 128 | this.x += this.velocityX * (double) delta; 129 | this.z += this.velocityZ * (double) delta; 130 | this.y += this.velocityY * (double) delta + this.accelerationY * 0.5D * (double) delta * (double) delta; 131 | this.velocityY += this.accelerationY * (double) delta; 132 | this.yaw = (int) (Math.atan2(this.velocityX, this.velocityZ) * 325.949D) + 1024 & 0x7FF; 133 | this.pitch = (int) (Math.atan2(this.velocityY, this.velocity) * 325.949D) & 0x7FF; 134 | 135 | if (this.spotanim.seq != null) { 136 | this.seqCycle += delta; 137 | 138 | while (this.seqCycle > this.spotanim.seq.delay[this.seqFrame]) { 139 | this.seqCycle -= this.spotanim.seq.delay[this.seqFrame] + 1; 140 | this.seqFrame++; 141 | if (this.seqFrame >= this.spotanim.seq.frameCount) { 142 | this.seqFrame = 0; 143 | } 144 | } 145 | } 146 | } 147 | 148 | @OriginalMember(owner = "client!ab", name = "a", descriptor = "(Z)Lclient!eb;") 149 | @Override 150 | public Model draw(int loopCycle) { 151 | @Pc(3) Model tmp = this.spotanim.getModel(); 152 | @Pc(19) Model model = new Model(tmp, true, !this.spotanim.animHasAlpha, false); 153 | 154 | if (this.spotanim.seq != null) { 155 | model.createLabelReferences(); 156 | model.applyTransform(this.spotanim.seq.frames[this.seqFrame]); 157 | model.labelFaces = null; 158 | model.labelVertices = null; 159 | } 160 | 161 | if (this.spotanim.resizeh != 128 || this.spotanim.resizev != 128) { 162 | model.scale(this.spotanim.resizeh, this.spotanim.resizev, this.spotanim.resizeh); 163 | } 164 | 165 | model.rotateX(this.pitch); 166 | model.calculateNormals(64 + this.spotanim.ambient, 850 + this.spotanim.contrast, -30, -50, -30, true); 167 | return model; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/entity/SpotAnimEntity.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.entity; 2 | 3 | import jagex2.config.SpotAnimType; 4 | import jagex2.graphics.Model; 5 | import org.openrs2.deob.annotation.OriginalArg; 6 | import org.openrs2.deob.annotation.OriginalClass; 7 | import org.openrs2.deob.annotation.OriginalMember; 8 | import org.openrs2.deob.annotation.Pc; 9 | 10 | @OriginalClass("client!bb") 11 | public class SpotAnimEntity extends Entity { 12 | 13 | @OriginalMember(owner = "client!bb", name = "g", descriptor = "Lclient!kc;") 14 | private final SpotAnimType type; 15 | 16 | @OriginalMember(owner = "client!bb", name = "h", descriptor = "I") 17 | public final int startCycle; 18 | 19 | @OriginalMember(owner = "client!bb", name = "i", descriptor = "I") 20 | public final int level; 21 | 22 | @OriginalMember(owner = "client!bb", name = "j", descriptor = "I") 23 | public final int x; 24 | 25 | @OriginalMember(owner = "client!bb", name = "k", descriptor = "I") 26 | public final int z; 27 | 28 | @OriginalMember(owner = "client!bb", name = "l", descriptor = "I") 29 | public final int y; 30 | 31 | @OriginalMember(owner = "client!bb", name = "m", descriptor = "I") 32 | private int seqFrame; 33 | 34 | @OriginalMember(owner = "client!bb", name = "n", descriptor = "I") 35 | private int seqCycle; 36 | 37 | @OriginalMember(owner = "client!bb", name = "o", descriptor = "Z") 38 | public boolean seqComplete = false; 39 | 40 | @OriginalMember(owner = "client!bb", name = "", descriptor = "(IIZIIIII)V") 41 | public SpotAnimEntity(@OriginalArg(1) int id, @OriginalArg(6) int level, @OriginalArg(0) int x, @OriginalArg(3) int z, @OriginalArg(5) int y, @OriginalArg(7) int cycle, @OriginalArg(4) int delay) { 42 | this.type = SpotAnimType.instances[id]; 43 | this.level = level; 44 | this.x = x; 45 | this.z = z; 46 | this.y = y; 47 | this.startCycle = cycle + delay; 48 | this.seqComplete = false; 49 | } 50 | 51 | @OriginalMember(owner = "client!bb", name = "a", descriptor = "(II)V") 52 | public void update(@OriginalArg(0) int delta) { 53 | for (this.seqCycle += delta; this.seqCycle > this.type.seq.delay[this.seqFrame]; ) { 54 | this.seqCycle -= this.type.seq.delay[this.seqFrame] + 1; 55 | this.seqFrame++; 56 | 57 | if (this.seqFrame >= this.type.seq.frameCount) { 58 | this.seqFrame = 0; 59 | this.seqComplete = true; 60 | } 61 | } 62 | } 63 | 64 | @OriginalMember(owner = "client!bb", name = "a", descriptor = "(Z)Lclient!eb;") 65 | @Override 66 | public Model draw(int loopCycle) { 67 | @Pc(3) Model tmp = this.type.getModel(); 68 | @Pc(19) Model model = new Model(tmp, true, !this.type.animHasAlpha, false); 69 | 70 | if (!this.seqComplete) { 71 | model.createLabelReferences(); 72 | model.applyTransform(this.type.seq.frames[this.seqFrame]); 73 | model.labelFaces = null; 74 | model.labelVertices = null; 75 | } 76 | 77 | if (this.type.resizeh != 128 || this.type.resizev != 128) { 78 | model.scale(this.type.resizeh, this.type.resizev, this.type.resizeh); 79 | } 80 | 81 | if (this.type.orientation != 0) { 82 | if (this.type.orientation == 90) { 83 | model.rotateY90(); 84 | } else if (this.type.orientation == 180) { 85 | model.rotateY90(); 86 | model.rotateY90(); 87 | } else if (this.type.orientation == 270) { 88 | model.rotateY90(); 89 | model.rotateY90(); 90 | model.rotateY90(); 91 | } 92 | } 93 | 94 | model.calculateNormals(64 + this.type.ambient, 850 + this.type.contrast, -30, -50, -30, true); 95 | return model; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/type/Decor.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.type; 2 | 3 | import jagex2.graphics.Model; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | 7 | @OriginalClass("client!h") 8 | public class Decor { 9 | 10 | @OriginalMember(owner = "client!h", name = "a", descriptor = "I") 11 | public int y; 12 | 13 | @OriginalMember(owner = "client!h", name = "b", descriptor = "I") 14 | public int x; 15 | 16 | @OriginalMember(owner = "client!h", name = "c", descriptor = "I") 17 | public int z; 18 | 19 | @OriginalMember(owner = "client!h", name = "d", descriptor = "I") 20 | public int type; 21 | 22 | @OriginalMember(owner = "client!h", name = "e", descriptor = "I") 23 | public int angle; 24 | 25 | @OriginalMember(owner = "client!h", name = "f", descriptor = "Lclient!eb;") 26 | public Model model; 27 | 28 | @OriginalMember(owner = "client!h", name = "g", descriptor = "I") 29 | public int bitset; 30 | 31 | @OriginalMember(owner = "client!h", name = "h", descriptor = "B") 32 | public byte info; 33 | } 34 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/type/Ground.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.type; 2 | 3 | import jagex2.datastruct.Linkable; 4 | import org.openrs2.deob.annotation.OriginalArg; 5 | import org.openrs2.deob.annotation.OriginalClass; 6 | import org.openrs2.deob.annotation.OriginalMember; 7 | 8 | @OriginalClass("client!cb") 9 | public class Ground extends Linkable { 10 | 11 | @OriginalMember(owner = "client!cb", name = "e", descriptor = "I") 12 | public int level; 13 | 14 | @OriginalMember(owner = "client!cb", name = "f", descriptor = "I") 15 | public final int x; 16 | 17 | @OriginalMember(owner = "client!cb", name = "g", descriptor = "I") 18 | public final int z; 19 | 20 | @OriginalMember(owner = "client!cb", name = "h", descriptor = "I") 21 | public final int occludeLevel; 22 | 23 | @OriginalMember(owner = "client!cb", name = "i", descriptor = "Lclient!o;") 24 | public TileUnderlay underlay; 25 | 26 | @OriginalMember(owner = "client!cb", name = "j", descriptor = "Lclient!i;") 27 | public TileOverlay overlay; 28 | 29 | @OriginalMember(owner = "client!cb", name = "k", descriptor = "Lclient!q;") 30 | public Wall wall; 31 | 32 | @OriginalMember(owner = "client!cb", name = "l", descriptor = "Lclient!h;") 33 | public Decor decor; 34 | 35 | @OriginalMember(owner = "client!cb", name = "m", descriptor = "Lclient!j;") 36 | public GroundDecor groundDecor; 37 | 38 | @OriginalMember(owner = "client!cb", name = "n", descriptor = "Lclient!k;") 39 | public GroundObject groundObj; 40 | 41 | @OriginalMember(owner = "client!cb", name = "o", descriptor = "I") 42 | public int locCount; 43 | 44 | @OriginalMember(owner = "client!cb", name = "p", descriptor = "[Lclient!p;") 45 | public final Location[] locs = new Location[5]; 46 | 47 | @OriginalMember(owner = "client!cb", name = "q", descriptor = "[I") 48 | public final int[] locSpan = new int[5]; 49 | 50 | @OriginalMember(owner = "client!cb", name = "r", descriptor = "I") 51 | public int locSpans; 52 | 53 | @OriginalMember(owner = "client!cb", name = "s", descriptor = "I") 54 | public int drawLevel; 55 | 56 | @OriginalMember(owner = "client!cb", name = "t", descriptor = "Z") 57 | public boolean visible; 58 | 59 | @OriginalMember(owner = "client!cb", name = "u", descriptor = "Z") 60 | public boolean update; 61 | 62 | @OriginalMember(owner = "client!cb", name = "v", descriptor = "Z") 63 | public boolean containsLocs; 64 | 65 | @OriginalMember(owner = "client!cb", name = "w", descriptor = "I") 66 | public int checkLocSpans; 67 | 68 | @OriginalMember(owner = "client!cb", name = "x", descriptor = "I") 69 | public int blockLocSpans; 70 | 71 | @OriginalMember(owner = "client!cb", name = "y", descriptor = "I") 72 | public int inverseBlockLocSpans; 73 | 74 | @OriginalMember(owner = "client!cb", name = "z", descriptor = "I") 75 | public int backWallTypes; 76 | 77 | @OriginalMember(owner = "client!cb", name = "A", descriptor = "Lclient!cb;") 78 | public Ground bridge; 79 | 80 | @OriginalMember(owner = "client!cb", name = "", descriptor = "(III)V") 81 | public Ground(@OriginalArg(0) int level, @OriginalArg(1) int x, @OriginalArg(2) int z) { 82 | this.occludeLevel = this.level = level; 83 | this.x = x; 84 | this.z = z; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/type/GroundDecor.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.type; 2 | 3 | import jagex2.graphics.Model; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | 7 | @OriginalClass("client!j") 8 | public class GroundDecor { 9 | 10 | @OriginalMember(owner = "client!j", name = "a", descriptor = "I") 11 | public int y; 12 | 13 | @OriginalMember(owner = "client!j", name = "b", descriptor = "I") 14 | public int x; 15 | 16 | @OriginalMember(owner = "client!j", name = "c", descriptor = "I") 17 | public int z; 18 | 19 | @OriginalMember(owner = "client!j", name = "d", descriptor = "Lclient!eb;") 20 | public Model model; 21 | 22 | @OriginalMember(owner = "client!j", name = "e", descriptor = "I") 23 | public int bitset; 24 | 25 | @OriginalMember(owner = "client!j", name = "f", descriptor = "B") 26 | public byte info; 27 | } 28 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/type/GroundObject.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.type; 2 | 3 | import jagex2.graphics.Model; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | 7 | @OriginalClass("client!k") 8 | public class GroundObject { 9 | 10 | @OriginalMember(owner = "client!k", name = "a", descriptor = "I") 11 | public int y; 12 | 13 | @OriginalMember(owner = "client!k", name = "b", descriptor = "I") 14 | public int x; 15 | 16 | @OriginalMember(owner = "client!k", name = "c", descriptor = "I") 17 | public int z; 18 | 19 | @OriginalMember(owner = "client!k", name = "d", descriptor = "Lclient!eb;") 20 | public Model topObj; 21 | 22 | @OriginalMember(owner = "client!k", name = "e", descriptor = "Lclient!eb;") 23 | public Model bottomObj; 24 | 25 | @OriginalMember(owner = "client!k", name = "f", descriptor = "Lclient!eb;") 26 | public Model middleObj; 27 | 28 | @OriginalMember(owner = "client!k", name = "g", descriptor = "I") 29 | public int bitset; 30 | 31 | @OriginalMember(owner = "client!k", name = "h", descriptor = "I") 32 | public int offset; 33 | } 34 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/type/Location.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.type; 2 | 3 | import jagex2.dash3d.entity.Entity; 4 | import jagex2.graphics.Model; 5 | import org.openrs2.deob.annotation.OriginalClass; 6 | import org.openrs2.deob.annotation.OriginalMember; 7 | 8 | @OriginalClass("client!p") 9 | public class Location { 10 | 11 | @OriginalMember(owner = "client!p", name = "a", descriptor = "I") 12 | public int level; 13 | 14 | @OriginalMember(owner = "client!p", name = "b", descriptor = "I") 15 | public int y; 16 | 17 | @OriginalMember(owner = "client!p", name = "c", descriptor = "I") 18 | public int x; 19 | 20 | @OriginalMember(owner = "client!p", name = "d", descriptor = "I") 21 | public int z; 22 | 23 | @OriginalMember(owner = "client!p", name = "e", descriptor = "Lclient!eb;") 24 | public Model model; 25 | 26 | @OriginalMember(owner = "client!p", name = "f", descriptor = "Lclient!w;") 27 | public Entity entity; 28 | 29 | @OriginalMember(owner = "client!p", name = "g", descriptor = "I") 30 | public int yaw; 31 | 32 | @OriginalMember(owner = "client!p", name = "h", descriptor = "I") 33 | public int minSceneTileX; 34 | 35 | @OriginalMember(owner = "client!p", name = "i", descriptor = "I") 36 | public int maxSceneTileX; 37 | 38 | @OriginalMember(owner = "client!p", name = "j", descriptor = "I") 39 | public int minSceneTileZ; 40 | 41 | @OriginalMember(owner = "client!p", name = "k", descriptor = "I") 42 | public int maxSceneTileZ; 43 | 44 | @OriginalMember(owner = "client!p", name = "l", descriptor = "I") 45 | public int distance; 46 | 47 | @OriginalMember(owner = "client!p", name = "m", descriptor = "I") 48 | public int cycle; 49 | 50 | @OriginalMember(owner = "client!p", name = "n", descriptor = "I") 51 | public int bitset; 52 | 53 | @OriginalMember(owner = "client!p", name = "o", descriptor = "B") 54 | public byte info; 55 | } 56 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/type/TileOverlay.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.type; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | @OriginalClass("client!i") 9 | public class TileOverlay { 10 | 11 | @OriginalMember(owner = "client!i", name = "a", descriptor = "[I") 12 | public final int[] vertexX; 13 | 14 | @OriginalMember(owner = "client!i", name = "b", descriptor = "[I") 15 | public final int[] vertexY; 16 | 17 | @OriginalMember(owner = "client!i", name = "c", descriptor = "[I") 18 | public final int[] vertexZ; 19 | 20 | @OriginalMember(owner = "client!i", name = "d", descriptor = "[I") 21 | public final int[] triangleColorA; 22 | 23 | @OriginalMember(owner = "client!i", name = "e", descriptor = "[I") 24 | public final int[] triangleColorB; 25 | 26 | @OriginalMember(owner = "client!i", name = "f", descriptor = "[I") 27 | public final int[] triangleColorC; 28 | 29 | @OriginalMember(owner = "client!i", name = "g", descriptor = "[I") 30 | public final int[] triangleVertexA; 31 | 32 | @OriginalMember(owner = "client!i", name = "h", descriptor = "[I") 33 | public final int[] triangleVertexB; 34 | 35 | @OriginalMember(owner = "client!i", name = "i", descriptor = "[I") 36 | public final int[] triangleVertexC; 37 | 38 | @OriginalMember(owner = "client!i", name = "j", descriptor = "[I") 39 | public int[] triangleTextureIds; 40 | 41 | @OriginalMember(owner = "client!i", name = "k", descriptor = "Z") 42 | public boolean flat = true; 43 | 44 | @OriginalMember(owner = "client!i", name = "l", descriptor = "I") 45 | public final int shape; 46 | 47 | @OriginalMember(owner = "client!i", name = "m", descriptor = "I") 48 | public final int rotation; 49 | 50 | @OriginalMember(owner = "client!i", name = "n", descriptor = "I") 51 | public final int backgroundRgb; 52 | 53 | @OriginalMember(owner = "client!i", name = "o", descriptor = "I") 54 | public final int foregroundRgb; 55 | 56 | @OriginalMember(owner = "client!i", name = "p", descriptor = "[I") 57 | public static final int[] tmpScreenX = new int[6]; 58 | 59 | @OriginalMember(owner = "client!i", name = "q", descriptor = "[I") 60 | public static final int[] tmpScreenY = new int[6]; 61 | 62 | @OriginalMember(owner = "client!i", name = "r", descriptor = "[I") 63 | public static final int[] tmpViewspaceX = new int[6]; 64 | 65 | @OriginalMember(owner = "client!i", name = "s", descriptor = "[I") 66 | public static final int[] tmpViewspaceY = new int[6]; 67 | 68 | @OriginalMember(owner = "client!i", name = "t", descriptor = "[I") 69 | public static final int[] tmpViewspaceZ = new int[6]; 70 | 71 | @OriginalMember(owner = "client!i", name = "x", descriptor = "[[I") 72 | public static final int[][] SHAPE_POINTS = new int[][] { 73 | { 1, 3, 5, 7 }, 74 | { 1, 3, 5, 7 }, // PLAIN_SHAPE 75 | { 1, 3, 5, 7 }, // DIAGONAL_SHAPE 76 | { 1, 3, 5, 7, 6 }, // LEFT_SEMI_DIAGONAL_SMALL_SHAPE 77 | { 1, 3, 5, 7, 6 }, // RIGHT_SEMI_DIAGONAL_SMALL_SHAPE 78 | { 1, 3, 5, 7, 6 }, // LEFT_SEMI_DIAGONAL_BIG_SHAPE 79 | { 1, 3, 5, 7, 6 }, // RIGHT_SEMI_DIAGONAL_BIG_SHAPE 80 | { 1, 3, 5, 7, 2, 6 }, // HALF_SQUARE_SHAPE 81 | { 1, 3, 5, 7, 2, 8 }, // CORNER_SMALL_SHAPE 82 | { 1, 3, 5, 7, 2, 8 }, // CORNER_BIG_SHAPE 83 | { 1, 3, 5, 7, 11, 12 }, // FAN_SMALL_SHAPE 84 | { 1, 3, 5, 7, 11, 12 }, // FAN_BIG_SHAPE 85 | { 1, 3, 5, 7, 13, 14 } // TRAPEZIUM_SHAPE 86 | }; 87 | 88 | @OriginalMember(owner = "client!i", name = "y", descriptor = "[[I") 89 | public static final int[][] SHAPE_PATHS = new int[][] { 90 | { 0, 1, 2, 3, 0, 0, 1, 3 }, 91 | { 1, 1, 2, 3, 1, 0, 1, 3 }, // PLAIN_SHAPE 92 | { 0, 1, 2, 3, 1, 0, 1, 3 }, // DIAGONAL_SHAPE 93 | { 0, 0, 1, 2, 0, 0, 2, 4, 1, 0, 4, 3 }, // LEFT_SEMI_DIAGONAL_SMALL_SHAPE 94 | { 0, 0, 1, 4, 0, 0, 4, 3, 1, 1, 2, 4 }, // RIGHT_SEMI_DIAGONAL_SMALL_SHAPE 95 | { 0, 0, 4, 3, 1, 0, 1, 2, 1, 0, 2, 4 }, // LEFT_SEMI_DIAGONAL_BIG_SHAPE 96 | { 0, 1, 2, 4, 1, 0, 1, 4, 1, 0, 4, 3 }, // RIGHT_SEMI_DIAGONAL_BIG_SHAPE 97 | { 0, 4, 1, 2, 0, 4, 2, 5, 1, 0, 4, 5, 1, 0, 5, 3 }, // HALF_SQUARE_SHAPE 98 | { 0, 4, 1, 2, 0, 4, 2, 3, 0, 4, 3, 5, 1, 0, 4, 5 }, // CORNER_SMALL_SHAPE 99 | { 0, 0, 4, 5, 1, 4, 1, 2, 1, 4, 2, 3, 1, 4, 3, 5 }, // CORNER_BIG_SHAPE 100 | { 0, 0, 1, 5, 0, 1, 4, 5, 0, 1, 2, 4, 1, 0, 5, 3, 1, 5, 4, 3, 1, 4, 2, 3 }, // FAN_SMALL_SHAPE 101 | { 1, 0, 1, 5, 1, 1, 4, 5, 1, 1, 2, 4, 0, 0, 5, 3, 0, 5, 4, 3, 0, 4, 2, 3 }, // FAN_BIG_SHAPE 102 | { 1, 0, 5, 4, 1, 0, 1, 5, 0, 0, 4, 3, 0, 4, 5, 3, 0, 5, 2, 3, 0, 1, 2, 5 } // TRAPEZIUM_SHAPE 103 | }; 104 | 105 | @OriginalMember(owner = "client!i", name = "", descriptor = "(IIIIIIIIIIIIIIIIIIII)V") 106 | public TileOverlay(@OriginalArg(0) int tileX, @OriginalArg(1) int shape, @OriginalArg(2) int southeastColor2, @OriginalArg(3) int southeastY, @OriginalArg(4) int northeastColor1, @OriginalArg(5) int rotation, @OriginalArg(6) int southwestColor1, @OriginalArg(7) int northwestY, @OriginalArg(8) int foregroundRgb, @OriginalArg(9) int southwestColor2, @OriginalArg(10) int textureId, @OriginalArg(11) int northwestColor2, @OriginalArg(12) int backgroundRgb, @OriginalArg(13) int northeastY, @OriginalArg(14) int northeastColor2, @OriginalArg(15) int northwestColor1, @OriginalArg(17) int southwestY, @OriginalArg(18) int tileZ, @OriginalArg(19) int southeastColor1) { 107 | if (southwestY != southeastY || southwestY != northeastY || southwestY != northwestY) { 108 | this.flat = false; 109 | } 110 | 111 | this.shape = shape; 112 | this.rotation = rotation; 113 | this.backgroundRgb = backgroundRgb; 114 | this.foregroundRgb = foregroundRgb; 115 | 116 | @Pc(32) short ONE = 128; 117 | @Pc(36) int HALF = ONE / 2; 118 | @Pc(40) int QUARTER = ONE / 4; 119 | @Pc(46) int THREE_QUARTER = ONE * 3 / 4; 120 | 121 | @Pc(50) int[] points = SHAPE_POINTS[shape]; 122 | @Pc(53) int vertexCount = points.length; 123 | this.vertexX = new int[vertexCount]; 124 | this.vertexY = new int[vertexCount]; 125 | this.vertexZ = new int[vertexCount]; 126 | @Pc(68) int[] primaryColors = new int[vertexCount]; 127 | @Pc(71) int[] secondaryColors = new int[vertexCount]; 128 | 129 | @Pc(75) int sceneX = tileX * ONE; 130 | @Pc(79) int sceneZ = tileZ * ONE; 131 | 132 | for (@Pc(81) int v = 0; v < vertexCount; v++) { 133 | @Pc(87) int type = points[v]; 134 | 135 | if ((type & 0x1) == 0 && type <= 8) { 136 | type = (type - rotation - rotation - 1 & 0x7) + 1; 137 | } 138 | 139 | if (type > 8 && type <= 12) { 140 | type = (type - rotation - 9 & 0x3) + 9; 141 | } 142 | 143 | if (type > 12 && type <= 16) { 144 | type = (type - rotation - 13 & 0x3) + 13; 145 | } 146 | 147 | @Pc(143) int x; 148 | @Pc(145) int z; 149 | @Pc(147) int y; 150 | @Pc(149) int color1; 151 | @Pc(151) int color2; 152 | 153 | if (type == 1) { 154 | x = sceneX; 155 | z = sceneZ; 156 | y = southwestY; 157 | color1 = southwestColor1; 158 | color2 = southwestColor2; 159 | } else if (type == 2) { 160 | x = sceneX + HALF; 161 | z = sceneZ; 162 | y = southwestY + southeastY >> 1; 163 | color1 = southwestColor1 + southeastColor1 >> 1; 164 | color2 = southwestColor2 + southeastColor2 >> 1; 165 | } else if (type == 3) { 166 | x = sceneX + ONE; 167 | z = sceneZ; 168 | y = southeastY; 169 | color1 = southeastColor1; 170 | color2 = southeastColor2; 171 | } else if (type == 4) { 172 | x = sceneX + ONE; 173 | z = sceneZ + HALF; 174 | y = southeastY + northeastY >> 1; 175 | color1 = southeastColor1 + northeastColor1 >> 1; 176 | color2 = southeastColor2 + northeastColor2 >> 1; 177 | } else if (type == 5) { 178 | x = sceneX + ONE; 179 | z = sceneZ + ONE; 180 | y = northeastY; 181 | color1 = northeastColor1; 182 | color2 = northeastColor2; 183 | } else if (type == 6) { 184 | x = sceneX + HALF; 185 | z = sceneZ + ONE; 186 | y = northeastY + northwestY >> 1; 187 | color1 = northeastColor1 + northwestColor1 >> 1; 188 | color2 = northeastColor2 + northwestColor2 >> 1; 189 | } else if (type == 7) { 190 | x = sceneX; 191 | z = sceneZ + ONE; 192 | y = northwestY; 193 | color1 = northwestColor1; 194 | color2 = northwestColor2; 195 | } else if (type == 8) { 196 | x = sceneX; 197 | z = sceneZ + HALF; 198 | y = northwestY + southwestY >> 1; 199 | color1 = northwestColor1 + southwestColor1 >> 1; 200 | color2 = northwestColor2 + southwestColor2 >> 1; 201 | } else if (type == 9) { 202 | x = sceneX + HALF; 203 | z = sceneZ + QUARTER; 204 | y = southwestY + southeastY >> 1; 205 | color1 = southwestColor1 + southeastColor1 >> 1; 206 | color2 = southwestColor2 + southeastColor2 >> 1; 207 | } else if (type == 10) { 208 | x = sceneX + THREE_QUARTER; 209 | z = sceneZ + HALF; 210 | y = southeastY + northeastY >> 1; 211 | color1 = southeastColor1 + northeastColor1 >> 1; 212 | color2 = southeastColor2 + northeastColor2 >> 1; 213 | } else if (type == 11) { 214 | x = sceneX + HALF; 215 | z = sceneZ + THREE_QUARTER; 216 | y = northeastY + northwestY >> 1; 217 | color1 = northeastColor1 + northwestColor1 >> 1; 218 | color2 = northeastColor2 + northwestColor2 >> 1; 219 | } else if (type == 12) { 220 | x = sceneX + QUARTER; 221 | z = sceneZ + HALF; 222 | y = northwestY + southwestY >> 1; 223 | color1 = northwestColor1 + southwestColor1 >> 1; 224 | color2 = northwestColor2 + southwestColor2 >> 1; 225 | } else if (type == 13) { 226 | x = sceneX + QUARTER; 227 | z = sceneZ + QUARTER; 228 | y = southwestY; 229 | color1 = southwestColor1; 230 | color2 = southwestColor2; 231 | } else if (type == 14) { 232 | x = sceneX + THREE_QUARTER; 233 | z = sceneZ + QUARTER; 234 | y = southeastY; 235 | color1 = southeastColor1; 236 | color2 = southeastColor2; 237 | } else if (type == 15) { 238 | x = sceneX + THREE_QUARTER; 239 | z = sceneZ + THREE_QUARTER; 240 | y = northeastY; 241 | color1 = northeastColor1; 242 | color2 = northeastColor2; 243 | } else { 244 | x = sceneX + QUARTER; 245 | z = sceneZ + THREE_QUARTER; 246 | y = northwestY; 247 | color1 = northwestColor1; 248 | color2 = northwestColor2; 249 | } 250 | 251 | this.vertexX[v] = x; 252 | this.vertexY[v] = y; 253 | this.vertexZ[v] = z; 254 | primaryColors[v] = color1; 255 | secondaryColors[v] = color2; 256 | } 257 | 258 | @Pc(552) int[] paths = SHAPE_PATHS[shape]; 259 | int triangleCount = paths.length / 4; 260 | this.triangleVertexA = new int[triangleCount]; 261 | this.triangleVertexB = new int[triangleCount]; 262 | this.triangleVertexC = new int[triangleCount]; 263 | this.triangleColorA = new int[triangleCount]; 264 | this.triangleColorB = new int[triangleCount]; 265 | this.triangleColorC = new int[triangleCount]; 266 | 267 | if (textureId != -1) { 268 | this.triangleTextureIds = new int[triangleCount]; 269 | } 270 | 271 | int index = 0; 272 | for (int t = 0; t < triangleCount; t++) { 273 | int color = paths[index]; 274 | int a = paths[index + 1]; 275 | @Pc(617) int b = paths[index + 2]; 276 | @Pc(623) int c = paths[index + 3]; 277 | index += 4; 278 | 279 | if (a < 4) { 280 | a = a - rotation & 0x3; 281 | } 282 | 283 | if (b < 4) { 284 | b = b - rotation & 0x3; 285 | } 286 | 287 | if (c < 4) { 288 | c = c - rotation & 0x3; 289 | } 290 | 291 | this.triangleVertexA[t] = a; 292 | this.triangleVertexB[t] = b; 293 | this.triangleVertexC[t] = c; 294 | 295 | if (color == 0) { 296 | this.triangleColorA[t] = primaryColors[a]; 297 | this.triangleColorB[t] = primaryColors[b]; 298 | this.triangleColorC[t] = primaryColors[c]; 299 | 300 | if (this.triangleTextureIds != null) { 301 | this.triangleTextureIds[t] = -1; 302 | } 303 | } else { 304 | this.triangleColorA[t] = secondaryColors[a]; 305 | this.triangleColorB[t] = secondaryColors[b]; 306 | this.triangleColorC[t] = secondaryColors[c]; 307 | 308 | if (this.triangleTextureIds != null) { 309 | this.triangleTextureIds[t] = textureId; 310 | } 311 | } 312 | } 313 | } 314 | } 315 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/type/TileUnderlay.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.type; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | 7 | @OriginalClass("client!o") 8 | public class TileUnderlay { 9 | 10 | @OriginalMember(owner = "client!o", name = "a", descriptor = "I") 11 | public final int southwestColor; 12 | 13 | @OriginalMember(owner = "client!o", name = "b", descriptor = "I") 14 | public final int southeastColor; 15 | 16 | @OriginalMember(owner = "client!o", name = "c", descriptor = "I") 17 | public final int northeastColor; 18 | 19 | @OriginalMember(owner = "client!o", name = "d", descriptor = "I") 20 | public final int northwestColor; 21 | 22 | @OriginalMember(owner = "client!o", name = "e", descriptor = "I") 23 | public final int textureId; 24 | 25 | @OriginalMember(owner = "client!o", name = "f", descriptor = "Z") 26 | public boolean flat = true; 27 | 28 | @OriginalMember(owner = "client!o", name = "g", descriptor = "I") 29 | public final int rgb; 30 | 31 | @OriginalMember(owner = "client!o", name = "", descriptor = "(IIIIIIZ)V") 32 | public TileUnderlay(@OriginalArg(0) int southwestColor, @OriginalArg(1) int southeastColor, @OriginalArg(2) int northeastColor, @OriginalArg(3) int northwestColor, @OriginalArg(4) int textureId, @OriginalArg(5) int rgb, @OriginalArg(6) boolean flat) { 33 | this.southwestColor = southwestColor; 34 | this.southeastColor = southeastColor; 35 | this.northeastColor = northeastColor; 36 | this.northwestColor = northwestColor; 37 | this.textureId = textureId; 38 | this.rgb = rgb; 39 | this.flat = flat; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/dash3d/type/Wall.java: -------------------------------------------------------------------------------- 1 | package jagex2.dash3d.type; 2 | 3 | import jagex2.graphics.Model; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | 7 | @OriginalClass("client!q") 8 | public class Wall { 9 | 10 | @OriginalMember(owner = "client!q", name = "a", descriptor = "I") 11 | public int y; 12 | 13 | @OriginalMember(owner = "client!q", name = "b", descriptor = "I") 14 | public int x; 15 | 16 | @OriginalMember(owner = "client!q", name = "c", descriptor = "I") 17 | public int z; 18 | 19 | @OriginalMember(owner = "client!q", name = "d", descriptor = "I") 20 | public int typeA; 21 | 22 | @OriginalMember(owner = "client!q", name = "e", descriptor = "I") 23 | public int typeB; 24 | 25 | @OriginalMember(owner = "client!q", name = "f", descriptor = "Lclient!eb;") 26 | public Model modelA; 27 | 28 | @OriginalMember(owner = "client!q", name = "g", descriptor = "Lclient!eb;") 29 | public Model modelB; 30 | 31 | @OriginalMember(owner = "client!q", name = "h", descriptor = "I") 32 | public int bitset; 33 | 34 | @OriginalMember(owner = "client!q", name = "i", descriptor = "B") 35 | public byte info; 36 | } 37 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/datastruct/DoublyLinkList.java: -------------------------------------------------------------------------------- 1 | package jagex2.datastruct; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | @OriginalClass("client!pb") 9 | public class DoublyLinkList { 10 | 11 | @OriginalMember(owner = "client!pb", name = "d", descriptor = "Lclient!db;") 12 | private final DoublyLinkable head = new DoublyLinkable(); 13 | 14 | @OriginalMember(owner = "client!pb", name = "", descriptor = "(I)V") 15 | public DoublyLinkList() { 16 | this.head.next2 = this.head; 17 | this.head.prev2 = this.head; 18 | } 19 | 20 | @OriginalMember(owner = "client!pb", name = "a", descriptor = "(Lclient!db;)V") 21 | public void push(@OriginalArg(0) DoublyLinkable node) { 22 | if (node.prev2 != null) { 23 | node.uncache(); 24 | } 25 | 26 | node.prev2 = this.head.prev2; 27 | node.next2 = this.head; 28 | node.prev2.next2 = node; 29 | node.next2.prev2 = node; 30 | } 31 | 32 | @OriginalMember(owner = "client!pb", name = "a", descriptor = "()Lclient!db;") 33 | public DoublyLinkable pop() { 34 | @Pc(3) DoublyLinkable node = this.head.next2; 35 | if (node == this.head) { 36 | return null; 37 | } else { 38 | node.uncache(); 39 | return node; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/datastruct/DoublyLinkable.java: -------------------------------------------------------------------------------- 1 | package jagex2.datastruct; 2 | 3 | import org.openrs2.deob.annotation.OriginalClass; 4 | import org.openrs2.deob.annotation.OriginalMember; 5 | 6 | @OriginalClass("client!db") 7 | public class DoublyLinkable extends Linkable { 8 | 9 | @OriginalMember(owner = "client!db", name = "e", descriptor = "Lclient!db;") 10 | public DoublyLinkable next2; 11 | 12 | @OriginalMember(owner = "client!db", name = "f", descriptor = "Lclient!db;") 13 | public DoublyLinkable prev2; 14 | 15 | @OriginalMember(owner = "client!db", name = "b", descriptor = "()V") 16 | public final void uncache() { 17 | if (this.prev2 != null) { 18 | this.prev2.next2 = this.next2; 19 | this.next2.prev2 = this.prev2; 20 | this.next2 = null; 21 | this.prev2 = null; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/datastruct/HashTable.java: -------------------------------------------------------------------------------- 1 | package jagex2.datastruct; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | // name taken from jaclib 9 | @OriginalClass("client!t") 10 | public class HashTable { 11 | 12 | @OriginalMember(owner = "client!t", name = "c", descriptor = "I") 13 | private final int bucketCount; 14 | 15 | @OriginalMember(owner = "client!t", name = "d", descriptor = "[Lclient!u;") 16 | private final Linkable[] buckets; 17 | 18 | @OriginalMember(owner = "client!t", name = "", descriptor = "(II)V") 19 | public HashTable(@OriginalArg(1) int size) { 20 | this.buckets = new Linkable[size]; 21 | this.bucketCount = size; 22 | 23 | for (@Pc(30) int i = 0; i < size; i++) { 24 | @Pc(40) Linkable sentinel = this.buckets[i] = new Linkable(); 25 | sentinel.next = sentinel; 26 | sentinel.prev = sentinel; 27 | } 28 | } 29 | 30 | @OriginalMember(owner = "client!t", name = "a", descriptor = "(J)Lclient!u;") 31 | public Linkable get(@OriginalArg(0) long key) { 32 | @Pc(11) Linkable sentinel = this.buckets[(int) (key & (long) (this.bucketCount - 1))]; 33 | 34 | for (@Pc(14) Linkable node = sentinel.next; node != sentinel; node = node.next) { 35 | if (node.key == key) { 36 | return node; 37 | } 38 | } 39 | 40 | return null; 41 | } 42 | 43 | @OriginalMember(owner = "client!t", name = "a", descriptor = "(JILclient!u;)V") 44 | public void put(@OriginalArg(0) long key, @OriginalArg(2) Linkable value) { 45 | if (value.prev != null) { 46 | value.unlink(); 47 | } 48 | 49 | @Pc(18) Linkable sentinel = this.buckets[(int) (key & (long) (this.bucketCount - 1))]; 50 | value.prev = sentinel.prev; 51 | value.next = sentinel; 52 | value.prev.next = value; 53 | value.next.prev = value; 54 | value.key = key; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/datastruct/JString.java: -------------------------------------------------------------------------------- 1 | package jagex2.datastruct; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | // name and packaging confirmed 100% in rs2/mapview applet strings 9 | // later repackaged under jagex2/jstring 10 | @OriginalClass("client!vb") 11 | public class JString { 12 | 13 | @OriginalMember(owner = "client!vb", name = "f", descriptor = "[C") 14 | private static final char[] builder = new char[12]; 15 | 16 | @OriginalMember(owner = "client!vb", name = "g", descriptor = "[C") 17 | private static final char[] BASE37_LOOKUP = new char[] { 18 | '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 19 | 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 20 | 't', 'u', 'v', 'w', 'x', 'y', 'z', 21 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' 22 | }; 23 | 24 | @OriginalMember(owner = "client!vb", name = "a", descriptor = "(Ljava/lang/String;)J") 25 | public static long toBase37(@OriginalArg(0) String str) { 26 | @Pc(3) long hash = 0L; 27 | 28 | for (@Pc(5) int i = 0; i < str.length() && i < 12; i++) { 29 | @Pc(11) char c = str.charAt(i); 30 | hash *= 37L; 31 | 32 | if (c >= 'A' && c <= 'Z') { 33 | hash += c + 1 - 65; 34 | } else if (c >= 'a' && c <= 'z') { 35 | hash += c + 1 - 97; 36 | } else if (c >= '0' && c <= '9') { 37 | hash += c + 27 - 48; 38 | } 39 | } 40 | 41 | while (hash % 37L == 0L && hash != 0L) { 42 | hash /= 37L; 43 | } 44 | 45 | return hash; 46 | } 47 | 48 | @OriginalMember(owner = "client!vb", name = "a", descriptor = "(JZ)Ljava/lang/String;") 49 | public static String fromBase37(@OriginalArg(0) long username) { 50 | // >= 37 to the 12th power 51 | if (username <= 0L || username >= 6582952005840035281L) { 52 | return "invalid_name"; 53 | } 54 | 55 | if (username % 37L == 0L) { 56 | return "invalid_name"; 57 | } 58 | 59 | @Pc(19) int len = 0; 60 | while (username != 0L) { 61 | @Pc(27) long last = username; 62 | username /= 37L; 63 | builder[11 - len++] = BASE37_LOOKUP[(int) (last - username * 37L)]; 64 | } 65 | 66 | return new String(builder, 12 - len, len); 67 | } 68 | 69 | @OriginalMember(owner = "client!vb", name = "a", descriptor = "(ILjava/lang/String;)J") 70 | public static long hashCode(@OriginalArg(1) String str) { 71 | @Pc(8) String upper = str.toUpperCase(); 72 | @Pc(10) long hash = 0L; 73 | 74 | for (@Pc(12) int i = 0; i < upper.length(); i++) { 75 | hash = hash * 61L + (long) upper.charAt(i) - 32L; 76 | hash = hash + (hash >> 56) & 0xFFFFFFFFFFFFFFL; 77 | } 78 | 79 | return hash; 80 | } 81 | 82 | @OriginalMember(owner = "client!vb", name = "a", descriptor = "(II)Ljava/lang/String;") 83 | public static String formatIPv4(@OriginalArg(1) int ip) { 84 | return (ip >> 24 & 0xFF) + "." + (ip >> 16 & 0xFF) + "." + (ip >> 8 & 0xFF) + "." + (ip & 0xFF); 85 | } 86 | 87 | @OriginalMember(owner = "client!vb", name = "b", descriptor = "(ILjava/lang/String;)Ljava/lang/String;") 88 | public static String formatName(@OriginalArg(1) String str) { 89 | if (str.length() == 0) { 90 | return str; 91 | } 92 | 93 | @Pc(11) char[] chars = str.toCharArray(); 94 | for (@Pc(13) int i = 0; i < chars.length; i++) { 95 | if (chars[i] == '_') { 96 | chars[i] = ' '; 97 | 98 | if (i + 1 < chars.length && chars[i + 1] >= 'a' && chars[i + 1] <= 'z') { 99 | chars[i + 1] = (char) (chars[i + 1] + 'A' - 97); 100 | } 101 | } 102 | } 103 | 104 | if (chars[0] >= 'a' && chars[0] <= 'z') { 105 | chars[0] = (char) (chars[0] + 'A' - 97); 106 | } 107 | 108 | return new String(chars); 109 | } 110 | 111 | @OriginalMember(owner = "client!vb", name = "a", descriptor = "(Ljava/lang/String;I)Ljava/lang/String;") 112 | public static String toSentenceCase(@OriginalArg(0) String str) { 113 | @Pc(2) String lower = str.toLowerCase(); 114 | @Pc(9) char[] chars = lower.toCharArray(); 115 | @Pc(12) int length = chars.length; 116 | @Pc(14) boolean capitalize = true; 117 | 118 | for (@Pc(16) int i = 0; i < length; i++) { 119 | @Pc(22) char c = chars[i]; 120 | 121 | if (capitalize && c >= 'a' && c <= 'z') { 122 | chars[i] = (char) (chars[i] - 32); 123 | capitalize = false; 124 | } 125 | 126 | if (c == '.' || c == '!') { 127 | capitalize = true; 128 | } 129 | } 130 | 131 | return new String(chars); 132 | } 133 | 134 | @OriginalMember(owner = "client!vb", name = "c", descriptor = "(ILjava/lang/String;)Ljava/lang/String;") 135 | public static String toAsterisks(@OriginalArg(1) String str) { 136 | @Pc(1) String temp = ""; 137 | for (@Pc(10) int i = 0; i < str.length(); i++) { 138 | temp = temp + "*"; 139 | } 140 | return temp; 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/datastruct/LinkList.java: -------------------------------------------------------------------------------- 1 | package jagex2.datastruct; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | // name taken from jaclib 9 | @OriginalClass("client!ob") 10 | public class LinkList { 11 | 12 | @OriginalMember(owner = "client!ob", name = "e", descriptor = "Lclient!u;") 13 | private final Linkable sentinel = new Linkable(); 14 | 15 | @OriginalMember(owner = "client!ob", name = "f", descriptor = "Lclient!u;") 16 | private Linkable cursor; 17 | 18 | @OriginalMember(owner = "client!ob", name = "", descriptor = "(I)V") 19 | public LinkList() { 20 | this.sentinel.next = this.sentinel; 21 | this.sentinel.prev = this.sentinel; 22 | } 23 | 24 | @OriginalMember(owner = "client!ob", name = "a", descriptor = "(Lclient!u;)V") 25 | public void addTail(@OriginalArg(0) Linkable node) { 26 | if (node.prev != null) { 27 | node.unlink(); 28 | } 29 | 30 | node.prev = this.sentinel.prev; 31 | node.next = this.sentinel; 32 | node.prev.next = node; 33 | node.next.prev = node; 34 | } 35 | 36 | @OriginalMember(owner = "client!ob", name = "a", descriptor = "(Lclient!u;I)V") 37 | public void addHead(@OriginalArg(0) Linkable node) { 38 | if (node.prev != null) { 39 | node.unlink(); 40 | } 41 | 42 | node.prev = this.sentinel; 43 | node.next = this.sentinel.next; 44 | node.prev.next = node; 45 | node.next.prev = node; 46 | } 47 | 48 | @OriginalMember(owner = "client!ob", name = "a", descriptor = "()Lclient!u;") 49 | public Linkable removeHead() { 50 | @Pc(3) Linkable node = this.sentinel.next; 51 | if (node == this.sentinel) { 52 | return null; 53 | } 54 | node.unlink(); 55 | return node; 56 | } 57 | 58 | @OriginalMember(owner = "client!ob", name = "b", descriptor = "()Lclient!u;") 59 | public Linkable head() { 60 | @Pc(3) Linkable node = this.sentinel.next; 61 | if (node == this.sentinel) { 62 | this.cursor = null; 63 | return null; 64 | } 65 | this.cursor = node.next; 66 | return node; 67 | } 68 | 69 | @OriginalMember(owner = "client!ob", name = "a", descriptor = "(B)Lclient!u;") 70 | public Linkable tail() { 71 | @Pc(3) Linkable node = this.sentinel.prev; 72 | if (node == this.sentinel) { 73 | this.cursor = null; 74 | return null; 75 | } 76 | this.cursor = node.prev; 77 | return node; 78 | } 79 | 80 | @OriginalMember(owner = "client!ob", name = "a", descriptor = "(I)Lclient!u;") 81 | public Linkable next() { 82 | @Pc(8) Linkable node = this.cursor; 83 | if (node == this.sentinel) { 84 | this.cursor = null; 85 | return null; 86 | } 87 | this.cursor = node.next; 88 | return node; 89 | } 90 | 91 | @OriginalMember(owner = "client!ob", name = "a", descriptor = "(Z)Lclient!u;") 92 | public Linkable prev() { 93 | @Pc(2) Linkable node = this.cursor; 94 | if (node == this.sentinel) { 95 | this.cursor = null; 96 | return null; 97 | } 98 | this.cursor = node.prev; 99 | return node; 100 | } 101 | 102 | @OriginalMember(owner = "client!ob", name = "c", descriptor = "()V") 103 | public void clear() { 104 | while (true) { 105 | @Pc(3) Linkable node = this.sentinel.next; 106 | if (node == this.sentinel) { 107 | return; 108 | } 109 | node.unlink(); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/datastruct/Linkable.java: -------------------------------------------------------------------------------- 1 | package jagex2.datastruct; 2 | 3 | import org.openrs2.deob.annotation.OriginalClass; 4 | import org.openrs2.deob.annotation.OriginalMember; 5 | 6 | // name and packaging confirmed 100% in rs2/mapview applet strings 7 | @OriginalClass("client!u") 8 | public class Linkable { 9 | 10 | @OriginalMember(owner = "client!u", name = "a", descriptor = "J") 11 | public long key; 12 | 13 | @OriginalMember(owner = "client!u", name = "b", descriptor = "Lclient!u;") 14 | public Linkable next; 15 | 16 | @OriginalMember(owner = "client!u", name = "c", descriptor = "Lclient!u;") 17 | public Linkable prev; 18 | 19 | @OriginalMember(owner = "client!u", name = "a", descriptor = "()V") 20 | public final void unlink() { 21 | if (this.prev != null) { 22 | this.prev.next = this.next; 23 | this.next.prev = this.prev; 24 | this.next = null; 25 | this.prev = null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/datastruct/LruCache.java: -------------------------------------------------------------------------------- 1 | package jagex2.datastruct; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | @OriginalClass("client!s") 9 | public class LruCache { 10 | 11 | @OriginalMember(owner = "client!s", name = "c", descriptor = "I") 12 | private final int capacity; 13 | 14 | @OriginalMember(owner = "client!s", name = "d", descriptor = "I") 15 | private int available; 16 | 17 | @OriginalMember(owner = "client!s", name = "e", descriptor = "Lclient!t;") 18 | private final HashTable hashtable = new HashTable(1024); 19 | 20 | @OriginalMember(owner = "client!s", name = "f", descriptor = "Lclient!pb;") 21 | private final DoublyLinkList history = new DoublyLinkList(); 22 | 23 | @OriginalMember(owner = "client!s", name = "", descriptor = "(BI)V") 24 | public LruCache(@OriginalArg(1) int size) { 25 | this.capacity = size; 26 | this.available = size; 27 | } 28 | 29 | @OriginalMember(owner = "client!s", name = "a", descriptor = "(J)Lclient!db;") 30 | public DoublyLinkable get(@OriginalArg(0) long key) { 31 | @Pc(5) DoublyLinkable node = (DoublyLinkable) this.hashtable.get(key); 32 | if (node != null) { 33 | this.history.push(node); 34 | } 35 | 36 | return node; 37 | } 38 | 39 | @OriginalMember(owner = "client!s", name = "a", descriptor = "(IJLclient!db;)V") 40 | public void put(@OriginalArg(1) long key, @OriginalArg(2) DoublyLinkable value) { 41 | if (this.available == 0) { 42 | @Pc(8) DoublyLinkable node = this.history.pop(); 43 | node.unlink(); 44 | node.uncache(); 45 | } else { 46 | this.available--; 47 | } 48 | 49 | this.hashtable.put(key, value); 50 | this.history.push(value); 51 | } 52 | 53 | @OriginalMember(owner = "client!s", name = "a", descriptor = "()V") 54 | public void clear() { 55 | while (true) { 56 | @Pc(3) DoublyLinkable node = this.history.pop(); 57 | if (node == null) { 58 | this.available = this.capacity; 59 | return; 60 | } 61 | 62 | node.unlink(); 63 | node.uncache(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/graphics/AnimBase.java: -------------------------------------------------------------------------------- 1 | package jagex2.graphics; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | import jagex2.io.Jagfile; 9 | import jagex2.io.Packet; 10 | 11 | // name taken from runetek5 12 | @OriginalClass("client!f") 13 | public class AnimBase { 14 | 15 | public static final int OP_BASE = 0; 16 | public static final int OP_TRANSLATE = 1; 17 | public static final int OP_ROTATE = 2; 18 | public static final int OP_SCALE = 3; 19 | public static final int OP_ALPHA = 5; 20 | 21 | @OriginalMember(owner = "client!f", name = "a", descriptor = "[Lclient!f;") 22 | public static AnimBase[] instances; 23 | 24 | @OriginalMember(owner = "client!f", name = "b", descriptor = "I") 25 | public int length; 26 | 27 | // an operation for a specific group - [group] 28 | @OriginalMember(owner = "client!f", name = "c", descriptor = "[I") 29 | public int[] types; 30 | 31 | // labels for a specific group - [group] [label] 32 | @OriginalMember(owner = "client!f", name = "d", descriptor = "[[I") 33 | public int[][] labels; 34 | 35 | @OriginalMember(owner = "client!f", name = "a", descriptor = "(ZLclient!ub;)V") 36 | public static void unpack(@OriginalArg(1) Jagfile models) { 37 | @Pc(11) Packet head = new Packet(models.read("base_head.dat", null)); 38 | @Pc(21) Packet type = new Packet(models.read("base_type.dat", null)); 39 | @Pc(31) Packet label = new Packet(models.read("base_label.dat", null)); 40 | 41 | @Pc(34) int total = head.g2(); 42 | @Pc(37) int count = head.g2(); 43 | instances = new AnimBase[count + 1]; 44 | 45 | for (@Pc(50) int i = 0; i < total; i++) { 46 | @Pc(55) int id = head.g2(); 47 | @Pc(58) int length = head.g1(); 48 | 49 | @Pc(61) int[] types = new int[length]; 50 | @Pc(64) int[][] labels = new int[length][]; 51 | 52 | for (@Pc(66) int g = 0; g < length; g++) { 53 | types[g] = type.g1(); 54 | 55 | @Pc(76) int labelCount = label.g1(); 56 | labels[g] = new int[labelCount]; 57 | 58 | for (@Pc(83) int l = 0; l < labelCount; l++) { 59 | labels[g][l] = label.g1(); 60 | } 61 | } 62 | 63 | instances[id] = new AnimBase(); 64 | instances[id].length = length; 65 | instances[id].types = types; 66 | instances[id].labels = labels; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/graphics/AnimFrame.java: -------------------------------------------------------------------------------- 1 | package jagex2.graphics; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | import jagex2.io.Jagfile; 9 | import jagex2.io.Packet; 10 | 11 | // name taken from runetek5 12 | @OriginalClass("client!g") 13 | public class AnimFrame { 14 | 15 | @OriginalMember(owner = "client!g", name = "a", descriptor = "[Lclient!g;") 16 | public static AnimFrame[] instances; 17 | 18 | @OriginalMember(owner = "client!g", name = "b", descriptor = "I") 19 | public int delay; 20 | 21 | @OriginalMember(owner = "client!g", name = "c", descriptor = "Lclient!f;") 22 | public AnimBase base; 23 | 24 | @OriginalMember(owner = "client!g", name = "d", descriptor = "I") 25 | public int length; 26 | 27 | // groups to use from base 28 | @OriginalMember(owner = "client!g", name = "e", descriptor = "[I") 29 | public int[] groups; 30 | 31 | // x adjustment for group 32 | @OriginalMember(owner = "client!g", name = "f", descriptor = "[I") 33 | public int[] x; 34 | 35 | // y adjustment for group 36 | @OriginalMember(owner = "client!g", name = "g", descriptor = "[I") 37 | public int[] y; 38 | 39 | // z adjustment for group 40 | @OriginalMember(owner = "client!g", name = "h", descriptor = "[I") 41 | public int[] z; 42 | 43 | @OriginalMember(owner = "client!g", name = "a", descriptor = "(ZLclient!ub;)V") 44 | public static void unpack(@OriginalArg(1) Jagfile models) { 45 | @Pc(17) Packet head = new Packet(models.read("frame_head.dat", null)); 46 | @Pc(27) Packet tran1 = new Packet(models.read("frame_tran1.dat", null)); 47 | @Pc(37) Packet tran2 = new Packet(models.read("frame_tran2.dat", null)); 48 | @Pc(47) Packet del = new Packet(models.read("frame_del.dat", null)); 49 | 50 | @Pc(50) int total = head.g2(); 51 | @Pc(53) int count = head.g2(); 52 | instances = new AnimFrame[count + 1]; 53 | 54 | @Pc(61) int[] groups = new int[500]; 55 | @Pc(64) int[] x = new int[500]; 56 | @Pc(67) int[] y = new int[500]; 57 | @Pc(70) int[] z = new int[500]; 58 | 59 | for (@Pc(72) int i = 0; i < total; i++) { 60 | @Pc(77) int id = head.g2(); 61 | @Pc(85) AnimFrame frame = instances[id] = new AnimFrame(); 62 | frame.delay = del.g1(); 63 | 64 | @Pc(92) int baseId = head.g2(); 65 | @Pc(96) AnimBase base = AnimBase.instances[baseId]; 66 | frame.base = base; 67 | 68 | @Pc(102) int groupCount = head.g1(); 69 | @Pc(104) int lastGroup = -1; 70 | @Pc(106) int current = 0; 71 | 72 | for (@Pc(108) int j = 0; j < groupCount; j++) { 73 | int flags = tran1.g1(); 74 | 75 | if (flags > 0) { 76 | if (base.types[j] != AnimBase.OP_BASE) { 77 | for (@Pc(124) int group = j - 1; group > lastGroup; group--) { 78 | if (base.types[group] == AnimBase.OP_BASE) { 79 | groups[current] = group; 80 | x[current] = 0; 81 | y[current] = 0; 82 | z[current] = 0; 83 | current++; 84 | break; 85 | } 86 | } 87 | } 88 | 89 | groups[current] = j; 90 | 91 | @Pc(160) short defaultValue = 0; 92 | if (base.types[groups[current]] == AnimBase.OP_SCALE) { 93 | defaultValue = 128; 94 | } 95 | 96 | if ((flags & 0x1) == 0) { 97 | x[current] = defaultValue; 98 | } else { 99 | x[current] = tran2.gsmart(); 100 | } 101 | 102 | if ((flags & 0x2) == 0) { 103 | y[current] = defaultValue; 104 | } else { 105 | y[current] = tran2.gsmart(); 106 | } 107 | 108 | if ((flags & 0x4) == 0) { 109 | z[current] = defaultValue; 110 | } else { 111 | z[current] = tran2.gsmart(); 112 | } 113 | 114 | lastGroup = j; 115 | current++; 116 | } 117 | } 118 | 119 | frame.length = current; 120 | frame.groups = new int[current]; 121 | frame.x = new int[current]; 122 | frame.y = new int[current]; 123 | frame.z = new int[current]; 124 | 125 | for (int j = 0; j < current; j++) { 126 | frame.groups[j] = groups[j]; 127 | frame.x[j] = x[j]; 128 | frame.y[j] = y[j]; 129 | frame.z[j] = z[j]; 130 | } 131 | } 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/graphics/Pix2D.java: -------------------------------------------------------------------------------- 1 | package jagex2.graphics; 2 | 3 | import jagex2.datastruct.DoublyLinkable; 4 | import org.openrs2.deob.annotation.OriginalArg; 5 | import org.openrs2.deob.annotation.OriginalClass; 6 | import org.openrs2.deob.annotation.OriginalMember; 7 | import org.openrs2.deob.annotation.Pc; 8 | 9 | // name taken from osrs 10 | @OriginalClass("client!fb") 11 | public class Pix2D extends DoublyLinkable { 12 | 13 | @OriginalMember(owner = "client!fb", name = "k", descriptor = "[I") 14 | public static int[] data; 15 | 16 | @OriginalMember(owner = "client!fb", name = "l", descriptor = "I") 17 | public static int width2d; 18 | 19 | @OriginalMember(owner = "client!fb", name = "m", descriptor = "I") 20 | public static int height2d; 21 | 22 | @OriginalMember(owner = "client!fb", name = "n", descriptor = "I") 23 | public static int boundTop; 24 | 25 | @OriginalMember(owner = "client!fb", name = "o", descriptor = "I") 26 | public static int boundBottom; 27 | 28 | @OriginalMember(owner = "client!fb", name = "p", descriptor = "I") 29 | public static int boundLeft; 30 | 31 | @OriginalMember(owner = "client!fb", name = "q", descriptor = "I") 32 | public static int boundRight; 33 | 34 | @OriginalMember(owner = "client!fb", name = "r", descriptor = "I") 35 | public static int safeWidth; 36 | 37 | @OriginalMember(owner = "client!fb", name = "s", descriptor = "I") 38 | public static int centerW2D; 39 | 40 | @OriginalMember(owner = "client!fb", name = "t", descriptor = "I") 41 | public static int centerH2D; 42 | 43 | @OriginalMember(owner = "client!fb", name = "", descriptor = "()V") 44 | protected Pix2D() { 45 | } 46 | 47 | @OriginalMember(owner = "client!fb", name = "a", descriptor = "(I[III)V") 48 | public static void bind(@OriginalArg(0) int width, @OriginalArg(3) int height, @OriginalArg(1) int[] src) { 49 | data = src; 50 | width2d = width; 51 | height2d = height; 52 | setClipping(height, width, 0, 0); 53 | } 54 | 55 | @OriginalMember(owner = "client!fb", name = "a", descriptor = "(I)V") 56 | public static void resetClipping() { 57 | boundLeft = 0; 58 | boundTop = 0; 59 | boundRight = width2d; 60 | boundBottom = height2d; 61 | safeWidth = boundRight - 1; 62 | centerW2D = boundRight / 2; 63 | } 64 | 65 | @OriginalMember(owner = "client!fb", name = "a", descriptor = "(IIIII)V") 66 | public static void setClipping(@OriginalArg(0) int bottom, @OriginalArg(2) int right, @OriginalArg(1) int top, @OriginalArg(4) int left) { 67 | if (left < 0) { 68 | left = 0; 69 | } 70 | 71 | if (top < 0) { 72 | top = 0; 73 | } 74 | 75 | if (right > width2d) { 76 | right = width2d; 77 | } 78 | 79 | if (bottom > height2d) { 80 | bottom = height2d; 81 | } 82 | 83 | Pix2D.boundLeft = left; 84 | Pix2D.boundTop = top; 85 | Pix2D.boundRight = right; 86 | Pix2D.boundBottom = bottom; 87 | safeWidth = Pix2D.boundRight - 1; 88 | centerW2D = Pix2D.boundRight / 2; 89 | centerH2D = Pix2D.boundBottom / 2; 90 | } 91 | 92 | @OriginalMember(owner = "client!fb", name = "b", descriptor = "(I)V") 93 | public static void clear() { 94 | @Pc(7) int len = width2d * height2d; 95 | for (@Pc(9) int i = 0; i < len; i++) { 96 | data[i] = 0; 97 | } 98 | } 99 | 100 | @OriginalMember(owner = "client!fb", name = "a", descriptor = "(IIIBII)V") 101 | public static void fillRect(@OriginalArg(1) int x, @OriginalArg(0) int y, @OriginalArg(2) int rgb, @OriginalArg(4) int width, @OriginalArg(5) int height) { 102 | if (x < boundLeft) { 103 | width -= boundLeft - x; 104 | x = boundLeft; 105 | } 106 | 107 | if (y < boundTop) { 108 | height -= boundTop - y; 109 | y = boundTop; 110 | } 111 | 112 | if (x + width > boundRight) { 113 | width = boundRight - x; 114 | } 115 | 116 | if (y + height > boundBottom) { 117 | height = boundBottom - y; 118 | } 119 | 120 | @Pc(50) int step = width2d - width; 121 | @Pc(56) int offset = x + y * width2d; 122 | for (@Pc(59) int i = -height; i < 0; i++) { 123 | for (@Pc(64) int j = -width; j < 0; j++) { 124 | data[offset++] = rgb; 125 | } 126 | 127 | offset += step; 128 | } 129 | } 130 | 131 | @OriginalMember(owner = "mapview!f", name = "a", descriptor = "(IIIIII)V") 132 | public static void fillRectTrans(@OriginalArg(0) int x, @OriginalArg(1) int y, @OriginalArg(2) int width, @OriginalArg(3) int height, @OriginalArg(4) int rgb, @OriginalArg(5) int alpha) { 133 | if (x < boundLeft) { 134 | width -= boundLeft - x; 135 | x = boundLeft; 136 | } 137 | 138 | if (y < boundTop) { 139 | height -= boundTop - y; 140 | y = boundTop; 141 | } 142 | 143 | if (x + width > boundRight) { 144 | width = boundRight - x; 145 | } 146 | 147 | if (y + height > boundBottom) { 148 | height = boundBottom - y; 149 | } 150 | 151 | @Pc(45) int invAlpha = 256 - alpha; 152 | @Pc(53) int r0 = (rgb >> 16 & 0xFF) * alpha; 153 | @Pc(61) int g0 = (rgb >> 8 & 0xFF) * alpha; 154 | @Pc(67) int b0 = (rgb & 0xFF) * alpha; 155 | @Pc(71) int step = width2d - width; 156 | @Pc(77) int offset = x + y * width2d; 157 | for (@Pc(79) int i = 0; i < height; i++) { 158 | for (@Pc(84) int j = -width; j < 0; j++) { 159 | @Pc(96) int r1 = (data[offset] >> 16 & 0xFF) * invAlpha; 160 | @Pc(106) int g1 = (data[offset] >> 8 & 0xFF) * invAlpha; 161 | @Pc(114) int b1 = (data[offset] & 0xFF) * invAlpha; 162 | @Pc(136) int color = (r0 + r1 >> 8 << 16) + (g0 + g1 >> 8 << 8) + (b0 + b1 >> 8); 163 | data[offset++] = color; 164 | } 165 | 166 | offset += step; 167 | } 168 | } 169 | 170 | @OriginalMember(owner = "mapview!f", name = "c", descriptor = "(IIIII)V") 171 | public static void fillCircleTrans(@OriginalArg(0) int xCenter, @OriginalArg(1) int yCenter, @OriginalArg(2) int yRadius, @OriginalArg(3) int rgb, @OriginalArg(4) int alpha) { 172 | @Pc(5) int invAlpha = 256 - alpha; 173 | @Pc(13) int r0 = (rgb >> 16 & 0xFF) * alpha; 174 | @Pc(21) int g0 = (rgb >> 8 & 0xFF) * alpha; 175 | @Pc(27) int b0 = (rgb & 0xFF) * alpha; 176 | @Pc(31) int yStart = yCenter - yRadius; 177 | if (yStart < 0) { 178 | yStart = 0; 179 | } 180 | 181 | @Pc(39) int yEnd = yCenter + yRadius; 182 | if (yEnd >= height2d) { 183 | yEnd = height2d - 1; 184 | } 185 | 186 | for (@Pc(48) int y = yStart; y <= yEnd; y++) { 187 | @Pc(54) int midpoint = y - yCenter; 188 | @Pc(65) int xRadius = (int) Math.sqrt((yRadius * yRadius) - (midpoint * midpoint)); 189 | @Pc(69) int xStart = xCenter - xRadius; 190 | if (xStart < 0) { 191 | xStart = 0; 192 | } 193 | 194 | @Pc(77) int xEnd = xCenter + xRadius; 195 | if (xEnd >= width2d) { 196 | xEnd = width2d - 1; 197 | } 198 | 199 | @Pc(90) int offset = xStart + y * width2d; 200 | for (@Pc(92) int x = xStart; x <= xEnd; x++) { 201 | @Pc(104) int r1 = (data[offset] >> 16 & 0xFF) * invAlpha; 202 | @Pc(114) int g1 = (data[offset] >> 8 & 0xFF) * invAlpha; 203 | @Pc(122) int b1 = (data[offset] & 0xFF) * invAlpha; 204 | @Pc(144) int color = (r0 + r1 >> 8 << 16) + (g0 + g1 >> 8 << 8) + (b0 + b1 >> 8); 205 | data[offset++] = color; 206 | } 207 | } 208 | } 209 | 210 | @OriginalMember(owner = "client!fb", name = "a", descriptor = "(IIIIII)V") 211 | public static void drawRect(@OriginalArg(1) int x, @OriginalArg(4) int y, @OriginalArg(2) int rgb, @OriginalArg(5) int width, @OriginalArg(3) int height) { 212 | hline(x, y, rgb, width); 213 | hline(x, y + height - 1, rgb, width); 214 | vline(x, y, rgb, height); 215 | vline(x + width - 1, y, rgb, height); 216 | } 217 | 218 | @OriginalMember(owner = "client!fb", name = "b", descriptor = "(IIIII)V") 219 | public static void hline(@OriginalArg(4) int x, @OriginalArg(2) int y, @OriginalArg(0) int rgb, @OriginalArg(3) int width) { 220 | if (y < boundTop || y >= boundBottom) { 221 | return; 222 | } 223 | 224 | if (x < boundLeft) { 225 | width -= boundLeft - x; 226 | x = boundLeft; 227 | } 228 | 229 | if (x + width > boundRight) { 230 | width = boundRight - x; 231 | } 232 | 233 | @Pc(32) int off = x + y * width2d; 234 | for (@Pc(37) int i = 0; i < width; i++) { 235 | data[off + i] = rgb; 236 | } 237 | } 238 | 239 | @OriginalMember(owner = "client!fb", name = "c", descriptor = "(IIIII)V") 240 | public static void vline(@OriginalArg(4) int x, @OriginalArg(2) int y, @OriginalArg(0) int rgb, @OriginalArg(3) int height) { 241 | if (x < boundLeft || x >= boundRight) { 242 | return; 243 | } 244 | 245 | if (y < boundTop) { 246 | height -= boundTop - y; 247 | y = boundTop; 248 | } 249 | 250 | if (y + height > boundBottom) { 251 | height = boundBottom - y; 252 | } 253 | 254 | @Pc(32) int off = x + y * width2d; 255 | for (@Pc(38) int i = 0; i < height; i++) { 256 | data[off + i * width2d] = rgb; 257 | } 258 | } 259 | 260 | public static void line(int x1, int y1, int x2, int y2, int rgb) { 261 | int dx = Math.abs(x2 - x1); 262 | int dy = Math.abs(y2 - y1); 263 | 264 | int sx = (x1 < x2) ? 1 : -1; 265 | int sy = (y1 < y2) ? 1 : -1; 266 | 267 | int err = dx - dy; 268 | 269 | while (true) { 270 | if ((x1 >= boundLeft) && (x1 < boundRight) && (y1 >= boundTop) && (y1 < boundBottom)) { 271 | data[x1 + (y1 * width2d)] = rgb; 272 | } 273 | 274 | if ((x1 == x2) && (y1 == y2)) { 275 | break; 276 | } 277 | 278 | int e2 = 2 * err; 279 | 280 | if (e2 > -dy) { 281 | err = err - dy; 282 | x1 = x1 + sx; 283 | } 284 | 285 | if (e2 < dx) { 286 | err = err + dx; 287 | y1 = y1 + sy; 288 | } 289 | } 290 | } 291 | } 292 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/graphics/Pix8.java: -------------------------------------------------------------------------------- 1 | package jagex2.graphics; 2 | 3 | import jagex2.io.Jagfile; 4 | import jagex2.io.Packet; 5 | import org.openrs2.deob.annotation.OriginalArg; 6 | import org.openrs2.deob.annotation.OriginalClass; 7 | import org.openrs2.deob.annotation.OriginalMember; 8 | import org.openrs2.deob.annotation.Pc; 9 | 10 | // name and packaging confirmed 100% in rs2/mapview applet strings 11 | @OriginalClass("client!ib") 12 | public class Pix8 extends Pix2D { 13 | 14 | @OriginalMember(owner = "client!ib", name = "z", descriptor = "[B") 15 | public byte[] pixels; 16 | 17 | @OriginalMember(owner = "client!ib", name = "A", descriptor = "[I") 18 | public final int[] palette; 19 | 20 | @OriginalMember(owner = "client!ib", name = "B", descriptor = "I") 21 | public int width; 22 | 23 | @OriginalMember(owner = "client!ib", name = "C", descriptor = "I") 24 | public int height; 25 | 26 | @OriginalMember(owner = "client!ib", name = "D", descriptor = "I") 27 | public int cropX; 28 | 29 | @OriginalMember(owner = "client!ib", name = "E", descriptor = "I") 30 | public int cropY; 31 | 32 | @OriginalMember(owner = "client!ib", name = "F", descriptor = "I") 33 | public int cropW; 34 | 35 | @OriginalMember(owner = "client!ib", name = "G", descriptor = "I") 36 | private int cropH; 37 | 38 | @OriginalMember(owner = "client!ib", name = "", descriptor = "(Lclient!ub;Ljava/lang/String;I)V") 39 | public Pix8(@OriginalArg(0) Jagfile jag, @OriginalArg(1) String name, @OriginalArg(2) int index) { 40 | @Pc(32) Packet dat = new Packet(jag.read(name + ".dat", null)); 41 | @Pc(42) Packet idx = new Packet(jag.read("index.dat", null)); 42 | idx.pos = dat.g2(); 43 | 44 | this.cropW = idx.g2(); 45 | this.cropH = idx.g2(); 46 | 47 | @Pc(57) int paletteCount = idx.g1(); 48 | this.palette = new int[paletteCount]; 49 | for (@Pc(63) int i = 0; i < paletteCount - 1; i++) { 50 | this.palette[i + 1] = idx.g3(); 51 | } 52 | 53 | for (@Pc(81) int i = 0; i < index; i++) { 54 | idx.pos += 2; 55 | dat.pos += idx.g2() * idx.g2(); 56 | idx.pos++; 57 | } 58 | 59 | this.cropX = idx.g1(); 60 | this.cropY = idx.g1(); 61 | this.width = idx.g2(); 62 | this.height = idx.g2(); 63 | 64 | @Pc(128) int pixelOrder = idx.g1(); 65 | @Pc(134) int len = this.width * this.height; 66 | this.pixels = new byte[len]; 67 | 68 | if (pixelOrder == 0) { 69 | for (int i = 0; i < len; i++) { 70 | this.pixels[i] = dat.g1b(); 71 | } 72 | } else if (pixelOrder == 1) { 73 | for (@Pc(142) int x = 0; x < this.width; x++) { 74 | for (@Pc(164) int y = 0; y < this.height; y++) { 75 | this.pixels[x + y * this.width] = dat.g1b(); 76 | } 77 | } 78 | } 79 | } 80 | 81 | @OriginalMember(owner = "client!ib", name = "a", descriptor = "(Z)V") 82 | public void shrink() { 83 | this.cropW /= 2; 84 | this.cropH /= 2; 85 | 86 | @Pc(20) byte[] pixels = new byte[this.cropW * this.cropH]; 87 | @Pc(22) int off = 0; 88 | for (@Pc(24) int y = 0; y < this.height; y++) { 89 | for (@Pc(28) int x = 0; x < this.width; x++) { 90 | pixels[(x + this.cropX >> 1) + (y + this.cropY >> 1) * this.cropW] = this.pixels[off++]; 91 | } 92 | } 93 | 94 | this.pixels = pixels; 95 | this.width = this.cropW; 96 | this.height = this.cropH; 97 | this.cropX = 0; 98 | this.cropY = 0; 99 | } 100 | 101 | @OriginalMember(owner = "client!ib", name = "c", descriptor = "(I)V") 102 | public void crop() { 103 | if (this.width == this.cropW && this.height == this.cropH) { 104 | return; 105 | } 106 | 107 | @Pc(19) byte[] pixels = new byte[this.cropW * this.cropH]; 108 | @Pc(21) int off = 0; 109 | for (@Pc(33) int y = 0; y < this.height; y++) { 110 | for (@Pc(37) int x = 0; x < this.width; x++) { 111 | pixels[x + this.cropX + (y + this.cropY) * this.cropW] = this.pixels[off++]; 112 | } 113 | } 114 | 115 | this.pixels = pixels; 116 | this.width = this.cropW; 117 | this.height = this.cropH; 118 | this.cropX = 0; 119 | this.cropY = 0; 120 | } 121 | 122 | @OriginalMember(owner = "client!ib", name = "d", descriptor = "(I)V") 123 | public void flipHorizontally() { 124 | @Pc(8) byte[] pixels = new byte[this.width * this.height]; 125 | @Pc(10) int off = 0; 126 | for (@Pc(12) int y = 0; y < this.height; y++) { 127 | for (@Pc(19) int x = this.width - 1; x >= 0; x--) { 128 | pixels[off++] = this.pixels[x + y * this.width]; 129 | } 130 | } 131 | 132 | this.pixels = pixels; 133 | this.cropX = this.cropW - this.width - this.cropX; 134 | } 135 | 136 | @OriginalMember(owner = "client!ib", name = "a", descriptor = "(B)V") 137 | public void flipVertically() { 138 | @Pc(8) byte[] pixels = new byte[this.width * this.height]; 139 | @Pc(13) int off = 0; 140 | for (@Pc(25) int y = this.height - 1; y >= 0; y--) { 141 | for (@Pc(29) int x = 0; x < this.width; x++) { 142 | pixels[off++] = this.pixels[x + y * this.width]; 143 | } 144 | } 145 | 146 | this.pixels = pixels; 147 | this.cropY = this.cropH - this.height - this.cropY; 148 | } 149 | 150 | @OriginalMember(owner = "client!ib", name = "a", descriptor = "(IIIZ)V") 151 | public void translate(@OriginalArg(0) int r, @OriginalArg(1) int g, @OriginalArg(2) int b) { 152 | for (@Pc(3) int i = 0; i < this.palette.length; i++) { 153 | @Pc(14) int red = this.palette[i] >> 16 & 0xFF; 154 | red += r; 155 | if (red < 0) { 156 | red = 0; 157 | } else if (red > 255) { 158 | red = 255; 159 | } 160 | 161 | @Pc(38) int green = this.palette[i] >> 8 & 0xFF; 162 | green += g; 163 | if (green < 0) { 164 | green = 0; 165 | } else if (green > 255) { 166 | green = 255; 167 | } 168 | 169 | @Pc(60) int blue = this.palette[i] & 0xFF; 170 | blue += b; 171 | if (blue < 0) { 172 | blue = 0; 173 | } else if (blue > 255) { 174 | blue = 255; 175 | } 176 | 177 | this.palette[i] = (red << 16) + (green << 8) + blue; 178 | } 179 | } 180 | 181 | @OriginalMember(owner = "client!ib", name = "a", descriptor = "(IIZ)V") 182 | public void draw(@OriginalArg(1) int x, @OriginalArg(0) int y) { 183 | x += this.cropX; 184 | y += this.cropY; 185 | 186 | @Pc(15) int dstOff = x + y * Pix2D.width2d; 187 | @Pc(17) int srcOff = 0; 188 | @Pc(20) int h = this.height; 189 | @Pc(23) int w = this.width; 190 | @Pc(27) int dstStep = Pix2D.width2d - w; 191 | @Pc(29) int srcStep = 0; 192 | 193 | if (y < Pix2D.boundTop) { 194 | int cutoff = Pix2D.boundTop - y; 195 | h -= cutoff; 196 | y = Pix2D.boundTop; 197 | srcOff += cutoff * w; 198 | dstOff += cutoff * Pix2D.width2d; 199 | } 200 | 201 | if (y + h > Pix2D.boundBottom) { 202 | h -= y + h - Pix2D.boundBottom; 203 | } 204 | 205 | if (x < Pix2D.boundLeft) { 206 | int cutoff = Pix2D.boundLeft - x; 207 | w -= cutoff; 208 | x = Pix2D.boundLeft; 209 | srcOff += cutoff; 210 | dstOff += cutoff; 211 | srcStep += cutoff; 212 | dstStep += cutoff; 213 | } 214 | 215 | if (x + w > Pix2D.boundRight) { 216 | int cutoff = x + w - Pix2D.boundRight; 217 | w -= cutoff; 218 | srcStep += cutoff; 219 | dstStep += cutoff; 220 | } 221 | 222 | if (w > 0 && h > 0) { 223 | this.copyPixels(w, h, this.pixels, srcOff, srcStep, Pix2D.data, dstOff, dstStep, this.palette); 224 | } 225 | } 226 | 227 | @OriginalMember(owner = "client!ib", name = "a", descriptor = "([III[BIIIII[I)V") 228 | private void copyPixels(@OriginalArg(6) int w, @OriginalArg(4) int h, @OriginalArg(3) byte[] src, @OriginalArg(1) int srcOff, @OriginalArg(2) int srcStep, @OriginalArg(0) int[] dst, @OriginalArg(7) int dstOff, @OriginalArg(8) int dstStep, @OriginalArg(9) int[] palette) { 229 | @Pc(6) int qw = -(w >> 2); 230 | w = -(w & 0x3); 231 | 232 | for (@Pc(17) int y = -h; y < 0; y++) { 233 | for (@Pc(21) int x = qw; x < 0; x++) { 234 | @Pc(28) byte palIndex = src[srcOff++]; 235 | if (palIndex == 0) { 236 | dstOff++; 237 | } else { 238 | dst[dstOff++] = palette[palIndex & 0xFF]; 239 | } 240 | 241 | palIndex = src[srcOff++]; 242 | if (palIndex == 0) { 243 | dstOff++; 244 | } else { 245 | dst[dstOff++] = palette[palIndex & 0xFF]; 246 | } 247 | 248 | palIndex = src[srcOff++]; 249 | if (palIndex == 0) { 250 | dstOff++; 251 | } else { 252 | dst[dstOff++] = palette[palIndex & 0xFF]; 253 | } 254 | 255 | palIndex = src[srcOff++]; 256 | if (palIndex == 0) { 257 | dstOff++; 258 | } else { 259 | dst[dstOff++] = palette[palIndex & 0xFF]; 260 | } 261 | } 262 | 263 | for (@Pc(104) int x = w; x < 0; x++) { 264 | @Pc(111) byte palIndex = src[srcOff++]; 265 | if (palIndex == 0) { 266 | dstOff++; 267 | } else { 268 | dst[dstOff++] = palette[palIndex & 0xFF]; 269 | } 270 | } 271 | 272 | dstOff += dstStep; 273 | srcOff += srcStep; 274 | } 275 | } 276 | 277 | @OriginalMember(owner = "mapview!i", name = "d", descriptor = "(IIII)V") 278 | public void clip(@OriginalArg(0) int arg0, @OriginalArg(1) int arg1, @OriginalArg(2) int arg2, @OriginalArg(3) int arg3) { 279 | try { 280 | @Pc(2) int local2 = this.width; 281 | @Pc(5) int local5 = this.height; 282 | @Pc(7) int local7 = 0; 283 | @Pc(9) int local9 = 0; 284 | @Pc(15) int local15 = (local2 << 16) / arg2; 285 | @Pc(21) int local21 = (local5 << 16) / arg3; 286 | @Pc(24) int local24 = this.cropW; 287 | @Pc(27) int local27 = this.cropH; 288 | @Pc(33) int local33 = (local24 << 16) / arg2; 289 | @Pc(39) int local39 = (local27 << 16) / arg3; 290 | arg0 += (this.cropX * arg2 + local24 - 1) / local24; 291 | arg1 += (this.cropY * arg3 + local27 - 1) / local27; 292 | if (this.cropX * arg2 % local24 != 0) { 293 | local7 = (local24 - this.cropX * arg2 % local24 << 16) / arg2; 294 | } 295 | if (this.cropY * arg3 % local27 != 0) { 296 | local9 = (local27 - this.cropY * arg3 % local27 << 16) / arg3; 297 | } 298 | arg2 = arg2 * (this.width - (local7 >> 16)) / local24; 299 | arg3 = arg3 * (this.height - (local9 >> 16)) / local27; 300 | @Pc(133) int local133 = arg0 + arg1 * Pix2D.width2d; 301 | @Pc(137) int local137 = Pix2D.width2d - arg2; 302 | @Pc(144) int local144; 303 | if (arg1 < Pix2D.boundTop) { 304 | local144 = Pix2D.boundTop - arg1; 305 | arg3 -= local144; 306 | arg1 = 0; 307 | local133 += local144 * Pix2D.width2d; 308 | local9 += local39 * local144; 309 | } 310 | if (arg1 + arg3 > Pix2D.boundBottom) { 311 | arg3 -= arg1 + arg3 - Pix2D.boundBottom; 312 | } 313 | if (arg0 < Pix2D.boundLeft) { 314 | local144 = Pix2D.boundLeft - arg0; 315 | arg2 -= local144; 316 | arg0 = 0; 317 | local133 += local144; 318 | local7 += local33 * local144; 319 | local137 += local144; 320 | } 321 | if (arg0 + arg2 > Pix2D.boundRight) { 322 | local144 = arg0 + arg2 - Pix2D.boundRight; 323 | arg2 -= local144; 324 | local137 += local144; 325 | } 326 | this.plot_scale(Pix2D.data, this.pixels, this.palette, local7, local9, local133, local137, arg2, arg3, local33, local39, local2); 327 | } catch (@Pc(239) Exception local239) { 328 | System.out.println("error in sprite clipping routine"); 329 | } 330 | } 331 | 332 | @OriginalMember(owner = "mapview!i", name = "a", descriptor = "([I[B[IIIIIIIIII)V") 333 | private void plot_scale(@OriginalArg(0) int[] arg0, @OriginalArg(1) byte[] arg1, @OriginalArg(2) int[] arg2, @OriginalArg(3) int arg3, @OriginalArg(4) int arg4, @OriginalArg(5) int arg5, @OriginalArg(6) int arg6, @OriginalArg(7) int arg7, @OriginalArg(8) int arg8, @OriginalArg(9) int arg9, @OriginalArg(10) int arg10, @OriginalArg(11) int arg11) { 334 | try { 335 | @Pc(3) int local3 = arg3; 336 | for (@Pc(6) int local6 = -arg8; local6 < 0; local6++) { 337 | @Pc(14) int local14 = (arg4 >> 16) * arg11; 338 | for (@Pc(17) int local17 = -arg7; local17 < 0; local17++) { 339 | @Pc(27) byte local27 = arg1[(arg3 >> 16) + local14]; 340 | if (local27 == 0) { 341 | arg5++; 342 | } else { 343 | arg0[arg5++] = arg2[local27 & 0xFF]; 344 | } 345 | arg3 += arg9; 346 | } 347 | arg4 += arg10; 348 | arg3 = local3; 349 | arg5 += arg6; 350 | } 351 | } catch (@Pc(63) Exception local63) { 352 | System.out.println("error in plot_scale"); 353 | } 354 | } 355 | } 356 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/graphics/PixMap.java: -------------------------------------------------------------------------------- 1 | package jagex2.graphics; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | 7 | import java.awt.*; 8 | import java.awt.image.*; 9 | 10 | // name taken from rsc 11 | @OriginalClass("client!qb") 12 | public class PixMap implements ImageProducer, ImageObserver { 13 | 14 | @OriginalMember(owner = "client!qb", name = "b", descriptor = "[I") 15 | public final int[] pixels; 16 | 17 | @OriginalMember(owner = "client!qb", name = "c", descriptor = "I") 18 | private final int width; 19 | 20 | @OriginalMember(owner = "client!qb", name = "d", descriptor = "I") 21 | private final int height; 22 | 23 | @OriginalMember(owner = "client!qb", name = "e", descriptor = "Ljava/awt/image/ColorModel;") 24 | private final ColorModel colorModel; 25 | 26 | @OriginalMember(owner = "client!qb", name = "f", descriptor = "Ljava/awt/image/ImageConsumer;") 27 | private ImageConsumer imageConsumer; 28 | 29 | @OriginalMember(owner = "client!qb", name = "g", descriptor = "Ljava/awt/Image;") 30 | private final Image image; 31 | 32 | @OriginalMember(owner = "client!qb", name = "", descriptor = "(Ljava/awt/Component;III)V") 33 | public PixMap(@OriginalArg(0) Component c, @OriginalArg(1) int width, @OriginalArg(3) int height) { 34 | this.width = width; 35 | this.height = height; 36 | this.pixels = new int[width * height]; 37 | this.colorModel = new DirectColorModel(32, 0xff0000, 0xff00, 0xff); 38 | this.image = c.createImage(this); 39 | 40 | this.setPixels(); 41 | c.prepareImage(this.image, this); 42 | 43 | this.setPixels(); 44 | c.prepareImage(this.image, this); 45 | 46 | this.setPixels(); 47 | c.prepareImage(this.image, this); 48 | 49 | this.bind(); 50 | } 51 | 52 | @OriginalMember(owner = "client!qb", name = "a", descriptor = "(B)V") 53 | public void bind() { 54 | Pix2D.bind(this.width, this.height, this.pixels); 55 | } 56 | 57 | @OriginalMember(owner = "client!qb", name = "a", descriptor = "(ILjava/awt/Graphics;II)V") 58 | public void draw(@OriginalArg(1) Graphics g, @OriginalArg(2) int width, @OriginalArg(0) int height) { 59 | this.setPixels(); 60 | g.drawImage(this.image, width, height, this); 61 | } 62 | 63 | @OriginalMember(owner = "client!qb", name = "addConsumer", descriptor = "(Ljava/awt/image/ImageConsumer;)V") 64 | @Override 65 | public synchronized void addConsumer(@OriginalArg(0) ImageConsumer consumer) { 66 | this.imageConsumer = consumer; 67 | consumer.setDimensions(this.width, this.height); 68 | consumer.setProperties(null); 69 | consumer.setColorModel(this.colorModel); 70 | consumer.setHints(14); 71 | } 72 | 73 | @OriginalMember(owner = "client!qb", name = "isConsumer", descriptor = "(Ljava/awt/image/ImageConsumer;)Z") 74 | @Override 75 | public synchronized boolean isConsumer(@OriginalArg(0) ImageConsumer consumer) { 76 | return this.imageConsumer == consumer; 77 | } 78 | 79 | @OriginalMember(owner = "client!qb", name = "removeConsumer", descriptor = "(Ljava/awt/image/ImageConsumer;)V") 80 | @Override 81 | public synchronized void removeConsumer(@OriginalArg(0) ImageConsumer consumer) { 82 | if (this.imageConsumer == consumer) { 83 | this.imageConsumer = null; 84 | } 85 | } 86 | 87 | @OriginalMember(owner = "client!qb", name = "startProduction", descriptor = "(Ljava/awt/image/ImageConsumer;)V") 88 | @Override 89 | public void startProduction(@OriginalArg(0) ImageConsumer consumer) { 90 | this.addConsumer(consumer); 91 | } 92 | 93 | @OriginalMember(owner = "client!qb", name = "requestTopDownLeftRightResend", descriptor = "(Ljava/awt/image/ImageConsumer;)V") 94 | @Override 95 | public void requestTopDownLeftRightResend(@OriginalArg(0) ImageConsumer consumer) { 96 | System.out.println("TDLR"); 97 | } 98 | 99 | @OriginalMember(owner = "client!qb", name = "a", descriptor = "()V") 100 | private synchronized void setPixels() { 101 | if (this.imageConsumer != null) { 102 | this.imageConsumer.setPixels(0, 0, this.width, this.height, this.colorModel, this.pixels, 0, this.width); 103 | this.imageConsumer.imageComplete(2); 104 | } 105 | } 106 | 107 | @OriginalMember(owner = "client!qb", name = "imageUpdate", descriptor = "(Ljava/awt/Image;IIIII)Z") 108 | @Override 109 | public boolean imageUpdate(@OriginalArg(0) Image img, @OriginalArg(1) int infoflags, @OriginalArg(2) int x, @OriginalArg(3) int y, @OriginalArg(4) int width, @OriginalArg(5) int height) { 110 | return true; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/io/ClientStream.java: -------------------------------------------------------------------------------- 1 | package jagex2.io; 2 | 3 | import jagex2.client.GameShell; 4 | import org.openrs2.deob.annotation.OriginalArg; 5 | import org.openrs2.deob.annotation.OriginalClass; 6 | import org.openrs2.deob.annotation.OriginalMember; 7 | import org.openrs2.deob.annotation.Pc; 8 | 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | import java.io.OutputStream; 12 | import java.net.Socket; 13 | 14 | @OriginalClass("client!d") 15 | public class ClientStream implements Runnable { 16 | 17 | @OriginalMember(owner = "client!d", name = "b", descriptor = "Ljava/io/InputStream;") 18 | private final InputStream in; 19 | 20 | @OriginalMember(owner = "client!d", name = "c", descriptor = "Ljava/io/OutputStream;") 21 | private final OutputStream out; 22 | 23 | @OriginalMember(owner = "client!d", name = "d", descriptor = "Ljava/net/Socket;") 24 | private final Socket socket; 25 | 26 | @OriginalMember(owner = "client!d", name = "e", descriptor = "Z") 27 | private boolean closed = false; 28 | 29 | @OriginalMember(owner = "client!d", name = "f", descriptor = "Lclient!a;") 30 | private final GameShell shell; 31 | 32 | @OriginalMember(owner = "client!d", name = "g", descriptor = "[B") 33 | private byte[] buf; 34 | 35 | @OriginalMember(owner = "client!d", name = "h", descriptor = "I") 36 | private int bufLen; 37 | 38 | @OriginalMember(owner = "client!d", name = "i", descriptor = "I") 39 | private int bufPos; 40 | 41 | @OriginalMember(owner = "client!d", name = "j", descriptor = "Z") 42 | private boolean writer = false; 43 | 44 | @OriginalMember(owner = "client!d", name = "k", descriptor = "Z") 45 | private boolean ioerror = false; 46 | 47 | @OriginalMember(owner = "client!d", name = "", descriptor = "(Lclient!a;BLjava/net/Socket;)V") 48 | public ClientStream(@OriginalArg(0) GameShell shell, @OriginalArg(2) Socket socket) throws IOException { 49 | this.shell = shell; 50 | this.socket = socket; 51 | this.socket.setSoTimeout(30000); 52 | this.socket.setTcpNoDelay(true); 53 | this.in = this.socket.getInputStream(); 54 | this.out = this.socket.getOutputStream(); 55 | } 56 | 57 | @OriginalMember(owner = "client!d", name = "a", descriptor = "()V") 58 | public void close() { 59 | this.closed = true; 60 | 61 | try { 62 | if (this.in != null) { 63 | this.in.close(); 64 | } 65 | 66 | if (this.out != null) { 67 | this.out.close(); 68 | } 69 | 70 | if (this.socket != null) { 71 | this.socket.close(); 72 | } 73 | } catch (@Pc(22) IOException ignored) { 74 | System.out.println("Error closing stream"); 75 | } 76 | 77 | this.writer = false; 78 | synchronized (this) { 79 | this.notify(); 80 | } 81 | this.buf = null; 82 | } 83 | 84 | @OriginalMember(owner = "client!d", name = "b", descriptor = "()I") 85 | public int read() throws IOException { 86 | return this.closed ? 0 : this.in.read(); 87 | } 88 | 89 | @OriginalMember(owner = "client!d", name = "c", descriptor = "()I") 90 | public int available() throws IOException { 91 | return this.closed ? 0 : this.in.available(); 92 | } 93 | 94 | @OriginalMember(owner = "client!d", name = "a", descriptor = "([BII)V") 95 | public void read(@OriginalArg(0) byte[] dst, @OriginalArg(1) int off, @OriginalArg(2) int len) throws IOException { 96 | if (this.closed) { 97 | return; 98 | } 99 | 100 | while (len > 0) { 101 | @Pc(11) int read = this.in.read(dst, off, len); 102 | if (read <= 0) { 103 | throw new IOException("EOF"); 104 | } 105 | 106 | off += read; 107 | len -= read; 108 | } 109 | } 110 | 111 | @OriginalMember(owner = "client!d", name = "a", descriptor = "([BIZI)V") 112 | public void write(@OriginalArg(0) byte[] src, @OriginalArg(1) int len, @OriginalArg(3) int off) throws IOException { 113 | if (!this.closed) { 114 | if (this.ioerror) { 115 | this.ioerror = false; 116 | throw new IOException("Error in writer thread"); 117 | } 118 | 119 | if (this.buf == null) { 120 | this.buf = new byte[5000]; 121 | } 122 | 123 | synchronized (this) { 124 | for (@Pc(31) int i = 0; i < len; i++) { 125 | this.buf[this.bufPos] = src[i + off]; 126 | this.bufPos = (this.bufPos + 1) % 5000; 127 | 128 | if (this.bufPos == (this.bufLen + 4900) % 5000) { 129 | throw new IOException("buffer overflow"); 130 | } 131 | } 132 | 133 | if (!this.writer) { 134 | this.writer = true; 135 | this.shell.startThread(this, 2); 136 | } 137 | 138 | this.notify(); 139 | } 140 | } 141 | } 142 | 143 | @OriginalMember(owner = "client!d", name = "run", descriptor = "()V") 144 | public void run() { 145 | while (this.writer) { 146 | @Pc(38) int len; 147 | @Pc(27) int off; 148 | 149 | synchronized (this) { 150 | if (this.bufPos == this.bufLen) { 151 | try { 152 | this.wait(); 153 | } catch (@Pc(16) InterruptedException ignored) { 154 | } 155 | } 156 | 157 | if (!this.writer) { 158 | return; 159 | } 160 | 161 | off = this.bufLen; 162 | if (this.bufPos >= this.bufLen) { 163 | len = this.bufPos - this.bufLen; 164 | } else { 165 | len = 5000 - this.bufLen; 166 | } 167 | } 168 | 169 | if (len > 0) { 170 | try { 171 | this.out.write(this.buf, off, len); 172 | } catch (@Pc(62) IOException ignored) { 173 | this.ioerror = true; 174 | } 175 | 176 | this.bufLen = (this.bufLen + len) % 5000; 177 | try { 178 | if (this.bufPos == this.bufLen) { 179 | this.out.flush(); 180 | } 181 | } catch (@Pc(83) IOException ignored) { 182 | this.ioerror = true; 183 | } 184 | } 185 | } 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/io/Isaac.java: -------------------------------------------------------------------------------- 1 | package jagex2.io; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | // name and packaging confirmed 100% in rs2/mapview applet strings 9 | @OriginalClass("client!tb") 10 | public class Isaac { 11 | 12 | @OriginalMember(owner = "client!tb", name = "a", descriptor = "I") 13 | private int count; 14 | 15 | @OriginalMember(owner = "client!tb", name = "b", descriptor = "[I") 16 | private final int[] rsl; 17 | 18 | @OriginalMember(owner = "client!tb", name = "c", descriptor = "[I") 19 | private final int[] mem; 20 | 21 | @OriginalMember(owner = "client!tb", name = "d", descriptor = "I") 22 | private int a; 23 | 24 | @OriginalMember(owner = "client!tb", name = "e", descriptor = "I") 25 | private int b; 26 | 27 | @OriginalMember(owner = "client!tb", name = "f", descriptor = "I") 28 | private int c; 29 | 30 | @OriginalMember(owner = "client!tb", name = "", descriptor = "(B[I)V") 31 | public Isaac(@OriginalArg(1) int[] seed) { 32 | this.mem = new int[256]; 33 | this.rsl = new int[256]; 34 | System.arraycopy(seed, 0, this.rsl, 0, seed.length); 35 | this.init(); 36 | } 37 | 38 | @OriginalMember(owner = "client!tb", name = "a", descriptor = "()I") 39 | public int takeNextValue() { 40 | if (this.count-- == 0) { 41 | this.generate(); 42 | this.count = 255; 43 | } 44 | return this.rsl[this.count]; 45 | } 46 | 47 | @OriginalMember(owner = "client!tb", name = "b", descriptor = "()V") 48 | private void generate() { 49 | this.b += ++this.c; 50 | 51 | for (@Pc(15) int i = 0; i < 256; i++) { 52 | @Pc(22) int x = this.mem[i]; 53 | switch (i & 0x3) { 54 | case 0: 55 | this.a ^= this.a << 13; 56 | break; 57 | case 1: 58 | this.a ^= this.a >>> 6; 59 | break; 60 | case 2: 61 | this.a ^= this.a << 2; 62 | break; 63 | case 3: 64 | this.a ^= this.a >>> 16; 65 | } 66 | 67 | this.a += this.mem[i + 128 & 0xFF]; 68 | @Pc(101) int y; 69 | this.mem[i] = y = this.mem[x >> 2 & 0xFF] + this.a + this.b; 70 | this.rsl[i] = this.b = this.mem[y >> 8 >> 2 & 0xFF] + x; 71 | } 72 | } 73 | 74 | @OriginalMember(owner = "client!tb", name = "c", descriptor = "()V") 75 | private void init() { 76 | @Pc(4) int h = 0x9e3779b9; 77 | @Pc(6) int g = 0x9e3779b9; 78 | @Pc(8) int f = 0x9e3779b9; 79 | @Pc(10) int e = 0x9e3779b9; 80 | @Pc(12) int d = 0x9e3779b9; 81 | @Pc(14) int c = 0x9e3779b9; 82 | @Pc(16) int b = 0x9e3779b9; 83 | @Pc(17) int a = 0x9e3779b9; 84 | 85 | @Pc(19) int i; 86 | for (i = 0; i < 4; i++) { 87 | a ^= b << 11; d += a; b += c; 88 | b ^= c >>> 2; e += b; c += d; 89 | c ^= d << 8; f += c; d += e; 90 | d ^= e >>> 16; g += d; e += f; 91 | e ^= f << 10; h += e; f += g; 92 | f ^= g >>> 4; a += f; g += h; 93 | g ^= h << 8; b += g; h += a; 94 | h ^= a >>> 9; c += h; a += b; 95 | } 96 | 97 | for (i = 0; i < 256; i += 8) { 98 | a += this.rsl[i]; 99 | b += this.rsl[i + 1]; 100 | c += this.rsl[i + 2]; 101 | d += this.rsl[i + 3]; 102 | e += this.rsl[i + 4]; 103 | f += this.rsl[i + 5]; 104 | g += this.rsl[i + 6]; 105 | h += this.rsl[i + 7]; 106 | 107 | a ^= b << 11; d += a; b += c; 108 | b ^= c >>> 2; e += b; c += d; 109 | c ^= d << 8; f += c; d += e; 110 | d ^= e >>> 16; g += d; e += f; 111 | e ^= f << 10; h += e; f += g; 112 | f ^= g >>> 4; a += f; g += h; 113 | g ^= h << 8; b += g; h += a; 114 | h ^= a >>> 9; c += h; a += b; 115 | 116 | this.mem[i] = a; 117 | this.mem[i + 1] = b; 118 | this.mem[i + 2] = c; 119 | this.mem[i + 3] = d; 120 | this.mem[i + 4] = e; 121 | this.mem[i + 5] = f; 122 | this.mem[i + 6] = g; 123 | this.mem[i + 7] = h; 124 | } 125 | for (i = 0; i < 256; i += 8) { 126 | a += this.mem[i]; 127 | b += this.mem[i + 1]; 128 | c += this.mem[i + 2]; 129 | d += this.mem[i + 3]; 130 | e += this.mem[i + 4]; 131 | f += this.mem[i + 5]; 132 | g += this.mem[i + 6]; 133 | h += this.mem[i + 7]; 134 | 135 | a ^= b << 11; d += a; b += c; 136 | b ^= c >>> 2; e += b; c += d; 137 | c ^= d << 8; f += c; d += e; 138 | d ^= e >>> 16; g += d; e += f; 139 | e ^= f << 10; h += e; f += g; 140 | f ^= g >>> 4; a += f; g += h; 141 | g ^= h << 8; b += g; h += a; 142 | h ^= a >>> 9; c += h; a += b; 143 | 144 | this.mem[i] = a; 145 | this.mem[i + 1] = b; 146 | this.mem[i + 2] = c; 147 | this.mem[i + 3] = d; 148 | this.mem[i + 4] = e; 149 | this.mem[i + 5] = f; 150 | this.mem[i + 6] = g; 151 | this.mem[i + 7] = h; 152 | } 153 | 154 | this.generate(); 155 | this.count = 256; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/io/Jagfile.java: -------------------------------------------------------------------------------- 1 | package jagex2.io; 2 | 3 | import org.openrs2.deob.annotation.OriginalArg; 4 | import org.openrs2.deob.annotation.OriginalClass; 5 | import org.openrs2.deob.annotation.OriginalMember; 6 | import org.openrs2.deob.annotation.Pc; 7 | 8 | // name and packaging confirmed 100% in rs2/mapview applet strings 9 | // it was also observed in an exception handler string during rev 234 10 | @OriginalClass("client!ub") 11 | public class Jagfile { 12 | 13 | @OriginalMember(owner = "client!ub", name = "e", descriptor = "[B") 14 | private byte[] buffer; 15 | 16 | @OriginalMember(owner = "client!ub", name = "f", descriptor = "I") 17 | private int fileCount; 18 | 19 | @OriginalMember(owner = "client!ub", name = "g", descriptor = "[I") 20 | private int[] fileHash; 21 | 22 | @OriginalMember(owner = "client!ub", name = "h", descriptor = "[I") 23 | private int[] fileUnpackedSize; 24 | 25 | @OriginalMember(owner = "client!ub", name = "i", descriptor = "[I") 26 | private int[] filePackedSize; 27 | 28 | @OriginalMember(owner = "client!ub", name = "j", descriptor = "[I") 29 | private int[] fileOffset; 30 | 31 | @OriginalMember(owner = "client!ub", name = "k", descriptor = "Z") 32 | private boolean unpacked; 33 | 34 | @OriginalMember(owner = "client!ub", name = "", descriptor = "([BZ)V") 35 | public Jagfile(@OriginalArg(0) byte[] src) { 36 | this.load(src); 37 | } 38 | 39 | @OriginalMember(owner = "client!ub", name = "a", descriptor = "(Z[B)V") 40 | private void load(@OriginalArg(1) byte[] src) { 41 | @Pc(7) Packet data = new Packet(src); 42 | @Pc(10) int unpackedSize = data.g3(); 43 | @Pc(13) int packedSize = data.g3(); 44 | 45 | if (packedSize == unpackedSize) { 46 | this.buffer = src; 47 | this.unpacked = false; 48 | } else { 49 | @Pc(19) byte[] temp = new byte[unpackedSize]; 50 | BZip2.read(temp, unpackedSize, src, packedSize, 6); 51 | this.buffer = temp; 52 | 53 | data = new Packet(this.buffer); 54 | this.unpacked = true; 55 | } 56 | 57 | this.fileCount = data.g2(); 58 | this.fileHash = new int[this.fileCount]; 59 | this.fileUnpackedSize = new int[this.fileCount]; 60 | this.filePackedSize = new int[this.fileCount]; 61 | this.fileOffset = new int[this.fileCount]; 62 | 63 | @Pc(82) int pos = data.pos + this.fileCount * 10; 64 | for (@Pc(84) int i = 0; i < this.fileCount; i++) { 65 | this.fileHash[i] = data.g4(); 66 | this.fileUnpackedSize[i] = data.g3(); 67 | this.filePackedSize[i] = data.g3(); 68 | this.fileOffset[i] = pos; 69 | pos += this.filePackedSize[i]; 70 | } 71 | } 72 | 73 | @OriginalMember(owner = "client!ub", name = "a", descriptor = "(Ljava/lang/String;[BB)[B") 74 | public byte[] read(@OriginalArg(0) String name, @OriginalArg(1) byte[] dst) { 75 | @Pc(3) int hash = 0; 76 | @Pc(6) String upper = name.toUpperCase(); 77 | for (@Pc(8) int i = 0; i < upper.length(); i++) { 78 | hash = hash * 61 + upper.charAt(i) - 32; 79 | } 80 | 81 | for (@Pc(27) int i = 0; i < this.fileCount; i++) { 82 | if (this.fileHash[i] == hash) { 83 | if (dst == null) { 84 | dst = new byte[this.fileUnpackedSize[i]]; 85 | } 86 | 87 | if (this.unpacked) { 88 | if (this.fileUnpackedSize[i] >= 0) { 89 | System.arraycopy(this.buffer, this.fileOffset[i], dst, 0, this.fileUnpackedSize[i]); 90 | } 91 | } else { 92 | BZip2.read(dst, this.fileUnpackedSize[i], this.buffer, this.filePackedSize[i], this.fileOffset[i]); 93 | } 94 | 95 | return dst; 96 | } 97 | } 98 | 99 | return null; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/io/Packet.java: -------------------------------------------------------------------------------- 1 | package jagex2.io; 2 | 3 | import jagex2.datastruct.DoublyLinkable; 4 | import jagex2.datastruct.LinkList; 5 | import org.openrs2.deob.annotation.OriginalArg; 6 | import org.openrs2.deob.annotation.OriginalClass; 7 | import org.openrs2.deob.annotation.OriginalMember; 8 | import org.openrs2.deob.annotation.Pc; 9 | 10 | import java.math.BigInteger; 11 | 12 | // name and packaging confirmed 100% in rs2/mapview applet strings 13 | @OriginalClass("client!kb") 14 | public class Packet extends DoublyLinkable { 15 | 16 | @OriginalMember(owner = "client!kb", name = "t", descriptor = "[I") 17 | private static final int[] crctable = new int[256]; 18 | 19 | @OriginalMember(owner = "client!kb", name = "u", descriptor = "[I") 20 | public static final int[] BITMASK = new int[33]; 21 | 22 | @OriginalMember(owner = "mapview!k", name = "o", descriptor = "[C") 23 | private char[] aCharArray1 = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; 24 | 25 | @OriginalMember(owner = "client!kb", name = "q", descriptor = "[B") 26 | public byte[] data; 27 | 28 | @OriginalMember(owner = "client!kb", name = "r", descriptor = "I") 29 | public int pos; 30 | 31 | @OriginalMember(owner = "client!kb", name = "s", descriptor = "I") 32 | public int bitPos; 33 | 34 | @OriginalMember(owner = "client!kb", name = "v", descriptor = "Lclient!tb;") 35 | public Isaac random; 36 | 37 | @OriginalMember(owner = "client!kb", name = "w", descriptor = "I") 38 | public static int cacheMinCount; 39 | 40 | @OriginalMember(owner = "client!kb", name = "x", descriptor = "I") 41 | public static int cacheMidCount; 42 | 43 | @OriginalMember(owner = "client!kb", name = "y", descriptor = "I") 44 | public static int cacheMaxCount; 45 | 46 | @OriginalMember(owner = "client!kb", name = "z", descriptor = "Lclient!ob;") 47 | public static final LinkList cacheMin = new LinkList(); 48 | 49 | @OriginalMember(owner = "client!kb", name = "A", descriptor = "Lclient!ob;") 50 | public static final LinkList cacheMid = new LinkList(); 51 | 52 | @OriginalMember(owner = "client!kb", name = "B", descriptor = "Lclient!ob;") 53 | public static final LinkList cacheMax = new LinkList(); 54 | 55 | static { 56 | for (int i = 0; i < 32; i++) { 57 | BITMASK[i] = (1 << i) - 1; 58 | } 59 | BITMASK[32] = 0xFFFFFFFF; 60 | 61 | for (@Pc(8) int b = 0; b < 256; b++) { 62 | @Pc(11) int remainder = b; 63 | 64 | for (@Pc(13) int bit = 0; bit < 8; bit++) { 65 | if ((remainder & 0x1) == 1) { 66 | remainder = remainder >>> 1 ^ 0xEDB88320; 67 | } else { 68 | remainder >>>= 0x1; 69 | } 70 | } 71 | 72 | crctable[b] = remainder; 73 | } 74 | } 75 | 76 | @OriginalMember(owner = "client!kb", name = "", descriptor = "(I)V") 77 | public Packet() { 78 | } 79 | 80 | @OriginalMember(owner = "client!kb", name = "", descriptor = "(I[B)V") 81 | public Packet(@OriginalArg(1) byte[] src) { 82 | this.data = src; 83 | this.pos = 0; 84 | } 85 | 86 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "(II)Lclient!kb;") 87 | public static Packet alloc(@OriginalArg(0) int type) { 88 | synchronized (cacheMid) { 89 | @Pc(7) Packet cached = null; 90 | if (type == 0 && cacheMinCount > 0) { 91 | cacheMinCount--; 92 | cached = (Packet) cacheMin.removeHead(); 93 | } else if (type == 1 && cacheMidCount > 0) { 94 | cacheMidCount--; 95 | cached = (Packet) cacheMid.removeHead(); 96 | } else if (type == 2 && cacheMaxCount > 0) { 97 | cacheMaxCount--; 98 | cached = (Packet) cacheMax.removeHead(); 99 | } 100 | 101 | if (cached != null) { 102 | cached.pos = 0; 103 | return cached; 104 | } 105 | } 106 | 107 | @Pc(77) Packet packet = new Packet(); 108 | packet.pos = 0; 109 | if (type == 0) { 110 | packet.data = new byte[100]; 111 | } else if (type == 1) { 112 | packet.data = new byte[5000]; 113 | } else { 114 | packet.data = new byte[30000]; 115 | } 116 | return packet; 117 | } 118 | 119 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "(B)V") 120 | public void release() { 121 | synchronized (cacheMid) { 122 | this.pos = 0; 123 | 124 | if (this.data.length == 100 && cacheMinCount < 1000) { 125 | cacheMin.addTail(this); 126 | cacheMinCount++; 127 | } else if (this.data.length == 5000 && cacheMidCount < 250) { 128 | cacheMid.addTail(this); 129 | cacheMidCount++; 130 | } else if (this.data.length == 30000 && cacheMaxCount < 50) { 131 | cacheMax.addTail(this); 132 | cacheMaxCount++; 133 | } 134 | } 135 | } 136 | 137 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "(BI)V") 138 | public void p1isaac(@OriginalArg(1) int opcode) { 139 | this.data[this.pos++] = (byte) (opcode + this.random.takeNextValue()); 140 | } 141 | 142 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "(I)V") 143 | public void p1(@OriginalArg(0) int value) { 144 | this.data[this.pos++] = (byte) value; 145 | } 146 | 147 | @OriginalMember(owner = "client!kb", name = "b", descriptor = "(I)V") 148 | public void p2(@OriginalArg(0) int value) { 149 | this.data[this.pos++] = (byte) (value >> 8); 150 | this.data[this.pos++] = (byte) value; 151 | } 152 | 153 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "(ZI)V") 154 | public void ip2(@OriginalArg(1) int value) { 155 | this.data[this.pos++] = (byte) value; 156 | this.data[this.pos++] = (byte) (value >> 8); 157 | } 158 | 159 | @OriginalMember(owner = "client!kb", name = "c", descriptor = "(I)V") 160 | public void p3(@OriginalArg(0) int value) { 161 | this.data[this.pos++] = (byte) (value >> 16); 162 | this.data[this.pos++] = (byte) (value >> 8); 163 | this.data[this.pos++] = (byte) value; 164 | } 165 | 166 | @OriginalMember(owner = "client!kb", name = "d", descriptor = "(I)V") 167 | public void p4(@OriginalArg(0) int value) { 168 | this.data[this.pos++] = (byte) (value >> 24); 169 | this.data[this.pos++] = (byte) (value >> 16); 170 | this.data[this.pos++] = (byte) (value >> 8); 171 | this.data[this.pos++] = (byte) value; 172 | } 173 | 174 | @OriginalMember(owner = "client!kb", name = "b", descriptor = "(ZI)V") 175 | public void ip4(@OriginalArg(1) int value) { 176 | this.data[this.pos++] = (byte) value; 177 | this.data[this.pos++] = (byte) (value >> 8); 178 | this.data[this.pos++] = (byte) (value >> 16); 179 | this.data[this.pos++] = (byte) (value >> 24); 180 | } 181 | 182 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "(ZJ)V") 183 | public void p8(@OriginalArg(1) long value) { 184 | this.data[this.pos++] = (byte) (value >> 56); 185 | this.data[this.pos++] = (byte) (value >> 48); 186 | this.data[this.pos++] = (byte) (value >> 40); 187 | this.data[this.pos++] = (byte) (value >> 32); 188 | this.data[this.pos++] = (byte) (value >> 24); 189 | this.data[this.pos++] = (byte) (value >> 16); 190 | this.data[this.pos++] = (byte) (value >> 8); 191 | this.data[this.pos++] = (byte) value; 192 | } 193 | 194 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "(Ljava/lang/String;)V") 195 | public void pjstr(@OriginalArg(0) String str) { 196 | str.getBytes(0, str.length(), this.data, this.pos); 197 | this.pos += str.length(); 198 | this.data[this.pos++] = 10; 199 | } 200 | 201 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "([BIIB)V") 202 | public void pdata(@OriginalArg(0) byte[] src, @OriginalArg(1) int length, @OriginalArg(2) int offset) { 203 | for (@Pc(7) int i = offset; i < offset + length; i++) { 204 | this.data[this.pos++] = src[i]; 205 | } 206 | } 207 | 208 | @OriginalMember(owner = "client!kb", name = "b", descriptor = "(II)V") 209 | public void psize1(@OriginalArg(1) int size) { 210 | this.data[this.pos - size - 1] = (byte) size; 211 | } 212 | 213 | @OriginalMember(owner = "client!kb", name = "c", descriptor = "()I") 214 | public int g1() { 215 | return this.data[this.pos++] & 0xFF; 216 | } 217 | 218 | @OriginalMember(owner = "client!kb", name = "d", descriptor = "()B") 219 | public byte g1b() { 220 | return this.data[this.pos++]; 221 | } 222 | 223 | @OriginalMember(owner = "client!kb", name = "e", descriptor = "()I") 224 | public int g2() { 225 | this.pos += 2; 226 | return ((this.data[this.pos - 2] & 0xFF) << 8) + (this.data[this.pos - 1] & 0xFF); 227 | } 228 | 229 | @OriginalMember(owner = "client!kb", name = "f", descriptor = "()I") 230 | public int g2b() { 231 | this.pos += 2; 232 | @Pc(27) int value = ((this.data[this.pos - 2] & 0xFF) << 8) + (this.data[this.pos - 1] & 0xFF); 233 | if (value > 32767) { 234 | value -= 65536; 235 | } 236 | return value; 237 | } 238 | 239 | @OriginalMember(owner = "client!kb", name = "g", descriptor = "()I") 240 | public int g3() { 241 | this.pos += 3; 242 | return ((this.data[this.pos - 3] & 0xFF) << 16) + ((this.data[this.pos - 2] & 0xFF) << 8) + (this.data[this.pos - 1] & 0xFF); 243 | } 244 | 245 | @OriginalMember(owner = "client!kb", name = "h", descriptor = "()I") 246 | public int g4() { 247 | this.pos += 4; 248 | return ((this.data[this.pos - 4] & 0xFF) << 24) + ((this.data[this.pos - 3] & 0xFF) << 16) + ((this.data[this.pos - 2] & 0xFF) << 8) + (this.data[this.pos - 1] & 0xFF); 249 | } 250 | 251 | @OriginalMember(owner = "client!kb", name = "e", descriptor = "(I)J") 252 | public long g8() { 253 | @Pc(5) long high = (long) this.g4() & 0xFFFFFFFFL; 254 | @Pc(15) long low = (long) this.g4() & 0xFFFFFFFFL; 255 | return (high << 32) + low; 256 | } 257 | 258 | @OriginalMember(owner = "client!kb", name = "i", descriptor = "()Ljava/lang/String;") 259 | public String gjstr() { 260 | @Pc(2) int start = this.pos; 261 | while (this.data[this.pos++] != 10) {} 262 | 263 | return new String(this.data, start, this.pos - start - 1); 264 | } 265 | 266 | @OriginalMember(owner = "client!kb", name = "b", descriptor = "(B)[B") 267 | public byte[] gstrbyte() { 268 | @Pc(2) int start = this.pos; 269 | while (this.data[this.pos++] != 10) {} 270 | 271 | @Pc(29) byte[] temp = new byte[this.pos - start - 1]; 272 | if (this.pos - 1 - start >= 0) System.arraycopy(this.data, start, temp, 0, this.pos - 1 - start); 273 | return temp; 274 | } 275 | 276 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "(III[B)V") 277 | public void gdata(@OriginalArg(0) int length, @OriginalArg(2) int offset, @OriginalArg(3) byte[] dest) { 278 | for (@Pc(6) int i = offset; i < offset + length; i++) { 279 | dest[i] = this.data[this.pos++]; 280 | } 281 | } 282 | 283 | @OriginalMember(owner = "client!kb", name = "f", descriptor = "(I)V") 284 | public void accessBits() { 285 | this.bitPos = this.pos * 8; 286 | } 287 | 288 | @OriginalMember(owner = "client!kb", name = "c", descriptor = "(II)I") 289 | public int gBit(@OriginalArg(1) int n) { 290 | @Pc(15) int bytePos = this.bitPos >> 3; 291 | @Pc(22) int remainingBits = 8 - (this.bitPos & 0x7); 292 | 293 | @Pc(24) int value = 0; 294 | this.bitPos += n; 295 | 296 | while (n > remainingBits) { 297 | value += (this.data[bytePos++] & BITMASK[remainingBits]) << n - remainingBits; 298 | n -= remainingBits; 299 | remainingBits = 8; 300 | } 301 | 302 | if (n == remainingBits) { 303 | value += this.data[bytePos] & BITMASK[remainingBits]; 304 | } else { 305 | value += this.data[bytePos] >> remainingBits - n & BITMASK[n]; 306 | } 307 | 308 | return value; 309 | } 310 | 311 | @OriginalMember(owner = "client!kb", name = "g", descriptor = "(I)V") 312 | public void accessBytes() { 313 | this.pos = (this.bitPos + 7) / 8; 314 | } 315 | 316 | @OriginalMember(owner = "client!kb", name = "j", descriptor = "()I") 317 | public int gsmart() { 318 | @Pc(7) int value = this.data[this.pos] & 0xFF; 319 | return value < 128 ? this.g1() - 64 : this.g2() - 49152; 320 | } 321 | 322 | @OriginalMember(owner = "client!kb", name = "k", descriptor = "()I") 323 | public int gsmarts() { 324 | @Pc(7) int value = this.data[this.pos] & 0xFF; 325 | return value < 128 ? this.g1() : this.g2() - 32768; 326 | } 327 | 328 | @OriginalMember(owner = "client!kb", name = "a", descriptor = "(Ljava/math/BigInteger;Ljava/math/BigInteger;I)V") 329 | public void rsaenc(@OriginalArg(0) BigInteger mod, @OriginalArg(1) BigInteger exp) { 330 | @Pc(2) int length = this.pos; 331 | this.pos = 0; 332 | 333 | @Pc(8) byte[] temp = new byte[length]; 334 | this.gdata(length, 0, temp); 335 | @Pc(19) BigInteger bigRaw = new BigInteger(temp); 336 | @Pc(24) BigInteger bigEnc = bigRaw.modPow(exp, mod); 337 | @Pc(27) byte[] rawEnc = bigEnc.toByteArray(); 338 | 339 | this.pos = 0; 340 | this.p1(rawEnc.length); 341 | this.pdata(rawEnc, rawEnc.length, 0); 342 | } 343 | } 344 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/io/Protocol.java: -------------------------------------------------------------------------------- 1 | package jagex2.io; 2 | 3 | import org.openrs2.deob.annotation.OriginalClass; 4 | import org.openrs2.deob.annotation.OriginalMember; 5 | 6 | @OriginalClass("client!dc") 7 | public class Protocol { 8 | 9 | @OriginalMember(owner = "client!dc", name = "a", descriptor = "[I") 10 | private static final int[] CLIENTPROT_SCRAMBLED = new int[] { 95, 218, 67, 50, 253, 222, 194, 60, 101, 128, 8, 251, 92, 111, 24, 33, 223, 66, 232, 59, 227, 113, 153, 105, 126, 98, 167, 102, 177, 238, 62, 190, 147, 23, 150, 151, 156, 144, 193, 155, 81, 0, 198, 22, 137, 210, 179, 16, 168, 170, 32, 181, 248, 141, 58, 87, 208, 106, 180, 191, 221, 241, 40, 176, 196, 154, 65, 145, 230, 78, 30, 161, 188, 41, 14, 129, 18, 199, 47, 247, 225, 34, 51, 10, 159, 75, 12, 56, 61, 31, 39, 91, 46, 242, 134, 5, 122, 123, 209, 228, 104, 195, 21, 3, 11, 44, 107, 172, 6, 186, 110, 215, 205, 103, 27, 185, 124, 77, 252, 117, 86, 115, 127, 207, 52, 79, 43, 97, 219, 116, 169, 7, 118, 162, 108, 36, 20, 233, 88, 135, 80, 19, 42, 237, 57, 152, 71, 9, 250, 17, 4, 119, 234, 130, 26, 200, 189, 163, 254, 245, 197, 171, 220, 235, 140, 244, 184, 94, 211, 231, 99, 246, 121, 212, 112, 204, 63, 148, 83, 178, 1, 255, 131, 13, 183, 142, 236, 45, 55, 35, 243, 136, 37, 85, 100, 160, 38, 224, 146, 174, 82, 48, 109, 132, 125, 90, 143, 138, 240, 173, 165, 164, 192, 175, 29, 74, 28, 114, 213, 73, 64, 206, 76, 139, 96, 2, 229, 15, 93, 25, 239, 202, 49, 70, 214, 201, 72, 203, 68, 89, 69, 157, 216, 217, 249, 120, 226, 84, 149, 187, 54, 53, 158, 166, 182, 133, 0 }; 11 | 12 | @OriginalMember(owner = "client!dc", name = "b", descriptor = "[I") 13 | public static final int[] SERVERPROT_SIZES = new int[] { 0, -2, 4, 6, -1, 0, 0, 2, 0, 0, 0, 0, 5, 4, 2, 2, 0, 0, 0, 0, 2, -2, 2, 14, 0, 6, 3, 0, 4, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, -1, 4, 2, 6, 0, 6, 0, 0, 3, 7, 0, 0, 0, -1, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 1, 15, 0, 0, 0, 0, 6, 0, 2, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -2, 0, 0, 2, 0, 0, 0, 2, 9, 0, 0, 0, 0, 0, 4, 0, 0, 0, 3, 7, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, -2, 2, 0, 0, 0, 0, 0, 6, 0, 0, 0, 2, 0, 2, 0, 0, 0, -2, 0, 0, 4, 0, 0, 0, 0, 6, 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, -2, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }; 14 | } 15 | -------------------------------------------------------------------------------- /runetek3/src/main/java/jagex2/wordenc/WordPack.java: -------------------------------------------------------------------------------- 1 | package jagex2.wordenc; 2 | 3 | import jagex2.io.Packet; 4 | import org.openrs2.deob.annotation.OriginalArg; 5 | import org.openrs2.deob.annotation.OriginalClass; 6 | import org.openrs2.deob.annotation.OriginalMember; 7 | import org.openrs2.deob.annotation.Pc; 8 | 9 | // name taken from rsc 10 | @OriginalClass("client!wb") 11 | public class WordPack { 12 | 13 | @OriginalMember(owner = "client!wb", name = "a", descriptor = "[C") 14 | private static final char[] charBuffer = new char[100]; 15 | 16 | @OriginalMember(owner = "client!wb", name = "b", descriptor = "[C") 17 | private static final char[] TABLE = new char[] { 18 | // combined to save space: 19 | ' ', 'e', 't', 'a', 'o', 'i', 'h', 'n', 's', 'r', 'd', 'l', 'u', 20 | // allowed: 21 | 'm', 'w', 'c', 'y', 'f', 'g', 'p', 'b', 'v', 'k', 'x', 'j', 'q', 'z', 22 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 23 | ' ', '!', '?', '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\', '\'', '@', '#', '+', '=', '£', '$', '%', '"', '[', ']' 24 | }; 25 | 26 | @OriginalMember(owner = "client!wb", name = "a", descriptor = "(Lclient!kb;II)Ljava/lang/String;") 27 | public static String unpack(@OriginalArg(0) Packet word, @OriginalArg(2) int length) { 28 | @Pc(3) int pos = 0; 29 | @Pc(5) int carry = -1; 30 | 31 | @Pc(22) int nibble; 32 | for (@Pc(11) int i = 0; i < length; i++) { 33 | @Pc(16) int value = word.g1(); 34 | nibble = value >> 4 & 0xF; 35 | 36 | if (carry != -1) { 37 | charBuffer[pos++] = TABLE[(carry << 4) + nibble - 195]; 38 | carry = -1; 39 | } else if (nibble < 13) { 40 | charBuffer[pos++] = TABLE[nibble]; 41 | } else { 42 | carry = nibble; 43 | } 44 | 45 | nibble = value & 0xF; 46 | if (carry != -1) { 47 | charBuffer[pos++] = TABLE[(carry << 4) + nibble - 195]; 48 | carry = -1; 49 | } else if (nibble < 13) { 50 | charBuffer[pos++] = TABLE[nibble]; 51 | } else { 52 | carry = nibble; 53 | } 54 | } 55 | 56 | @Pc(100) boolean uppercase = true; 57 | for (int i = 0; i < pos; i++) { 58 | @Pc(108) char c = charBuffer[i]; 59 | if (uppercase && c >= 'a' && c <= 'z') { 60 | charBuffer[i] = (char) (charBuffer[i] - 32); 61 | uppercase = false; 62 | } 63 | 64 | if (c == '.' || c == '!') { 65 | uppercase = true; 66 | } 67 | } 68 | return new String(charBuffer, 0, pos); 69 | } 70 | 71 | @OriginalMember(owner = "client!wb", name = "a", descriptor = "(Lclient!kb;ZLjava/lang/String;)V") 72 | public static void pack(@OriginalArg(0) Packet word, @OriginalArg(2) String str) { 73 | if (str.length() > 80) { 74 | str = str.substring(0, 80); 75 | } 76 | str = str.toLowerCase(); 77 | 78 | @Pc(15) int carry = -1; 79 | for (@Pc(17) int i = 0; i < str.length(); i++) { 80 | @Pc(23) char c = str.charAt(i); 81 | 82 | @Pc(25) int index = 0; 83 | for (@Pc(27) int j = 0; j < TABLE.length; j++) { 84 | if (c == TABLE[j]) { 85 | index = j; 86 | break; 87 | } 88 | } 89 | 90 | if (index > 12) { 91 | index += 195; 92 | } 93 | 94 | if (carry == -1) { 95 | if (index < 13) { 96 | carry = index; 97 | } else { 98 | word.p1(index); 99 | } 100 | } else if (index < 13) { 101 | word.p1((carry << 4) + index); 102 | carry = -1; 103 | } else { 104 | word.p1((carry << 4) + (index >> 4)); 105 | carry = index & 0xF; 106 | } 107 | } 108 | 109 | if (carry != -1) { 110 | word.p1(carry << 4); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "rs2" 2 | 3 | include( 4 | "deob-annotations", 5 | "runetek3", 6 | "client", 7 | "mapview", 8 | "tools", 9 | "loader", 10 | ) 11 | -------------------------------------------------------------------------------- /tools/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | tasks.withType(JavaCompile) { 6 | options.encoding = 'UTF-8' 7 | options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' 8 | } 9 | 10 | tasks.withType(JavaExec) { 11 | workingDir = project.rootDir 12 | } 13 | 14 | tasks.register('sig', JavaExec) { 15 | classpath = sourceSets.main.runtimeClasspath 16 | mainClass = 'lostcity.tools.LoaderSig' 17 | args = ['client/build/libs/client.jar'] 18 | } 19 | 20 | tasks.register('mapSig', JavaExec) { 21 | classpath = sourceSets.main.runtimeClasspath 22 | mainClass = 'lostcity.tools.MapviewSig' 23 | } 24 | 25 | tasks.register('removeAnnotations', JavaExec) { 26 | classpath = sourceSets.main.runtimeClasspath 27 | mainClass = 'lostcity.tools.RemoveAnnotations' 28 | } 29 | -------------------------------------------------------------------------------- /tools/src/main/java/lostcity/tools/LoaderSig.java: -------------------------------------------------------------------------------- 1 | package lostcity.tools; 2 | 3 | import java.nio.file.Files; 4 | import java.nio.file.Paths; 5 | import java.security.MessageDigest; 6 | 7 | public class LoaderSig { 8 | public static void main(String[] args) { 9 | String sig = "public class sig {\n\tpublic static final int len = %d;\n\n\tpublic static final int[] sha = { %s };\n}"; 10 | 11 | try { 12 | String name = args[0]; 13 | byte[] src = Files.readAllBytes(Paths.get(name)); 14 | 15 | System.out.println("len: " + src.length); 16 | 17 | MessageDigest shasum = MessageDigest.getInstance("SHA"); 18 | shasum.reset(); 19 | shasum.update(src); 20 | 21 | String shaStr = ""; 22 | String uriSha = ""; 23 | byte[] sha = shasum.digest(); 24 | for (int i = 0; i < 20; i++) { 25 | if (i < 10) { 26 | uriSha += sha[i]; 27 | } 28 | 29 | if (i < 19) { 30 | shaStr += sha[i] + ", "; 31 | } else { 32 | shaStr += sha[i]; 33 | } 34 | } 35 | System.out.println("SHA: " + shaStr); 36 | System.out.println("URI: " + uriSha); 37 | 38 | sig = String.format(sig, src.length, shaStr); 39 | 40 | Files.write(Paths.get("loader/src/main/java/sig.java"), sig.getBytes()); 41 | Files.createDirectories(Paths.get("loader/build/libs/")); 42 | Files.write(Paths.get("loader/build/libs/runescape" + uriSha + ".jar"), src); 43 | } catch (Exception ex) { 44 | ex.printStackTrace(); 45 | System.exit(1); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /tools/src/main/java/lostcity/tools/MapviewConvert.java: -------------------------------------------------------------------------------- 1 | package lostcity.tools; 2 | 3 | import javax.imageio.ImageIO; 4 | import java.awt.image.BufferedImage; 5 | import java.io.IOException; 6 | import java.nio.file.Files; 7 | import java.nio.file.Paths; 8 | 9 | public class MapviewConvert { 10 | public static void main(String[] args) { 11 | // read in a file named "map-$width-$height-rgb.raw" 12 | // convert it to a file named "map-$width-$height.png" 13 | // we can extract the dimensions from the file name 14 | // the rgb indicates it's already in a 24-bit format so we don't have to do any conversion 15 | 16 | if (args.length != 1) { 17 | System.err.println("Usage: MapviewConvert "); 18 | System.exit(1); 19 | } 20 | 21 | String filename = args[0]; 22 | String[] parts = filename.split("-"); 23 | if (parts.length != 4) { 24 | System.err.println("Filename must be of the form map-$width-$height-rgb.raw"); 25 | System.exit(1); 26 | } 27 | 28 | int width = Integer.parseInt(parts[1]); 29 | int height = Integer.parseInt(parts[2]); 30 | 31 | System.out.println("Converting " + filename + " to map-" + width + "-" + height + ".png"); 32 | 33 | try { 34 | byte[] src = Files.readAllBytes(Paths.get(filename)); 35 | BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 36 | 37 | int index = 0; 38 | for (int y = 0; y < height; y++) { 39 | for (int x = 0; x < width; x++) { 40 | int r = src[index++] & 0xFF; 41 | int g = src[index++] & 0xFF; 42 | int b = src[index++] & 0xFF; 43 | int rgb = (r << 16) | (g << 8) | b; 44 | img.setRGB(x, y, rgb); 45 | } 46 | } 47 | 48 | ImageIO.write(img, "png", Paths.get("map-" + width + "-" + height + ".png").toFile()); 49 | } catch (IOException ex) { 50 | ex.printStackTrace(); 51 | System.exit(1); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /tools/src/main/java/lostcity/tools/MapviewSig.java: -------------------------------------------------------------------------------- 1 | package lostcity.tools; 2 | 3 | import java.nio.file.Files; 4 | import java.nio.file.Paths; 5 | import java.security.MessageDigest; 6 | 7 | public class MapviewSig { 8 | public static void main(String[] args) { 9 | String sig = "public class sig {\n\tpublic static final int len = %d;\n\n\tpublic static final int[] sha = { %s };\n}"; 10 | 11 | try { 12 | String name = args[0]; 13 | byte[] src = Files.readAllBytes(Paths.get(name)); 14 | 15 | System.out.println("len: " + src.length); 16 | 17 | MessageDigest shasum = MessageDigest.getInstance("SHA"); 18 | shasum.reset(); 19 | shasum.update(src); 20 | 21 | String shaStr = ""; 22 | String uriSha = ""; 23 | byte[] sha = shasum.digest(); 24 | for (int i = 0; i < 20; i++) { 25 | if (i < 10) { 26 | uriSha += sha[i]; 27 | } 28 | 29 | if (i < 19) { 30 | shaStr += sha[i] + ", "; 31 | } else { 32 | shaStr += sha[i]; 33 | } 34 | } 35 | System.out.println("SHA: " + shaStr); 36 | System.out.println("URI: " + uriSha); 37 | 38 | sig = String.format(sig, src.length, shaStr); 39 | 40 | Files.write(Paths.get("mapview/src/main/java/sig.java"), sig.getBytes()); 41 | } catch (Exception ex) { 42 | ex.printStackTrace(); 43 | System.exit(1); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /tools/src/main/java/lostcity/tools/RemoveAnnotations.java: -------------------------------------------------------------------------------- 1 | package lostcity.tools; 2 | 3 | import lostcity.utils.FileUtils; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.util.Collection; 8 | import java.util.Iterator; 9 | 10 | public class RemoveAnnotations { 11 | public static void main(String[] args) { 12 | // in order to build for ancient Java versions, iterate through every single .java file and remove annotations (Java 5+) 13 | Collection source = FileUtils.listFiles(new File("runetek3/src/main/java"), new String[]{ "java" }, true); 14 | source.addAll(FileUtils.listFiles(new File("client/src/main/java"), new String[]{ "java" }, true)); 15 | source.addAll(FileUtils.listFiles(new File("mapview/src/main/java"), new String[]{ "java" }, true)); 16 | for (Iterator iterator = source.iterator(); iterator.hasNext();) { 17 | File file = iterator.next(); 18 | 19 | try { 20 | String contents = FileUtils.readFileToString(file); 21 | contents = contents.replaceAll("@Override", ""); 22 | contents = contents.replaceAll("@OriginalArg\\(\\d+\\) ", ""); 23 | contents = contents.replaceAll("@OriginalClass\\(.*\\)", ""); 24 | contents = contents.replaceAll("@OriginalMember\\(.*\\)", ""); 25 | contents = contents.replaceAll("@Pc\\(\\d+\\) ", ""); 26 | contents = contents.replaceAll("import org\\.openrs2\\.deob\\.annotation\\..*;", ""); 27 | FileUtils.writeStringToFile(file, contents); 28 | } catch (IOException ex) { 29 | ex.printStackTrace(); 30 | } 31 | } 32 | 33 | // and then remove deob-annotations as a dependency from the build.gradle file 34 | // also update the build.gradle file to use a lower java version (make sure the runner is using a compatible JDK) 35 | Collection build = FileUtils.listFiles(new File("."), new String[]{ "gradle" }, true); 36 | for (Iterator iterator = build.iterator(); iterator.hasNext();) { 37 | File file = iterator.next(); 38 | 39 | try { 40 | String contents = FileUtils.readFileToString(file); 41 | contents = contents.replaceAll("compileOnly project\\(':deob-annotations'\\)", ""); 42 | contents = contents.replaceAll("sourceCompatibility = JavaVersion\\.VERSION_1_8", "sourceCompatibility = JavaVersion.VERSION_1_2"); 43 | contents = contents.replaceAll("targetCompatibility = JavaVersion\\.VERSION_1_8", "targetCompatibility = JavaVersion.VERSION_1_1"); 44 | FileUtils.writeStringToFile(file, contents); 45 | } catch (IOException ex) { 46 | ex.printStackTrace(); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tools/src/main/java/lostcity/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | package lostcity.utils; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.nio.charset.StandardCharsets; 6 | import java.nio.file.Files; 7 | import java.nio.file.Paths; 8 | import java.util.ArrayList; 9 | import java.util.Collection; 10 | 11 | public class FileUtils { 12 | public static Collection listFiles(File directory, String[] extensions, boolean recursive) { 13 | Collection files = new ArrayList<>(); 14 | 15 | if (directory.isDirectory()) { 16 | File[] found = directory.listFiles(); 17 | 18 | for (int i = 0; i < found.length; i++) { 19 | File file = found[i]; 20 | if (file.isDirectory()) { 21 | if (recursive) { 22 | files.addAll(listFiles(file, extensions, recursive)); 23 | } 24 | } else { 25 | for (int j = 0; j < extensions.length; j++) { 26 | String extension = extensions[j]; 27 | if (file.getName().endsWith(extension)) { 28 | files.add(file); 29 | } 30 | } 31 | } 32 | } 33 | } 34 | 35 | return files; 36 | } 37 | 38 | public static String readFileToString(File file) throws IOException { 39 | byte[] encoded = Files.readAllBytes(file.toPath()); 40 | return new String(encoded, StandardCharsets.UTF_8); 41 | } 42 | 43 | public static void writeStringToFile(File file, String contents) throws IOException { 44 | Files.write(Paths.get(file.toURI()), contents.getBytes(StandardCharsets.UTF_8)); 45 | } 46 | } 47 | --------------------------------------------------------------------------------