From 9ebb798bdacf736d944eea5bb8a974ad4849959f Mon Sep 17 00:00:00 2001 From: Tristan Cormier Date: Wed, 8 Oct 2025 21:27:13 -0400 Subject: [PATCH] feat(connection): add ClientConnection::GetRealmList --- src/client/ClientServices.cpp | 4 ++++ src/client/ClientServices.hpp | 1 + src/net/connection/ClientConnection.cpp | 16 ++++++++++++++++ src/net/connection/ClientConnection.hpp | 1 + 4 files changed, 22 insertions(+) diff --git a/src/client/ClientServices.cpp b/src/client/ClientServices.cpp index 6321a32..3d4060b 100644 --- a/src/client/ClientServices.cpp +++ b/src/client/ClientServices.cpp @@ -200,6 +200,10 @@ REALM_INFO* ClientServices::GetRealmInfoByIndex(int32_t index) { return &ClientServices::GetInstance()->m_realmList[index]; } +void ClientServices::GetRealmList() { + ClientServices::Connection()->GetRealmList(); +} + const char* ClientServices::GetSelectedRealmName() { if (!ClientServices::s_realmNameVar) { ClientServices::s_realmNameVar = CVar::Register( diff --git a/src/client/ClientServices.hpp b/src/client/ClientServices.hpp index 798e298..f9aae59 100644 --- a/src/client/ClientServices.hpp +++ b/src/client/ClientServices.hpp @@ -36,6 +36,7 @@ class ClientServices : public LoginResponse { static const char* GetErrorToken(int32_t errorCode); static ClientServices* GetInstance(); static REALM_INFO* GetRealmInfoByIndex(int32_t index); + static void GetRealmList(); static const char* GetSelectedRealmName(); static const REALM_INFO* GetSelectedRealm(); static void Initialize(); diff --git a/src/net/connection/ClientConnection.cpp b/src/net/connection/ClientConnection.cpp index 7cdb286..99b4183 100644 --- a/src/net/connection/ClientConnection.cpp +++ b/src/net/connection/ClientConnection.cpp @@ -91,6 +91,22 @@ void ClientConnection::GetCharacterList() { } } +void ClientConnection::GetRealmList() { + this->m_cleanup = nullptr; + this->m_statusCop = COP_GET_REALMS; + this->m_errorCode = 35; + this->m_statusComplete = 0; + + // TODO LogConnectionStatus(this->m_statusCop, this->m_errorCode, 1); + + if (ClientServices::LoginConnection()->IsLoggedOn()) { + ClientServices::LoginConnection()->GetRealmList(); + } + else { + ClientServices::LoginConnection()->Reconnect(); + } +} + int32_t ClientConnection::HandleConnect() { this->Complete(1, 5); diff --git a/src/net/connection/ClientConnection.hpp b/src/net/connection/ClientConnection.hpp index 445db0e..0af46fc 100644 --- a/src/net/connection/ClientConnection.hpp +++ b/src/net/connection/ClientConnection.hpp @@ -37,6 +37,7 @@ class ClientConnection : public RealmConnection { int32_t Disconnect(); void EnumerateCharacters(ENUMERATE_CHARACTERS_CALLBACK callback, void* param); void GetCharacterList(); + void GetRealmList(); void Initiate(WOWCS_OPS op, int32_t errorCode, void (*cleanup)()); int32_t IsConnected(); int32_t PollStatus(WOWCS_OPS& op, const char** msg, int32_t& result, int32_t& errorCode);