mirror of
https://github.com/HikikoMarmy/Champions-Reborn-Server.git
synced 2026-04-05 08:59:54 -03:00
Reorganized and cleaned up the solution.
This commit is contained in:
93
Source/Network/Event/RequestMatchGame_RTA.cpp
Normal file
93
Source/Network/Event/RequestMatchGame_RTA.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
#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 );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user