feat(net): handle SMSG_AUTH_RESPONSE

This commit is contained in:
fallenoak 2023-04-03 18:00:18 -05:00
parent 6479dcaecf
commit e18afec28d
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
5 changed files with 115 additions and 2 deletions

View File

@ -0,0 +1,5 @@
#include "client/ClientRealmResponseAdapter.hpp"
void ClientRealmResponseAdapter::HandleAuthResponse(RealmConnection* connection, uint8_t authResult) {
// TODO
}

View File

@ -5,6 +5,9 @@
class ClientRealmResponseAdapter : public RealmResponse {
public:
// Virtual member functions
virtual void HandleAuthResponse(RealmConnection* connection, uint8_t authResult);
virtual void GameServerResult(RealmConnection* connection, const char* a2, const char* a3, const char* a4) {};
};
#endif

View File

@ -1,4 +1,5 @@
#include "net/connection/RealmConnection.hpp"
#include "net/connection/RealmResponse.hpp"
#include "net/Types.hpp"
#include <common/DataStore.hpp>
#include <common/SHA1.hpp>
@ -8,8 +9,64 @@ SCritSect RealmConnection::s_AllRealmConnectionsCrit;
STORM_LIST(RealmConnection::REALMCONNECTIONNODE) RealmConnection::s_AllRealmConnections;
int32_t RealmConnection::MessageHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
// TODO
return 0;
auto connection = static_cast<RealmConnection*>(param);
int32_t result = 0;
switch (msgId) {
case SMSG_AUTH_RESPONSE: {
result = connection->HandleAuthResponse(msgId, time, msg);
break;
}
case SMSG_CREATE_CHAR: {
// TODO
break;
}
case SMSG_ENUM_CHARACTERS_RESULT: {
// TODO
break;
}
case SMSG_DELETE_CHAR: {
// TODO
break;
}
case SMSG_CHARACTER_LOGIN_FAILED: {
// TODO
break;
}
case SMSG_ADDON_INFO: {
// TODO
break;
}
case SMSG_LOGOUT_CANCEL_ACK: {
// TODO
break;
}
case SMSG_LOGOUT_COMPLETE: {
// TODO
break;
}
case SMSG_LOGOUT_RESPONSE: {
// TODO
break;
}
default:
break;
}
if (!msg->IsRead()) {
// TODO
}
return result;
}
void RealmConnection::PollNet() {
@ -99,6 +156,43 @@ int32_t RealmConnection::HandleAuthChallenge(AuthenticationChallenge* challenge)
return 1;
}
int32_t RealmConnection::HandleAuthResponse(uint32_t msgId, uint32_t time, CDataStore* msg) {
if (this->m_realmResponse) {
this->m_realmResponse->GameServerResult(this, "SMSG_AUTH_RESPONSE", nullptr, nullptr);
}
uint8_t authResult;
msg->Get(authResult);
// AUTH_OK or AUTH_WAIT_QUEUE
if (authResult == 12 || authResult == 27) {
// AUTH_OK
if (authResult == 12) {
this->m_authenticated = 1;
}
if (msg->Size() - msg->m_read >= 10 + (authResult == 27 ? 5 : 0)) {
msg->Get(this->m_billingTimeRemaining);
msg->Get(this->m_billingFlags);
msg->Get(this->m_billingTimeRested);
msg->Get(this->m_accountExpansion);
}
// AUTH_WAIT_QUEUE
if (authResult == 27) {
msg->Get(this->m_queuePosition);
uint8_t freeCharacterMigration;
msg->Get(freeCharacterMigration);
this->m_freeCharacterMigration = freeCharacterMigration;
}
}
this->m_realmResponse->HandleAuthResponse(this, authResult);
return 1;
}
void RealmConnection::SetSelectedRealm(uint32_t a2, uint32_t a3, uint32_t a4) {
// TODO
}

View File

@ -24,12 +24,20 @@ class RealmConnection : public NetClient {
// Member variables
RealmResponse* m_realmResponse;
uint8_t m_authenticated = 0;
uint32_t m_queuePosition = 0;
uint32_t m_freeCharacterMigration = 0;
uint32_t m_billingTimeRemaining = 0;
uint32_t m_billingTimeRested = 0;
uint8_t m_billingFlags = 0;
uint8_t m_accountExpansion = 0;
// Virtual member functions
virtual int32_t HandleAuthChallenge(AuthenticationChallenge* challenge);
// Member functions
RealmConnection(RealmResponse* realmResponse);
int32_t HandleAuthResponse(uint32_t msgId, uint32_t time, CDataStore* msg);
void SetSelectedRealm(uint32_t a2, uint32_t a3, uint32_t a4);
};

View File

@ -3,6 +3,9 @@
class RealmResponse {
public:
// Virtual member functions
virtual void HandleAuthResponse(RealmConnection* connection, uint8_t authResult) = 0;
virtual void GameServerResult(RealmConnection* connection, const char* a3, const char* a4, const char* a5) = 0;
};
#endif