mirror of
https://github.com/HikikoMarmy/Champions-Reborn-Server.git
synced 2026-04-05 00:49:48 -03:00
94 lines
2.3 KiB
C++
94 lines
2.3 KiB
C++
#include "Network/Event/RequestMatchGame_RTA.hpp"
|
|
|
|
#include "Game/RealmUserManager.hpp"
|
|
#include "Game/GameSessionManager.hpp"
|
|
#include "logging.hpp"
|
|
|
|
void RequestMatchGame_RTA::Deserialize( sptr_byte_stream stream )
|
|
{
|
|
DeserializeHeader( stream );
|
|
}
|
|
|
|
sptr_generic_response RequestMatchGame_RTA::ProcessRequest( sptr_socket socket, sptr_byte_stream stream )
|
|
{
|
|
Deserialize( stream );
|
|
|
|
auto user = UserManager::Get().FindUserBySocket( socket );
|
|
if( user == nullptr )
|
|
{
|
|
UserManager::Get().Disconnect( socket, "User not found!" );
|
|
return std::make_shared< ResultMatchGame_RTA >( this, "" );
|
|
}
|
|
|
|
if( !user->m_isLoggedIn )
|
|
{
|
|
UserManager::Get().Disconnect( user, "User is not logged in!" );
|
|
return std::make_shared< ResultMatchGame_RTA >( this, "" );
|
|
}
|
|
|
|
return std::make_shared< ResultMatchGame_RTA >( this, socket->remote_ip );
|
|
}
|
|
|
|
ResultMatchGame_RTA::ResultMatchGame_RTA( GenericRequest *request, std::string userIp ) : GenericResponse( *request )
|
|
{
|
|
m_userIp = userIp;
|
|
}
|
|
|
|
void ResultMatchGame_RTA::Serialize( ByteBuffer &out ) const
|
|
{
|
|
out.write_u16( m_packetId );
|
|
out.write_u32( m_trackId );
|
|
out.write_u32( 0 );
|
|
|
|
const auto publicGameList = GameSessionManager::Get().GetAvailableGameSessionList( RealmGameType::RETURN_TO_ARMS );
|
|
const auto publicGameCount = static_cast< uint32_t >( publicGameList.size() );
|
|
|
|
out.write_u32( publicGameCount );
|
|
{
|
|
for( const auto &game : publicGameList )
|
|
out.write_utf16( Util::UTF8ToWide( game->m_gameData ) );
|
|
}
|
|
|
|
out.write_u32( publicGameCount );
|
|
{
|
|
for( const auto &game : publicGameList )
|
|
out.write_utf16( game->m_playerCount );
|
|
}
|
|
|
|
out.write_u32( publicGameCount );
|
|
{
|
|
for( const auto &game : publicGameList )
|
|
out.write_u32( game->m_gameId );
|
|
}
|
|
|
|
// Something about filtering.
|
|
out.write_u32( publicGameCount );
|
|
{
|
|
out.write_u32( 0 ); // Size
|
|
}
|
|
|
|
out.write_u32( publicGameCount );
|
|
{
|
|
for( const auto &game : publicGameList )
|
|
out.write_utf16( Util::UTF8ToWide( game->m_hostLocalAddr ) );
|
|
}
|
|
|
|
out.write_u32( publicGameCount );
|
|
{
|
|
for( const auto &game : publicGameList )
|
|
out.write_u32( game->m_hostLocalPort );
|
|
}
|
|
|
|
out.write_u32( publicGameCount );
|
|
{
|
|
for( const auto &game : publicGameList )
|
|
out.write_utf16( Util::UTF8ToWide( game->m_hostExternalAddr ) );
|
|
}
|
|
|
|
out.write_u32( publicGameCount );
|
|
{
|
|
for( const auto &game : publicGameList )
|
|
out.write_u32( game->m_hostNatPort );
|
|
}
|
|
}
|