cache: load script key/value pairs too

This commit is contained in:
Adam
2017-05-07 14:38:07 -04:00
parent 4049785d63
commit e210cf6f1e
2 changed files with 42 additions and 9 deletions

View File

@@ -22,19 +22,21 @@
* (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;
public class ScriptDefinition
{
private int id;
private int intStackCount;
private int[] instructions;
private int[] intOperands;
private String[] stringOperands;
private int localStringCount;
private int stringStackCount;
private int localIntCount;
private int intStackCount;
private int[] instructions;
private int[] intOperands;
private String[] stringOperands;
private int localStringCount;
private int stringStackCount;
private int localIntCount;
private Map<Integer, Integer>[] attributes;
public int getId()
{
@@ -115,4 +117,14 @@ public class ScriptDefinition
{
this.localIntCount = localIntCount;
}
public Map<Integer, Integer>[] getAttributes()
{
return attributes;
}
public void setAttributes(Map<Integer, Integer>[] attributes)
{
this.attributes = attributes;
}
}

View File

@@ -24,6 +24,8 @@
*/
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;
@@ -46,7 +48,26 @@ public class ScriptLoader
int intStackCount = in.readUnsignedShort();
int stringStackCount = in.readUnsignedShort();
// XXX There are key/value pairs here
int attributeCount = in.readUnsignedByte();
if (attributeCount > 0)
{
Map<Integer, Integer>[] attributes = new Map[attributeCount];
def.setAttributes(attributes);
for (int i = 0; i < attributeCount; ++i)
{
attributes[i] = new HashMap<>();
int count = in.readUnsignedShort();
while (count-- > 0)
{
int key = in.readInt();
int value = in.readInt();
attributes[i].put(key, value);
}
}
}
def.setLocalIntCount(localIntCount);
def.setLocalStringCount(localStringCount);