Skip to content

Commit 4025d36

Browse files
committed
Avoid parsing .xml bundles twice (resolves #4277)
1 parent bba93b3 commit 4025d36

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/BizHawk.Client.Common/RomLoader.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ private object GetCoreSyncSettings(Type t, Type syncSettingsType)
120120
public GameInfo Game { get; private set; }
121121
public RomGame Rom { get; private set; }
122122
public string CanonicalFullPath { get; private set; }
123+
public XmlGame XMLGameInfo = null;
123124

124125
public bool Deterministic { get; set; }
125126

@@ -682,14 +683,22 @@ private static bool IsDiscForXML(string system, string path)
682683
return Disc.IsValidExtension(ext);
683684
}
684685

685-
private bool LoadXML(string path, CoreComm nextComm, HawkFile file, string forcedCoreName, out IEmulator nextEmulator, out RomGame rom, out GameInfo game)
686+
private bool LoadXML(
687+
string path,
688+
CoreComm nextComm,
689+
HawkFile file,
690+
string forcedCoreName,
691+
out IEmulator nextEmulator,
692+
out RomGame rom,
693+
out GameInfo game,
694+
out XmlGame xmlGame)
686695
{
687696
nextEmulator = null;
688697
rom = null;
689698
game = null;
690699
try
691700
{
692-
var xmlGame = XmlGame.Create(file); // if load fails, are we supposed to retry as a bsnes XML????????
701+
xmlGame = XmlGame.Create(file); // if load fails, are we supposed to retry as a bsnes XML????????
693702
game = xmlGame.GI;
694703

695704
var system = game.System;
@@ -725,6 +734,7 @@ private bool LoadXML(string path, CoreComm nextComm, HawkFile file, string force
725734
}
726735
catch (Exception ex)
727736
{
737+
xmlGame = null;
728738
try
729739
{
730740
// need to get rid of this hack at some point
@@ -886,8 +896,18 @@ public bool LoadRom(string path, CoreComm nextComm, string launchLibretroCore, s
886896
LoadM3U(path, nextComm, file, forcedCoreName, out nextEmulator, out game);
887897
break;
888898
case ".xml":
889-
if (!LoadXML(path, nextComm, file, forcedCoreName, out nextEmulator, out rom, out game))
899+
if (!LoadXML(
900+
path,
901+
nextComm,
902+
file,
903+
forcedCoreName,
904+
out nextEmulator,
905+
out rom,
906+
out game,
907+
out XMLGameInfo))
908+
{
890909
return false;
910+
}
891911
break;
892912
case ".psf":
893913
case ".minipsf":

src/BizHawk.Client.EmuHawk/MainForm.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,13 +3856,10 @@ private bool LoadRomInternal(string path, LoadRomArgs args, out bool failureIsFr
38563856
InputManager.SyncControls(Emulator, MovieSession, Config);
38573857
_multiDiskMode = false;
38583858

3859-
if (oaOpenrom is not null && ".xml".EqualsIgnoreCase(Path.GetExtension(oaOpenrom.Path.Replace("|", "")))
3860-
&& Emulator is not LibsnesCore)
3859+
if (loader.XMLGameInfo is XmlGame xmlGame && Emulator is not LibsnesCore)
38613860
{
38623861
// this is a multi-disk bundler file
38633862
// determine the xml assets and create RomStatusDetails for all of them
3864-
var xmlGame = XmlGame.Create(new HawkFile(oaOpenrom.Path));
3865-
38663863
using var xSw = new StringWriter();
38673864

38683865
for (int xg = 0; xg < xmlGame.Assets.Count; xg++)

0 commit comments

Comments
 (0)