Revert to old layout for refactor

This commit is contained in:
zeruth
2019-06-07 23:54:32 -04:00
parent 74a0bf004e
commit eafb024f16
3552 changed files with 105486 additions and 145251 deletions

168
cache/pom.xml vendored Normal file
View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.runelite</groupId>
<artifactId>runelite-parent</artifactId>
<version>1.5.27-SNAPSHOT</version>
</parent>
<artifactId>cache</artifactId>
<name>Cache</name>
<properties>
<commons.cli.version>1.3.1</commons.cli.version>
<commons.compress.version>1.10</commons.compress.version>
<antlr4.version>4.6</antlr4.version>
<cache.version>165</cache.version>
</properties>
<dependencies>
<dependency>
<groupId>net.runelite</groupId>
<artifactId>http-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>${commons.compress.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr4.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>${commons.cli.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>net.runelite.rs</groupId>
<artifactId>cache</artifactId>
<version>${cache.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<enableAssertions>true</enableAssertions>
<argLine>-Xmx2048m</argLine>
<systemProperties>
<cache.tmpdir>${cache.tmpdir}</cache.tmpdir>
</systemProperties>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr4.version}</version>
<executions>
<execution>
<id>process-resources</id>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

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

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 anInt2069 = 16;
private boolean isSolid = 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 nonFlatShading = false;
private int anInt2088 = -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 aBool2097 = 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 aBool2104 = false;
private int anInt2105 = -1;
private int anInt2106 = -1;
private int[] configChangeDest;
private boolean isRotated = false;
private int varpID = -1;
private int anInt2110 = -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,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,30 @@
/*
* 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,289 @@
/*
* 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.ItemDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
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,289 @@
/*
* 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.NpcDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
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.tileSpacesOccupied = stream.readUnsignedByte();
}
else if (opcode == 13)
{
def.stanceAnimation = stream.readUnsignedShort();
}
else if (opcode == 14)
{
def.walkAnimation = stream.readUnsignedShort();
}
else if (opcode == 15)
{
def.anInt2165 = stream.readUnsignedShort();
}
else if (opcode == 16)
{
def.anInt2189 = stream.readUnsignedShort();
}
else if (opcode == 17)
{
def.walkAnimation = stream.readUnsignedShort();
def.rotate180Animation = stream.readUnsignedShort();
def.rotate90RightAnimation = stream.readUnsignedShort();
def.rotate90LeftAnimation = 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 == 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.models_2 = new int[length];
for (index = 0; index < length; ++index)
{
def.models_2[index] = stream.readUnsignedShort();
}
}
else if (opcode == 93)
{
def.renderOnMinimap = false;
}
else if (opcode == 95)
{
def.combatLevel = stream.readUnsignedShort();
}
else if (opcode == 97)
{
def.resizeX = stream.readUnsignedShort();
}
else if (opcode == 98)
{
def.resizeY = 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.rotation = stream.readUnsignedShort();
}
else if (opcode == 106)
{
def.varbitIndex = stream.readUnsignedShort();
if ('\uffff' == def.varbitIndex)
{
def.varbitIndex = -1;
}
def.varpIndex = stream.readUnsignedShort();
if ('\uffff' == def.varpIndex)
{
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.isClickable = false;
}
else if (opcode == 109)
{
def.aBool2170 = false;
}
else if (opcode == 111)
{
def.aBool2190 = true;
}
else if (opcode == 118)
{
def.varbitIndex = stream.readUnsignedShort();
if ('\uffff' == def.varbitIndex)
{
def.varbitIndex = -1;
}
def.varpIndex = stream.readUnsignedShort();
if ('\uffff' == def.varpIndex)
{
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.setAnInt2088(is.readUnsignedByte());
}
else if (opcode == 21)
{
def.setAnInt2105(0);
}
else if (opcode == 22)
{
def.setNonFlatShading(false);
}
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.setAnInt2069(is.readUnsignedByte());
}
else if (opcode == 29)
{
def.setAmbient(is.readByte());
}
else if (opcode == 39)
{
def.setContrast(is.readByte());
}
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.setABool2097(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.setABool2104(true);
}
else if (opcode == 74)
{
def.setSolid(true);
}
else if (opcode == 75)
{
def.setAnInt2106(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.setAnInt2110(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.setAnInt2105(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.getAnInt2088() == -1)
{
def.setAnInt2088(0);
if (def.getObjectModels() != null && (def.getObjectTypes() == null || def.getObjectTypes()[0] == 10))
{
def.setAnInt2088(1);
}
for (int var1 = 0; var1 < 5; ++var1)
{
if (def.getActions()[var1] != null)
{
def.setAnInt2088(1);
}
}
}
if (def.getAnInt2106() == -1)
{
def.setAnInt2106(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,113 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders;
import java.util.HashMap;
import java.util.Map;
import net.runelite.cache.definitions.ScriptDefinition;
import net.runelite.cache.io.InputStream;
import static net.runelite.cache.script.Opcodes.SCONST;
import static net.runelite.cache.script.Opcodes.POP_INT;
import static net.runelite.cache.script.Opcodes.POP_STRING;
import static net.runelite.cache.script.Opcodes.RETURN;
public class ScriptLoader
{
public ScriptDefinition load(int id, byte[] b)
{
ScriptDefinition def = new ScriptDefinition();
def.setId(id);
InputStream in = new InputStream(b);
in.setOffset(in.getLength() - 2);
int switchLength = in.readUnsignedShort();
// 2 for switchLength + the switch data + 12 for the param/vars/stack data
int endIdx = in.getLength() - 2 - switchLength - 12;
in.setOffset(endIdx);
int numOpcodes = in.readInt();
int localIntCount = in.readUnsignedShort();
int localStringCount = in.readUnsignedShort();
int intStackCount = in.readUnsignedShort();
int stringStackCount = in.readUnsignedShort();
int numSwitches = in.readUnsignedByte();
if (numSwitches > 0)
{
Map<Integer, Integer>[] switches = new Map[numSwitches];
def.setSwitches(switches);
for (int i = 0; i < numSwitches; ++i)
{
switches[i] = new HashMap<>();
int count = in.readUnsignedShort();
while (count-- > 0)
{
int key = in.readInt(); // int from stack is compared to this
int pcOffset = in.readInt(); // pc jumps by this
switches[i].put(key, pcOffset);
}
}
}
def.setLocalIntCount(localIntCount);
def.setLocalStringCount(localStringCount);
def.setIntStackCount(intStackCount);
def.setStringStackCount(stringStackCount);
in.setOffset(0);
in.readStringOrNull();
int[] instructions = new int[numOpcodes];
int[] intOperands = new int[numOpcodes];
String[] stringOperands = new String[numOpcodes];
def.setInstructions(instructions);
def.setIntOperands(intOperands);
def.setStringOperands(stringOperands);
int opcode;
for (int i = 0; in.getOffset() < endIdx; instructions[i++] = opcode)
{
opcode = in.readUnsignedShort();
if (opcode == SCONST)
{
stringOperands[i] = in.readString();
}
else if (opcode < 100 && opcode != RETURN && opcode != POP_INT && opcode != POP_STRING)
{
intOperands[i] = in.readInt();
}
else
{
intOperands[i] = in.readUnsignedByte();
}
}
return def;
}
}

View File

@@ -0,0 +1,156 @@
/*
* 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.SequenceDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SequenceLoader
{
private static final Logger logger = LoggerFactory.getLogger(SequenceLoader.class);
public SequenceDefinition load(int id, byte[] b)
{
SequenceDefinition def = new SequenceDefinition(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, SequenceDefinition def, InputStream stream)
{
int var3;
int var4;
if (opcode == 1)
{
var3 = stream.readUnsignedShort();
def.frameLenghts = new int[var3];
for (var4 = 0; var4 < var3; ++var4)
{
def.frameLenghts[var4] = stream.readUnsignedShort();
}
def.frameIDs = new int[var3];
for (var4 = 0; var4 < var3; ++var4)
{
def.frameIDs[var4] = stream.readUnsignedShort();
}
for (var4 = 0; var4 < var3; ++var4)
{
def.frameIDs[var4] += stream.readUnsignedShort() << 16;
}
}
else if (opcode == 2)
{
def.frameStep = stream.readUnsignedShort();
}
else if (opcode == 3)
{
var3 = stream.readUnsignedByte();
def.interleaveLeave = new int[1 + var3];
for (var4 = 0; var4 < var3; ++var4)
{
def.interleaveLeave[var4] = stream.readUnsignedByte();
}
def.interleaveLeave[var3] = 9999999;
}
else if (opcode == 4)
{
def.stretches = true;
}
else if (opcode == 5)
{
def.forcedPriority = stream.readUnsignedByte();
}
else if (opcode == 6)
{
def.leftHandItem = stream.readUnsignedShort();
}
else if (opcode == 7)
{
def.rightHandItem = stream.readUnsignedShort();
}
else if (opcode == 8)
{
def.maxLoops = stream.readUnsignedByte();
}
else if (opcode == 9)
{
def.precedenceAnimating = stream.readUnsignedByte();
}
else if (opcode == 10)
{
def.priority = stream.readUnsignedByte();
}
else if (opcode == 11)
{
def.replyMode = stream.readUnsignedByte();
}
else if (opcode == 12)
{
var3 = stream.readUnsignedByte();
def.field3048 = new int[var3];
for (var4 = 0; var4 < var3; ++var4)
{
def.field3048[var4] = stream.readUnsignedShort();
}
for (var4 = 0; var4 < var3; ++var4)
{
def.field3048[var4] += stream.readUnsignedShort() << 16;
}
}
else if (opcode == 13)
{
var3 = stream.readUnsignedByte();
def.field3056 = new int[var3];
for (var4 = 0; var4 < var3; ++var4)
{
def.field3056[var4] = stream.read24BitInt();
}
}
}
}

View File

@@ -0,0 +1,111 @@
/*
* 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.SpotAnimDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SpotAnimLoader
{
private static final Logger logger = LoggerFactory.getLogger(SpotAnimLoader.class);
public SpotAnimDefinition load(int id, byte[] b)
{
SpotAnimDefinition def = new SpotAnimDefinition();
InputStream is = new InputStream(b);
def.id = id;
while (true)
{
int opcode = is.readUnsignedByte();
if (opcode == 0)
{
break;
}
this.decodeValues(opcode, def, is);
}
return def;
}
private void decodeValues(int opcode, SpotAnimDefinition def, InputStream stream)
{
if (opcode == 1)
{
def.modelId = stream.readUnsignedShort();
}
else if (opcode == 2)
{
def.animationId = stream.readUnsignedShort();
}
else if (opcode == 4)
{
def.resizeX = stream.readUnsignedShort();
}
else if (opcode == 5)
{
def.resizeY = stream.readUnsignedShort();
}
else if (opcode == 6)
{
def.rotaton = stream.readUnsignedShort();
}
else if (opcode == 7)
{
def.ambient = stream.readUnsignedByte();
}
else if (opcode == 8)
{
def.contrast = stream.readUnsignedByte();
}
else if (opcode == 40)
{
int var3 = stream.readUnsignedByte();
def.recolorToFind = new short[var3];
def.recolorToReplace = new short[var3];
for (int var4 = 0; var4 < var3; ++var4)
{
def.recolorToFind[var4] = (short) stream.readUnsignedShort();
def.recolorToReplace[var4] = (short) stream.readUnsignedShort();
}
}
else if (opcode == 41)
{
int var3 = stream.readUnsignedByte();
def.textureToFind = new short[var3];
def.textureToReplace = new short[var3];
for (int var4 = 0; var4 < var3; ++var4)
{
def.textureToFind[var4] = (short) stream.readUnsignedShort();
def.textureToReplace[var4] = (short) stream.readUnsignedShort();
}
}
}
}

View File

@@ -0,0 +1,183 @@
/*
* 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.SpriteDefinition;
import net.runelite.cache.io.InputStream;
public class SpriteLoader
{
public static final int FLAG_VERTICAL = 0b01;
public static final int FLAG_ALPHA = 0b10;
public SpriteDefinition[] load(int id, byte[] b)
{
InputStream is = new InputStream(b);
is.setOffset(is.getLength() - 2);
int spriteCount = is.readUnsignedShort();
SpriteDefinition[] sprites = new SpriteDefinition[spriteCount];
// 2 for size
// 5 for width, height, palette length
// + 8 bytes per sprite for offset x/y, width, and height
is.setOffset(is.getLength() - 7 - spriteCount * 8);
// max width and height
int width = is.readUnsignedShort();
int height = is.readUnsignedShort();
int paletteLength = is.readUnsignedByte() + 1;
for (int i = 0; i < spriteCount; ++i)
{
sprites[i] = new SpriteDefinition();
sprites[i].setId(id);
sprites[i].setFrame(i);
sprites[i].setMaxWidth(width);
sprites[i].setMaxHeight(height);
}
for (int i = 0; i < spriteCount; ++i)
{
sprites[i].setOffsetX(is.readUnsignedShort());
}
for (int i = 0; i < spriteCount; ++i)
{
sprites[i].setOffsetY(is.readUnsignedShort());
}
for (int i = 0; i < spriteCount; ++i)
{
sprites[i].setWidth(is.readUnsignedShort());
}
for (int i = 0; i < spriteCount; ++i)
{
sprites[i].setHeight(is.readUnsignedShort());
}
// same as above + 3 bytes for each palette entry, except for the first one (which is transparent)
is.setOffset(is.getLength() - 7 - spriteCount * 8 - (paletteLength - 1) * 3);
int[] palette = new int[paletteLength];
for (int i = 1; i < paletteLength; ++i)
{
palette[i] = is.read24BitInt();
if (palette[i] == 0)
{
palette[i] = 1;
}
}
is.setOffset(0);
for (int i = 0; i < spriteCount; ++i)
{
SpriteDefinition def = sprites[i];
int spriteWidth = def.getWidth();
int spriteHeight = def.getHeight();
int dimension = spriteWidth * spriteHeight;
byte[] pixelPaletteIndicies = new byte[dimension];
byte[] pixelAlphas = new byte[dimension];
def.pixelIdx = pixelPaletteIndicies;
def.palette = palette;
int flags = is.readUnsignedByte();
if ((flags & FLAG_VERTICAL) == 0)
{
// read horizontally
for (int j = 0; j < dimension; ++j)
{
pixelPaletteIndicies[j] = is.readByte();
}
}
else
{
// read vertically
for (int j = 0; j < spriteWidth; ++j)
{
for (int k = 0; k < spriteHeight; ++k)
{
pixelPaletteIndicies[spriteWidth * k + j] = is.readByte();
}
}
}
// read alphas
if ((flags & FLAG_ALPHA) != 0)
{
if ((flags & FLAG_VERTICAL) == 0)
{
// read horizontally
for (int j = 0; j < dimension; ++j)
{
pixelAlphas[j] = is.readByte();
}
}
else
{
// read vertically
for (int j = 0; j < spriteWidth; ++j)
{
for (int k = 0; k < spriteHeight; ++k)
{
pixelAlphas[spriteWidth * k + j] = is.readByte();
}
}
}
}
else
{
// everything non-zero is opaque
for (int j = 0; j < dimension; ++j)
{
int index = pixelPaletteIndicies[j];
if (index != 0)
pixelAlphas[j] = (byte) 0xFF;
}
}
int[] pixels = new int[dimension];
// build argb pixels from palette/alphas
for (int j = 0; j < dimension; ++j)
{
int index = pixelPaletteIndicies[j] & 0xFF;
pixels[j] = palette[index] | (pixelAlphas[j] << 24);
}
def.setPixels(pixels);
}
return sprites;
}
}

View File

@@ -0,0 +1,80 @@
/*
* 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.loaders;
import java.util.HashMap;
import net.runelite.cache.definitions.StructDefinition;
import net.runelite.cache.io.InputStream;
public class StructLoader
{
public StructDefinition load(int id, byte[] b)
{
StructDefinition def = new StructDefinition(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, StructDefinition def, InputStream stream)
{
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);
}
}
}
}

View File

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

View File

@@ -0,0 +1,506 @@
/*
* 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.TrackDefinition;
import net.runelite.cache.io.InputStream;
import net.runelite.cache.io.OutputStream;
public class TrackLoader
{
// Headers
private static final int MTHD_MAGIC = 1297377380;
private static final int MTRK_MAGIC = 1297379947;
// Major MIDI Messages. Bottom 4 bits are the channel.
private static final int NOTE_ON = 0b1001_0000;
private static final int NOTE_OFF = 0b1000_0000;
private static final int CONTROL_CHANGE = 0b1011_0000;
private static final int PITCH_WHEEL_CHANGE = 0b1110_0000;
private static final int CHANNEL_PRESSURE = 0b1101_0000;
private static final int POLYPHONIC_KEY_PRESSURE = 0b1010_0000;
private static final int PROGRAM_CHANGE = 0b1100_0000;
// Meta Events
private static final int META = 255;
private static final int END_OF_TRACK = 47;
private static final int TEMPO = 81;
// Controller messages
private static final int CONTROLLER_BANK_SELECT = 0;
private static final int CONTROLLER_MODULATION_WHEEL = 1;
private static final int CONTROLLER_CHANNEL_VOLUME = 7;
private static final int CONTROLLER_PAN = 10;
private static final int CONTROLLER_BANK_SELECT_2 = 32;
private static final int CONTROLLER_MODULATION_WHEEL2 = 33;
private static final int CONTROLLER_CHANNEL_VOLUME_2 = 39;
private static final int CONTROLLER_PAN_2 = 42;
private static final int CONTROLLER_DAMPER_PEDAL = 64;
private static final int CONTROLLER_PORTAMENTO = 65;
private static final int CONTROLLER_NON_REGISTERED_PARAMETER_NUMBER_LSB = 98;
private static final int CONTROLLER_NON_REGISTERED_PARAMETER_NUMBER_MSB = 99;
private static final int CONTROLLER_REGISTERED_PARAMETER_NUMBER_LSB = 100;
private static final int CONTROLLER_REGISTERED_PARAMETER_NUMBER_MSB = 101;
private static final int CONTROLLER_ALL_SOUND_OFF = 120;
private static final int CONTROLLER_RESET_ALL_CONTROLLERS = 121;
private static final int CONTROLLER_ALL_NOTES_OFF = 123;
private static final int JAG_NOTE_ON = 0;
private static final int JAG_NOTE_OFF = 1;
private static final int JAG_CONTROL_CHANGE = 2;
private static final int JAG_PITCH_BEND = 3;
private static final int JAG_CHANNEL_PRESSURE = 4;
private static final int JAG_POLY_PRESSURE = 5;
private static final int JAG_PROGRAM_CHANGE = 6;
private static final int JAG_END_OF_TRACK = 7;
private static final int JAG_TEMPO = 23;
public TrackDefinition load(byte[] b)
{
TrackDefinition def = new TrackDefinition();
load(def, new InputStream(b));
return def;
}
private void load(TrackDefinition def, InputStream var1)
{
// Some of the names are from https://www.rune-server.ee/runescape-development/rs-503-client-server/snippets/311669-rs-music-file-structure-conversion.html
var1.setOffset(var1.getLength() - 3);
int tracks = var1.readUnsignedByte();
int division = var1.readUnsignedShort();
int offset = 14 + tracks * 10;
var1.setOffset(0);
int tempoOpcodes = 0;
int ctrlChangeOpcodes = 0;
int noteOnOpcodes = 0;
int noteOffOpcodes = 0;
int wheelChangeOpcodes = 0;
int chnnlAfterTchOpcodes = 0;
int keyAfterTchOpcodes = 0;
int progmChangeOpcodes = 0;
int var13;
int opcode;
int controlChangeIndex;
for (var13 = 0; var13 < tracks; ++var13)
{
opcode = -1;
while (true)
{
controlChangeIndex = var1.readUnsignedByte();
if (controlChangeIndex != opcode)
{
++offset;
}
opcode = controlChangeIndex & 15;
if (controlChangeIndex == JAG_END_OF_TRACK)
{
break;
}
if (controlChangeIndex == JAG_TEMPO)
{
++tempoOpcodes;
}
else if (opcode == JAG_NOTE_ON)
{
++noteOnOpcodes;
}
else if (opcode == JAG_NOTE_OFF)
{
++noteOffOpcodes;
}
else if (opcode == JAG_CONTROL_CHANGE)
{
++ctrlChangeOpcodes;
}
else if (opcode == JAG_PITCH_BEND)
{
++wheelChangeOpcodes;
}
else if (opcode == JAG_CHANNEL_PRESSURE)
{
++chnnlAfterTchOpcodes;
}
else if (opcode == JAG_POLY_PRESSURE)
{
++keyAfterTchOpcodes;
}
else if (opcode == JAG_PROGRAM_CHANGE)
{
++progmChangeOpcodes;
}
else
{
throw new RuntimeException();
}
}
}
offset += 5 * tempoOpcodes;
offset += 2 * (noteOnOpcodes + noteOffOpcodes + ctrlChangeOpcodes + wheelChangeOpcodes + keyAfterTchOpcodes);
offset += chnnlAfterTchOpcodes + progmChangeOpcodes;
var13 = var1.getOffset();
opcode = tracks + tempoOpcodes + ctrlChangeOpcodes + noteOnOpcodes + noteOffOpcodes + wheelChangeOpcodes + chnnlAfterTchOpcodes + keyAfterTchOpcodes + progmChangeOpcodes;
for (controlChangeIndex = 0; controlChangeIndex < opcode; ++controlChangeIndex)
{
var1.readVarInt();
}
offset += var1.getOffset() - var13;
controlChangeIndex = var1.getOffset();
int modulationWheelSize = 0;
int modulationWheel2Size = 0;
int channelVolumeSize = 0;
int channelVolume2Size = 0;
int panSize = 0;
int pan2Size = 0;
int nonRegisteredMsbSize = 0;
int nonRegisteredLsbSize = 0;
int registeredNumberMsb = 0;
int registeredLsbSize = 0;
int commandsSize = 0;
int otherSize = 0;
int controllerNumber = 0;
int var29;
for (var29 = 0; var29 < ctrlChangeOpcodes; ++var29)
{
controllerNumber = controllerNumber + var1.readUnsignedByte() & 127;
if (controllerNumber == CONTROLLER_BANK_SELECT || controllerNumber == CONTROLLER_BANK_SELECT_2)
{
++progmChangeOpcodes;
}
else if (controllerNumber == CONTROLLER_MODULATION_WHEEL)
{
++modulationWheelSize;
}
else if (controllerNumber == CONTROLLER_MODULATION_WHEEL2)
{
++modulationWheel2Size;
}
else if (controllerNumber == CONTROLLER_CHANNEL_VOLUME)
{
++channelVolumeSize;
}
else if (controllerNumber == CONTROLLER_CHANNEL_VOLUME_2)
{
++channelVolume2Size;
}
else if (controllerNumber == CONTROLLER_PAN)
{
++panSize;
}
else if (controllerNumber == CONTROLLER_PAN_2)
{
++pan2Size;
}
else if (controllerNumber == CONTROLLER_NON_REGISTERED_PARAMETER_NUMBER_MSB)
{
++nonRegisteredMsbSize;
}
else if (controllerNumber == CONTROLLER_NON_REGISTERED_PARAMETER_NUMBER_LSB)
{
++nonRegisteredLsbSize;
}
else if (controllerNumber == CONTROLLER_REGISTERED_PARAMETER_NUMBER_MSB)
{
++registeredNumberMsb;
}
else if (controllerNumber == CONTROLLER_REGISTERED_PARAMETER_NUMBER_LSB)
{
++registeredLsbSize;
}
else if (controllerNumber != CONTROLLER_DAMPER_PEDAL
&& controllerNumber != CONTROLLER_PORTAMENTO
&& controllerNumber != CONTROLLER_ALL_SOUND_OFF
&& controllerNumber != CONTROLLER_RESET_ALL_CONTROLLERS
&& controllerNumber != CONTROLLER_ALL_NOTES_OFF)
{
++otherSize;
}
else
{
++commandsSize;
}
}
var29 = 0;
int commandsIndex = var1.getOffset();
var1.skip(commandsSize);
int polyPressureIndex = var1.getOffset();
var1.skip(keyAfterTchOpcodes);
int channelPressureIndex = var1.getOffset();
var1.skip(chnnlAfterTchOpcodes);
int pitchWheelHighIndex = var1.getOffset();
var1.skip(wheelChangeOpcodes);
int modulationWheelOffset = var1.getOffset();
var1.skip(modulationWheelSize);
int channelVolumeOffset = var1.getOffset();
var1.skip(channelVolumeSize);
int panOffset = var1.getOffset();
var1.skip(panSize);
int notesIndex = var1.getOffset();
var1.skip(noteOnOpcodes + noteOffOpcodes + keyAfterTchOpcodes);
int notesOnIndex = var1.getOffset();
var1.skip(noteOnOpcodes);
int otherIndex = var1.getOffset();
var1.skip(otherSize);
int notesOffIndex = var1.getOffset();
var1.skip(noteOffOpcodes);
int modulationWheel2Offset = var1.getOffset();
var1.skip(modulationWheel2Size);
int channelVolume2Offset = var1.getOffset();
var1.skip(channelVolume2Size);
int pan2Offset = var1.getOffset();
var1.skip(pan2Size);
int programChangeIndex = var1.getOffset();
var1.skip(progmChangeOpcodes);
int pitchWheelLowIndex = var1.getOffset();
var1.skip(wheelChangeOpcodes);
int nonRegisteredMsbIndex = var1.getOffset();
var1.skip(nonRegisteredMsbSize);
int nonRegisteredLsbIndex = var1.getOffset();
var1.skip(nonRegisteredLsbSize);
int registeredMsbIndex = var1.getOffset();
var1.skip(registeredNumberMsb);
int registeredLsbIndex = var1.getOffset();
var1.skip(registeredLsbSize);
int tempoOffset = var1.getOffset();
var1.skip(tempoOpcodes * 3);
OutputStream var51 = new OutputStream(offset);
var51.writeInt(MTHD_MAGIC); // MThd header
var51.writeInt(6); // length of header
var51.writeShort(tracks > 1 ? 1 : 0); // format
var51.writeShort(tracks); // tracks
var51.writeShort(division); // division
var1.setOffset(var13);
int channel = 0;
int var53 = 0;
int var54 = 0;
int var55 = 0;
int var56 = 0;
int var57 = 0;
int var58 = 0;
int[] var59 = new int[128];
controllerNumber = 0;
label361:
for (int var60 = 0; var60 < tracks; ++var60)
{
var51.writeInt(MTRK_MAGIC); // MTrk
var51.skip(4); // length gets written here later
int var61 = var51.getOffset();
int var62 = -1;
while (true)
{
int deltaTick = var1.readVarInt();
var51.writeVarInt(deltaTick); // delta time
int status = var1.getArray()[var29++] & 255;
boolean var65 = status != var62;
var62 = status & 15;
if (status == JAG_END_OF_TRACK)
{
//if (var65) -- client has this if, but it causes broken midi to be produced
{
var51.writeByte(META);
}
var51.writeByte(END_OF_TRACK); // type - end of track
var51.writeByte(0); // length
var51.writeLengthFromMark(var51.getOffset() - var61);
continue label361;
}
if (status == JAG_TEMPO)
{
//if (var65) -- client has this if, but it causes broken midi to be produced
{
var51.writeByte(META); // meta event FF
}
var51.writeByte(TEMPO); // type - set tempo
var51.writeByte(3); // length
var51.writeByte(var1.getArray()[tempoOffset++]);
var51.writeByte(var1.getArray()[tempoOffset++]);
var51.writeByte(var1.getArray()[tempoOffset++]);
}
else
{
channel ^= status >> 4;
if (var62 == JAG_NOTE_ON)
{
if (var65)
{
var51.writeByte(NOTE_ON + channel);
}
var53 += var1.getArray()[notesIndex++];
var54 += var1.getArray()[notesOnIndex++];
var51.writeByte(var53 & 127);
var51.writeByte(var54 & 127);
}
else if (var62 == JAG_NOTE_OFF)
{
if (var65)
{
var51.writeByte(NOTE_OFF + channel);
}
var53 += var1.getArray()[notesIndex++];
var55 += var1.getArray()[notesOffIndex++];
var51.writeByte(var53 & 127);
var51.writeByte(var55 & 127);
}
else if (var62 == JAG_CONTROL_CHANGE)
{
if (var65)
{
var51.writeByte(CONTROL_CHANGE + channel);
}
controllerNumber = controllerNumber + var1.getArray()[controlChangeIndex++] & 127;
var51.writeByte(controllerNumber);
byte var66;
if (controllerNumber == CONTROLLER_BANK_SELECT || controllerNumber == CONTROLLER_BANK_SELECT_2)
{
var66 = var1.getArray()[programChangeIndex++];
}
else if (controllerNumber == CONTROLLER_MODULATION_WHEEL)
{
var66 = var1.getArray()[modulationWheelOffset++];
}
else if (controllerNumber == CONTROLLER_MODULATION_WHEEL2)
{
var66 = var1.getArray()[modulationWheel2Offset++];
}
else if (controllerNumber == CONTROLLER_CHANNEL_VOLUME)
{
var66 = var1.getArray()[channelVolumeOffset++];
}
else if (controllerNumber == CONTROLLER_CHANNEL_VOLUME_2)
{
var66 = var1.getArray()[channelVolume2Offset++];
}
else if (controllerNumber == CONTROLLER_PAN)
{
var66 = var1.getArray()[panOffset++];
}
else if (controllerNumber == CONTROLLER_PAN_2)
{
var66 = var1.getArray()[pan2Offset++];
}
else if (controllerNumber == CONTROLLER_NON_REGISTERED_PARAMETER_NUMBER_MSB)
{
var66 = var1.getArray()[nonRegisteredMsbIndex++];
}
else if (controllerNumber == CONTROLLER_NON_REGISTERED_PARAMETER_NUMBER_LSB)
{
var66 = var1.getArray()[nonRegisteredLsbIndex++];
}
else if (controllerNumber == CONTROLLER_REGISTERED_PARAMETER_NUMBER_MSB)
{
var66 = var1.getArray()[registeredMsbIndex++];
}
else if (controllerNumber == CONTROLLER_REGISTERED_PARAMETER_NUMBER_LSB)
{
var66 = var1.getArray()[registeredLsbIndex++];
}
else if (controllerNumber != CONTROLLER_DAMPER_PEDAL
&& controllerNumber != CONTROLLER_PORTAMENTO
&& controllerNumber != CONTROLLER_ALL_SOUND_OFF
&& controllerNumber != CONTROLLER_RESET_ALL_CONTROLLERS
&& controllerNumber != CONTROLLER_ALL_NOTES_OFF)
{
var66 = var1.getArray()[otherIndex++];
}
else
{
var66 = var1.getArray()[commandsIndex++];
}
int var67 = var66 + var59[controllerNumber];
var59[controllerNumber] = var67;
var51.writeByte(var67 & 127);
}
else if (var62 == JAG_PITCH_BEND)
{
if (var65)
{
var51.writeByte(PITCH_WHEEL_CHANGE + channel);
}
var56 += var1.getArray()[pitchWheelLowIndex++];
var56 += var1.getArray()[pitchWheelHighIndex++] << 7;
var51.writeByte(var56 & 127);
var51.writeByte(var56 >> 7 & 127);
}
else if (var62 == JAG_CHANNEL_PRESSURE)
{
if (var65)
{
var51.writeByte(CHANNEL_PRESSURE + channel);
}
var57 += var1.getArray()[channelPressureIndex++];
var51.writeByte(var57 & 127);
}
else if (var62 == JAG_POLY_PRESSURE)
{
if (var65)
{
var51.writeByte(POLYPHONIC_KEY_PRESSURE + channel);
}
var53 += var1.getArray()[notesIndex++];
var58 += var1.getArray()[polyPressureIndex++];
var51.writeByte(var53 & 127);
var51.writeByte(var58 & 127);
}
else if (var62 == JAG_PROGRAM_CHANGE)
{
if (var65)
{
var51.writeByte(PROGRAM_CHANGE + channel);
}
var51.writeByte(var1.getArray()[programChangeIndex++]);
}
else
{
throw new RuntimeException();
}
}
}
}
def.midi = var51.flip();
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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.UnderlayDefinition;
import net.runelite.cache.io.InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UnderlayLoader
{
private static final Logger logger = LoggerFactory.getLogger(UnderlayLoader.class);
public UnderlayDefinition load(int id, byte[] b)
{
UnderlayDefinition def = new UnderlayDefinition();
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.setColor(color);
}
}
def.calculateHsl();
return def;
}
}

View File

@@ -0,0 +1,57 @@
/*
* 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.VarbitDefinition;
import net.runelite.cache.io.InputStream;
public class VarbitLoader
{
public VarbitDefinition load(int id, byte[] b)
{
VarbitDefinition def = new VarbitDefinition();
InputStream is = new InputStream(b);
def.setId(id);
for (;;)
{
int opcode = is.readUnsignedByte();
if (opcode == 0)
{
break;
}
if (opcode == 1)
{
def.setIndex(is.readUnsignedShort());
def.setLeastSignificantBit(is.readUnsignedByte());
def.setMostSignificantBit(is.readUnsignedByte());
}
}
return def;
}
}

View File

@@ -0,0 +1,179 @@
/*
* 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.LinkedList;
import net.runelite.cache.definitions.WorldMapDefinition;
import net.runelite.cache.definitions.WorldMapType0;
import net.runelite.cache.definitions.WorldMapType1;
import net.runelite.cache.definitions.WorldMapType2;
import net.runelite.cache.definitions.WorldMapType3;
import net.runelite.cache.definitions.WorldMapTypeBase;
import net.runelite.cache.io.InputStream;
import net.runelite.cache.region.Position;
public class WorldMapLoader
{
public WorldMapDefinition load(byte[] b, int fileId)
{
WorldMapDefinition def = new WorldMapDefinition();
InputStream in = new InputStream(b);
def.fileId = fileId;
def.safeName = in.readString();
def.name = in.readString();
int packedPos = in.readInt();
if (packedPos == -1)
{
def.position = new Position(-1, -1, -1);
}
else
{
int y = packedPos >> 28 & 3;
int x = packedPos >> 14 & 16383;
int z = packedPos & 16383;
def.position = new Position(x, y, z);
}
def.field450 = in.readInt();
in.readUnsignedByte();
def.field457 = in.readUnsignedByte() == 1;
def.field451 = in.readUnsignedByte();
int var3 = in.readUnsignedByte();
def.field458 = new LinkedList();
for (int var4 = 0; var4 < var3; ++var4)
{
def.field458.add(this.loadType(in));
}
return def;
}
private WorldMapTypeBase loadType(InputStream var1)
{
int var2 = var1.readUnsignedByte();
// field397 = new class27(1, (byte)0);
// field390 = new class27(2, (byte)1);
// field399 = new class27(3, (byte)2);
// field393 = new class27(0, (byte)3);
WorldMapTypeBase base;
switch (var2)
{
case 0:
// type 1
base = load1(var1);
break;
case 1:
// type 2
base = load2(var1);
break;
case 2:
// type 3
base = load3(var1);
break;
case 3:
// type 0
base = load0(var1);
break;
default:
throw new IllegalStateException();
}
return base;
}
private WorldMapTypeBase load0(InputStream in)
{
WorldMapType0 wm = new WorldMapType0();
wm.field606 = in.readUnsignedByte();
wm.field605 = in.readUnsignedByte();
wm.field601 = in.readUnsignedShort();
wm.field602 = in.readUnsignedByte();
wm.field603 = in.readUnsignedShort();
wm.field607 = in.readUnsignedByte();
wm.field604 = in.readUnsignedShort();
wm.field600 = in.readUnsignedByte();
wm.field608 = in.readUnsignedShort();
wm.field609 = in.readUnsignedByte();
return wm;
}
private WorldMapTypeBase load1(InputStream in)
{
WorldMapType1 wm = new WorldMapType1();
wm.field434 = in.readUnsignedByte();
wm.field424 = in.readUnsignedByte();
wm.field425 = in.readUnsignedShort();
wm.field426 = in.readUnsignedShort();
wm.field427 = in.readUnsignedShort();
wm.field431 = in.readUnsignedShort();
wm.field429 = in.readUnsignedShort();
wm.field428 = in.readUnsignedShort();
wm.field433 = in.readUnsignedShort();
wm.field435 = in.readUnsignedShort();
return wm;
}
private WorldMapTypeBase load2(InputStream in)
{
WorldMapType2 wm = new WorldMapType2();
wm.field519 = in.readUnsignedByte();
wm.field511 = in.readUnsignedByte();
wm.field510 = in.readUnsignedShort();
wm.field512 = in.readUnsignedShort();
wm.field514 = in.readUnsignedShort();
wm.field515 = in.readUnsignedShort();
return wm;
}
private WorldMapTypeBase load3(InputStream in)
{
WorldMapType3 wm = new WorldMapType3();
wm.field387 = in.readUnsignedByte();
wm.field377 = in.readUnsignedByte();
wm.field378 = in.readUnsignedShort();
wm.field382 = in.readUnsignedByte();
wm.field376 = in.readUnsignedByte();
wm.field383 = in.readUnsignedShort();
wm.field385 = in.readUnsignedByte();
wm.field379 = in.readUnsignedByte();
wm.field380 = in.readUnsignedShort();
wm.field386 = in.readUnsignedByte();
wm.field388 = in.readUnsignedByte();
wm.field381 = in.readUnsignedShort();
wm.field384 = in.readUnsignedByte();
wm.field389 = in.readUnsignedByte();
return wm;
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders.sound;
import net.runelite.cache.definitions.sound.SoundEffect1Definition;
import net.runelite.cache.definitions.sound.SoundEffect2Definition;
import net.runelite.cache.io.InputStream;
public class SoundEffect1Loader
{
private final SoundEffect2Loader se2Loader = new SoundEffect2Loader();
private final SoundEffect3Loader se3Loader = new SoundEffect3Loader();
public SoundEffect1Definition load(InputStream in)
{
SoundEffect1Definition se = new SoundEffect1Definition();
load(se, in);
return se;
}
private void load(SoundEffect1Definition se, InputStream var1)
{
se.field1181 = se2Loader.load(var1);
se.field1173 = se2Loader.load(var1);
int var2 = var1.readUnsignedByte();
if (var2 != 0)
{
var1.setOffset(var1.getOffset() - 1);
se.field1174 = se2Loader.load(var1);
se.field1193 = se2Loader.load(var1);
}
var2 = var1.readUnsignedByte();
if (var2 != 0)
{
var1.setOffset(var1.getOffset() - 1);
se.field1183 = se2Loader.load(var1);
se.field1192 = se2Loader.load(var1);
}
var2 = var1.readUnsignedByte();
if (var2 != 0)
{
var1.setOffset(var1.getOffset() - 1);
se.field1178 = se2Loader.load(var1);
se.field1175 = se2Loader.load(var1);
}
for (int var3 = 0; var3 < 10; ++var3)
{
int var4 = var1.readUnsignedShortSmart();
if (var4 == 0)
{
break;
}
se.field1180[var3] = var4;
se.field1179[var3] = var1.readShortSmart();
se.field1177[var3] = var1.readUnsignedShortSmart();
}
se.field1187 = var1.readUnsignedShortSmart();
se.field1184 = var1.readUnsignedShortSmart();
se.field1176 = var1.readUnsignedShort();
se.field1188 = var1.readUnsignedShort();
se.field1186 = new SoundEffect2Definition();
se.field1182 = se3Loader.load(var1, se.field1186);
}
}

View File

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

View File

@@ -0,0 +1,95 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.loaders.sound;
import net.runelite.cache.definitions.sound.SoundEffect2Definition;
import net.runelite.cache.definitions.sound.SoundEffect3Definition;
import net.runelite.cache.io.InputStream;
public class SoundEffect3Loader
{
private final SoundEffect2Loader se2Loader = new SoundEffect2Loader();
public SoundEffect3Definition load(InputStream in, SoundEffect2Definition var2)
{
SoundEffect3Definition se = new SoundEffect3Definition();
load(se, in, var2);
return se;
}
private void load(SoundEffect3Definition se, InputStream var1, SoundEffect2Definition var2)
{
int var3 = var1.readUnsignedByte();
se.field1155[0] = var3 >> 4;
se.field1155[1] = var3 & 15;
if (var3 != 0)
{
se.field1156[0] = var1.readUnsignedShort();
se.field1156[1] = var1.readUnsignedShort();
int var4 = var1.readUnsignedByte();
int var5;
int var6;
for (var5 = 0; var5 < 2; ++var5)
{
for (var6 = 0; var6 < se.field1155[var5]; ++var6)
{
se.field1154[var5][0][var6] = var1.readUnsignedShort();
se.field1159[var5][0][var6] = var1.readUnsignedShort();
}
}
for (var5 = 0; var5 < 2; ++var5)
{
for (var6 = 0; var6 < se.field1155[var5]; ++var6)
{
if ((var4 & 1 << var5 * 4 << var6) != 0)
{
se.field1154[var5][1][var6] = var1.readUnsignedShort();
se.field1159[var5][1][var6] = var1.readUnsignedShort();
}
else
{
se.field1154[var5][1][var6] = se.field1154[var5][0][var6];
se.field1159[var5][1][var6] = se.field1159[var5][0][var6];
}
}
}
if (var4 != 0 || se.field1156[1] != se.field1156[0])
{
se2Loader.method1144(var2, var1);
}
}
else
{
int[] var7 = se.field1156;
se.field1156[1] = 0;
var7[0] = 0;
}
}
}

View File

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

View File

@@ -0,0 +1,32 @@
/*
* 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.definitions.providers;
import net.runelite.cache.definitions.ItemDefinition;
public interface ItemProvider
{
ItemDefinition provide(int itemId);
}

View File

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

View File

@@ -0,0 +1,32 @@
/*
* 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.definitions.providers;
import net.runelite.cache.definitions.OverlayDefinition;
public interface OverlayProvider
{
OverlayDefinition provide(int overlayId);
}

View File

@@ -0,0 +1,32 @@
/*
* 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.definitions.providers;
import net.runelite.cache.definitions.SpriteDefinition;
public interface SpriteProvider
{
SpriteDefinition provide(int spriteId, int frameId);
}

View File

@@ -0,0 +1,32 @@
/*
* 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.providers;
import net.runelite.cache.definitions.StructDefinition;
public interface StructProvider
{
StructDefinition provide(int structId);
}

View File

@@ -0,0 +1,32 @@
/*
* 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.definitions.providers;
import net.runelite.cache.definitions.TextureDefinition;
public interface TextureProvider
{
TextureDefinition[] provide();
}

View File

@@ -0,0 +1,32 @@
/*
* 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.definitions.providers;
import net.runelite.cache.definitions.UnderlayDefinition;
public interface UnderlayProvider
{
UnderlayDefinition provide(int underlayId);
}

View File

@@ -0,0 +1,226 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.savers;
import net.runelite.cache.definitions.ClientScript1Instruction;
import net.runelite.cache.definitions.InterfaceDefinition;
import net.runelite.cache.io.OutputStream;
public class InterfaceSaver
{
public byte[] save(InterfaceDefinition def)
{
if (def.isIf3)
{
return saveIf3(def);
}
else
{
return saveIf1(def);
}
}
private byte[] saveIf3(InterfaceDefinition def)
{
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
private byte[] saveIf1(InterfaceDefinition def)
{
OutputStream out = new OutputStream();
out.writeByte(def.type);
out.writeByte(def.menuType);
out.writeShort(def.contentType);
out.writeShort(def.originalX);
out.writeShort(def.originalY);
out.writeShort(def.originalWidth);
out.writeShort(def.originalHeight);
out.writeByte(def.opacity);
out.writeShort(def.parentId);
out.writeShort(def.hoveredSiblingId);
if (def.alternateOperators != null)
{
out.writeByte(def.alternateOperators.length);
for (int i = 0; i < def.alternateOperators.length; ++i)
{
out.writeByte(def.alternateOperators[i]);
out.writeShort(def.alternateRhs[i]);
}
}
else
{
out.writeByte(0);
}
if (def.clientScripts != null)
{
out.writeByte(def.clientScripts.length);
for (int i = 0; i < def.clientScripts.length; ++i)
{
int len = 0;
for (int j = 0; j < def.clientScripts[i].length; ++j)
{
ClientScript1Instruction ins = def.clientScripts[i][j];
len++;
if (ins.operands != null)
{
len += ins.operands.length;
}
}
out.writeShort(len);
for (int j = 0; j < def.clientScripts[i].length; ++j)
{
ClientScript1Instruction ins = def.clientScripts[i][j];
out.writeShort(ins.opcode.ordinal());
if (ins.operands != null)
{
for (int op : ins.operands)
{
out.writeShort(op);
}
}
}
}
}
else
{
out.writeByte(0);
}
if (def.type == 0)
{
out.writeShort(def.scrollHeight);
out.writeByte(def.isHidden ? 1 : 0);
}
if (def.type == 1)
{
out.writeShort(0);
out.writeByte(0);
}
if (def.type == 2)
{
out.writeByte((def.clickMask & 268435456) != 0 ? 1 : 0);
out.writeByte((def.clickMask & 1073741824) != 0 ? 1 : 0);
out.writeByte((def.clickMask & Integer.MIN_VALUE) != 0 ? 1 : 0);
out.writeByte((def.clickMask & 536870912) != 0 ? 1 : 0);
out.writeByte(def.xPitch);
out.writeByte(def.yPitch);
for (int i = 0; i < 20; ++i)
{
if (def.sprites[i] != -1)
{
out.writeByte(1);
out.writeShort(def.xOffsets[i]);
out.writeShort(def.yOffsets[i]);
out.writeShort(def.sprites[i]);
}
else
{
out.writeByte(0);
}
}
for (int i = 0; i < 5; ++i)
{
if (def.configActions[i] != null)
{
out.writeString(def.configActions[i]);
}
else
{
out.writeString("");
}
}
}
if (def.type == 3)
{
out.writeByte(def.filled ? 1 : 0);
}
if (def.type == 4 || def.type == 1)
{
out.writeByte(def.xTextAlignment);
out.writeByte(def.yTextAlignment);
out.writeByte(def.lineHeight);
out.writeShort(def.fontId);
out.writeByte(def.textShadowed ? 1 : 0);
}
if (def.type == 4)
{
out.writeString(def.text);
out.writeString(def.alternateText);
}
if (def.type == 1 || def.type == 3 || def.type == 4)
{
out.writeInt(def.textColor);
}
if (def.type == 3 || def.type == 4)
{
out.writeInt(def.alternateTextColor);
out.writeInt(def.hoveredTextColor);
out.writeInt(def.alternateHoveredTextColor);
}
if (def.type == 5)
{
out.writeInt(def.spriteId);
out.writeInt(def.alternateSpriteId);
}
if (def.type == 6)
{
out.writeShort(def.modelId);
out.writeShort(def.alternateModelId);
out.writeShort(def.animation);
out.writeShort(def.alternateAnimation);
out.writeShort(def.modelZoom);
out.writeShort(def.rotationX);
out.writeShort(def.rotationZ);
}
if (def.type == 7)
{
out.writeByte(def.xTextAlignment);
out.writeShort(def.fontId);
out.writeByte(def.textShadowed ? 1 : 0);
out.writeInt(def.textColor);
out.writeShort(def.xPitch);
out.writeShort(def.yPitch);
out.writeByte((def.clickMask & 1073741824) != 0 ? 1 : 0);
for (int i = 0; i < 5; ++i)
{
out.writeString(def.configActions[i]);
}
}
if (def.type == 8)
{
out.writeString(def.text);
}
if (def.menuType == 2 || def.type == 2)
{
out.writeString(def.targetVerb);
out.writeString(def.spellName);
out.writeShort((def.clickMask >>> 11) & 63);
}
if (def.menuType == 1 || def.menuType == 4 || def.menuType == 5 || def.menuType == 6)
{
out.writeString(def.tooltip);
}
return out.flip();
}
}

View File

@@ -0,0 +1,235 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.savers;
import java.util.Map.Entry;
import net.runelite.cache.definitions.ItemDefinition;
import net.runelite.cache.io.OutputStream;
public class ItemSaver
{
public byte[] save(ItemDefinition item)
{
OutputStream out = new OutputStream();
if (item.inventoryModel != 0)
{
out.writeByte(1);
out.writeShort(item.inventoryModel);
}
if (item.name != null)
{
out.writeByte(2);
out.writeString(item.name);
}
out.writeByte(4);
out.writeShort(item.zoom2d);
out.writeByte(5);
out.writeShort(item.xan2d);
out.writeByte(6);
out.writeShort(item.yan2d);
out.writeByte(7);
out.writeShort(item.xOffset2d);
out.writeByte(8);
out.writeShort(item.yOffset2d);
if (item.stackable != 0)
{
out.writeByte(11);
}
out.writeByte(12);
out.writeInt(item.cost);
if (item.members)
{
out.writeByte(16);
}
if (item.maleModel0 != -1 || item.maleOffset != 0)
{
out.writeByte(23);
out.writeShort(item.maleModel0);
out.writeByte(item.maleOffset);
}
if (item.maleModel1 != -1)
{
out.writeByte(24);
out.writeShort(item.maleModel1);
}
if (item.femaleModel0 != -1 || item.femaleOffset != 0)
{
out.writeByte(25);
out.writeShort(item.femaleModel0);
out.writeByte(item.femaleOffset);
}
if (item.femaleModel1 != -1)
{
out.writeByte(26);
out.writeShort(item.femaleModel1);
}
for (int i = 0; i < 5; ++i)
{
if (item.options[i] != null)
{
out.writeByte(30 + i);
out.writeString(item.options[i]);
}
}
for (int i = 0; i < 5; ++i)
{
if (item.interfaceOptions[i] != null)
{
out.writeByte(35 + i);
out.writeString(item.interfaceOptions[i]);
}
}
if (item.colorFind != null && item.colorReplace != null)
{
out.writeByte(40);
out.writeByte(item.colorFind.length);
for (int i = 0; i < item.colorFind.length; ++i)
{
out.writeShort(item.colorFind[i]);
out.writeShort(item.colorReplace[i]);
}
}
if (item.textureFind != null && item.textureReplace != null)
{
out.writeByte(41);
out.writeByte(item.textureFind.length);
for (int i = 0; i < item.textureFind.length; ++i)
{
out.writeShort(item.textureFind[i]);
out.writeShort(item.textureReplace[i]);
}
}
out.writeByte(42);
out.writeByte(item.shiftClickDropIndex);
if (item.isTradeable)
{
out.writeByte(65);
}
if (item.maleModel2 != -1)
{
out.writeByte(78);
out.writeShort(item.maleModel2);
}
if (item.femaleModel2 != -1)
{
out.writeByte(79);
out.writeShort(item.femaleModel2);
}
if (item.maleHeadModel != -1)
{
out.writeByte(90);
out.writeShort(item.maleHeadModel);
}
if (item.femaleHeadModel != -1)
{
out.writeByte(91);
out.writeShort(item.femaleHeadModel);
}
if (item.maleHeadModel2 != -1)
{
out.writeByte(92);
out.writeShort(item.maleHeadModel2);
}
if (item.femaleHeadModel2 != -1)
{
out.writeByte(93);
out.writeShort(item.femaleHeadModel2);
}
out.writeByte(95);
out.writeShort(item.zan2d);
if (item.notedID != -1)
{
out.writeByte(97);
out.writeShort(item.notedID);
}
if (item.notedTemplate != -1)
{
out.writeByte(98);
out.writeShort(item.notedTemplate);
}
if (item.countObj != null)
{
for (int i = 0; i < 10; ++i)
{
out.writeByte(100 + i);
out.writeShort(item.countObj[i]);
out.writeShort(item.countCo[i]);
}
}
out.writeByte(110);
out.writeShort(item.resizeX);
out.writeByte(111);
out.writeShort(item.resizeY);
out.writeByte(112);
out.writeShort(item.resizeZ);
out.writeByte(113);
out.writeByte(item.ambient);
out.writeByte(114);
out.writeByte(item.contrast);
out.writeByte(115);
out.writeByte(item.team);
if (item.boughtId != -1)
{
out.writeByte(139);
out.writeShort(item.boughtId);
}
if (item.boughtTemplateId != -1)
{
out.writeByte(140);
out.writeShort(item.boughtTemplateId);
}
if (item.placeholderId != -1)
{
out.writeByte(148);
out.writeShort(item.placeholderId);
}
if (item.placeholderTemplateId != -1)
{
out.writeByte(149);
out.writeShort(item.placeholderTemplateId);
}
if (item.params != null)
{
out.writeByte(249);
out.writeByte(item.params.size());
for (Entry<Integer, Object> entry : item.params.entrySet())
{
out.writeByte(entry.getValue() instanceof String ? 1 : 0);
out.write24BitInt(entry.getKey());
if (entry.getValue() instanceof String)
{
out.writeString((String) entry.getValue());
}
else
{
out.writeInt((Integer) entry.getValue());
}
}
}
out.writeByte(0);
return out.flip();
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.savers;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.runelite.cache.definitions.LocationsDefinition;
import net.runelite.cache.io.OutputStream;
import net.runelite.cache.region.Location;
public class LocationSaver
{
public byte[] save(LocationsDefinition locs)
{
Multimap<Integer, Location> locById = LinkedListMultimap.create();
List<Location> sortedLocs = new ArrayList<>(locs.getLocations());
sortedLocs.sort((l1, l2) -> Integer.compare(l1.getId(), l2.getId()));
for (Location loc : sortedLocs)
{
locById.put(loc.getId(), loc);
}
OutputStream out = new OutputStream();
int prevId = -1;
for (Integer id : locById.keySet())
{
int diffId = id - prevId;
prevId = id;
out.writeShortSmart(diffId);
Collection<Location> locations = locById.get(id);
int position = 0;
for (Location loc : locations)
{
int packedPosition = (loc.getPosition().getZ() << 12)
| (loc.getPosition().getX() << 6)
| (loc.getPosition().getY());
int diffPos = packedPosition - position;
position = packedPosition;
out.writeShortSmart(diffPos + 1);
int packedAttributes = (loc.getType() << 2) | loc.getOrientation();
out.writeByte(packedAttributes);
}
out.writeShortSmart(0);
}
out.writeShortSmart(0);
return out.flip();
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.savers;
import net.runelite.cache.definitions.MapDefinition;
import net.runelite.cache.definitions.MapDefinition.Tile;
import net.runelite.cache.io.OutputStream;
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 MapSaver
{
public byte[] save(MapDefinition map)
{
Tile[][][] tiles = map.getTiles();
OutputStream out = new OutputStream();
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];
if (tile.attrOpcode != 0)
{
out.writeByte(tile.attrOpcode);
out.writeByte(tile.overlayId);
}
if (tile.settings != 0)
{
out.writeByte(tile.settings + 49);
}
if (tile.underlayId != 0)
{
out.writeByte(tile.underlayId + 81);
}
if (tile.height == null)
{
out.writeByte(0);
}
else
{
out.writeByte(1);
out.writeByte(tile.height);
}
}
}
}
return out.flip();
}
}

View File

@@ -0,0 +1,195 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.savers;
import java.util.Map;
import net.runelite.cache.definitions.NpcDefinition;
import net.runelite.cache.io.OutputStream;
public class NpcSaver
{
public byte[] save(NpcDefinition npc)
{
OutputStream out = new OutputStream();
if (npc.models != null)
{
out.writeByte(1);
out.writeByte(npc.models.length);
for (int modelId : npc.models)
{
out.writeShort(modelId);
}
}
if (npc.name != null)
{
out.writeByte(2);
out.writeString(npc.name);
}
if (npc.tileSpacesOccupied != 1)
{
out.writeByte(12);
out.writeByte(npc.tileSpacesOccupied);
}
if (npc.stanceAnimation != -1)
{
out.writeByte(13);
out.writeShort(npc.stanceAnimation);
}
if (npc.walkAnimation != -1)
{
out.writeByte(14);
out.writeShort(npc.walkAnimation);
}
if (npc.anInt2165 != -1)
{
out.writeByte(15);
out.writeShort(npc.anInt2165);
}
if (npc.anInt2189 != -1)
{
out.writeByte(16);
out.writeShort(npc.anInt2189);
}
if (npc.rotate180Animation != -1 || npc.rotate90LeftAnimation != -1 || npc.rotate90RightAnimation != -1)
{
out.writeByte(17);
out.writeShort(npc.walkAnimation);
out.writeShort(npc.rotate180Animation);
out.writeShort(npc.rotate90RightAnimation);
out.writeShort(npc.rotate90LeftAnimation);
}
for (int i = 0; i < 5; ++i)
{
if (npc.options[i] != null)
{
out.writeByte(30 + i);
out.writeString(npc.options[i]);
}
}
if (npc.recolorToFind != null && npc.recolorToReplace != null)
{
out.writeByte(40);
out.writeByte(npc.recolorToFind.length);
for (int i = 0; i < npc.recolorToFind.length; ++i)
{
out.writeShort(npc.recolorToFind[i]);
out.writeShort(npc.recolorToReplace[i]);
}
}
if (npc.retextureToFind != null && npc.retextureToReplace != null)
{
out.writeByte(41);
out.writeByte(npc.retextureToFind.length);
for (int i = 0; i < npc.retextureToFind.length; ++i)
{
out.writeShort(npc.retextureToFind[i]);
out.writeShort(npc.retextureToReplace[i]);
}
}
if (npc.models_2 != null)
{
out.writeByte(60);
out.writeByte(npc.models_2.length);
for (int modelId : npc.models_2)
{
out.writeShort(modelId);
}
}
if (!npc.renderOnMinimap)
{
out.writeByte(93);
}
if (npc.combatLevel != -1)
{
out.writeByte(95);
out.writeShort(npc.combatLevel);
}
out.writeByte(97);
out.writeShort(npc.resizeX);
out.writeByte(98);
out.writeShort(npc.resizeY);
if (npc.hasRenderPriority)
{
out.writeByte(99);
}
out.writeByte(100);
out.writeByte(npc.ambient);
out.writeByte(101);
out.writeByte(npc.contrast);
if (npc.headIcon != -1)
{
out.writeByte(102);
out.writeShort(npc.headIcon);
}
out.writeByte(103);
out.writeShort(npc.rotation);
if (!npc.isClickable)
{
out.writeByte(107);
}
if (!npc.aBool2170)
{
out.writeByte(109);
}
if (npc.aBool2190)
{
out.writeByte(111);
}
if (npc.configs != null)
{
out.writeByte(118);
out.writeShort(npc.varbitIndex);
out.writeShort(npc.varpIndex);
int[] c = npc.configs;
out.writeShort(c[c.length - 1]);
out.writeByte(c.length - 2);
for (int i = 0; i <= c.length - 2; ++i)
{
out.writeShort(c[i]);
}
}
if (npc.params != null)
{
out.writeByte(249);
out.writeByte(npc.params.size());
for (Map.Entry<Integer, Object> entry : npc.params.entrySet())
{
out.writeByte(entry.getValue() instanceof String ? 1 : 0);
out.write24BitInt(entry.getKey());
if (entry.getValue() instanceof String)
{
out.writeString((String) entry.getValue());
}
else
{
out.writeInt((Integer) entry.getValue());
}
}
}
out.writeByte(0);
return out.flip();
}
}

View File

@@ -0,0 +1,231 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.definitions.savers;
import java.util.Map;
import net.runelite.cache.definitions.ObjectDefinition;
import net.runelite.cache.io.OutputStream;
public class ObjectSaver
{
public byte[] save(ObjectDefinition obj)
{
OutputStream out = new OutputStream();
if (obj.getObjectTypes() != null && obj.getObjectModels() != null)
{
out.writeByte(1);
out.writeByte(obj.getObjectTypes().length);
for (int i = 0; i < obj.getObjectTypes().length; ++i)
{
out.writeShort(obj.getObjectModels()[i]);
out.writeByte(obj.getObjectTypes()[i]);
}
}
if (obj.getName() != null)
{
out.writeByte(2);
out.writeString(obj.getName());
}
if (obj.getObjectTypes() == null && obj.getObjectModels() != null)
{
out.writeByte(5);
out.writeByte(obj.getObjectModels().length);
for (int i = 0; i < obj.getObjectModels().length; ++i)
{
out.writeShort(obj.getObjectModels()[i]);
}
}
out.writeByte(14);
out.writeByte(obj.getSizeX());
out.writeByte(15);
out.writeByte(obj.getSizeY());
if (obj.getInteractType() == 0 && !obj.isBlocksProjectile())
{
out.writeByte(17);
}
else if (!obj.isBlocksProjectile())
{
out.writeByte(18);
}
if (obj.getAnInt2088() != -1)
{
out.writeByte(19);
out.writeByte(obj.getAnInt2088());
}
if (obj.getAnInt2105() == 0)
{
out.writeByte(21);
}
if (!obj.isNonFlatShading())
{
out.writeByte(22);
}
if (obj.isABool2111())
{
out.writeByte(23);
}
if (obj.getAnimationID() != -1)
{
out.writeByte(24);
out.writeShort(obj.getAnimationID());
}
if (obj.getInteractType() == 1)
{
out.writeByte(27);
}
out.writeByte(28);
out.writeByte(obj.getAnInt2069());
out.writeByte(29);
out.writeByte(obj.getAmbient());
out.writeByte(39);
out.writeByte(obj.getContrast());
for (int i = 0; i < 5; ++i)
{
out.writeByte(30 + i);
String action = obj.getActions()[i];
out.writeString(action != null ? action : "Hidden");
}
if (obj.getRecolorToFind() != null && obj.getRecolorToReplace() != null)
{
out.writeByte(40);
out.writeByte(obj.getRecolorToFind().length);
for (int i = 0; i < obj.getRecolorToFind().length; ++i)
{
out.writeShort(obj.getRecolorToFind()[i]);
out.writeShort(obj.getRecolorToReplace()[i]);
}
}
if (obj.getRetextureToFind() != null && obj.getTextureToReplace() != null)
{
out.writeByte(41);
out.writeByte(obj.getRetextureToFind().length);
for (int i = 0; i < obj.getRetextureToFind().length; ++i)
{
out.writeShort(obj.getRetextureToFind()[i]);
out.writeShort(obj.getTextureToReplace()[i]);
}
}
if (obj.isRotated())
{
out.writeByte(62);
}
if (!obj.isABool2097())
{
out.writeByte(64);
}
out.writeByte(65);
out.writeShort(obj.getModelSizeX());
out.writeByte(66);
out.writeShort(obj.getModelSizeHeight());
out.writeByte(67);
out.writeShort(obj.getModelSizeY());
if (obj.getMapSceneID() != -1)
{
out.writeByte(68);
out.writeShort(obj.getMapSceneID());
}
out.writeByte(70);
out.writeShort(obj.getOffsetX());
out.writeByte(71);
out.writeShort(obj.getOffsetHeight());
out.writeByte(72);
out.writeShort(obj.getOffsetY());
if (obj.isABool2104())
{
out.writeByte(73);
}
if (obj.isSolid())
{
out.writeByte(74);
}
if (obj.getAnInt2106() != -1)
{
out.writeByte(75);
out.writeByte(obj.getAnInt2106());
}
if (obj.getAnInt2110() != -1)
{
out.writeByte(78);
out.writeShort(obj.getAnInt2110());
out.writeByte(obj.getAnInt2083());
}
if (obj.getAnIntArray2084() != null)
{
out.writeByte(79);
out.writeShort(obj.getAnInt2112());
out.writeShort(obj.getAnInt2113());
out.writeByte(obj.getAnInt2083());
out.writeByte(obj.getAnIntArray2084().length);
for (int i : obj.getAnIntArray2084())
{
out.writeShort(i);
}
}
if (obj.getAnInt2105() != -1)
{
out.writeByte(81);
out.writeByte(obj.getAnInt2105() / 256);
}
if (obj.getMapAreaId() != -1)
{
out.writeByte(82);
out.writeShort(obj.getMapAreaId());
}
if (obj.getConfigChangeDest() != null)
{
out.writeByte(92);
out.writeShort(obj.getVarbitID());
out.writeShort(obj.getVarpID());
int[] c = obj.getConfigChangeDest();
out.writeShort(c[c.length - 1]);
out.writeByte(c.length - 2);
for (int i = 0; i <= c.length - 2; ++i)
{
out.writeShort(c[i]);
}
}
if (obj.getParams() != null)
{
out.writeByte(249);
out.writeByte(obj.getParams().size());
for (Map.Entry<Integer, Object> entry : obj.getParams().entrySet())
{
out.writeByte(entry.getValue() instanceof String ? 1 : 0);
out.write24BitInt(entry.getKey());
if (entry.getValue() instanceof String)
{
out.writeString((String) entry.getValue());
}
else
{
out.writeInt((Integer) entry.getValue());
}
}
}
out.writeByte(0);
return out.flip();
}
}

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.savers;
import java.util.Map;
import java.util.Map.Entry;
import net.runelite.cache.definitions.ScriptDefinition;
import net.runelite.cache.io.OutputStream;
import static net.runelite.cache.script.Opcodes.SCONST;
import static net.runelite.cache.script.Opcodes.POP_INT;
import static net.runelite.cache.script.Opcodes.POP_STRING;
import static net.runelite.cache.script.Opcodes.RETURN;
public class ScriptSaver
{
public byte[] save(ScriptDefinition script)
{
int[] instructions = script.getInstructions();
int[] intOperands = script.getIntOperands();
String[] stringOperands = script.getStringOperands();
Map<Integer, Integer>[] switches = script.getSwitches();
OutputStream out = new OutputStream();
out.writeByte(0); // null string
for (int i = 0; i < instructions.length; ++i)
{
int opcode = instructions[i];
out.writeShort(opcode);
if (opcode == SCONST)
{
out.writeString(stringOperands[i]);
}
else if (opcode < 100 && opcode != RETURN && opcode != POP_INT && opcode != POP_STRING)
{
out.writeInt(intOperands[i]);
}
else
{
out.writeByte(intOperands[i]);
}
}
out.writeInt(instructions.length);
out.writeShort(script.getLocalIntCount());
out.writeShort(script.getLocalStringCount());
out.writeShort(script.getIntStackCount());
out.writeShort(script.getStringStackCount());
int switchStart = out.getOffset();
if (switches == null)
{
out.writeByte(0);
}
else
{
out.writeByte(switches.length);
for (Map<Integer, Integer> s : switches)
{
out.writeShort(s.size());
for (Entry<Integer, Integer> e : s.entrySet())
{
out.writeInt(e.getKey());
out.writeInt(e.getValue());
}
}
}
int switchLength = out.getOffset() - switchStart;
out.writeShort(switchLength);
return out.flip();
}
}

View File

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

View File

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

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.sound;
public class SoundEffect3Definition
{
public int[][][] field1154 = new int[2][2][4];
public int[] field1155 = new int[2];
public int[] field1156 = new int[2];
public int[][][] field1159 = new int[2][2][4];
}

View File

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

View File

@@ -0,0 +1,224 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.cache.fs;
import java.io.IOException;
import net.runelite.cache.index.FileData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Archive
{
private static final Logger logger = LoggerFactory.getLogger(Archive.class);
private final Index index; // member of this index
private final int archiveId;
private int nameHash;
private int crc;
private int revision;
private int compression;
private FileData[] fileData;
private byte[] hash; // used by webservice, sha256 hash of content
public Archive(Index index, int id)
{
this.index = index;
this.archiveId = id;
}
@Override
public int hashCode()
{
int hash = 7;
hash = 47 * hash + this.archiveId;
hash = 47 * hash + this.nameHash;
hash = 47 * hash + this.revision;
return hash;
}
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final Archive other = (Archive) obj;
if (this.archiveId != other.archiveId)
{
return false;
}
if (this.nameHash != other.nameHash)
{
return false;
}
if (this.revision != other.revision)
{
return false;
}
return true;
}
public Index getIndex()
{
return index;
}
public byte[] decompress(byte[] data) throws IOException
{
return decompress(data, null);
}
public byte[] decompress(byte[] data, int[] keys) throws IOException
{
if (data == null)
{
return null;
}
byte[] encryptedData = data;
Container container = Container.decompress(encryptedData, keys);
if (container == null)
{
logger.warn("Unable to decrypt archive {}", this);
return null;
}
byte[] decompressedData = container.data;
if (this.crc != container.crc)
{
logger.warn("crc mismatch for archive {}/{}", index.getId(), this.getArchiveId());
throw new IOException("CRC mismatch for " + index.getId() + "/" + this.getArchiveId());
}
if (container.revision != -1 && this.getRevision() != container.revision)
{
// compressed data doesn't always include a revision, but check it if it does
logger.warn("revision mismatch for archive {}/{}, expected {} was {}",
index.getId(), this.getArchiveId(),
this.getRevision(), container.revision);
// I've seen this happen with vanilla caches where the
// revision in the index data differs from the revision
// stored for the archive data on disk... I assume this
// is more correct
this.setRevision(container.revision);
}
setCompression(container.compression);
return decompressedData;
}
public ArchiveFiles getFiles(byte[] data) throws IOException
{
return getFiles(data, null);
}
public ArchiveFiles getFiles(byte[] data, int[] keys) throws IOException
{
byte[] decompressedData = decompress(data, keys);
ArchiveFiles files = new ArchiveFiles();
for (FileData fileEntry : fileData)
{
FSFile file = new FSFile(fileEntry.getId());
file.setNameHash(fileEntry.getNameHash());
files.addFile(file);
}
files.loadContents(decompressedData);
return files;
}
public int getArchiveId()
{
return archiveId;
}
public int getNameHash()
{
return nameHash;
}
public void setNameHash(int nameHash)
{
this.nameHash = nameHash;
}
public int getCrc()
{
return crc;
}
public void setCrc(int crc)
{
this.crc = crc;
}
public int getRevision()
{
return revision;
}
public void setRevision(int revision)
{
this.revision = revision;
}
public int getCompression()
{
return compression;
}
public void setCompression(int compression)
{
this.compression = compression;
}
public FileData[] getFileData()
{
return fileData;
}
public void setFileData(FileData[] fileData)
{
this.fileData = fileData;
}
public byte[] getHash()
{
return hash;
}
public void setHash(byte[] hash)
{
this.hash = hash;
}
}

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