aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-06-27 20:46:39 +0100
committerGitHub <noreply@github.com>2023-06-27 21:46:39 +0200
commit77ef26e748fa66e2b94a31889029c7b477dd6826 (patch)
treec928dad536891c65b586e03dd1babe0c7a217c20
parentfd5680a6ba02896ce30a88e0f683fa3f4b1e0c5a (diff)
downloadNorthstarMods-77ef26e748fa66e2b94a31889029c7b477dd6826.tar.gz
NorthstarMods-77ef26e748fa66e2b94a31889029c7b477dd6826.zip
disable RequiredOnClient mods properly (#658)
* disable RequiredOnClient mods properly * better disabling logic
-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 7ea8134a..c4046132 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 )
}
}