Esempio n. 1
0
 //Cleans up any dead connections, removing their character from the world, and telling other clients to do the same on their end
 public static void CleanDeadClients(Simulation World)
 {
     foreach (ClientConnection DeadClient in ClientSubsetFinder.GetDeadClients())
     {
         //Backup / Remove from World and alert other clients about any ingame dead clients
         if (DeadClient.Character.InGame)
         {
             CharactersDatabase.SaveCharacterData(DeadClient.Character);
             DeadClient.Character.RemoveBody(World);
             foreach (ClientConnection LivingClient in ClientSubsetFinder.GetInGameLivingClientsExceptFor(DeadClient.ClientID))
             {
                 PlayerManagementPacketSender.SendRemoveRemotePlayer(LivingClient.ClientID, DeadClient.Character.Name, DeadClient.Character.IsAlive);
             }
         }
         ActiveConnections.Remove(DeadClient.ClientID);
     }
 }
Esempio n. 2
0
        //Tries using the command arguments for performing a player kick
        private void TryKickPlayer(string[] Input)
        {
            //Get the characters name
            string CharacterName = Input[1];

            //Make sure the character exists
            if (!CharactersDatabase.DoesCharacterExist(CharacterName))
            {
                MessageLog.Print("That character doesnt exist, cant kick them.");
                return;
            }

            //Get the client who this character belongs to
            ClientConnection Client = ClientSubsetFinder.GetClientUsingCharacter(CharacterName);

            //If the client couldnt be found then the character isnt logged in currently
            if (Client == null)
            {
                MessageLog.Print("That character is not in the game right now, cant kick them.");
                return;
            }

            //Show that the player is being kicked
            MessageLog.Print("Kicking " + CharacterName + " from the game...");

            //Tell the client that they have been kicked from the game and mark them to be cleaned up from the game
            SystemPacketSender.SendKickedFromServer(Client.ClientID);
            Client.ConnectionDead = true;

            //Tell everyone else to remove the client from their games
            List <ClientConnection> OtherClients = ClientSubsetFinder.GetInGameClientsExceptFor(Client.ClientID);

            foreach (ClientConnection OtherClient in OtherClients)
            {
                PlayerManagementPacketSender.SendRemoveRemotePlayer(OtherClient.ClientID, Client.Character.Name, Client.Character.IsAlive);
            }
        }