private static void FARCProcessor(KKdFARC farc, string choose, Format format, bool a3dcOpt) { if (!farc.HeaderReader() || !farc.HasFiles) { return; } KKdList <string> list = KKdList <string> .New; for (int i = 0; i < farc.Files.Count; i++) { string file = farc.Files[i].Name.ToLower(); if (!file.Contains("_div_") && file.EndsWith(".a3da")) { list.Add(file); } } KKdList <string> A3DAlist = KKdList <string> .New; for (int i = 0; i < farc.Files.Count; i++) { if (farc.Files[i].Name.ToLower().EndsWith(".a3da")) { A3DAlist.Add(farc.Files[i].Name); } } byte[] data = null; if (list.Count == A3DAlist.Count) { KKdA3DA a3da; for (int i = 0; i < A3DAlist.Count; i++) { using (a3da = new KKdA3DA(a3dcOpt)) { data = farc.FileReader(A3DAlist[i]); int state = a3da.A3DAReader(data); if (state == 1) { KKdFARC.FARCFile file = farc.Files[i]; a3da.Head.Format = format; file.Data = (choose == "1" || choose == "4") ? a3da.A3DAWriter() : a3da.A3DCWriter(); farc.Files[i] = file; } } } farc.Save(); return; } KKdA3DA[] a3daArray; using (KKdList <KKdA3DA> a3daList = KKdList <KKdA3DA> .NewReserve(list.Count)) { for (int i = 0; i < list.Count; i++) { KKdA3DA a3da; using (a3da = new KKdA3DA(a3dcOpt)) { data = farc.FileReader(list[i]); int state = a3da.A3DAReader(data); if (state == 1) { a3daList.Add(a3da); } } } a3daArray = a3daList.ToArray(); } for (int i = 0; i < list.Count; i++) { if (a3daArray[i].Data.PlayControl.Div == null) { continue; } int div = a3daArray[i].Data.PlayControl.Div.Value; string filename = Path.RemoveExtension(list[i]); string ext = Path.GetExtension(list[i]).ToLower(); KKdA3DA a3da; for (int i1 = 1; i1 < div; i1++) { using (a3da = new KKdA3DA(a3dcOpt)) { string file = filename + "_div_" + i1 + ext; data = farc.FileReader(file); int state = a3da.A3DAReader(data); if (state == 1) { a3daArray[i].A3DAMerger(ref a3da.Data); } } } a3daArray[i].Data.PlayControl.Div = null; } farc.Files.Capacity = 0; farc.Files.Capacity = list.Count; for (int i = 0; i < list.Count; i++) { KKdFARC.FARCFile file = default; file.Name = list[i]; a3daArray[i].Head.Format = format; file.Data = (choose == "1" || choose == "4") ? a3daArray[i].A3DAWriter() : a3daArray[i].A3DCWriter(); farc.Files.Add(file); } farc.Save(); return; }
private static void FARCProcessor(KKdFARC farc, string choose, Format format) { if (!farc.HeaderReader()) { return; } if (!farc.HasFiles) { return; } KKdList <string> list = KKdList <string> .New; for (int i = 0; i < farc.Files.Length; i++) { if (!farc.Files[i].Name.Contains("div") && farc.Files[i].Name.EndsWith(".a3da")) { list.Add(farc.Files[i].Name); } } KKdList <string> A3DAlist = KKdList <string> .New; for (int i = 0; i < farc.Files.Length; i++) { if (farc.Files[i].Name.EndsWith(".a3da")) { A3DAlist.Add(farc.Files[i].Name); } } byte[] data = null; if (list.Count == A3DAlist.Count || (format > Format.AFT && format < Format.FT)) { KKdA3DA a3da; for (int i = 0; i < A3DAlist.Count; i++) { using (a3da = new KKdA3DA(true)) { data = farc.FileReader(A3DAlist[i]); int state = a3da.A3DAReader(data); if (state == 1) { a3da.Data._.CompressF16 = format > Format.AFT && format < Format.FT ? format == Format.MGF ? 2 : 1 : 0; a3da.Head.Format = format; farc.Files[i].Data = (choose != "1" && choose != "3") ? a3da.A3DCWriter() : a3da.A3DAWriter(); } } } farc.Save(); return; } KKdA3DA[] a3daArray; using (KKdList <KKdA3DA> a3daList = KKdList <KKdA3DA> .New) { for (int i = 0; i < list.Count; i++) { KKdA3DA a3da; using (a3da = new KKdA3DA(true)) { data = farc.FileReader(list[i]); int state = a3da.A3DAReader(data); if (state == 1) { a3daList.Add(a3da); } } } a3daArray = a3daList.ToArray(); } for (int i = 0; i < list.Count; i++) { if (a3daArray[i].Data.PlayControl.Div == null) { continue; } float Div = a3daArray[i].Data.PlayControl.Div.Value; KKdA3DA a3da; for (int i1 = 1; i1 < Div; i1++) { using (a3da = new KKdA3DA(true)) { string file = Path.GetFileNameWithoutExtension(list[i]) + "_div_" + i1 + Path.GetExtension(list[i]); data = farc.FileReader(file); int state = a3da.A3DAReader(data); if (state == 1) { a3daArray[i].A3DAMerger(ref a3da.Data); } } } a3daArray[i].Data.PlayControl.Div = null; } farc.Files = new KKdFARC.FARCFile[list.Count]; for (int i = 0; i < list.Count; i++) { farc.Files[i].Name = list[i]; a3daArray[i].Data._.CompressF16 = format > Format.AFT && format < Format.FT ? format == Format.MGF ? 2 : 1 : 0; a3daArray[i].Head.Format = format; farc.Files[i].Data = (choose != "1" && choose != "3") ? a3daArray[i].A3DCWriter() : a3daArray[i].A3DAWriter(); } farc.Save(); return; }