Exemplo n.º 1
0
        /// <summary>
        /// Gets list of offset slots of the textures in the tpk block array.
        /// </summary>
        /// <param name="byteptr_t">Pointer to the tpk block array.</param>
        /// <param name="offset">Partial 1 part3 offset in the tpk block array.</param>
        protected override unsafe void GetOffsetSlots(byte *byteptr_t, int offset)
        {
            if (offset == -1)
            {
                return;                            // if Part3 does not exist
            }
            if (*(uint *)(byteptr_t + offset) != TPK.INFO_PART3_BLOCKID)
            {
                return;                 // check Part3 ID
            }
            int ReaderSize = 8 + *(int *)(byteptr_t + offset + 4);
            int current    = 8;

            while (current < ReaderSize)
            {
                var offslot = new OffSlot();
                offslot.Key            = *(uint *)(byteptr_t + offset + current);
                offslot.AbsoluteOffset = *(int *)(byteptr_t + offset + current + 4);
                offslot.CompressedSize = *(int *)(byteptr_t + offset + current + 8);
                offslot.ActualSize     = *(int *)(byteptr_t + offset + current + 0xC);
                offslot.ToHeaderOffset = *(int *)(byteptr_t + offset + current + 0x10);
                offslot.UnknownInt32   = *(int *)(byteptr_t + offset + current + 0x14);
                this.offslots.Add(offslot);
                current += 0x18;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses compressed texture and returns it on the output.
        /// </summary>
        /// <param name="byteptr_t">Pointer to the tpk block array.</param>
        /// <param name="offslot">Offslot of the texture to be parsed</param>
        /// <returns>Decompressed texture valid to the current support.</returns>
        protected override unsafe void ParseCompTexture(byte *byteptr_t, OffSlot offslot)
        {
            byteptr_t += offslot.AbsoluteOffset;
            if (*(uint *)byteptr_t != TPK.COMPRESSED_TEXTURE)
            {
                return;                 // if not a compressed texture
            }
            // Decompress all data excluding 0x18 byte header
            var data = new byte[offslot.CompressedSize - 0x18];

            for (int a1 = 0; a1 < data.Length; ++a1)
            {
                data[a1] = *(byteptr_t + 0x18 + a1);
            }
            data = JDLZ.Decompress(data);

            // In compressed textures, their header lies right in the end (0x7C + 0x18 bytes)
            fixed(byte *dataptr_t = &data[0])
            {
                int offset = data.Length - 0x7C - 0x18;
                var Read   = new Texture(dataptr_t, offset, 0x7C, this._collection_name, this.Database);

                Read.ReadData(dataptr_t, 0, true);
                uint compression = *(uint *)(dataptr_t + offset + 0x7C + 0xC);

                this.compressions.Add(compression);
                this.Textures.Add(Read);
            }
        }