feat(glue): add initial account login handling to glue idle loop

This commit is contained in:
fallenoak 2023-02-11 23:35:53 -06:00
parent 6b1b666d41
commit 3dc51289b8
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D
7 changed files with 247 additions and 3 deletions

View file

@ -1,4 +1,5 @@
#include "glue/CGlueMgr.hpp"
#include "glue/CRealmList.hpp"
#include "client/Client.hpp"
#include "client/ClientServices.hpp"
#include "gx/Coordinate.hpp"
@ -46,6 +47,7 @@ char CGlueMgr::m_accountName[1280];
float CGlueMgr::m_aspect;
bool CGlueMgr::m_authenticated;
char CGlueMgr::m_currentScreen[64];
int32_t CGlueMgr::m_displayingQueueDialog;
CGlueMgr::GLUE_IDLE_STATE CGlueMgr::m_idleState;
int32_t CGlueMgr::m_initialized;
int32_t CGlueMgr::m_lastLoginResult;
@ -195,6 +197,12 @@ int32_t CGlueMgr::Idle(const void* a1, void* a2) {
// TODO
WOWCS_OPS op;
const char* msg;
int32_t result;
int32_t errorCode;
int32_t complete = ClientServices::Connection()->PollStatus(op, &msg, result, errorCode);
switch (CGlueMgr::m_idleState) {
case IDLE_LOGIN_SERVER_LOGIN: {
CGlueMgr::PollLoginServerLogin();
@ -202,7 +210,7 @@ int32_t CGlueMgr::Idle(const void* a1, void* a2) {
}
case IDLE_ACCOUNT_LOGIN: {
// TODO PollAccountLogin
CGlueMgr::PollAccountLogin(errorCode, msg, complete, result, op);
break;
}
@ -304,6 +312,75 @@ void CGlueMgr::QuitGame() {
ClientPostClose(0);
}
void CGlueMgr::PollAccountLogin(int32_t errorCode, const char* msg, int32_t complete, int32_t result, WOWCS_OPS op) {
auto login = ClientServices::LoginConnection();
if (login->GetLoginServerType() == 1 && CGlueMgr::m_loginState == LOGIN_STATE_FAILED) {
CGlueMgr::DisplayLoginStatus();
ClientServices::Connection()->Cancel(2);
login->Logoff();
CGlueMgr::m_idleState = IDLE_NONE;
CGlueMgr::m_showedDisconnect = 0;
return;
}
if (errorCode == 27) {
// TODO AUTH_WAIT_QUEUE
} else {
if (CGlueMgr::m_displayingQueueDialog) {
FrameScript_SignalEvent(3, "%s", "CANCEL");
CGlueMgr::m_displayingQueueDialog = 0;
}
FrameScript_SignalEvent(4, "%s", msg);
}
if (complete) {
if (result == 0) {
if (errorCode != 2) {
// TODO
}
CGlueMgr::m_idleState = IDLE_NONE;
CGlueMgr::m_showedDisconnect = 0;
if (errorCode == 2) {
// TODO CGlueMgr::m_disconnectPending = 1;
// TODO ClientServices::Connection()->Disconnect();
}
if (errorCode != 13) {
// TODO CCharacterSelection::ClearCharacterList();
if (ClientServices::GetInstance()->m_realmList.Count()) {
FrameScript_SignalEvent(5, nullptr);
CRealmList::UpdateList();
} else {
// TODO
}
return;
}
if (!SStrCmpI(CGlueMgr::m_currentScreen, "charselect", STORM_MAX_STR)) {
CGlueMgr::SetScreen("login");
return;
}
return;
}
if (op == COP_CONNECT) {
// TODO
return;
}
}
}
void CGlueMgr::PollLoginServerLogin() {
if (CGlueMgr::m_loginState != LOGIN_STATE_PIN_WAIT) {
CGlueMgr::DisplayLoginStatus();

View file

@ -36,6 +36,7 @@ class CGlueMgr {
static float m_aspect;
static bool m_authenticated;
static char m_currentScreen[];
static int32_t m_displayingQueueDialog;
static GLUE_IDLE_STATE m_idleState;
static int32_t m_initialized;
static int32_t m_lastLoginResult;
@ -59,6 +60,7 @@ class CGlueMgr {
static void Initialize();
static void LoginServerLogin(const char* accountName, const char* password);
static void QuitGame();
static void PollAccountLogin(int32_t errorCode, const char* msg, int32_t complete, int32_t result, WOWCS_OPS op);
static void PollLoginServerLogin();
static void Resume();
static void SetCurrentAccount(const char* accountName);

5
src/glue/CRealmList.cpp Normal file
View file

@ -0,0 +1,5 @@
#include "glue/CRealmList.hpp"
void CRealmList::UpdateList() {
// TODO
}

10
src/glue/CRealmList.hpp Normal file
View file

@ -0,0 +1,10 @@
#ifndef GLUE_C_REALM_LIST_HPP
#define GLUE_C_REALM_LIST_HPP
class CRealmList {
public:
// Static functions
static void UpdateList();
};
#endif