cache: Rev 187

This commit is contained in:
TheRealNull
2020-01-16 21:31:12 -05:00
parent 171fe9e76c
commit 5952c01c85
196 changed files with 28663 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
.gradle
.idea
build

26
LICENSE Normal file
View File

@@ -0,0 +1,26 @@
BSD 2-Clause License
Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
Copyright (c) 2020, Null <TheRealNull@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# cache
Tools for modifying the osrs cache

82
build.gradle.kts Normal file
View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
java
`maven-publish`
}
group = "com.openosrs"
version = "1.0-SNAPSHOT"
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
annotationProcessor("org.projectlombok:lombok:1.18.10")
implementation("org.projectlombok:lombok:1.18.10")
implementation("com.google.code.gson:gson:2.8.6")
implementation("com.google.guava:guava:28.2-jre")
implementation("commons-cli:commons-cli:1.4")
implementation("io.netty:netty-buffer:4.1.44.Final")
implementation("org.antlr:antlr4-runtime:4.7.2")
implementation("org.apache.commons:commons-compress:1.19")
implementation("org.slf4j:slf4j-api:1.7.30")
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_11
}
tasks {
compileJava {
options.encoding = "UTF-8"
}
}
val sourcesJar by tasks.registering(Jar::class) {
classifier = "sources"
from(sourceSets.main.get().allSource)
}
publishing {
repositories {
maven {
url = uri("$buildDir/repo")
}
}
publications {
register("mavenJava", MavenPublication::class) {
from(components["java"])
artifact(sourcesJar.get())
}
}
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

172
gradlew vendored Normal file
View File

@@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

2
settings.gradle.kts Normal file
View File

@@ -0,0 +1,2 @@
rootProject.name = "cache"

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
grammar rs2asm;
prog: NEWLINE* (header NEWLINE+)* (line NEWLINE+)+ ;
header: id | int_stack_count | string_stack_count | int_var_count | string_var_count ;
id: '.id ' id_value ;
int_stack_count: '.int_stack_count ' int_stack_value ;
string_stack_count: '.string_stack_count ' string_stack_value ;
int_var_count: '.int_var_count ' int_var_value ;
string_var_count: '.string_var_count ' string_var_value ;
id_value: INT ;
int_stack_value: INT ;
string_stack_value: INT ;
int_var_value: INT ;
string_var_value: INT ;
line: instruction | label | switch_lookup ;
instruction: instruction_name instruction_operand ;
label: IDENTIFIER ':' ;
instruction_name: name_string | name_opcode ;
name_string: IDENTIFIER ;
name_opcode: INT ;
instruction_operand: operand_int | operand_qstring | operand_label | ;
operand_int: INT ;
operand_qstring: QSTRING ;
operand_label: IDENTIFIER ;
switch_lookup: switch_key ':' switch_value ;
switch_key: INT ;
switch_value: IDENTIFIER ;
NEWLINE: ( '\r' | '\n' )+ ;
INT: '-'? [0-9]+ ;
QSTRING: '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"' ;
IDENTIFIER: [a-zA-Z0-9_]+ ;
COMMENT: ';' ~( '\r' | '\n' )* -> channel(HIDDEN) ;
WS: (' ' | '\t')+ -> channel(HIDDEN) ;

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.runelite.cache.definitions.AreaDefinition;
import net.runelite.cache.definitions.loaders.AreaLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
public class AreaManager
{
private final Store store;
private final Map<Integer, AreaDefinition> areas = new HashMap<>();
public AreaManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.AREA.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile file : files.getFiles())
{
AreaLoader loader = new AreaLoader();
AreaDefinition area = loader.load(file.getContents(), file.getFileId());
areas.put(area.id, area);
}
}
public Collection<AreaDefinition> getAreas()
{
return Collections.unmodifiableCollection(areas.values());
}
public AreaDefinition getArea(int areaId)
{
return areas.get(areaId);
}
}

View File

@@ -0,0 +1,161 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.File;
import java.io.IOException;
import net.runelite.cache.fs.Store;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
public class Cache
{
public static void main(String[] args) throws IOException
{
Options options = new Options();
options.addOption("c", "cache", true, "cache base");
options.addOption(null, "items", true, "directory to dump items to");
options.addOption(null, "npcs", true, "directory to dump npcs to");
options.addOption(null, "objects", true, "directory to dump objects to");
options.addOption(null, "sprites", true, "directory to dump sprites to");
CommandLineParser parser = new DefaultParser();
CommandLine cmd;
try
{
cmd = parser.parse(options, args);
}
catch (ParseException ex)
{
System.err.println("Error parsing command line options: " + ex.getMessage());
System.exit(-1);
return;
}
String cache = cmd.getOptionValue("cache");
Store store = loadStore(cache);
if (cmd.hasOption("items"))
{
String itemdir = cmd.getOptionValue("items");
if (itemdir == null)
{
System.err.println("Item directory must be specified");
return;
}
System.out.println("Dumping items to " + itemdir);
dumpItems(store, new File(itemdir));
}
else if (cmd.hasOption("npcs"))
{
String npcdir = cmd.getOptionValue("npcs");
if (npcdir == null)
{
System.err.println("NPC directory must be specified");
return;
}
System.out.println("Dumping npcs to " + npcdir);
dumpNpcs(store, new File(npcdir));
}
else if (cmd.hasOption("objects"))
{
String objectdir = cmd.getOptionValue("objects");
if (objectdir == null)
{
System.err.println("Object directory must be specified");
return;
}
System.out.println("Dumping objects to " + objectdir);
dumpObjects(store, new File(objectdir));
}
else if (cmd.hasOption("sprites"))
{
String spritedir = cmd.getOptionValue("sprites");
if (spritedir == null)
{
System.err.println("Sprite directory must be specified");
return;
}
System.out.println("Dumping sprites to " + spritedir);
dumpSprites(store, new File(spritedir));
}
else
{
System.err.println("Nothing to do");
}
}
private static Store loadStore(String cache) throws IOException
{
Store store = new Store(new File("./osrs_cache/"));
store.load();
return store;
}
private static void dumpItems(Store store, File itemdir) throws IOException
{
ItemManager dumper = new ItemManager(store);
dumper.load();
dumper.export(itemdir);
dumper.java(itemdir);
}
private static void dumpNpcs(Store store, File npcdir) throws IOException
{
NpcManager dumper = new NpcManager(store);
dumper.load();
dumper.dump(npcdir);
dumper.java(npcdir);
}
private static void dumpObjects(Store store, File objectdir) throws IOException
{
ObjectManager dumper = new ObjectManager(store);
dumper.load();
dumper.dump(objectdir);
dumper.java(objectdir);
}
private static void dumpSprites(Store store, File spritedir) throws IOException
{
SpriteManager dumper = new SpriteManager(store);
dumper.load();
dumper.export(spritedir);
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
public enum ConfigType
{
// types from https://github.com/im-frizzy/OpenRS/blob/master/source/net/openrs/cache/type/ConfigArchive.java
UNDERLAY(1),
IDENTKIT(3),
OVERLAY(4),
INV(5),
OBJECT(6),
ENUM(8),
NPC(9),
ITEM(10),
PARAMS(11),
SEQUENCE(12),
SPOTANIM(13),
VARBIT(14),
VARCLIENT(19),
VARCLIENTSTRING(15),
VARPLAYER(16),
STRUCT(34),
AREA(35);
private final int id;
ConfigType(int id)
{
this.id = id;
}
public int getId()
{
return id;
}
}

View File

@@ -0,0 +1,149 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.IOException;
import net.runelite.cache.fs.Store;
import net.runelite.cache.region.Region;
import net.runelite.cache.region.RegionLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HeightMapDumper
{
private static final Logger logger = LoggerFactory.getLogger(HeightMapDumper.class);
private static final int MAP_SCALE = 1;
private static final float MAX_HEIGHT = 2048f;
private final Store store;
private RegionLoader regionLoader;
public HeightMapDumper(Store store)
{
this.store = store;
}
public void load() throws IOException
{
regionLoader = new RegionLoader(store);
regionLoader.loadRegions();
regionLoader.calculateBounds();
}
public BufferedImage drawHeightMap(int z)
{
int minX = regionLoader.getLowestX().getBaseX();
int minY = regionLoader.getLowestY().getBaseY();
int maxX = regionLoader.getHighestX().getBaseX() + Region.X;
int maxY = regionLoader.getHighestY().getBaseY() + Region.Y;
int dimX = maxX - minX;
int dimY = maxY - minY;
dimX *= MAP_SCALE;
dimY *= MAP_SCALE;
logger.info("Map image dimensions: {}px x {}px, {}px per map square ({} MB)", dimX, dimY, MAP_SCALE, (dimX * dimY / 1024 / 1024));
BufferedImage image = new BufferedImage(dimX, dimY, BufferedImage.TYPE_INT_RGB);
draw(image, z);
return image;
}
private void draw(BufferedImage image, int z)
{
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
for (Region region : regionLoader.getRegions())
{
int baseX = region.getBaseX();
int baseY = region.getBaseY();
// to pixel X
int drawBaseX = baseX - regionLoader.getLowestX().getBaseX();
// to pixel Y. top most y is 0, but the top most
// region has the greatest y, so invert
int drawBaseY = regionLoader.getHighestY().getBaseY() - baseY;
for (int x = 0; x < Region.X; ++x)
{
int drawX = drawBaseX + x;
for (int y = 0; y < Region.Y; ++y)
{
int drawY = drawBaseY + (Region.Y - 1 - y);
int height = region.getTileHeight(z, x, y);
if (height > max)
{
max = height;
}
if (height < min)
{
min = height;
}
int rgb = toColor(height);
drawMapSquare(image, drawX, drawY, rgb);
}
}
}
System.out.println("max " + max);
System.out.println("min " + min);
}
private int toColor(int height)
{
// height seems to be between -2040 and 0, inclusive
height = -height;
// Convert to between 0 and 1
float color = (float) height / MAX_HEIGHT;
assert color >= 0.0f && color <= 1.0f;
return new Color(color, color, color).getRGB();
}
private void drawMapSquare(BufferedImage image, int x, int y, int rgb)
{
x *= MAP_SCALE;
y *= MAP_SCALE;
for (int i = 0; i < MAP_SCALE; ++i)
{
for (int j = 0; j < MAP_SCALE; ++j)
{
image.setRGB(x + i, y + j, rgb);
}
}
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
public enum IndexType
{
FRAMES(0),
FRAMEMAPS(1),
CONFIGS(2),
INTERFACES(3),
SOUNDEFFECTS(4),
MAPS(5),
TRACK1(6),
MODELS(7),
SPRITES(8),
TEXTURES(9),
BINARY(10),
TRACK2(11),
CLIENTSCRIPT(12),
FONTS(13),
VORBIS(14),
INSTRUMENTS(15),
WORLDMAP(16);
private int id;
IndexType(int id)
{
this.id = id;
}
public int getNumber()
{
return id;
}
}

View File

@@ -0,0 +1,176 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import net.runelite.cache.definitions.InterfaceDefinition;
import net.runelite.cache.definitions.exporters.InterfaceExporter;
import net.runelite.cache.definitions.loaders.InterfaceLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import net.runelite.cache.util.Namer;
public class InterfaceManager
{
private final Store store;
private InterfaceDefinition[][] interfaces;
private final Namer namer = new Namer();
public InterfaceManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
InterfaceLoader loader = new InterfaceLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.INTERFACES);
int max = index.getArchives().stream().mapToInt(a -> a.getArchiveId()).max().getAsInt();
interfaces = new InterfaceDefinition[max + 1][];
for (Archive archive : index.getArchives())
{
int archiveId = archive.getArchiveId();
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
InterfaceDefinition[] ifaces = interfaces[archiveId];
if (ifaces == null)
{
ifaces = interfaces[archiveId] = new InterfaceDefinition[archive.getFileData().length];
}
for (FSFile file : files.getFiles())
{
int fileId = file.getFileId();
int widgetId = (archiveId << 16) + fileId;
InterfaceDefinition iface = loader.load(widgetId, file.getContents());
ifaces[fileId] = iface;
}
}
}
public int getNumInterfaceGroups()
{
return interfaces.length;
}
public int getNumChildren(int groupId)
{
return interfaces[groupId].length;
}
public InterfaceDefinition[] getIntefaceGroup(int groupId)
{
return interfaces[groupId];
}
public InterfaceDefinition getInterface(int groupId, int childId)
{
return interfaces[groupId][childId];
}
public InterfaceDefinition[][] getInterfaces()
{
return interfaces;
}
public void export(File out) throws IOException
{
out.mkdirs();
for (InterfaceDefinition[] defs : interfaces)
{
if (defs == null)
{
continue;
}
for (InterfaceDefinition def : defs)
{
if (def == null)
{
continue;
}
InterfaceExporter exporter = new InterfaceExporter(def);
File folder = new File(out, "" + (def.id >>> 16));
folder.mkdirs();
File targ = new File(folder, (def.id & 0xffff) + ".json");
exporter.exportTo(targ);
}
}
}
public void java(File java) throws IOException
{
System.setProperty("line.separator", "\n");
java.mkdirs();
File targ = new File(java, "InterfaceID.java");
try (PrintWriter fw = new PrintWriter(targ))
{
fw.println("/* This file is automatically generated. Do not edit. */");
fw.println("package net.runelite.api;");
fw.println("");
fw.println("public final class InterfaceID {");
for (InterfaceDefinition[] defs : interfaces)
{
if (defs == null)
{
continue;
}
for (InterfaceDefinition def : defs)
{
if (def == null || def.name == null || def.name.equalsIgnoreCase("NULL"))
{
continue;
}
String name = namer.name(def.name, def.id);
if (name == null)
{
continue;
}
fw.println(" public static final int " + name + " = " + def.id + ";");
}
}
fw.println("}");
}
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.runelite.cache.definitions.InventoryDefinition;
import net.runelite.cache.definitions.loaders.InventoryLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
public class InventoryManager
{
private final Store store;
private final List<InventoryDefinition> inventories = new ArrayList<>();
public InventoryManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
InventoryLoader loader = new InventoryLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.INV.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile file : files.getFiles())
{
InventoryDefinition inv = loader.load(file.getFileId(), file.getContents());
inventories.add(inv);
}
}
public List<InventoryDefinition> getInventories()
{
return Collections.unmodifiableList(inventories);
}
public InventoryDefinition findInventory(int id)
{
for (InventoryDefinition def : inventories)
{
if (def.id == id)
{
return def;
}
}
return null;
}
}

View File

@@ -0,0 +1,123 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.runelite.cache.definitions.ItemDefinition;
import net.runelite.cache.definitions.exporters.ItemExporter;
import net.runelite.cache.definitions.loaders.ItemLoader;
import net.runelite.cache.definitions.providers.ItemProvider;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import net.runelite.cache.util.IDClass;
public class ItemManager implements ItemProvider
{
private final Store store;
private final Map<Integer, ItemDefinition> items = new HashMap<>();
public ItemManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
ItemLoader loader = new ItemLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.ITEM.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile f : files.getFiles())
{
ItemDefinition def = loader.load(f.getFileId(), f.getContents());
items.put(f.getFileId(), def);
}
}
public Collection<ItemDefinition> getItems()
{
return Collections.unmodifiableCollection(items.values());
}
public ItemDefinition getItem(int itemId)
{
return items.get(itemId);
}
public void export(File out) throws IOException
{
out.mkdirs();
for (ItemDefinition def : items.values())
{
ItemExporter exporter = new ItemExporter(def);
File targ = new File(out, def.id + ".json");
exporter.exportTo(targ);
}
}
public void java(File java) throws IOException
{
java.mkdirs();
try (IDClass ids = IDClass.create(java, "ItemID"))
{
try (IDClass nulls = IDClass.create(java, "NullItemID"))
{
for (ItemDefinition def : items.values())
{
if (def.name.equalsIgnoreCase("NULL"))
{
nulls.add(def.name, def.id);
}
else
{
ids.add(def.name, def.id);
}
}
}
}
}
@Override
public ItemDefinition provide(int itemId)
{
return getItem(itemId);
}
}

View File

