aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-10-07 11:40:31 +0100
committerGitHub <noreply@github.com>2023-10-07 12:40:31 +0200
commit15b3b65fc4e88fe98ba12b4d7603e396fba91fb3 (patch)
tree2bda073e3a7340445dfa8e5b2ea0288ef2efe815
parent1c3bafd8efd56c4f0bb11a952fb192f60bcf42c0 (diff)
downloadNorthstarMods-1.19.5.tar.gz
NorthstarMods-1.19.5.zip
Display origin auth failure in a dialog (#648)v1.19.5-rc1v1.19.5
Currently, we don't do anything with origin auth failure, meaning the next request just fails, and we get not particularly relevant error messages (player not found, invalid masterserver token)
-rw-r--r--.github/nativefuncs.json6
-rw-r--r--Northstar.Client/mod.json7
-rw-r--r--Northstar.Client/mod/resource/northstar_client_localisation_english.txt5
-rw-r--r--Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut7
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/atlas_auth.nut56
5 files changed, 81 insertions, 0 deletions
diff --git a/.github/nativefuncs.json b/.github/nativefuncs.json
index 6f46095f..13a7edd3 100644
--- a/.github/nativefuncs.json
+++ b/.github/nativefuncs.json
@@ -729,6 +729,12 @@
"helpText":"",
"returnTypeString":"void",
"argTypes":"struct presence"
+ },
+ {
+ "name":"NSGetMasterServerAuthResult",
+ "helpText":"",
+ "returnTypeString":"MasterServerAuthResult",
+ "argTypes":""
}
]
} \ No newline at end of file
diff --git a/Northstar.Client/mod.json b/Northstar.Client/mod.json
index 7d695a4b..f7c7c9b5 100644
--- a/Northstar.Client/mod.json
+++ b/Northstar.Client/mod.json
@@ -128,6 +128,13 @@
{
"Path": "ui/ui_mouse_capture.nut",
"RunOn": "UI"
+ },
+ {
+ "Path": "ui/atlas_auth.nut",
+ "RunOn": "UI",
+ "UICallback": {
+ "After": "AtlasAuthDialog"
+ }
}
],
"Localisation": [
diff --git a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt
index 8c7bab3a..49e9ee43 100644
--- a/Northstar.Client/mod/resource/northstar_client_localisation_english.txt
+++ b/Northstar.Client/mod/resource/northstar_client_localisation_english.txt
@@ -322,6 +322,11 @@ Press Yes if you agree to this. This choice can be changed in the mods menu at a
"INVALID_MASTERSERVER_TOKEN" "Invalid or expired masterserver token"
"JSON_PARSE_ERROR" "Error parsing json response"
"UNSUPPORTED_VERSION" "The version you are using is no longer supported"
+
+ "AUTHENTICATION_FAILED_HEADER" "Authentication Failed"
+ "AUTHENTICATION_FAILED_BODY" "Failed to authenticate with Atlas!"
+ "AUTHENTICATION_FAILED_ERROR_CODE" "Error code: ^DB6F2C00%s1^"
+ "AUTHENTICATION_FAILED_HELP" "Help"
// Mod Settings
"MOD_SETTINGS" "Mod Settings"
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 2a2ed3db..a844478a 100644
--- a/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut
+++ b/Northstar.Client/mod/scripts/vscripts/cl_northstar_client_init.nut
@@ -41,3 +41,10 @@ global struct ServerInfo
string region
array< RequiredModInfo > requiredMods
}
+
+global struct MasterServerAuthResult
+{
+ bool success
+ string errorCode
+ string errorMessage
+}
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/atlas_auth.nut b/Northstar.Client/mod/scripts/vscripts/ui/atlas_auth.nut
new file mode 100644
index 00000000..89b7f719
--- /dev/null
+++ b/Northstar.Client/mod/scripts/vscripts/ui/atlas_auth.nut
@@ -0,0 +1,56 @@
+global function AtlasAuthDialog
+
+void function AtlasAuthDialog()
+{
+ thread AtlasAuthDialog_Threaded()
+}
+
+void function AtlasAuthDialog_Threaded()
+{
+ // wait at least 1 frame so that the main menu can be loaded first
+ WaitFrame()
+
+ while ( !NSIsMasterServerAuthenticated() || GetConVarBool( "ns_auth_allow_insecure" ) )
+ WaitFrame()
+
+ if ( GetConVarBool( "ns_auth_allow_insecure" ) )
+ return
+
+ MasterServerAuthResult res = NSGetMasterServerAuthResult()
+
+ // do nothing on successful authentication
+ if ( res.success )
+ return
+
+ EmitUISound( "blackmarket_purchase_fail" )
+
+ DialogData dialogData
+ dialogData.image = $"ui/menu/common/dialog_error"
+ dialogData.header = Localize( "#AUTHENTICATION_FAILED_HEADER" )
+
+ // if we got a special error message from Atlas, display it
+ if ( res.errorMessage != "" )
+ dialogData.message = res.errorMessage
+ else
+ dialogData.message = Localize( "#AUTHENTICATION_FAILED_BODY" )
+
+ if ( res.errorCode != "" )
+ dialogData.message += format( "\n\n%s", Localize( "#AUTHENTICATION_FAILED_ERROR_CODE", res.errorCode ) )
+
+ string link = "https://r2northstar.gitbook.io/r2northstar-wiki/installing-northstar/troubleshooting"
+ // link to generic troubleshooting page if we don't have an error code from Atlas
+ if ( res.errorCode != "" )
+ link = format( "%s#%s", link, res.errorCode )
+
+ CloseAllDialogs()
+ AddDialogButton( dialogData, "#OK" )
+ AddDialogButton( dialogData, Localize( "#AUTHENTICATION_FAILED_HELP" ), void function() : ( dialogData, link )
+ {
+ // todo: get MS to redirect, so i can use an MS link or something?
+ LaunchExternalWebBrowser( link, WEBBROWSER_FLAG_FORCEEXTERNAL )
+ // keep the dialog open
+ OpenDialog( dialogData )
+ } )
+
+ OpenDialog( dialogData )
+}