Avoid parsing `.xml` bundles twice (resolves #4277)

This commit is contained in:
YoshiRulz 2025-05-25 01:10:51 +10:00
parent bba93b33d6
commit 4025d36b18
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 24 additions and 7 deletions

View File

@ -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":

View File

@ -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++)