Beispiel #1
0
            public int Rebuild(FileOutput o)
            {
                o.writeString("GRP ");
                int sizeoff = o.size();

                o.writeInt(0);
                int size = o.size();

                o.writeInt(names.Count);

                int        start = names.Count * 8 + 4;
                FileOutput name  = new FileOutput();

                name.Endian = Endianness.Little;

                int c = 0;

                foreach (string na in names)
                {
                    o.writeInt(start + name.size());

                    int ns = name.pos();
                    name.writeInt(1);
                    name.writeByte(na.Length == 0 ? 0xFF : na.Length + 1);
                    name.writeString(na);
                    name.writeByte(0);
                    name.align(4);
                    if (c != names.Count - 1)
                    {
                        name.writeInt(0); // padding
                    }
                    else
                    {
                        ns -= 4;
                    }
                    c++;

                    o.writeInt(name.pos() - ns);
                }
                o.writeInt(0);
                o.writeOutput(name);

                size = o.size() - size;
                o.writeIntAt(size, sizeoff);
                return(size);
            }
Beispiel #2
0
        public byte[] Rebuild(int pos)
        {
            FileOutput f = new FileOutput();

            f.Endian = Endianness.Big;

            f.writeInt(pos + f.pos() + 0x8);
            f.writeInt(0);
            f.writeInt(defaultTexId);
            f.writeInt(keyframes.Count);
            f.writeInt(pos + f.pos() + 0x1C);
            f.writeInt(frameCount - 1);
            f.writeInt(unknown);
            f.writeBytes(new byte[0x10]);
            foreach (keyframe k in keyframes)
            {
                f.writeInt(k.texId);
                f.writeInt(k.frameNum);
            }

            return(f.getBytes());
        }
Beispiel #3
0
        public byte[] Rebuild(int pos)
        {
            FileOutput f = new FileOutput();

            f.Endian = Endianness.Big;

            f.writeInt(pos + f.pos() + 0x20);
            f.writeInt(Convert.ToInt32(unk1));
            int offset = pos + f.pos() + 0x18;

            offset += name.Length + 1;
            while (offset % 16 != 0)
            {
                offset++;
            }
            offset += 0x10;
            f.writeInt(offset);
            f.writeBytes(new byte[0x14]);
            f.writeString(name);
            f.writeByte(0);
            while ((pos + f.pos()) % 16 != 0)
            {
                f.writeByte(0);
            }
            f.writeBytes(new byte[0x10]);
            f.writeInt(frameCount);
            f.writeShort(Convert.ToInt32(unk2));
            f.writeShort(frames.Count);
            f.writeInt(pos + f.pos() + 0x18);
            f.writeBytes(new byte[0x14]);
            foreach (frame keyframe in frames)
            {
                f.writeShort(keyframe.frameNum);
                f.writeByte(keyframe.state);
                f.writeByte(keyframe.unknown);
            }

            return(f.getBytes());
        }
Beispiel #4
0
        public byte[] Rebuild(int pos)
        {
            FileOutput f = new FileOutput();

            f.Endian = Endianness.Big;

            f.writeInt(pos + f.pos() + 0x20);
            f.writeInt(unknown);
            f.writeInt(valueCount);
            f.writeInt(frames.Count);
            f.writeShort(unknown2);
            f.writeShort(unknown3);
            int position = pos + f.pos() + 0xC + name.Length + 1;

            while (position % 0x10 != 0)
            {
                position++;
            }

            f.writeInt(position);
            f.writeBytes(new byte[8]);
            f.writeString(name);
            f.writeByte(0);
            while ((pos + f.pos()) % 0x10 != 0)
            {
                f.writeByte(0);
            }

            foreach (frame fr in frames)
            {
                for (int i = 0; i < valueCount; i++)
                {
                    f.writeFloat(fr.values[i]);
                }
            }
            f.writeBytes(new byte[0x10]);

            return(f.getBytes());
        }
Beispiel #5
0
        public byte[] RebuildEntries(FileOutput f)
        {
            List <int> nameOffsets     = new List <int>();
            int        nameTableOffset = 0x30 + (0x20 * entries.Count);
            FileOutput nameTable       = new FileOutput()
            {
                Endian = Endianness.Big
            };

            foreach (Entry entry in entries)
            {
                nameOffsets.Add(nameTableOffset + nameTable.pos());
                nameTable.writeString(entry.name);
                nameTable.writeBytes(new byte[4 - (entry.name.Length % 4)]); //Pad to next word
            }
            while (nameTable.pos() % 0x10 != 0)
            {
                nameTable.writeByte(0);
            }

            for (int i = 0; i < entries.Count; i++)
            {
                entries[i].values[0] = nameOffsets[i];
            }

            foreach (Entry entry in entries)
            {
                foreach (int value in entry.values)
                {
                    f.writeInt(value);
                }
            }

            f.writeBytes(nameTable.getBytes());

            return(f.getBytes());
        }
