cache: add interface definition, loader, and manager

This commit is contained in:
Adam
2017-03-30 19:28:03 -04:00
parent 3c0ed845f9
commit 776add59a3
8 changed files with 927 additions and 3 deletions

View File

@@ -0,0 +1,119 @@
/*
* 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 java.util.ArrayList;
import java.util.List;
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.Index;
import net.runelite.cache.fs.Store;
import net.runelite.cache.util.Namer;
public class InterfaceManager
{
private final Store store;
private final List<InterfaceDefinition> interfaces = new ArrayList<>();
private final Namer namer = new Namer();
public InterfaceManager(Store store)
{
this.store = store;
}
public void load()
{
InterfaceLoader loader = new InterfaceLoader();
Index index = store.getIndex(IndexType.INTERFACES);
for (Archive archive : index.getArchives())
{
int archiveId = archive.getArchiveId();
for (net.runelite.cache.fs.File file : archive.getFiles())
{
int fileId = file.getFileId();
int widgetId = (archiveId << 16) + fileId;
InterfaceDefinition iface = loader.load(widgetId, file.getContents());
interfaces.add(iface);
}
}
}
public List<InterfaceDefinition> getItems()
{
return interfaces;
}
public void export(File out) throws IOException
{
out.mkdirs();
for (InterfaceDefinition def : interfaces)
{
InterfaceExporter exporter = new InterfaceExporter(def);
File targ = new File(out, def.id + ".json");
exporter.exportTo(targ);
}
}
public void java(File java) throws IOException
{
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 def : interfaces)
{
if (def.name == null || def.name.equalsIgnoreCase("NULL"))
{
continue;
}
String name = namer.name(def.name);
if (name == null)
{
continue;
}
fw.println(" public static final int " + name + " = " + def.id + ";");
}
fw.println("}");
}
}
}

View File

@@ -83,7 +83,7 @@ public class ItemManager
public void java(File java) throws IOException
{
java.mkdirs();
java.io.File targ = new java.io.File(java, "ItemID.java");
File targ = new File(java, "ItemID.java");
try (PrintWriter fw = new PrintWriter(targ))
{
fw.println("/* This file is automatically generated. Do not edit. */");

View File

