Skip to content

Commit

Permalink
Fix crash on login.
Browse files Browse the repository at this point in the history
  • Loading branch information
ratkosrb committed Jun 22, 2024
1 parent 29dc202 commit 54fa00e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/realmd/AuthSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,10 @@ AccountTypes AuthSocket::GetSecurityOn(uint32 realmId) const
// Read the packet from the client
void AuthSocket::ProcessIncomingData()
{
// benchmarking has demonstrated that this lookup method is faster than std::map
constexpr AuthHandler table[] =
{
{ CMD_AUTH_LOGON_CHALLENGE, STATUS_CHALLENGE, &AuthSocket::_HandleLogonChallenge },
{ CMD_AUTH_LOGON_PROOF, STATUS_LOGON_PROOF, &AuthSocket::_HandleLogonProof },
{ CMD_AUTH_RECONNECT_CHALLENGE, STATUS_CHALLENGE, &AuthSocket::_HandleReconnectChallenge },
{ CMD_AUTH_RECONNECT_PROOF, STATUS_RECON_PROOF, &AuthSocket::_HandleReconnectProof },
{ CMD_REALM_LIST, STATUS_AUTHED, &AuthSocket::_HandleRealmList },
//{ CMD_XFER_ACCEPT, STATUS_PATCH, &AuthSocket::_HandleXferAccept },
//{ CMD_XFER_RESUME, STATUS_PATCH, &AuthSocket::_HandleXferResume },
//{ CMD_XFER_CANCEL, STATUS_PATCH, &AuthSocket::_HandleXferCancel }
};

constexpr size_t tableLength = sizeof(table) / sizeof(AuthHandler);

std::shared_ptr<eAuthCmd> cmd = std::make_shared<eAuthCmd>();

sLog.Out(LOG_BASIC, LOG_LVL_DEBUG, "ProcessIncomingData() Reading... Ready for next opcode");
Read((char*)cmd.get(), sizeof(eAuthCmd), [self = shared_from_this(), cmd, &table, tableLength](MaNGOS::IO::NetworkError const& error) -> void
Read((char*)cmd.get(), sizeof(eAuthCmd), [self = shared_from_this(), cmd](MaNGOS::IO::NetworkError const& error) -> void
{
if (error)
{
Expand All @@ -244,6 +229,21 @@ void AuthSocket::ProcessIncomingData()
return;
}

// benchmarking has demonstrated that this lookup method is faster than std::map
constexpr AuthHandler table[] =
{
{ CMD_AUTH_LOGON_CHALLENGE, STATUS_CHALLENGE, &AuthSocket::_HandleLogonChallenge },
{ CMD_AUTH_LOGON_PROOF, STATUS_LOGON_PROOF, &AuthSocket::_HandleLogonProof },
{ CMD_AUTH_RECONNECT_CHALLENGE, STATUS_CHALLENGE, &AuthSocket::_HandleReconnectChallenge },
{ CMD_AUTH_RECONNECT_PROOF, STATUS_RECON_PROOF, &AuthSocket::_HandleReconnectProof },
{ CMD_REALM_LIST, STATUS_AUTHED, &AuthSocket::_HandleRealmList },
//{ CMD_XFER_ACCEPT, STATUS_PATCH, &AuthSocket::_HandleXferAccept },
//{ CMD_XFER_RESUME, STATUS_PATCH, &AuthSocket::_HandleXferResume },
//{ CMD_XFER_CANCEL, STATUS_PATCH, &AuthSocket::_HandleXferCancel }
};

constexpr size_t tableLength = sizeof(table) / sizeof(AuthHandler);

size_t i;
// Circle through known commands and call the correct command handler
for (i = 0; i < tableLength; ++i)
Expand Down

0 comments on commit 54fa00e

Please sign in to comment.