Skip to content

Commit

Permalink
Merge pull request runelite#55 from kfricilone/cache/defs-update
Browse files Browse the repository at this point in the history
Thanks
  • Loading branch information
Adam- authored May 8, 2017
2 parents c64fb00 + c532640 commit 2f3073e
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
package net.runelite.cache.definitions;

import java.util.Map;

public class ItemDefinition
{
public int id;
Expand Down Expand Up @@ -96,6 +98,8 @@ public class ItemDefinition
public int placeholderId = -1;
public int placeholderTemplateId = -1;

public Map<Integer, Object> params = null;

public ItemDefinition(int definitionID)
{
this.id = definitionID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package net.runelite.cache.definitions;

import java.util.Map;

public class NpcDefinition
{

Expand Down Expand Up @@ -54,13 +56,13 @@ public class NpcDefinition
public boolean hasRenderPriority = false;
public int ambient = 0;
public int headIcon = -1;
public int anInt2184 = 30;
public int[] anIntArray2185;
public short[] retextureToFind;
public int anInt2187 = -1;
public boolean isClickable = true;
public int anInt2189 = -1;
public boolean aBool2190 = false;
public Map<Integer, Object> params = null;

public NpcDefinition(int definitionID)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package net.runelite.cache.definitions;

import java.util.Map;

public class ObjectDefinition
{
private int id;
Expand Down Expand Up @@ -70,6 +72,7 @@ public class ObjectDefinition
private int anInt2112 = 0;
private int anInt2113 = 0;
private boolean aBool2114 = true;
private Map<Integer, Object> params = null;

public int getId()
{
Expand Down Expand Up @@ -500,4 +503,14 @@ 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;

public class ItemLoader
{
private static final Logger logger = LoggerFactory.getLogger(ItemLoader.class);
Expand Down Expand Up @@ -254,6 +256,31 @@ 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;

public class NpcLoader
{
private static final Logger logger = LoggerFactory.getLogger(NpcLoader.class);
Expand Down Expand Up @@ -190,11 +192,11 @@ else if (opcode == 106)
def.anInt2187 = stream.readUnsignedShort();
if ('\uffff' == def.anInt2187)
{
def.anInt2187 = -40212193;
def.anInt2187 = -1;
}

length = stream.readUnsignedByte();
def.anIntArray2185 = new int[length + 1];
def.anIntArray2185 = new int[length + 2];

for (index = 0; index <= length; ++index)
{
Expand All @@ -205,6 +207,8 @@ else if (opcode == 106)
}
}

def.anIntArray2185[length + 1] = -1;

}
else if (107 == opcode)
{
Expand All @@ -218,9 +222,64 @@ else if (opcode == 111)
{
def.aBool2190 = true;
}
else if (opcode == 112)
else if (opcode == 118)
{
def.anInt2184 = stream.readUnsignedByte();
def.anInt2174 = stream.readUnsignedShort();
if ('\uffff' == def.anInt2174)
{
def.anInt2174 = -1;
}

def.anInt2187 = stream.readUnsignedShort();
if ('\uffff' == def.anInt2187)
{
def.anInt2187 = -1;
}

int var = stream.readUnsignedShort();
if (var == 0xFFFF)
{
var = -1;
}

length = stream.readUnsignedByte();
def.anIntArray2185 = new int[length + 2];

for (index = 0; index <= length; ++index)
{
def.anIntArray2185[index] = stream.readUnsignedShort();
if (def.anIntArray2185[index] == '\uffff')
{
def.anIntArray2185[index] = -1;
}
}

def.anIntArray2185[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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class ObjectLoader
{
private static final Logger logger = LoggerFactory.getLogger(ObjectLoader.class);
Expand Down Expand Up @@ -263,7 +266,7 @@ else if (opcode == 77)
def.setConfigId(configId);

int length = is.readUnsignedByte();
int[] configChangeDest = new int[length + 1];
int[] configChangeDest = new int[length + 2];

for (int index = 0; index <= length; ++index)
{
Expand All @@ -274,6 +277,8 @@ else if (opcode == 77)
}
}

configChangeDest[length + 1] = -1;

def.setConfigChangeDest(configChangeDest);
}
else if (opcode == 78)
Expand All @@ -300,6 +305,71 @@ else if (opcode == 81)
{
def.setAnInt2105(is.readUnsignedByte());
}
else if (opcode == 92)
{
int varpID = is.readUnsignedShort();
if (varpID == 0xFFFF)
{
varpID = -1;
}
def.setVarpID(varpID);

int configId = is.readUnsignedShort();
if (configId == 0xFFFF)
{
configId = -1;
}
def.setConfigId(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);
Expand Down

0 comments on commit 2f3073e

Please sign in to comment.