Ejemplo n.º 1
0
 public void KickPlayer(NetworkCommunicator peerToKick, bool banPlayer)
 {
     if (GameNetwork.IsServer || GameNetwork.IsDedicatedServer)
     {
         if (peerToKick.IsMine)
         {
             return;
         }
         MissionPeer component = peerToKick.GetComponent <MissionPeer>();
         if (component == null)
         {
             return;
         }
         if (banPlayer)
         {
             if (GameNetwork.IsClient)
             {
                 BannedPlayerManagerCustomGameClient.AddBannedPlayer(component.Peer.Id, GameNetwork.IsDedicatedServer ? -1 : Environment.TickCount + 600000);
             }
             else if (GameNetwork.IsDedicatedServer)
             {
                 BannedPlayerManagerCustomGameServer.AddBannedPlayer(component.Peer.Id, component.GetNetworkPeer().UserName, GameNetwork.IsDedicatedServer ? -1 : Environment.TickCount + 600000);
             }
         }
         if (GameNetwork.IsDedicatedServer)
         {
             throw new NotImplementedException();
         }
         NetworkMain.GameClient.KickPlayer(component.Peer.Id, banPlayer);
     }
     else
     {
         if (!GameNetwork.IsClient)
         {
             return;
         }
         GameNetwork.BeginModuleEventAsClient();
         GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromClient.KickPlayer(peerToKick, banPlayer));
         GameNetwork.EndModuleEventAsClient();
     }
 }
Ejemplo n.º 2
0
 public void EndPoll()
 {
     if (this._runningPollAcceptedCount >= (this._runningPoll is MultiplayerPollComponent.KickPlayer || this._runningPoll is MultiplayerPollComponent.BanPlayer ? (int)Math.Ceiling(((double)GameNetwork.NetworkPeerCount - 1.0) / 2.0) : (int)Math.Ceiling((double)GameNetwork.NetworkPeerCount / 2.0)))
     {
         if (this._runningPoll is MultiplayerPollComponent.KickPlayer)
         {
             MissionPeer component = ((MultiplayerPollComponent.KickPlayer) this._runningPoll).playerPeer.GetComponent <MissionPeer>();
             if (component != null)
             {
                 NetworkCommunicator networkPeer    = component.GetNetworkPeer();
                 DisconnectInfo      disconnectInfo = networkPeer.PlayerConnectionInfo.GetParameter <DisconnectInfo>("DisconnectInfo") ?? new DisconnectInfo();
                 disconnectInfo.Type = DisconnectType.KickedByPoll;
                 networkPeer.PlayerConnectionInfo.AddParameter("DisconnectInfo", (object)disconnectInfo);
                 GameNetwork.AddNetworkPeerToDisconnectAsServer(networkPeer);
                 if (GameNetwork.IsDedicatedServer)
                 {
                     throw new NotImplementedException();
                 }
                 NetworkMain.GameClient.KickPlayer(component.Peer.Id, false);
             }
         }
         else if (this._runningPoll is MultiplayerPollComponent.BanPlayer)
         {
             MissionPeer component = ((MultiplayerPollComponent.BanPlayer) this._runningPoll).playerPeer.GetComponent <MissionPeer>();
             if (component != null)
             {
                 NetworkCommunicator networkPeer    = component.GetNetworkPeer();
                 DisconnectInfo      disconnectInfo = networkPeer.PlayerConnectionInfo.GetParameter <DisconnectInfo>("DisconnectInfo") ?? new DisconnectInfo();
                 disconnectInfo.Type = DisconnectType.BannedByPoll;
                 networkPeer.PlayerConnectionInfo.AddParameter("DisconnectInfo", (object)disconnectInfo);
                 GameNetwork.AddNetworkPeerToDisconnectAsServer(networkPeer);
                 if (GameNetwork.IsClient)
                 {
                     BannedPlayerManagerCustomGameClient.AddBannedPlayer(component.Peer.Id, GameNetwork.IsDedicatedServer ? -1 : Environment.TickCount + 600000);
                 }
                 else if (GameNetwork.IsDedicatedServer)
                 {
                     BannedPlayerManagerCustomGameServer.AddBannedPlayer(component.Peer.Id, component.GetPeer().UserName, GameNetwork.IsDedicatedServer ? -1 : Environment.TickCount + 600000);
                 }
                 if (GameNetwork.IsDedicatedServer)
                 {
                     throw new NotImplementedException();
                 }
                 NetworkMain.GameClient.KickPlayer(component.Peer.Id, true);
             }
         }
         else if (this._runningPoll is MultiplayerPollComponent.ChangeGame)
         {
             MultiplayerPollComponent.ChangeGame             runningPoll = (MultiplayerPollComponent.ChangeGame) this._runningPoll;
             MultiplayerOptions.MultiplayerOptionsAccessMode mode        = MultiplayerOptions.MultiplayerOptionsAccessMode.NextMapOptions;
             MultiplayerOptions.OptionType.GameType.SetValue(runningPoll.GameType, mode);
             MultiplayerOptions.Instance.OnGameTypeChanged(mode);
             MultiplayerOptions.OptionType.Map.SetValue(runningPoll.MapName, mode);
             this._missionLobbyComponent.SetStateEndingAsServer();
         }
     }
     this._runningPoll              = (object)null;
     this._runningPollStartTime     = new int?();
     this._runningPollAcceptedCount = 0;
     this._runningPollRejectedCount = 0;
     this._runningPollVoted.Clear();
 }