Ejemplo n.º 1
0
        /// <summary>
        /// Gets the frontend group, decompresses it if needed, and plugs into Vector.
        /// </summary>
        /// <param name="byteptr_t">Pointer to the beginning of frontend group in Global data.</param>
        /// <param name="length">Length of the block to be read.</param>
        /// <param name="db">Database to which add classes.</param>
        private static unsafe void E_FNGroup(byte *byteptr_t, uint length, Database.Underground2 db)
        {
            // Copy data and decompress
            var data = new byte[length];

            fixed(byte *dataptr_t = &data[0])
            {
                for (int a1 = 0; a1 < data.Length; ++a1)
                {
                    *(dataptr_t + a1) = *(byteptr_t + a1);
                }
            }

            data = SAT.Decompress(data);
            var Class = new FNGroup(data, db);

            // Check whether this FEng class already exists in the database
            if (Class.Destroy)
            {
                return;
            }
            if (db.FNGroups.FindCollection(Class.CollectionName) != null)
            {
                return;
            }
            db.FNGroups.Collections.Add(Class);
            Bin.Hash(Class.CollectionName);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Disassembles array into <see cref="FNGroup"/> properties.
        /// </summary>
        /// <param name="br"><see cref="BinaryReader"/> to read <see cref="FNGroup"/> with.</param>
        public override void Disassemble(BinaryReader br)
        {
            var ID   = br.ReadUInt32();
            var size = br.ReadInt32();

            this._data = SAT.Decompress(br.ReadBytes(size), ID);

            using var ms     = new MemoryStream(this._data);
            using var reader = new BinaryReader(ms);

            reader.BaseStream.Position = 0x28;
            this.CollectionName        = reader.ReadNullTermUTF8().ToUpper();

            if (this.CollectionName.EndsWith(".FNG"))
            {
                this.CollectionName.GetFormattedValue("{X}.FNG", out string name);
                this.CollectionName = name;
            }

            reader.BaseStream.Position = 0x28;

            while (reader.BaseStream.Position < reader.BaseStream.Length)
            {
                byte b1 = reader.ReadByte();
                byte b2 = reader.ReadByte();
                byte b3 = reader.ReadByte();
                byte b4 = reader.ReadByte();

                // SAT, SAD, SA(0x90) or 1111
                if ((b1 == 'S' && b2 == 'A') || (b1 == Byte.MaxValue && b2 == Byte.MaxValue &&
                                                 b3 == Byte.MaxValue && b4 == Byte.MaxValue))
                {
                    uint Offset = (uint)reader.BaseStream.Position;
                    uint Blue   = reader.ReadUInt32();
                    uint Green  = reader.ReadUInt32();
                    uint Red    = reader.ReadUInt32();
                    uint Alpha  = reader.ReadUInt32();

                    if (Blue <= Byte.MaxValue && Green <= Byte.MaxValue &&
                        Red <= Byte.MaxValue && Alpha <= Byte.MaxValue)
                    {
                        var color = new FEngColor(this)
                        {
                            Offset = Offset,
                            Blue   = (byte)Blue,
                            Green  = (byte)Green,
                            Red    = (byte)Red,
                            Alpha  = (byte)Alpha
                        };

                        this._colorinfo.Add(color);
                    }
                }
            }
        }