Store the game type in the socket for gateways

This commit is contained in:
HikikoMarmy
2025-06-15 23:07:52 +01:00
parent cb7a3f0825
commit fffbc95b87
4 changed files with 14 additions and 17 deletions

View File

@@ -15,27 +15,21 @@ sptr_generic_response RequestGetServerAddress::ProcessRequest( sptr_socket socke
{
Deserialize( stream );
auto user = RealmUserManager::Get().FindUserBySocket( socket );
if( user == nullptr )
if( socket->gameType == RealmGameType::RETURN_TO_ARMS )
{
return std::make_shared< ResultGetServerAddress >( this, "", 0, RealmGameType::RETURN_TO_ARMS );
}
if (user->m_gameType == RealmGameType::RETURN_TO_ARMS)
{
return std::make_shared< ResultGetServerAddress >(this, Config::service_ip, Config::rta_lobby_port, user->m_gameType);
return std::make_shared< ResultGetServerAddress >( this, Config::service_ip, Config::rta_lobby_port, socket->gameType );
}
else
{
return std::make_shared< ResultGetServerAddress >(this, Config::service_ip, Config::con_lobby_port, user->m_gameType);
return std::make_shared< ResultGetServerAddress >( this, Config::service_ip, Config::con_lobby_port, socket->gameType );
}
}
ResultGetServerAddress::ResultGetServerAddress( GenericRequest *request, std::string ip, int32_t port, RealmGameType clientType ) : GenericResponse( *request )
ResultGetServerAddress::ResultGetServerAddress( GenericRequest *request, std::string ip, int32_t port, RealmGameType gameType ) : GenericResponse( *request )
{
m_ip = ip;
m_port = port;
m_clientType = clientType;
m_gameType = gameType;
}
ByteBuffer &ResultGetServerAddress::Serialize()
@@ -44,7 +38,7 @@ ByteBuffer &ResultGetServerAddress::Serialize()
m_stream.write_u32( m_trackId );
m_stream.write_u32( 0 );
if( m_clientType == RealmGameType::RETURN_TO_ARMS )
if( m_gameType == RealmGameType::RETURN_TO_ARMS )
m_stream.write_utf8( m_ip );
else
m_stream.write_sz_utf8( m_ip );

View File

@@ -22,7 +22,7 @@ class ResultGetServerAddress : public GenericResponse {
public:
std::string m_ip;
int32_t m_port;
RealmGameType m_clientType;
RealmGameType m_gameType;
ResultGetServerAddress( GenericRequest *request, std::string ip, int32_t port, RealmGameType clientType );
ByteBuffer &Serialize();

View File

@@ -8,6 +8,7 @@
#include "GenericNetRequest.h"
#include "GenericNetResponse.h"
#include "GenericNetMessage.h"
#include "../Common/Constant.h"
class RealmSocket
{
@@ -46,6 +47,7 @@ public:
sockaddr_in local_addr;
sockaddr_in remote_addr;
RealmGameType gameType;
std::string remote_ip;
uint32_t remote_port;
uint32_t last_write_position;