gameServer/HWProtoCore.hs
branchqmlfrontend
changeset 11481 caa1e84c3ac2
parent 11467 f2c36df8c7b1
child 11575 db7743e2fad1
equal deleted inserted replaced
11480:b0c34402038c 11481:caa1e84c3ac2
    73         h "PART" m | not $ B.null m = handleCmd ["PART", m]
    73         h "PART" m | not $ B.null m = handleCmd ["PART", m]
    74                    | otherwise = handleCmd ["PART"]
    74                    | otherwise = handleCmd ["PART"]
    75         h "QUIT" m | not $ B.null m = handleCmd ["QUIT", m]
    75         h "QUIT" m | not $ B.null m = handleCmd ["QUIT", m]
    76                    | otherwise = handleCmd ["QUIT"]
    76                    | otherwise = handleCmd ["QUIT"]
    77         h "RND" p = handleCmd ("RND" : B.words p)
    77         h "RND" p = handleCmd ("RND" : B.words p)
    78         h "GLOBAL" p = do
    78         h "GLOBAL" p = serverAdminOnly $ do
    79             cl <- thisClient
       
    80             rnc <- liftM snd ask
    79             rnc <- liftM snd ask
    81             let chans = map (sendChan . client rnc) $ allClients rnc
    80             let chans = map (sendChan . client rnc) $ allClients rnc
    82             return [AnswerClients chans ["CHAT", "[global notice]", p] | isAdministrator cl]
    81             return [AnswerClients chans ["CHAT", "[global notice]", p]]
    83         h "WATCH" f = return [QueryReplay f]
    82         h "WATCH" f = return [QueryReplay f]
    84         h "FIX" _ = handleCmd ["FIX"]
    83         h "FIX" _ = handleCmd ["FIX"]
    85         h "UNFIX" _ = handleCmd ["UNFIX"]
    84         h "UNFIX" _ = handleCmd ["UNFIX"]
    86         h "GREETING" msg | not $ B.null msg = handleCmd ["GREETING", msg]
    85         h "GREETING" msg | not $ B.null msg = handleCmd ["GREETING", msg]
    87         h "CALLVOTE" msg | B.null msg = handleCmd ["CALLVOTE"]
    86         h "CALLVOTE" msg | B.null msg = handleCmd ["CALLVOTE"]
    90         h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg]
    89         h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg]
    91         h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"]
    90         h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"]
    92         h "MAXTEAMS" n | not $ B.null n = handleCmd ["MAXTEAMS", n]
    91         h "MAXTEAMS" n | not $ B.null n = handleCmd ["MAXTEAMS", n]
    93         h "INFO" n | not $ B.null n = handleCmd ["INFO", n]
    92         h "INFO" n | not $ B.null n = handleCmd ["INFO", n]
    94         h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"]
    93         h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"]
       
    94         h "REGISTERED_ONLY" _ = serverAdminOnly $ do
       
    95             cl <- thisClient
       
    96             return
       
    97                 [ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s})
       
    98                 , AnswerClients [sendChan cl] ["CHAT", "[server]", "'Registered only' state toggled"]
       
    99                 ]
       
   100         h "SUPER_POWER" _ = serverAdminOnly $ return [ModifyClient (\c -> c{hasSuperPower = True})]
    95         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]]
   101         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]]
    96 
   102 
    97         extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b)
   103         extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b)
    98 
   104 
    99 handleCmd_loggedin ["INFO", asknick] = do
   105 handleCmd_loggedin ["INFO", asknick] = do