static void ExportLanguageSubtitle(string lang, string exportpath = "") { byte[] data = ExportChunk(lang); CompressionThing deCompressor = new CompressionThing(); data = deCompressor.decompressLZ4(data); //File.WriteAllBytes(Path.Combine(CurrentPath,"en.bin.GOODY"), data); if (exportpath == "") { exportpath = Tools.EnumarateFileName(CurrentPath, lang); } deCompressor.ExportTextsToExcelFile(exportpath, data); }
static void ImportLanguage(string lang, string excelPath) { CompressionThing compressor = new CompressionThing(); Toc langToc = tocFiles.Where(p => Path.GetFileNameWithoutExtension(p.filePath) == lang).First(); Entry ent1 = langToc.mainEntry.subTypes["chunks"][0]; Entry ent2 = langToc.mainEntry.subTypes["chunks"][1]; Kat kat1 = Tools.GetCatSettings(catFiles, ent1.subTypes["sha1"]); Kat kat2 = Tools.GetCatSettings(catFiles, ent2.subTypes["sha1"]); Entry bigEnt = kat1.size > kat2.size ? ent1 : ent2; //bigger one is subtitle one byte[] sha1 = bigEnt.subTypes["sha1"]; byte[] id = bigEnt.subTypes["id"]; string idStr = BitConverter.ToString(id).Replace("-", ""); Kat deKat = Tools.GetCatSettings(catFiles, sha1); Console.WriteLine("Compressing.."); byte[] compressedNewBytes; if (lang == "de" || lang == "zh" || lang == "ja") { compressedNewBytes = compressor.compressGermanLZ4(excelPath); } else { compressedNewBytes = compressor.compressLZ4(excelPath); } Console.WriteLine("OK."); string cas1path = Path.Combine(GamePath, MainFolder, @"Win32\gameconfigurations\initialinstallpackage\cas_01.cas"); byte[] cas1 = File.ReadAllBytes(cas1path); int z = 0; if (compressedNewBytes.Length > (uint)deKat.size) { Console.WriteLine("Yeni dosyanın boyutu (" + compressedNewBytes.Length + ") Orjinal boyuttan (" + deKat.size + ") daha büyük!\nİptal.. "); return; } for (uint i = deKat.offset; i < deKat.offset + deKat.size; i++) { if (z < compressedNewBytes.Length) { cas1[i] = compressedNewBytes[z]; z++; } else { cas1[i] = 0; } } Console.WriteLine("Writing to Cas1 File.."); BackupAndWriteBytes(cas1path, cas1); Console.WriteLine("OK."); //for new decompressedSize, if not edited game refuses to open -except polish int dataSizeOffset = -1;//454368;//420703;//420813; string cas2path = Path.Combine(GamePath, MainFolder, @"Win32\gameconfigurations\initialinstallpackage\cas_02.cas"); byte[] cas2 = File.ReadAllBytes(cas2path); dataSizeOffset = Tools.SearchIdInCasFile(cas2, id); if (dataSizeOffset == -1) { Console.WriteLine("Skip Cas2.."); return; } dataSizeOffset += 16;//size offset comes after id start offset byte[] dataLen = BitConverter.GetBytes(compressor.DecompressedDataLength); for (int i = 0; i < 4; i++) { cas2[i + dataSizeOffset] = dataLen[i]; } Console.WriteLine("Writing to Cas2 File.."); BackupAndWriteBytes(cas2path, cas2); Console.WriteLine("OK."); }