--- a/gameServer/Actions.hs Thu Jul 26 21:58:25 2012 +0400
+++ b/gameServer/Actions.hs Mon Aug 06 00:40:26 2012 +0400
@@ -146,9 +146,14 @@
io $
infoM "Clients" (show ci ++ " quits: " ++ B.unpack msg)
- processAction $ AnswerClients [chan] ["BYE", msg]
when loggedIn $ processAction $ AnswerClients clientsChans ["LOBBY:LEFT", clNick, msg]
+ mapM processAction
+ [
+ AnswerClients [chan] ["BYE", msg]
+ , ModifyClient (\c -> c{logonPassed = False}) -- this will effectively hide client from others while he isn't deleted from list
+ ]
+
s <- get
put $! s{removedClients = ci `Set.insert` removedClients s}
@@ -418,11 +423,22 @@
processAction JoinLobby = do
chan <- client's sendChan
clientNick <- client's nick
- (lobbyNicks, clientsChans) <- liftM (unzip . Prelude.map (nick &&& sendChan) . Prelude.filter logonPassed) $! allClientsS
- mapM_ processAction $
- AnswerClients clientsChans ["LOBBY:JOINED", clientNick]
- : AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)
- : [ModifyClient (\cl -> cl{logonPassed = True}), SendServerMessage]
+ isAuthenticated <- liftM (not . B.null) $ client's webPassword
+ isAdmin <- client's isAdministrator
+ loggedInClients <- liftM (Prelude.filter logonPassed) $! allClientsS
+ let (lobbyNicks, clientsChans) = unzip . L.map (nick &&& sendChan) $ loggedInClients
+ let authenticatedNicks = L.map nick . L.filter (not . B.null . webPassword) $ loggedInClients
+ let adminsNicks = L.map nick . L.filter isAdministrator $ loggedInClients
+ let clFlags = B.concat . L.concat $ [["u" | isAuthenticated], ["a" | isAdmin]]
+ mapM_ processAction . concat $ [
+ [AnswerClients clientsChans ["LOBBY:JOINED", clientNick]]
+ , [AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)]
+ , [AnswerClients [chan] ("CLIENT_FLAGS" : "+u" : authenticatedNicks) | not $ null authenticatedNicks]
+ , [AnswerClients [chan] ("CLIENT_FLAGS" : "+a" : adminsNicks) | not $ null adminsNicks]
+ , [AnswerClients (chan : clientsChans) ["CLIENT_FLAGS", B.concat["+" , clFlags], clientNick] | not $ B.null clFlags]
+ , [ModifyClient (\cl -> cl{logonPassed = True})]
+ , [SendServerMessage]
+ ]
processAction (KickClient kickId) = do
@@ -522,9 +538,11 @@
where
kickTimeouted rnc ci = do
pq <- io $ client'sM rnc pingsQueue ci
- when (pq > 0) $
+ when (pq > 0) $ do
withStateT (\as -> as{clientIndex = Just ci}) $
processAction (ByeClient "Ping timeout")
+ when (pq > 1) $
+ processAction $ DeleteClient ci -- smth went wrong with client io threads, issue DeleteClient here
processAction StatsAction = do