gameServer/HWProtoCore.hs
changeset 11054 6e575b29881c
parent 11046 47a8c19ecb60
child 11465 0ae2e4c13bd1
equal deleted inserted replaced
11053:a009cc19a639 11054:6e575b29881c
    48     if pingsQueue cl == 0 then
    48     if pingsQueue cl == 0 then
    49         return [ProtocolError "Protocol violation"]
    49         return [ProtocolError "Protocol violation"]
    50         else
    50         else
    51         return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})]
    51         return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})]
    52 
    52 
    53 handleCmd ["CMD", parameters] = uncurry h $ extractParameters parameters
    53 handleCmd cmd = do
       
    54     (ci, irnc) <- ask
       
    55     let cl = irnc `client` ci
       
    56     if logonPassed cl then
       
    57         if isChecker cl then
       
    58             handleCmd_checker cmd
       
    59             else
       
    60             handleCmd_loggedin cmd
       
    61         else
       
    62         handleCmd_NotEntered cmd
       
    63 
       
    64 
       
    65 handleCmd_loggedin ["CMD", parameters] = uncurry h $ extractParameters parameters
    54     where
    66     where
    55         h "DELEGATE" n | not $ B.null n = handleCmd ["DELEGATE", n]
    67         h "DELEGATE" n | not $ B.null n = handleCmd ["DELEGATE", n]
    56         h "SAVEROOM" n | not $ B.null n = handleCmd ["SAVEROOM", n]
    68         h "SAVEROOM" n | not $ B.null n = handleCmd ["SAVEROOM", n]
    57         h "LOADROOM" n | not $ B.null n = handleCmd ["LOADROOM", n]
    69         h "LOADROOM" n | not $ B.null n = handleCmd ["LOADROOM", n]
    58         h "SAVE" n | not $ B.null n = handleCmd ["SAVE", n]
    70         h "SAVE" n | not $ B.null n = handleCmd ["SAVE", n]
    81         h "INFO" n | not $ B.null n = handleCmd ["INFO", n]
    93         h "INFO" n | not $ B.null n = handleCmd ["INFO", n]
    82         h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"]
    94         h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"]
    83         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]]
    95         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]]
    84 
    96 
    85         extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b)
    97         extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b)
    86 
       
    87 
       
    88 handleCmd cmd = do
       
    89     (ci, irnc) <- ask
       
    90     let cl = irnc `client` ci
       
    91     if logonPassed cl then
       
    92         if isChecker cl then
       
    93             handleCmd_checker cmd
       
    94             else
       
    95             handleCmd_loggedin cmd
       
    96         else
       
    97         handleCmd_NotEntered cmd
       
    98 
       
    99 
    98 
   100 handleCmd_loggedin ["INFO", asknick] = do
    99 handleCmd_loggedin ["INFO", asknick] = do
   101     (_, rnc) <- ask
   100     (_, rnc) <- ask
   102     maybeClientId <- clientByNick asknick
   101     maybeClientId <- clientByNick asknick
   103     isAdminAsking <- liftM isAdministrator thisClient
   102     isAdminAsking <- liftM isAdministrator thisClient