From 89e189d5e752dd5b83a3c7b30fcbc8a1d5686c67 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Sun, 8 May 2022 23:41:38 +0100 Subject: more reliable reload => connect logic --- .../mod/scripts/vscripts/ui/menu_ns_modmenu.nut | 8 ++++---- .../scripts/vscripts/ui/menu_ns_serverbrowser.nut | 24 +++++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'Northstar.Client/mod/scripts') 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 8aba05e2..160cbd86 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -213,7 +213,7 @@ void function SetModMenuNameText( var button ) void function OnModMenuButtonPressed( var button ) { string modName = file.modsArrayFiltered[ int ( Hud_GetScriptID( button ) ) + file.scrollOffset ].modName - if ( ( modName == "Northstar.Client" || modName == "Northstar.Coop" || modName == "Northstar.CustomServers") && NSIsModEnabled( modName ) ) + if ( ( modName == "Northstar.Client" || modName == "Northstar.CustomServers") && NSIsModEnabled( modName ) ) { file.currentMod = modName file.currentButton = button @@ -317,9 +317,6 @@ void function ReloadMods() // do any logic that needs to be threaded off thread ReloadModsThreaded() - - // note: the logic for this seems really odd, unsure why it doesn't seem to update, since the same code seems to get run irregardless of whether we've read weapon data before - ClientCommand( "uiscript_reset" ) } void function ReloadModsThreaded() @@ -328,8 +325,11 @@ void function ReloadModsThreaded() SetConVarBool( "sv_cheats", true ) ClientCommand( "weapon_reparse" ) + wait 0.1 // weapon_reparse takes a sec to start, we need to wait to ensure sv_cheats is still 0 by the time it gets run properly + SetConVarBool( "sv_cheats", originalCheatsValue ) + ClientCommand( "uiscript_reset" ) } void function OnAuthenticationAgreementButtonPressed( var button ) 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 ce52c5fb..6899e535 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut @@ -99,6 +99,20 @@ bool function floatCompareInRange(float arg1, float arg2, float tolerance) void function AddNorthstarServerBrowserMenu() { AddMenu( "ServerBrowserMenu", $"resource/ui/menus/server_browser.menu", InitServerBrowserMenu, "#MENU_SERVER_BROWSER" ) + + // if we're reloading mods for a connect, then we've just finished reloading mods since ui has reset + // so start trying to connect + if ( GetConVarBool( "ns_try_connect_server_on_ui_reload" ) && NSWasAuthSuccessful() ) + { + try + { + NSConnectToAuthedServer() + } + catch ( ex ) + {} + } + + SetConVarBool( "ns_try_connect_server_on_ui_reload", false ) } void function UpdatePrivateMatchModesAndMaps() @@ -1021,7 +1035,7 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) } } - DelayedReloadModsAndConnect( modsChanged ) + TryReloadModsAndConnect( modsChanged ) } else { @@ -1041,16 +1055,16 @@ void function ThreadedAuthAndConnectToServer( string password = "" ) } } -void function DelayedReloadModsAndConnect( bool modsChanged ) +void function TryReloadModsAndConnect( bool modsChanged ) { // only actually reload if we need to since the uiscript reset on reload lags hard if ( modsChanged ) { ReloadMods() - wait 0.25 + SetConVarBool( "ns_try_connect_server_on_ui_reload", true ) // don't connect, instead connect when uiscript has reloaded in the init func for this file } - - NSConnectToAuthedServer() + else + NSConnectToAuthedServer() } ////////////////////////////////////// -- cgit v1.2.3