From 080e1bdc6ef3d505a23af5fbaba4dc2236cc9fe7 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Mon, 29 Jul 2024 00:54:21 +0200 Subject: [PATCH 01/24] refactor: use new function names --- .../vscripts/ui/menu_ns_serverbrowser.nut | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 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 4f17dedf2..38f3f9f1e 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1092,25 +1092,30 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha if ( NSWasAuthSuccessful() ) { // disable all RequiredOnClient mods that are not required by the server and are currently enabled - foreach ( string modName in NSGetModNames() ) + foreach ( RequiredModInfo mod in NSGetModNamesAndVersions() ) { - if ( NSIsModRequiredOnClient( modName ) && NSIsModEnabled( modName ) ) + string modName = mod.name + string modVersion = mod.version + + if ( NSIsModRequiredOnClientWithVersion( modName, modVersion ) && NSIsModEnabledWithVersion( modName, modVersion ) ) { // 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) + if (mod.name == modName && mod.version == modVersion) { found = true + print(format("Found \"%s\" v%s", modName, modVersion)) break } } - // if we didnt find the mod name, disable the mod + // if we didn't find the mod name, disable the mod if (!found) { modsChanged = true - NSSetModEnabled( modName, false ) + NSSetModEnabledWithVersion( modName, modVersion, false ) + print(format("Disabled \"%s\" v%s", modName, modVersion)) } } } @@ -1118,10 +1123,14 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha // 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 ) && !NSIsModEnabled( mod.name )) + string modName = mod.name + string modVersion = mod.version + + if ( NSIsModRequiredOnClientWithVersion( modName, modVersion ) && !NSIsModEnabledWithVersion( modName, modVersion ) ) { modsChanged = true - NSSetModEnabled( mod.name, true ) + NSSetModEnabledWithVersion( modName, modVersion, true ) + print(format("Enabled \"%s\" v%s", modName, modVersion)) } } From eb6ba6f4343574ac00990f452d7e2a2d88bc5b88 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Tue, 30 Jul 2024 01:00:46 +0200 Subject: [PATCH 02/24] refactor: use NSGetModsInformation to reduce number of native calls in menu_ns_modmenu.nut Each time a "NSGetMod*" or "NSIsMod*" method is called, launcher will loop over all mods until the correct one is found, which is not that optimal. NSGetModsInformation directly (in one loop) builds up an array of structs containing all required mod information to be displayed on the mods view. --- .../vscripts/cl_northstar_client_init.nut | 11 +++++ .../scripts/vscripts/ui/menu_ns_modmenu.nut | 46 ++++++------------- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut b/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut index 3560fd562..7df41ca1e 100644 --- a/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut +++ b/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut @@ -26,6 +26,17 @@ global struct UIPresenceStruct { int gameState } +global struct ModInfo +{ + string name = "" + string version = "" + string downloadLink = "" + int loadPriority = 0 + bool enabled = false + bool requiredOnClient = false + array conVars = [] +} + global struct RequiredModInfo { string name diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index 3f643aa3d..a5e3858a9 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -5,17 +5,8 @@ global function AddNorthstarModMenu_MainMenuFooter global function ReloadMods -struct modData { - string name = "" - string version = "" - string link = "" - int loadPriority = 0 - bool enabled = false - array conVars = [] -} - struct panelContent { - modData& mod + ModInfo& mod bool isHeader = false } @@ -40,7 +31,7 @@ struct { array enabledMods var currentButton string searchTerm - modData& lastMod + ModInfo& lastMod } file const int PANELS_LEN = 15 @@ -324,25 +315,26 @@ void function UpdateList() void function RefreshMods() { - array modNames = NSGetModNames() + array mods = NSGetModsInformation() file.mods.clear() bool reverse = GetConVarBool( "modlist_reverse" ) - int lastLoadPriority = reverse ? NSGetModLoadPriority( modNames[ modNames.len() - 1 ] ) + 1 : -1 + int lastLoadPriority = reverse ? mods.top().loadPriority + 1 : -1 string searchTerm = Hud_GetUTF8Text( Hud_GetChild( file.menu, "BtnModsSearch" ) ).tolower() - for ( int i = reverse ? modNames.len() - 1 : 0; - reverse ? ( i >= 0 ) : ( i < modNames.len() ); + for ( int i = reverse ? mods.len() - 1 : 0; + reverse ? ( i >= 0 ) : ( i < mods.len() ); i += ( reverse ? -1 : 1) ) { - string mod = modNames[i] + ModInfo mod = mods[i] + string modName = mod.name - if ( searchTerm.len() && mod.tolower().find( searchTerm ) == null ) + if ( searchTerm.len() && modName.tolower().find( searchTerm ) == null ) continue - bool enabled = NSIsModEnabled( mod ) - bool required = NSIsModRequiredOnClient( mod ) + bool enabled = mod.enabled + bool required = mod.requiredOnClient switch ( GetConVarInt( "filter_mods" ) ) { case filterShow.ONLY_ENABLED: @@ -363,11 +355,11 @@ void function RefreshMods() break } - int pr = NSGetModLoadPriority( mod ) + int pr = mod.loadPriority if ( reverse ? pr < lastLoadPriority : pr > lastLoadPriority ) { - modData m + ModInfo m m.name = pr.tostring() panelContent c @@ -377,16 +369,8 @@ void function RefreshMods() lastLoadPriority = pr } - modData m - m.name = mod - m.version = NSGetModVersionByModName( mod ) - m.link = NSGetModDownloadLinkByModName( mod ) - m.loadPriority = NSGetModLoadPriority( mod ) - m.enabled = enabled - m.conVars = NSGetModConvarsByModName( mod ) - panelContent c - c.mod = m + c.mod = mod file.mods.append( c ) } @@ -400,7 +384,7 @@ void function DisplayModPanels() break panelContent c = file.mods[ file.scrollOffset + i ] - modData mod = c.mod + ModInfo mod = c.mod var btn = Hud_GetChild( panel, "BtnMod" ) var headerLabel = Hud_GetChild( panel, "Header" ) var box = Hud_GetChild( panel, "ControlBox" ) From 9d96ffa909565575bfd6ef86ae3ee7102a7b3c3f Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 00:30:04 +0200 Subject: [PATCH 03/24] feat: add modVersion parameter to NSSetModEnabled function --- .github/nativefuncs.json | 6 +++--- .../mod/scripts/vscripts/ui/menu_ns_modmenu.nut | 10 ++++++---- .../scripts/vscripts/ui/menu_ns_serverbrowser.nut | 12 +++++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index 889432d73..7340a1a3b 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -16,7 +16,7 @@ "name":"NSSetModEnabled", "helpText":"", "returnTypeString":"void", - "argTypes":"string modName, bool enabled" + "argTypes":"string modName, string modVersion, bool enabled" }, { "name":"NSGetModDescriptionByModName", @@ -264,7 +264,7 @@ "name":"NSSetModEnabled", "helpText":"", "returnTypeString":"void", - "argTypes":"string modName, bool enabled" + "argTypes":"string modName, string modVersion, bool enabled" }, { "name":"NSGetModDescriptionByModName", @@ -464,7 +464,7 @@ "name":"NSSetModEnabled", "helpText":"", "returnTypeString":"void", - "argTypes":"string modName, bool enabled" + "argTypes":"string modName, string modVersion, bool enabled" }, { "name":"NSGetModDescriptionByModName", diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index a5e3858a9..6e0e3fc2c 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -193,12 +193,13 @@ void function OnModButtonFocused( var button ) void function OnModButtonPressed( var button ) { - string modName = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) + file.scrollOffset - 1 ].mod.name + ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) + file.scrollOffset - 1 ].mod + string modName = mod.name if ( StaticFind( modName ) && NSIsModEnabled( modName ) ) CoreModToggleDialog( modName ) else { - NSSetModEnabled( modName, !NSIsModEnabled( modName ) ) + NSSetModEnabled( modName, mod.version, !NSIsModEnabled( modName ) ) var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) - 1 ] SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName ) SetControlBarColor( modName ) @@ -275,8 +276,9 @@ void function CoreModToggleDialog( string mod ) void function DisableMod() { - string modName = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod.name - NSSetModEnabled( modName, false ) + ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod + string modName = mod.name + NSSetModEnabled( modName, mod.version, false ) var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) - 1] SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName ) 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 2590a32f1..a42b5f1fc 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1164,7 +1164,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) if (!found) { modsChanged = true - NSSetModEnabledWithVersion( modName, modVersion, false ) + NSSetModEnabled( modName, modVersion, false ) print(format("Disabled \"%s\" v%s", modName, modVersion)) } } @@ -1179,7 +1179,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) if ( NSIsModRequiredOnClientWithVersion( modName, modVersion ) && !NSIsModEnabledWithVersion( modName, modVersion ) ) { modsChanged = true - NSSetModEnabledWithVersion( modName, modVersion, true ) + NSSetModEnabled( modName, modVersion, true ) print(format("Enabled \"%s\" v%s", modName, modVersion)) } } @@ -1439,8 +1439,10 @@ bool function JoinServer( ServerInfo server, string password = "" ) bool modsChanged = false // disable all RequiredOnClient mods that are not required by the server and are currently enabled - foreach ( string modName in NSGetModNames() ) + foreach ( ModInfo mod in NSGetModsInformation() ) { + string modName = mod.name + if ( NSIsModRequiredOnClient( modName ) && NSIsModEnabled( modName ) ) { // find the mod name in the list of server required mods @@ -1457,7 +1459,7 @@ bool function JoinServer( ServerInfo server, string password = "" ) if ( !found ) { modsChanged = true - NSSetModEnabled( modName, false ) + NSSetModEnabled( modName, mod.version, false ) } } } @@ -1468,7 +1470,7 @@ bool function JoinServer( ServerInfo server, string password = "" ) if ( NSIsModRequiredOnClient( mod.name ) && !NSIsModEnabled( mod.name ) ) { modsChanged = true - NSSetModEnabled( mod.name, true ) + NSSetModEnabled( mod.name, mod.version, true ) } } From e994cd280931216544835a65157bd7ff9a1a078c Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 01:03:46 +0200 Subject: [PATCH 04/24] feat: add modVersion parameter to NSIsModEnabled function --- .github/nativefuncs.json | 6 +-- .../scripts/vscripts/ui/menu_ns_modmenu.nut | 46 +++++++++---------- .../vscripts/ui/menu_ns_serverbrowser.nut | 8 ++-- .../scripts/vscripts/ui/panel_mainmenu.nut | 5 +- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index 7340a1a3b..0c3cb96be 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -10,7 +10,7 @@ "name":"NSIsModEnabled", "helpText":"", "returnTypeString":"bool", - "argTypes":"string modName" + "argTypes":"string modName, string modVersion" }, { "name":"NSSetModEnabled", @@ -258,7 +258,7 @@ "name":"NSIsModEnabled", "helpText":"", "returnTypeString":"bool", - "argTypes":"string modName" + "argTypes":"string modName, string modVersion" }, { "name":"NSSetModEnabled", @@ -458,7 +458,7 @@ "name":"NSIsModEnabled", "helpText":"", "returnTypeString":"bool", - "argTypes":"string modName" + "argTypes":"string modName, string modVersion" }, { "name":"NSSetModEnabled", diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index 6e0e3fc2c..42b4a1f1f 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -184,7 +184,7 @@ void function OnModButtonFocused( var button ) Hud_SetVisible( linkButton, false ) } - SetControlBarColor( modName ) + SetControlBarColor( modName, file.lastMod.version ) bool required = NSIsModRequiredOnClient( modName ) Hud_SetVisible( Hud_GetChild( file.menu, "WarningLegendLabel" ), required ) @@ -195,15 +195,15 @@ void function OnModButtonPressed( var button ) { ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) + file.scrollOffset - 1 ].mod string modName = mod.name - if ( StaticFind( modName ) && NSIsModEnabled( modName ) ) + if ( StaticFind( modName ) && NSIsModEnabled( modName, mod.version ) ) CoreModToggleDialog( modName ) else { - NSSetModEnabled( modName, mod.version, !NSIsModEnabled( modName ) ) + NSSetModEnabled( modName, mod.version, !NSIsModEnabled( modName, mod.version ) ) var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) - 1 ] - SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName ) - SetControlBarColor( modName ) - SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modName ) + SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName, mod.version ) + SetControlBarColor( modName, mod.version ) + SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modName, mod.version ) // RefreshMods() UpdateListSliderPosition() UpdateListSliderHeight() @@ -281,9 +281,9 @@ void function DisableMod() NSSetModEnabled( modName, mod.version, false ) var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) - 1] - SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName ) - SetControlBarColor( modName ) - SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modName ) + SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName, mod.version ) + SetControlBarColor( modName, mod.version ) + SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modName, mod.version ) RefreshMods() } @@ -291,10 +291,10 @@ void function DisableMod() array function GetEnabledModsArray() { array enabledMods - foreach ( string mod in NSGetModNames() ) + foreach ( ModInfo mod in NSGetModsInformation() ) { - if ( NSIsModEnabled( mod ) ) - enabledMods.append( mod ) + if ( mod.enabled ) + enabledMods.append( mod.name ) } return enabledMods } @@ -416,39 +416,39 @@ void function DisplayModPanels() Hud_SetVisible( headerLabel, false ) - SetControlBoxColor( box, mod.name ) + SetControlBoxColor( box, mod.name, mod.version ) Hud_SetVisible( box, true ) Hud_SetVisible( line, false ) Hud_SetVisible( warning, NSIsModRequiredOnClient( c.mod.name ) ) - SetModEnabledHelperImageAsset( enabledImage, c.mod.name ) + SetModEnabledHelperImageAsset( enabledImage, c.mod.name, c.mod.version ) } Hud_SetVisible( panel, true ) } } -void function SetModEnabledHelperImageAsset( var panel, string modName ) +void function SetModEnabledHelperImageAsset( var panel, string modName, string modVersion ) { - if( NSIsModEnabled( modName ) ) + if( NSIsModEnabled( modName, modVersion ) ) RuiSetImage( Hud_GetRui( panel ), "basicImage", $"rui/menu/common/merit_state_success" ) else RuiSetImage( Hud_GetRui( panel ), "basicImage", $"rui/menu/common/merit_state_failure" ) - RuiSetFloat3(Hud_GetRui( panel ), "basicImageColor", GetControlColorForMod( modName ) ) + RuiSetFloat3(Hud_GetRui( panel ), "basicImageColor", GetControlColorForMod( modName, modVersion ) ) Hud_SetVisible( panel, true ) } -void function SetControlBoxColor( var box, string modName ) +void function SetControlBoxColor( var box, string modName, string modVersion ) { var rui = Hud_GetRui( box ) // if ( NSIsModEnabled( modName ) ) // RuiSetFloat3(rui, "basicImageColor", <0,1,0>) // else // RuiSetFloat3(rui, "basicImageColor", <1,0,0>) - RuiSetFloat3(rui, "basicImageColor", GetControlColorForMod( modName ) ) + RuiSetFloat3(rui, "basicImageColor", GetControlColorForMod( modName, modVersion ) ) } -void function SetControlBarColor( string modName ) +void function SetControlBarColor( string modName, string modVersion ) { var bar_element = Hud_GetChild( file.menu, "ModEnabledBar" ) var bar = Hud_GetRui( bar_element ) @@ -456,13 +456,13 @@ void function SetControlBarColor( string modName ) // RuiSetFloat3(bar, "basicImageColor", <0,1,0>) // else // RuiSetFloat3(bar, "basicImageColor", <1,0,0>) - RuiSetFloat3(bar, "basicImageColor", GetControlColorForMod( modName ) ) + RuiSetFloat3(bar, "basicImageColor", GetControlColorForMod( modName, modVersion ) ) Hud_SetVisible( bar_element, true ) } -vector function GetControlColorForMod( string modName ) +vector function GetControlColorForMod( string modName, string modVersion ) { - if ( NSIsModEnabled( modName ) ) + if ( NSIsModEnabled( modName, modVersion ) ) switch ( GetConVarInt( "colorblind_mode" ) ) { case 1: 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 a42b5f1fc..5eaeb2a8d 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1147,7 +1147,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) string modName = mod.name string modVersion = mod.version - if ( NSIsModRequiredOnClientWithVersion( modName, modVersion ) && NSIsModEnabledWithVersion( modName, modVersion ) ) + if ( NSIsModRequiredOnClientWithVersion( modName, modVersion ) && NSIsModEnabled( modName, modVersion ) ) { // find the mod name in the list of server required mods bool found = false @@ -1176,7 +1176,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) string modName = mod.name string modVersion = mod.version - if ( NSIsModRequiredOnClientWithVersion( modName, modVersion ) && !NSIsModEnabledWithVersion( modName, modVersion ) ) + if ( NSIsModRequiredOnClientWithVersion( modName, modVersion ) && !NSIsModEnabled( modName, modVersion ) ) { modsChanged = true NSSetModEnabled( modName, modVersion, true ) @@ -1443,7 +1443,7 @@ bool function JoinServer( ServerInfo server, string password = "" ) { string modName = mod.name - if ( NSIsModRequiredOnClient( modName ) && NSIsModEnabled( modName ) ) + if ( NSIsModRequiredOnClient( modName ) && NSIsModEnabled( modName, mod.version ) ) { // find the mod name in the list of server required mods bool found = false @@ -1467,7 +1467,7 @@ bool function JoinServer( ServerInfo server, string password = "" ) // enable all RequiredOnClient mods that are required by the server and are currently disabled foreach ( RequiredModInfo mod in server.requiredMods ) { - if ( NSIsModRequiredOnClient( mod.name ) && !NSIsModEnabled( mod.name ) ) + if ( NSIsModRequiredOnClient( mod.name ) && !NSIsModEnabled( mod.name, mod.version ) ) { modsChanged = true NSSetModEnabled( mod.name, mod.version, true ) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut index 2f1bcf025..47248edd2 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut @@ -431,9 +431,10 @@ void function UpdatePlayButton( var button ) { // restrict non-vanilla players from accessing official servers bool hasNonVanillaMods = false - foreach ( string modName in NSGetModNames() ) + foreach ( ModInfo mod in NSGetModsInformation() ) { - if ( NSIsModEnabled( modName ) && NSIsModRequiredOnClient( modName ) ) + string modName = mod.name + if ( NSIsModEnabled( modName, mod.version ) && NSIsModRequiredOnClient( modName ) ) { hasNonVanillaMods = true break From 9ac22a58561fd916e2e9340bf87c0952fba5b3d9 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 01:05:43 +0200 Subject: [PATCH 05/24] refactor: remove useless NSGetModNamesAndVersions function --- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5eaeb2a8d..d12b3a14d 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1142,7 +1142,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) bool modsChanged = false // disable all RequiredOnClient mods that are not required by the server and are currently enabled - foreach ( RequiredModInfo mod in NSGetModNamesAndVersions() ) + foreach ( ModInfo mod in NSGetModsInformation() ) { string modName = mod.name string modVersion = mod.version From 0cb86a7a46326310d334ce3334957cb0c987ccd2 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 01:17:58 +0200 Subject: [PATCH 06/24] refactor: remove NSIsModRequiredOnClient calls where it's not needed --- Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut | 4 ++-- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 4 ++-- Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index 42b4a1f1f..e4e2e023a 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -186,7 +186,7 @@ void function OnModButtonFocused( var button ) SetControlBarColor( modName, file.lastMod.version ) - bool required = NSIsModRequiredOnClient( modName ) + bool required = file.lastMod.requiredOnClient Hud_SetVisible( Hud_GetChild( file.menu, "WarningLegendLabel" ), required ) Hud_SetVisible( Hud_GetChild( file.menu, "WarningLegendImage" ), required ) } @@ -420,7 +420,7 @@ void function DisplayModPanels() Hud_SetVisible( box, true ) Hud_SetVisible( line, false ) - Hud_SetVisible( warning, NSIsModRequiredOnClient( c.mod.name ) ) + Hud_SetVisible( warning, mod.requiredOnClient ) SetModEnabledHelperImageAsset( enabledImage, c.mod.name, c.mod.version ) } 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 d12b3a14d..c189b3790 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1147,7 +1147,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) string modName = mod.name string modVersion = mod.version - if ( NSIsModRequiredOnClientWithVersion( modName, modVersion ) && NSIsModEnabled( modName, modVersion ) ) + if ( mod.requiredOnClient && mod.enabled ) { // find the mod name in the list of server required mods bool found = false @@ -1443,7 +1443,7 @@ bool function JoinServer( ServerInfo server, string password = "" ) { string modName = mod.name - if ( NSIsModRequiredOnClient( modName ) && NSIsModEnabled( modName, mod.version ) ) + if ( mod.requiredOnClient && mod.enabled ) { // find the mod name in the list of server required mods bool found = false diff --git a/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut index 47248edd2..354770e38 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/panel_mainmenu.nut @@ -434,7 +434,7 @@ void function UpdatePlayButton( var button ) foreach ( ModInfo mod in NSGetModsInformation() ) { string modName = mod.name - if ( NSIsModEnabled( modName, mod.version ) && NSIsModRequiredOnClient( modName ) ) + if ( mod.enabled && mod.requiredOnClient ) { hasNonVanillaMods = true break From c24e1ed667d8a56eb5cb45bd0db38036658958ef Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 01:22:25 +0200 Subject: [PATCH 07/24] feat: add modVersion parameter to NSIsModRequiredOnClient function --- .github/nativefuncs.json | 6 +++--- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index 0c3cb96be..bb3e03ab1 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -46,7 +46,7 @@ "name":"NSIsModRequiredOnClient", "helpText":"", "returnTypeString":"bool", - "argTypes":"string modName" + "argTypes":"string modName, string modVersion" }, { "name":"NSGetModConvarsByModName", @@ -294,7 +294,7 @@ "name":"NSIsModRequiredOnClient", "helpText":"", "returnTypeString":"bool", - "argTypes":"string modName" + "argTypes":"string modName, string modVersion" }, { "name":"NSGetModConvarsByModName", @@ -494,7 +494,7 @@ "name":"NSIsModRequiredOnClient", "helpText":"", "returnTypeString":"bool", - "argTypes":"string modName" + "argTypes":"string modName, string modVersion" }, { "name":"NSGetModConvarsByModName", 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 c189b3790..3a25d5d76 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1176,7 +1176,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) string modName = mod.name string modVersion = mod.version - if ( NSIsModRequiredOnClientWithVersion( modName, modVersion ) && !NSIsModEnabled( modName, modVersion ) ) + if ( NSIsModRequiredOnClient( modName, modVersion ) && !NSIsModEnabled( modName, modVersion ) ) { modsChanged = true NSSetModEnabled( modName, modVersion, true ) @@ -1467,7 +1467,7 @@ bool function JoinServer( ServerInfo server, string password = "" ) // enable all RequiredOnClient mods that are required by the server and are currently disabled foreach ( RequiredModInfo mod in server.requiredMods ) { - if ( NSIsModRequiredOnClient( mod.name ) && !NSIsModEnabled( mod.name, mod.version ) ) + if ( NSIsModRequiredOnClient( mod.name, mod.version ) && !NSIsModEnabled( mod.name, mod.version ) ) { modsChanged = true NSSetModEnabled( mod.name, mod.version, true ) From 0b2cfd7ca536b7647c58c9f985cea09eb9ce21e1 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 01:41:44 +0200 Subject: [PATCH 08/24] refactor: remove FormatModDescription useless parameter --- .../mod/scripts/vscripts/ui/menu_ns_modmenu.nut | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index e4e2e023a..d4365326b 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -167,7 +167,7 @@ void function OnModButtonFocused( var button ) RuiSetGameTime( rui, "startTime", -99999.99 ) // make sure it skips the whole animation for showing this RuiSetString( rui, "headerText", modName ) - RuiSetString( rui, "messageText", FormatModDescription( modName ) ) + RuiSetString( rui, "messageText", FormatModDescription() ) // Add a button to open the link with if required string link = NSGetModDownloadLinkByModName( modName ) @@ -253,7 +253,7 @@ void function OnHideConVarsChange( var n ) if ( modName == "" ) return var rui = Hud_GetRui( Hud_GetChild( file.menu, "LabelDetails" ) ) - RuiSetString( rui, "messageText", FormatModDescription( modName ) ) + RuiSetString( rui, "messageText", FormatModDescription() ) } // LIST LOGIC @@ -484,17 +484,20 @@ vector function GetControlColorForMod( string modName, string modVersion ) unreachable } -string function FormatModDescription( string modName ) +string function FormatModDescription() { + ModInfo mod = file.lastMod + string modName = mod.name + string ret // version - ret += format( "Version %s\n", NSGetModVersionByModName( modName ) ) + ret += format( "Version %s\n", mod.version ) // load priority - ret += format( "Load Priority: %i\n", NSGetModLoadPriority( modName ) ) + ret += format( "Load Priority: %i\n", mod.loadPriority ) // convars - array modCvars = NSGetModConvarsByModName( modName ) + array modCvars = mod.conVars if ( modCvars.len() != 0 && GetConVarBool( "modlist_show_convars" ) ) { ret += "ConVars: " @@ -511,7 +514,7 @@ string function FormatModDescription( string modName ) } // description - ret += format( "\n%s\n", NSGetModDescriptionByModName( modName ) ) + ret += format( "\n%s\n", NSGetModDescriptionByModName( modName ) ) // TODO put description in NSGetModsInformation results return ret } From 6797581f149d13565876c7773cc97e95452ddb4d Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 01:46:25 +0200 Subject: [PATCH 09/24] refactor: put mod description in NSGetModsInformation results and remove NSGetModDescription function --- .github/nativefuncs.json | 18 ------------------ .../vscripts/cl_northstar_client_init.nut | 1 + .../scripts/vscripts/ui/menu_ns_modmenu.nut | 2 +- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index bb3e03ab1..c551f11ab 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -18,12 +18,6 @@ "returnTypeString":"void", "argTypes":"string modName, string modVersion, bool enabled" }, - { - "name":"NSGetModDescriptionByModName", - "helpText":"", - "returnTypeString":"string", - "argTypes":"string modName" - }, { "name":"NSGetModVersionByModName", "helpText":"", @@ -266,12 +260,6 @@ "returnTypeString":"void", "argTypes":"string modName, string modVersion, bool enabled" }, - { - "name":"NSGetModDescriptionByModName", - "helpText":"", - "returnTypeString":"string", - "argTypes":"string modName" - }, { "name":"NSGetModVersionByModName", "helpText":"", @@ -466,12 +454,6 @@ "returnTypeString":"void", "argTypes":"string modName, string modVersion, bool enabled" }, - { - "name":"NSGetModDescriptionByModName", - "helpText":"", - "returnTypeString":"string", - "argTypes":"string modName" - }, { "name":"NSGetModVersionByModName", "helpText":"", diff --git a/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut b/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut index 7df41ca1e..273d4c611 100644 --- a/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut +++ b/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut @@ -29,6 +29,7 @@ global struct UIPresenceStruct { global struct ModInfo { string name = "" + string description = "" string version = "" string downloadLink = "" int loadPriority = 0 diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index d4365326b..85e0ffa6b 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -514,7 +514,7 @@ string function FormatModDescription() } // description - ret += format( "\n%s\n", NSGetModDescriptionByModName( modName ) ) // TODO put description in NSGetModsInformation results + ret += format( "\n%s\n", mod.description ) return ret } From d82f5d1205e001d71f33b238563aac35c2e59fea Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 01:53:55 +0200 Subject: [PATCH 10/24] refactor: remove NSGetModDownloadLinkByModName calls since download link info is in ModInfo struct --- .github/nativefuncs.json | 18 ------------------ .../scripts/vscripts/ui/menu_ns_modmenu.nut | 6 +++--- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index c551f11ab..91b5b8d5b 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -24,12 +24,6 @@ "returnTypeString":"string", "argTypes":"string modName" }, - { - "name":"NSGetModDownloadLinkByModName", - "helpText":"", - "returnTypeString":"string", - "argTypes":"string modName" - }, { "name":"NSGetModLoadPriority", "helpText":"", @@ -266,12 +260,6 @@ "returnTypeString":"string", "argTypes":"string modName" }, - { - "name":"NSGetModDownloadLinkByModName", - "helpText":"", - "returnTypeString":"string", - "argTypes":"string modName" - }, { "name":"NSGetModLoadPriority", "helpText":"", @@ -460,12 +448,6 @@ "returnTypeString":"string", "argTypes":"string modName" }, - { - "name":"NSGetModDownloadLinkByModName", - "helpText":"", - "returnTypeString":"string", - "argTypes":"string modName" - }, { "name":"NSGetModLoadPriority", "helpText":"", diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index 85e0ffa6b..816308d92 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -170,7 +170,7 @@ void function OnModButtonFocused( var button ) RuiSetString( rui, "messageText", FormatModDescription() ) // Add a button to open the link with if required - string link = NSGetModDownloadLinkByModName( modName ) + string link = file.lastMod.downloadLink var linkButton = Hud_GetChild( file.menu, "ModPageButton" ) if ( link.len() ) { @@ -222,8 +222,8 @@ void function OnAuthenticationAgreementButtonPressed( var button ) void function OnModLinkButtonPressed( var button ) { - string modName = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod.name - string link = NSGetModDownloadLinkByModName( modName ) + ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod + string link = mod.downloadLink if ( link.find("http://") != 0 && link.find("https://") != 0 ) link = "http://" + link // links without the http or https protocol get opened in the internal browser LaunchExternalWebBrowser( link, WEBBROWSER_FLAG_FORCEEXTERNAL ) From 1a157b81ae317a386176e1510ca9ddc1bc01ded7 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 01:56:30 +0200 Subject: [PATCH 11/24] build: remove NSGetModLoadPriority signature from CI configuration since info is in ModInfo struct --- .github/nativefuncs.json | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index 91b5b8d5b..6a2cb1a18 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -24,12 +24,6 @@ "returnTypeString":"string", "argTypes":"string modName" }, - { - "name":"NSGetModLoadPriority", - "helpText":"", - "returnTypeString":"int", - "argTypes":"string modName" - }, { "name":"NSIsModRequiredOnClient", "helpText":"", @@ -260,12 +254,6 @@ "returnTypeString":"string", "argTypes":"string modName" }, - { - "name":"NSGetModLoadPriority", - "helpText":"", - "returnTypeString":"int", - "argTypes":"string modName" - }, { "name":"NSIsModRequiredOnClient", "helpText":"", @@ -448,12 +436,6 @@ "returnTypeString":"string", "argTypes":"string modName" }, - { - "name":"NSGetModLoadPriority", - "helpText":"", - "returnTypeString":"int", - "argTypes":"string modName" - }, { "name":"NSIsModRequiredOnClient", "helpText":"", From 8fa8ae92741cf19dec94b14a13297e0a4425228e Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 02:02:17 +0200 Subject: [PATCH 12/24] build: remove NSGetModConvarsByModName signature from CI configuration since convars are in ModInfo struct --- .github/nativefuncs.json | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index 6a2cb1a18..01dd2e673 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -30,12 +30,6 @@ "returnTypeString":"bool", "argTypes":"string modName, string modVersion" }, - { - "name":"NSGetModConvarsByModName", - "helpText":"", - "returnTypeString":"array", - "argTypes":"string modName" - }, { "name":"DecodeJSON", "helpText":"converts a json string to a squirrel table", @@ -260,12 +254,6 @@ "returnTypeString":"bool", "argTypes":"string modName, string modVersion" }, - { - "name":"NSGetModConvarsByModName", - "helpText":"", - "returnTypeString":"array", - "argTypes":"string modName" - }, { "name":"DecodeJSON", "helpText":"converts a json string to a squirrel table", @@ -442,12 +430,6 @@ "returnTypeString":"bool", "argTypes":"string modName, string modVersion" }, - { - "name":"NSGetModConvarsByModName", - "helpText":"", - "returnTypeString":"array", - "argTypes":"string modName" - }, { "name": "NSFetchVerifiedModsManifesto", "helpText": "Retrieves the verified mods list from the central authority (GitHub).", From 69fb41f1affdacb79deb8c3d0418fc93db8cbaf1 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 18:17:41 +0200 Subject: [PATCH 13/24] refactor: replace NSGetModVersionByModName function with NSGetModVersions function --- .github/nativefuncs.json | 12 ++++++------ .../vscripts/ui/menu_ns_serverbrowser.nut | 18 ++++++++++++------ .../vscripts/ui/menu_ns_setversionlabel.nut | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index 01dd2e673..a2e158958 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -19,9 +19,9 @@ "argTypes":"string modName, string modVersion, bool enabled" }, { - "name":"NSGetModVersionByModName", + "name":"NSGetModVersions", "helpText":"", - "returnTypeString":"string", + "returnTypeString":"array", "argTypes":"string modName" }, { @@ -243,9 +243,9 @@ "argTypes":"string modName, string modVersion, bool enabled" }, { - "name":"NSGetModVersionByModName", + "name":"NSGetModVersions", "helpText":"", - "returnTypeString":"string", + "returnTypeString":"array", "argTypes":"string modName" }, { @@ -419,9 +419,9 @@ "argTypes":"string modName, string modVersion, bool enabled" }, { - "name":"NSGetModVersionByModName", + "name":"NSGetModVersions", "helpText":"", - "returnTypeString":"string", + "returnTypeString":"array", "argTypes":"string modName" }, { 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 3a25d5d76..98a2961b2 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -984,10 +984,13 @@ void function OnServerSelected_Threaded( var button ) print( format ( "\"%s\" was not found locally, triggering manifesto fetching.", requiredModInfo.name ) ) uninstalledModFound = true break - } else if ( NSGetModVersionByModName( requiredModInfo.name ) != requiredModInfo.version ) { - print( format ( "\"%s\" was found locally but has version \"%s\" while server requires \"%s\", triggering manifesto fetching.", requiredModInfo.name, NSGetModVersionByModName( requiredModInfo.name ), requiredModInfo.version ) ) - uninstalledModFound = true - break + } else { + array modVersions = NSGetModVersions( requiredModInfo.name ) + if ( !modVersions.contains( requiredModInfo.version ) ) { + print( format ( "\"%s\" was found locally but has versions \"%s\" while server requires \"%s\", triggering manifesto fetching.", requiredModInfo.name, modVersions.tostring(), requiredModInfo.version ) ) + uninstalledModFound = true + break + } } } @@ -1005,7 +1008,7 @@ void function OnServerSelected_Threaded( var button ) if ( mod.name.len() > 10 && mod.name.slice(0, 10) == "Northstar." ) continue - if ( !NSGetModNames().contains( mod.name ) || NSGetModVersionByModName( mod.name ) != mod.version ) + if ( !NSGetModNames().contains( mod.name ) || !NSGetModVersions( mod.name ).contains( mod.version ) ) { // Auto-download mod if ( autoDownloadAllowed ) @@ -1058,8 +1061,11 @@ void function OnServerSelected_Threaded( var button ) return } } + + // If we get here, means that mod version exists locally => we good else { + /* // this uses semver https://semver.org array serverModVersion = split( mod.name, "." ) array clientModVersion = split( NSGetModVersionByModName( mod.name ), "." ) @@ -1093,7 +1099,7 @@ void function OnServerSelected_Threaded( var button ) OpenDialog( dialogData ) return - } + }*/ } } diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_setversionlabel.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_setversionlabel.nut index 6dbafde96..0b868a910 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_setversionlabel.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_setversionlabel.nut @@ -5,6 +5,6 @@ void function NS_SetVersionLabel() { var mainMenu = GetMenu( "MainMenu" ) //Gets main menu element var versionLabel = GetElementsByClassname( mainMenu, "nsVersionClass" )[0] //Gets the label from the mainMenu element. - Hud_SetText( versionLabel, "v" + NSGetModVersionByModName("Northstar.Client")) //Sets the label text (Getting Northstar version from Northstar.Client) + Hud_SetText( versionLabel, "v" + NSGetModVersions("Northstar.Client")[0]) //Sets the label text (Getting Northstar version from Northstar.Client) } From d55c1b14daee42a1a97a39bcd7429987154a8f07 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 18:27:37 +0200 Subject: [PATCH 14/24] build: add NSGetModsInformation signature to CI configuration --- .github/nativefuncs.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json index a2e158958..0ed7d6140 100644 --- a/.github/nativefuncs.json +++ b/.github/nativefuncs.json @@ -6,6 +6,12 @@ "returnTypeString":"array", "argTypes":"" }, + { + "name":"NSGetModsInformation", + "helpText":"", + "returnTypeString":"array", + "argTypes":"" + }, { "name":"NSIsModEnabled", "helpText":"", @@ -230,6 +236,12 @@ "returnTypeString":"array", "argTypes":"" }, + { + "name":"NSGetModsInformation", + "helpText":"", + "returnTypeString":"array", + "argTypes":"" + }, { "name":"NSIsModEnabled", "helpText":"", @@ -406,6 +418,12 @@ "returnTypeString":"array", "argTypes":"" }, + { + "name":"NSGetModsInformation", + "helpText":"", + "returnTypeString":"array", + "argTypes":"" + }, { "name":"NSIsModEnabled", "helpText":"", From dfc6cf670b1993a52caa4be233946e7636903a0c Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Wed, 31 Jul 2024 18:36:05 +0200 Subject: [PATCH 15/24] fix: check targetServer type (must be ServerInfo instance) --- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fb590b42c..0253f5aa2 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1373,6 +1373,6 @@ void function TriggerConnectToServerCallbacks( ServerInfo ornull targetServer = foreach( callback in file.connectCallbacks ) { - callback( targetServer ) + callback( expect ServerInfo( targetServer ) ) } } \ No newline at end of file From d59fc1ae4b162ea2738c616d9b116e4692e21de8 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Mon, 5 Aug 2024 01:06:17 +0200 Subject: [PATCH 16/24] fix: reload mods when disabling/enabling two versions of a mod at the same time --- .../scripts/vscripts/ui/menu_ns_modmenu.nut | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index 816308d92..fd4cda27c 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -28,7 +28,7 @@ struct { var menu array panels int scrollOffset = 0 - array enabledMods + array enabledMods var currentButton string searchTerm ModInfo& lastMod @@ -141,11 +141,22 @@ void function OnModMenuClosed() } catch ( ex ) {} - array current = GetEnabledModsArray() + array current = GetEnabledModsArray() bool reload - foreach ( string mod in current ) + foreach ( ModInfo mod in current ) { - if ( file.enabledMods.find(mod) == -1 ) + bool notFound = true + + foreach (ModInfo enMod in file.enabledMods ) + { + if (mod.name == enMod.name && mod.version == enMod.version) + { + notFound = false + break + } + } + + if (notFound) { reload = true break @@ -288,13 +299,13 @@ void function DisableMod() RefreshMods() } -array function GetEnabledModsArray() +array function GetEnabledModsArray() { - array enabledMods + array enabledMods foreach ( ModInfo mod in NSGetModsInformation() ) { if ( mod.enabled ) - enabledMods.append( mod.name ) + enabledMods.append( mod ) } return enabledMods } From c8d155b77a05a2efe78b7c531f37672286eaeb69 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Fri, 9 Aug 2024 23:14:19 +0200 Subject: [PATCH 17/24] refactor: extract core mod test into a dedicated function --- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 9 +++++++-- 1 file changed, 7 insertions(+), 2 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 0253f5aa2..75356e754 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -973,7 +973,7 @@ void function OnServerSelected_Threaded( var button ) foreach ( requiredModInfo in server.requiredMods ) { // Tolerate core mods having different versions - if ( requiredModInfo.name.len() > 10 && requiredModInfo.name.slice(0, 10) == "Northstar." ) + if ( IsCoreMod( requiredModInfo.name ) ) continue if ( !modNames.contains( requiredModInfo.name ) ) @@ -1002,7 +1002,7 @@ void function OnServerSelected_Threaded( var button ) foreach ( RequiredModInfo mod in server.requiredMods ) { // Tolerate core mods having different versions - if ( mod.name.len() > 10 && mod.name.slice(0, 10) == "Northstar." ) + if ( IsCoreMod( mod.name ) ) continue if ( !NSGetModNames().contains( mod.name ) || !NSGetModVersions( mod.name ).contains( mod.version ) ) @@ -1375,4 +1375,9 @@ void function TriggerConnectToServerCallbacks( ServerInfo ornull targetServer = { callback( expect ServerInfo( targetServer ) ) } +} + +bool function IsCoreMod( string modName ) +{ + return modName.len() > 10 && modName.slice(0, 10) == "Northstar." } \ No newline at end of file From 0fa9b70853f0eceda47eec24b4ecf7440a7081a2 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Fri, 9 Aug 2024 23:39:19 +0200 Subject: [PATCH 18/24] refactor: use a mod list to define if a mod is a core mod --- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 75356e754..e2e4a38c5 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1377,7 +1377,8 @@ void function TriggerConnectToServerCallbacks( ServerInfo ornull targetServer = } } +const array CORE_MODS = ["Northstar.Client", "Northstar.Coop", "Northstar.CustomServers", "Northstar.Custom"] bool function IsCoreMod( string modName ) { - return modName.len() > 10 && modName.slice(0, 10) == "Northstar." + return CORE_MODS.find( modName ) != -1 } \ No newline at end of file From fa7b782801f3514aaf378c2b0a7417224f1e955c Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Fri, 30 Aug 2024 01:33:10 +0200 Subject: [PATCH 19/24] refactor: add ModInfo.isRemote member --- .../mod/scripts/vscripts/cl_northstar_client_init.nut | 1 + Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut b/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut index 273d4c611..c600e6392 100644 --- a/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut +++ b/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut @@ -35,6 +35,7 @@ global struct ModInfo int loadPriority = 0 bool enabled = false bool requiredOnClient = false + bool isRemote array conVars = [] } diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index 8e7889874..e3f470bdc 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -344,7 +344,7 @@ void function RefreshMods() string modName = mod.name // Do not display remote mods - if ( NSIsModRemote( modName, mod.version ) ) + if ( mod.isRemote ) continue if ( searchTerm.len() && modName.tolower().find( searchTerm ) == null ) From 60ee024965312ecced0d571a0a2dfd030d7bff95 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Fri, 30 Aug 2024 02:53:29 +0200 Subject: [PATCH 20/24] fix: tolerate Northstar.Custom version differences (with server version) --- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 e2e4a38c5..05fe53b91 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1153,7 +1153,8 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha bool found = false foreach ( RequiredModInfo mod in file.lastSelectedServer.requiredMods ) { - if (mod.name == modName && mod.version == modVersion) + // this tolerates a version difference for requiredOnClient core mods (only Northstar.Custom for now) + if (mod.name == modName && ( IsCoreMod( modName ) || mod.version == modVersion )) { found = true print(format("Found \"%s\" v%s", modName, modVersion)) From b606248b98a31e8b3af88881e337b5d2268a56c0 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Fri, 30 Aug 2024 21:41:49 +0200 Subject: [PATCH 21/24] fix: enable Northstar.Custom mod if it is disabled --- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 05fe53b91..2f94d1790 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1177,7 +1177,16 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha string modName = mod.name string modVersion = mod.version - if ( NSIsModRequiredOnClient( modName, modVersion ) && !NSIsModEnabled( modName, modVersion ) ) + // Tolerate core mods (only Northstar.Custom for now) having a different version than server + if ( IsCoreMod(modName) ) + { + string coreModVersion = NSGetModVersions( modName )[0] + modsChanged = true + NSSetModEnabled( modName, coreModVersion, true ) + print(format("Enabled \"%s\" v%s", modName, coreModVersion)) + } + + else if ( NSIsModRequiredOnClient( modName, modVersion ) && !NSIsModEnabled( modName, modVersion ) ) { modsChanged = true NSSetModEnabled( modName, modVersion, true ) From da1a915c295fe8e8ddc6c5385f6b477848be66fd Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Fri, 30 Aug 2024 23:06:06 +0200 Subject: [PATCH 22/24] feat: complete log messages --- .../vscripts/ui/menu_ns_serverbrowser.nut | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 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 2f94d1790..c37dfe787 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -978,13 +978,18 @@ void function OnServerSelected_Threaded( var button ) if ( !modNames.contains( requiredModInfo.name ) ) { - print( format ( "\"%s\" was not found locally, triggering manifesto fetching.", requiredModInfo.name ) ) + print( format ( "\"%s\" was not found locally" + ( autoDownloadAllowed ? ", triggering manifesto fetching." : "." ), requiredModInfo.name ) ) uninstalledModFound = true break } else { array modVersions = NSGetModVersions( requiredModInfo.name ) if ( !modVersions.contains( requiredModInfo.version ) ) { - print( format ( "\"%s\" was found locally but has versions \"%s\" while server requires \"%s\", triggering manifesto fetching.", requiredModInfo.name, modVersions.tostring(), requiredModInfo.version ) ) + print( format ( "\"%s\" was found locally but has versions:", requiredModInfo.name ) ) + foreach ( string version in modVersions ) + { + print(" - " + version) + } + print( format ( "while server requires \"%s\"" + ( autoDownloadAllowed ? ", triggering manifesto fetching." : "." ), requiredModInfo.version ) ) uninstalledModFound = true break } @@ -995,7 +1000,6 @@ void function OnServerSelected_Threaded( var button ) // mods can be installed through auto-download if ( uninstalledModFound && autoDownloadAllowed ) { - print("Auto-download is allowed, checking if missing mods can be installed automatically.") FetchVerifiedModsManifesto() } @@ -1157,7 +1161,7 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha if (mod.name == modName && ( IsCoreMod( modName ) || mod.version == modVersion )) { found = true - print(format("Found \"%s\" v%s", modName, modVersion)) + print(format("\"%s\" (v%s) is required and already enabled.", modName, modVersion)) break } } @@ -1166,7 +1170,7 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha { modsChanged = true NSSetModEnabled( modName, modVersion, false ) - print(format("Disabled \"%s\" v%s", modName, modVersion)) + print(format("Disabled \"%s\" (v%s) since it's not required on server.", modName, modVersion)) } } } @@ -1183,14 +1187,14 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha string coreModVersion = NSGetModVersions( modName )[0] modsChanged = true NSSetModEnabled( modName, coreModVersion, true ) - print(format("Enabled \"%s\" v%s", modName, coreModVersion)) + print(format("Enabled \"%s\" (v%s) to join server.", modName, coreModVersion)) } else if ( NSIsModRequiredOnClient( modName, modVersion ) && !NSIsModEnabled( modName, modVersion ) ) { modsChanged = true NSSetModEnabled( modName, modVersion, true ) - print(format("Enabled \"%s\" v%s", modName, modVersion)) + print(format("Enabled \"%s\" (v%s) to join server.", modName, modVersion)) } } From f3779421b6f48c9d75b78303367744540e99da98 Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Fri, 30 Aug 2024 23:07:29 +0200 Subject: [PATCH 23/24] refactor: remove (pseudo) semver check --- .../vscripts/ui/menu_ns_serverbrowser.nut | 38 ------------------- 1 file changed, 38 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 c37dfe787..09e77c73a 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1064,44 +1064,6 @@ void function OnServerSelected_Threaded( var button ) } // If we get here, means that mod version exists locally => we good - else - { - /* - // this uses semver https://semver.org - array serverModVersion = split( mod.name, "." ) - array clientModVersion = split( NSGetModVersionByModName( mod.name ), "." ) - - bool semverFail = false - // if server has invalid semver don't bother checking - if ( serverModVersion.len() == 3 ) - { - // bad client semver - if ( clientModVersion.len() != serverModVersion.len() ) - semverFail = true - // major version, don't think we should need to check other versions - else if ( clientModVersion[ 0 ] != serverModVersion[ 0 ] ) - semverFail = true - } - - if ( semverFail ) - { - DialogData dialogData - dialogData.header = "#ERROR" - dialogData.message = Localize( "#WRONG_MOD_VERSION", mod.name, mod.version, NSGetModVersionByModName( mod.name ) ) - dialogData.image = $"ui/menu/common/dialog_error" - - #if PC_PROG - AddDialogButton( dialogData, "#DISMISS" ) - - AddDialogFooter( dialogData, "#A_BUTTON_SELECT" ) - #endif // PC_PROG - AddDialogFooter( dialogData, "#B_BUTTON_DISMISS_RUI" ) - - OpenDialog( dialogData ) - - return - }*/ - } } if ( server.requiresPassword ) From 6216e0a70ef780aa46dd61114272d8e3adcc714e Mon Sep 17 00:00:00 2001 From: Remy Raes Date: Sat, 31 Aug 2024 01:08:52 +0200 Subject: [PATCH 24/24] fix: only enable core mod if it currently is disabled --- .../mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 09e77c73a..be5bd89e9 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -1147,9 +1147,12 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha if ( IsCoreMod(modName) ) { string coreModVersion = NSGetModVersions( modName )[0] - modsChanged = true - NSSetModEnabled( modName, coreModVersion, true ) - print(format("Enabled \"%s\" (v%s) to join server.", modName, coreModVersion)) + if ( !NSIsModEnabled( modName, coreModVersion ) ) + { + modsChanged = true + NSSetModEnabled( modName, coreModVersion, true ) + print(format("Enabled \"%s\" (v%s) to join server.", modName, coreModVersion)) + } } else if ( NSIsModRequiredOnClient( modName, modVersion ) && !NSIsModEnabled( modName, modVersion ) )