Search in sources :

Example 1 with ItemDefinitionDecoder

use of org.apollo.cache.decoder.ItemDefinitionDecoder in project apollo by apollo-rsps.

the class EquipmentUpdater method main.

/**
 * The entry point of the application.
 *
 * @param args The command line arguments.
 * @throws Exception If an error occurs.
 */
public static void main(String[] args) throws Exception {
    Preconditions.checkArgument(args.length == 1, "Usage:\njava -cp ... org.apollo.tools.EquipmentUpdater [release].");
    String release = args[0];
    try (DataOutputStream os = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("data/equipment-" + release + ".dat")));
        IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs/", release), true)) {
        ItemDefinitionDecoder decoder = new ItemDefinitionDecoder(fs);
        decoder.run();
        int count = ItemDefinition.count();
        os.writeShort(count);
        for (int id = 0; id < count; id++) {
            ItemDefinition definition = ItemDefinition.lookup(id);
            int type = getWeaponType(definition);
            os.writeByte(type);
            if (type != -1) {
                os.writeBoolean(isTwoHanded(definition));
                os.writeBoolean(isFullBody(definition));
                os.writeBoolean(isFullHat(definition));
                os.writeBoolean(isFullMask(definition));
                os.writeByte(getAttackRequirement(definition));
                os.writeByte(getStrengthRequirement(definition));
                os.writeByte(getDefenceRequirement(definition));
                os.writeByte(getRangedRequirement(definition));
                os.writeByte(getPrayerRequirement(definition));
                os.writeByte(getMagicRequirement(definition));
            }
        }
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) ItemDefinitionDecoder(org.apollo.cache.decoder.ItemDefinitionDecoder) FileOutputStream(java.io.FileOutputStream) ItemDefinition(org.apollo.cache.def.ItemDefinition) IndexedFileSystem(org.apollo.cache.IndexedFileSystem) BufferedOutputStream(java.io.BufferedOutputStream)

Example 2 with ItemDefinitionDecoder

use of org.apollo.cache.decoder.ItemDefinitionDecoder in project apollo by apollo-rsps.

the class World method init.

/**
 * Initialises the world by loading definitions from the specified file
 * system.
 *
 * @param release The release number.
 * @param fs The file system.
 * @param manager The plugin manager. TODO move this.
 * @throws Exception If there was a failure when loading plugins.
 */
public void init(int release, IndexedFileSystem fs, PluginManager manager) throws Exception {
    releaseNumber = release;
    SynchronousDecoder firstStageDecoder = new SynchronousDecoder(new NpcDefinitionDecoder(fs), new ItemDefinitionDecoder(fs), new ObjectDefinitionDecoder(fs), new MapIndexDecoder(fs), EquipmentDefinitionParser.fromFile("data/equipment-" + release + "" + ".dat"));
    firstStageDecoder.block();
    SynchronousDecoder secondStageDecoder = new SynchronousDecoder(new WorldObjectsDecoder(fs, this, regions), new WorldMapDecoder(fs, collisionManager));
    secondStageDecoder.block();
    // Build collision matrices for the first time
    collisionManager.build(false);
    regions.addRegionListener(new CollisionUpdateListener(collisionManager));
    // Must be exactly here because of ordering issues.
    npcMovement = new NpcMovementTask(collisionManager);
    scheduler.schedule(npcMovement);
    manager.start();
    commandDispatcher.init(manager.getAuthors());
    pluginManager = manager;
}
Also used : NpcMovementTask(org.apollo.game.scheduling.impl.NpcMovementTask) SynchronousDecoder(org.apollo.game.fs.decoder.SynchronousDecoder) NpcDefinitionDecoder(org.apollo.cache.decoder.NpcDefinitionDecoder) MapIndexDecoder(org.apollo.cache.map.MapIndexDecoder) WorldObjectsDecoder(org.apollo.game.fs.decoder.WorldObjectsDecoder) ItemDefinitionDecoder(org.apollo.cache.decoder.ItemDefinitionDecoder) WorldMapDecoder(org.apollo.game.fs.decoder.WorldMapDecoder) CollisionUpdateListener(org.apollo.game.model.area.collision.CollisionUpdateListener) ObjectDefinitionDecoder(org.apollo.cache.decoder.ObjectDefinitionDecoder)

Aggregations

ItemDefinitionDecoder (org.apollo.cache.decoder.ItemDefinitionDecoder)2 BufferedOutputStream (java.io.BufferedOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 IndexedFileSystem (org.apollo.cache.IndexedFileSystem)1 NpcDefinitionDecoder (org.apollo.cache.decoder.NpcDefinitionDecoder)1 ObjectDefinitionDecoder (org.apollo.cache.decoder.ObjectDefinitionDecoder)1 ItemDefinition (org.apollo.cache.def.ItemDefinition)1 MapIndexDecoder (org.apollo.cache.map.MapIndexDecoder)1 SynchronousDecoder (org.apollo.game.fs.decoder.SynchronousDecoder)1 WorldMapDecoder (org.apollo.game.fs.decoder.WorldMapDecoder)1 WorldObjectsDecoder (org.apollo.game.fs.decoder.WorldObjectsDecoder)1 CollisionUpdateListener (org.apollo.game.model.area.collision.CollisionUpdateListener)1 NpcMovementTask (org.apollo.game.scheduling.impl.NpcMovementTask)1