mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-26 13:56:05 +03:00
feat(client): handle successful authentication in ClientServices
This commit is contained in:
parent
9fe2e2e8ff
commit
5355b75768
@ -9,6 +9,7 @@
|
||||
|
||||
ClientConnection* g_clientConnection;
|
||||
|
||||
char ClientServices::s_accountName[1280];
|
||||
RealmResponse* ClientServices::s_clientRealmResponse;
|
||||
ClientConnection* ClientServices::s_currentConnection;
|
||||
ClientServices* ClientServices::s_instance;
|
||||
@ -88,10 +89,33 @@ void ClientServices::Logon(const char* accountName, const char* password) {
|
||||
ClientServices::s_loginObj->Logon(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void ClientServices::SetAccountName(const char* accountName) {
|
||||
SStrCopy(ClientServices::s_accountName, accountName, sizeof(ClientServices::s_accountName));
|
||||
}
|
||||
|
||||
void ClientServices::LoginServerStatus(LOGIN_STATE state, LOGIN_RESULT result, const char* addrStr, const char* stateStr, const char* resultStr, uint8_t flags) {
|
||||
CGlueMgr::SetLoginStateAndResult(state, result, addrStr, stateStr, resultStr, flags);
|
||||
|
||||
if (state == LOGIN_STATE_AUTHENTICATED) {
|
||||
LoginData loginData;
|
||||
SStrCopy(loginData.m_account, ClientServices::LoginConnection()->m_accountName, sizeof(loginData.m_account));
|
||||
loginData.m_loginServerID = ClientServices::LoginConnection()->GetServerId();
|
||||
memcpy(loginData.m_sessionKey, ClientServices::LoginConnection()->m_sessionKey, sizeof(loginData.m_sessionKey));
|
||||
loginData.m_loginServerType = ClientServices::LoginConnection()->GetLoginServerType();
|
||||
|
||||
if (!ClientServices::s_currentConnection) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
ClientServices::s_currentConnection->SetLoginData(&loginData);
|
||||
ClientServices::SetAccountName(loginData.m_account);
|
||||
|
||||
CGlueMgr::SetCurrentAccount(loginData.m_account);
|
||||
|
||||
// TODO
|
||||
// - initialize addons?
|
||||
// sub_5F9080(v7.m_account);
|
||||
|
||||
// TODO CVar::DeleteAccountCVars();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ class RealmResponse;
|
||||
class ClientServices : public LoginResponse {
|
||||
public:
|
||||
// Static variables
|
||||
static char s_accountName[1280];
|
||||
static RealmResponse* s_clientRealmResponse;
|
||||
static ClientConnection* s_currentConnection;
|
||||
static ClientServices* s_instance;
|
||||
@ -22,6 +23,7 @@ class ClientServices : public LoginResponse {
|
||||
static void Initialize();
|
||||
static Login* LoginConnection();
|
||||
static void Logon(const char* accountName, const char* password);
|
||||
static void SetAccountName(const char* accountName);
|
||||
|
||||
// Virtual member functions
|
||||
virtual void LoginServerStatus(LOGIN_STATE state, LOGIN_RESULT result, const char* addrStr, const char* stateStr, const char* resultStr, uint8_t flags);
|
||||
|
||||
@ -250,6 +250,7 @@ void CGlueMgr::PollLoginServerLogin() {
|
||||
// CGlueMgr::DisplayLoginStatus();
|
||||
}
|
||||
|
||||
// Open new client connection after successful authentication
|
||||
if (CGlueMgr::m_authenticated) {
|
||||
CGlueMgr::m_idleState = IDLE_NONE;
|
||||
CGlueMgr::m_showedDisconnect = 0;
|
||||
@ -438,6 +439,11 @@ void CGlueMgr::Resume() {
|
||||
// }
|
||||
}
|
||||
|
||||
void CGlueMgr::SetCurrentAccount(const char* accountName) {
|
||||
SStrCopy(CGlueMgr::m_accountName, accountName, sizeof(CGlueMgr::m_accountName));
|
||||
SStrUpper(CGlueMgr::m_accountName);
|
||||
}
|
||||
|
||||
void CGlueMgr::SetLoginStateAndResult(LOGIN_STATE state, LOGIN_RESULT result, const char* addrStr, const char* stateStr, const char* resultStr, uint8_t flags) {
|
||||
// TODO
|
||||
// CGlueMgr::LogConnectionStatus("GRUNT: state: %s result: %s %s", a4);
|
||||
|
||||
@ -60,6 +60,7 @@ class CGlueMgr {
|
||||
static void QuitGame();
|
||||
static void PollLoginServerLogin();
|
||||
static void Resume();
|
||||
static void SetCurrentAccount(const char* accountName);
|
||||
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);
|
||||
static void StatusDialogClick();
|
||||
|
||||
@ -1208,6 +1208,13 @@ enum WOWCS_OPS {
|
||||
COP_WAIT_QUEUE = 10,
|
||||
};
|
||||
|
||||
struct LoginData {
|
||||
char m_account[1280];
|
||||
int32_t m_loginServerID;
|
||||
uint8_t m_sessionKey[40];
|
||||
int32_t m_loginServerType;
|
||||
};
|
||||
|
||||
struct NETADDR {
|
||||
uint16_t family;
|
||||
char data[14];
|
||||
|
||||
@ -44,6 +44,10 @@ int32_t NetClient::Initialize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void NetClient::SetLoginData(LoginData* loginData) {
|
||||
memcpy(&this->m_loginData, loginData, sizeof(this->m_loginData));
|
||||
}
|
||||
|
||||
void NetClient::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param) {
|
||||
this->m_handlers[msgId] = handler;
|
||||
this->m_handlerParams[msgId] = param;
|
||||
|
||||
@ -36,6 +36,7 @@ class NetClient : public WowConnectionResponse {
|
||||
static int32_t s_clientCount;
|
||||
|
||||
// Member variables
|
||||
LoginData m_loginData;
|
||||
NETSTATE m_netState = NS_UNINITIALIZED;
|
||||
MESSAGE_HANDLER m_handlers[NUM_MSG_TYPES];
|
||||
void* m_handlerParams[NUM_MSG_TYPES];
|
||||
@ -50,6 +51,7 @@ class NetClient : public WowConnectionResponse {
|
||||
|
||||
// Member functions
|
||||
int32_t Initialize();
|
||||
void SetLoginData(LoginData* loginData);
|
||||
void SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param);
|
||||
};
|
||||
|
||||
|
||||
@ -17,11 +17,13 @@ class Grunt::ClientResponse {
|
||||
virtual void SetTokenInfo(bool enabled, uint8_t required) = 0;
|
||||
virtual void LogonResult(Result result, const uint8_t* sessionKey, uint32_t sessionKeyLen, uint16_t flags) = 0;
|
||||
virtual LOGIN_STATE NextSecurityState(LOGIN_STATE state) = 0;
|
||||
virtual int32_t GetServerId() = 0;
|
||||
virtual void GetRealmList() = 0;
|
||||
virtual void Logon(const char* a2, const char* a3) = 0;
|
||||
virtual void ProveVersion(const uint8_t* versionChecksum) = 0;
|
||||
virtual void Logoff() = 0;
|
||||
virtual void Init(LoginResponse* loginResponse) = 0;
|
||||
virtual int32_t GetLoginServerType() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -34,6 +34,11 @@ bool GruntLogin::Connected(const NETADDR& addr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t GruntLogin::GetLoginServerType() {
|
||||
// Grunt
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GruntLogin::GetLogonMethod() {
|
||||
Grunt::ClientLink::Logon logon;
|
||||
|
||||
@ -88,6 +93,11 @@ void GruntLogin::GetRealmList() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
int32_t GruntLogin::GetServerId() {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GruntLogin::GetVersionProof(const uint8_t* versionChallenge) {
|
||||
if (this->IsReconnect()) {
|
||||
// TODO
|
||||
|
||||
@ -21,11 +21,13 @@ class GruntLogin : public Login {
|
||||
virtual void SetTokenInfo(bool enabled, uint8_t tokenRequired);
|
||||
virtual void LogonResult(Grunt::Result result, const uint8_t* sessionKey, uint32_t sessionKeyLen, uint16_t flags);
|
||||
virtual LOGIN_STATE NextSecurityState(LOGIN_STATE state);
|
||||
virtual int32_t GetServerId();
|
||||
virtual void GetRealmList();
|
||||
virtual void Logon(const char* a2, const char* a3);
|
||||
virtual void ProveVersion(const uint8_t* versionChecksum);
|
||||
virtual void Logoff();
|
||||
virtual void Init(LoginResponse* loginResponse);
|
||||
virtual int32_t GetLoginServerType();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user