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:
61
Source/Network/Event/RequestCancelGame_RTA.cpp
Normal file
61
Source/Network/Event/RequestCancelGame_RTA.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "Network/Event/RequestCancelGame_RTA.hpp"
|
||||
|
||||
#include "Game/RealmUserManager.hpp"
|
||||
#include "Game/GameSessionManager.hpp"
|
||||
#include "Game/ChatRoomManager.hpp"
|
||||
#include "logging.hpp"
|
||||
|
||||
void RequestCancelGame_RTA::Deserialize( sptr_byte_stream stream )
|
||||
{
|
||||
DeserializeHeader( stream );
|
||||
|
||||
m_sessionId = stream->read_encrypted_utf16();
|
||||
}
|
||||
|
||||
sptr_generic_response RequestCancelGame_RTA::ProcessRequest( sptr_socket socket, sptr_byte_stream stream )
|
||||
{
|
||||
Deserialize( stream );
|
||||
|
||||
auto user = UserManager::Get().FindUserBySocket( socket );
|
||||
if( user == nullptr )
|
||||
{
|
||||
Log::Error( "User not found! [{}]", m_sessionId );
|
||||
return std::make_shared< ResultCancelGame_RTA >( this );
|
||||
}
|
||||
|
||||
if( user->m_gameType != RealmGameType::RETURN_TO_ARMS )
|
||||
{
|
||||
return std::make_shared< ResultCancelGame_RTA >( this );
|
||||
}
|
||||
|
||||
const auto &gameSession = GameSessionManager::Get().FindGame( user->m_gameId, user->m_gameType );
|
||||
if( gameSession == nullptr )
|
||||
{
|
||||
Log::Error( "Game session not found for user [{}]", user->m_sessionId );
|
||||
return std::make_shared< ResultCancelGame_RTA >( this );
|
||||
}
|
||||
|
||||
if( !GameSessionManager::Get().RequestCancel( user ) )
|
||||
{
|
||||
Log::Error( "Failed to cancel game session for user [{}]", user->m_sessionId );
|
||||
}
|
||||
|
||||
if( !ChatRoomManager::Get().LeaveRoom( user, user->m_privateRoomId ) )
|
||||
{
|
||||
Log::Error( "Failed to leave private chat room for user [{}]", user->m_username );
|
||||
}
|
||||
|
||||
return std::make_shared< ResultCancelGame_RTA >( this );
|
||||
}
|
||||
|
||||
ResultCancelGame_RTA::ResultCancelGame_RTA( GenericRequest *request ) : GenericResponse( *request )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ResultCancelGame_RTA::Serialize( ByteBuffer &out ) const
|
||||
{
|
||||
out.write_u16( m_packetId );
|
||||
out.write_u32( m_trackId );
|
||||
out.write_u32( 0 );
|
||||
}
|
||||
Reference in New Issue
Block a user