@@ -0,0 +1,987 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import net.runelite.cache.definitions.AreaDefinition;
import net.runelite.cache.definitions.ObjectDefinition;
import net.runelite.cache.definitions.OverlayDefinition;
import net.runelite.cache.definitions.SpriteDefinition;
import net.runelite.cache.definitions.UnderlayDefinition;
import net.runelite.cache.definitions.loaders.OverlayLoader;
import net.runelite.cache.definitions.loaders.SpriteLoader;
import net.runelite.cache.definitions.loaders.UnderlayLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import net.runelite.cache.item.ColorPalette;
import net.runelite.cache.item.RSTextureProvider;
import net.runelite.cache.region.Location;
import net.runelite.cache.region.Region;
import net.runelite.cache.region.RegionLoader;
import net.runelite.cache.util.Djb2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MapImageDumper
{
private static final Logger logger = LoggerFactory.getLogger(MapImageDumper.class);
private static final int MAP_SCALE = 4; // this squared is the number of pixels per map square
private static final int MAPICON_MAX_WIDTH = 5; // scale minimap icons down to this size so they fit..
private static final int MAPICON_MAX_HEIGHT = 6;
private static final int BLEND = 5; // number of surrounding tiles for ground blending
private static int[] colorPalette = new ColorPalette(0.9d, 0, 512).getColorPalette();
private static int[][] TILE_SHAPE_2D = new int[][]{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}};
private static int[][] TILE_ROTATION_2D = new int[][]{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3}, {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}};
private final int wallColor = (238 + (int) (Math.random() * 20.0D) - 10 << 16) + (238 + (int) (Math.random() * 20.0D) - 10 << 8) + (238 + (int) (Math.random() * 20.0D) - 10);
private final int doorColor = 238 + (int) (Math.random() * 20.0D) - 10 << 16;
private final Store store;
private final Map<Integer, UnderlayDefinition> underlays = new HashMap<>();
private final Map<Integer, OverlayDefinition> overlays = new HashMap<>();
private final Map<Integer, Image> scaledMapIcons = new HashMap<>();
private RegionLoader regionLoader;
private final AreaManager areas;
private final SpriteManager sprites;
private RSTextureProvider rsTextureProvider;
private final ObjectManager objectManager;
@Getter
@Setter
private boolean labelRegions;
@Getter
@Setter
private boolean outlineRegions;
public MapImageDumper(Store store)
{
this.store = store;
this.areas = new AreaManager(store);
this.sprites = new SpriteManager(store);
objectManager = new ObjectManager(store);
}
public void load() throws IOException
{
loadUnderlays(store);
loadOverlays(store);
objectManager.load();
TextureManager textureManager = new TextureManager(store);
textureManager.load();
rsTextureProvider = new RSTextureProvider(textureManager, sprites);
loadRegions(store);
areas.load();
sprites.load();
loadSprites();
}
public BufferedImage drawMap(int z)
{
int minX = regionLoader.getLowestX().getBaseX();
int minY = regionLoader.getLowestY().getBaseY();
int maxX = regionLoader.getHighestX().getBaseX() + Region.X;
int maxY = regionLoader.getHighestY().getBaseY() + Region.Y;
int dimX = maxX - minX;
int dimY = maxY - minY;
int pixelsX = dimX * MAP_SCALE;
int pixelsY = dimY * MAP_SCALE;
logger.info("Map image dimensions: {}px x {}px, {}px per map square ({} MB). Max memory: {}mb", pixelsX, pixelsY,
MAP_SCALE, (pixelsX * pixelsY * 3 / 1024 / 1024),
Runtime.getRuntime().maxMemory() / 1024L / 1024L);
BufferedImage image = new BufferedImage(pixelsX, pixelsY, BufferedImage.TYPE_INT_RGB);
drawMap(image, z);
drawObjects(image, z);
drawMapIcons(image, z);
return image;
}
public BufferedImage drawRegion(Region region, int z)
{
int pixelsX = Region.X * MAP_SCALE;
int pixelsY = Region.Y * MAP_SCALE;
BufferedImage image = new BufferedImage(pixelsX, pixelsY, BufferedImage.TYPE_INT_RGB);
drawMap(image, 0, 0, z, region);
drawObjects(image, 0, 0, region, z);
drawMapIcons(image, 0, 0, region, z);
return image;
}
private void drawMap(BufferedImage image, int drawBaseX, int drawBaseY, int z, Region region)
{
int[][] map = new int[Region.X * MAP_SCALE][Region.Y * MAP_SCALE];
drawMap(map, region, z);
int[][] above = null;
if (z < 3)
{
above = new int[Region.X * MAP_SCALE][Region.Y * MAP_SCALE];
drawMap(above, region, z + 1);
}
for (int x = 0; x < Region.X; ++x)
{
for (int y = 0; y < Region.Y; ++y)
{
boolean isBridge = (region.getTileSetting(1, x, Region.Y - y - 1) & 2) != 0;
int tileSetting = region.getTileSetting(z, x, Region.Y - y - 1);
if (!isBridge && ((tileSetting & 24) == 0))
{
drawTile(image, map, drawBaseX, drawBaseY, x, y);
}
if (z < 3 && isBridge) // client also has a check for &8 != 0 here
{
drawTile(image, above, drawBaseX, drawBaseY, x, y);
}
}
}
}
private void drawMap(BufferedImage image, int z)
{
for (Region region : regionLoader.getRegions())
{
int baseX = region.getBaseX();
int baseY = region.getBaseY();
// to pixel X
int drawBaseX = baseX - regionLoader.getLowestX().getBaseX();
// to pixel Y. top most y is 0, but the top most
// region has the greatest y, so invert
int drawBaseY = regionLoader.getHighestY().getBaseY() - baseY;
drawMap(image, drawBaseX, drawBaseY, z, region);
}
}
private void drawTile(BufferedImage to, int[][] pixels, int drawBaseX, int drawBaseY, int x, int y)
{
for (int i = 0; i < MAP_SCALE; ++i)
{
for (int j = 0; j < MAP_SCALE; ++j)
{
to.setRGB(drawBaseX * MAP_SCALE + x * MAP_SCALE + i,
drawBaseY * MAP_SCALE + y * MAP_SCALE + j,
pixels[x * MAP_SCALE + i][y * MAP_SCALE + j]);
}
}
}
private void drawMap(int[][] pixels, Region region, int z)
{
int baseX = region.getBaseX();
int baseY = region.getBaseY();
int len = Region.X + BLEND * 2;
int[] hues = new int[len];
int[] sats = new int[len];
int[] light = new int[len];
int[] mul = new int[len];
int[] num = new int[len];
boolean hasLeftRegion = regionLoader.findRegionForWorldCoordinates(baseX - 1, baseY) != null;
boolean hasRightRegion = regionLoader.findRegionForWorldCoordinates(baseX + Region.X, baseY) != null;
boolean hasUpRegion = regionLoader.findRegionForWorldCoordinates(baseX, baseY + Region.Y) != null;
boolean hasDownRegion = regionLoader.findRegionForWorldCoordinates(baseX, baseY - 1) != null;
for (int xi = (hasLeftRegion ? -BLEND * 2 : -BLEND); xi < Region.X + (hasRightRegion ? BLEND * 2 : BLEND); ++xi)
{
for (int yi = (hasDownRegion ? -BLEND : 0); yi < Region.Y + (hasUpRegion ? BLEND : 0); ++yi)
{
int xr = xi + BLEND;
if (xr >= (hasLeftRegion ? -BLEND : 0) && xr < Region.X + (hasRightRegion ? BLEND : 0))
{
Region r = regionLoader.findRegionForWorldCoordinates(baseX + xr, baseY + yi);
if (r != null)
{
int underlayId = r.getUnderlayId(z, convert(xr), convert(yi));
if (underlayId > 0)
{
UnderlayDefinition underlay = findUnderlay(underlayId - 1);
hues[yi + BLEND] += underlay.getHue();
sats[yi + BLEND] += underlay.getSaturation();
light[yi + BLEND] += underlay.getLightness();
mul[yi + BLEND] += underlay.getHueMultiplier();
num[yi + BLEND]++;
}
}
}
int xl = xi - BLEND;
if (xl >= (hasLeftRegion ? -BLEND : 0) && xl < Region.X + (hasRightRegion ? BLEND : 0))
{
Region r = regionLoader.findRegionForWorldCoordinates(baseX + xl, baseY + yi);
if (r != null)
{
int underlayId = r.getUnderlayId(z, convert(xl), convert(yi));
if (underlayId > 0)
{
UnderlayDefinition underlay = findUnderlay(underlayId - 1);
hues[yi + BLEND] -= underlay.getHue();
sats[yi + BLEND] -= underlay.getSaturation();
light[yi + BLEND] -= underlay.getLightness();
mul[yi + BLEND] -= underlay.getHueMultiplier();
num[yi + BLEND]--;
}
}
}
}
if (xi >= 0 && xi < Region.X)
{
int runningHues = 0;
int runningSat = 0;
int runningLight = 0;
int runningMultiplier = 0;
int runningNumber = 0;
for (int yi = (hasDownRegion ? -BLEND * 2 : -BLEND); yi < Region.Y + (hasUpRegion ? BLEND * 2 : BLEND); ++yi)
{
int yu = yi + BLEND;
if (yu >= (hasDownRegion ? -BLEND : 0) && yu < Region.Y + (hasUpRegion ? BLEND : 0))
{
runningHues += hues[yu + BLEND];
runningSat += sats[yu + BLEND];
runningLight += light[yu + BLEND];
runningMultiplier += mul[yu + BLEND];
runningNumber += num[yu + BLEND];
}
int yd = yi - BLEND;
if (yd >= (hasDownRegion ? -BLEND : 0) && yd < Region.Y + (hasUpRegion ? BLEND : 0))
{
runningHues -= hues[yd + BLEND];
runningSat -= sats[yd + BLEND];
runningLight -= light[yd + BLEND];
runningMultiplier -= mul[yd + BLEND];
runningNumber -= num[yd + BLEND];
}
if (yi >= 0 && yi < Region.Y)
{
Region r = regionLoader.findRegionForWorldCoordinates(baseX + xi, baseY + yi);
if (r != null)
{
int underlayId = r.getUnderlayId(z, convert(xi), convert(yi));
int overlayId = r.getOverlayId(z, convert(xi), convert(yi));
if (underlayId > 0 || overlayId > 0)
{
int underlayHsl = -1;
if (underlayId > 0)
{
int avgHue = runningHues * 256 / runningMultiplier;
int avgSat = runningSat / runningNumber;
int avgLight = runningLight / runningNumber;
// randomness is added to avgHue here
if (avgLight < 0)
{
avgLight = 0;
}
else if (avgLight > 255)
{
avgLight = 255;
}
underlayHsl = packHsl(avgHue, avgSat, avgLight);
}
int underlayRgb = 0;
if (underlayHsl != -1)
{
int var0 = method1792(underlayHsl, 96);
underlayRgb = colorPalette[var0];
}
int shape, rotation;
Integer overlayRgb = null;
if (overlayId == 0)
{
shape = rotation = 0;
}
else
{
shape = r.getOverlayPath(z, convert(xi), convert(yi)) + 1;
rotation = r.getOverlayRotation(z, convert(xi), convert(yi));
OverlayDefinition overlayDefinition = findOverlay(overlayId - 1);
int overlayTexture = overlayDefinition.getTexture();
int rgb;
if (overlayTexture >= 0)
{
rgb = rsTextureProvider.getAverageTextureRGB(overlayTexture);
}
else if (overlayDefinition.getRgbColor() == 0xFF_00FF)
{
rgb = -2;
}
else
{
// randomness added here
int overlayHsl = packHsl(overlayDefinition.getHue(), overlayDefinition.getSaturation(), overlayDefinition.getLightness());
rgb = overlayHsl;
}
overlayRgb = 0;
if (rgb != -2)
{
int var0 = adjustHSLListness0(rgb, 96);
overlayRgb = colorPalette[var0];
}
if (overlayDefinition.getSecondaryRgbColor() != -1)
{
int hue = overlayDefinition.getOtherHue();
int sat = overlayDefinition.getOtherSaturation();
int olight = overlayDefinition.getOtherLightness();
rgb = packHsl(hue, sat, olight);
int var0 = adjustHSLListness0(rgb, 96);
overlayRgb = colorPalette[var0];
}
}
if (shape == 0)
{
int drawX = xi;
int drawY = Region.Y - 1 - yi;
if (underlayRgb != 0)
{
drawMapSquare(pixels, drawX, drawY, underlayRgb);
}
}
else if (shape == 1)
{
int drawX = xi;
int drawY = Region.Y - 1 - yi;
drawMapSquare(pixels, drawX, drawY, overlayRgb);
}
else
{
int drawX = xi * MAP_SCALE;
int drawY = (Region.Y - 1 - yi) * MAP_SCALE;
int[] tileShapes = TILE_SHAPE_2D[shape];
int[] tileRotations = TILE_ROTATION_2D[rotation];
if (underlayRgb != 0)
{
int rotIdx = 0;
for (int i = 0; i < Region.Z; ++i)
{
int p1 = tileShapes[tileRotations[rotIdx++]] == 0 ? underlayRgb : overlayRgb;
int p2 = tileShapes[tileRotations[rotIdx++]] == 0 ? underlayRgb : overlayRgb;
int p3 = tileShapes[tileRotations[rotIdx++]] == 0 ? underlayRgb : overlayRgb;
int p4 = tileShapes[tileRotations[rotIdx++]] == 0 ? underlayRgb : overlayRgb;
pixels[drawX + 0][drawY + i] = p1;
pixels[drawX + 1][drawY + i] = p2;
pixels[drawX + 2][drawY + i] = p3;
pixels[drawX + 3][drawY + i] = p4;
}
}
else
{
int rotIdx = 0;
for (int i = 0; i < Region.Z; ++i)
{
int p1 = tileShapes[tileRotations[rotIdx++]];
int p2 = tileShapes[tileRotations[rotIdx++]];
int p3 = tileShapes[tileRotations[rotIdx++]];
int p4 = tileShapes[tileRotations[rotIdx++]];
if (p1 != 0)
{
pixels[drawX + 0][drawY + i] = overlayRgb;
}
if (p2 != 0)
{
pixels[drawX + 1][drawY + i] = overlayRgb;
}
if (p3 != 0)
{
pixels[drawX + 2][drawY + i] = overlayRgb;
}
if (p4 != 0)
{
pixels[drawX + 3][drawY + i] = overlayRgb;
}
}
}
}
}
}
}
}
}
}
}
private static int convert(int d)
{
if (d >= 0)
{
return d % 64;
}
else
{
return 64 - -(d % 64) - 1;
}
}
private void drawObjects(BufferedImage image, int drawBaseX, int drawBaseY, Region region, int z)
{
Graphics2D graphics = image.createGraphics();
for (Location location : region.getLocations())
{
int rotation = location.getOrientation();
int type = location.getType();
int localX = location.getPosition().getX() - region.getBaseX();
int localY = location.getPosition().getY() - region.getBaseY();
boolean isBridge = (region.getTileSetting(1, localX, localY) & 2) != 0;
if (location.getPosition().getZ() == z + 1)
{
if (!isBridge)
{
continue;
}
}
else if (location.getPosition().getZ() == z)
{
if (isBridge)
{
continue;
}
if ((region.getTileSetting(z, localX, localY) & 24) != 0)
{
continue;
}
}
else
{
continue;
}
ObjectDefinition object = findObject(location.getId());
int drawX = (drawBaseX + localX) * MAP_SCALE;
int drawY = (drawBaseY + (Region.Y - 1 - localY)) * MAP_SCALE;
if (type >= 0 && type <= 3)
{
// this is a wall
int hash = (localY << 7) + localX + (location.getId() << 14) + 0x4000_0000;
if (object.getWallOrDoor() == 0)
{
hash -= Integer.MIN_VALUE;
}
int rgb = wallColor;
if (hash > 0)
{
rgb = doorColor;
}
if (object.getMapSceneID() != -1)
{
Image spriteImage = scaledMapIcons.get(object.getMapSceneID());
graphics.drawImage(spriteImage, drawX * MAP_SCALE, drawY * MAP_SCALE, null);
}
else
{
if (type == 0 || type == 2)
{
if (rotation == 0)
{
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 0, drawY + 1, rgb);
image.setRGB(drawX + 0, drawY + 2, rgb);
image.setRGB(drawX + 0, drawY + 3, rgb);
}
else if (rotation == 1)
{
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 1, drawY + 0, rgb);
image.setRGB(drawX + 2, drawY + 0, rgb);
image.setRGB(drawX + 3, drawY + 0, rgb);
}
else if (rotation == 2)
{
image.setRGB(drawX + 3, drawY + 0, rgb);
image.setRGB(drawX + 3, drawY + 1, rgb);
image.setRGB(drawX + 3, drawY + 2, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
}
else if (rotation == 3)
{
image.setRGB(drawX + 0, drawY + 3, rgb);
image.setRGB(drawX + 1, drawY + 3, rgb);
image.setRGB(drawX + 2, drawY + 3, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
}
}
if (type == 3)
{
if (rotation == 0)
{
image.setRGB(drawX + 0, drawY + 0, rgb);
}
else if (rotation == 1)
{
image.setRGB(drawX + 3, drawY + 0, rgb);
}
else if (rotation == 2)
{
image.setRGB(drawX + 3, drawY + 3, rgb);
}
else if (rotation == 3)
{
image.setRGB(drawX + 0, drawY + 3, rgb);
}
}
if (type == 2)
{
if (rotation == 3)
{
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 0, drawY + 1, rgb);
image.setRGB(drawX + 0, drawY + 2, rgb);
image.setRGB(drawX + 0, drawY + 3, rgb);
}
else if (rotation == 0)
{
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 1, drawY + 0, rgb);
image.setRGB(drawX + 2, drawY + 0, rgb);
image.setRGB(drawX + 3, drawY + 0, rgb);
}
else if (rotation == 1)
{
image.setRGB(drawX + 3, drawY + 0, rgb);
image.setRGB(drawX + 3, drawY + 1, rgb);
image.setRGB(drawX + 3, drawY + 2, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
}
else if (rotation == 2)
{
image.setRGB(drawX + 0, drawY + 3, rgb);
image.setRGB(drawX + 1, drawY + 3, rgb);
image.setRGB(drawX + 2, drawY + 3, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
}
}
}
}
else if (type == 9)
{
if (object.getMapSceneID() != -1)
{
Image spriteImage = scaledMapIcons.get(object.getMapSceneID());
graphics.drawImage(spriteImage, drawX, drawY, null);
continue;
}
int hash = (localY << 7) + localX + (location.getId() << 14) + 0x4000_0000;
if (object.getWallOrDoor() == 0)
{
hash -= Integer.MIN_VALUE;
}
if ((hash >> 29 & 3) != 2)
{
continue;
}
int rgb = 0xEE_EEEE;
if (hash > 0)
{
rgb = 0xEE_0000;
}
if (rotation != 0 && rotation != 2)
{
image.setRGB(drawX + 0, drawY + 0, rgb);
image.setRGB(drawX + 1, drawY + 1, rgb);
image.setRGB(drawX + 2, drawY + 2, rgb);
image.setRGB(drawX + 3, drawY + 3, rgb);
}
else
{
image.setRGB(drawX + 0, drawY + 3, rgb);
image.setRGB(drawX + 1, drawY + 2, rgb);
image.setRGB(drawX + 2, drawY + 1, rgb);
image.setRGB(drawX + 3, drawY + 0, rgb);
}
}
else if (type == 22 || (type >= 9 && type <= 11))
{
// ground object
if (object.getMapSceneID() != -1)
{
Image spriteImage = scaledMapIcons.get(object.getMapSceneID());
graphics.drawImage(spriteImage, drawX, drawY, null);
}
}
}
graphics.dispose();
}
private void drawObjects(BufferedImage image, int z)
{
for (Region region : regionLoader.getRegions())
{
int baseX = region.getBaseX();
int baseY = region.getBaseY();
// to pixel X
int drawBaseX = baseX - regionLoader.getLowestX().getBaseX();
// to pixel Y. top most y is 0, but the top most
// region has the greatest y, so invert
int drawBaseY = regionLoader.getHighestY().getBaseY() - baseY;
drawObjects(image, drawBaseX, drawBaseY, region, z);
}
}
private void drawMapIcons(BufferedImage image, int drawBaseX, int drawBaseY, Region region, int z)
{
int baseX = region.getBaseX();
int baseY = region.getBaseY();
Graphics2D graphics = image.createGraphics();
drawMapIcons(graphics, region, z, drawBaseX, drawBaseY);
if (labelRegions)
{
graphics.setColor(Color.WHITE);
String str = baseX + "," + baseY + " (" + region.getRegionX() + "," + region.getRegionY() + ")";
graphics.drawString(str, drawBaseX * MAP_SCALE, drawBaseY * MAP_SCALE + graphics.getFontMetrics().getHeight());
}
if (outlineRegions)
{
graphics.setColor(Color.WHITE);
graphics.drawRect(drawBaseX * MAP_SCALE, drawBaseY * MAP_SCALE, Region.X * MAP_SCALE, Region.Y * MAP_SCALE);
}
graphics.dispose();
}
private void drawMapIcons(BufferedImage image, int z)
{
// map icons
for (Region region : regionLoader.getRegions())
{
int baseX = region.getBaseX();
int baseY = region.getBaseY();
// to pixel X
int drawBaseX = baseX - regionLoader.getLowestX().getBaseX();
// to pixel Y. top most y is 0, but the top most
// region has the greatest y, so invert
int drawBaseY = regionLoader.getHighestY().getBaseY() - baseY;
drawMapIcons(image, drawBaseX, drawBaseY, region, z);
}
}
private ObjectDefinition findObject(int id)
{
return objectManager.getObject(id);
}
private int packHsl(int var0, int var1, int var2)
{
if (var2 > 179)
{
var1 /= 2;
}
if (var2 > 192)
{
var1 /= 2;
}
if (var2 > 217)
{
var1 /= 2;
}
if (var2 > 243)
{
var1 /= 2;
}
int var3 = (var1 / 32 << 7) + (var0 / 4 << 10) + var2 / 2;
return var3;
}
static int method1792(int var0, int var1)
{
if (var0 == -1)
{
return 12345678;
}
else
{
var1 = (var0 & 127) * var1 / 128;
if (var1 < 2)
{
var1 = 2;
}
else if (var1 > 126)
{
var1 = 126;
}
return (var0 & 65408) + var1;
}
}
static final int adjustHSLListness0(int var0, int var1)
{
if (var0 == -2)
{
return 12345678;
}
else if (var0 == -1)
{
if (var1 < 2)
{
var1 = 2;
}
else if (var1 > 126)
{
var1 = 126;
}
return var1;
}
else
{
var1 = (var0 & 127) * var1 / 128;
if (var1 < 2)
{
var1 = 2;
}
else if (var1 > 126)
{
var1 = 126;
}
return (var0 & 65408) + var1;
}
}
private void drawMapSquare(int[][] pixels, int x, int y, int rgb)
{
x *= MAP_SCALE;
y *= MAP_SCALE;
for (int i = 0; i < MAP_SCALE; ++i)
{
for (int j = 0; j < MAP_SCALE; ++j)
{
pixels[x + i][y + j] = rgb;
}
}
}
private void drawMapIcons(Graphics2D graphics, Region region, int z, int drawBaseX, int drawBaseY)
{
for (Location location : region.getLocations())
{
int localZ = location.getPosition().getZ();
if (z != 0 && localZ != z)
{
// draw all icons on z=0
continue;
}
ObjectDefinition od = findObject(location.getId());
assert od != null;
int localX = location.getPosition().getX() - region.getBaseX();
int localY = location.getPosition().getY() - region.getBaseY();
int drawX = drawBaseX + localX;
int drawY = drawBaseY + (Region.Y - 1 - localY);
if (od.getMapAreaId() != -1)
{
AreaDefinition area = areas.getArea(od.getMapAreaId());
assert area != null;
int spriteId = area.spriteId;
SpriteDefinition sprite = sprites.findSprite(spriteId, 0);
assert sprite != null;
BufferedImage iconImage = sprites.getSpriteImage(sprite);
graphics.drawImage(iconImage, drawX * MAP_SCALE, drawY * MAP_SCALE, null);
}
}
}
private void loadRegions(Store store) throws IOException
{
regionLoader = new RegionLoader(store);
regionLoader.loadRegions();
regionLoader.calculateBounds();
logger.info("North most region: {}", regionLoader.getLowestY().getBaseY());
logger.info("South most region: {}", regionLoader.getHighestY().getBaseY());
logger.info("West most region: {}", regionLoader.getLowestX().getBaseX());
logger.info("East most region: {}", regionLoader.getHighestX().getBaseX());
}
private void loadUnderlays(Store store) throws IOException
{
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.UNDERLAY.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile file : files.getFiles())
{
UnderlayLoader loader = new UnderlayLoader();
UnderlayDefinition underlay = loader.load(file.getFileId(), file.getContents());
underlays.put(underlay.getId(), underlay);
}
}
private UnderlayDefinition findUnderlay(int id)
{
return underlays.get(id);
}
private void loadOverlays(Store store) throws IOException
{
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.OVERLAY.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile file : files.getFiles())
{
OverlayLoader loader = new OverlayLoader();
OverlayDefinition overlay = loader.load(file.getFileId(), file.getContents());
overlays.put(overlay.getId(), overlay);
}
}
private OverlayDefinition findOverlay(int id)
{
return overlays.get(id);
}
private void loadSprites() throws IOException
{
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.SPRITES);
final int mapsceneHash = Djb2.hash("mapscene");
for (Archive a : index.getArchives())
{
byte[] contents = a.decompress(storage.loadArchive(a));
SpriteLoader loader = new SpriteLoader();
SpriteDefinition[] sprites = loader.load(a.getArchiveId(), contents);
for (SpriteDefinition sprite : sprites)
{
if (sprite.getHeight() <= 0 || sprite.getWidth() <= 0)
{
continue;
}
if (a.getNameHash() == mapsceneHash)
{
BufferedImage spriteImage = new BufferedImage(sprite.getWidth(), sprite.getHeight(), BufferedImage.TYPE_INT_ARGB);
spriteImage.setRGB(0, 0, sprite.getWidth(), sprite.getHeight(), sprite.getPixels(), 0, sprite.getWidth());
// scale image down so it fits
Image scaledImage = spriteImage.getScaledInstance(MAPICON_MAX_WIDTH, MAPICON_MAX_HEIGHT, 0);
assert scaledMapIcons.containsKey(sprite.getFrame()) == false;
scaledMapIcons.put(sprite.getFrame(), scaledImage);
}
}
}
}
}