Beispiel #6
0
        public override byte[] Rebuild()
        {
            FileOutput f = new FileOutput();

            f.Endian = endianess;

            f.writeInt(entries.Count);
            f.writeInt(otherEntries.Count);
            f.writeInt(0x30);
            f.writeInt(0x20);
            f.writeInt(0x8);
            f.writeInt(0x30);
            byte[] entryData = RebuildEntries(new FileOutput());
            f.writeInt(entryData.Length + 0x30);
            f.writeBytes(new byte[0x14]);
            f.writeBytes(entryData);
            f.writeBytes(RebuildOtherEntries(new FileOutput(), f.pos()));

            return(f.getBytes());
        }
Beispiel #7
0
        public override byte[] Rebuild()
        {
            FileOutput f = new FileOutput();

            f.Endian = Endianness.Big;

            f.writeString("MTA4");
            f.writeInt((int)unknown);
            f.writeInt((int)numFrames);
            f.writeInt(0);
            f.writeInt((int)numFrames - 1);
            f.writeInt((int)frameRate);
            f.writeInt(matEntries.Count);
            if (matEntries.Count > 0)
            {
                f.writeInt(0x38);
            }
            else
            {
                f.writeInt(0);
            }
            f.writeInt(visEntries.Count);
            if (visEntries.Count > 0)
            {
                f.writeInt(0x38 + 4 * matEntries.Count);
            }
            else
            {
                f.writeInt(0);
            }
            for (int i = 0; i < 0x10; i++)
            {
                f.writeByte(0);
            }

            List <byte[]> matEntriesBuilt = new List <byte[]>();
            List <byte[]> visEntriesBuilt = new List <byte[]>();

            int position = 0x38 + matEntries.Count + visEntries.Count;

            while (position % 0x10 != 0)
            {
                position++;
            }

            foreach (MatEntry m in matEntries)
            {
                byte[] b = m.Rebuild(position);
                matEntriesBuilt.Add(b);
                f.writeInt(position);
                position += b.Length;
                while (position % 0x10 != 0)
                {
                    position++;
                }
            }

            foreach (VisEntry v in visEntries)
            {
                byte[] b = v.Rebuild(position);
                matEntriesBuilt.Add(b);
                f.writeInt(position);
                position += b.Length;
                while (position % 0x10 != 0)
                {
                    position++;
                }
            }

            while (f.pos() % 0x10 != 0)
            {
                f.writeByte(0);
            }

            foreach (byte[] b in matEntriesBuilt)
            {
                f.writeBytes(b);
                while (f.pos() % 0x10 != 0)
                {
                    f.writeByte(0);
                }
            }

            foreach (byte[] b in visEntriesBuilt)
            {
                f.writeBytes(b);
                while (f.pos() % 0x10 != 0)
                {
                    f.writeByte(0);
                }
            }

            return(f.getBytes());
        }
Beispiel #8
0
        public byte[] Rebuild(int pos)
        {
            FileOutput f = new FileOutput();

            f.Endian = Endianness.Big;

            f.writeInt(pos + f.pos() + 0x20);
            f.writeInt(matHash);
            f.writeInt(properties.Count);
            int nameOffset = pos + f.pos() + 0x15 + name.Length;

            while (nameOffset % 4 != 0)
            {
                nameOffset++;
            }
            f.writeInt(nameOffset);
            f.writeFlag(hasPat);
            f.writeBytes(new byte[3]);
            //Write all the mat data into a buffer (g) then write pat offset
            int        pos2 = pos + f.pos() + 4;
            FileOutput g    = new FileOutput();

            g.Endian = Endianness.Big;

            if (matHash2 != 0)
            {
                g.writeInt(pos2 + g.pos() + 0x8);
                g.writeInt(matHash);
            }
            else
            {
                g.writeBytes(new byte[8]);
            }

            g.writeString(name);
            g.writeByte(0);
            while ((pos2 + g.pos()) % 0x10 != 0)
            {
                g.writeByte(0);
            }

            int position = pos2 + g.pos() + properties.Count * 4;

            while (position % 16 != 0)
            {
                position++;
            }

            List <byte[]> builtProperties = new List <byte[]>();

            foreach (MatData prop in properties)
            {
                g.writeInt(position);
                byte[] b = prop.Rebuild(position);
                builtProperties.Add(b);
                position += b.Length;
                while (position % 16 != 0)
                {
                    position++;
                }
            }

            while ((pos2 + g.pos()) % 16 != 0)
            {
                g.writeByte(0);
            }

            foreach (byte[] b in builtProperties)
            {
                g.writeBytes(b);
                while ((pos2 + g.pos()) % 16 != 0)
                {
                    g.writeByte(0);
                }
            }

            f.writeInt(pos2 + g.pos());
            f.writeBytes(g.getBytes());
            if (hasPat)
            {
                f.writeBytes(pat0.Rebuild(f.pos()));
            }

            return(f.getBytes());
        }