2023-01-02 13:17:18 -06:00
|
|
|
#include "client/ClientServices.hpp"
|
|
|
|
|
#include "client/ClientRealmResponseAdapter.hpp"
|
2023-01-09 17:37:24 -06:00
|
|
|
#include "glue/CGlueMgr.hpp"
|
2023-01-02 13:17:18 -06:00
|
|
|
#include "net/Connection.hpp"
|
|
|
|
|
#include "net/Login.hpp"
|
|
|
|
|
#include <storm/Memory.hpp>
|
|
|
|
|
#include <storm/String.hpp>
|
|
|
|
|
#include <new>
|
|
|
|
|
|
|
|
|
|
ClientConnection* g_clientConnection;
|
|
|
|
|
|
|
|
|
|
RealmResponse* ClientServices::s_clientRealmResponse;
|
|
|
|
|
ClientConnection* ClientServices::s_currentConnection;
|
|
|
|
|
ClientServices* ClientServices::s_instance;
|
|
|
|
|
Login* ClientServices::s_loginObj;
|
|
|
|
|
bool ClientServices::s_newLogin;
|
|
|
|
|
|
|
|
|
|
ClientConnection* ClientServices::Connection() {
|
|
|
|
|
// TODO assertion?
|
|
|
|
|
|
|
|
|
|
return ClientServices::s_currentConnection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClientServices* ClientServices::GetInstance() {
|
|
|
|
|
if (ClientServices::s_instance) {
|
|
|
|
|
return ClientServices::s_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-04 21:00:29 -06:00
|
|
|
auto m = SMemAlloc(sizeof(ClientServices), __FILE__, __LINE__, 0x0);
|
|
|
|
|
auto instance = new (m) ClientServices();
|
2023-01-02 13:17:18 -06:00
|
|
|
ClientServices::s_instance = instance;
|
|
|
|
|
|
|
|
|
|
return ClientServices::s_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientServices::Initialize() {
|
|
|
|
|
if (!g_clientConnection) {
|
|
|
|
|
auto adapterMem = SMemAlloc(sizeof(ClientRealmResponseAdapter), __FILE__, __LINE__, 0x0);
|
|
|
|
|
auto clientRealmResponse = new (adapterMem) ClientRealmResponseAdapter();
|
|
|
|
|
ClientServices::s_clientRealmResponse = clientRealmResponse;
|
|
|
|
|
|
|
|
|
|
auto connectionMem = SMemAlloc(sizeof(ClientConnection), __FILE__, __LINE__, 0x0);
|
|
|
|
|
auto clientConnection = new (connectionMem) ClientConnection(ClientServices::s_clientRealmResponse);
|
|
|
|
|
g_clientConnection = clientConnection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClientServices::s_currentConnection = g_clientConnection;
|
|
|
|
|
|
|
|
|
|
// TODO ConsoleCommandRegister("logout", &Sub6B2030, 5, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Login* ClientServices::LoginConnection() {
|
|
|
|
|
return ClientServices::s_loginObj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClientServices::Logon(const char* accountName, const char* password) {
|
|
|
|
|
if (ClientServices::s_newLogin) {
|
|
|
|
|
if (ClientServices::s_loginObj) {
|
|
|
|
|
// TODO
|
|
|
|
|
// ClientServices::s_loginObj->Vfunc48(1);
|
|
|
|
|
|
|
|
|
|
ClientServices::s_loginObj = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClientServices::s_newLogin = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto useBattlenet = SStrChr(accountName, '@') != 0;
|
|
|
|
|
|
|
|
|
|
Login* loginObj;
|
|
|
|
|
|
|
|
|
|
if (useBattlenet) {
|
|
|
|
|
// TODO
|
|
|
|
|
} else {
|
|
|
|
|
auto loginMem = SMemAlloc(sizeof(GruntLogin), __FILE__, __LINE__, 0x0);
|
|
|
|
|
loginObj = new (loginMem) GruntLogin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClientServices::s_loginObj = loginObj;
|
|
|
|
|
ClientServices::s_loginObj->Init(ClientServices::GetInstance());
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
|
|
ClientServices::s_loginObj->SetLogonCreds(accountName, password);
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
|
|
ClientServices::s_loginObj->Logon(nullptr, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-09 17:37:24 -06:00
|
|
|
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) {
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
2023-01-02 13:17:18 -06:00
|
|
|
}
|