feat(net): use LoginResponse::UpdateLoginStatus to adjust states in GruntLogin::LogonResult

This commit is contained in:
fallenoak 2023-02-07 17:04:24 -06:00
parent 5355b75768
commit 153b25ede9
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
3 changed files with 12 additions and 30 deletions

View File

@ -166,40 +166,18 @@ void GruntLogin::LogonResult(Grunt::Result result, const uint8_t* sessionKey, ui
}
memcpy(this->m_sessionKey, sessionKey, sessionKeyLen);
this->m_loginResponse->m_loginResult = LOGIN_OK;
if (this->m_clientLink->m_surveyID == 0) {
this->m_loginResponse->m_loginState = LOGIN_STATE_AUTHENTICATED;
char stateStr[64];
SStrCopy(stateStr, Grunt::g_LoginStateStringNames[LOGIN_STATE_AUTHENTICATED], sizeof(stateStr));
char resultStr[64];
SStrCopy(resultStr, Grunt::g_LoginResultStringNames[LOGIN_OK], sizeof(resultStr));
this->m_loginResponse->LoginServerStatus(
this->m_loginResponse->UpdateLoginStatus(
LOGIN_STATE_AUTHENTICATED,
LOGIN_OK,
nullptr,
stateStr,
resultStr,
flags
);
} else {
this->m_loginResponse->m_loginState = LOGIN_STATE_SURVEY;
char stateStr[64];
SStrCopy(stateStr, Grunt::g_LoginStateStringNames[LOGIN_STATE_SURVEY], sizeof(stateStr));
char resultStr[64];
SStrCopy(resultStr, Grunt::g_LoginResultStringNames[LOGIN_OK], sizeof(resultStr));
this->m_loginResponse->LoginServerStatus(
this->m_loginResponse->UpdateLoginStatus(
LOGIN_STATE_SURVEY,
LOGIN_OK,
nullptr,
stateStr,
resultStr,
flags
);
}

View File

@ -1,12 +1,16 @@
#include "net/login/LoginResponse.hpp"
#include "net/grunt/Grunt.hpp"
#include <storm/String.hpp>
void LoginResponse::UpdateLoginStatus(LOGIN_STATE state, LOGIN_RESULT result, const char* a4, uint16_t a5) {
void LoginResponse::UpdateLoginStatus(LOGIN_STATE state, LOGIN_RESULT result, const char* addrStr, uint16_t flags) {
this->m_loginState = state;
this->m_loginResult = result;
// TODO string lookups
const char* stateStr = nullptr;
const char* resultStr = nullptr;
char stateStr[64];
SStrCopy(stateStr, Grunt::g_LoginStateStringNames[LOGIN_STATE_AUTHENTICATED], sizeof(stateStr));
this->LoginServerStatus(state, result, a4, stateStr, resultStr, a5);
char resultStr[64];
SStrCopy(resultStr, Grunt::g_LoginResultStringNames[LOGIN_OK], sizeof(resultStr));
this->LoginServerStatus(state, result, addrStr, stateStr, resultStr, flags);
}

View File

@ -13,7 +13,7 @@ class LoginResponse {
virtual void LoginServerStatus(LOGIN_STATE state, LOGIN_RESULT result, const char* addrStr, const char* stateStr, const char* resultStr, uint8_t flags) = 0;
// Member functions
void UpdateLoginStatus(LOGIN_STATE state, LOGIN_RESULT result, const char* a4, uint16_t a5);
void UpdateLoginStatus(LOGIN_STATE state, LOGIN_RESULT result, const char* addrStr, uint16_t flags);
};
#endif