From c093ee10f004f7e2b8be2b326a4b087392ded544 Mon Sep 17 00:00:00 2001 From: Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> Date: Sat, 7 Oct 2023 11:25:09 +0100 Subject: Expose origin auth state and errors to squirrel (#468) Also moves `NSIsMasterServerAuthenticated` out of `scriptserverbrowser.cpp` because it didn't really fit there This will be used for showing failed origin auth errors in the game's UI --- NorthstarDLL/scripts/client/scriptoriginauth.cpp | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 NorthstarDLL/scripts/client/scriptoriginauth.cpp (limited to 'NorthstarDLL/scripts/client/scriptoriginauth.cpp') diff --git a/NorthstarDLL/scripts/client/scriptoriginauth.cpp b/NorthstarDLL/scripts/client/scriptoriginauth.cpp new file mode 100644 index 00000000..420c4872 --- /dev/null +++ b/NorthstarDLL/scripts/client/scriptoriginauth.cpp @@ -0,0 +1,35 @@ +#include "squirrel/squirrel.h" +#include "masterserver/masterserver.h" +#include "engine/r2engine.h" +#include "client/r2client.h" + +ADD_SQFUNC("bool", NSIsMasterServerAuthenticated, "", "", ScriptContext::UI) +{ + g_pSquirrel->pushbool(sqvm, g_pMasterServerManager->m_bOriginAuthWithMasterServerDone); + return SQRESULT_NOTNULL; +} + +/* +global struct MasterServerAuthResult +{ + bool success + string errorCode + string errorMessage +} +*/ + +ADD_SQFUNC("MasterServerAuthResult", NSGetMasterServerAuthResult, "", "", ScriptContext::UI) +{ + g_pSquirrel->pushnewstructinstance(sqvm, 3); + + g_pSquirrel->pushbool(sqvm, g_pMasterServerManager->m_bOriginAuthWithMasterServerSuccessful); + g_pSquirrel->sealstructslot(sqvm, 0); + + g_pSquirrel->pushstring(sqvm, g_pMasterServerManager->m_sOriginAuthWithMasterServerErrorCode.c_str(), -1); + g_pSquirrel->sealstructslot(sqvm, 1); + + g_pSquirrel->pushstring(sqvm, g_pMasterServerManager->m_sOriginAuthWithMasterServerErrorMessage.c_str(), -1); + g_pSquirrel->sealstructslot(sqvm, 2); + + return SQRESULT_NOTNULL; +} -- cgit v1.2.3