Fix match making.

"gameLocation" is actually "gameAddress".
This commit is contained in:
HikikoMarmy
2025-04-16 22:54:28 +01:00
parent 247cd434e5
commit b4dfb0666c
6 changed files with 20 additions and 22 deletions

View File

@@ -12,7 +12,7 @@ GameSession::GameSession()
m_currentPlayers = 0;
m_maximumPlayers = 0;
m_gameLocation.clear();
m_gameAddress.clear();
m_gameName.clear();
m_ownerName.clear();
m_gameData.clear();
@@ -31,7 +31,7 @@ GameSession::~GameSession()
m_currentPlayers = 0;
m_maximumPlayers = 0;
m_gameLocation.clear();
m_gameAddress.clear();
m_gameName.clear();
m_ownerName.clear();
m_gameData.clear();

View File

@@ -21,7 +21,7 @@ public:
int32_t m_gameIndex;
std::wstring m_gameLocation;
std::wstring m_gameAddress;
std::wstring m_gameName;
std::wstring m_ownerName;

View File

@@ -1,4 +1,7 @@
#include "../global_define.h"
#include <format>
#include "GameSessionManager.h"
#include "../Lobby Server/Event/NotifyClientDiscovered.h"
@@ -59,15 +62,13 @@ void GameSessionManager::OnDisconnectUser( sptr_user user )
}
}
bool GameSessionManager::CreatePublicGameSession( sptr_user owner, std::wstring gameInfo )
bool GameSessionManager::CreatePublicGameSession( sptr_user owner, std::wstring gameName )
{
auto new_session = std::make_shared< GameSession >();
auto [gameName, gameLocation] = ParseInfoData( gameInfo );
new_session->m_type = GameSession::GameType::Public;
new_session->m_gameIndex = m_gameIndex;
new_session->m_gameLocation = gameLocation;
new_session->m_gameAddress = L"";
new_session->m_gameName = gameName;
new_session->m_minimumLevel = 1;
new_session->m_maximumLevel = 9999;
@@ -88,10 +89,8 @@ bool GameSessionManager::CreatePublicGameSession( sptr_user owner, std::wstring
return true;
}
bool GameSessionManager::CreatePrivateGameSession( sptr_user owner, std::wstring gameInfo )
bool GameSessionManager::CreatePrivateGameSession( sptr_user owner, std::wstring gameName )
{
auto [gameName, gameLocation] = ParseInfoData( gameInfo );
// Check if the game name or host session id is already in use
for( auto &gameSession : m_gameSessionList )
{
@@ -109,7 +108,7 @@ bool GameSessionManager::CreatePrivateGameSession( sptr_user owner, std::wstring
new_session->m_type = GameSession::GameType::Private;
new_session->m_gameIndex = m_gameIndex;
new_session->m_gameLocation = gameLocation;
new_session->m_gameAddress = L"";
new_session->m_gameName = gameName;
new_session->m_minimumLevel = 1;
new_session->m_maximumLevel = 9999;
@@ -209,10 +208,14 @@ bool GameSessionManager::RequestOpen( sptr_user user )
return false;
}
session->m_gameAddress = std::format( L"{}:{}",
std::wstring( user->m_discoveryAddr.begin(), user->m_discoveryAddr.end() ),
user->m_discoveryPort );
session->m_state = GameSession::GameState::Open;
// Tell the host its own address.
NotifyGameDiscovered msg( user->m_discoveryAddr, 3000 );// user->m_discoveryPort);
NotifyGameDiscovered msg( user->m_discoveryAddr, user->m_discoveryPort);
user->sock->send( msg );
Log::Info( "Game Session [%d] Discoverable on %s", gameId, user->m_discoveryAddr.c_str() );
@@ -294,11 +297,11 @@ bool GameSessionManager::RequestJoin( sptr_user join_user )
join_user->m_isHost = false;
// First, notify the host that a client is trying to connect.
NotifyClientRequestConnect msgNotifyReqConnect( join_user->m_discoveryAddr, 3000 );// join_user->m_discoveryPort);
NotifyClientRequestConnect msgNotifyReqConnect( join_user->m_discoveryAddr, join_user->m_discoveryPort);
host_user->sock->send( msgNotifyReqConnect );
// Then, tell the joiner its own address.
NotifyClientDiscovered msgClientDiscovered( join_user->m_discoveryAddr, 3000 );// host_user->m_discoveryPort);
NotifyClientDiscovered msgClientDiscovered( join_user->m_discoveryAddr,host_user->m_discoveryPort);
join_user->sock->send( msgClientDiscovered );
Log::Info( "User [%S] Joining game session... [%d]", join_user->m_sessionId.c_str(), gameId );

View File

@@ -32,8 +32,8 @@ public:
void OnDisconnectUser( sptr_user user );
bool CreatePublicGameSession( sptr_user user, std::wstring gameInfo );
bool CreatePrivateGameSession( sptr_user user, std::wstring gameInfo );
bool CreatePublicGameSession( sptr_user user, std::wstring gameName );
bool CreatePrivateGameSession( sptr_user user, std::wstring gameName );
bool ForceTerminateGame( const int32_t gameId );
sptr_game_session FindGame( const int32_t gameId );
sptr_game_session FindGame( const std::wstring &gameName );

View File

@@ -1,8 +1,6 @@
#include "../../global_define.h"
#include "RequestCreatePublicGame.h"
#include "NotifyGameDiscovered.h"
#include "NotifyClientDiscovered.h"
// Request
void RequestCreatePublicGame::Deserialize( sptr_byte_stream stream )

View File

@@ -39,9 +39,6 @@ sptr_generic_response RequestMatchGame::ProcessRequest( sptr_user user, sptr_byt
{
Deserialize( stream );
Log::Debug( "RequestMatchGame : %S", m_sessionId.c_str() );
Log::Packet( stream->data, stream->data.size(), false );
return std::make_shared< ResultMatchGame >( this );
}
@@ -62,7 +59,7 @@ ByteStream &ResultMatchGame::Serialize()
m_stream.write_u32( publicGameCount );
{
for( auto &game : publicGameList )
m_stream.write_utf16( game->m_gameLocation );
m_stream.write_utf16( game->m_gameAddress );
}
m_stream.write_u32( publicGameCount );