aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-06-27 20:46:39 +0100
committerGeckoEidechse <gecko.eidechse+git@pm.me>2023-07-11 01:32:40 +0200
commiteac2ad09eeb901486410ce8306bc6ff30f0b7f0f (patch)
tree9c102402b9bbcb2ac1b49294c125b44633c312df
parentf4f3c6d863840682d380839133f2c1c9530ef34b (diff)
downloadNorthstarMods-eac2ad09eeb901486410ce8306bc6ff30f0b7f0f.tar.gz
NorthstarMods-eac2ad09eeb901486410ce8306bc6ff30f0b7f0f.zip
disable RequiredOnClient mods properly (#658)
* disable RequiredOnClient mods properly * better disabling logic (cherry picked from commit 77ef26e748fa66e2b94a31889029c7b477dd6826)
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut34
1 files changed, 29 insertions, 5 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
index 7ea8134a8..c40461329 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
@@ -1059,15 +1059,39 @@ void function ThreadedAuthAndConnectToServer( string password = "" )
if ( NSWasAuthSuccessful() )
{
- bool modsChanged
+ bool modsChanged = false
- // unload mods we don't need, load necessary ones and reload mods before connecting
+ // disable all RequiredOnClient mods that are not required by the server and are currently enabled
+ foreach ( string modName in NSGetModNames() )
+ {
+ if ( NSIsModRequiredOnClient( modName ) && NSIsModEnabled( modName ) )
+ {
+ // find the mod name in the list of server required mods
+ bool found = false
+ foreach ( RequiredModInfo mod in file.lastSelectedServer.requiredMods )
+ {
+ if (mod.name == modName)
+ {
+ found = true
+ break
+ }
+ }
+ // if we didnt find the mod name, disable the mod
+ if (!found)
+ {
+ modsChanged = true
+ NSSetModEnabled( modName, false )
+ }
+ }
+ }
+
+ // enable all RequiredOnClient mods that are required by the server and are currently disabled
foreach ( RequiredModInfo mod in file.lastSelectedServer.requiredMods )
{
- if ( NSIsModRequiredOnClient( mod.name ) )
+ if ( NSIsModRequiredOnClient( mod.name ) && !NSIsModEnabled( mod.name ))
{
- modsChanged = modsChanged || NSIsModEnabled( mod.name ) != file.lastSelectedServer.requiredMods.contains( mod )
- NSSetModEnabled( mod.name, file.lastSelectedServer.requiredMods.contains( mod ) )
+ modsChanged = true
+ NSSetModEnabled( mod.name, true )
}
}