gameServer/HWProtoCore.hs
changeset 11467 f2c36df8c7b1
parent 11466 4b5c7a5c49fd
child 11575 db7743e2fad1
equal deleted inserted replaced
11466:4b5c7a5c49fd 11467:f2c36df8c7b1
    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"]
    95         h "REGISTERED_ONLY" _ = do
    94         h "REGISTERED_ONLY" _ = serverAdminOnly $ do
    96             cl <- thisClient
    95             cl <- thisClient
    97             return $ if isAdministrator cl then 
    96             return
    98                 [ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s})
    97                 [ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s})
    99                 , AnswerClients [sendChan cl] ["CHAT", "[server]", "'Registered only' state toggled"]
    98                 , AnswerClients [sendChan cl] ["CHAT", "[server]", "'Registered only' state toggled"]
   100                 ]
    99                 ]
   101                 else
   100         h "SUPER_POWER" _ = serverAdminOnly $ return [ModifyClient (\c -> c{hasSuperPower = True})]
   102                 []
       
   103         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]]
   101         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]]
   104 
   102 
   105         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)
   106 
   104 
   107 handleCmd_loggedin ["INFO", asknick] = do
   105 handleCmd_loggedin ["INFO", asknick] = do