View File

@@ -0,0 +1,111 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.runelite.cache.definitions.NpcDefinition;
import net.runelite.cache.definitions.exporters.NpcExporter;
import net.runelite.cache.definitions.loaders.NpcLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import net.runelite.cache.util.IDClass;
public class NpcManager
{
private final Store store;
private final Map<Integer, NpcDefinition> npcs = new HashMap<>();
public NpcManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
NpcLoader loader = new NpcLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.NPC.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile f : files.getFiles())
{
NpcDefinition npc = loader.load(f.getFileId(), f.getContents());
npcs.put(f.getFileId(), npc);
}
}
public Collection<NpcDefinition> getNpcs()
{
return Collections.unmodifiableCollection(npcs.values());
}
public NpcDefinition get(int npcId)
{
return npcs.get(npcId);
}
public void dump(File out) throws IOException
{
out.mkdirs();
for (NpcDefinition def : npcs.values())
{
NpcExporter exporter = new NpcExporter(def);
File targ = new File(out, def.id + ".json");
exporter.exportTo(targ);
}
}
public void java(File java) throws IOException
{
java.mkdirs();
try (IDClass ids = IDClass.create(java, "NpcID"))
{
for (NpcDefinition def : npcs.values())
{
if (def.name.equalsIgnoreCase("NULL"))
{
continue;
}
ids.add(def.name, def.id);
}
}
}
}

View File

@@ -0,0 +1,116 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.runelite.cache.definitions.ObjectDefinition;
import net.runelite.cache.definitions.exporters.ObjectExporter;
import net.runelite.cache.definitions.loaders.ObjectLoader;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
import net.runelite.cache.util.IDClass;
public class ObjectManager
{
private final Store store;
private final Map<Integer, ObjectDefinition> objects = new HashMap<>();
public ObjectManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
ObjectLoader loader = new ObjectLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.OBJECT.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile f : files.getFiles())
{
ObjectDefinition def = loader.load(f.getFileId(), f.getContents());
objects.put(f.getFileId(), def);
}
}
public Collection<ObjectDefinition> getObjects()
{
return Collections.unmodifiableCollection(objects.values());
}
public ObjectDefinition getObject(int id)
{
return objects.get(id);
}
public void dump(File out) throws IOException
{
out.mkdirs();
for (ObjectDefinition def : objects.values())
{
ObjectExporter exporter = new ObjectExporter(def);
File targ = new File(out, def.getId() + ".json");
exporter.exportTo(targ);
}
}
public void java(File java) throws IOException
{
java.mkdirs();
try (IDClass ids = IDClass.create(java, "ObjectID"))
{
try (IDClass nulls = IDClass.create(java, "NullObjectID"))
{
for (ObjectDefinition def : objects.values())
{
if ("null".equals(def.getName()))
{
nulls.add(def.getName(), def.getId());
}
else
{
ids.add(def.getName(), def.getId());
}
}
}
}
}
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.runelite.cache.definitions.OverlayDefinition;
import net.runelite.cache.definitions.loaders.OverlayLoader;
import net.runelite.cache.definitions.providers.OverlayProvider;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
public class OverlayManager implements OverlayProvider
{
private final Store store;
private final Map<Integer, OverlayDefinition> overlays = new HashMap<>();
public OverlayManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.OVERLAY.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile file : files.getFiles())
{
OverlayLoader loader = new OverlayLoader();
OverlayDefinition overlay = loader.load(file.getFileId(), file.getContents());
overlays.put(overlay.getId(), overlay);
}
}
public Collection<OverlayDefinition> getOverlays()
{
return Collections.unmodifiableCollection(overlays.values());
}
@Override
public OverlayDefinition provide(int overlayId)
{
return overlays.get(overlayId);
}
}

View File

