// Non-public interface private void Apply_Member_Moved_Operation( CLobbyMemberMovedOperation operation ) { Move_Member( operation.PlayerID, operation.MemberType, operation.MemberIndex ); }
private void Move_Player_In_Lobby( CMovePlayerInLobbyRequest request, EPersistenceID source_player ) { CConnectedPlayer player = CConnectedPlayerManager.Instance.Get_Player_By_Persistence_ID( source_player ); if ( player == null ) { throw new CApplicationException( "Processing a move request from an unknown player" ); } CLog.Log( ELoggingChannel.Lobby, ELogLevel.Medium, String.Format( "Player {0} in lobby {1} attempting to move player {2} to role={3},slot={4}.", CConnectedPlayerManager.Get_Player_Log_Name( source_player ), Get_Lobby_Log_Description( player.LobbyID ), CConnectedPlayerManager.Get_Player_Log_Name( request.PlayerID ), request.DestinationCategory.ToString(), request.DestinationIndex ) ); if ( player.LobbyID == ELobbyID.Invalid ) { CServerMessageRouter.Send_Message_To_Player( new CMovePlayerInLobbyResponse( request.RequestID, EMovePlayerInLobbyError.Not_In_A_Lobby ), source_player ); return; } CServerLobby lobby = Get_Lobby_By_Creator( source_player ); if ( lobby == null ) { CServerMessageRouter.Send_Message_To_Player( new CMovePlayerInLobbyResponse( request.RequestID, EMovePlayerInLobbyError.Not_Lobby_Creator ), source_player ); return; } if ( !lobby.State_Allows_Player_Operations() ) { CServerMessageRouter.Send_Message_To_Player( new CMovePlayerInLobbyResponse( request.RequestID, EMovePlayerInLobbyError.Lobby_Not_Ready ), source_player ); return; } bool valid_destination = false; switch ( request.DestinationCategory ) { case ELobbyMemberType.Player: valid_destination = request.DestinationIndex < CGameModeUtils.Player_Count_For_Game_Mode( lobby.GameMode ); break; case ELobbyMemberType.Observer: valid_destination = lobby.AllowObservers; break; default: break; } if ( !valid_destination ) { CServerMessageRouter.Send_Message_To_Player( new CMovePlayerInLobbyResponse( request.RequestID, EMovePlayerInLobbyError.Invalid_Move_Destination ), source_player ); return; } EPersistenceID destination_player = lobby.Get_Player_At( request.DestinationCategory, request.DestinationIndex ); if ( destination_player == request.PlayerID ) { CServerMessageRouter.Send_Message_To_Player( new CMovePlayerInLobbyResponse( request.RequestID, EMovePlayerInLobbyError.No_Change ), source_player ); return; } CServerMessageRouter.Send_Message_To_Player( new CMovePlayerInLobbyResponse( request.RequestID, EMovePlayerInLobbyError.None ), source_player ); if ( destination_player == EPersistenceID.Invalid ) { lobby.Move_Member( request.PlayerID, request.DestinationCategory, request.DestinationIndex ); CLobbyMemberMovedOperation op = new CLobbyMemberMovedOperation( request.PlayerID, request.DestinationCategory, request.DestinationIndex ); Send_Message_To_Members( lobby.ID, new CLobbyOperationMessage( op ) ); } else { lobby.Swap_Members( request.PlayerID, destination_player ); CLobbyMembersSwappedOperation op = new CLobbyMembersSwappedOperation( request.PlayerID, destination_player ); Send_Message_To_Members( lobby.ID, new CLobbyOperationMessage( op ) ); } }