Name single file
This commit is contained in:
parent
4caf35bd84
commit
b1b4a6eaba
1 changed files with 23 additions and 10 deletions
33
Program.cs
33
Program.cs
|
@ -23,7 +23,7 @@ namespace RSCacheTool
|
||||||
|
|
||||||
bool help = false, extract = false, combine = false, overwrite = false, incomplete = false, nameMusic = false, pauseAfterDone = false;
|
bool help = false, extract = false, combine = false, overwrite = false, incomplete = false, nameMusic = false, pauseAfterDone = false;
|
||||||
int extractArchive = -1, combineArchive = 40;
|
int extractArchive = -1, combineArchive = 40;
|
||||||
string combineFile = "";
|
string combineFile = "", nameFile = "";
|
||||||
|
|
||||||
OptionSet argsParser = new OptionSet() {
|
OptionSet argsParser = new OptionSet() {
|
||||||
{ "h", "show this message", val => { help = true; } },
|
{ "h", "show this message", val => { help = true; } },
|
||||||
|
@ -46,7 +46,12 @@ namespace RSCacheTool
|
||||||
{ "f=", "single index file (.jaga) to combine sounds of, if you want to fix just one sound", val => { combineFile = val; } },
|
{ "f=", "single index file (.jaga) to combine sounds of, if you want to fix just one sound", val => { combineFile = val; } },
|
||||||
{ "i", "merge incomplete files (into special directory)", val => { incomplete = true; } },
|
{ "i", "merge incomplete files (into special directory)", val => { incomplete = true; } },
|
||||||
|
|
||||||
{ "n", "try to name music (archive 40, needs archive 17 file 5 too), renames incompletes too if i is set", val => { nameMusic = true; } },
|
{ "n:", "try to name music (archive 40, needs archive 17 file 5 too), renames incompletes too if i is set. If a number is suplied it will only name a single file.", val => {
|
||||||
|
nameMusic = true;
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(val) && val.All(c => c >= '0' && c <= '9'))
|
||||||
|
nameFile = val;
|
||||||
|
}},
|
||||||
|
|
||||||
{ "p", "pause after running (mainly for easier debugging in VS)", val => { pauseAfterDone = true; } }
|
{ "p", "pause after running (mainly for easier debugging in VS)", val => { pauseAfterDone = true; } }
|
||||||
};
|
};
|
||||||
|
@ -103,7 +108,7 @@ namespace RSCacheTool
|
||||||
CombineSounds(combineArchive, combineFile, overwrite, incomplete);
|
CombineSounds(combineArchive, combineFile, overwrite, incomplete);
|
||||||
|
|
||||||
if (nameMusic)
|
if (nameMusic)
|
||||||
NameMusic(incomplete, overwrite);
|
NameMusic(nameFile, incomplete, overwrite);
|
||||||
|
|
||||||
if (pauseAfterDone)
|
if (pauseAfterDone)
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
|
@ -464,7 +469,7 @@ namespace RSCacheTool
|
||||||
/// Tries to parse Archive 17 file 5 to obtain a list of music and their corresponding index file id in archive 40.
|
/// Tries to parse Archive 17 file 5 to obtain a list of music and their corresponding index file id in archive 40.
|
||||||
/// Returns a dictionary that can resolve index file id to the name of the track as it appears in-game.
|
/// Returns a dictionary that can resolve index file id to the name of the track as it appears in-game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void NameMusic(bool incomplete, bool overwrite)
|
public static void NameMusic(string file, bool incomplete, bool overwrite)
|
||||||
{
|
{
|
||||||
//the following is based on even more assumptions than normal made while comparing 2 extracted caches, it's therefore probably the first thing to break
|
//the following is based on even more assumptions than normal made while comparing 2 extracted caches, it's therefore probably the first thing to break
|
||||||
//4B magic number (0x00016902) - 2B a file id? - 2B amount of files (higher than actual entries sometimes) - 2B amount of files
|
//4B magic number (0x00016902) - 2B a file id? - 2B amount of files (higher than actual entries sometimes) - 2B amount of files
|
||||||
|
@ -526,9 +531,13 @@ namespace RSCacheTool
|
||||||
if (!Directory.Exists(outDir + "sound\\named\\"))
|
if (!Directory.Exists(outDir + "sound\\named\\"))
|
||||||
Directory.CreateDirectory(outDir + "sound\\named\\");
|
Directory.CreateDirectory(outDir + "sound\\named\\");
|
||||||
|
|
||||||
foreach (string file in Directory.GetFiles(outDir + "sound\\"))
|
foreach (string soundFile in Directory.GetFiles(outDir + "sound\\"))
|
||||||
{
|
{
|
||||||
string fileIdString = Path.GetFileNameWithoutExtension(file);
|
string fileIdString = Path.GetFileNameWithoutExtension(soundFile);
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(file) && fileIdString != file)
|
||||||
|
continue;
|
||||||
|
|
||||||
uint fileId;
|
uint fileId;
|
||||||
if (uint.TryParse(fileIdString, out fileId))
|
if (uint.TryParse(fileIdString, out fileId))
|
||||||
{
|
{
|
||||||
|
@ -541,7 +550,7 @@ namespace RSCacheTool
|
||||||
string destFile = outDir + "sound\\named\\" + trackName + ".ogg";
|
string destFile = outDir + "sound\\named\\" + trackName + ".ogg";
|
||||||
|
|
||||||
if (!File.Exists(destFile) || overwrite)
|
if (!File.Exists(destFile) || overwrite)
|
||||||
File.Copy(file, destFile, true);
|
File.Copy(soundFile, destFile, true);
|
||||||
|
|
||||||
Console.WriteLine(destFile);
|
Console.WriteLine(destFile);
|
||||||
}
|
}
|
||||||
|
@ -555,9 +564,13 @@ namespace RSCacheTool
|
||||||
if (!Directory.Exists(outDir + "sound\\named\\incomplete\\"))
|
if (!Directory.Exists(outDir + "sound\\named\\incomplete\\"))
|
||||||
Directory.CreateDirectory(outDir + "sound\\named\\incomplete");
|
Directory.CreateDirectory(outDir + "sound\\named\\incomplete");
|
||||||
|
|
||||||
foreach (string file in Directory.GetFiles(outDir + "sound\\incomplete\\"))
|
foreach (string soundFile in Directory.GetFiles(outDir + "sound\\incomplete\\"))
|
||||||
{
|
{
|
||||||
string fileIdString = Path.GetFileNameWithoutExtension(file);
|
string fileIdString = Path.GetFileNameWithoutExtension(soundFile);
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(file) && fileIdString != file)
|
||||||
|
continue;
|
||||||
|
|
||||||
uint fileId;
|
uint fileId;
|
||||||
if (uint.TryParse(fileIdString, out fileId))
|
if (uint.TryParse(fileIdString, out fileId))
|
||||||
{
|
{
|
||||||
|
@ -570,7 +583,7 @@ namespace RSCacheTool
|
||||||
string destFile = outDir + "sound\\named\\incomplete\\" + trackName + ".ogg";
|
string destFile = outDir + "sound\\named\\incomplete\\" + trackName + ".ogg";
|
||||||
|
|
||||||
if (!File.Exists(destFile) || overwrite)
|
if (!File.Exists(destFile) || overwrite)
|
||||||
File.Copy(file, destFile, true);
|
File.Copy(soundFile, destFile, true);
|
||||||
|
|
||||||
Console.WriteLine(destFile);
|
Console.WriteLine(destFile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue