コード例 #1
0
        public static void ProcessGroupKick(string targetPlayerName, Socket connection)
        {
            Player thisPlayer   = GetPlayer(connection);
            bool   isGameServer = GameServers.Contains(connection);

            // if initiating party is player and player is not in group, etc...
            if (!isGameServer && (thisPlayer == null || thisPlayer.Group == null || thisPlayer.Group.Leader != thisPlayer))
            {
                return;
            }

            //find the player that we want to kick
            Player targetPlayer = Players.SingleOrDefault(x => x.Name == targetPlayerName);

            if (targetPlayer == null || targetPlayer.Group == null || (!isGameServer && (targetPlayer.Group != thisPlayer.Group)))
            {
                return;
            }

            Console.WriteLine($"Kicking from group: {targetPlayerName}");

            if (isGameServer) //kick issued by server (because of disconnect), kick after a delay of X seconds
            {
                CreatePendingKick(targetPlayer);
            }
            else
            {
                RemoveFromGroup(targetPlayer); //kick issued by group leader, kick immediately
                //notify the player that they were kicked from the clan
                byte[] message = MergeByteArrays(ToBytes(Command.GroupKick));
                targetPlayer.SendOrKick(message);
            }
        }
コード例 #2
0
ファイル: Logic.cs プロジェクト: Amaratsu/COOServer
 public static void KickConnection(Socket connection)
 {
     if (GameServers.Contains(connection))
     {
         KickServer(connection);
     }
     else
     {
         KickPlayer(GetPlayer(connection));
     }
 }