use of net.runelite.cache.io.InputStream in project runelite by runelite.
the class IndexData method load.
public void load(byte[] data) {
InputStream stream = new InputStream(data);
protocol = stream.readUnsignedByte();
if (protocol < 5 || protocol > 7) {
throw new IllegalArgumentException("Unsupported protocol");
}
if (protocol >= 6) {
this.revision = stream.readInt();
}
int hash = stream.readUnsignedByte();
named = (1 & hash) != 0;
if ((hash & ~1) != 0) {
throw new IllegalArgumentException("Unknown flags");
}
assert (hash & ~3) == 0;
int validArchivesCount = protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
int lastArchiveId = 0;
archives = new ArchiveData[validArchivesCount];
for (int index = 0; index < validArchivesCount; ++index) {
int archive = lastArchiveId += protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
ArchiveData ad = new ArchiveData();
ad.id = archive;
archives[index] = ad;
}
if (named) {
for (int index = 0; index < validArchivesCount; ++index) {
int nameHash = stream.readInt();
ArchiveData ad = archives[index];
ad.nameHash = nameHash;
}
}
for (int index = 0; index < validArchivesCount; ++index) {
int crc = stream.readInt();
ArchiveData ad = archives[index];
ad.crc = crc;
}
for (int index = 0; index < validArchivesCount; ++index) {
int revision = stream.readInt();
ArchiveData ad = archives[index];
ad.revision = revision;
}
int[] numberOfFiles = new int[validArchivesCount];
for (int index = 0; index < validArchivesCount; ++index) {
int num = protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
numberOfFiles[index] = num;
}
for (int index = 0; index < validArchivesCount; ++index) {
ArchiveData ad = archives[index];
int num = numberOfFiles[index];
ad.files = new FileData[num];
int last = 0;
for (int i = 0; i < num; ++i) {
int fileId = last += protocol >= 7 ? stream.readBigSmart() : stream.readUnsignedShort();
FileData fd = ad.files[i] = new FileData();
fd.id = fileId;
}
}
if (named) {
for (int index = 0; index < validArchivesCount; ++index) {
ArchiveData ad = archives[index];
int num = numberOfFiles[index];
for (int i = 0; i < num; ++i) {
FileData fd = ad.files[i];
int name = stream.readInt();
fd.nameHash = name;
}
}
}
}
use of net.runelite.cache.io.InputStream in project runelite by runelite.
the class AreaLoader method load.
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;
}
use of net.runelite.cache.io.InputStream in project runelite by runelite.
the class FramemapLoader method load.
public FramemapDefinition load(int id, byte[] b) {
FramemapDefinition def = new FramemapDefinition();
InputStream in = new InputStream(b);
def.id = id;
def.length = in.readUnsignedByte();
def.field1456 = new int[def.length];
def.field1457 = new int[def.length][];
for (int i = 0; i < def.length; ++i) {
def.field1456[i] = in.readUnsignedByte();
}
for (int i = 0; i < def.length; ++i) {
def.field1457[i] = new int[in.readUnsignedByte()];
}
for (int i = 0; i < def.length; ++i) {
for (int j = 0; j < def.field1457[i].length; ++j) {
def.field1457[i][j] = in.readUnsignedByte();
}
}
return def;
}
Aggregations