public void deserializeVoiceLogicBinary()
        {
            UnitIDList unitIDList = load_UnitID();
            SoundLogicUnitIDGroupList soundLogicUnitIDGroupList = load_GroupList();

            Voice_Line_Logic voice_Line_Logic = parse_Voice_Line_Logic(Properties.Settings.Default.inputVoiceLogicBinary, unitIDList, soundLogicUnitIDGroupList);
            //@"G:\Games\PS3\EXVSFB JPN\Pkg research\FB Repacker\Repack\PAC\Input\MBON Reimport Project\MBON Units\Wing Zero EW\Extract MBON\Data - 4A5DEE5F\001-MBON\002-FHM\007.bin", unitIDList, soundLogicUnitIDGroupList);

            string outputName = Path.GetFileNameWithoutExtension(Properties.Settings.Default.inputVoiceLogicBinary);

            write_Voice_Line_Data_Json(Properties.Settings.Default.outputVoiceLogicJSONFolder + @"\" + outputName + ".JSON", voice_Line_Logic);

            //@"G:\Games\PS3\EXVSFB JPN\Pkg research\FB Repacker\Repack\PAC\Input\MBON Reimport Project\MBON Units\Wing Zero EW\Converted from MBON\WingZeroEWVoiceLogic.json");
        }
Exemple #2
0
        public void ExportBin()
        {
            UnitIDList unitIDList = load_UnitID();

            FileStream fs = File.OpenRead(@"G:\Games\PS3\EXVSFB JPN\Pkg research\FB Repacker\Repack\PAC\Input\MBON Reimport Project\big_endian_list.bin");

            List <MBONBinaries> BinaryList = new List <MBONBinaries>();

            for (int j = 0; j < 356; j++)
            {
                MBONBinaries mBONBinaries = new MBONBinaries();

                for (int i = 0; i < 15; i++)
                {
                    if (i == 0)
                    {
                        mBONBinaries.unitID = readUIntBigEndian(fs);
                    }
                    else
                    {
                        mBONBinaries.binaryHashes.Add(readUIntBigEndian(fs));
                    }
                }

                BinaryList.Add(mBONBinaries);
            }

            fs.Close();

            for (int i = 0; i < BinaryList.Count; i++)
            {
                MBONBinaries binary   = BinaryList[i];
                UnitID       unit     = unitIDList.Unit_ID.FirstOrDefault(x => x.id == binary.unitID);
                string       unitName = "";
                if (unit != null)
                {
                    unitName = unit.name_english + " - " + unit.id.ToString();
                }
                else
                {
                    unitName = "Unknown - " + binary.unitID.ToString();
                }
                string unitFolder = @"G:\Games\PS3\EXVSFB JPN\Pkg research\FB Repacker\Repack\PAC\Input\MBON Reimport Project\Total MBON Export\" + (i + 1).ToString() + ". " + unitName;

                Directory.CreateDirectory(unitFolder);
                Directory.CreateDirectory(unitFolder + @"\Original MBON");
                Directory.CreateDirectory(unitFolder + @"\Extracted MBON");

                List <string> junkBin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[0].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (junkBin.Count == 0 || junkBin.Count > 1)
                {
                    throw new Exception();
                }

                copyBinarywithout0x10000(junkBin[0], unitFolder + @"\Original MBON\" + "Junk - " + binary.binaryHashes[0].ToString("X8") + ".bin");

                List <string> dataBin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[1].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (dataBin.Count == 0 || dataBin.Count > 1)
                {
                    throw new Exception();
                }

                copyBinarywithout0x10000(dataBin[0], unitFolder + @"\Original MBON\" + "Data - " + binary.binaryHashes[1].ToString("X8") + ".bin");

                List <string> script_1Bin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[2].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (script_1Bin.Count == 0 || script_1Bin.Count > 1)
                {
                    throw new Exception();
                }

                copyBinarywithout0x10000(script_1Bin[0], unitFolder + @"\Original MBON\" + "Script 1 - " + binary.binaryHashes[2].ToString("X8") + ".bin");

                List <string> script_2Bin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[3].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (script_2Bin.Count == 0 || script_2Bin.Count > 1)
                {
                    throw new Exception();
                }

                copyBinarywithout0x10000(script_2Bin[0], unitFolder + @"\Original MBON\" + "Script 2 - " + binary.binaryHashes[3].ToString("X8") + ".bin");

                List <string> modelBin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[4].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (modelBin.Count == 0 || modelBin.Count > 1)
                {
                    throw new Exception();
                }

                copyBinarywithout0x10000(modelBin[0], unitFolder + @"\Original MBON\" + "Model and Texture - " + binary.binaryHashes[4].ToString("X8") + ".bin");

                List <string> OMOBin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[5].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (OMOBin.Count == 0 || OMOBin.Count > 1)
                {
                    throw new Exception();
                }

                copyBinarywithout0x10000(OMOBin[0], unitFolder + @"\Original MBON\" + "OMO - " + binary.binaryHashes[5].ToString("X8") + ".bin");

                List <string> EIDXBin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[6].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (EIDXBin.Count == 0 || EIDXBin.Count > 1)
                {
                    throw new Exception();
                }

                copyBinarywithout0x10000(EIDXBin[0], unitFolder + @"\Original MBON\" + "EIDX - " + binary.binaryHashes[6].ToString("X8") + ".bin");

                if (binary.binaryHashes[7] != 0xffffffff || binary.binaryHashes[8] != 0xffffffff)
                {
                    throw new Exception();
                }

                List <string> DNSOBin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[9].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (DNSOBin.Count > 1)
                {
                    throw new Exception();
                }

                if (DNSOBin.Count != 0)
                {
                    copyBinarywithout0x10000(DNSOBin[0], unitFolder + @"\Original MBON\" + "DNSO - " + binary.binaryHashes[9].ToString("X8") + ".bin");
                }

                List <string> unkBin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[10].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (unkBin.Count > 0)
                {
                    throw new Exception();
                }

                List <string> KPKPBin = Directory.GetFiles(@"D:\MBON\Image0\archives\", binary.binaryHashes[11].ToString("X8") + ".bin", SearchOption.AllDirectories).ToList();

                if (KPKPBin.Count > 1)
                {
                    throw new Exception();
                }

                if (KPKPBin.Count != 0)
                {
                    copyBinarywithout0x10000(KPKPBin[0], unitFolder + @"\Original MBON\" + "KPKP - " + binary.binaryHashes[11].ToString("X8") + ".bin");
                }

                if (binary.binaryHashes[12] != 0xffffffff || binary.binaryHashes[13] != 0xffffffff)
                {
                    throw new Exception();
                }
            }
        }
        public void repackData(
            string reimportRepackedFiles,
            string reimportFilestoRepack,
            string unitFolderName,
            string data,
            string reimportConvertedfromMBONFolder,
            Unit_Files_List unit_Files
            )
        {
            RepackPAC repackInstance = new RepackPAC(Properties.Settings.Default.OutputRepackPAC);

            Properties.Settings.Default.OutputRepackPAC = reimportRepackedFiles;

            string data_folder_path = reimportFilestoRepack + @"\Data - " + unit_Files.data_and_script_PAC_hash.ToString("X8");

            Directory.CreateDirectory(data_folder_path);

            /// Repack Data Folder
            DirectoryCopy(repackTemplates + @"\Data", data_folder_path, true);

            string data_001FHM_path = data_folder_path + @"\001-FHM\";

            FileStream fs002     = File.Create(data_001FHM_path + @"\002.bin");
            FileStream vardataFS = File.OpenRead(reimportConvertedfromMBONFolder + @"\Unit Variables\UnitData.bin");

            vardataFS.Seek(0, SeekOrigin.Begin);
            vardataFS.CopyTo(fs002);
            fs002.Close();
            vardataFS.Close();

            FileStream fs003     = File.Create(data_001FHM_path + @"\003.bin");
            FileStream MBON003FS = File.OpenRead(data + @"\001-FHM\003.bin");

            MBON003FS.Seek(0, SeekOrigin.Begin);
            MBON003FS.CopyTo(fs003);
            fs003.Close();
            MBON003FS.Close();

            FileStream fs005     = File.Create(data_001FHM_path + @"\005.bin");
            FileStream MBON005FS = File.OpenRead(data + @"\001-FHM\005.bin");

            MBON005FS.Seek(0, SeekOrigin.Begin);
            MBON005FS.CopyTo(fs005);
            fs005.Close();
            MBON005FS.Close();

            FileStream fs006 = File.Create(data_001FHM_path + @"\006.bin");
            FileStream mscFS = File.OpenRead(XBScriptFolder + @"\Compiled Refactored Script\" + unitFolderName + ".mscsb");

            mscFS.Seek(0, SeekOrigin.Begin);
            mscFS.CopyTo(fs006);
            fs006.Close();
            mscFS.Close();

            FileStream fs008        = File.Create(data_001FHM_path + @"\008.bin");
            FileStream voicelogicFS = File.OpenRead(reimportConvertedfromMBONFolder + @"\Voice Data\006.bin");

            voicelogicFS.Seek(0, SeekOrigin.Begin);
            voicelogicFS.CopyTo(fs008);
            fs008.Close();
            voicelogicFS.Close();

            Properties.Settings.Default.OpenRepackPath = data_folder_path;

            repackInstance.initializePACInfoFileRepack();
            repackInstance.parseInfo();
            repackInstance.repackPAC();


            // Get unit's english name
            UnitIDList unit_Infos = load_UnitID();
            string     unitName   = unit_Infos.Unit_ID.FirstOrDefault(s => s.id == unit_Files.Unit_ID).name_english.Replace(" ", "_");

            unitName = unitName.Replace(".", "_");
            unitName = unitName.Replace("∀", "Turn_A");

            string basePsarcRepackFolder = XBCombinedPsarcFolder + @"\Units\FB_Units\" + unitName;

            string[] allRepackedPACs = Directory.GetFiles(reimportRepackedFiles, "*", SearchOption.TopDirectoryOnly);


            string Data_Path = basePsarcRepackFolder + @"\Data\PATCH" + unit_Files.data_and_script_PAC_hash.ToString("X8") + ".PAC";

            FileStream dataFS = File.OpenRead(allRepackedPACs.FirstOrDefault(s => s.Contains("Data")));

            dataFS.Seek(0, SeekOrigin.Begin);

            FileStream newDataFS = File.Create(Data_Path);

            dataFS.CopyTo(newDataFS);

            dataFS.Close();

            newDataFS.Close();
        }
        public Voice_Line_Logic parse_Voice_Line_Logic(string path, UnitIDList unitIDList, SoundLogicUnitIDGroupList soundLogicUnitIDGroupList)
        {
            Voice_Line_Logic voice_Line_Logic = new Voice_Line_Logic();

            voice_Line_Logic.schemaVersion = schemaVersion;

            FileStream fs = File.OpenRead(path);

            changeStreamFile(fs);

            List <Voice_Line_Logic_Set_Data> set_Data = new List <Voice_Line_Logic_Set_Data>();

            uint magic  = readUIntBigEndian();
            uint unitID = readUIntBigEndian();

            voice_Line_Logic.magic   = magic;
            voice_Line_Logic.unit_ID = unitID;

            uint pointer1 = readUIntBigEndian();
            uint pointer2 = readUIntBigEndian();
            uint pointer3 = readUIntBigEndian();

            // Parse Individual Voice Line Sets
            Stream.Seek(pointer1, SeekOrigin.Begin);
            uint IndividualSetCount = readUIntBigEndian();

            Stream.Seek(0xC, SeekOrigin.Current);

            for (int i = 0; i < IndividualSetCount; i++)
            {
                uint prop1  = readUIntBigEndian();
                uint index  = readUIntBigEndian();
                uint prop2  = readUIntBigEndian();
                uint prop3  = readUIntBigEndian();
                uint prop4  = readUIntBigEndian();
                uint prop5  = readUIntBigEndian();
                uint prop6  = readUIntBigEndian();
                uint prop7  = readUIntBigEndian();
                uint prop8  = readUIntBigEndian();
                uint prop9  = readUIntBigEndian();
                uint prop10 = readUIntBigEndian();

                Voice_Line_Logic_Set_Data voice_Line_Logic_Set_Data = new Voice_Line_Logic_Set_Data();
                Voice_Line_Logic_Set_Data_Individual_Properties voice_Line_Logic_Set_Data_Properties = new Voice_Line_Logic_Set_Data_Individual_Properties();
                voice_Line_Logic_Set_Data_Properties.prop1  = prop1;
                voice_Line_Logic_Set_Data_Properties.prop2  = prop2;
                voice_Line_Logic_Set_Data_Properties.prop3  = prop3;
                voice_Line_Logic_Set_Data_Properties.prop4  = prop4;
                voice_Line_Logic_Set_Data_Properties.prop5  = prop5;
                voice_Line_Logic_Set_Data_Properties.prop6  = prop6;
                voice_Line_Logic_Set_Data_Properties.prop7  = prop7;
                voice_Line_Logic_Set_Data_Properties.prop8  = prop8;
                voice_Line_Logic_Set_Data_Properties.prop9  = prop9;
                voice_Line_Logic_Set_Data_Properties.prop10 = prop10;

                uint voiceCount = readUIntBigEndian();
                uint setPointer = readUIntBigEndian();

                voice_Line_Logic_Set_Data.properties = voice_Line_Logic_Set_Data_Properties;
                voice_Line_Logic_Set_Data.voiceCount = voiceCount;
                voice_Line_Logic_Set_Data.setPointer = setPointer;
                voice_Line_Logic_Set_Data.voiceType  = voiceType.Individual;
                voice_Line_Logic_Set_Data.index      = index;

                uint        returnAddress = (uint)Stream.Position;
                List <uint> voiceHashes   = new List <uint>();

                Stream.Seek(setPointer, SeekOrigin.Begin);
                for (int j = 0; j < voiceCount; j++)
                {
                    uint voiceHash = readUIntBigEndian();
                    voiceHashes.Add(voiceHash);
                }

                voice_Line_Logic_Set_Data.voiceHashes = voiceHashes;

                Stream.Seek(returnAddress, SeekOrigin.Begin);
                set_Data.Add(voice_Line_Logic_Set_Data);
            }

            // Parse Triggered Voice Line Sets
            Stream.Seek(pointer2, SeekOrigin.Begin);
            uint TriggeredSetCount = readUIntBigEndian();

            Stream.Seek(0xC, SeekOrigin.Current);

            for (int i = 0; i < TriggeredSetCount; i++)
            {
                uint triggerCondition = readUIntBigEndian();
                uint index            = readUIntBigEndian();
                int  groupID          = (int)readUIntBigEndian();
                uint voiceCount       = readUIntBigEndian();
                uint setPointer       = readUIntBigEndian();

                Voice_Line_Logic_Set_Data voice_Line_Logic_Set_Data = new Voice_Line_Logic_Set_Data();
                voice_Line_Logic_Set_Data.voiceCount       = voiceCount;
                voice_Line_Logic_Set_Data.setPointer       = setPointer;
                voice_Line_Logic_Set_Data.triggerCondition = triggerCondition;
                voice_Line_Logic_Set_Data.index            = index;

                uint        returnAddress = (uint)Stream.Position;
                List <uint> voiceHashes   = new List <uint>();

                Stream.Seek(setPointer, SeekOrigin.Begin);
                for (int j = 0; j < voiceCount; j++)
                {
                    uint voiceHash = readUIntBigEndian();
                    voiceHashes.Add(voiceHash);
                }

                // For some reason groupID = -1 is possible, where the unit ID list is fetched from Xi's old corresponding trigger unitIDs

                List <uint> triggerUnitIDs = soundLogicUnitIDGroupList.soundLogicUnitIDGroupList.FirstOrDefault(s => s.groupID.Equals(groupID)).unitIDs;

                voice_Line_Logic_Set_Data.voiceHashes   = voiceHashes;
                voice_Line_Logic_Set_Data.triggerUnitID = triggerUnitIDs;
                voice_Line_Logic_Set_Data.voiceType     = voiceType.Triggered;

                Stream.Seek(returnAddress, SeekOrigin.Begin);
                set_Data.Add(voice_Line_Logic_Set_Data);
            }

            // Parse Paired Voice Line Sets (Banters)
            Stream.Seek(pointer3, SeekOrigin.Begin);
            uint PairedSetCount = readUIntBigEndian();

            Stream.Seek(0xC, SeekOrigin.Current);

            for (int i = 0; i < PairedSetCount; i++)
            {
                uint triggerCondition = readUIntBigEndian();
                uint index            = readUIntBigEndian();
                int  groupID          = (int)readUIntBigEndian();
                uint voiceCount       = 2; // Paired is always two
                uint setPointer       = 0; // There's no pointer
                uint self_VoiceHash   = readUIntBigEndian();
                uint target_VoiceHash = readUIntBigEndian();
                uint unk_Zero         = readUIntBigEndian(); // Not sure what

                List <uint> voiceHashes = new List <uint>();
                voiceHashes.Add(self_VoiceHash);
                voiceHashes.Add(target_VoiceHash);

                List <uint> triggerUnitIDs = soundLogicUnitIDGroupList.soundLogicUnitIDGroupList.FirstOrDefault(s => s.groupID.Equals(groupID)).unitIDs;

                Voice_Line_Logic_Set_Data voice_Line_Logic_Set_Data = new Voice_Line_Logic_Set_Data();
                voice_Line_Logic_Set_Data.voiceCount       = voiceCount;
                voice_Line_Logic_Set_Data.setPointer       = setPointer;
                voice_Line_Logic_Set_Data.triggerCondition = triggerCondition;
                voice_Line_Logic_Set_Data.index            = index;
                voice_Line_Logic_Set_Data.voiceHashes      = voiceHashes;
                voice_Line_Logic_Set_Data.triggerUnitID    = triggerUnitIDs;
                voice_Line_Logic_Set_Data.voiceType        = voiceType.Pair_Triggered;

                set_Data.Add(voice_Line_Logic_Set_Data);
            }

            fs.Close();

            voice_Line_Logic.voice_Line_Logic_Set_Datas = set_Data;
            return(voice_Line_Logic);
        }
Exemple #5
0
        public Parse_Unit_Files_List()
        {
            List <Unit_Files_List> FB_List       = parse_Unit_Files_List_FB(@"D:\Games\PS3\EXVSFB JPN\Pkg research\FB Repacker\Repack\PAC\Input\MBON Reimport Project\list_fb.bin");
            List <Unit_Files_List> MBON_List     = parse_Unit_Files_List_MBON(@"D:\Games\PS3\EXVSFB JPN\Pkg research\FB Repacker\Repack\PAC\Input\MBON Reimport Project\big_endian_list.bin");
            List <Unit_Files_List> Combined_List = new List <Unit_Files_List>();

            UnitIDList    unitIDList   = load_UnitID();
            List <UnitID> unit_ID_List = unitIDList.Unit_ID;

            StringBuilder MBONlog = new StringBuilder();

            MBONlog.AppendLine("MBON PAC Hashes");
            foreach (var MBON in MBON_List)
            {
                if (FB_List.Any(x => x.Unit_ID == MBON.Unit_ID))
                {
                    Unit_Files_List FBUnit = FB_List.FirstOrDefault(x => x.Unit_ID == MBON.Unit_ID);
                    FBUnit.MBONAdded = false;
                    Combined_List.Add(FBUnit);
                }
                else
                {
                    if (unit_ID_List.Any(x => x.id == MBON.Unit_ID))
                    {
                        UnitID unit = unit_ID_List.FirstOrDefault(x => x.id == MBON.Unit_ID);

                        MBONlog.AppendLine(@"//----------------------- " + unit.name_english + @"-----------------------//");

                        // Manually add own made hashes to newly added MBON units
                        Crc32  crc32             = new Crc32();
                        string sound_effect_str  = unit.name_english + "_sound_effects";
                        string sound_effect_hash = crc32.Get(Encoding.UTF8.GetBytes(sound_effect_str.ToLower())).ToString("X8");

                        MBONlog.AppendLine(sound_effect_str + " - 0x" + sound_effect_hash);

                        uint.TryParse(sound_effect_hash, out uint result);
                        MBON.sound_effect_PAC_hash = result;


                        string global_pilot_voices_str  = unit.name_english + "_global_pilot_voices";
                        string global_pilot_voices_hash = crc32.Get(Encoding.UTF8.GetBytes(global_pilot_voices_str.ToLower())).ToString("X8");

                        MBONlog.AppendLine(global_pilot_voices_str + " - 0x" + global_pilot_voices_hash);

                        uint.TryParse(global_pilot_voices_hash, out result);
                        MBON.global_pilot_voices_PAC_hash = result;


                        string sortie_and_awakening_sprites_costume_1_str  = unit.name_english + "_sortie_and_awakening_sprites_costume_1";
                        string sortie_and_awakening_sprites_costume_1_hash = crc32.Get(Encoding.UTF8.GetBytes(sortie_and_awakening_sprites_costume_1_str.ToLower())).ToString("X8");

                        MBONlog.AppendLine(sortie_and_awakening_sprites_costume_1_str + " - 0x" + sortie_and_awakening_sprites_costume_1_hash);

                        uint.TryParse(sortie_and_awakening_sprites_costume_1_hash, out result);
                        MBON.sortie_and_awakening_sprites_PAC_hash = result;


                        string global_pilot_voice_file_list_str  = unit.name_english + "_global_pilot_voice_file_list";
                        string global_pilot_voice_file_list_hash = crc32.Get(Encoding.UTF8.GetBytes(global_pilot_voice_file_list_str.ToLower())).ToString("X8");

                        MBONlog.AppendLine(global_pilot_voice_file_list_str + " - 0x" + global_pilot_voice_file_list_hash);

                        uint.TryParse(global_pilot_voice_file_list_hash, out result);
                        MBON.voice_file_list_PAC_hash = result;


                        string local_pilot_voices_str  = unit.name_english + "_global_pilot_voices";
                        string local_pilot_voices_hash = crc32.Get(Encoding.UTF8.GetBytes(local_pilot_voices_str.ToLower())).ToString("X8");

                        MBONlog.AppendLine(local_pilot_voices_str + " - 0x" + local_pilot_voices_hash);

                        uint.TryParse(local_pilot_voices_hash, out result);
                        MBON.local_pilot_voices_STREAM_PAC_hash = result;

                        MBON.MBONAdded = true;

                        Combined_List.Add(MBON);
                    }
                }
            }

            StreamWriter streamWriter = File.CreateText(@"D:\Games\PS3\EXVSFB JPN\Pkg research\FB Repacker\Repack\PAC\Input\MBON Reimport Project\GeneratedMBONPACHashes.txt");

            streamWriter.Write(MBONlog.ToString());

            streamWriter.Close();

            string       json   = JsonConvert.SerializeObject(Combined_List, Formatting.Indented);
            StreamWriter jsonSW = File.CreateText(@"D:\Games\PS3\EXVSFB JPN\Pkg research\FB Repacker\Repack\PAC\Input\MBON Reimport Project\AllUnitsPACHashes.json");

            jsonSW.Write(json);
            jsonSW.Close();
        }