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:
45
Source/Network/Event/RequestAppendCharacterData.cpp
Normal file
45
Source/Network/Event/RequestAppendCharacterData.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "Network/Event/RequestAppendCharacterData.hpp"
|
||||
|
||||
#include "Game/CharacterSaveManager.hpp"
|
||||
#include "Game/RealmUserManager.hpp"
|
||||
#include "Game/RealmUser.hpp"
|
||||
#include "Database/Database.hpp"
|
||||
#include "logging.hpp"
|
||||
|
||||
void RequestAppendCharacterData::Deserialize( sptr_byte_stream stream )
|
||||
{
|
||||
DeserializeHeader( stream );
|
||||
|
||||
auto sessionId = stream->read_encrypted_utf16();
|
||||
|
||||
auto length = stream->read_u32();
|
||||
m_data = stream->read_bytes( length );
|
||||
m_endOfData = stream->read_u32();
|
||||
}
|
||||
|
||||
sptr_generic_response RequestAppendCharacterData::ProcessRequest( sptr_socket socket, sptr_byte_stream stream )
|
||||
{
|
||||
Deserialize( stream );
|
||||
|
||||
auto user = UserManager::Get().FindUserBySocket( socket );
|
||||
if( user == nullptr )
|
||||
{
|
||||
return std::make_shared< ResultAppendCharacterData >( this, FATAL_ERROR );
|
||||
}
|
||||
|
||||
CharacterSaveManager::Get().AppendSaveData( user->m_sessionId, m_data, m_endOfData );
|
||||
|
||||
return std::make_shared< ResultAppendCharacterData >( this, SUCCESS );
|
||||
}
|
||||
|
||||
ResultAppendCharacterData::ResultAppendCharacterData( GenericRequest *request, int32_t reply ) : GenericResponse( *request )
|
||||
{
|
||||
m_reply = reply;
|
||||
}
|
||||
|
||||
void ResultAppendCharacterData::Serialize( ByteBuffer &out ) const
|
||||
{
|
||||
out.write_u16( m_packetId );
|
||||
out.write_u32( m_trackId );
|
||||
out.write_u32( m_reply );
|
||||
}
|
||||
Reference in New Issue
Block a user