@@ -78,7 +78,7 @@ public class NpcManager
public void java(File java) throws IOException
{
java.mkdirs();
java.io.File targ = new java.io.File(java, "NpcID.java");
File targ = new File(java, "NpcID.java");
try (PrintWriter fw = new PrintWriter(targ))
{
fw.println("/* This file is automatically generated. Do not edit. */");

View File

@@ -83,7 +83,7 @@ public class ObjectManager
public void java(File java) throws IOException
{
java.mkdirs();
java.io.File targ = new java.io.File(java, "ObjectID.java");
File targ = new File(java, "ObjectID.java");
try (PrintWriter fw = new PrintWriter(targ))
{
fw.println("/* This file is automatically generated. Do not edit. */");

View File

@@ -0,0 +1,128 @@
/*
* 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 class InterfaceDefinition
{
public int id = -1;
public boolean hasScript = true;
public int type;
public int contentType;
public int originalX;
public int originalY;
public int originalWidth;
public int field2231;
public int field2226;
public int field2227;
public int field2351;
public int field2217;
public int parentId = -1;
public boolean isHidden;
public int scrollWidth;
public int scrollHeight;
public boolean field2210;
public int textureId;
public int field2294;
public boolean field2257;
public int opacity;
public int borderThickness;
public int sprite2;
public boolean flippedVertically;
public boolean flippedHorizontally;
public int modelType;
public int modelId;
public int field2268;
public int field2269;
public int rotationX;
public int rotationY;
public int rotationZ;
public int field2320;
public int field2266;
public boolean field2296;
public int field2274;
public int fontId;
public String text;
public int field2212;
public int field2219;
public int field2283;
public boolean field2298;
public int textColor;
public boolean field2267;
public int field2218;
public boolean field2253;
public int field2291;
public String name;
public String[] actions;
public int field2295;
public int field2223;
public boolean field2297;
public String field2328;
public Object[] field2225;
public Object[] field2300;
public Object[] field2248;
public Object[] field2311;
public Object[] field2350;
public Object[] field2312;
public Object[] field2314;
public Object[] field2316;
public Object[] field2318;
public Object[] field2319;
public Object[] field2306;
public Object[] field2337;
public Object[] field2287;
public Object[] field2303;
public Object[] field2304;
public Object[] field2308;
public Object[] field2310;
public Object[] field2262;
public int[] field2313;
public int[] field2315;
public int[] field2282;
public boolean field2299;
public int field2222;
public int field2334;
public int[] field2224;
public int[] field2333;
public int[][] dynamicValues;
public int[] itemIds;
public int[] itemQuantities;
public int field2285;
public int field2286;
public int[] field2340;
public int[] field2288;
public int[] field2289;
public String[] field2336;
public String field2241;
public int field2245;
public int field2280;
public int field2247;
public int field2332;
public int field2264;
public int field2265;
public int field2276;
public String field2335;
public String tooltip;
}

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,554 @@
/*
* 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.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)
{
method3252(iface, new InputStream(b));
}
else
{
method3251(iface, new InputStream(b));
}
return iface;
}
private void method3251(InterfaceDefinition iface, InputStream var1)
{
iface.hasScript = false;
iface.type = var1.readUnsignedByte();
iface.field2222 = var1.readUnsignedByte();
iface.contentType = var1.readUnsignedShort();
iface.originalX = var1.readShort();
iface.originalY = var1.readShort();
iface.originalWidth = var1.readUnsignedShort();
iface.field2231 = var1.readUnsignedShort();
iface.opacity = var1.readUnsignedByte();
iface.parentId = var1.readUnsignedShort();
if (iface.parentId == '\uffff')
{
iface.parentId = -1;
}
else
{
iface.parentId += iface.id & -65536;
}
iface.field2334 = var1.readUnsignedShort();
if (iface.field2334 == '\uffff')
{
iface.field2334 = -1;
}
int var2 = var1.readUnsignedByte();
int var3;
if (var2 > 0)
{
iface.field2224 = new int[var2];
iface.field2333 = new int[var2];
for (var3 = 0; var3 < var2; ++var3)
{
iface.field2224[var3] = var1.readUnsignedByte();
iface.field2333[var3] = var1.readUnsignedShort();
}
}
var3 = var1.readUnsignedByte();
int var4;
int var5;
int var6;
if (var3 > 0)
{
iface.dynamicValues = new int[var3][];
for (var4 = 0; var4 < var3; ++var4)
{
var5 = var1.readUnsignedShort();
iface.dynamicValues[var4] = new int[var5];
for (var6 = 0; var6 < var5; ++var6)
{
iface.dynamicValues[var4][var6] = var1.readUnsignedShort();
if (iface.dynamicValues[var4][var6] == '\uffff')
{
iface.dynamicValues[var4][var6] = -1;
}
}
}
}
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.field2231];
iface.itemQuantities = new int[iface.field2231 * iface.originalWidth];
var4 = var1.readUnsignedByte();
if (var4 == 1)
{
iface.field2291 |= 268435456;
}
var5 = var1.readUnsignedByte();
if (var5 == 1)
{
iface.field2291 |= 1073741824;
}
var6 = var1.readUnsignedByte();
if (var6 == 1)
{
iface.field2291 |= Integer.MIN_VALUE;
}
int var7 = var1.readUnsignedByte();
if (var7 == 1)
{
iface.field2291 |= 536870912;
}
iface.field2285 = var1.readUnsignedByte();
iface.field2286 = var1.readUnsignedByte();
iface.field2340 = new int[20];
iface.field2288 = new int[20];
iface.field2289 = new int[20];
int var8;
for (var8 = 0; var8 < 20; ++var8)
{
int var9 = var1.readUnsignedByte();
if (var9 == 1)
{
iface.field2340[var8] = var1.readShort();
iface.field2288[var8] = var1.readShort();
iface.field2289[var8] = var1.readInt();
}
else
{
iface.field2289[var8] = -1;
}
}
iface.field2336 = new String[5];
for (var8 = 0; var8 < 5; ++var8)
{
String var11 = var1.readString();
if (var11.length() > 0)
{
iface.field2336[var8] = var11;
iface.field2291 |= 1 << var8 + 23;
}
}
}
if (iface.type == 3)
{
iface.field2267 = var1.readUnsignedByte() == 1;
}
if (iface.type == 4 || iface.type == 1)
{
iface.field2219 = var1.readUnsignedByte();
iface.field2283 = var1.readUnsignedByte();
iface.field2212 = var1.readUnsignedByte();
iface.fontId = var1.readUnsignedShort();
if (iface.fontId == '\uffff')
{
iface.fontId = -1;
}
iface.field2298 = var1.readUnsignedByte() == 1;
}
if (iface.type == 4)
{
iface.text = var1.readString();
iface.field2241 = var1.readString();
}
if (iface.type == 1 || iface.type == 3 || iface.type == 4)
{
iface.textColor = var1.readInt();
}
if (iface.type == 3 || iface.type == 4)
{
iface.field2245 = var1.readInt();
iface.field2280 = var1.readInt();
iface.field2247 = var1.readInt();
}
if (iface.type == 5)
{
iface.textureId = var1.readInt();
iface.field2332 = var1.readInt();
}
if (iface.type == 6)
{
iface.modelType = 1;
iface.modelId = var1.readUnsignedShort();
if (iface.modelId == '\uffff')
{
iface.modelId = -1;
}
iface.field2264 = 1;
iface.field2265 = var1.readUnsignedShort();
if (iface.field2265 == '\uffff')
{
iface.field2265 = -1;
}
iface.field2266 = var1.readUnsignedShort();
if (iface.field2266 == '\uffff')
{
iface.field2266 = -1;
}
iface.field2276 = var1.readUnsignedShort();
if (iface.field2276 == '\uffff')
{
iface.field2276 = -1;
}
iface.field2320 = var1.readUnsignedShort();
iface.rotationX = var1.readUnsignedShort();
iface.rotationZ = var1.readUnsignedShort();
}
if (iface.type == 7)
{
iface.itemIds = new int[iface.originalWidth * iface.field2231];
iface.itemQuantities = new int[iface.originalWidth * iface.field2231];
iface.field2219 = var1.readUnsignedByte();
iface.fontId = var1.readUnsignedShort();
if (iface.fontId == '\uffff')
{
iface.fontId = -1;
}
iface.field2298 = var1.readUnsignedByte() == 1;
iface.textColor = var1.readInt();
iface.field2285 = var1.readShort();
iface.field2286 = var1.readShort();
var4 = var1.readUnsignedByte();
if (var4 == 1)
{
iface.field2291 |= 1073741824;
}
iface.field2336 = new String[5];
for (var5 = 0; var5 < 5; ++var5)
{
String var10 = var1.readString();
if (var10.length() > 0)
{
iface.field2336[var5] = var10;
iface.field2291 |= 1 << var5 + 23;
}
}
}
if (iface.type == 8)
{
iface.text = var1.readString();
}
if (iface.field2222 == 2 || iface.type == 2)
{
iface.field2328 = var1.readString();
iface.field2335 = var1.readString();
var4 = var1.readUnsignedShort() & 63;
iface.field2291 |= var4 << 11;
}
if (iface.field2222 == 1 || iface.field2222 == 4 || iface.field2222 == 5 || iface.field2222 == 6)
{
iface.tooltip = var1.readString();
if (iface.tooltip.length() == 0)
{
if (iface.field2222 == 1)
{
iface.tooltip = "Ok";
}
if (iface.field2222 == 4)
{
iface.tooltip = "Select";
}
if (iface.field2222 == 5)
{
iface.tooltip = "Select";
}
if (iface.field2222 == 6)
{
iface.tooltip = "Continue";
}
}
}
if (iface.field2222 == 1 || iface.field2222 == 4 || iface.field2222 == 5)
{
iface.field2291 |= 4194304;
}
if (iface.field2222 == 6)
{
iface.field2291 |= 1;
}
}
private void method3252(InterfaceDefinition iface, InputStream var1)
{
var1.readUnsignedByte();
iface.hasScript = 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.field2231 = var1.readShort();
}
else
{
iface.field2231 = var1.readUnsignedShort();
}
iface.field2226 = var1.readByte();
iface.field2227 = var1.readByte();
iface.field2351 = var1.readByte();
iface.field2217 = var1.readByte();
iface.parentId = var1.readUnsignedShort();
if (iface.parentId == '\uffff')
{
iface.parentId = -1;
}
else
{
iface.parentId += iface.id & -65536;
}
iface.isHidden = var1.readUnsignedByte() == 1;
if (iface.type == 0)
{
iface.scrollWidth = var1.readUnsignedShort();
iface.scrollHeight = var1.readUnsignedShort();
iface.field2210 = var1.readUnsignedByte() == 1;
}
if (iface.type == 5)
{
iface.textureId = var1.readInt();
iface.field2294 = var1.readUnsignedShort();
iface.field2257 = var1.readUnsignedByte() == 1;
iface.opacity = var1.readUnsignedByte();
iface.borderThickness = var1.readUnsignedByte();
iface.sprite2 = 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 == '\uffff')
{
iface.modelId = -1;
}
iface.field2268 = var1.readShort();
iface.field2269 = var1.readShort();
iface.rotationX = var1.readUnsignedShort();
iface.rotationZ = var1.readUnsignedShort();
iface.rotationY = var1.readUnsignedShort();
iface.field2320 = var1.readUnsignedShort();
iface.field2266 = var1.readUnsignedShort();
if (iface.field2266 == '\uffff')
{
iface.field2266 = -1;
}
iface.field2296 = var1.readUnsignedByte() == 1;
var1.readUnsignedShort();
if (iface.field2226 != 0)
{
iface.field2274 = var1.readUnsignedShort();
}
if (iface.field2227 != 0)
{
var1.readUnsignedShort();
}
}
if (iface.type == 4)
{
iface.fontId = var1.readUnsignedShort();
if (iface.fontId == '\uffff')
{
iface.fontId = -1;
}
iface.text = var1.readString();
iface.field2212 = var1.readUnsignedByte();
iface.field2219 = var1.readUnsignedByte();
iface.field2283 = var1.readUnsignedByte();
iface.field2298 = var1.readUnsignedByte() == 1;
iface.textColor = var1.readInt();
}
if (iface.type == 3)
{
iface.textColor = var1.readInt();
iface.field2267 = var1.readUnsignedByte() == 1;
iface.opacity = var1.readUnsignedByte();
}
if (iface.type == 9)
{
iface.field2218 = var1.readUnsignedByte();
iface.textColor = var1.readInt();
iface.field2253 = var1.readUnsignedByte() == 1;
}
iface.field2291 = 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.field2295 = var1.readUnsignedByte();
iface.field2223 = var1.readUnsignedByte();
iface.field2297 = var1.readUnsignedByte() == 1;
iface.field2328 = var1.readString();
iface.field2225 = this.method3282(iface, var1);
iface.field2300 = this.method3282(iface, var1);
iface.field2248 = this.method3282(iface, var1);
iface.field2311 = this.method3282(iface, var1);
iface.field2350 = this.method3282(iface, var1);
iface.field2312 = this.method3282(iface, var1);
iface.field2314 = this.method3282(iface, var1);
iface.field2316 = this.method3282(iface, var1);
iface.field2318 = this.method3282(iface, var1);
iface.field2319 = this.method3282(iface, var1);
iface.field2306 = this.method3282(iface, var1);
iface.field2337 = this.method3282(iface, var1);
iface.field2287 = this.method3282(iface, var1);
iface.field2303 = this.method3282(iface, var1);
iface.field2304 = this.method3282(iface, var1);
iface.field2308 = this.method3282(iface, var1);
iface.field2310 = this.method3282(iface, var1);
iface.field2262 = this.method3282(iface, var1);
iface.field2313 = this.method3274(var1);
iface.field2315 = this.method3274(var1);
iface.field2282 = this.method3274(var1);
}
private Object[] method3282(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.field2299 = true;
return var3;
}
}
private int[] method3274(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,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;
import java.io.File;
import java.io.IOException;
import net.runelite.cache.fs.Store;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InterfaceManagerTest
{
private static final Logger logger = LoggerFactory.getLogger(InterfaceManagerTest.class);
@Rule
public TemporaryFolder folder = StoreLocation.getTemporaryFolder();
@Test
public void test() throws IOException
{
File dumpDir = folder.newFolder(),
javaDir = folder.newFolder();
Store store = new Store(StoreLocation.LOCATION);
store.load();
InterfaceManager dumper = new InterfaceManager(
store
);
dumper.load();
dumper.export(dumpDir);
dumper.java(javaDir);
logger.info("Dumped to {}, java {}", dumpDir, javaDir);
}
}