gameServer/Actions.hs
changeset 1879 bb114339eb4e
parent 1866 36aa0ca6e8af
child 1921 2a09f7f786a0
--- a/gameServer/Actions.hs	Mon Mar 09 20:23:04 2009 +0000
+++ b/gameServer/Actions.hs	Mon Mar 09 20:47:17 2009 +0000
@@ -28,6 +28,8 @@
 	| Warning String
 	| ByeClient String
 	| KickClient Int -- clID
+	| KickRoomClient Int -- clID
+	| RemoveClientTeams Int -- clID
 	| BanClient String -- nick
 	| ModifyClient (ClientInfo -> ClientInfo)
 	| ModifyRoom (RoomInfo -> RoomInfo)
@@ -54,7 +56,8 @@
 
 
 processAction (clID, serverInfo, clients, rooms) (AnswerAllOthers msg) = do
-	mapM_ (\id -> writeChan (sendChan $ clients ! id) msg) $ Prelude.filter (/= clID) (keys clients)
+	mapM_ (\id -> writeChan (sendChan $ clients ! id) msg) $
+		Prelude.filter (\id' -> (id' /= clID) && (logonPassed $ clients ! id')) (keys clients)
 	return (clID, serverInfo, clients, rooms)
 
 
@@ -285,4 +288,19 @@
 
 
 processAction (clID, serverInfo, clients, rooms) (KickClient kickID) = do
-	liftM2 replaceID (return clID) (processAction (kickID, serverInfo, clients, rooms) $ ByeClient "Kicked")
\ No newline at end of file
+	liftM2 replaceID (return clID) (processAction (kickID, serverInfo, clients, rooms) $ ByeClient "Kicked")
+
+
+processAction (clID, serverInfo, clients, rooms) (KickRoomClient kickID) = do
+	writeChan (sendChan $ clients ! kickID) ["KICKED"]
+	liftM2 replaceID (return clID) (processAction (kickID, serverInfo, clients, rooms) $ RoomRemoveThisClient)
+
+
+processAction (clID, serverInfo, clients, rooms) (RemoveClientTeams teamsClID) = do
+	liftM2 replaceID (return clID) $
+		foldM processAction (teamsClID, serverInfo, clients, rooms) $ removeTeamsActions
+	where
+		client = clients ! teamsClID
+		room = rooms ! (roomID client)
+		teamsToRemove = Prelude.filter (\t -> teamowner t == nick client) $ teams room
+		removeTeamsActions = Prelude.map (RemoveTeam . teamname) teamsToRemove