gameServer/Actions.hs
changeset 8401 87410ae372f6
parent 8396 5123eac2f9d6
child 8403 fbc6e7602e05
equal deleted inserted replaced
8400:33ab77c0b486 8401:87410ae372f6
   424     uid <- client's clUID
   424     uid <- client's clUID
   425     -- allow multiple checker logins
   425     -- allow multiple checker logins
   426     haveSameNick <- liftM (not . null . tail . filter (\c -> (not $ isChecker c) && caseInsensitiveCompare (nick c) n)) allClientsS
   426     haveSameNick <- liftM (not . null . tail . filter (\c -> (not $ isChecker c) && caseInsensitiveCompare (nick c) n)) allClientsS
   427     if haveSameNick && (not checker) then
   427     if haveSameNick && (not checker) then
   428         if p < 38 then
   428         if p < 38 then
   429             processAction $ ByeClient "Nickname is already in use"
   429             processAction $ ByeClient $ loc "Nickname is already in use"
   430             else
   430             else
   431             processAction $ NoticeMessage NickAlreadyInUse
   431             processAction $ NoticeMessage NickAlreadyInUse
   432         else
   432         else
   433         do
   433         do
   434         db <- gets (dbQueries . serverInfo)
   434         db <- gets (dbQueries . serverInfo)
   457             processAction $ AnswerClients [chan] ["ADMIN_ACCESS"]
   457             processAction $ AnswerClients [chan] ["ADMIN_ACCESS"]
   458     where
   458     where
   459     isBanned = do
   459     isBanned = do
   460         processAction $ CheckBanned False
   460         processAction $ CheckBanned False
   461         liftM B.null $ client's nick
   461         liftM B.null $ client's nick
   462     checkerLogin _ False = processAction $ ByeClient "No checker rights"
   462     checkerLogin _ False = processAction $ ByeClient $ loc "No checker rights"
   463     checkerLogin p True = do
   463     checkerLogin p True = do
   464         wp <- client's webPassword
   464         wp <- client's webPassword
   465         processAction $
   465         processAction $
   466             if wp == p then ModifyClient $ \c -> c{logonPassed = True} else ByeClient "Authentication failed"
   466             if wp == p then ModifyClient $ \c -> c{logonPassed = True} else ByeClient $ loc "Authentication failed"
   467     playerLogin p a = do
   467     playerLogin p a = do
   468         chan <- client's sendChan
   468         chan <- client's sendChan
   469         mapM_ processAction [AnswerClients [chan] ["ASKPASSWORD"], ModifyClient (\c -> c{webPassword = p, isAdministrator = a})]
   469         mapM_ processAction [AnswerClients [chan] ["ASKPASSWORD"], ModifyClient (\c -> c{webPassword = p, isAdministrator = a})]
   470 
   470 
   471 processAction JoinLobby = do
   471 processAction JoinLobby = do
   492 processAction (KickClient kickId) = do
   492 processAction (KickClient kickId) = do
   493     modify (\s -> s{clientIndex = Just kickId})
   493     modify (\s -> s{clientIndex = Just kickId})
   494     clHost <- client's host
   494     clHost <- client's host
   495     currentTime <- io getCurrentTime
   495     currentTime <- io getCurrentTime
   496     mapM_ processAction [
   496     mapM_ processAction [
   497         AddIP2Bans clHost "60 seconds cooldown after kick" (addUTCTime 60 currentTime)
   497         AddIP2Bans clHost (loc "60 seconds cooldown after kick") (addUTCTime 60 currentTime)
   498         , ModifyClient (\c -> c{isKickedFromServer = True})
   498         , ModifyClient (\c -> c{isKickedFromServer = True})
   499         , ByeClient "Kicked"
   499         , ByeClient "Kicked"
   500         ]
   500         ]
   501 
   501 
   502 
   502 
   548 
   548 
   549 
   549 
   550 processAction (KickRoomClient kickId) = do
   550 processAction (KickRoomClient kickId) = do
   551     modify (\s -> s{clientIndex = Just kickId})
   551     modify (\s -> s{clientIndex = Just kickId})
   552     ch <- client's sendChan
   552     ch <- client's sendChan
   553     mapM_ processAction [AnswerClients [ch] ["KICKED"], MoveToLobby "kicked"]
   553     mapM_ processAction [AnswerClients [ch] ["KICKED"], MoveToLobby $ loc "kicked"]
   554 
   554 
   555 
   555 
   556 processAction (AddClient cl) = do
   556 processAction (AddClient cl) = do
   557     rnc <- gets roomsClients
   557     rnc <- gets roomsClients
   558     si <- gets serverInfo
   558     si <- gets serverInfo
   611     where
   611     where
   612         kickTimeouted rnc ci = do
   612         kickTimeouted rnc ci = do
   613             pq <- io $ client'sM rnc pingsQueue ci
   613             pq <- io $ client'sM rnc pingsQueue ci
   614             when (pq > 0) $ do
   614             when (pq > 0) $ do
   615                 withStateT (\as -> as{clientIndex = Just ci}) $
   615                 withStateT (\as -> as{clientIndex = Just ci}) $
   616                     processAction (ByeClient "Ping timeout")
   616                     processAction (ByeClient $ loc "Ping timeout")
   617 --                when (pq > 1) $
   617 --                when (pq > 1) $
   618 --                    processAction $ DeleteClient ci -- smth went wrong with client io threads, issue DeleteClient here
   618 --                    processAction $ DeleteClient ci -- smth went wrong with client io threads, issue DeleteClient here
   619 
   619 
   620 
   620 
   621 processAction StatsAction = do
   621 processAction StatsAction = do