gameServer/Actions.hs
changeset 7498 86984f6fa1b9
parent 7465 c2dcf97ca664
child 7521 093ea41051c5
equal deleted inserted replaced
7495:2592240b7b62 7498:86984f6fa1b9
   421 
   421 
   422 
   422 
   423 processAction JoinLobby = do
   423 processAction JoinLobby = do
   424     chan <- client's sendChan
   424     chan <- client's sendChan
   425     clientNick <- client's nick
   425     clientNick <- client's nick
   426     (lobbyNicks, clientsChans) <- liftM (unzip . Prelude.map (nick &&& sendChan) . Prelude.filter logonPassed) $! allClientsS
   426     isAuthenticated <- liftM (not . B.null) $ client's webPassword
   427     mapM_ processAction $
   427     isAdmin <- client's isAdministrator
   428         AnswerClients clientsChans ["LOBBY:JOINED", clientNick]
   428     loggedInClients <- liftM (Prelude.filter logonPassed) $! allClientsS
   429         : AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)
   429     let (lobbyNicks, clientsChans) = unzip . L.map (nick &&& sendChan) $ loggedInClients
   430         : [ModifyClient (\cl -> cl{logonPassed = True}), SendServerMessage]
   430     let authenticatedNicks = L.map nick . L.filter (not . B.null . webPassword) $ loggedInClients
       
   431     let adminsNicks = L.map nick . L.filter isAdministrator $ loggedInClients
       
   432     let clFlags = B.concat . L.concat $ [["u" | isAuthenticated], ["a" | isAdmin]]
       
   433     mapM_ processAction . concat $ [
       
   434         [AnswerClients clientsChans ["LOBBY:JOINED", clientNick]]
       
   435         , [AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)]
       
   436         , [AnswerClients [chan] ("CLIENT_FLAGS" : "+u" : authenticatedNicks) | not $ null authenticatedNicks]
       
   437         , [AnswerClients [chan] ("CLIENT_FLAGS" : "+a" : adminsNicks) | not $ null adminsNicks]
       
   438         , [AnswerClients (chan : clientsChans) ["CLIENT_FLAGS",  B.concat["+" , clFlags], clientNick] | not $ B.null clFlags]
       
   439         , [ModifyClient (\cl -> cl{logonPassed = True})]
       
   440         , [SendServerMessage]
       
   441         ]
   431 
   442 
   432 
   443 
   433 processAction (KickClient kickId) = do
   444 processAction (KickClient kickId) = do
   434     modify (\s -> s{clientIndex = Just kickId})
   445     modify (\s -> s{clientIndex = Just kickId})
   435     clHost <- client's host
   446     clHost <- client's host