Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • Striker Fox2: download it
      Today at 03:26:06 AM
    • Zezuma09: how do i get this game started ?
      October 22, 2017, 03:24:27 AM
    • Striker Fox2: Much more on General Board
      October 21, 2017, 04:30:25 AM
    • Striker Fox2: New price guide link [link]
      October 21, 2017, 04:30:18 AM
    • Striker Fox2: New discord link [link]
      October 21, 2017, 04:30:03 AM
    • Saltyspade10: If you are new and reading this, stick around becaus it's a great server and community! Hope to see you in-game :)
      October 21, 2017, 02:44:16 AM
    • damian6: hello i wanne buy this server can u add me
      October 20, 2017, 03:54:38 PM
    • Wilkooo: lol jks
      October 20, 2017, 02:39:53 PM
    • Wilkooo: ilyall
      October 20, 2017, 02:39:48 PM
    • tm4dz: why cant i see any download links??
      October 20, 2017, 10:46:55 AM
    • stCky: u dont need to its fudgeing sick
      October 19, 2017, 08:13:13 PM
    • odin stormborn: how do i change my username
      October 19, 2017, 12:16:51 PM
    • qazplm102938: everyone play manicps its best server out there loads to do its badboyyyy - manicps manicps shout out kiteshield
      October 19, 2017, 10:28:21 AM
    • qazplm102938: everyone play manicps its best server out there loads to do its badboyyyy - manicps manicps
      October 19, 2017, 10:11:08 AM
    • Travas: wtf
      October 19, 2017, 07:37:52 AM
    • stCky: Adaro, you are a threat to the communities image, yes
      October 18, 2017, 02:53:43 PM
    • Krackkid: Hello everyone it is I, Krackkid.
      October 18, 2017, 07:21:56 AM
    • soma_: Does anyone have an updated link to a blank Source / Client? 317/508
      October 18, 2017, 04:57:44 AM
    • michaeltrailer: olm t pst
      October 18, 2017, 04:52:48 AM
    • Adaro: Strange that staff think I'm a threat when I'm not threatening anyone
      October 18, 2017, 03:07:16 AM

    Author Topic: Adding an archive to the cache in config.jag  (Read 3219 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineAmbokile

    • Member
    • ****
    • Posts: 3,009
    • Thanks: +0/-0
      • View Profile
    Adding an archive to the cache in config.jag
    « on: June 05, 2015, 08:26:36 AM »
    I have a file, "file.dat", that I want to put into the config.jag archive. Whenever I add the file into the archive using Tom's Cache Suite, the client then fails to load.

    Can anyone link me to some information on how to correctly add new files into the cache?


    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Adding an archive to the cache in config.jag
    « Reply #1 on: June 05, 2015, 01:51:15 PM »
    Code: [Select]
    package io.eve.tinker;

    import io.eve.tinker.bzip.HBZip2InputStream;

    import java.io.ByteArrayInputStream;
    import java.io.IOException;

    /**
     * Created by hadyn on 5/21/2015.
     */
    public class Archive {

        private int[] packedLengths;
        private int[] unpackedLengths;
        private int[] offsets;
        private int[] names;
        private int size;
        private byte[] bytes;
        private boolean packedEntries;

        public Archive(byte[] data) throws IOException {
            Buffer buffer = new Buffer(data);
            int unpackedLength = buffer.getUInt24();
            int packedLength = buffer.getUInt24();
            if(unpackedLength != packedLength) {
                byte[] unpacked = new byte[unpackedLength];
                HBZip2InputStream is = new HBZip2InputStream(new ByteArrayInputStream(data, 6, data.length - 6));
                int off = 0;
                while (off < packedLength){
                    off += is.read(unpacked, off, packedLength - off);
                }
                buffer = new Buffer(unpacked);
                bytes = unpacked;
                packedEntries = false;
            } else {
                bytes = data;
                packedEntries = true;
            }

            size = buffer.getUInt16();
            names = new int[size];
            offsets = new int[size];
            unpackedLengths = new int[size];
            packedLengths = new int[size];

            int off = buffer.position() + size * 10;

            for(int i = 0; i < size; i++) {
                names[i] = buffer.getInt32();
                unpackedLengths[i] = buffer.getUInt24();
                packedLengths[i] = buffer.getUInt24();
                offsets[i] = off;
                off += packedLengths[i];
            }
        }

        public int getName(int i) {
            return names[i];
        }

        public byte[] get(int i) throws IOException {
            if(i < 0 || i >= size) {
                throw new ArrayIndexOutOfBoundsException(i);
            }
            byte[] unpacked = new byte[unpackedLengths[i]];
            if(packedEntries) {
                HBZip2InputStream is = new HBZip2InputStream(new ByteArrayInputStream(bytes, offsets[i], packedLengths[i]));
                int off = 0;
                while (off < unpackedLengths[i]){
                    off += is.read(unpacked, off, unpackedLengths[i] - off);
                }
            } else {
                System.arraycopy(bytes, offsets[i], unpacked, 0, unpackedLengths[i]);
            }
            return unpacked;
        }

        public int size() {
            return size;
        }
    }


    Pretty much:

    - Increment the amount of entries
    - If the entire archive is compressed (headerless BZIP 2 blocksize = 1) then just decompress ALL the entries, append it, compress
    - If the individual entries are compressed then compress it, append to the end of the archive
    - Append the size
    - Append the name (hashed)

    OfflineAmbokile

    • Member
    • ****
    • Posts: 3,009
    • Thanks: +0/-0
      • View Profile
    Re: Adding an archive to the cache in config.jag
    « Reply #2 on: June 06, 2015, 08:37:11 AM »
    Thanks for that Hadyn. I'm currently loading my extra file just from a .dat file in the cache folder but I'd like to be able to pack it into the cache for cleanliness.

    Do you think it would be easier to pack an extra file into the archive or to create a new archive?

    Offlinesini

    • Member
    • ****
    • *
    • *
    • Posts: 5,785
    • Thanks: +0/-0
      • View Profile
    Re: Adding an archive to the cache in config.jag
    « Reply #3 on: June 06, 2015, 09:15:21 PM »
    Inserting it isn't tough, just takes a few calculations and the specification isn't really too friendly for repacking existing binary entries unless you have the original files and packer. Which we obviously don't.

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal