From 93c15fbf25b63d1722bc407f2b0f5b55e3e1d3cb Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 20 Nov 2024 21:32:15 +0100 Subject: [PATCH] fix: enable required local mods on server join --- .../vscripts/ui/menu_ns_serverbrowser.nut | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 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 247d619a9..f2effd128 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1010,9 +1010,7 @@ void function OnServerSelected_Threaded( var button ) if ( IsCoreMod( mod.name ) ) continue - array modVersions = GetModVersions( mod.name ) - - if ( !NSGetModNames().contains( mod.name ) || !modVersions.contains( mod.version ) ) + if ( !NSGetModNames().contains( mod.name ) || !GetModVersions( mod.name ).contains( mod.version ) ) { // Auto-download mod if ( autoDownloadAllowed ) @@ -1145,25 +1143,31 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha { string modName = mod.name string modVersion = mod.version - array localModInfo = NSGetModInformation( modName ) - ModInfo firstModInfo = localModInfo[0] + array localModInfos = NSGetModInformation( modName ) // Tolerate core mods (only Northstar.Custom for now) having a different version than server if ( IsCoreMod(modName) ) { - if ( !firstModInfo.enabled ) + if ( !localModInfos[0].enabled ) { modsChanged = true NSSetModEnabled( modName, true ) - print(format("Enabled \"%s\" (v%s) to join server.", modName, firstModInfo.version)) + print(format("Enabled \"%s\" (v%s) to join server.", modName, localModInfos[0].version)) } } - else if ( !firstModInfo.enabled ) //todo(in multiple versions PR): loop over `NSGetModInformation` members and check versions + else { - modsChanged = true - NSSetModEnabled( mod.name, true ) - print(format("Enabled \"%s\" (v%s) to join server.", modName, modVersion)) + foreach( localMod in localModInfos ) + { + if ( localMod.version == mod.version ) + { + modsChanged = true + NSSetModEnabled( mod.name, true ) + print(format("Enabled \"%s\" (v%s) to join server.", modName, modVersion)) + break + } + } } }