Beispiel #1
0
        }     //method Export ends

        public override void Import(Stream output, string path)
        {
            string inputPath = Path.GetDirectoryName(path) + @"\" + Path.GetFileNameWithoutExtension(path);

            uint         offset = (uint)output.Position;
            BinaryWriter writer = new BinaryWriter(output, Encoding.Default, true);

            fileCount = (uint)files.Count;

            writer.Write(signature);
            writer.Write(fileCount);
            writer.Write(boneGroups);
            writer.Write(boneGroups2);
            writer.WriteZeros(8);

            for (int i = 0; i < files.Count; i++)
            {
                files[i].hash = NameResolver.GetHashFromName(files[i].name);
            } //for ends

            files.Sort((x, y) => x.hash.CompareTo(y.hash));

            for (int i = 0; i < files.Count; i++)
            {
                files[i].Write(output);
            } //for ends

            for (int i = 0; i < files.Count; i++)
            {
                byte[] file = File.ReadAllBytes(inputPath + @"_mtar\" + files[i].name);
                offset = (uint)writer.BaseStream.Position;
                writer.BaseStream.Position = (0x20 + ((0x10 * i) + 0x8));
                writer.Write(offset);
                writer.Write(file.Length);
                writer.BaseStream.Position = offset;
                writer.Write(file);
                output.AlignWrite(16, 0x00);
            } //for ends
        }     //method Import ends
Beispiel #2
0
        }         //method Export ends

        public override void Import(Stream output, string path)
        {
            string inputPath = Path.GetDirectoryName(path) + @"\" + Path.GetFileNameWithoutExtension(path);

            Console.WriteLine(inputPath);
            uint         offset;
            BinaryWriter writer = new BinaryWriter(output, Encoding.Default, true);

            fileCount = (uint)files.Count;

            writer.Write(signature);
            writer.Write(fileCount);
            writer.Write(unknown0);
            writer.Write(unknown1);
            writer.Write(unknown2);
            writer.Write(unknown3);
            writer.Write(unknown4);
            writer.Write(unknown5);
            writer.WriteZeros(0xC);

            for (int i = 0; i < files.Count; i++)
            {
                files[i].hash = NameResolver.GetHashFromName(files[i].name);
            } //for ends

            files.Sort((x, y) => x.hash.CompareTo(y.hash));

            for (int i = 0; i < files.Count; i++)
            {
                files[i].Write(output);
            } //for ends

            offset = (uint)output.Position;
            byte[] track = File.ReadAllBytes(inputPath + @"_mtar\" + mtarTrack.name + ".trk");
            writer.BaseStream.Position = 0x14;
            writer.Write(offset);
            writer.BaseStream.Position = offset;
            writer.Write(track);

            if (output.Position % 0x10 != 0)
            {
                writer.WriteZeros(0x10 - (int)output.Position % 0x10);
            }

            if (File.Exists(inputPath + @"_mtar\" + mtarChunk.name + ".chnk"))
            {
                byte[] chunk = File.ReadAllBytes(inputPath + @"_mtar\" + mtarChunk.name + ".chnk");
                writer.Write(chunk);
            } //if

            for (int i = 0; i < files.Count; i++)
            {
                byte[] file = File.ReadAllBytes(inputPath + @"_mtar\" + files[i].name + ".gani");
                byte[] exFile;
                offset          = (uint)output.Position;
                output.Position = (0x20 + ((0x20 * i) + 0x8));
                writer.Write(offset);
                writer.Write((ushort)(file.Length / 0x10));

                if (File.Exists(inputPath + @"_mtar\" + files[i].name + ".exchnk"))
                {
                    writer.Write((ushort)(file.Length / 0x10));
                    exFile = File.ReadAllBytes(inputPath + @"_mtar\" + files[i].name + ".exchnk");
                    writer.Write((ushort)(exFile.Length / 0x10));
                } //if ends
                else
                {
                    exFile = new byte[0];
                } //else ends

                output.Position = offset;
                writer.Write(file);

                if (exFile.Length > 0)
                {
                    writer.Write(exFile);
                } //if ends
            }     //for ends

            for (int i = 0; i < files.Count; i++)
            {
                if (File.Exists(inputPath + @"_mtar\" + files[i].name + ".enchnk"))
                {
                    byte[] file = File.ReadAllBytes(inputPath + @"_mtar\" + files[i].name + ".enchnk");

                    offset          = (uint)output.Position;
                    output.Position = (0x30 + ((0x20 * i) + 0x8));
                    writer.Write(offset);
                    output.Position = offset;
                    writer.Write(file);
                } //if ends
            }     //for ends
        }         //method Import ends