diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index 31e839ec..e272dd17 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -134,7 +134,8 @@ public: uint16_t port, const std::vector& sessionKey, const std::string& accountName, - uint32_t build = 12340); + uint32_t build = 12340, + uint32_t realmId = 0); /** * Disconnect from world server @@ -957,6 +958,7 @@ private: std::vector sessionKey; // 40-byte session key from auth server std::string accountName; // Account name uint32_t build = 12340; // Client build (3.3.5a) + uint32_t realmId_ = 0; // Realm ID from auth REALM_LIST (used in WotLK AUTH_SESSION) uint32_t clientSeed = 0; // Random seed generated by client uint32_t serverSeed = 0; // Seed from SMSG_AUTH_CHALLENGE diff --git a/src/core/application.cpp b/src/core/application.cpp index 9295733f..d2cbb521 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -892,12 +892,25 @@ void Application::setupUICallbacks() { accountName = "TESTACCOUNT"; } + uint32_t realmId = 0; + { + // WotLK AUTH_SESSION includes a RealmID field; some servers reject if it's wrong/zero. + const auto& realms = authHandler->getRealms(); + for (const auto& r : realms) { + if (r.name == realmName && r.address == realmAddress) { + realmId = r.id; + break; + } + } + LOG_INFO("Selected realmId=", realmId); + } + uint32_t clientBuild = 12340; // default WotLK if (expansionRegistry_) { auto* profile = expansionRegistry_->getActive(); if (profile) clientBuild = profile->build; } - if (gameHandler->connect(host, port, sessionKey, accountName, clientBuild)) { + if (gameHandler->connect(host, port, sessionKey, accountName, clientBuild, realmId)) { LOG_INFO("Connected to world server, transitioning to character selection"); setState(AppState::CHARACTER_SELECTION); } else { diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index a56d955f..0a95725a 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -114,7 +114,8 @@ bool GameHandler::connect(const std::string& host, uint16_t port, const std::vector& sessionKey, const std::string& accountName, - uint32_t build) { + uint32_t build, + uint32_t realmId) { if (sessionKey.size() != 40) { LOG_ERROR("Invalid session key size: ", sessionKey.size(), " (expected 40)"); @@ -134,6 +135,7 @@ bool GameHandler::connect(const std::string& host, this->sessionKey = sessionKey; this->accountName = accountName; this->build = build; + this->realmId_ = realmId; requiresWarden_ = false; wardenGateSeen_ = false; wardenGateElapsed_ = 0.0f; @@ -1433,7 +1435,8 @@ void GameHandler::sendAuthSession() { accountName, clientSeed, sessionKey, - serverSeed + serverSeed, + realmId_ ); LOG_DEBUG("CMSG_AUTH_SESSION packet size: ", packet.getSize(), " bytes");