cache: lombok definitions

This commit is contained in:
Adam
2017-12-28 21:03:44 -05:00
parent e9e7e2a180
commit 0cebc5ebe8
28 changed files with 185 additions and 975 deletions

6
cache/pom.xml vendored
View File

@@ -83,6 +83,12 @@
<artifactId>commons-cli</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>

View File

@@ -27,8 +27,6 @@ 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;
@@ -43,7 +41,7 @@ import net.runelite.cache.util.Namer;
public class InterfaceManager
{
private final Store store;
private final List<InterfaceDefinition> interfaces = new ArrayList<>();
private InterfaceDefinition[][] interfaces;
private final Namer namer = new Namer();
public InterfaceManager(Store store)
@@ -58,12 +56,21 @@ public class InterfaceManager
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();
@@ -71,12 +78,32 @@ public class InterfaceManager
int widgetId = (archiveId << 16) + fileId;
InterfaceDefinition iface = loader.load(widgetId, file.getContents());
interfaces.add(iface);
ifaces[fileId] = iface;
}
}
}
public List<InterfaceDefinition> getItems()
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;
}
@@ -85,12 +112,28 @@ public class InterfaceManager
{
out.mkdirs();
for (InterfaceDefinition def : interfaces)
for (InterfaceDefinition[] defs : interfaces)
{
InterfaceExporter exporter = new InterfaceExporter(def);
if (defs == null)
{
continue;
}
File targ = new File(out, def.id + ".json");
exporter.exportTo(targ);
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);
}
}
}
@@ -105,20 +148,27 @@ public class InterfaceManager
fw.println("package net.runelite.api;");
fw.println("");
fw.println("public final class InterfaceID {");
for (InterfaceDefinition def : interfaces)
for (InterfaceDefinition[] defs : interfaces)
{
if (def.name == null || def.name.equalsIgnoreCase("NULL"))
if (defs == null)
{
continue;
}
String name = namer.name(def.name, def.id);
if (name == null)
for (InterfaceDefinition def : defs)
{
continue;
}
if (def == null || def.name == null || def.name.equalsIgnoreCase("NULL"))
{
continue;
}
fw.println(" public static final int " + name + " = " + def.id + ";");
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

@@ -27,8 +27,10 @@ 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 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;
@@ -43,7 +45,7 @@ import net.runelite.cache.util.Namer;
public class ItemManager
{
private final Store store;
private final List<ItemDefinition> items = new ArrayList<>();
private final Map<Integer, ItemDefinition> items = new HashMap<>();
private final Namer namer = new Namer();
public ItemManager(Store store)
@@ -65,20 +67,25 @@ public class ItemManager
for (FSFile f : files.getFiles())
{
ItemDefinition def = loader.load(f.getFileId(), f.getContents());
items.add(def);
items.put(f.getFileId(), def);
}
}
public List<ItemDefinition> getItems()
public Collection<ItemDefinition> getItems()
{
return items;
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)
for (ItemDefinition def : items.values())
{
ItemExporter exporter = new ItemExporter(def);
@@ -99,7 +106,7 @@ public class ItemManager
fw.println("");
fw.println("public final class ItemID");
fw.println("{");
for (ItemDefinition def : items)
for (ItemDefinition def : items.values())
{
if (def.name.equalsIgnoreCase("NULL"))
{

View File

@@ -28,6 +28,7 @@ import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.runelite.cache.definitions.ObjectDefinition;
import net.runelite.cache.definitions.exporters.ObjectExporter;
@@ -71,7 +72,7 @@ public class ObjectManager
public List<ObjectDefinition> getObjects()
{
return objects;
return Collections.unmodifiableList(objects);
}
public void dump(File out) throws IOException

View File

@@ -25,6 +25,9 @@
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class EnumDefinition
{
private int id;
@@ -36,94 +39,4 @@ public class EnumDefinition
private int size;
private int[] keys;
private String[] stringVals;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public int[] getIntVals()
{
return intVals;
}
public void setIntVals(int[] intVals)
{
this.intVals = intVals;
}
public char getKeyType()
{
return keyType;
}
public void setKeyType(char keyType)
{
this.keyType = keyType;
}
public char getValType()
{
return valType;
}
public void setValType(char valType)
{
this.valType = valType;
}
public String getDefaultString()
{
return defaultString;
}
public void setDefaultString(String defaultString)
{
this.defaultString = defaultString;
}
public int getDefaultInt()
{
return defaultInt;
}
public void setDefaultInt(int defaultInt)
{
this.defaultInt = defaultInt;
}
public int getSize()
{
return size;
}
public void setSize(int size)
{
this.size = size;
}
public int[] getKeys()
{
return keys;
}
public void setKeys(int[] keys)
{
this.keys = keys;
}
public String[] getStringVals()
{
return stringVals;
}
public void setStringVals(String[] stringVals)
{
this.stringVals = stringVals;
}
}

View File

@@ -26,5 +26,6 @@ package net.runelite.cache.definitions;
public class InventoryDefinition
{
public int id;
public int size;
}

View File

@@ -25,10 +25,12 @@
package net.runelite.cache.definitions;
import java.util.Map;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class ItemDefinition
{
public int id;
public final int id;
public String name = "null";
@@ -99,9 +101,4 @@ public class ItemDefinition
public int placeholderTemplateId = -1;
public Map<Integer, Object> params = null;
public ItemDefinition(int definitionID)
{
this.id = definitionID;
}
}

View File

@@ -24,8 +24,13 @@
*/
package net.runelite.cache.definitions;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class KitDefinition
{
@Getter
private final int id;
public short[] recolorToReplace;
public short[] recolorToFind;
@@ -38,14 +43,4 @@ public class KitDefinition
-1, -1, -1, -1, -1
};
public boolean nonSelectable = false;
public KitDefinition(int id)
{
this.id = id;
}
public int getId()
{
return id;
}
}

View File

@@ -26,11 +26,13 @@
package net.runelite.cache.definitions;
import java.util.Map;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class NpcDefinition
{
public int id;
public final int id;
public short[] recolorToFind;
public int anInt2156 = 32;
public String name = "null";
@@ -63,9 +65,4 @@ public class NpcDefinition
public int anInt2189 = -1;
public boolean aBool2190 = false;
public Map<Integer, Object> params = null;
public NpcDefinition(int definitionID)
{
this.id = definitionID;
}
}

View File

@@ -26,7 +26,9 @@
package net.runelite.cache.definitions;
import java.util.Map;
import lombok.Data;
@Data
public class ObjectDefinition
{
private int id;
@@ -73,444 +75,4 @@ public class ObjectDefinition
private int anInt2113 = 0;
private boolean blocksProjectile = true;
private Map<Integer, Object> params = null;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public short[] getRetextureToFind()
{
return retextureToFind;
}
public void setRetextureToFind(short[] retextureToFind)
{
this.retextureToFind = retextureToFind;
}
public int getAnInt2069()
{
return anInt2069;
}
public void setAnInt2069(int anInt2069)
{
this.anInt2069 = anInt2069;
}
public boolean isIsSolid()
{
return isSolid;
}
public void setIsSolid(boolean isSolid)
{
this.isSolid = isSolid;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int[] getObjectModels()
{
return objectModels;
}
public void setObjectModels(int[] objectModels)
{
this.objectModels = objectModels;
}
public int[] getObjectTypes()
{
return objectTypes;
}
public void setObjectTypes(int[] objectTypes)
{
this.objectTypes = objectTypes;
}
public short[] getRecolorToFind()
{
return recolorToFind;
}
public void setRecolorToFind(short[] recolorToFind)
{
this.recolorToFind = recolorToFind;
}
public int getMapAreaId()
{
return mapAreaId;
}
public void setMapAreaId(int mapAreaId)
{
this.mapAreaId = mapAreaId;
}
public short[] getTextureToReplace()
{
return textureToReplace;
}
public void setTextureToReplace(short[] textureToReplace)
{
this.textureToReplace = textureToReplace;
}
public int getSizeX()
{
return sizeX;
}
public void setSizeX(int sizeX)
{
this.sizeX = sizeX;
}
public int getSizeY()
{
return sizeY;
}
public void setSizeY(int sizeY)
{
this.sizeY = sizeY;
}
public int getAnInt2083()
{
return anInt2083;
}
public void setAnInt2083(int anInt2083)
{
this.anInt2083 = anInt2083;
}
public int[] getAnIntArray2084()
{
return anIntArray2084;
}
public void setAnIntArray2084(int[] anIntArray2084)
{
this.anIntArray2084 = anIntArray2084;
}
public int getOffsetX()
{
return offsetX;
}
public void setOffsetX(int offsetX)
{
this.offsetX = offsetX;
}
public boolean isNonFlatShading()
{
return nonFlatShading;
}
public void setNonFlatShading(boolean nonFlatShading)
{
this.nonFlatShading = nonFlatShading;
}
public int getAnInt2088()
{
return anInt2088;
}
public void setAnInt2088(int anInt2088)
{
this.anInt2088 = anInt2088;
}
public int getAnimationID()
{
return animationID;
}
public void setAnimationID(int animationID)
{
this.animationID = animationID;
}
public int getVarpID()
{
return varpID;
}
public void setVarpID(int varpID)
{
this.varpID = varpID;
}
public int getAmbient()
{
return ambient;
}
public void setAmbient(int ambient)
{
this.ambient = ambient;
}
public int getContrast()
{
return contrast;
}
public void setContrast(int contrast)
{
this.contrast = contrast;
}
public String[] getActions()
{
return actions;
}
public void setActions(String[] actions)
{
this.actions = actions;
}
public int getAnInt2094()
{
return anInt2094;
}
public void setAnInt2094(int anInt2094)
{
this.anInt2094 = anInt2094;
}
public int getMapSceneID()
{
return mapSceneID;
}
public void setMapSceneID(int mapSceneID)
{
this.mapSceneID = mapSceneID;
}
public short[] getRecolorToReplace()
{
return recolorToReplace;
}
public void setRecolorToReplace(short[] recolorToReplace)
{
this.recolorToReplace = recolorToReplace;
}
public boolean isaBool2097()
{
return aBool2097;
}
public void setaBool2097(boolean aBool2097)
{
this.aBool2097 = aBool2097;
}
public int getModelSizeX()
{
return modelSizeX;
}
public void setModelSizeX(int modelSizeX)
{
this.modelSizeX = modelSizeX;
}
public int getModelSizeHeight()
{
return modelSizeHeight;
}
public void setModelSizeHeight(int modelSizeHeight)
{
this.modelSizeHeight = modelSizeHeight;
}
public int getModelSizeY()
{
return modelSizeY;
}
public void setModelSizeY(int modelSizeY)
{
this.modelSizeY = modelSizeY;
}
public int getObjectID()
{
return objectID;
}
public void setObjectID(int objectID)
{
this.objectID = objectID;
}
public int getOffsetHeight()
{
return offsetHeight;
}
public void setOffsetHeight(int offsetHeight)
{
this.offsetHeight = offsetHeight;
}
public int getOffsetY()
{
return offsetY;
}
public void setOffsetY(int offsetY)
{
this.offsetY = offsetY;
}
public boolean isaBool2104()
{
return aBool2104;
}
public void setaBool2104(boolean aBool2104)
{
this.aBool2104 = aBool2104;
}
public int getAnInt2105()
{
return anInt2105;
}
public void setAnInt2105(int anInt2105)
{
this.anInt2105 = anInt2105;
}
public int getAnInt2106()
{
return anInt2106;
}
public void setAnInt2106(int anInt2106)
{
this.anInt2106 = anInt2106;
}
public int[] getConfigChangeDest()
{
return configChangeDest;
}
public void setConfigChangeDest(int[] configChangeDest)
{
this.configChangeDest = configChangeDest;
}
public boolean isRotated()
{
return isRotated;
}
public void setIsRotated(boolean isRotated)
{
this.isRotated = isRotated;
}
public int getConfigId()
{
return configId;
}
public void setConfigId(int configId)
{
this.configId = configId;
}
public int getAnInt2110()
{
return anInt2110;
}
public void setAnInt2110(int anInt2110)
{
this.anInt2110 = anInt2110;
}
public boolean isaBool2111()
{
return aBool2111;
}
public void setaBool2111(boolean aBool2111)
{
this.aBool2111 = aBool2111;
}
public int getAnInt2112()
{
return anInt2112;
}
public void setAnInt2112(int anInt2112)
{
this.anInt2112 = anInt2112;
}
public int getAnInt2113()
{
return anInt2113;
}
public void setAnInt2113(int anInt2113)
{
this.anInt2113 = anInt2113;
}
public boolean isaBool2114()
{
return aBool2114;
}
public void setaBool2114(boolean aBool2114)
{
this.aBool2114 = aBool2114;
}
public Map<Integer, Object> getParams()
{
return params;
}
public void setParams(final Map<Integer, Object> params)
{
this.params = params;
}
}

View File

@@ -25,6 +25,9 @@
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class OverlayDefinition
{
private int id;
@@ -32,54 +35,4 @@ public class OverlayDefinition
private int texture = -1;
private int secondaryRgbColor = -1;
private boolean hideUnderlay = true;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public int getRgbColor()
{
return rgbColor;
}
public void setRgbColor(int rgbColor)
{
this.rgbColor = rgbColor;
}
public int getTexture()
{
return texture;
}
public void setTexture(int texture)
{
this.texture = texture;
}
public int getSecondaryRgbColor()
{
return secondaryRgbColor;
}
public void setSecondaryRgbColor(int secondaryRgbColor)
{
this.secondaryRgbColor = secondaryRgbColor;
}
public boolean isHideUnderlay()
{
return hideUnderlay;
}
public void setHideUnderlay(boolean hideUnderlay)
{
this.hideUnderlay = hideUnderlay;
}
}

View File

@@ -25,7 +25,9 @@
package net.runelite.cache.definitions;
import java.util.Map;
import lombok.Data;
@Data
public class ScriptDefinition
{
private int id;
@@ -37,94 +39,4 @@ public class ScriptDefinition
private int localIntCount;
private int localStringCount;
private Map<Integer, Integer>[] switches;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public int getIntStackCount()
{
return intStackCount;
}
public void setIntStackCount(int intStackCount)
{
this.intStackCount = intStackCount;
}
public int[] getInstructions()
{
return instructions;
}
public void setInstructions(int[] instructions)
{
this.instructions = instructions;
}
public int[] getIntOperands()
{
return intOperands;
}
public void setIntOperands(int[] intOperands)
{
this.intOperands = intOperands;
}
public String[] getStringOperands()
{
return stringOperands;
}
public void setStringOperands(String[] stringOperands)
{
this.stringOperands = stringOperands;
}
public int getLocalStringCount()
{
return localStringCount;
}
public void setLocalStringCount(int localStringCount)
{
this.localStringCount = localStringCount;
}
public int getStringStackCount()
{
return stringStackCount;
}
public void setStringStackCount(int stringStackCount)
{
this.stringStackCount = stringStackCount;
}
public int getLocalIntCount()
{
return localIntCount;
}
public void setLocalIntCount(int localIntCount)
{
this.localIntCount = localIntCount;
}
public Map<Integer, Integer>[] getSwitches()
{
return switches;
}
public void setSwitches(Map<Integer, Integer>[] switches)
{
this.switches = switches;
}
}

View File

@@ -24,8 +24,13 @@
*/
package net.runelite.cache.definitions;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class SequenceDefinition
{
@Getter
private final int id;
public int[] frameIDs;
public int[] field3048;
@@ -41,15 +46,4 @@ public class SequenceDefinition
public int replyMode = 2;
public int frameStep = -1;
public int priority = -1;
public SequenceDefinition(int id)
{
this.id = id;
}
public int getId()
{
return id;
}
}

View File

@@ -25,6 +25,9 @@
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class SpriteDefinition
{
private int id;
@@ -36,130 +39,4 @@ public class SpriteDefinition
private int[] pixels;
private int maxWidth;
private int maxHeight;
@Override
public int hashCode()
{
int hash = 7;
hash = 89 * hash + this.id;
hash = 89 * hash + this.frame;
return hash;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final SpriteDefinition other = (SpriteDefinition) obj;
if (this.id != other.id)
{
return false;
}
if (this.frame != other.frame)
{
return false;
}
return true;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public int getFrame()
{
return frame;
}
public void setFrame(int frame)
{
this.frame = frame;
}
public int getOffsetX()
{
return offsetX;
}
public void setOffsetX(int offsetX)
{
this.offsetX = offsetX;
}
public int getOffsetY()
{
return offsetY;
}
public void setOffsetY(int offsetY)
{
this.offsetY = offsetY;
}
public int getWidth()
{
return width;
}
public void setWidth(int width)
{
this.width = width;
}
public int getHeight()
{
return height;
}
public void setHeight(int height)
{
this.height = height;
}
public int[] getPixels()
{
return pixels;
}
public void setPixels(int[] pixels)
{
this.pixels = pixels;
}
public int getMaxWidth()
{
return maxWidth;
}
public void setMaxWidth(int maxWidth)
{
this.maxWidth = maxWidth;
}
public int getMaxHeight()
{
return maxHeight;
}
public void setMaxHeight(int maxHeight)
{
this.maxHeight = maxHeight;
}
}

View File

@@ -25,28 +25,11 @@
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class TextureDefinition
{
private int id;
private int[] fileIds;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public int[] getFileIds()
{
return fileIds;
}
public void setFileIds(int[] fileIds)
{
this.fileIds = fileIds;
}
}

View File

@@ -24,28 +24,11 @@
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class UnderlayDefinition
{
private int id;
private int color;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public int getColor()
{
return color;
}
public void setColor(int color)
{
this.color = color;
}
}

View File

@@ -24,50 +24,13 @@
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class VarbitDefinition
{
private int id;
private int index;
private int leastSignificantBit;
private int mostSignificantBit;
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public int getIndex()
{
return index;
}
public void setIndex(int index)
{
this.index = index;
}
public int getLeastSignificantBit()
{
return leastSignificantBit;
}
public void setLeastSignificantBit(int leastSignificantBit)
{
this.leastSignificantBit = leastSignificantBit;
}
public int getMostSignificantBit()
{
return mostSignificantBit;
}
public void setMostSignificantBit(int mostSignificantBit)
{
this.mostSignificantBit = mostSignificantBit;
}
}

View File

@@ -25,8 +25,10 @@
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;

View File

@@ -24,6 +24,9 @@
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class WorldMapType1 implements WorldMapTypeBase
{
public int field424;

View File

@@ -24,6 +24,9 @@
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class WorldMapType2 implements WorldMapTypeBase
{
public int field510;

View File

@@ -24,6 +24,9 @@
*/
package net.runelite.cache.definitions;
import lombok.Data;
@Data
public class WorldMapType3 implements WorldMapTypeBase
{
public int field376;

View File

@@ -29,9 +29,10 @@ import net.runelite.cache.io.InputStream;
public class InventoryLoader
{
public InventoryDefinition load(byte[] b)
public InventoryDefinition load(int id, byte[] b)
{
InventoryDefinition def = new InventoryDefinition();
def.id = id;
InputStream is = new InputStream(b);
while (true)

View File

@@ -101,7 +101,7 @@ public class ItemLoader
{
def.cost = stream.readInt();
}
else if (16 == opcode)
else if (opcode == 16)
{
def.members = true;
}

View File

@@ -58,7 +58,7 @@ public class NpcLoader
{
int length;
int index;
if (1 == opcode)
if (opcode == 1)
{
length = stream.readUnsignedByte();
def.models = new int[length];
@@ -69,11 +69,11 @@ public class NpcLoader
}
}
else if (2 == opcode)
else if (opcode == 2)
{
def.name = stream.readString();
}
else if (12 == opcode)
else if (opcode == 12)
{
def.tileSpacesOccupied = stream.readUnsignedByte();
}
@@ -85,7 +85,7 @@ public class NpcLoader
{
def.walkAnimation = stream.readUnsignedShort();
}
else if (15 == opcode)
else if (opcode == 15)
{
def.anInt2165 = stream.readUnsignedShort();
}
@@ -93,7 +93,7 @@ public class NpcLoader
{
def.anInt2189 = stream.readUnsignedShort();
}
else if (17 == opcode)
else if (opcode == 17)
{
def.walkAnimation = stream.readUnsignedShort();
def.rotate180Animation = stream.readUnsignedShort();
@@ -134,7 +134,7 @@ public class NpcLoader
}
}
else if (60 == opcode)
else if (opcode == 60)
{
length = stream.readUnsignedByte();
def.models_2 = new int[length];
@@ -149,15 +149,15 @@ public class NpcLoader
{
def.renderOnMinimap = false;
}
else if (95 == opcode)
else if (opcode == 95)
{
def.combatLevel = stream.readUnsignedShort();
}
else if (97 == opcode)
else if (opcode == 97)
{
def.resizeX = stream.readUnsignedShort();
}
else if (98 == opcode)
else if (opcode == 98)
{
def.resizeY = stream.readUnsignedShort();
}
@@ -165,11 +165,11 @@ public class NpcLoader
{
def.hasRenderPriority = true;
}
else if (100 == opcode)
else if (opcode == 100)
{
def.ambient = stream.readByte();
}
else if (101 == opcode)
else if (opcode == 101)
{
def.contrast = stream.readByte();
}
@@ -177,7 +177,7 @@ public class NpcLoader
{
def.headIcon = stream.readUnsignedShort();
}
else if (103 == opcode)
else if (opcode == 103)
{
def.anInt2156 = stream.readUnsignedShort();
}
@@ -210,7 +210,7 @@ public class NpcLoader
def.anIntArray2185[length + 1] = -1;
}
else if (107 == opcode)
else if (opcode == 107)
{
def.isClickable = false;
}

View File

@@ -128,7 +128,7 @@ public class ObjectLoader
}
else if (opcode == 23)
{
def.setaBool2111(true);
def.setABool2111(true);
}
else if (opcode == 24)
{
@@ -195,11 +195,11 @@ public class ObjectLoader
}
else if (opcode == 62)
{
def.setIsRotated(true);
def.setRotated(true);
}
else if (opcode == 64)
{
def.setaBool2097(false);
def.setABool2097(false);
}
else if (opcode == 65)
{
@@ -233,13 +233,13 @@ public class ObjectLoader
{
def.setOffsetY(is.readUnsignedShort());
}
else if (73 == opcode)
else if (opcode == 73)
{
def.setaBool2104(true);
def.setABool2104(true);
}
else if (74 == opcode)
else if (opcode == 74)
{
def.setIsSolid(true);
def.setSolid(true);
}
else if (opcode == 75)
{

View File

@@ -28,6 +28,10 @@ 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.LOAD_STRING;
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
{
@@ -37,12 +41,12 @@ public class ScriptLoader
InputStream in = new InputStream(b);
in.setOffset(in.getLength() - 2);
int scriptEndOffset = in.readUnsignedShort();
int switchLength = in.readUnsignedShort();
// 2 for scriptEndOffset + the k/v data + 12 for the param/vars/stack data
int endIdx = in.getLength() - 2 - scriptEndOffset - 12;
// 2 for switchLength + the switch data + 12 for the param/vars/stack data
int endIdx = in.getLength() - 2 - switchLength - 12;
in.setOffset(endIdx);
int paramCount = in.readInt();
int numOpcodes = in.readInt();
int localIntCount = in.readUnsignedShort();
int localStringCount = in.readUnsignedShort();
int intStackCount = in.readUnsignedShort();
@@ -77,29 +81,29 @@ public class ScriptLoader
in.setOffset(0);
in.readStringOrNull();
int[] instructions = new int[paramCount];
int[] intOperands = new int[paramCount];
String[] stringOperands = new String[paramCount];
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 var3;
for (int var6 = 0; in.getOffset() < endIdx; instructions[var6++] = var3)
int opcode;
for (int i = 0; in.getOffset() < endIdx; instructions[i++] = opcode)
{
var3 = in.readUnsignedShort();
if (var3 == 3)
opcode = in.readUnsignedShort();
if (opcode == LOAD_STRING)
{
stringOperands[var6] = in.readString();
stringOperands[i] = in.readString();
}
else if (var3 < 100 && 21 != var3 && 38 != var3 && 39 != var3)
else if (opcode < 100 && opcode != RETURN && opcode != POP_INT && opcode != POP_STRING)
{
intOperands[var6] = in.readInt();
intOperands[i] = in.readInt();
}
else
{
intOperands[var6] = in.readUnsignedByte();
intOperands[i] = in.readUnsignedByte();
}
}

View File

@@ -75,9 +75,9 @@ public class InventoryDumper
for (FSFile file : files.getFiles())
{
InventoryLoader loader = new InventoryLoader();
InventoryDefinition inv = loader.load(file.getContents());
InventoryDefinition inv = loader.load(file.getFileId(), file.getContents());
Files.write(gson.toJson(inv), new File(outDir, file.getFileId() + ".json"), Charset.defaultCharset());
Files.write(gson.toJson(inv), new File(outDir, inv.id + ".json"), Charset.defaultCharset());
++count;
}
}

View File

@@ -1 +1 @@
org.slf4j.simpleLogger.defaultLogLevel=info
org.slf4j.simpleLogger.defaultLogLevel=INFO