From 0186cb158df4fc125657cd8fe1a7bd0034ed7017 Mon Sep 17 00:00:00 2001 From: Villermen Date: Fri, 21 Nov 2014 23:27:09 +0100 Subject: [PATCH] Soundtrack now uses index file's name Closes #3. Also removed combineStartFile since it's not used by any arguments for simplicity's sake. --- Program.cs | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/Program.cs b/Program.cs index d479756..400d83d 100644 --- a/Program.cs +++ b/Program.cs @@ -21,7 +21,7 @@ namespace RSCacheTool bool error = false; bool help = false, extract = false, combine = false, overwrite = false, combineMergeIncomplete = false; - int extractArchive = -1, combineArchive = 40, combineStartFile = 0; + int extractArchive = -1, combineArchive = 40; OptionSet argsParser = new OptionSet() { { "h", "show this message", val => { help = true; } }, @@ -81,7 +81,7 @@ namespace RSCacheTool ExtractFiles(extractArchive, overwrite); if (combine) - CombineSounds(combineArchive, combineStartFile, overwrite, combineMergeIncomplete); + CombineSounds(combineArchive, overwrite, combineMergeIncomplete); } return 0; @@ -323,26 +323,21 @@ namespace RSCacheTool /// /// Combines the sound files (.jag & .ogg) in the specified archive (40 for the build it was made on), and puts them into the soundtracks directory. /// - static void CombineSounds(int archive, int startFile, bool overwriteExisting, bool mergeIncomplete) + static void CombineSounds(int archive, bool overwriteExisting, bool mergeIncomplete) { string archiveDir = outDir + archive + "\\"; string soundDir = outDir + "sound\\"; //gather all index files - string[] indexFiles = Directory.GetFiles(archiveDir, "*.jag", SearchOption.TopDirectoryOnly); + string[] indexFiles = Directory.GetFiles(archiveDir, "*.jaga", SearchOption.TopDirectoryOnly); //create directories if (!Directory.Exists(soundDir + "incomplete\\")) Directory.CreateDirectory(soundDir + "incomplete\\"); - int i = 0; foreach (string indexFileString in indexFiles) { - if (i < startFile) - { - i++; - continue; - } + string indexFileIdString = Path.GetFileNameWithoutExtension(indexFileString); bool incomplete = false; List chunkFiles = new List(); @@ -385,7 +380,7 @@ namespace RSCacheTool if (!incomplete || incomplete && mergeIncomplete) { - string outFile = soundDir + (incomplete ? "incomplete\\" : "") + i + ".ogg"; + string outFile = soundDir + (incomplete ? "incomplete\\" : "") + indexFileIdString + ".ogg"; if (!overwriteExisting && File.Exists(outFile)) Console.WriteLine("Skipping track because it already exists."); @@ -402,7 +397,7 @@ namespace RSCacheTool { soxProcess.StartInfo.Arguments += " " + str; }); - soxProcess.StartInfo.Arguments += " " + soundDir + "incomplete\\" + i + ".ogg "; + soxProcess.StartInfo.Arguments += " " + soundDir + "incomplete\\" + indexFileIdString + ".ogg "; soxProcess.StartInfo.UseShellExecute = false; soxProcess.Start(); @@ -413,13 +408,13 @@ namespace RSCacheTool if (!incomplete) { //clear space - if (File.Exists(soundDir + i + ".ogg")) - File.Delete(soundDir + i + ".ogg"); + if (File.Exists(outFile)) + File.Delete(outFile); - File.Move(soundDir + "incomplete\\" + i + ".ogg", soundDir + i + ".ogg"); + File.Move(soundDir + "incomplete\\" + indexFileIdString + ".ogg", outFile); } - Console.WriteLine(soundDir + (incomplete ? "incomplete\\" : "") + i + ".ogg"); + Console.WriteLine(outFile); } else Console.WriteLine("SoX encountered error code " + soxProcess.ExitCode + " and probably didn't finish processing the files."); @@ -427,8 +422,6 @@ namespace RSCacheTool } else Console.WriteLine("Skipping track because it's incomplete."); - - i++; } //cleanup on isle 4