From 0dc68de00d95a5600ecef38013fa00a992654334 Mon Sep 17 00:00:00 2001 From: Fireball <32598847+FIr3baL@users.noreply.github.com> Date: Tue, 6 Aug 2024 19:19:35 +0200 Subject: [PATCH] Allow reusage of previous loaded modoptions for gameversions. This removes an error, which occurs when using bots and switching battles. (battle room crash) --- LuaMenu/widgets/gui_modoptions_panel.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/LuaMenu/widgets/gui_modoptions_panel.lua b/LuaMenu/widgets/gui_modoptions_panel.lua index 3136e0ab6..fab2a6ce3 100644 --- a/LuaMenu/widgets/gui_modoptions_panel.lua +++ b/LuaMenu/widgets/gui_modoptions_panel.lua @@ -21,6 +21,7 @@ local battleLobby local localModoptions = {} local modoptionControlNames = {} local modoptions +local modoptionsByGame = {} -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -737,7 +738,10 @@ function ModoptionsPanel.LoadModoptions(gameName, newBattleLobby) return VFS.Include("modoptions.lua", nil, VFS.ZIP) end - do + if modoptionsByGame[gameName] then + modoptions = modoptionsByGame[gameName] + else + local alreadyLoaded = false for _, archive in pairs(VFS.GetLoadedArchives()) do if archive == gameName then @@ -745,11 +749,14 @@ function ModoptionsPanel.LoadModoptions(gameName, newBattleLobby) break end end + if alreadyLoaded then - modoptions = VFS.Include("modoptions.lua", nil, VFS.ZIP) + Spring.Log(LOG_SECTION, LOG.ERROR, "Game archive already loaded, cannot fetch modoptions") else modoptions = VFS.UseArchive(gameName, LoadModOptions) + modoptionsByGame[gameName] = modoptions end + end