From 12008b9dda798bd9b0d2c6318c283ea41dc9fca5 Mon Sep 17 00:00:00 2001 From: sora10pls <17801814+sora10pls@users.noreply.github.com> Date: Sat, 11 Sep 2021 16:58:44 -0400 Subject: [PATCH] Simplify Title ID fetch --- pkNX.Game/GameManagerSWSH.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkNX.Game/GameManagerSWSH.cs b/pkNX.Game/GameManagerSWSH.cs index e4297fe8..2bf4aacd 100644 --- a/pkNX.Game/GameManagerSWSH.cs +++ b/pkNX.Game/GameManagerSWSH.cs @@ -10,13 +10,15 @@ namespace pkNX.Game public class GameManagerSWSH : GameManager { public GameManagerSWSH(GameLocation rom, int language) : base(rom, language) { } - private string GetTitleID() => BitConverter.ToString(File.ReadAllBytes(Path.Combine(PathExeFS, "main.npdm")).Skip(0x290).Take(0x08).Reverse().ToArray()).Replace("-", ""); + private string npdmPath => Path.Combine(PathExeFS, "main.npdm"); + private string TitleID => BitConverter.ToUInt64(File.ReadAllBytes(npdmPath), 0x290).ToString("X16"); + protected override void SetMitm() { var basePath = Path.GetDirectoryName(ROM.RomFS); - var TitleID = PathExeFS != null ? GetTitleID() : "0100ABF008968000"; // no way to differentiate without exefs, so default to Sword - var redirect = Path.Combine(basePath, TitleID); + var tid = ROM.ExeFS != null ? TitleID : "0100ABF008968000"; // no way to differentiate without exefs, so default to Sword + var redirect = Path.Combine(basePath, tid); FileMitm.SetRedirect(basePath, redirect); }