private CServerLobby Create_Lobby( EPersistenceID creator_id, CLobbyConfig config ) { ELobbyID lobby_id = Allocate_Lobby_ID(); CServerLobby lobby = new CServerLobby( lobby_id, config, creator_id ); m_Lobbies.Add( lobby_id, lobby ); m_LobbiesByCreator.Add( creator_id, lobby_id ); return lobby; }
private void Join_Lobby_Aux( EPersistenceID player_id, CServerLobby lobby, EMessageRequestID request_id, string password ) { CConnectedPlayer player = CConnectedPlayerManager.Instance.Get_Active_Player_By_Persistence_ID( player_id ); if ( player == null ) { throw new CApplicationException( "Processing a join request by an inactive player" ); } if ( !player.State_Allows_Operation( EConnectedPlayerOperation.Join_Lobby ) ) { On_Join_Lobby_Failure( ELobbyID.Invalid, player_id, request_id, EJoinLobbyFailureReason.Invalid_State_To_Join ); return; } EJoinLobbyFailureReason join_check_result = lobby.Check_Join( player_id ); if ( join_check_result != EJoinLobbyFailureReason.None ) { On_Join_Lobby_Failure( lobby.ID, player_id, request_id, join_check_result ); return; } CServerLobbyBrowserManager.Instance.Stop_Browsing( player_id ); lobby.Add_Member( player_id ); On_Join_Lobby_Success( player_id, request_id, lobby.ID ); if ( lobby.ChatChannel != EChannelID.Invalid ) { CAsyncBackendOperations.Player_Join_Lobby_Channel( player.PersistenceID, lobby.ID, lobby.ChatChannel ); } }
private void Notify_Browser_Of_Potential_Lobby( CServerLobbyBrowser browser, CServerLobby lobby ) { EPersistenceID browser_id = browser.PlayerID; ELobbyID lobby_id = lobby.ID; if ( browser.WatchedLobbyCount == MAX_WATCHED_LOBBIES && browser.FirstLobby > lobby_id ) { return; } if ( browser.Is_Watching ( lobby_id ) ) { return; } if ( browser.WatchedLobbyCount == MAX_WATCHED_LOBBIES && browser.LastLobby < lobby_id ) { return; } if ( lobby.Matches_Browse_Criteria( browser.BrowseCriteria ) ) { if ( browser.JoinFirstAvailable ) { CServerLobbyManager.Instance.Join_Lobby_By_Browsing( browser_id, lobby_id ); return; } ELobbyID removed_lobby = ELobbyID.Invalid; if ( browser.WatchedLobbyCount == MAX_WATCHED_LOBBIES ) { removed_lobby = browser.LastLobby; Remove_As_Watcher( removed_lobby, browser_id ); } Insert_As_Watcher( lobby_id, browser_id ); CServerMessageRouter.Send_Message_To_Player( new CBrowseLobbyAddRemoveMessage( lobby.Create_Summary(), removed_lobby ), browser_id ); } }