@@ -0,0 +1,118 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import net.runelite.cache.definitions.SpriteDefinition;
import net.runelite.cache.definitions.exporters.SpriteExporter;
import net.runelite.cache.definitions.loaders.SpriteLoader;
import net.runelite.cache.definitions.providers.SpriteProvider;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
public class SpriteManager implements SpriteProvider
{
private final Store store;
private final Multimap<Integer, SpriteDefinition> sprites = LinkedListMultimap.create();
public SpriteManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.SPRITES);
for (Archive a : index.getArchives())
{
byte[] contents = a.decompress(storage.loadArchive(a));
SpriteLoader loader = new SpriteLoader();
SpriteDefinition[] defs = loader.load(a.getArchiveId(), contents);
for (SpriteDefinition sprite : defs)
{
sprites.put(sprite.getId(), sprite);
}
}
}
public Collection<SpriteDefinition> getSprites()
{
return Collections.unmodifiableCollection(sprites.values());
}
public SpriteDefinition findSprite(int spriteId, int frameId)
{
for (SpriteDefinition sprite : sprites.get(spriteId))
{
if (sprite.getFrame() == frameId)
{
return sprite;
}
}
return null;
}
public BufferedImage getSpriteImage(SpriteDefinition sprite)
{
BufferedImage image = new BufferedImage(sprite.getWidth(), sprite.getHeight(), BufferedImage.TYPE_INT_ARGB);
image.setRGB(0, 0, sprite.getWidth(), sprite.getHeight(), sprite.getPixels(), 0, sprite.getWidth());
return image;
}
public void export(File outDir) throws IOException
{
for (SpriteDefinition sprite : sprites.values())
{
// I don't know why this happens
if (sprite.getHeight() <= 0 || sprite.getWidth() <= 0)
{
continue;
}
SpriteExporter exporter = new SpriteExporter(sprite);
File png = new File(outDir, sprite.getId() + "-" + sprite.getFrame() + ".png");
exporter.exportTo(png);
}
}
@Override
public SpriteDefinition provide(int spriteId, int frameId)
{
return findSprite(spriteId, frameId);
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2018, Joshua Filby <joshua@filby.me>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.runelite.cache.definitions.StructDefinition;
import net.runelite.cache.definitions.loaders.StructLoader;
import net.runelite.cache.definitions.providers.StructProvider;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
public class StructManager implements StructProvider
{
private final Store store;
private final Map<Integer, StructDefinition> structs = new HashMap<>();
public StructManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
StructLoader loader = new StructLoader();
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.STRUCT.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile f : files.getFiles())
{
StructDefinition def = loader.load(f.getFileId(), f.getContents());
structs.put(f.getFileId(), def);
}
}
public Map<Integer, StructDefinition> getStructs()
{
return Collections.unmodifiableMap(structs);
}
public StructDefinition getStruct(int structId)
{
return structs.get(structId);
}
@Override
public StructDefinition provide(int structId)
{
return getStruct(structId);
}
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.runelite.cache.definitions.TextureDefinition;
import net.runelite.cache.definitions.loaders.TextureLoader;
import net.runelite.cache.definitions.providers.TextureProvider;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
public class TextureManager implements TextureProvider
{
private final Store store;
private final List<TextureDefinition> textures = new ArrayList<>();
public TextureManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.TEXTURES);
Archive archive = index.getArchive(0);
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
TextureLoader loader = new TextureLoader();
for (FSFile file : files.getFiles())
{
TextureDefinition texture = loader.load(file.getFileId(), file.getContents());
textures.add(texture);
}
}
public List<TextureDefinition> getTextures()
{
return textures;
}
public TextureDefinition findTexture(int id)
{
for (TextureDefinition td : textures)
{
if (td.getId() == id)
{
return td;
}
}
return null;
}
@Override
public TextureDefinition[] provide()
{
return textures.toArray(new TextureDefinition[textures.size()]);
}
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2018, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import net.runelite.cache.definitions.UnderlayDefinition;
import net.runelite.cache.definitions.loaders.UnderlayLoader;
import net.runelite.cache.definitions.providers.UnderlayProvider;
import net.runelite.cache.fs.Archive;
import net.runelite.cache.fs.ArchiveFiles;
import net.runelite.cache.fs.FSFile;
import net.runelite.cache.fs.Index;
import net.runelite.cache.fs.Storage;
import net.runelite.cache.fs.Store;
public class UnderlayManager implements UnderlayProvider
{
private final Store store;
private final Map<Integer, UnderlayDefinition> underlays = new HashMap<>();
public UnderlayManager(Store store)
{
this.store = store;
}
public void load() throws IOException
{
Storage storage = store.getStorage();
Index index = store.getIndex(IndexType.CONFIGS);
Archive archive = index.getArchive(ConfigType.UNDERLAY.getId());
byte[] archiveData = storage.loadArchive(archive);
ArchiveFiles files = archive.getFiles(archiveData);
for (FSFile file : files.getFiles())
{
UnderlayLoader loader = new UnderlayLoader();
UnderlayDefinition underlay = loader.load(file.getFileId(), file.getContents());
underlays.put(underlay.getId(), underlay);
}
}
public Collection<UnderlayDefinition> getUnderlays()
{
return Collections.unmodifiableCollection(underlays.values());
}
@Override
public UnderlayDefinition provide(int underlayId)
{
return underlays.get(underlayId);
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class AreaDefinition
{
public int id;
public int[] field3292;
public int spriteId = -1;
public int field3294 = -1;
public String name;
public int field3296;
public int field3297 = -1;
public String[] field3298 = new String[5];
public int[] field3300;
public String field3308;
public byte[] field3309;
public int field3310;
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2018 Abex
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@Data
public class ClientScript1Instruction
{
@RequiredArgsConstructor
public enum Opcode
{
RETURN(0),
BOOSTED_SKILL_LEVELS(1),
REAL_SKILL_LEVELS(1),
SKILL_EXPERIENCE(1),
WIDGET_CONTAINS_ITEM_GET_QUANTITY(3),
VARP(1),
EXPERIENCE_AT_LEVEL_FOR_SKILL(1),
VARP_TIMES_469(1),
COMBAT_LEVEL(1),
TOTAL_LEVEL(0),
WIDGET_CONTAINS_ITEM_STAR(3),
RUN_ENERGY(0),
WEIGHT(0),
VARP_TESTBIT(2),
VARBIT(1),
MINUS(0),
DIV(0),
MUL(0),
WORLD_X(0),
WORLD_Y(1),
CONSTANT(1);
public final int argumentCount;
}
public Opcode opcode;
public int[] operands;
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
import net.runelite.cache.util.ScriptVarType;
@Data
public class EnumDefinition
{
private int id;
private int[] intVals;
private ScriptVarType keyType;
private ScriptVarType valType;
private String defaultString = "null";
private int defaultInt;
private int size;
private int[] keys;
private String[] stringVals;
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class FrameDefinition
{
public int id; // file id
public FramemapDefinition framemap;
public int[] translator_x;
public int[] translator_y;
public int[] translator_z;
public int translatorCount = -1;
public int[] indexFrameIds;
public boolean showing;
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class FramemapDefinition
{
public int id;
public int[] types;
public int[][] frameMaps;
public int length;
}

View File

@@ -0,0 +1,131 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class InterfaceDefinition
{
public int id = -1;
public boolean isIf3 = false;
public int type;
public int contentType;
public int originalX;
public int originalY;
public int originalWidth;
public int originalHeight;
public int widthMode;
public int heightMode;
public int xPositionMode;
public int yPositionMode;
public int parentId = -1;
public boolean isHidden;
public int scrollWidth;
public int scrollHeight;
public boolean noClickThrough;
public int spriteId;
public int textureId;
public boolean spriteTiling;
public int opacity;
public int borderType;
public int shadowColor;
public boolean flippedVertically;
public boolean flippedHorizontally;
public int modelType;
public int modelId;
public int offsetX2d;
public int offsetY2d;
public int rotationX;
public int rotationY;
public int rotationZ;
public int modelZoom;
public int animation;
public boolean orthogonal;
public int modelHeightOverride;
public int fontId;
public String text;
public int lineHeight;
public int xTextAlignment;
public int yTextAlignment;
public boolean textShadowed;
public int textColor;
public boolean filled;
public int lineWidth;
public boolean lineDirection;
public int clickMask;
public String name;
public String[] actions;
public int dragDeadZone;
public int dragDeadTime;
public boolean dragRenderBehavior;
public String targetVerb;
public Object[] onLoadListener;
public Object[] onMouseOverListener;
public Object[] onMouseLeaveListener;
public Object[] onTargetLeaveListener;
public Object[] onTargetEnterListener;
public Object[] onVarTransmitListener;
public Object[] onInvTransmitListener;
public Object[] onStatTransmitListener;
public Object[] onTimerListener;
public Object[] onOpListener;
public Object[] onMouseRepeatListener;
public Object[] onClickListener;
public Object[] onClickRepeatListener;
public Object[] onReleaseListener;
public Object[] onHoldListener;
public Object[] onDragListener;
public Object[] onDragCompleteListener;
public Object[] onScrollWheelListener;
public int[] varTransmitTriggers;
public int[] invTransmitTriggers;
public int[] statTransmitTriggers;
public boolean hasListener;
public int menuType;
// This is set to a siblings' child id when that widget should get a hover effect when this one is hovered
public int hoveredSiblingId;
public int[] alternateOperators;
public int[] alternateRhs;
public ClientScript1Instruction[][] clientScripts;
public int[] itemIds;
public int[] itemQuantities;
public int xPitch;
public int yPitch;
public int[] xOffsets;
public int[] yOffsets;
public int[] sprites;
public String[] configActions;
public String alternateText;
public int alternateTextColor;
public int hoveredTextColor;
public int alternateHoveredTextColor;
public int alternateSpriteId;
public int alternateModelId;
public int alternateAnimation;
public String spellName;
public String tooltip;
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class InventoryDefinition
{
public int id;
public int size;
}

View File

@@ -0,0 +1,123 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import java.util.Map;
import lombok.Data;
@Data
public class ItemDefinition
{
public final int id;
public String name = "null";
public int resizeX = 128;
public int resizeY = 128;
public int resizeZ = 128;
public int xan2d = 0;
public int yan2d = 0;
public int zan2d = 0;
public int cost = 1;
public boolean isTradeable;
public int stackable = 0;
public int inventoryModel;
public boolean members = false;
public short[] colorFind;
public short[] colorReplace;
public short[] textureFind;
public short[] textureReplace;
public int zoom2d = 2000;
public int xOffset2d = 0;
public int yOffset2d = 0;
public int ambient;
public int contrast;
public int[] countCo;
public int[] countObj;
public String[] options = new String[]
{
null, null, "Take", null, null
};
public String[] interfaceOptions = new String[]
{
null, null, null, null, "Drop"
};
public int maleModel0 = -1;
public int maleModel1 = -1;
public int maleModel2 = -1;
public int maleOffset;
public int maleHeadModel = -1;
public int maleHeadModel2 = -1;
public int femaleModel0 = -1;
public int femaleModel1 = -1;
public int femaleModel2 = -1;
public int femaleOffset;
public int femaleHeadModel = -1;
public int femaleHeadModel2 = -1;
public int notedID = -1;
public int notedTemplate = -1;
public int team;
public int shiftClickDropIndex = -2;
public int boughtId = -1;
public int boughtTemplateId = -1;
public int placeholderId = -1;
public int placeholderTemplateId = -1;
public Map<Integer, Object> params = null;
public void updateNote(ItemDefinition notedItem, ItemDefinition unnotedItem)
{
this.inventoryModel = notedItem.inventoryModel;
this.zoom2d = notedItem.zoom2d;
this.xan2d = notedItem.xan2d;
this.yan2d = notedItem.yan2d;
this.zan2d = notedItem.zan2d;
this.xOffset2d = notedItem.xOffset2d;
this.yOffset2d = notedItem.yOffset2d;
this.colorFind = notedItem.colorFind;
this.colorReplace = notedItem.colorReplace;
this.textureFind = notedItem.textureFind;
this.textureReplace = notedItem.textureReplace;
this.name = unnotedItem.name;
this.members = unnotedItem.members;
this.cost = unnotedItem.cost;
this.stackable = 1;
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class KitDefinition
{
private final int id;
public short[] recolorToReplace;
public short[] recolorToFind;
public short[] retextureToFind;
public short[] retextureToReplace;
public int bodyPartId = -1;
public int[] modelIds;
public int[] models = new int[]
{
-1, -1, -1, -1, -1
};
public boolean nonSelectable = false;
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import net.runelite.cache.region.Location;
@Data
public class LocationsDefinition
{
private int regionX;
private int regionY;
private List<Location> locations = new ArrayList<>();
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class MapDefinition
{
public static final int X = 64;
public static final int Y = 64;
public static final int Z = 4;
@Data
public static class Tile
{
public Integer height;
public int attrOpcode;
public byte settings;
public byte overlayId;
public byte overlayPath;
public byte overlayRotation;
public byte underlayId;
}
private int regionX;
private int regionY;
private Tile[][][] tiles = new Tile[Z][X][Y];
}

View File

@@ -0,0 +1,635 @@
package net.runelite.cache.definitions;
import java.util.Arrays;
import lombok.Data;
import net.runelite.cache.models.CircularAngle;
import net.runelite.cache.models.FaceNormal;
import net.runelite.cache.models.VertexNormal;
@Data
public class ModelDefinition
{
public int id;
public int vertexCount = 0;
public int[] vertexPositionsX;
public int[] vertexPositionsY;
public int[] vertexPositionsZ;
public transient VertexNormal[] vertexNormals;
public int faceCount;
public int[] faceVertexIndices1;
public int[] faceVertexIndices2;
public int[] faceVertexIndices3;
public byte[] faceAlphas;
public short[] faceColors;
public byte[] faceRenderPriorities;
public byte[] faceRenderTypes;
public transient FaceNormal[] faceNormals;
public int textureTriangleCount;
public short[] textureTriangleVertexIndices1;
public short[] textureTriangleVertexIndices2;
public short[] textureTriangleVertexIndices3;
public transient float[][] faceTextureUCoordinates;
public transient float[][] faceTextureVCoordinates;
public short[] texturePrimaryColors;
public short[] faceTextures;
public byte[] textureCoordinates;
public byte[] textureRenderTypes;
public int[] vertexSkins;
public int[] faceSkins;
public byte priority;
public short[] aShortArray2574;
public short[] aShortArray2575;
public short[] aShortArray2577;
public short[] aShortArray2578;
public byte[] aByteArray2580;
public short[] aShortArray2586;
private transient int[][] vertexGroups;
private transient int[] origVX;
private transient int[] origVY;
private transient int[] origVZ;
public transient int maxPriority;
public static transient int animOffsetX, animOffsetY, animOffsetZ;
public void computeNormals()
{
if (this.vertexNormals != null)
{
return;
}
this.vertexNormals = new VertexNormal[this.vertexCount];
int var1;
for (var1 = 0; var1 < this.vertexCount; ++var1)
{
this.vertexNormals[var1] = new VertexNormal();
}
for (var1 = 0; var1 < this.faceCount; ++var1)
{
int vertexA = this.faceVertexIndices1[var1];
int vertexB = this.faceVertexIndices2[var1];
int vertexC = this.faceVertexIndices3[var1];
int xA = this.vertexPositionsX[vertexB] - this.vertexPositionsX[vertexA];
int yA = this.vertexPositionsY[vertexB] - this.vertexPositionsY[vertexA];
int zA = this.vertexPositionsZ[vertexB] - this.vertexPositionsZ[vertexA];
int xB = this.vertexPositionsX[vertexC] - this.vertexPositionsX[vertexA];
int yB = this.vertexPositionsY[vertexC] - this.vertexPositionsY[vertexA];
int zB = this.vertexPositionsZ[vertexC] - this.vertexPositionsZ[vertexA];
// Compute cross product
int var11 = yA * zB - yB * zA;
int var12 = zA * xB - zB * xA;
int var13 = xA * yB - xB * yA;
while (var11 > 8192 || var12 > 8192 || var13 > 8192 || var11 < -8192 || var12 < -8192 || var13 < -8192)
{
var11 >>= 1;
var12 >>= 1;
var13 >>= 1;
}
int length = (int) Math.sqrt((double) (var11 * var11 + var12 * var12 + var13 * var13));
if (length <= 0)
{
length = 1;
}
var11 = var11 * 256 / length;
var12 = var12 * 256 / length;
var13 = var13 * 256 / length;
byte var15;
if (this.faceRenderTypes == null)
{
var15 = 0;
}
else
{
var15 = this.faceRenderTypes[var1];
}
if (var15 == 0)
{
VertexNormal var16 = this.vertexNormals[vertexA];
var16.x += var11;
var16.y += var12;
var16.z += var13;
++var16.magnitude;
var16 = this.vertexNormals[vertexB];
var16.x += var11;
var16.y += var12;
var16.z += var13;
++var16.magnitude;
var16 = this.vertexNormals[vertexC];
var16.x += var11;
var16.y += var12;
var16.z += var13;
++var16.magnitude;
}
else if (var15 == 1)
{
if (this.faceNormals == null)
{
this.faceNormals = new FaceNormal[this.faceCount];
}
FaceNormal var17 = this.faceNormals[var1] = new FaceNormal();
var17.x = var11;
var17.y = var12;
var17.z = var13;
}
}
}
/**
* Computes the UV coordinates for every three-vertex face that has a
* texture.
*/
public void computeTextureUVCoordinates()
{
this.faceTextureUCoordinates = new float[faceCount][];
this.faceTextureVCoordinates = new float[faceCount][];
for (int i = 0; i < faceCount; i++)
{
int textureCoordinate;
if (textureCoordinates == null)
{
textureCoordinate = -1;
}
else
{
textureCoordinate = textureCoordinates[i];
}
int textureIdx;
if (faceTextures == null)
{
textureIdx = -1;
}
else
{
textureIdx = faceTextures[i] & 0xFFFF;
}
if (textureIdx != -1)
{
float[] u = new float[3];
float[] v = new float[3];
if (textureCoordinate == -1)
{
u[0] = 0.0F;
v[0] = 1.0F;
u[1] = 1.0F;
v[1] = 1.0F;
u[2] = 0.0F;
v[2] = 0.0F;
}
else
{
textureCoordinate &= 0xFF;
byte textureRenderType = 0;
if (textureRenderTypes != null)
{
textureRenderType = textureRenderTypes[textureCoordinate];
}
if (textureRenderType == 0)
{
int faceVertexIdx1 = faceVertexIndices1[i];
int faceVertexIdx2 = faceVertexIndices2[i];
int faceVertexIdx3 = faceVertexIndices3[i];
short triangleVertexIdx1 = textureTriangleVertexIndices1[textureCoordinate];
short triangleVertexIdx2 = textureTriangleVertexIndices2[textureCoordinate];
short triangleVertexIdx3 = textureTriangleVertexIndices3[textureCoordinate];
float triangleX = (float) vertexPositionsX[triangleVertexIdx1];
float triangleY = (float) vertexPositionsY[triangleVertexIdx1];
float triangleZ = (float) vertexPositionsZ[triangleVertexIdx1];
float f_882_ = (float) vertexPositionsX[triangleVertexIdx2] - triangleX;
float f_883_ = (float) vertexPositionsY[triangleVertexIdx2] - triangleY;
float f_884_ = (float) vertexPositionsZ[triangleVertexIdx2] - triangleZ;
float f_885_ = (float) vertexPositionsX[triangleVertexIdx3] - triangleX;
float f_886_ = (float) vertexPositionsY[triangleVertexIdx3] - triangleY;
float f_887_ = (float) vertexPositionsZ[triangleVertexIdx3] - triangleZ;
float f_888_ = (float) vertexPositionsX[faceVertexIdx1] - triangleX;
float f_889_ = (float) vertexPositionsY[faceVertexIdx1] - triangleY;
float f_890_ = (float) vertexPositionsZ[faceVertexIdx1] - triangleZ;
float f_891_ = (float) vertexPositionsX[faceVertexIdx2] - triangleX;
float f_892_ = (float) vertexPositionsY[faceVertexIdx2] - triangleY;
float f_893_ = (float) vertexPositionsZ[faceVertexIdx2] - triangleZ;
float f_894_ = (float) vertexPositionsX[faceVertexIdx3] - triangleX;
float f_895_ = (float) vertexPositionsY[faceVertexIdx3] - triangleY;
float f_896_ = (float) vertexPositionsZ[faceVertexIdx3] - triangleZ;
float f_897_ = f_883_ * f_887_ - f_884_ * f_886_;
float f_898_ = f_884_ * f_885_ - f_882_ * f_887_;
float f_899_ = f_882_ * f_886_ - f_883_ * f_885_;
float f_900_ = f_886_ * f_899_ - f_887_ * f_898_;
float f_901_ = f_887_ * f_897_ - f_885_ * f_899_;
float f_902_ = f_885_ * f_898_ - f_886_ * f_897_;
float f_903_ = 1.0F / (f_900_ * f_882_ + f_901_ * f_883_ + f_902_ * f_884_);
u[0] = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
u[1] = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
u[2] = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
f_900_ = f_883_ * f_899_ - f_884_ * f_898_;
f_901_ = f_884_ * f_897_ - f_882_ * f_899_;
f_902_ = f_882_ * f_898_ - f_883_ * f_897_;
f_903_ = 1.0F / (f_900_ * f_885_ + f_901_ * f_886_ + f_902_ * f_887_);
v[0] = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
v[1] = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
v[2] = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
}
}
this.faceTextureUCoordinates[i] = u;
this.faceTextureVCoordinates[i] = v;
}
}
}
public void computeAnimationTables()
{
if (this.vertexSkins != null)
{
int[] groupCounts = new int[256];
int numGroups = 0;
int var3, var4;
for (var3 = 0; var3 < this.vertexCount; ++var3)
{
var4 = this.vertexSkins[var3];
++groupCounts[var4];
if (var4 > numGroups)
{
numGroups = var4;
}
}
this.vertexGroups = new int[numGroups + 1][];
for (var3 = 0; var3 <= numGroups; ++var3)
{
this.vertexGroups[var3] = new int[groupCounts[var3]];
groupCounts[var3] = 0;
}
for (var3 = 0; var3 < this.vertexCount; this.vertexGroups[var4][groupCounts[var4]++] = var3++)
{
var4 = this.vertexSkins[var3];
}
this.vertexSkins = null;
}
// triangleSkinValues is here
}
public void rotate(int orientation)
{
int sin = CircularAngle.SINE[orientation];
int cos = CircularAngle.COSINE[orientation];
assert vertexPositionsX.length == vertexPositionsY.length;
assert vertexPositionsY.length == vertexPositionsZ.length;
for (int i = 0; i < vertexPositionsX.length; ++i)
{
vertexPositionsX[i] = vertexPositionsX[i] * cos + vertexPositionsZ[i] * sin >> 16;
vertexPositionsZ[i] = vertexPositionsZ[i] * cos - vertexPositionsX[i] * sin >> 16;
}
reset();
}
public void resetAnim()
{
if (origVX == null)
{
return;
}
System.arraycopy(origVX, 0, vertexPositionsX, 0, origVX.length);
System.arraycopy(origVY, 0, vertexPositionsY, 0, origVY.length);
System.arraycopy(origVZ, 0, vertexPositionsZ, 0, origVZ.length);
}
public void animate(int type, int[] frameMap, int dx, int dy, int dz)
{
if (origVX == null)
{
origVX = Arrays.copyOf(vertexPositionsX, vertexPositionsX.length);
origVY = Arrays.copyOf(vertexPositionsY, vertexPositionsY.length);
origVZ = Arrays.copyOf(vertexPositionsZ, vertexPositionsZ.length);
}
final int[] verticesX = vertexPositionsX;
final int[] verticesY = vertexPositionsY;
final int[] verticesZ = vertexPositionsZ;
int var6 = frameMap.length;
int var7;
int var8;
int var11;
int var12;
if (type == 0)
{
var7 = 0;
animOffsetX = 0;
animOffsetY = 0;
animOffsetZ = 0;
for (var8 = 0; var8 < var6; ++var8)
{
int var9 = frameMap[var8];
if (var9 < this.vertexGroups.length)
{
int[] var10 = this.vertexGroups[var9];
for (var11 = 0; var11 < var10.length; ++var11)
{
var12 = var10[var11];
animOffsetX += verticesX[var12];
animOffsetY += verticesY[var12];
animOffsetZ += verticesZ[var12];
++var7;
}
}
}
if (var7 > 0)
{
animOffsetX = dx + animOffsetX / var7;
animOffsetY = dy + animOffsetY / var7;
animOffsetZ = dz + animOffsetZ / var7;
}
else
{
animOffsetX = dx;
animOffsetY = dy;
animOffsetZ = dz;
}
}
else
{
int[] var18;
int var19;
if (type == 1)
{
for (var7 = 0; var7 < var6; ++var7)
{
var8 = frameMap[var7];
if (var8 < this.vertexGroups.length)
{
var18 = this.vertexGroups[var8];
for (var19 = 0; var19 < var18.length; ++var19)
{
var11 = var18[var19];
verticesX[var11] += dx;
verticesY[var11] += dy;
verticesZ[var11] += dz;
}
}
}
}
else if (type == 2)
{
for (var7 = 0; var7 < var6; ++var7)
{
var8 = frameMap[var7];
if (var8 < this.vertexGroups.length)
{
var18 = this.vertexGroups[var8];
for (var19 = 0; var19 < var18.length; ++var19)
{
var11 = var18[var19];
verticesX[var11] -= animOffsetX;
verticesY[var11] -= animOffsetY;
verticesZ[var11] -= animOffsetZ;
var12 = (dx & 255) * 8;
int var13 = (dy & 255) * 8;
int var14 = (dz & 255) * 8;
int var15;
int var16;
int var17;
if (var14 != 0)
{
var15 = CircularAngle.SINE[var14];
var16 = CircularAngle.COSINE[var14];
var17 = var15 * verticesY[var11] + var16 * verticesX[var11] >> 16;
verticesY[var11] = var16 * verticesY[var11] - var15 * verticesX[var11] >> 16;
verticesX[var11] = var17;
}
if (var12 != 0)
{
var15 = CircularAngle.SINE[var12];
var16 = CircularAngle.COSINE[var12];
var17 = var16 * verticesY[var11] - var15 * verticesZ[var11] >> 16;
verticesZ[var11] = var15 * verticesY[var11] + var16 * verticesZ[var11] >> 16;
verticesY[var11] = var17;
}
if (var13 != 0)
{
var15 = CircularAngle.SINE[var13];
var16 = CircularAngle.COSINE[var13];
var17 = var15 * verticesZ[var11] + var16 * verticesX[var11] >> 16;
verticesZ[var11] = var16 * verticesZ[var11] - var15 * verticesX[var11] >> 16;
verticesX[var11] = var17;
}
verticesX[var11] += animOffsetX;
verticesY[var11] += animOffsetY;
verticesZ[var11] += animOffsetZ;
}
}
}
}
else if (type == 3)
{
for (var7 = 0; var7 < var6; ++var7)
{
var8 = frameMap[var7];
if (var8 < this.vertexGroups.length)
{
var18 = this.vertexGroups[var8];
for (var19 = 0; var19 < var18.length; ++var19)
{
var11 = var18[var19];
verticesX[var11] -= animOffsetX;
verticesY[var11] -= animOffsetY;
verticesZ[var11] -= animOffsetZ;
verticesX[var11] = dx * verticesX[var11] / 128;
verticesY[var11] = dy * verticesY[var11] / 128;
verticesZ[var11] = dz * verticesZ[var11] / 128;
verticesX[var11] += animOffsetX;
verticesY[var11] += animOffsetY;
verticesZ[var11] += animOffsetZ;
}
}
}
}
else if (type == 5)
{
// alpha animation
}
}
}
public void method1493()
{
int var1;
for (var1 = 0; var1 < this.vertexCount; ++var1)
{
this.vertexPositionsZ[var1] = -this.vertexPositionsZ[var1];
}
for (var1 = 0; var1 < this.faceCount; ++var1)
{
int var2 = this.faceVertexIndices1[var1];
this.faceVertexIndices1[var1] = this.faceVertexIndices3[var1];
this.faceVertexIndices3[var1] = var2;
}
reset();
}
public void rotate1()
{
for (int var1 = 0; var1 < this.vertexCount; ++var1)
{
int var2 = this.vertexPositionsX[var1];
this.vertexPositionsX[var1] = this.vertexPositionsZ[var1];
this.vertexPositionsZ[var1] = -var2;
}
reset();
}
public void rotate2()
{
for (int var1 = 0; var1 < this.vertexCount; ++var1)
{
this.vertexPositionsX[var1] = -this.vertexPositionsX[var1];
this.vertexPositionsZ[var1] = -this.vertexPositionsZ[var1];
}
reset();
}
public void rotate3()
{
for (int var1 = 0; var1 < this.vertexCount; ++var1)
{
int var2 = this.vertexPositionsZ[var1];
this.vertexPositionsZ[var1] = this.vertexPositionsX[var1];
this.vertexPositionsX[var1] = -var2;
}
reset();
}
private void reset()
{
vertexNormals = null;
faceNormals = null;
faceTextureUCoordinates = faceTextureVCoordinates = null;
}
public void resize(int var1, int var2, int var3)
{
for (int var4 = 0; var4 < this.vertexCount; ++var4)
{
this.vertexPositionsX[var4] = this.vertexPositionsX[var4] * var1 / 128;
this.vertexPositionsY[var4] = var2 * this.vertexPositionsY[var4] / 128;
this.vertexPositionsZ[var4] = var3 * this.vertexPositionsZ[var4] / 128;
}
reset();
}
public void recolor(short var1, short var2)
{
for (int var3 = 0; var3 < this.faceCount; ++var3)
{
if (this.faceColors[var3] == var1)
{
this.faceColors[var3] = var2;
}
}
}
public void retexture(short var1, short var2)
{
if (this.faceTextures != null)
{
for (int var3 = 0; var3 < this.faceCount; ++var3)
{
if (this.faceTextures[var3] == var1)
{
this.faceTextures[var3] = var2;
}
}
}
}
public void move(int xOffset, int yOffset, int zOffset)
{
for (int i = 0; i < this.vertexCount; i++)
{
this.vertexPositionsX[i] += xOffset;
this.vertexPositionsY[i] += yOffset;
this.vertexPositionsZ[i] += zOffset;
}
this.reset();
}
public void computeMaxPriority()
{
if (faceRenderPriorities == null)
{
return;
}
for (int i = 0; i < faceCount; ++i)
{
if (faceRenderPriorities[i] > maxPriority)
{
maxPriority = faceRenderPriorities[i];
}
}
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import java.util.Map;
import lombok.Data;
@Data
public class NpcDefinition
{
public final int id;
public String name = "null";
public int size = 1;
public int[] models;
public int[] chatheadModels;
public int standingAnimation = -1;
public int rotateLeftAnimation = -1;
public int rotateRightAnimation = -1;
public int walkingAnimation = -1;
public int rotate180Animation = -1;
public int rotate90RightAnimation = -1;
public int rotate90LeftAnimation = -1;
public short[] recolorToFind;
public short[] recolorToReplace;
public short[] retextureToFind;
public short[] retextureToReplace;
public String[] actions = new String[5];
public boolean isMinimapVisible = true;
public int combatLevel = -1;
public int widthScale = 128;
public int heightScale = 128;
public boolean hasRenderPriority;
public int ambient;
public int contrast;
public int headIcon = -1;
public int rotationSpeed = 32;
public int[] configs;
public int varbitId = -1;
public int varpIndex = -1;
public boolean isInteractable = true;
public boolean rotationFlag = true;
public boolean isPet;
public Map<Integer, Object> params;
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import java.util.Map;
import lombok.Data;
@Data
public class ObjectDefinition
{
private int id;
private short[] retextureToFind;
private int decorDisplacement = 16;
private boolean isHollow = false;
private String name = "null";
private int[] objectModels;
private int[] objectTypes;
private short[] recolorToFind;
private int mapAreaId = -1;
private short[] textureToReplace;
private int sizeX = 1;
private int sizeY = 1;
private int anInt2083 = 0;
private int[] anIntArray2084;
private int offsetX = 0;
private boolean mergeNormals = false;
private int wallOrDoor = -1;
private int animationID = -1;
private int varbitID = -1;
private int ambient = 0;
private int contrast = 0;
private String[] actions = new String[5];
private int interactType = 2;
private int mapSceneID = -1;
private short[] recolorToReplace;
private boolean shadow = true;
private int modelSizeX = 128;
private int modelSizeHeight = 128;
private int modelSizeY = 128;
private int objectID;
private int offsetHeight = 0;
private int offsetY = 0;
private boolean obstructsGround = false;
private int contouredGround = -1;
private int supportsItems = -1;
private int[] configChangeDest;
private boolean isRotated = false;
private int varpID = -1;
private int ambientSoundId = -1;
private boolean aBool2111 = false;
private int anInt2112 = 0;
private int anInt2113 = 0;
private boolean blocksProjectile = true;
private Map<Integer, Object> params = null;
}

View File

@@ -0,0 +1,139 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class OverlayDefinition
{
private int id;
private int rgbColor = 0;
private int texture = -1;
private int secondaryRgbColor = -1;
private boolean hideUnderlay = true;
private transient int hue;
private transient int saturation;
private transient int lightness;
private transient int otherHue;
private transient int otherSaturation;
private transient int otherLightness;
public void calculateHsl()
{
if (secondaryRgbColor != -1)
{
calculateHsl(secondaryRgbColor);
otherHue = hue;
otherSaturation = saturation;
otherLightness = lightness;
}
calculateHsl(rgbColor);
}
private void calculateHsl(int var1)
{
double var2 = (double) (var1 >> 16 & 255) / 256.0D;
double var4 = (double) (var1 >> 8 & 255) / 256.0D;
double var6 = (double) (var1 & 255) / 256.0D;
double var8 = var2;
if (var4 < var2)
{
var8 = var4;
}
if (var6 < var8)
{
var8 = var6;
}
double var10 = var2;
if (var4 > var2)
{
var10 = var4;
}
if (var6 > var10)
{
var10 = var6;
}
double var12 = 0.0D;
double var14 = 0.0D;
double var16 = (var8 + var10) / 2.0D;
if (var10 != var8)
{
if (var16 < 0.5D)
{
var14 = (var10 - var8) / (var10 + var8);
}
if (var16 >= 0.5D)
{
var14 = (var10 - var8) / (2.0D - var10 - var8);
}
if (var2 == var10)
{
var12 = (var4 - var6) / (var10 - var8);
}
else if (var4 == var10)
{
var12 = 2.0D + (var6 - var2) / (var10 - var8);
}
else if (var10 == var6)
{
var12 = 4.0D + (var2 - var4) / (var10 - var8);
}
}
var12 /= 6.0D;
this.hue = (int) (256.0D * var12);
this.saturation = (int) (var14 * 256.0D);
this.lightness = (int) (var16 * 256.0D);
if (this.saturation < 0)
{
this.saturation = 0;
}
else if (this.saturation > 255)
{
this.saturation = 255;
}
if (this.lightness < 0)
{
this.lightness = 0;
}
else if (this.lightness > 255)
{
this.lightness = 255;
}
}
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2020, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
import net.runelite.cache.util.ScriptVarType;
@Data
public class ParamDefinition
{
private ScriptVarType type;
private boolean isMembers = true;
private int defaultInt;
private String defaultString;
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import java.util.Map;
import lombok.Data;
@Data
public class ScriptDefinition
{
private int id;
private int[] instructions;
private int[] intOperands;
private String[] stringOperands;
private int intStackCount;
private int stringStackCount;
private int localIntCount;
private int localStringCount;
private Map<Integer, Integer>[] switches;
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class SequenceDefinition
{
private final int id;
public int[] frameIDs; // top 16 bits are FrameDefinition ids
public int[] field3048;
public int[] frameLenghts;
public int rightHandItem = -1;
public int[] interleaveLeave;
public boolean stretches = false;
public int forcedPriority = 5;
public int maxLoops = 99;
public int[] field3056;
public int precedenceAnimating = -1;
public int leftHandItem = -1;
public int replyMode = 2;
public int frameStep = -1;
public int priority = -1;
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class SpotAnimDefinition
{
public int rotaton = 0;
public short[] textureToReplace;
public int id;
public short[] textureToFind;
public int resizeY = 128;
public int animationId = -1;
public short[] recolorToFind;
public short[] recolorToReplace;
public int resizeX = 128;
public int modelId;
public int ambient = 0;
public int contrast = 0;
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class SpriteDefinition
{
private int id;
private int frame;
private int offsetX;
private int offsetY;
private int width;
private int height;
private int[] pixels;
private int maxWidth;
private int maxHeight;
public transient byte[] pixelIdx;
public transient int[] palette;
public void normalize()
{
if (this.width != this.maxWidth || this.height != this.maxHeight)
{
byte[] var1 = new byte[this.maxWidth * this.maxHeight];
int var2 = 0;
for (int var3 = 0; var3 < this.height; ++var3)
{
for (int var4 = 0; var4 < this.width; ++var4)
{
var1[var4 + (var3 + this.offsetY) * this.maxWidth + this.offsetX] = this.pixelIdx[var2++];
}
}
this.pixelIdx = var1;
this.width = this.maxWidth;
this.height = this.maxHeight;
this.offsetX = 0;
this.offsetY = 0;
}
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2018, Joshua Filby <joshua@filby.me>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import java.util.Map;
import lombok.Data;
@Data
public class StructDefinition
{
public final int id;
public Map<Integer, Object> params = null;
}

View File

@@ -0,0 +1,150 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
import net.runelite.cache.definitions.providers.SpriteProvider;
@Data
public class TextureDefinition
{
public int field1777;
public boolean field1778;
private int id;
private int[] fileIds;
public int[] field1780;
public int[] field1781;
public int[] field1786;
public int field1782;
public int field1783;
public transient int[] pixels;
public boolean method2680(double var1, int var3, SpriteProvider spriteProvider)
{
int var5 = var3 * var3;
this.pixels = new int[var5];
for (int var6 = 0; var6 < this.fileIds.length; ++var6)
{
SpriteDefinition var7 = spriteProvider.provide(fileIds[var6], 0);
var7.normalize();
byte[] var8 = var7.pixelIdx;
int[] var9 = var7.palette;
int var10 = this.field1786[var6];
int var11;
int var12;
int var13;
int var14;
if ((var10 & -16777216) == 50331648)
{
var11 = var10 & 16711935;
var12 = var10 >> 8 & 255;
for (var13 = 0; var13 < var9.length; ++var13)
{
var14 = var9[var13];
if (var14 >> 8 == (var14 & 65535))
{
var14 &= 255;
var9[var13] = var11 * var14 >> 8 & 16711935 | var12 * var14 & 65280;
}
}
}
for (var11 = 0; var11 < var9.length; ++var11)
{
var9[var11] = adjustRGB(var9[var11], var1);
}
if (var6 == 0)
{
var11 = 0;
}
else
{
var11 = this.field1780[var6 - 1];
}
if (var11 == 0)
{
if (var3 == var7.getMaxWidth())
{
for (var12 = 0; var12 < var5; ++var12)
{
this.pixels[var12] = var9[var8[var12] & 255];
}
}
else if (var7.getMaxWidth() == 64 && var3 == 128)
{
var12 = 0;
for (var13 = 0; var13 < var3; ++var13)
{
for (var14 = 0; var14 < var3; ++var14)
{
this.pixels[var12++] = var9[var8[(var13 >> 1 << 6) + (var14 >> 1)] & 255];
}
}
}
else
{
if (var7.getMaxWidth() != 128 || var3 != 64)
{
throw new RuntimeException();
}
var12 = 0;
for (var13 = 0; var13 < var3; ++var13)
{
for (var14 = 0; var14 < var3; ++var14)
{
this.pixels[var12++] = var9[var8[(var14 << 1) + (var13 << 1 << 7)] & 255];
}
}
}
}
}
return true;
}
static int adjustRGB(int var0, double var1)
{
double var3 = (double) (var0 >> 16) / 256.0D;
double var5 = (double) (var0 >> 8 & 255) / 256.0D;
double var7 = (double) (var0 & 255) / 256.0D;
var3 = Math.pow(var3, var1);
var5 = Math.pow(var5, var1);
var7 = Math.pow(var7, var1);
int var9 = (int) (var3 * 256.0D);
int var10 = (int) (var5 * 256.0D);
int var11 = (int) (var7 * 256.0D);
return var11 + (var10 << 8) + (var9 << 16);
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class TrackDefinition
{
public byte[] midi; // midi file contents
}

View File

@@ -0,0 +1,134 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class UnderlayDefinition
{
private int id;
private int color;
private transient int hue;
private transient int saturation;
private transient int lightness;
private transient int hueMultiplier;
public void calculateHsl()
{
int var1 = color;
double var2 = (double) (var1 >> 16 & 255) / 256.0D;
double var4 = (double) (var1 >> 8 & 255) / 256.0D;
double var6 = (double) (var1 & 255) / 256.0D;
double var8 = var2;
if (var4 < var2)
{
var8 = var4;
}
if (var6 < var8)
{
var8 = var6;
}
double var10 = var2;
if (var4 > var2)
{
var10 = var4;
}
if (var6 > var10)
{
var10 = var6;
}
double var12 = 0.0D;
double var14 = 0.0D;
double var16 = (var10 + var8) / 2.0D;
if (var8 != var10)
{
if (var16 < 0.5D)
{
var14 = (var10 - var8) / (var8 + var10);
}
if (var16 >= 0.5D)
{
var14 = (var10 - var8) / (2.0D - var10 - var8);
}
if (var2 == var10)
{
var12 = (var4 - var6) / (var10 - var8);
}
else if (var10 == var4)
{
var12 = 2.0D + (var6 - var2) / (var10 - var8);
}
else if (var10 == var6)
{
var12 = 4.0D + (var2 - var4) / (var10 - var8);
}
}
var12 /= 6.0D;
this.saturation = (int) (var14 * 256.0D);
this.lightness = (int) (var16 * 256.0D);
if (this.saturation < 0)
{
this.saturation = 0;
}
else if (this.saturation > 255)
{
this.saturation = 255;
}
if (this.lightness < 0)
{
this.lightness = 0;
}
else if (this.lightness > 255)
{
this.lightness = 255;
}
if (var16 > 0.5D)
{
this.hueMultiplier = (int) (var14 * (1.0D - var16) * 512.0D);
}
else
{
this.hueMultiplier = (int) (var14 * var16 * 512.0D);
}
if (this.hueMultiplier < 1)
{
this.hueMultiplier = 1;
}
this.hue = (int) ((double) this.hueMultiplier * var12);
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class VarbitDefinition
{
private int id;
private int index;
private int leastSignificantBit;
private int mostSignificantBit;
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import java.util.List;
import lombok.Data;
import net.runelite.cache.region.Position;
@Data
public class WorldMapDefinition
{
public String name;
public int field450;
public int field451;
public int fileId;
public int field453;
public int field454;
public int field456;
public boolean field457;
public List field458;
public String safeName;
public Position position;
public int field463;
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class WorldMapType0 implements WorldMapTypeBase
{
public int field600;
public int field601;
public int field602;
public int field603;
public int field604;
public int field605;
public int field606;
public int field607;
public int field608;
public int field609;
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class WorldMapType1 implements WorldMapTypeBase
{
public int field424;
public int field425;
public int field426;
public int field427;
public int field428;
public int field429;
public int field431;
public int field433;
public int field434;
public int field435;
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class WorldMapType2 implements WorldMapTypeBase
{
public int field510;
public int field511;
public int field512;
public int field514;
public int field515;
public int field519;
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class WorldMapType3 implements WorldMapTypeBase
{
public int field376;
public int field377;
public int field378;
public int field379;
public int field380;
public int field381;
public int field382;
public int field383;
public int field384;
public int field385;
public int field386;
public int field387;
public int field388;
public int field389;
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions;
public interface WorldMapTypeBase {}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.exporters;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import net.runelite.cache.definitions.InterfaceDefinition;
public class InterfaceExporter
{
private final InterfaceDefinition item;
private final Gson gson;
public InterfaceExporter(InterfaceDefinition item)
{
this.item = item;
GsonBuilder builder = new GsonBuilder()
.setPrettyPrinting();
gson = builder.create();
}
public String export()
{
return gson.toJson(item);
}
public void exportTo(File file) throws IOException
{
try (FileWriter fw = new FileWriter(file))
{
fw.write(export());
}
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.exporters;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import net.runelite.cache.definitions.ItemDefinition;
public class ItemExporter
{
private final ItemDefinition item;
private final Gson gson;
public ItemExporter(ItemDefinition item)
{
this.item = item;
GsonBuilder builder = new GsonBuilder()
.setPrettyPrinting();
gson = builder.create();
}
public String export()
{
return gson.toJson(item);
}
public void exportTo(File file) throws IOException
{
try (FileWriter fw = new FileWriter(file))
{
fw.write(export());
}
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.exporters;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import net.runelite.cache.definitions.NpcDefinition;
public class NpcExporter
{
private final NpcDefinition npc;
private final Gson gson;
public NpcExporter(NpcDefinition npc)
{
this.npc = npc;
GsonBuilder builder = new GsonBuilder()
.setPrettyPrinting();
gson = builder.create();
}
public String export()
{
return gson.toJson(npc);
}
public void exportTo(File file) throws IOException
{
try (FileWriter fw = new FileWriter(file))
{
fw.write(export());
}
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.exporters;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import net.runelite.cache.definitions.ObjectDefinition;
public class ObjectExporter
{
private final ObjectDefinition object;
private final Gson gson;
public ObjectExporter(ObjectDefinition object)
{
this.object = object;
GsonBuilder builder = new GsonBuilder()
.setPrettyPrinting();
gson = builder.create();
}
public String export()
{
return gson.toJson(object);
}
public void exportTo(File file) throws IOException
{
try (FileWriter fw = new FileWriter(file))
{
fw.write(export());
}
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.exporters;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import net.runelite.cache.definitions.SpriteDefinition;
public class SpriteExporter
{
private final SpriteDefinition sprite;
public SpriteExporter(SpriteDefinition sprite)
{
this.sprite = sprite;
}
public BufferedImage export()
{
BufferedImage bi = new BufferedImage(sprite.getWidth(), sprite.getHeight(), BufferedImage.TYPE_INT_ARGB);
bi.setRGB(0, 0, sprite.getWidth(), sprite.getHeight(), sprite.getPixels(), 0, sprite.getWidth());
return bi;
}
public void exportTo(File file) throws IOException
{
BufferedImage image = export();
ImageIO.write(image, "png", file);
}
}

View File

@@ -0,0 +1,190 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.AreaDefinition;
import net.runelite.cache.io.InputStream;
public class AreaLoader
{
public AreaDefinition load(byte[] b, int id)
{
InputStream in = new InputStream(b);
AreaDefinition def = new AreaDefinition();
def.id = id;
for (;;)
{
int opcode = in.readUnsignedByte();
if (opcode == 0)
{
break;
}
processOpcode(def, in, opcode);
}
return def;
}
private void processOpcode(AreaDefinition def, InputStream in, int opcode)
{
if (opcode == 1)
{
def.spriteId = in.readBigSmart2();
}
else if (opcode == 2)
{
def.field3294 = in.readBigSmart2();
}
else if (opcode == 3)
{
def.name = in.readString();
}
else if (opcode == 4)
{
def.field3296 = in.read24BitInt();
}
else if (opcode == 5)
{
in.read24BitInt();
}
else if (opcode == 6)
{
def.field3310 = in.readUnsignedByte();
}
else if (opcode == 7)
{
int var3 = in.readUnsignedByte();
if ((var3 & 1) == 0)
{
;
}
if ((var3 & 2) == 2)
{
;
}
}
else if (opcode == 8)
{
in.readUnsignedByte();
}
else if (opcode >= 10 && opcode <= 14)
{
def.field3298[opcode - 10] = in.readString();
}
else if (opcode == 15)
{
int var3 = in.readUnsignedByte();
def.field3300 = new int[var3 * 2];
int var4;
for (var4 = 0; var4 < var3 * 2; ++var4)
{
def.field3300[var4] = in.readShort();
}
in.readInt();
var4 = in.readUnsignedByte();
def.field3292 = new int[var4];
int var5;
for (var5 = 0; var5 < def.field3292.length; ++var5)
{
def.field3292[var5] = in.readInt();
}
def.field3309 = new byte[var3];
for (var5 = 0; var5 < var3; ++var5)
{
def.field3309[var5] = in.readByte();
}
}
else if (opcode == 16)
{
}
else if (opcode == 17)
{
def.field3308 = in.readString();
}
else if (opcode == 18)
{
in.readBigSmart2();
}
else if (opcode == 19)
{
def.field3297 = in.readUnsignedShort();
}
else if (opcode == 21)
{
in.readInt();
}
else if (opcode == 22)
{
in.readInt();
}
else if (opcode == 23)
{
in.readUnsignedByte();
in.readUnsignedByte();
in.readUnsignedByte();
}
else if (opcode == 24)
{
in.readShort();
in.readShort();
}
else if (opcode == 25)
{
in.readBigSmart2();
}
else if (opcode == 28)
{
in.readUnsignedByte();
}
else if (opcode == 29)
{
in.skip(1);
// class257[] var6 = new class257[]
// {
// class257.field3538, class257.field3539, class257.field3540
// };
// this.field3299 = (class257) Item.method1751(var6, var1.readUnsignedByte());
}
else if (opcode == 30)
{
in.skip(1);
// class239[] var7 = new class239[]
// {
// class239.field3273, class239.field3275, class239.field3271
// };
// this.field3306 = (class239) Item.method1751(var7, var1.readUnsignedByte());
}
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.EnumDefinition;
import net.runelite.cache.io.InputStream;
import net.runelite.cache.util.ScriptVarType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EnumLoader
{
private static final Logger logger = LoggerFactory.getLogger(EnumLoader.class);
public EnumDefinition load(int id, byte[] b)
{
if (b.length == 1 && b[0] == 0)
{
return null;
}
EnumDefinition def = new EnumDefinition();
InputStream is = new InputStream(b);
def.setId(id);
for (;;)
{
int opcode = is.readUnsignedByte();
if (opcode == 0)
{
break;
}
processOp(opcode, def, is);
}
return def;
}
private void processOp(int opcode, EnumDefinition def, InputStream is)
{
switch (opcode)
{
case 1:
def.setKeyType(ScriptVarType.forCharKey((char) is.readUnsignedByte()));
break;
case 2:
def.setValType(ScriptVarType.forCharKey((char) is.readUnsignedByte()));
break;
case 3:
def.setDefaultString(is.readString());
break;
case 4:
def.setDefaultInt(is.readInt());
break;
case 5:
{
int size = is.readUnsignedShort();
int[] keys = new int[size];
String[] stringVals = new String[size];
for (int index = 0; index < size; ++index)
{
keys[index] = is.readInt();
stringVals[index] = is.readString();
}
def.setSize(size);
def.setKeys(keys);
def.setStringVals(stringVals);
break;
}
case 6:
{
int size = is.readUnsignedShort();
int[] keys = new int[size];
int[] intVals = new int[size];
for (int index = 0; index < size; ++index)
{
keys[index] = is.readInt();
intVals[index] = is.readInt();
}
def.setSize(size);
def.setKeys(keys);
def.setIntVals(intVals);
break;
}
default:
logger.warn("Unrecognized opcode {}", opcode);
break;
}
}
}

View File

@@ -0,0 +1,142 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.FrameDefinition;
import net.runelite.cache.definitions.FramemapDefinition;
import net.runelite.cache.io.InputStream;
public class FrameLoader
{
public FrameDefinition load(FramemapDefinition framemap, int id, byte[] b)
{
FrameDefinition def = new FrameDefinition();
InputStream in = new InputStream(b);
InputStream data = new InputStream(b);
def.id = id;
def.framemap = framemap;
int framemapArchiveIndex = in.readUnsignedShort();
int length = in.readUnsignedByte();
data.skip(3 + length); // framemapArchiveIndex + length + data
int[] indexFrameIds = new int[500];
int[] scratchTranslatorX = new int[500];
int[] scratchTranslatorY = new int[500];
int[] scratchTranslatorZ = new int[500];
int lastI = -1;
int index = 0;
for (int i = 0; i < length; ++i)
{
int var9 = in.readUnsignedByte();
if (var9 <= 0)
{
continue;
}
if (def.framemap.types[i] != 0)
{
for (int var10 = i - 1; var10 > lastI; --var10)
{
if (def.framemap.types[var10] == 0)
{
indexFrameIds[index] = var10;
scratchTranslatorX[index] = 0;
scratchTranslatorY[index] = 0;
scratchTranslatorZ[index] = 0;
++index;
break;
}
}
}
indexFrameIds[index] = i;
short var11 = 0;
if (def.framemap.types[i] == 3)
{
var11 = 128;
}
if ((var9 & 1) != 0)
{
scratchTranslatorX[index] = data.readShortSmart();
}
else
{
scratchTranslatorX[index] = var11;
}
if ((var9 & 2) != 0)
{
scratchTranslatorY[index] = data.readShortSmart();
}
else
{
scratchTranslatorY[index] = var11;
}
if ((var9 & 4) != 0)
{
scratchTranslatorZ[index] = data.readShortSmart();
}
else
{
scratchTranslatorZ[index] = var11;
}
lastI = i;
++index;
if (def.framemap.types[i] == 5)
{
def.showing = true;
}
}
if (data.getOffset() != b.length)
{
throw new RuntimeException();
}
def.translatorCount = index;
def.indexFrameIds = new int[index];
def.translator_x = new int[index];
def.translator_y = new int[index];
def.translator_z = new int[index];
for (int i = 0; i < index; ++i)
{
def.indexFrameIds[i] = indexFrameIds[i];
def.translator_x[i] = scratchTranslatorX[i];
def.translator_y[i] = scratchTranslatorY[i];
def.translator_z[i] = scratchTranslatorZ[i];
}
return def;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.FramemapDefinition;
import net.runelite.cache.io.InputStream;
public class FramemapLoader
{
public FramemapDefinition load(int id, byte[] b)
{
FramemapDefinition def = new FramemapDefinition();
InputStream in = new InputStream(b);
def.id = id;
def.length = in.readUnsignedByte();
def.types = new int[def.length];
def.frameMaps = new int[def.length][];
for (int i = 0; i < def.length; ++i)
{
def.types[i] = in.readUnsignedByte();
}
for (int i = 0; i < def.length; ++i)
{
def.frameMaps[i] = new int[in.readUnsignedByte()];
}
for (int i = 0; i < def.length; ++i)
{
for (int j = 0; j < def.frameMaps[i].length; ++j)
{
def.frameMaps[i][j] = in.readUnsignedByte();
}
}
return def;
}
}

View File

@@ -0,0 +1,572 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.runelite.cache.definitions.ClientScript1Instruction;
import net.runelite.cache.definitions.InterfaceDefinition;
import net.runelite.cache.io.InputStream;
public class InterfaceLoader
{
public InterfaceDefinition load(int id, byte[] b)
{
InterfaceDefinition iface = new InterfaceDefinition();
iface.id = id;
if (b[0] == -1)
{
decodeIf3(iface, new InputStream(b));
}
else
{
decodeIf1(iface, new InputStream(b));
}
return iface;
}
private void decodeIf1(InterfaceDefinition iface, InputStream var1)
{
iface.isIf3 = false;
iface.type = var1.readUnsignedByte();
iface.menuType = var1.readUnsignedByte();
iface.contentType = var1.readUnsignedShort();
iface.originalX = var1.readShort();
iface.originalY = var1.readShort();
iface.originalWidth = var1.readUnsignedShort();
iface.originalHeight = var1.readUnsignedShort();
iface.opacity = var1.readUnsignedByte();
iface.parentId = var1.readUnsignedShort();
if (iface.parentId == 0xFFFF)
{
iface.parentId = -1;
}
else
{
iface.parentId += iface.id & ~0xFFFF;
}
iface.hoveredSiblingId = var1.readUnsignedShort();
if (iface.hoveredSiblingId == 0xFFFF)
{
iface.hoveredSiblingId = -1;
}
int var2 = var1.readUnsignedByte();
int var3;
if (var2 > 0)
{
iface.alternateOperators = new int[var2];
iface.alternateRhs = new int[var2];
for (var3 = 0; var3 < var2; ++var3)
{
iface.alternateOperators[var3] = var1.readUnsignedByte();
iface.alternateRhs[var3] = var1.readUnsignedShort();
}
}
var3 = var1.readUnsignedByte();
int var4;
int var5;
int var6;
if (var3 > 0)
{
iface.clientScripts = new ClientScript1Instruction[var3][];
for (var4 = 0; var4 < var3; ++var4)
{
var5 = var1.readUnsignedShort();
int[] bytecode = new int[var5];
for (var6 = 0; var6 < var5; ++var6)
{
bytecode[var6] = var1.readUnsignedShort();
if (bytecode[var6] == 0xFFFF)
{
bytecode[var6] = -1;
}
List<ClientScript1Instruction> instructions = new ArrayList<>();
for (int i = 0; i < bytecode.length;)
{
ClientScript1Instruction ins = new ClientScript1Instruction();
ins.opcode = ClientScript1Instruction.Opcode.values()[bytecode[i++]];
int ac = ins.opcode.argumentCount;
ins.operands = Arrays.copyOfRange(bytecode, i, i + ac);
instructions.add(ins);
i += ac;
}
iface.clientScripts[var4] = instructions.toArray(new ClientScript1Instruction[0]);
}
}
}
if (iface.type == 0)
{
iface.scrollHeight = var1.readUnsignedShort();
iface.isHidden = var1.readUnsignedByte() == 1;
}
if (iface.type == 1)
{
var1.readUnsignedShort();
var1.readUnsignedByte();
}
if (iface.type == 2)
{
iface.itemIds = new int[iface.originalWidth * iface.originalHeight];
iface.itemQuantities = new int[iface.originalHeight * iface.originalWidth];
var4 = var1.readUnsignedByte();
if (var4 == 1)
{
iface.clickMask |= 268435456;
}
var5 = var1.readUnsignedByte();
if (var5 == 1)
{
iface.clickMask |= 1073741824;
}
var6 = var1.readUnsignedByte();
if (var6 == 1)
{
iface.clickMask |= Integer.MIN_VALUE;
}
int var7 = var1.readUnsignedByte();
if (var7 == 1)
{
iface.clickMask |= 536870912;
}
iface.xPitch = var1.readUnsignedByte();
iface.yPitch = var1.readUnsignedByte();
iface.xOffsets = new int[20];
iface.yOffsets = new int[20];
iface.sprites = new int[20];
int var8;
for (var8 = 0; var8 < 20; ++var8)
{
int var9 = var1.readUnsignedByte();
if (var9 == 1)
{
iface.xOffsets[var8] = var1.readShort();
iface.yOffsets[var8] = var1.readShort();
iface.sprites[var8] = var1.readInt();
}
else
{
iface.sprites[var8] = -1;
}
}
iface.configActions = new String[5];
for (var8 = 0; var8 < 5; ++var8)
{
String var11 = var1.readString();
if (var11.length() > 0)
{
iface.configActions[var8] = var11;
iface.clickMask |= 1 << var8 + 23;
}
}
}
if (iface.type == 3)
{
iface.filled = var1.readUnsignedByte() == 1;
}
if (iface.type == 4 || iface.type == 1)
{
iface.xTextAlignment = var1.readUnsignedByte();
iface.yTextAlignment = var1.readUnsignedByte();
iface.lineHeight = var1.readUnsignedByte();
iface.fontId = var1.readUnsignedShort();
if (iface.fontId == 0xFFFF)
{
iface.fontId = -1;
}
iface.textShadowed = var1.readUnsignedByte() == 1;
}
if (iface.type == 4)
{
iface.text = var1.readString();
iface.alternateText = var1.readString();
}
if (iface.type == 1 || iface.type == 3 || iface.type == 4)
{
iface.textColor = var1.readInt();
}
if (iface.type == 3 || iface.type == 4)
{
iface.alternateTextColor = var1.readInt();
iface.hoveredTextColor = var1.readInt();
iface.alternateHoveredTextColor = var1.readInt();
}
if (iface.type == 5)
{
iface.spriteId = var1.readInt();
iface.alternateSpriteId = var1.readInt();
}
if (iface.type == 6)
{
iface.modelType = 1;
iface.modelId = var1.readUnsignedShort();
if (iface.modelId == 0xFFFF)
{
iface.modelId = -1;
}
iface.alternateModelId = var1.readUnsignedShort();
if (iface.alternateModelId == 0xFFFF)
{
iface.alternateModelId = -1;
}
iface.animation = var1.readUnsignedShort();
if (iface.animation == 0xFFFF)
{
iface.animation = -1;
}
iface.alternateAnimation = var1.readUnsignedShort();
if (iface.alternateAnimation == 0xFFFF)
{
iface.alternateAnimation = -1;
}
iface.modelZoom = var1.readUnsignedShort();
iface.rotationX = var1.readUnsignedShort();
iface.rotationZ = var1.readUnsignedShort();
}
if (iface.type == 7)
{
iface.itemIds = new int[iface.originalWidth * iface.originalHeight];
iface.itemQuantities = new int[iface.originalWidth * iface.originalHeight];
iface.xTextAlignment = var1.readUnsignedByte();
iface.fontId = var1.readUnsignedShort();
if (iface.fontId == 0xFFFF)
{
iface.fontId = -1;
}
iface.textShadowed = var1.readUnsignedByte() == 1;
iface.textColor = var1.readInt();
iface.xPitch = var1.readShort();
iface.yPitch = var1.readShort();
var4 = var1.readUnsignedByte();
if (var4 == 1)
{
iface.clickMask |= 1073741824;
}
iface.configActions = new String[5];
for (var5 = 0; var5 < 5; ++var5)
{
String var10 = var1.readString();
if (var10.length() > 0)
{
iface.configActions[var5] = var10;
iface.clickMask |= 1 << var5 + 23;
}
}
}
if (iface.type == 8)
{
iface.text = var1.readString();
}
if (iface.menuType == 2 || iface.type == 2)
{
iface.targetVerb = var1.readString();
iface.spellName = var1.readString();
var4 = var1.readUnsignedShort() & 63;
iface.clickMask |= var4 << 11;
}
if (iface.menuType == 1 || iface.menuType == 4 || iface.menuType == 5 || iface.menuType == 6)
{
iface.tooltip = var1.readString();
if (iface.tooltip.length() == 0)
{
if (iface.menuType == 1)
{
iface.tooltip = "Ok";
}
if (iface.menuType == 4)
{
iface.tooltip = "Select";
}
if (iface.menuType == 5)
{
iface.tooltip = "Select";
}
if (iface.menuType == 6)
{
iface.tooltip = "Continue";
}
}
}
if (iface.menuType == 1 || iface.menuType == 4 || iface.menuType == 5)
{
iface.clickMask |= 4194304;
}
if (iface.menuType == 6)
{
iface.clickMask |= 1;
}
}
private void decodeIf3(InterfaceDefinition iface, InputStream var1)
{
var1.readUnsignedByte();
iface.isIf3 = true;
iface.type = var1.readUnsignedByte();
iface.contentType = var1.readUnsignedShort();
iface.originalX = var1.readShort();
iface.originalY = var1.readShort();
iface.originalWidth = var1.readUnsignedShort();
if (iface.type == 9)
{
iface.originalHeight = var1.readShort();
}
else
{
iface.originalHeight = var1.readUnsignedShort();
}
iface.widthMode = var1.readByte();
iface.heightMode = var1.readByte();
iface.xPositionMode = var1.readByte();
iface.yPositionMode = var1.readByte();
iface.parentId = var1.readUnsignedShort();
if (iface.parentId == 0xFFFF)
{
iface.parentId = -1;
}
else
{
iface.parentId += iface.id & ~0xFFFF;
}
iface.isHidden = var1.readUnsignedByte() == 1;
if (iface.type == 0)
{
iface.scrollWidth = var1.readUnsignedShort();
iface.scrollHeight = var1.readUnsignedShort();
iface.noClickThrough = var1.readUnsignedByte() == 1;
}
if (iface.type == 5)
{
iface.spriteId = var1.readInt();
iface.textureId = var1.readUnsignedShort();
iface.spriteTiling = var1.readUnsignedByte() == 1;
iface.opacity = var1.readUnsignedByte();
iface.borderType = var1.readUnsignedByte();
iface.shadowColor = var1.readInt();
iface.flippedVertically = var1.readUnsignedByte() == 1;
iface.flippedHorizontally = var1.readUnsignedByte() == 1;
}
if (iface.type == 6)
{
iface.modelType = 1;
iface.modelId = var1.readUnsignedShort();
if (iface.modelId == 0xFFFF)
{
iface.modelId = -1;
}
iface.offsetX2d = var1.readShort();
iface.offsetY2d = var1.readShort();
iface.rotationX = var1.readUnsignedShort();
iface.rotationZ = var1.readUnsignedShort();
iface.rotationY = var1.readUnsignedShort();
iface.modelZoom = var1.readUnsignedShort();
iface.animation = var1.readUnsignedShort();
if (iface.animation == 0xFFFF)
{
iface.animation = -1;
}
iface.orthogonal = var1.readUnsignedByte() == 1;
var1.readUnsignedShort();
if (iface.widthMode != 0)
{
iface.modelHeightOverride = var1.readUnsignedShort();
}
if (iface.heightMode != 0)
{
var1.readUnsignedShort();
}
}
if (iface.type == 4)
{
iface.fontId = var1.readUnsignedShort();
if (iface.fontId == 0xFFFF)
{
iface.fontId = -1;
}
iface.text = var1.readString();
iface.lineHeight = var1.readUnsignedByte();
iface.xTextAlignment = var1.readUnsignedByte();
iface.yTextAlignment = var1.readUnsignedByte();
iface.textShadowed = var1.readUnsignedByte() == 1;
iface.textColor = var1.readInt();
}
if (iface.type == 3)
{
iface.textColor = var1.readInt();
iface.filled = var1.readUnsignedByte() == 1;
iface.opacity = var1.readUnsignedByte();
}
if (iface.type == 9)
{
iface.lineWidth = var1.readUnsignedByte();
iface.textColor = var1.readInt();
iface.lineDirection = var1.readUnsignedByte() == 1;
}
iface.clickMask = var1.read24BitInt();
iface.name = var1.readString();
int var2 = var1.readUnsignedByte();
if (var2 > 0)
{
iface.actions = new String[var2];
for (int var3 = 0; var3 < var2; ++var3)
{
iface.actions[var3] = var1.readString();
}
}
iface.dragDeadZone = var1.readUnsignedByte();
iface.dragDeadTime = var1.readUnsignedByte();
iface.dragRenderBehavior = var1.readUnsignedByte() == 1;
iface.targetVerb = var1.readString();
iface.onLoadListener = this.decodeListener(iface, var1);
iface.onMouseOverListener = this.decodeListener(iface, var1);
iface.onMouseLeaveListener = this.decodeListener(iface, var1);
iface.onTargetLeaveListener = this.decodeListener(iface, var1);
iface.onTargetEnterListener = this.decodeListener(iface, var1);
iface.onVarTransmitListener = this.decodeListener(iface, var1);
iface.onInvTransmitListener = this.decodeListener(iface, var1);
iface.onStatTransmitListener = this.decodeListener(iface, var1);
iface.onTimerListener = this.decodeListener(iface, var1);
iface.onOpListener = this.decodeListener(iface, var1);
iface.onMouseRepeatListener = this.decodeListener(iface, var1);
iface.onClickListener = this.decodeListener(iface, var1);
iface.onClickRepeatListener = this.decodeListener(iface, var1);
iface.onReleaseListener = this.decodeListener(iface, var1);
iface.onHoldListener = this.decodeListener(iface, var1);
iface.onDragListener = this.decodeListener(iface, var1);
iface.onDragCompleteListener = this.decodeListener(iface, var1);
iface.onScrollWheelListener = this.decodeListener(iface, var1);
iface.varTransmitTriggers = this.decodeTriggers(var1);
iface.invTransmitTriggers = this.decodeTriggers(var1);
iface.statTransmitTriggers = this.decodeTriggers(var1);
}
private Object[] decodeListener(InterfaceDefinition iface, InputStream var1)
{
int var2 = var1.readUnsignedByte();
if (var2 == 0)
{
return null;
}
else
{
Object[] var3 = new Object[var2];
for (int var4 = 0; var4 < var2; ++var4)
{
int var5 = var1.readUnsignedByte();
if (var5 == 0)
{
var3[var4] = new Integer(var1.readInt());
}
else if (var5 == 1)
{
var3[var4] = var1.readString();
}
}
iface.hasListener = true;
return var3;
}
}
private int[] decodeTriggers(InputStream var1)
{
int var2 = var1.readUnsignedByte();
if (var2 == 0)
{
return null;
}
else
{
int[] var3 = new int[var2];
for (int var4 = 0; var4 < var2; ++var4)
{
var3[var4] = var1.readInt();
}
return var3;
}
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.InventoryDefinition;
import net.runelite.cache.io.InputStream;
public class InventoryLoader
{
public InventoryDefinition load(int id, byte[] b)
{
InventoryDefinition def = new InventoryDefinition();
def.id = id;
InputStream is = new InputStream(b);
while (true)
{
int opcode = is.readUnsignedByte();
if (opcode == 0)
{
break;
}
if (opcode == 2)
{
def.size = is.readUnsignedShort();
}
}
return def;
}
}

View File

@@ -0,0 +1,288 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import java.util.HashMap;
import net.runelite.cache.definitions.ItemDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ItemLoader
{
private static final Logger logger = LoggerFactory.getLogger(ItemLoader.class);
public ItemDefinition load(int id, byte[] b)
{
ItemDefinition def = new ItemDefinition(id);
InputStream is = new InputStream(b);
while (true)
{
int opcode = is.readUnsignedByte();
if (opcode == 0)
{
break;
}
this.decodeValues(opcode, def, is);
}
return def;
}
private void decodeValues(int opcode, ItemDefinition def, InputStream stream)
{
if (opcode == 1)
{
def.inventoryModel = stream.readUnsignedShort();
}
else if (opcode == 2)
{
def.name = stream.readString();
}
else if (opcode == 4)
{
def.zoom2d = stream.readUnsignedShort();
}
else if (opcode == 5)
{
def.xan2d = stream.readUnsignedShort();
}
else if (opcode == 6)
{
def.yan2d = stream.readUnsignedShort();
}
else if (opcode == 7)
{
def.xOffset2d = stream.readUnsignedShort();
if (def.xOffset2d > 32767)
{
def.xOffset2d -= 65536;
}
}
else if (opcode == 8)
{
def.yOffset2d = stream.readUnsignedShort();
if (def.yOffset2d > 32767)
{
def.yOffset2d -= 65536;
}
}
else if (opcode == 11)
{
def.stackable = 1;
}
else if (opcode == 12)
{
def.cost = stream.readInt();
}
else if (opcode == 16)
{
def.members = true;
}
else if (opcode == 23)
{
def.maleModel0 = stream.readUnsignedShort();
def.maleOffset = stream.readUnsignedByte();
}
else if (opcode == 24)
{
def.maleModel1 = stream.readUnsignedShort();
}
else if (opcode == 25)
{
def.femaleModel0 = stream.readUnsignedShort();
def.femaleOffset = stream.readUnsignedByte();
}
else if (opcode == 26)
{
def.femaleModel1 = stream.readUnsignedShort();
}
else if (opcode >= 30 && opcode < 35)
{
def.options[opcode - 30] = stream.readString();
if (def.options[opcode - 30].equalsIgnoreCase("Hidden"))
{
def.options[opcode - 30] = null;
}
}
else if (opcode >= 35 && opcode < 40)
{
def.interfaceOptions[opcode - 35] = stream.readString();
}
else if (opcode == 40)
{
int var5 = stream.readUnsignedByte();
def.colorFind = new short[var5];
def.colorReplace = new short[var5];
for (int var4 = 0; var4 < var5; ++var4)
{
def.colorFind[var4] = (short) stream.readUnsignedShort();
def.colorReplace[var4] = (short) stream.readUnsignedShort();
}
}
else if (opcode == 41)
{
int var5 = stream.readUnsignedByte();
def.textureFind = new short[var5];
def.textureReplace = new short[var5];
for (int var4 = 0; var4 < var5; ++var4)
{
def.textureFind[var4] = (short) stream.readUnsignedShort();
def.textureReplace[var4] = (short) stream.readUnsignedShort();
}
}
else if (opcode == 42)
{
def.shiftClickDropIndex = stream.readByte();
}
else if (opcode == 65)
{
def.isTradeable = true;
}
else if (opcode == 78)
{
def.maleModel2 = stream.readUnsignedShort();
}
else if (opcode == 79)
{
def.femaleModel2 = stream.readUnsignedShort();
}
else if (opcode == 90)
{
def.maleHeadModel = stream.readUnsignedShort();
}
else if (opcode == 91)
{
def.femaleHeadModel = stream.readUnsignedShort();
}
else if (opcode == 92)
{
def.maleHeadModel2 = stream.readUnsignedShort();
}
else if (opcode == 93)
{
def.femaleHeadModel2 = stream.readUnsignedShort();
}
else if (opcode == 95)
{
def.zan2d = stream.readUnsignedShort();
}
else if (opcode == 97)
{
def.notedID = stream.readUnsignedShort();
}
else if (opcode == 98)
{
def.notedTemplate = stream.readUnsignedShort();
}
else if (opcode >= 100 && opcode < 110)
{
if (def.countObj == null)
{
def.countObj = new int[10];
def.countCo = new int[10];
}
def.countObj[opcode - 100] = stream.readUnsignedShort();
def.countCo[opcode - 100] = stream.readUnsignedShort();
}
else if (opcode == 110)
{
def.resizeX = stream.readUnsignedShort();
}
else if (opcode == 111)
{
def.resizeY = stream.readUnsignedShort();
}
else if (opcode == 112)
{
def.resizeZ = stream.readUnsignedShort();
}
else if (opcode == 113)
{
def.ambient = stream.readByte();
}
else if (opcode == 114)
{
def.contrast = stream.readByte();
}
else if (opcode == 115)
{
def.team = stream.readUnsignedByte();
}
else if (opcode == 139)
{
def.boughtId = stream.readUnsignedShort();
}
else if (opcode == 140)
{
def.boughtTemplateId = stream.readUnsignedShort();
}
else if (opcode == 148)
{
def.placeholderId = stream.readUnsignedShort();
}
else if (opcode == 149)
{
def.placeholderTemplateId = stream.readUnsignedShort();
}
else if (opcode == 249)
{
int length = stream.readUnsignedByte();
def.params = new HashMap<>(length);
for (int i = 0; i < length; i++)
{
boolean isString = stream.readUnsignedByte() == 1;
int key = stream.read24BitInt();
Object value;
if (isString)
{
value = stream.readString();
}
else
{
value = stream.readInt();
}
def.params.put(key, value);
}
}
else
{
logger.warn("Unrecognized opcode {}", opcode);
}
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.KitDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class KitLoader
{
private static final Logger logger = LoggerFactory.getLogger(KitLoader.class);
public KitDefinition load(int id, byte[] b)
{
KitDefinition def = new KitDefinition(id);
InputStream is = new InputStream(b);
for (;;)
{
int opcode = is.readUnsignedByte();
if (opcode == 0)
{
break;
}
if (opcode == 1)
{
def.bodyPartId = is.readUnsignedByte();
}
else if (opcode == 2)
{
int length = is.readUnsignedByte();
def.modelIds = new int[length];
for (int index = 0; index < length; ++index)
{
def.modelIds[index] = is.readUnsignedShort();
}
}
else if (opcode == 3)
{
def.nonSelectable = true;
}
else if (opcode == 40)
{
int length = is.readUnsignedByte();
def.recolorToFind = new short[length];
def.recolorToReplace = new short[length];
for (int index = 0; index < length; ++index)
{
def.recolorToFind[index] = is.readShort();
def.recolorToReplace[index] = is.readShort();
}
}
else if (opcode == 41)
{
int length = is.readUnsignedByte();
def.retextureToFind = new short[length];
def.retextureToReplace = new short[length];
for (int index = 0; index < length; ++index)
{
def.retextureToFind[index] = is.readShort();
def.retextureToReplace[index] = is.readShort();
}
}
else if (opcode >= 60 && opcode < 70)
{
def.models[opcode - 60] = is.readShort();
}
}
return def;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.LocationsDefinition;
import net.runelite.cache.io.InputStream;
import net.runelite.cache.region.Location;
import net.runelite.cache.region.Position;
public class LocationsLoader
{
public LocationsDefinition load(int regionX, int regionY, byte[] b)
{
LocationsDefinition loc = new LocationsDefinition();
loc.setRegionX(regionX);
loc.setRegionY(regionY);
loadLocations(loc, b);
return loc;
}
private void loadLocations(LocationsDefinition loc, byte[] b)
{
InputStream buf = new InputStream(b);
int id = -1;
int idOffset;
while ((idOffset = buf.readUnsignedIntSmartShortCompat()) != 0)
{
id += idOffset;
int position = 0;
int positionOffset;
while ((positionOffset = buf.readUnsignedShortSmart()) != 0)
{
position += positionOffset - 1;
int localY = position & 0x3F;
int localX = position >> 6 & 0x3F;
int height = position >> 12 & 0x3;
int attributes = buf.readUnsignedByte();
int type = attributes >> 2;
int orientation = attributes & 0x3;
loc.getLocations().add(new Location(id, type, orientation, new Position(localX, localY, height)));
}
}
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.MapDefinition;
import net.runelite.cache.definitions.MapDefinition.Tile;
import net.runelite.cache.io.InputStream;
import static net.runelite.cache.region.Region.X;
import static net.runelite.cache.region.Region.Y;
import static net.runelite.cache.region.Region.Z;
public class MapLoader
{
public MapDefinition load(int regionX, int regionY, byte[] b)
{
MapDefinition map = new MapDefinition();
map.setRegionX(regionX);
map.setRegionY(regionY);
loadTerrain(map, b);
return map;
}
private void loadTerrain(MapDefinition map, byte[] buf)
{
Tile[][][] tiles = map.getTiles();
InputStream in = new InputStream(buf);
for (int z = 0; z < Z; z++)
{
for (int x = 0; x < X; x++)
{
for (int y = 0; y < Y; y++)
{
Tile tile = tiles[z][x][y] = new Tile();
while (true)
{
int attribute = in.readUnsignedByte();
if (attribute == 0)
{
break;
}
else if (attribute == 1)
{
int height = in.readUnsignedByte();
tile.height = height;
break;
}
else if (attribute <= 49)
{
tile.attrOpcode = attribute;
tile.overlayId = in.readByte();
tile.overlayPath = (byte) ((attribute - 2) / 4);
tile.overlayRotation = (byte) (attribute - 2 & 3);
}
else if (attribute <= 81)
{
tile.settings = (byte) (attribute - 49);
}
else
{
tile.underlayId = (byte) (attribute - 81);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,750 @@
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.ModelDefinition;
import net.runelite.cache.io.InputStream;
public class ModelLoader
{
public ModelDefinition load(int modelId, byte[] b)
{
ModelDefinition def = new ModelDefinition();
def.id = modelId;
if (b[b.length - 1] == -1 && b[b.length - 2] == -1)
{
this.load1(def, b);
}
else
{
this.load2(def, b);
}
def.computeNormals();
def.computeTextureUVCoordinates();
def.computeAnimationTables();
return def;
}
private void load1(ModelDefinition model, byte[] var1)
{
InputStream var2 = new InputStream(var1);
InputStream var24 = new InputStream(var1);
InputStream var3 = new InputStream(var1);
InputStream var28 = new InputStream(var1);
InputStream var6 = new InputStream(var1);
InputStream var55 = new InputStream(var1);
InputStream var51 = new InputStream(var1);
var2.setOffset(var1.length - 23);
int verticeCount = var2.readUnsignedShort();
int triangleCount = var2.readUnsignedShort();
int textureTriangleCount = var2.readUnsignedByte();
int var13 = var2.readUnsignedByte();
int modelPriority = var2.readUnsignedByte();
int var50 = var2.readUnsignedByte();
int var17 = var2.readUnsignedByte();
int modelTexture = var2.readUnsignedByte();
int modelVertexSkins = var2.readUnsignedByte();
int var20 = var2.readUnsignedShort();
int var21 = var2.readUnsignedShort();
int var42 = var2.readUnsignedShort();
int var22 = var2.readUnsignedShort();
int var38 = var2.readUnsignedShort();
int textureAmount = 0;
int var7 = 0;
int var29 = 0;
int position;
if (textureTriangleCount > 0)
{
model.textureRenderTypes = new byte[textureTriangleCount];
var2.setOffset(0);
for (position = 0; position < textureTriangleCount; ++position)
{
byte renderType = model.textureRenderTypes[position] = var2.readByte();
if (renderType == 0)
{
++textureAmount;
}
if (renderType >= 1 && renderType <= 3)
{
++var7;
}
if (renderType == 2)
{
++var29;
}
}
}
position = textureTriangleCount + verticeCount;
int renderTypePos = position;
if (var13 == 1)
{
position += triangleCount;
}
int var49 = position;
position += triangleCount;
int priorityPos = position;
if (modelPriority == 255)
{
position += triangleCount;
}
int triangleSkinPos = position;
if (var17 == 1)
{
position += triangleCount;
}
int var35 = position;
if (modelVertexSkins == 1)
{
position += verticeCount;
}
int alphaPos = position;
if (var50 == 1)
{
position += triangleCount;
}
int var11 = position;
position += var22;
int texturePos = position;
if (modelTexture == 1)
{
position += triangleCount * 2;
}
int textureCoordPos = position;
position += var38;
int colorPos = position;
position += triangleCount * 2;
int var40 = position;
position += var20;
int var41 = position;
position += var21;
int var8 = position;
position += var42;
int var43 = position;
position += textureAmount * 6;
int var37 = position;
position += var7 * 6;
int var48 = position;
position += var7 * 6;
int var56 = position;
position += var7 * 2;
int var45 = position;
position += var7;
int var46 = position;
position += var7 * 2 + var29 * 2;
model.vertexCount = verticeCount;
model.faceCount = triangleCount;
model.textureTriangleCount = textureTriangleCount;
model.vertexPositionsX = new int[verticeCount];
model.vertexPositionsY = new int[verticeCount];
model.vertexPositionsZ = new int[verticeCount];
model.faceVertexIndices1 = new int[triangleCount];
model.faceVertexIndices2 = new int[triangleCount];
model.faceVertexIndices3 = new int[triangleCount];
if (modelVertexSkins == 1)
{
model.vertexSkins = new int[verticeCount];
}
if (var13 == 1)
{
model.faceRenderTypes = new byte[triangleCount];
}
if (modelPriority == 255)
{
model.faceRenderPriorities = new byte[triangleCount];
}
else
{
model.priority = (byte) modelPriority;
}
if (var50 == 1)
{
model.faceAlphas = new byte[triangleCount];
}
if (var17 == 1)
{
model.faceSkins = new int[triangleCount];
}
if (modelTexture == 1)
{
model.faceTextures = new short[triangleCount];
}
if (modelTexture == 1 && textureTriangleCount > 0)
{
model.textureCoordinates = new byte[triangleCount];
}
model.faceColors = new short[triangleCount];
if (textureTriangleCount > 0)
{
model.textureTriangleVertexIndices1 = new short[textureTriangleCount];
model.textureTriangleVertexIndices2 = new short[textureTriangleCount];
model.textureTriangleVertexIndices3 = new short[textureTriangleCount];
if (var7 > 0)
{
model.aShortArray2574 = new short[var7];
model.aShortArray2575 = new short[var7];
model.aShortArray2586 = new short[var7];
model.aShortArray2577 = new short[var7];
model.aByteArray2580 = new byte[var7];
model.aShortArray2578 = new short[var7];
}
if (var29 > 0)
{
model.texturePrimaryColors = new short[var29];
}
}
var2.setOffset(textureTriangleCount);
var24.setOffset(var40);
var3.setOffset(var41);
var28.setOffset(var8);
var6.setOffset(var35);
int vX = 0;
int vY = 0;
int vZ = 0;
int vertexZOffset;
int var10;
int vertexYOffset;
int var15;
int point;
for (point = 0; point < verticeCount; ++point)
{
int vertexFlags = var2.readUnsignedByte();
int vertexXOffset = 0;
if ((vertexFlags & 1) != 0)
{
vertexXOffset = var24.readShortSmart();
}
vertexYOffset = 0;
if ((vertexFlags & 2) != 0)
{
vertexYOffset = var3.readShortSmart();
}
vertexZOffset = 0;
if ((vertexFlags & 4) != 0)
{
vertexZOffset = var28.readShortSmart();
}
model.vertexPositionsX[point] = vX + vertexXOffset;
model.vertexPositionsY[point] = vY + vertexYOffset;
model.vertexPositionsZ[point] = vZ + vertexZOffset;
vX = model.vertexPositionsX[point];
vY = model.vertexPositionsY[point];
vZ = model.vertexPositionsZ[point];
if (modelVertexSkins == 1)
{
model.vertexSkins[point] = var6.readUnsignedByte();
}
}
var2.setOffset(colorPos);
var24.setOffset(renderTypePos);
var3.setOffset(priorityPos);
var28.setOffset(alphaPos);
var6.setOffset(triangleSkinPos);
var55.setOffset(texturePos);
var51.setOffset(textureCoordPos);
for (point = 0; point < triangleCount; ++point)
{
model.faceColors[point] = (short) var2.readUnsignedShort();
if (var13 == 1)
{
model.faceRenderTypes[point] = var24.readByte();
}
if (modelPriority == 255)
{
model.faceRenderPriorities[point] = var3.readByte();
}
if (var50 == 1)
{
model.faceAlphas[point] = var28.readByte();
}
if (var17 == 1)
{
model.faceSkins[point] = var6.readUnsignedByte();
}
if (modelTexture == 1)
{
model.faceTextures[point] = (short) (var55.readUnsignedShort() - 1);
}
if (model.textureCoordinates != null && model.faceTextures[point] != -1)
{
model.textureCoordinates[point] = (byte) (var51.readUnsignedByte() - 1);
}
}
var2.setOffset(var11);
var24.setOffset(var49);
int trianglePointX = 0;
int trianglePointY = 0;
int trianglePointZ = 0;
vertexYOffset = 0;
int var16;
for (vertexZOffset = 0; vertexZOffset < triangleCount; ++vertexZOffset)
{
int numFaces = var24.readUnsignedByte();
if (numFaces == 1)
{
trianglePointX = var2.readShortSmart() + vertexYOffset;
trianglePointY = var2.readShortSmart() + trianglePointX;
trianglePointZ = var2.readShortSmart() + trianglePointY;
vertexYOffset = trianglePointZ;
model.faceVertexIndices1[vertexZOffset] = trianglePointX;
model.faceVertexIndices2[vertexZOffset] = trianglePointY;
model.faceVertexIndices3[vertexZOffset] = trianglePointZ;
}
if (numFaces == 2)
{
trianglePointY = trianglePointZ;
trianglePointZ = var2.readShortSmart() + vertexYOffset;
vertexYOffset = trianglePointZ;
model.faceVertexIndices1[vertexZOffset] = trianglePointX;
model.faceVertexIndices2[vertexZOffset] = trianglePointY;
model.faceVertexIndices3[vertexZOffset] = trianglePointZ;
}
if (numFaces == 3)
{
trianglePointX = trianglePointZ;
trianglePointZ = var2.readShortSmart() + vertexYOffset;
vertexYOffset = trianglePointZ;
model.faceVertexIndices1[vertexZOffset] = trianglePointX;
model.faceVertexIndices2[vertexZOffset] = trianglePointY;
model.faceVertexIndices3[vertexZOffset] = trianglePointZ;
}
if (numFaces == 4)
{
int var57 = trianglePointX;
trianglePointX = trianglePointY;
trianglePointY = var57;
trianglePointZ = var2.readShortSmart() + vertexYOffset;
vertexYOffset = trianglePointZ;
model.faceVertexIndices1[vertexZOffset] = trianglePointX;
model.faceVertexIndices2[vertexZOffset] = var57;
model.faceVertexIndices3[vertexZOffset] = trianglePointZ;
}
}
var2.setOffset(var43);
var24.setOffset(var37);
var3.setOffset(var48);
var28.setOffset(var56);
var6.setOffset(var45);
var55.setOffset(var46);
for (int texIndex = 0; texIndex < textureTriangleCount; ++texIndex)
{
int type = model.textureRenderTypes[texIndex] & 255;
if (type == 0)
{
model.textureTriangleVertexIndices1[texIndex] = (short) var2.readUnsignedShort();
model.textureTriangleVertexIndices2[texIndex] = (short) var2.readUnsignedShort();
model.textureTriangleVertexIndices3[texIndex] = (short) var2.readUnsignedShort();
}
if (type == 1)
{
model.textureTriangleVertexIndices1[texIndex] = (short) var24.readUnsignedShort();
model.textureTriangleVertexIndices2[texIndex] = (short) var24.readUnsignedShort();
model.textureTriangleVertexIndices3[texIndex] = (short) var24.readUnsignedShort();
model.aShortArray2574[texIndex] = (short) var3.readUnsignedShort();
model.aShortArray2575[texIndex] = (short) var3.readUnsignedShort();
model.aShortArray2586[texIndex] = (short) var3.readUnsignedShort();
model.aShortArray2577[texIndex] = (short) var28.readUnsignedShort();
model.aByteArray2580[texIndex] = var6.readByte();
model.aShortArray2578[texIndex] = (short) var55.readUnsignedShort();
}
if (type == 2)
{
model.textureTriangleVertexIndices1[texIndex] = (short) var24.readUnsignedShort();
model.textureTriangleVertexIndices2[texIndex] = (short) var24.readUnsignedShort();
model.textureTriangleVertexIndices3[texIndex] = (short) var24.readUnsignedShort();
model.aShortArray2574[texIndex] = (short) var3.readUnsignedShort();
model.aShortArray2575[texIndex] = (short) var3.readUnsignedShort();
model.aShortArray2586[texIndex] = (short) var3.readUnsignedShort();
model.aShortArray2577[texIndex] = (short) var28.readUnsignedShort();
model.aByteArray2580[texIndex] = var6.readByte();
model.aShortArray2578[texIndex] = (short) var55.readUnsignedShort();
model.texturePrimaryColors[texIndex] = (short) var55.readUnsignedShort();
}
if (type == 3)
{
model.textureTriangleVertexIndices1[texIndex] = (short) var24.readUnsignedShort();
model.textureTriangleVertexIndices2[texIndex] = (short) var24.readUnsignedShort();
model.textureTriangleVertexIndices3[texIndex] = (short) var24.readUnsignedShort();
model.aShortArray2574[texIndex] = (short) var3.readUnsignedShort();
model.aShortArray2575[texIndex] = (short) var3.readUnsignedShort();
model.aShortArray2586[texIndex] = (short) var3.readUnsignedShort();
model.aShortArray2577[texIndex] = (short) var28.readUnsignedShort();
model.aByteArray2580[texIndex] = var6.readByte();
model.aShortArray2578[texIndex] = (short) var55.readUnsignedShort();
}
}
var2.setOffset(position);
vertexZOffset = var2.readUnsignedByte();
if (vertexZOffset != 0)
{
//new Class41();
var2.readUnsignedShort();
var2.readUnsignedShort();
var2.readUnsignedShort();
var2.readInt();
}
}
private void load2(ModelDefinition model, byte[] var1)
{
boolean var2 = false;
boolean var43 = false;
InputStream var5 = new InputStream(var1);
InputStream var39 = new InputStream(var1);
InputStream var26 = new InputStream(var1);
InputStream var9 = new InputStream(var1);
InputStream var3 = new InputStream(var1);
var5.setOffset(var1.length - 18);
int var10 = var5.readUnsignedShort();
int var11 = var5.readUnsignedShort();
int var12 = var5.readUnsignedByte();
int var13 = var5.readUnsignedByte();
int var14 = var5.readUnsignedByte();
int var30 = var5.readUnsignedByte();
int var15 = var5.readUnsignedByte();
int var28 = var5.readUnsignedByte();
int var27 = var5.readUnsignedShort();
int var20 = var5.readUnsignedShort();
int var36 = var5.readUnsignedShort();
int var23 = var5.readUnsignedShort();
byte var16 = 0;
int var46 = var16 + var10;
int var24 = var46;
var46 += var11;
int var25 = var46;
if (var14 == 255)
{
var46 += var11;
}
int var4 = var46;
if (var15 == 1)
{
var46 += var11;
}
int var42 = var46;
if (var13 == 1)
{
var46 += var11;
}
int var37 = var46;
if (var28 == 1)
{
var46 += var10;
}
int var29 = var46;
if (var30 == 1)
{
var46 += var11;
}
int var44 = var46;
var46 += var23;
int var17 = var46;
var46 += var11 * 2;
int var32 = var46;
var46 += var12 * 6;
int var34 = var46;
var46 += var27;
int var35 = var46;
var46 += var20;
int var10000 = var46 + var36;
model.vertexCount = var10;
model.faceCount = var11;
model.textureTriangleCount = var12;
model.vertexPositionsX = new int[var10];
model.vertexPositionsY = new int[var10];
model.vertexPositionsZ = new int[var10];
model.faceVertexIndices1 = new int[var11];
model.faceVertexIndices2 = new int[var11];
model.faceVertexIndices3 = new int[var11];
if (var12 > 0)
{
model.textureRenderTypes = new byte[var12];
model.textureTriangleVertexIndices1 = new short[var12];
model.textureTriangleVertexIndices2 = new short[var12];
model.textureTriangleVertexIndices3 = new short[var12];
}
if (var28 == 1)
{
model.vertexSkins = new int[var10];
}
if (var13 == 1)
{
model.faceRenderTypes = new byte[var11];
model.textureCoordinates = new byte[var11];
model.faceTextures = new short[var11];
}
if (var14 == 255)
{
model.faceRenderPriorities = new byte[var11];
}
else
{
model.priority = (byte) var14;
}
if (var30 == 1)
{
model.faceAlphas = new byte[var11];
}
if (var15 == 1)
{
model.faceSkins = new int[var11];
}
model.faceColors = new short[var11];
var5.setOffset(var16);
var39.setOffset(var34);
var26.setOffset(var35);
var9.setOffset(var46);
var3.setOffset(var37);
int var41 = 0;
int var33 = 0;
int var19 = 0;
int var6;
int var7;
int var8;
int var18;
int var31;
for (var18 = 0; var18 < var10; ++var18)
{
var8 = var5.readUnsignedByte();
var31 = 0;
if ((var8 & 1) != 0)
{
var31 = var39.readShortSmart();
}
var6 = 0;
if ((var8 & 2) != 0)
{
var6 = var26.readShortSmart();
}
var7 = 0;
if ((var8 & 4) != 0)
{
var7 = var9.readShortSmart();
}
model.vertexPositionsX[var18] = var41 + var31;
model.vertexPositionsY[var18] = var33 + var6;
model.vertexPositionsZ[var18] = var19 + var7;
var41 = model.vertexPositionsX[var18];
var33 = model.vertexPositionsY[var18];
var19 = model.vertexPositionsZ[var18];
if (var28 == 1)
{
model.vertexSkins[var18] = var3.readUnsignedByte();
}
}
var5.setOffset(var17);
var39.setOffset(var42);
var26.setOffset(var25);
var9.setOffset(var29);
var3.setOffset(var4);
for (var18 = 0; var18 < var11; ++var18)
{
model.faceColors[var18] = (short) var5.readUnsignedShort();
if (var13 == 1)
{
var8 = var39.readUnsignedByte();
if ((var8 & 1) == 1)
{
model.faceRenderTypes[var18] = 1;
var2 = true;
}
else
{
model.faceRenderTypes[var18] = 0;
}
if ((var8 & 2) == 2)
{
model.textureCoordinates[var18] = (byte) (var8 >> 2);
model.faceTextures[var18] = model.faceColors[var18];
model.faceColors[var18] = 127;
if (model.faceTextures[var18] != -1)
{
var43 = true;
}
}
else
{
model.textureCoordinates[var18] = -1;
model.faceTextures[var18] = -1;
}
}
if (var14 == 255)
{
model.faceRenderPriorities[var18] = var26.readByte();
}
if (var30 == 1)
{
model.faceAlphas[var18] = var9.readByte();
}
if (var15 == 1)
{
model.faceSkins[var18] = var3.readUnsignedByte();
}
}
var5.setOffset(var44);
var39.setOffset(var24);
var18 = 0;
var8 = 0;
var31 = 0;
var6 = 0;
int var21;
int var22;
for (var7 = 0; var7 < var11; ++var7)
{
var22 = var39.readUnsignedByte();
if (var22 == 1)
{
var18 = var5.readShortSmart() + var6;
var8 = var5.readShortSmart() + var18;
var31 = var5.readShortSmart() + var8;
var6 = var31;
model.faceVertexIndices1[var7] = var18;
model.faceVertexIndices2[var7] = var8;
model.faceVertexIndices3[var7] = var31;
}
if (var22 == 2)
{
var8 = var31;
var31 = var5.readShortSmart() + var6;
var6 = var31;
model.faceVertexIndices1[var7] = var18;
model.faceVertexIndices2[var7] = var8;
model.faceVertexIndices3[var7] = var31;
}
if (var22 == 3)
{
var18 = var31;
var31 = var5.readShortSmart() + var6;
var6 = var31;
model.faceVertexIndices1[var7] = var18;
model.faceVertexIndices2[var7] = var8;
model.faceVertexIndices3[var7] = var31;
}
if (var22 == 4)
{
var21 = var18;
var18 = var8;
var8 = var21;
var31 = var5.readShortSmart() + var6;
var6 = var31;
model.faceVertexIndices1[var7] = var18;
model.faceVertexIndices2[var7] = var21;
model.faceVertexIndices3[var7] = var31;
}
}
var5.setOffset(var32);
for (var7 = 0; var7 < var12; ++var7)
{
model.textureRenderTypes[var7] = 0;
model.textureTriangleVertexIndices1[var7] = (short) var5.readUnsignedShort();
model.textureTriangleVertexIndices2[var7] = (short) var5.readUnsignedShort();
model.textureTriangleVertexIndices3[var7] = (short) var5.readUnsignedShort();
}
if (model.textureCoordinates != null)
{
boolean var45 = false;
for (var22 = 0; var22 < var11; ++var22)
{
var21 = model.textureCoordinates[var22] & 255;
if (var21 != 255)
{
if ((model.textureTriangleVertexIndices1[var21] & '\uffff') == model.faceVertexIndices1[var22] && (model.textureTriangleVertexIndices2[var21] & '\uffff') == model.faceVertexIndices2[var22] && (model.textureTriangleVertexIndices3[var21] & '\uffff') == model.faceVertexIndices3[var22])
{
model.textureCoordinates[var22] = -1;
}
else
{
var45 = true;
}
}
}
if (!var45)
{
model.textureCoordinates = null;
}
}
if (!var43)
{
model.faceTextures = null;
}
if (!var2)
{
model.faceRenderTypes = null;
}
}
}

View File

@@ -0,0 +1,287 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import java.util.HashMap;
import net.runelite.cache.definitions.NpcDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NpcLoader
{
private static final Logger logger = LoggerFactory.getLogger(NpcLoader.class);
public NpcDefinition load(int id, byte[] b)
{
NpcDefinition def = new NpcDefinition(id);
InputStream is = new InputStream(b);
while (true)
{
int opcode = is.readUnsignedByte();
if (opcode == 0)
{
break;
}
this.decodeValues(opcode, def, is);
}
return def;
}
private void decodeValues(int opcode, NpcDefinition def, InputStream stream)
{
int length;
int index;
if (opcode == 1)
{
length = stream.readUnsignedByte();
def.models = new int[length];
for (index = 0; index < length; ++index)
{
def.models[index] = stream.readUnsignedShort();
}
}
else if (opcode == 2)
{
def.name = stream.readString();
}
else if (opcode == 12)
{
def.size = stream.readUnsignedByte();
}
else if (opcode == 13)
{
def.standingAnimation = stream.readUnsignedShort();
}
else if (opcode == 14)
{
def.walkingAnimation = stream.readUnsignedShort();
}
else if (opcode == 15)
{
def.rotateLeftAnimation = stream.readUnsignedShort();
}
else if (opcode == 16)
{
def.rotateRightAnimation = stream.readUnsignedShort();
}
else if (opcode == 17)
{
def.walkingAnimation = stream.readUnsignedShort();
def.rotate180Animation = stream.readUnsignedShort();
def.rotate90RightAnimation = stream.readUnsignedShort();
def.rotate90LeftAnimation = stream.readUnsignedShort();
}
else if (opcode >= 30 && opcode < 35)
{
def.actions[opcode - 30] = stream.readString();
if (def.actions[opcode - 30].equalsIgnoreCase("Hidden"))
{
def.actions[opcode - 30] = null;
}
}
else if (opcode == 40)
{
length = stream.readUnsignedByte();
def.recolorToFind = new short[length];
def.recolorToReplace = new short[length];
for (index = 0; index < length; ++index)
{
def.recolorToFind[index] = (short) stream.readUnsignedShort();
def.recolorToReplace[index] = (short) stream.readUnsignedShort();
}
}
else if (opcode == 41)
{
length = stream.readUnsignedByte();
def.retextureToFind = new short[length];
def.retextureToReplace = new short[length];
for (index = 0; index < length; ++index)
{
def.retextureToFind[index] = (short) stream.readUnsignedShort();
def.retextureToReplace[index] = (short) stream.readUnsignedShort();
}
}
else if (opcode == 60)
{
length = stream.readUnsignedByte();
def.chatheadModels = new int[length];
for (index = 0; index < length; ++index)
{
def.chatheadModels[index] = stream.readUnsignedShort();
}
}
else if (opcode == 93)
{
def.isMinimapVisible = false;
}
else if (opcode == 95)
{
def.combatLevel = stream.readUnsignedShort();
}
else if (opcode == 97)
{
def.widthScale = stream.readUnsignedShort();
}
else if (opcode == 98)
{
def.heightScale = stream.readUnsignedShort();
}
else if (opcode == 99)
{
def.hasRenderPriority = true;
}
else if (opcode == 100)
{
def.ambient = stream.readByte();
}
else if (opcode == 101)
{
def.contrast = stream.readByte();
}
else if (opcode == 102)
{
def.headIcon = stream.readUnsignedShort();
}
else if (opcode == 103)
{
def.rotationSpeed = stream.readUnsignedShort();
}
else if (opcode == 106)
{
def.varbitId = stream.readUnsignedShort();
if (def.varbitId == 65535)
{
def.varbitId = -1;
}
def.varpIndex = stream.readUnsignedShort();
if (def.varpIndex == 65535)
{
def.varpIndex = -1;
}
length = stream.readUnsignedByte();
def.configs = new int[length + 2];
for (index = 0; index <= length; ++index)
{
def.configs[index] = stream.readUnsignedShort();
if (def.configs[index] == '\uffff')
{
def.configs[index] = -1;
}
}
def.configs[length + 1] = -1;
}
else if (opcode == 107)
{
def.isInteractable = false;
}
else if (opcode == 109)
{
def.rotationFlag = false;
}
else if (opcode == 111)
{
def.isPet = true;
}
else if (opcode == 118)
{
def.varbitId = stream.readUnsignedShort();
if (def.varbitId == 65535)
{
def.varbitId = -1;
}
def.varpIndex = stream.readUnsignedShort();
if (def.varpIndex == 65535)
{
def.varpIndex = -1;
}
int var = stream.readUnsignedShort();
if (var == 0xFFFF)
{
var = -1;
}
length = stream.readUnsignedByte();
def.configs = new int[length + 2];
for (index = 0; index <= length; ++index)
{
def.configs[index] = stream.readUnsignedShort();
if (def.configs[index] == '\uffff')
{
def.configs[index] = -1;
}
}
def.configs[length + 1] = var;
}
else if (opcode == 249)
{
length = stream.readUnsignedByte();
def.params = new HashMap<>(length);
for (int i = 0; i < length; i++)
{
boolean isString = stream.readUnsignedByte() == 1;
int key = stream.read24BitInt();
Object value;
if (isString)
{
value = stream.readString();
}
else
{
value = stream.readInt();
}
def.params.put(key, value);
}
}
else
{
logger.warn("Unrecognized opcode {}", opcode);
}
}
}

View File

@@ -0,0 +1,405 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import java.util.HashMap;
import java.util.Map;
import net.runelite.cache.definitions.ObjectDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ObjectLoader
{
private static final Logger logger = LoggerFactory.getLogger(ObjectLoader.class);
public ObjectDefinition load(int id, byte[] b)
{
ObjectDefinition def = new ObjectDefinition();
InputStream is = new InputStream(b);
def.setId(id);
for (;;)
{
int opcode = is.readUnsignedByte();
if (opcode == 0)
{
break;
}
processOp(opcode, def, is);
}
post(def);
return def;
}
private void processOp(int opcode, ObjectDefinition def, InputStream is)
{
if (opcode == 1)
{
int length = is.readUnsignedByte();
if (length > 0)
{
int[] objectTypes = new int[length];
int[] objectModels = new int[length];
for (int index = 0; index < length; ++index)
{
objectModels[index] = is.readUnsignedShort();
objectTypes[index] = is.readUnsignedByte();
}
def.setObjectTypes(objectTypes);
def.setObjectModels(objectModels);
}
}
else if (opcode == 2)
{
def.setName(is.readString());
}
else if (opcode == 5)
{
int length = is.readUnsignedByte();
if (length > 0)
{
def.setObjectTypes(null);
int[] objectModels = new int[length];
for (int index = 0; index < length; ++index)
{
objectModels[index] = is.readUnsignedShort();
}
def.setObjectModels(objectModels);
}
}
else if (opcode == 14)
{
def.setSizeX(is.readUnsignedByte());
}
else if (opcode == 15)
{
def.setSizeY(is.readUnsignedByte());
}
else if (opcode == 17)
{
def.setInteractType(0);
def.setBlocksProjectile(false);
}
else if (opcode == 18)
{
def.setBlocksProjectile(false);
}
else if (opcode == 19)
{
def.setWallOrDoor(is.readUnsignedByte());
}
else if (opcode == 21)
{
def.setContouredGround(0);
}
else if (opcode == 22)
{
def.setMergeNormals(true);
}
else if (opcode == 23)
{
def.setABool2111(true);
}
else if (opcode == 24)
{
def.setAnimationID(is.readUnsignedShort());
if (def.getAnimationID() == 0xFFFF)
{
def.setAnimationID(-1);
}
}
else if (opcode == 27)
{
def.setInteractType(1);
}
else if (opcode == 28)
{
def.setDecorDisplacement(is.readUnsignedByte());
}
else if (opcode == 29)
{
def.setAmbient(is.readByte());
}
else if (opcode == 39)
{
def.setContrast(is.readByte() * 25);
}
else if (opcode >= 30 && opcode < 35)
{
String[] actions = def.getActions();
actions[opcode - 30] = is.readString();
if (actions[opcode - 30].equalsIgnoreCase("Hidden"))
{
actions[opcode - 30] = null;
}
}
else if (opcode == 40)
{
int length = is.readUnsignedByte();
short[] recolorToFind = new short[length];
short[] recolorToReplace = new short[length];
for (int index = 0; index < length; ++index)
{
recolorToFind[index] = is.readShort();
recolorToReplace[index] = is.readShort();
}
def.setRecolorToFind(recolorToFind);
def.setRecolorToReplace(recolorToReplace);
}
else if (opcode == 41)
{
int length = is.readUnsignedByte();
short[] retextureToFind = new short[length];
short[] textureToReplace = new short[length];
for (int index = 0; index < length; ++index)
{
retextureToFind[index] = is.readShort();
textureToReplace[index] = is.readShort();
}
def.setRetextureToFind(retextureToFind);
def.setTextureToReplace(textureToReplace);
}
else if (opcode == 62)
{
def.setRotated(true);
}
else if (opcode == 64)
{
def.setShadow(false);
}
else if (opcode == 65)
{
def.setModelSizeX(is.readUnsignedShort());
}
else if (opcode == 66)
{
def.setModelSizeHeight(is.readUnsignedShort());
}
else if (opcode == 67)
{
def.setModelSizeY(is.readUnsignedShort());
}
else if (opcode == 68)
{
def.setMapSceneID(is.readUnsignedShort());
}
else if (opcode == 69)
{
is.readByte();
}
else if (opcode == 70)
{
def.setOffsetX(is.readUnsignedShort());
}
else if (opcode == 71)
{
def.setOffsetHeight(is.readUnsignedShort());
}
else if (opcode == 72)
{
def.setOffsetY(is.readUnsignedShort());
}
else if (opcode == 73)
{
def.setObstructsGround(true);
}
else if (opcode == 74)
{
def.setHollow(true);
}
else if (opcode == 75)
{
def.setSupportsItems(is.readUnsignedByte());
}
else if (opcode == 77)
{
int varpID = is.readUnsignedShort();
if (varpID == 0xFFFF)
{
varpID = -1;
}
def.setVarbitID(varpID);
int configId = is.readUnsignedShort();
if (configId == 0xFFFF)
{
configId = -1;
}
def.setVarpID(configId);
int length = is.readUnsignedByte();
int[] configChangeDest = new int[length + 2];
for (int index = 0; index <= length; ++index)
{
configChangeDest[index] = is.readUnsignedShort();
if (0xFFFF == configChangeDest[index])
{
configChangeDest[index] = -1;
}
}
configChangeDest[length + 1] = -1;
def.setConfigChangeDest(configChangeDest);
}
else if (opcode == 78)
{
def.setAmbientSoundId(is.readUnsignedShort());
def.setAnInt2083(is.readUnsignedByte());
}
else if (opcode == 79)
{
def.setAnInt2112(is.readUnsignedShort());
def.setAnInt2113(is.readUnsignedShort());
def.setAnInt2083(is.readUnsignedByte());
int length = is.readUnsignedByte();
int[] anIntArray2084 = new int[length];
for (int index = 0; index < length; ++index)
{
anIntArray2084[index] = is.readUnsignedShort();
}
def.setAnIntArray2084(anIntArray2084);
}
else if (opcode == 81)
{
def.setContouredGround(is.readUnsignedByte() * 256);
}
else if (opcode == 82)
{
def.setMapAreaId(is.readUnsignedShort());
}
else if (opcode == 92)
{
int varpID = is.readUnsignedShort();
if (varpID == 0xFFFF)
{
varpID = -1;
}
def.setVarbitID(varpID);
int configId = is.readUnsignedShort();
if (configId == 0xFFFF)
{
configId = -1;
}
def.setVarpID(configId);
int var = is.readUnsignedShort();
if (var == 0xFFFF)
{
var = -1;
}
int length = is.readUnsignedByte();
int[] configChangeDest = new int[length + 2];
for (int index = 0; index <= length; ++index)
{
configChangeDest[index] = is.readUnsignedShort();
if (0xFFFF == configChangeDest[index])
{
configChangeDest[index] = -1;
}
}
configChangeDest[length + 1] = var;
def.setConfigChangeDest(configChangeDest);
}
else if (opcode == 249)
{
int length = is.readUnsignedByte();
Map<Integer, Object> params = new HashMap<>(length);
for (int i = 0; i < length; i++)
{
boolean isString = is.readUnsignedByte() == 1;
int key = is.read24BitInt();
Object value;
if (isString)
{
value = is.readString();
}
else
{
value = is.readInt();
}
params.put(key, value);
}
def.setParams(params);
}
else
{
logger.warn("Unrecognized opcode {}", opcode);
}
}
private void post(ObjectDefinition def)
{
if (def.getWallOrDoor() == -1)
{
def.setWallOrDoor(0);
if (def.getObjectModels() != null && (def.getObjectTypes() == null || def.getObjectTypes()[0] == 10))
{
def.setWallOrDoor(1);
}
for (int var1 = 0; var1 < 5; ++var1)
{
if (def.getActions()[var1] != null)
{
def.setWallOrDoor(1);
}
}
}
if (def.getSupportsItems() == -1)
{
def.setSupportsItems(def.getInteractType() != 0 ? 1 : 0);
}
}
}

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.OverlayDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OverlayLoader
{
private static final Logger logger = LoggerFactory.getLogger(OverlayLoader.class);
public OverlayDefinition load(int id, byte[] b)
{
OverlayDefinition def = new OverlayDefinition();
InputStream is = new InputStream(b);
def.setId(id);
for (;;)
{
int opcode = is.readUnsignedByte();
if (opcode == 0)
{
break;
}
if (opcode == 1)
{
int color = is.read24BitInt();
def.setRgbColor(color);
}
else if (opcode == 2)
{
int texture = is.readUnsignedByte();
def.setTexture(texture);
}
else if (opcode == 5)
{
def.setHideUnderlay(false);
}
else if (opcode == 7)
{
int secondaryColor = is.read24BitInt();
def.setSecondaryRgbColor(secondaryColor);
}
}
def.calculateHsl();
return def;
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2020, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import net.runelite.cache.definitions.ParamDefinition;
import net.runelite.cache.io.InputStream;
import net.runelite.cache.util.ScriptVarType;
public class ParamLoader
{
public ParamDefinition load(byte[] data)
{
ParamDefinition def = new ParamDefinition();
InputStream b = new InputStream(data);
for (; ; )
{
int opcode = b.readUnsignedByte();
switch (opcode)
{
case 0:
return def;
case 1:
{
int idx = b.readByte();
def.setType(ScriptVarType.forCharKey((char) idx));
break;
}
case 2:
def.setDefaultInt(b.readInt());
break;
case 4:
def.setMembers(false);
break;
case 5:
def.setDefaultString(b.readString());
break;
}
}
}
}

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