Search in sources :

Example 26 with InputStream

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;
            }
        }
    }
}
Also used : InputStream(net.runelite.cache.io.InputStream)

Example 27 with InputStream

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;
}
Also used : AreaDefinition(net.runelite.cache.definitions.AreaDefinition) InputStream(net.runelite.cache.io.InputStream)

Example 28 with InputStream

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;
}
Also used : InputStream(net.runelite.cache.io.InputStream) FramemapDefinition(net.runelite.cache.definitions.FramemapDefinition)

Aggregations

InputStream (net.runelite.cache.io.InputStream)28 Position (net.runelite.cache.region.Position)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 AreaDefinition (net.runelite.cache.definitions.AreaDefinition)1 EnumDefinition (net.runelite.cache.definitions.EnumDefinition)1 FrameDefinition (net.runelite.cache.definitions.FrameDefinition)1 FramemapDefinition (net.runelite.cache.definitions.FramemapDefinition)1 InterfaceDefinition (net.runelite.cache.definitions.InterfaceDefinition)1 InventoryDefinition (net.runelite.cache.definitions.InventoryDefinition)1 ItemDefinition (net.runelite.cache.definitions.ItemDefinition)1 KitDefinition (net.runelite.cache.definitions.KitDefinition)1 Tile (net.runelite.cache.definitions.MapDefinition.Tile)1 NpcDefinition (net.runelite.cache.definitions.NpcDefinition)1 ObjectDefinition (net.runelite.cache.definitions.ObjectDefinition)1 OverlayDefinition (net.runelite.cache.definitions.OverlayDefinition)1 ScriptDefinition (net.runelite.cache.definitions.ScriptDefinition)1 SequenceDefinition (net.runelite.cache.definitions.SequenceDefinition)1 SpotAnimDefinition (net.runelite.cache.definitions.SpotAnimDefinition)1