Search in sources :

Example 1 with IndexedFileSystem

use of org.apollo.cache.IndexedFileSystem 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 IndexedFileSystem

use of org.apollo.cache.IndexedFileSystem in project apollo by apollo-rsps.

the class Server method init.

/**
 * Initialises the server.
 *
 * @param releaseName The class name of the current active {@link Release}.
 * @throws Exception If an error occurs.
 */
public void init(String releaseName) throws Exception {
    Class<?> clazz = Class.forName(releaseName);
    Release release = (Release) clazz.newInstance();
    int version = release.getReleaseNumber();
    logger.info("Initialized " + release + ".");
    serviceBootstrap.group(loopGroup);
    httpBootstrap.group(loopGroup);
    jaggrabBootstrap.group(loopGroup);
    World world = new World();
    ServiceManager services = new ServiceManager(world);
    IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs", Integer.toString(version)), true);
    ServerContext context = new ServerContext(release, services, fs);
    ApolloHandler handler = new ApolloHandler(context);
    ChannelInitializer<SocketChannel> service = new ServiceChannelInitializer(handler);
    serviceBootstrap.channel(NioServerSocketChannel.class);
    serviceBootstrap.childHandler(service);
    ChannelInitializer<SocketChannel> http = new HttpChannelInitializer(handler);
    httpBootstrap.channel(NioServerSocketChannel.class);
    httpBootstrap.childHandler(http);
    ChannelInitializer<SocketChannel> jaggrab = new JagGrabChannelInitializer(handler);
    jaggrabBootstrap.channel(NioServerSocketChannel.class);
    jaggrabBootstrap.childHandler(jaggrab);
    PluginManager manager = new PluginManager(world, new PluginContext(context));
    services.startAll();
    world.init(version, fs, manager);
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) ServiceChannelInitializer(org.apollo.net.ServiceChannelInitializer) PluginContext(org.apollo.game.plugin.PluginContext) World(org.apollo.game.model.World) PluginManager(org.apollo.game.plugin.PluginManager) HttpChannelInitializer(org.apollo.net.HttpChannelInitializer) IndexedFileSystem(org.apollo.cache.IndexedFileSystem) ApolloHandler(org.apollo.game.session.ApolloHandler) JagGrabChannelInitializer(org.apollo.net.JagGrabChannelInitializer) Release(org.apollo.net.release.Release)

Example 3 with IndexedFileSystem

use of org.apollo.cache.IndexedFileSystem in project apollo by apollo-rsps.

the class UpdateService method start.

@Override
public void start() {
    int release = context.getRelease().getReleaseNumber();
    try {
        Path base = Paths.get("data/fs/", Integer.toString(release));
        for (int i = 0; i < THREADS_PER_TYPE; i++) {
            workers.add(new JagGrabRequestWorker(dispatcher, new IndexedFileSystem(base, true)));
            workers.add(new OnDemandRequestWorker(dispatcher, new IndexedFileSystem(base, true)));
            workers.add(new HttpRequestWorker(dispatcher, new IndexedFileSystem(base, true)));
        }
    } catch (FileNotFoundException reason) {
        logger.log(Level.SEVERE, "Unable to find index or data files from the file system.", reason);
    }
    workers.forEach(service::submit);
}
Also used : Path(java.nio.file.Path) HttpRequestWorker(org.apollo.net.update.HttpRequestWorker) JagGrabRequestWorker(org.apollo.net.update.JagGrabRequestWorker) OnDemandRequestWorker(org.apollo.net.update.OnDemandRequestWorker) FileNotFoundException(java.io.FileNotFoundException) IndexedFileSystem(org.apollo.cache.IndexedFileSystem)

Aggregations

IndexedFileSystem (org.apollo.cache.IndexedFileSystem)3 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 BufferedOutputStream (java.io.BufferedOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 Path (java.nio.file.Path)1 ItemDefinitionDecoder (org.apollo.cache.decoder.ItemDefinitionDecoder)1 ItemDefinition (org.apollo.cache.def.ItemDefinition)1 World (org.apollo.game.model.World)1 PluginContext (org.apollo.game.plugin.PluginContext)1 PluginManager (org.apollo.game.plugin.PluginManager)1 ApolloHandler (org.apollo.game.session.ApolloHandler)1 HttpChannelInitializer (org.apollo.net.HttpChannelInitializer)1 JagGrabChannelInitializer (org.apollo.net.JagGrabChannelInitializer)1 ServiceChannelInitializer (org.apollo.net.ServiceChannelInitializer)1 Release (org.apollo.net.release.Release)1 HttpRequestWorker (org.apollo.net.update.HttpRequestWorker)1 JagGrabRequestWorker (org.apollo.net.update.JagGrabRequestWorker)1