upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tools/rpf9dump/Program.cs
diff options
context:
space:
mode:
authortupacfan04 <359939016+tupacfan04@users.noreply.github.com>2026-11-22 12:37:20 -0600
committertupacfan04 <359939016+tupacfan04@users.noreply.github.com>2026-11-22 16:06:38 -0600
commit60868f0ebd7e501cddfe008fddd4ea057a746815 (patch)
treeaa3f6f399fc7e7e415ec2fa4ccef31056f01ce37 /tools/rpf9dump/Program.cs
parent4c52ce27a6cf4af2bbf07a343ede39c5f1572b8d (diff)
rpf9dump: reject an unknown mode before touching the source or output
An unknown first argument fell through every mode branch: it created <outdir>/<source>, printed ok=0 fail=0 skip=0 and exited 0, which make_game reads as a finished stage. Check the mode first, print one usage listing all five modes (audio and xma were missing) and exit 2.
Diffstat (limited to 'tools/rpf9dump/Program.cs')
-rw-r--r--tools/rpf9dump/Program.cs16
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/rpf9dump/Program.cs b/tools/rpf9dump/Program.cs
index f090e3cfd..bf92e5aa7 100644
--- a/tools/rpf9dump/Program.cs
+++ b/tools/rpf9dump/Program.cs
@@ -5,7 +5,11 @@ using System.Globalization;
5using System.Text.Json; 5using System.Text.Json;
6using RpfPreview.Core; 6using RpfPreview.Core;
7 7
8if (args.Length < 3) { Console.WriteLine("usage: rpf9dump ttpf|models|textures <source> <outdir> [--start BYTES] [--length BYTES]"); return 2; } 8// The mode is checked before the source or the output folder is touched. A typo used to fall through every branch:
9// it created the output folder, printed ok=0 fail=0 skip=0 and exited 0, which make_game reads as a finished stage.
10string[] modes = ["ttpf", "audio", "xma", "models", "textures"];
11if (args.Length < 3) { Usage(); return 2; }
12if (!modes.Contains(args[0])) { Console.Error.WriteLine($"unknown mode '{args[0]}'"); Usage(); return 2; }
9string mode = args[0], src = Path.GetFullPath(args[1]), outRoot = Path.GetFullPath(args[2]); 13string mode = args[0], src = Path.GetFullPath(args[1]), outRoot = Path.GetFullPath(args[2]);
10// --start/--length scan one window of the file instead of the whole archive. A window is a raw slice of an 14// --start/--length scan one window of the file instead of the whole archive. A window is a raw slice of an
11// archive (`levels.rpf` cut at an offset), so it need not carry the file's header and it is not an 15// archive (`levels.rpf` cut at an offset), so it need not carry the file's header and it is not an
@@ -375,6 +379,16 @@ static void WithdrawMarker(string path)
375 File.Delete(path); 379 File.Delete(path);
376} 380}
377 381
382static void Usage()
383{
384 Console.WriteLine("usage: rpf9dump <mode> <source> <outdir> [--start BYTES] [--length BYTES]");
385 Console.WriteLine(" ttpf texture dictionaries and world texture pools as DDS");
386 Console.WriteLine(" models drawable models as OBJ, with their embedded textures");
387 Console.WriteLine(" textures texture dictionaries as DDS");
388 Console.WriteLine(" audio AWC banks whole, plus audio_manifest.json");
389 Console.WriteLine(" xma XMA2 streams as RIFF XMA2 .wav for ffmpeg");
390}
391
378// One exported entry: its manifest row (null when nothing was written), counts, a failure to report in order, 392// One exported entry: its manifest row (null when nothing was written), counts, a failure to report in order,
379// and how many of its failures were output-write failures (the ones a retry can fix; decode failures are not). 393// and how many of its failures were output-write failures (the ones a retry can fix; decode failures are not).
380readonly record struct Result(object? Row, int Ok, int Fail, int Embedded, ModelDecodeFailure? DecodeFailure, string? Error, int WriteFail); 394readonly record struct Result(object? Row, int Ok, int Fail, int Embedded, ModelDecodeFailure? DecodeFailure, string? Error, int WriteFail);