Send the correct game ID when joining private rooms.

This commit is contained in:
HikikoMarmy
2025-04-14 19:07:20 +01:00
parent 665a114d71
commit 2fcc3b5800
2 changed files with 17 additions and 6 deletions

View File

@@ -33,15 +33,24 @@ sptr_generic_response RequestGetGame::ProcessRequest( sptr_user user, sptr_byte_
return std::make_shared< ResultGetGame >( this, TIMEOUT ); return std::make_shared< ResultGetGame >( this, TIMEOUT );
} }
auto host_user = session->m_owner.lock();
if( host_user == nullptr )
{
Log::Error( "Game session owner not found! [%S]", m_gameName.c_str() );
return std::make_shared< ResultGetGame >( this, TIMEOUT );
}
user->m_isHost = false; user->m_isHost = false;
user->m_gameId = session->m_gameIndex; user->m_gameId = session->m_gameIndex;
return std::make_shared< ResultGetGame >( this, SUCCESS ); return std::make_shared< ResultGetGame >( this, SUCCESS, session->m_gameIndex );
} }
ResultGetGame::ResultGetGame( GenericRequest *request, int32_t reply ) : GenericResponse( *request ) ResultGetGame::ResultGetGame( GenericRequest *request, int32_t reply, int32_t gameId ) : GenericResponse( *request )
{ {
m_reply = reply; m_reply = reply;
m_gameId = gameId;
} }
ByteStream &ResultGetGame::Serialize() ByteStream &ResultGetGame::Serialize()
@@ -50,9 +59,11 @@ ByteStream &ResultGetGame::Serialize()
m_stream.write_u32( m_requestId ); m_stream.write_u32( m_requestId );
m_stream.write_u32( m_reply ); m_stream.write_u32( m_reply );
// TODO: These may come in from the UpdateGameData event
m_stream.write_utf16( L"Kelethin" ); m_stream.write_utf16( L"Kelethin" );
m_stream.write_utf16( L"OwnerName" ); m_stream.write_utf16( L"OwnerName" );
m_stream.write_u32( 0 );
m_stream.write_u32( m_gameId );
return m_stream; return m_stream;
} }

View File

@@ -1,7 +1,6 @@
#pragma once #pragma once
class RequestGetGame : public GenericRequest class RequestGetGame : public GenericRequest {
{
private: private:
std::wstring m_sessionId; std::wstring m_sessionId;
std::wstring m_gameName; std::wstring m_gameName;
@@ -24,8 +23,9 @@ public:
class ResultGetGame : public GenericResponse { class ResultGetGame : public GenericResponse {
private: private:
int32_t m_reply; int32_t m_reply;
int32_t m_gameId;
public: public:
ResultGetGame( GenericRequest *request, int32_t reply ); ResultGetGame( GenericRequest *request, int32_t reply, int32_t gameId = 0 );
ByteStream &Serialize(); ByteStream &Serialize();
}; };