Search in sources :

Example 1 with UnityVersion

use of info.ata4.junity.UnityVersion in project disunity by ata4.

the class BundleProps method read.

static void read(Path propsFile, Bundle bundle) throws IOException {
    BundleProps props;
    try (Reader reader = Files.newBufferedReader(propsFile, CHARSET)) {
        props = new Gson().fromJson(reader, BundleProps.class);
    }
    BundleHeader header = bundle.header();
    header.compressed(props.compressed);
    header.streamVersion(props.streamVersion);
    header.unityVersion(new UnityVersion(props.unityVersion));
    header.unityRevision(new UnityVersion(props.unityRevision));
    String bundleName = PathUtils.getBaseName(propsFile);
    Path bundleDir = propsFile.resolveSibling(bundleName);
    props.files.stream().map(bundleDir::resolve).forEach(file -> {
        bundle.entries().add(new BundleExternalEntry(file));
    });
}
Also used : Path(java.nio.file.Path) BundleExternalEntry(info.ata4.junity.bundle.BundleExternalEntry) BundleHeader(info.ata4.junity.bundle.BundleHeader) Reader(java.io.Reader) Gson(com.google.gson.Gson) UnityVersion(info.ata4.junity.UnityVersion)

Example 2 with UnityVersion

use of info.ata4.junity.UnityVersion in project disunity by ata4.

the class BundleHeader method read.

@Override
public void read(DataReader in) throws IOException {
    signature = in.readStringNull();
    streamVersion = in.readInt();
    unityVersion = new UnityVersion(in.readStringNull());
    unityRevision = new UnityVersion(in.readStringNull());
    if (signature.equals(SIGNATURE_FS)) {
        // FS signature
        // Expect streamVersion == 6
        completeFileSize = in.readLong();
        compressedDataHeaderSize = in.readInt();
        dataHeaderSize = in.readInt();
        flags = in.readInt();
        headerSize = (int) in.position();
        if ((flags & 0x80) == 0) {
            // The data header is part of the bundle header
            headerSize += compressedDataHeaderSize;
        }
    // else it's at the end of the file
    } else {
        // Web or Raw signature
        minimumStreamedBytes = in.readUnsignedInt();
        headerSize = in.readInt();
        numberOfLevelsToDownload = in.readInt();
        int numberOfLevels = in.readInt();
        levelByteEnd.clear();
        for (int i = 0; i < numberOfLevels; i++) {
            levelByteEnd.add(new ImmutablePair(in.readUnsignedInt(), in.readUnsignedInt()));
        }
        if (streamVersion >= 2) {
            completeFileSize = in.readUnsignedInt();
        }
        if (streamVersion >= 3) {
            dataHeaderSize = in.readUnsignedInt();
        }
        in.readByte();
    }
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) UnityVersion(info.ata4.junity.UnityVersion)

Example 3 with UnityVersion

use of info.ata4.junity.UnityVersion in project disunity by ata4.

the class BundleInfo method buildHeaderTable.

private Table<Integer, Integer, Object> buildHeaderTable(BundleHeader header) {
    TableBuilder table = new TableBuilder();
    table.row("Field", "Value");
    table.row("signature", header.signature());
    table.row("streamVersion", header.streamVersion());
    table.row("unityVersion", header.unityVersion());
    table.row("unityRevision", header.unityRevision());
    table.row("minimumStreamedBytes", header.minimumStreamedBytes());
    table.row("headerSize", header.headerSize());
    table.row("numberOfLevelsToDownload", header.numberOfLevelsToDownload());
    table.row("numberOfLevels", header.numberOfLevels());
    List<Pair<Long, Long>> levelByteEnds = header.levelByteEnd();
    for (int i = 0; i < levelByteEnds.size(); i++) {
        Pair<Long, Long> levelByteEnd = levelByteEnds.get(i);
        table.row("levelByteEnd[" + i + "][0]", levelByteEnd.getLeft());
        table.row("levelByteEnd[" + i + "][1]", levelByteEnd.getRight());
    }
    if (header.streamVersion() >= 2) {
        table.row("completeFileSize", header.completeFileSize());
    }
    if (header.streamVersion() >= 3) {
        table.row("dataHeaderSize", header.dataHeaderSize());
    }
    return table.get();
}
Also used : TableBuilder(info.ata4.disunity.cli.util.TableBuilder) Pair(org.apache.commons.lang3.tuple.Pair)

Example 4 with UnityVersion

use of info.ata4.junity.UnityVersion in project disunity by ata4.

the class TypeTreeV3 method read.

@Override
public void read(DataReader in) throws IOException {
    revision = new UnityVersion(in.readStringNull(255));
    attributes = in.readInt();
    embedded = in.readBoolean();
    int numBaseClasses = in.readInt();
    for (int i = 0; i < numBaseClasses; i++) {
        int classID = in.readInt();
        TypeRoot typeRoot = new TypeRoot();
        typeRoot.classID(classID);
        if (classID < 0) {
            UnityHash128 scriptID = new UnityHash128();
            in.readStruct(scriptID);
            typeRoot.scriptID(scriptID);
        }
        UnityHash128 oldTypeHash = new UnityHash128();
        in.readStruct(oldTypeHash);
        typeRoot.oldTypeHash(oldTypeHash);
        if (embedded) {
            Node<T> node = new Node<>();
            readNode(in, node);
            typeRoot.nodes(node);
        }
        typeMap.put(classID, typeRoot);
    }
}
Also used : Node(info.ata4.util.collection.Node) UnityVersion(info.ata4.junity.UnityVersion) UnityHash128(info.ata4.junity.UnityHash128)

Example 5 with UnityVersion

use of info.ata4.junity.UnityVersion in project disunity by ata4.

the class TypeTreeV2 method read.

@Override
public void read(DataReader in) throws IOException {
    revision = new UnityVersion(in.readStringNull(255));
    attributes = in.readInt();
    super.read(in);
    // padding
    in.readInt();
}
Also used : UnityVersion(info.ata4.junity.UnityVersion)

Aggregations

UnityVersion (info.ata4.junity.UnityVersion)4 Gson (com.google.gson.Gson)1 TableBuilder (info.ata4.disunity.cli.util.TableBuilder)1 UnityHash128 (info.ata4.junity.UnityHash128)1 BundleExternalEntry (info.ata4.junity.bundle.BundleExternalEntry)1 BundleHeader (info.ata4.junity.bundle.BundleHeader)1 Node (info.ata4.util.collection.Node)1 Reader (java.io.Reader)1 Path (java.nio.file.Path)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Pair (org.apache.commons.lang3.tuple.Pair)1