Skip to content

Commit

Permalink
Allow reusage of previous loaded modoptions for gameversions.
Browse files Browse the repository at this point in the history
This removes an error, which occurs when using bots and switching battles. (battle room crash)
  • Loading branch information
FIr3baL committed Aug 6, 2024
1 parent ee6dc48 commit 0dc68de
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions LuaMenu/widgets/gui_modoptions_panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local battleLobby
local localModoptions = {}
local modoptionControlNames = {}
local modoptions
local modoptionsByGame = {}

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -737,19 +738,25 @@ 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
alreadyLoaded = true
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


Expand Down

0 comments on commit 0dc68de

Please sign in to comment.