From d689281b6ffeee02c5264a68726f3db3ba6b26bf Mon Sep 17 00:00:00 2001 From: fallenoak Date: Mon, 9 Jan 2023 18:01:27 -0600 Subject: [PATCH] feat(glue): poll login state in glue manager loop --- src/glue/CGlueMgr.cpp | 83 +++++++++++++++++++++++++++++++++++++++++-- src/glue/CGlueMgr.hpp | 5 +-- 2 files changed, 83 insertions(+), 5 deletions(-) diff --git a/src/glue/CGlueMgr.cpp b/src/glue/CGlueMgr.cpp index 97a7893..6a87e9c 100644 --- a/src/glue/CGlueMgr.cpp +++ b/src/glue/CGlueMgr.cpp @@ -135,6 +135,23 @@ int32_t CGlueMgr::Idle(const void* a1, void* a2) { // TODO + switch (CGlueMgr::m_idleState) { + case IDLE_LOGIN_SERVER_LOGIN: { + CGlueMgr::PollLoginServerLogin(); + break; + } + + case IDLE_ACCOUNT_LOGIN: { + // TODO PollAccountLogin + break; + } + + // TODO other idle states + + default: + break; + } + return 1; } @@ -199,7 +216,7 @@ void CGlueMgr::LoginServerLogin(const char* accountName, const char* password) { CGlueMgr::m_lastLoginState = -1; CGlueMgr::m_authenticated = false; CGlueMgr::m_matrixRemaining = 0; - CGlueMgr::m_idleState = IDLE_ACCOUNT_LOGIN; + CGlueMgr::m_idleState = IDLE_LOGIN_SERVER_LOGIN; CGlueMgr::m_showedDisconnect = 0; char* dest = CGlueMgr::m_accountName; @@ -227,6 +244,66 @@ void CGlueMgr::QuitGame() { ClientPostClose(0); } +void CGlueMgr::PollLoginServerLogin() { + if (CGlueMgr::m_loginState != LOGIN_STATE_PIN_WAIT) { + // TODO + // CGlueMgr::DisplayLoginStatus(); + } + + if (CGlueMgr::m_authenticated) { + CGlueMgr::m_idleState = IDLE_NONE; + CGlueMgr::m_showedDisconnect = 0; + // Sub4D8BA0(); + CGlueMgr::m_authenticated = false; + return; + } + + switch (CGlueMgr::m_loginState) { + case LOGIN_STATE_FAILED: { + // TODO + + break; + } + + case LOGIN_STATE_DOWNLOADFILE: { + // TODO + + break; + } + + case LOGIN_STATE_PIN: { + // TODO + + break; + } + + case LOGIN_STATE_MATRIX: { + // TODO + + break; + } + + case LOGIN_STATE_TOKEN: { + // TODO + + break; + } + + case LOGIN_STATE_CHECKINGVERSIONS: { + uint8_t versionChecksum[20]; + // TODO + // uint8_t* versionChallenge = ClientServices::LoginConnection()->GetVersionChallenge(); + // ChecksumExecutables(versionChallenge, 16, versionChecksum); + ClientServices::LoginConnection()->ProveVersion(versionChecksum); + + break; + } + + default: + break; + } +} + void CGlueMgr::Resume() { // TODO // CGlueMgr::m_disconnectPending = 0; @@ -393,7 +470,7 @@ void CGlueMgr::StatusDialogClick() { break; } - case IDLE_ACCOUNT_LOGIN: { + case IDLE_LOGIN_SERVER_LOGIN: { ClientServices::LoginConnection()->Logoff(); CGlueMgr::m_showedDisconnect = 0; @@ -402,7 +479,7 @@ void CGlueMgr::StatusDialogClick() { break; } - case IDLE_2: + case IDLE_ACCOUNT_LOGIN: case IDLE_3: { ClientServices::Connection()->Cancel(2); diff --git a/src/glue/CGlueMgr.hpp b/src/glue/CGlueMgr.hpp index 15a6cde..ecc21bc 100644 --- a/src/glue/CGlueMgr.hpp +++ b/src/glue/CGlueMgr.hpp @@ -12,8 +12,8 @@ class CGlueMgr { // Types enum GLUE_IDLE_STATE { IDLE_NONE = 0, - IDLE_ACCOUNT_LOGIN = 1, - IDLE_2 = 2, + IDLE_LOGIN_SERVER_LOGIN = 1, + IDLE_ACCOUNT_LOGIN = 2, IDLE_3 = 3, IDLE_4 = 4, IDLE_5 = 5, @@ -58,6 +58,7 @@ class CGlueMgr { static void Initialize(); static void LoginServerLogin(const char* accountName, const char* password); static void QuitGame(); + static void PollLoginServerLogin(); static void Resume(); static void SetLoginStateAndResult(LOGIN_STATE state, LOGIN_RESULT result, char const* addrStr, char const* stateStr, char const* resultStr, uint8_t flags); static void SetScreen(const char* screen);