-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for extracting Sting's .pck files in the PC versions of Y…
…ggdra Union and Riviera
- Loading branch information
1 parent
566de2b
commit 4b6cbb6
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using HyoutaPluginBase; | ||
using HyoutaTools.Tales.Vesperia.NUB; | ||
using HyoutaUtils; | ||
using HyoutaUtils.Streams; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace HyoutaTools.Sting { | ||
public class PcPckFile { | ||
public static void Extract(DuplicatableStream file, string destination) { | ||
System.IO.Directory.CreateDirectory(destination); | ||
|
||
uint fileCount = file.ReadUInt32(); | ||
uint headerLength = file.ReadUInt32(); | ||
|
||
for (uint i = 0; i < fileCount; ++i) { | ||
string filename = file.ReadSizedString(0x40, TextUtils.GameTextEncoding.ShiftJIS).TrimNull(); | ||
uint length = file.ReadUInt32(); | ||
uint offset = file.ReadUInt32(); | ||
using (FileStream newFile = new FileStream(System.IO.Path.Combine(destination, filename), FileMode.Create)) { | ||
long p = file.Position; | ||
file.Position = offset; | ||
StreamUtils.CopyStream(file, newFile, length); | ||
file.Position = p; | ||
} | ||
} | ||
} | ||
|
||
public static int ExecuteExtract(List<string> args) { | ||
if (args.Count == 0) { | ||
Console.WriteLine("Sting.PcPckFile.Extract file.pck [output_folder]"); | ||
return -1; | ||
} | ||
|
||
try { | ||
Extract(new DuplicatableFileStream(args[0]), args.Count > 1 ? args[1] : (args[0] + ".ex")); | ||
return 0; | ||
} catch (Exception e) { | ||
Console.WriteLine(e.Message); | ||
return -1; | ||
} | ||
} | ||
} | ||
} |