//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); } }
//Tries using the command arguments for performing a server shutdown private void TryServerShutdown(string[] Input) { //Log what is happening here MessageLog.Print("Server shutting down..."); //Get a list of all ingame clients who are logged in and playing right now List <ClientConnection> ActiveClients = ClientSubsetFinder.GetInGameClients(); //Loop through all the active players and backup their data foreach (ClientConnection ActiveClient in ActiveClients) { CharactersDatabase.SaveCharacterData(ActiveClient.Character); } //Close and save the current log file MessageLog.Close(); //Close the application Program.ApplicationWindow.Close(); }