diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 334e8ea4ab..d0422a7792 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -120,6 +120,7 @@ namespace BizHawk.Client.Common public GameInfo Game { get; private set; } public RomGame Rom { get; private set; } public string CanonicalFullPath { get; private set; } + public XmlGame XMLGameInfo = null; public bool Deterministic { get; set; } @@ -682,14 +683,22 @@ namespace BizHawk.Client.Common return Disc.IsValidExtension(ext); } - private bool LoadXML(string path, CoreComm nextComm, HawkFile file, string forcedCoreName, out IEmulator nextEmulator, out RomGame rom, out GameInfo game) + private bool LoadXML( + string path, + CoreComm nextComm, + HawkFile file, + string forcedCoreName, + out IEmulator nextEmulator, + out RomGame rom, + out GameInfo game, + out XmlGame xmlGame) { nextEmulator = null; rom = null; game = null; try { - var xmlGame = XmlGame.Create(file); // if load fails, are we supposed to retry as a bsnes XML???????? + xmlGame = XmlGame.Create(file); // if load fails, are we supposed to retry as a bsnes XML???????? game = xmlGame.GI; var system = game.System; @@ -725,6 +734,7 @@ namespace BizHawk.Client.Common } catch (Exception ex) { + xmlGame = null; try { // need to get rid of this hack at some point @@ -886,8 +896,18 @@ namespace BizHawk.Client.Common LoadM3U(path, nextComm, file, forcedCoreName, out nextEmulator, out game); break; case ".xml": - if (!LoadXML(path, nextComm, file, forcedCoreName, out nextEmulator, out rom, out game)) + if (!LoadXML( + path, + nextComm, + file, + forcedCoreName, + out nextEmulator, + out rom, + out game, + out XMLGameInfo)) + { return false; + } break; case ".psf": case ".minipsf": diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 405d03c375..9f477f30d3 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3856,13 +3856,10 @@ namespace BizHawk.Client.EmuHawk InputManager.SyncControls(Emulator, MovieSession, Config); _multiDiskMode = false; - if (oaOpenrom is not null && ".xml".EqualsIgnoreCase(Path.GetExtension(oaOpenrom.Path.Replace("|", ""))) - && Emulator is not LibsnesCore) + if (loader.XMLGameInfo is XmlGame xmlGame && Emulator is not LibsnesCore) { // this is a multi-disk bundler file // determine the xml assets and create RomStatusDetails for all of them - var xmlGame = XmlGame.Create(new HawkFile(oaOpenrom.Path)); - using var xSw = new StringWriter(); for (int xg = 0; xg < xmlGame.Assets.Count; xg++)