Search in sources :

Example 1 with ModelFileLoader

use of com.ostracker.cache.loaders.ModelFileLoader in project ostracker by OSTracker.

the class OSTracker method main.

/**
     * -s [version] = load a cache from the cache store.
     * If this argument isn't provided, it loads it from user.home/jagexcache/oldschool/LIVE
     *
     * -o = dump a file even if it has already been dumped
     */
public static void main(String[] args) {
    try {
        String sourceVersion = null;
        boolean overwriteFiles = false;
        for (int i = 0; i < args.length; i++) {
            switch(args[i]) {
                case "-s":
                    sourceVersion = args[i + 1];
                    break;
                case "-o":
                    overwriteFiles = true;
                    break;
            }
        }
        if (sourceVersion == null) {
            putHomeCacheInLiveStore();
        } else {
            putCacheInLiveStore(sourceVersion);
        }
        Store cacheStore = new Store(LIVE_CACHE_STORE);
        cacheStore.load();
        String worldHost = GameConnectionUtil.getBestWorldHost();
        RemoteCache remoteCache = new RemoteCache();
        remoteCache.connect(worldHost, GameConnectionUtil.GAME_PORT);
        remoteCache.shakeHands(GameConnectionUtil.getRevision(worldHost));
        remoteCache.download(cacheStore);
        remoteCache.close();
        cacheStore.save();
        cacheStore.close();
        // Reload cache to update file contents
        cacheStore = new Store(LIVE_CACHE_STORE);
        cacheStore.load();
        // Dump item definitions
        ItemFileLoader itemFileLoader = new ItemFileLoader(cacheStore);
        ItemDefinitionSerializer itemDefinitionSerializer = new ItemDefinitionSerializer(itemFileLoader);
        for (Integer itemId : itemFileLoader.getItemIds()) {
            itemDefinitionSerializer.dump(itemId, overwriteFiles);
        }
        // Dump NPC definitions
        NpcFileLoader npcFileLoader = new NpcFileLoader(cacheStore);
        NpcDefinitionSerializer npcDefinitionSerializer = new NpcDefinitionSerializer(npcFileLoader);
        for (Integer npcId : npcFileLoader.getNpcIds()) {
            npcDefinitionSerializer.dump(npcId, overwriteFiles);
        }
        // Dump models
        ModelFileLoader modelFileLoader = new ModelFileLoader(cacheStore);
        ModelConverter modelConverter = new ModelConverter(modelFileLoader);
        for (Integer modelId : modelFileLoader.getModelFiles().keySet()) {
            modelConverter.convert(modelId, overwriteFiles);
        }
        // Dump sprites
        SpriteDumper spriteDumper = new SpriteDumper(modelFileLoader);
        for (Integer spriteId : modelFileLoader.getSpriteFiles().keySet()) {
            spriteDumper.dump(spriteId, overwriteFiles);
        }
        int cacheVersion = CacheStoreUtil.getCacheVersion(cacheStore);
        cacheStore.close();
        putLiveCacheInCacheStore(cacheVersion);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ModelFileLoader(com.ostracker.cache.loaders.ModelFileLoader) Store(net.runelite.cache.fs.Store) ItemDefinitionSerializer(com.ostracker.cache.dumpers.ItemDefinitionSerializer) ItemFileLoader(com.ostracker.cache.loaders.ItemFileLoader) NpcDefinitionSerializer(com.ostracker.cache.dumpers.NpcDefinitionSerializer) ModelConverter(com.ostracker.cache.dumpers.ModelConverter) IOException(java.io.IOException) SpriteDumper(com.ostracker.cache.dumpers.SpriteDumper) RemoteCache(com.ostracker.cache.RemoteCache) NpcFileLoader(com.ostracker.cache.loaders.NpcFileLoader)

Aggregations

RemoteCache (com.ostracker.cache.RemoteCache)1 ItemDefinitionSerializer (com.ostracker.cache.dumpers.ItemDefinitionSerializer)1 ModelConverter (com.ostracker.cache.dumpers.ModelConverter)1 NpcDefinitionSerializer (com.ostracker.cache.dumpers.NpcDefinitionSerializer)1 SpriteDumper (com.ostracker.cache.dumpers.SpriteDumper)1 ItemFileLoader (com.ostracker.cache.loaders.ItemFileLoader)1 ModelFileLoader (com.ostracker.cache.loaders.ModelFileLoader)1 NpcFileLoader (com.ostracker.cache.loaders.NpcFileLoader)1 IOException (java.io.IOException)1 Store (net.runelite.cache.fs.Store)1