mirror of
https://github.com/HikikoMarmy/Champions-Reborn-Server.git
synced 2026-04-05 00:49:48 -03:00
63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
#include "Network/Event/RequestGetRules.hpp"
|
|
|
|
#include "Game/RealmUserManager.hpp"
|
|
#include "Game/RealmUser.hpp"
|
|
#include "Common/Constant.hpp"
|
|
#include "logging.hpp"
|
|
|
|
void RequestGetRules::Deserialize( sptr_byte_stream stream )
|
|
{
|
|
DeserializeHeader( stream );
|
|
|
|
m_language = stream->read_sz_utf8();
|
|
}
|
|
|
|
sptr_generic_response RequestGetRules::ProcessRequest( sptr_socket socket, sptr_byte_stream stream )
|
|
{
|
|
Deserialize( stream );
|
|
|
|
auto user = UserManager::Get().FindUserBySocket( socket );
|
|
if( user == nullptr )
|
|
{
|
|
return std::make_shared< ResultGetRules >( this, L"" );
|
|
}
|
|
|
|
// TODO: Get rules/eula based on language
|
|
// and move it info a MOTD file.
|
|
std::wstring rules;
|
|
|
|
if( user->m_gameType == RealmGameType::RETURN_TO_ARMS )
|
|
{
|
|
rules = L"Welcome to the Champions Emulated Server!\n\n"
|
|
L"RETURN TO ARMS network support is currently a\n"
|
|
L"work in progress and can not guarantee stability.\n\n"
|
|
L"[IMPORTANT]:\n"
|
|
L"Please note that ONLINE character saves may be unstable.\n"
|
|
L"Use them at your own risk.\n";
|
|
}
|
|
else
|
|
{
|
|
rules = L"Welcome to the Champions Emulated Server!\n\n"
|
|
L"This server is currently in development\n"
|
|
L"and may not be fully functional.\n\n";
|
|
}
|
|
|
|
return std::make_shared< ResultGetRules >( this, rules );
|
|
}
|
|
|
|
ResultGetRules::ResultGetRules( GenericRequest *request, std::wstring rules ) : GenericResponse( *request )
|
|
{
|
|
m_rules = rules;
|
|
}
|
|
|
|
void ResultGetRules::Serialize( ByteBuffer &out ) const
|
|
{
|
|
out.write_u16( m_packetId );
|
|
out.write_u32( m_trackId );
|
|
out.write_u32( 0 );
|
|
|
|
out.write_utf16( m_rules );
|
|
|
|
|
|
}
|