diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index 0db096835d..02fd411a76 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -258,13 +258,10 @@ namespace BizHawk.Client.Common if (OpenAdvanced is OpenAdvanced_Libretro) { - // kind of dirty.. we need to stash this, and then we can unstash it in a moment, in case the core doesn't fail - var oldGame = Global.Game; - // must be done before LoadNoGame (which triggers retro_init and the paths to be consumed by the core) // game name == name of core string codePathPart = Path.GetFileNameWithoutExtension(launchLibretroCore); - Global.Game = game = new GameInfo { Name = codePathPart, System = "Libretro" }; + Game = game = new GameInfo { Name = codePathPart, System = "Libretro" }; var retro = new LibretroCore(nextComm, game, launchLibretroCore); nextEmulator = retro; @@ -272,7 +269,6 @@ namespace BizHawk.Client.Common { // if we are allowed to run NoGame and we don't have a game, boot up the core that way bool ret = retro.LoadNoGame(); - Global.Game = oldGame; if (!ret) { @@ -318,8 +314,6 @@ namespace BizHawk.Client.Common } } - Global.Game = oldGame; - if (!ret) { DoLoadErrorCallback("Libretro failed to load the given file. This is probably due to a core/content mismatch. Moreover, the process is now likely to be hosed. We suggest you restart the program.", "Libretro"); diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index b4c4ca5911..14d9bc3b3c 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3679,8 +3679,11 @@ namespace BizHawk.Client.EmuHawk //path = ioa_openrom.Path; } + var oldGame = Global.Game; var result = loader.LoadRom(path, nextComm, ioaRetro?.CorePath); + Global.Game = result ? loader.Game : oldGame; + // we need to replace the path in the OpenAdvanced with the canonical one the user chose. // It can't be done until loader.LoadRom happens (for CanonicalFullPath) // i'm not sure this needs to be more abstractly engineered yet until we have more OpenAdvanced examples @@ -3703,7 +3706,6 @@ namespace BizHawk.Client.EmuHawk { string openAdvancedArgs = $"*{OpenAdvancedSerializer.Serialize(ioa)}"; Emulator = loader.LoadedEmulator; - Global.Game = loader.Game; InputManager.SyncControls(Emulator, Config); if (oaOpenrom != null && Path.GetExtension(oaOpenrom.Path.Replace("|", "")).ToLowerInvariant() == ".xml" && !(Emulator is LibsnesCore))