gameServer/HWProtoNEState.hs
changeset 3538 b11ac2677e42
parent 3536 7d99655130ff
child 3566 772a46ef8288
equal deleted inserted replaced
3536:7d99655130ff 3538:b11ac2677e42
    18 handleCmd_NotEntered ["NICK", newNick] = do
    18 handleCmd_NotEntered ["NICK", newNick] = do
    19     (ci, irnc) <- ask
    19     (ci, irnc) <- ask
    20     let cl = irnc `client` ci
    20     let cl = irnc `client` ci
    21     if not . B.null $ nick cl then return [ProtocolError "Nickname already chosen"]
    21     if not . B.null $ nick cl then return [ProtocolError "Nickname already chosen"]
    22         else
    22         else
    23         if haveSameNick irnc then return [AnswerClients [sendChan cl] ["WARNING", "Nickname already in use"], ByeClient ""]
    23         if haveSameNick irnc (nick cl) then return [AnswerClients [sendChan cl] ["WARNING", "Nickname already in use"], ByeClient ""]
    24             else 
    24             else
    25             if illegalName newNick then return [ByeClient "Illegal nickname"]
    25             if illegalName newNick then return [ByeClient "Illegal nickname"]
    26                 else
    26                 else
    27                 return $
    27                 return $
    28                     ModifyClient (\c -> c{nick = newNick}) :
    28                     ModifyClient (\c -> c{nick = newNick}) :
    29                     AnswerClients [sendChan cl] ["NICK", newNick] :
    29                     AnswerClients [sendChan cl] ["NICK", newNick] :
    30                     [CheckRegistered | clientProto cl /= 0]
    30                     [CheckRegistered | clientProto cl /= 0]
    31     where
    31     where
    32         haveSameNick irnc = False --isJust $ find (\cl -> newNick == nick cl) $ IntMap.elems clients
    32     haveSameNick irnc clNick = isJust $ find (\cl -> newNick == clNick) $ map (client irnc) $ allClients irnc
    33 
       
    34 
    33 
    35 handleCmd_NotEntered ["PROTO", protoNum] = do
    34 handleCmd_NotEntered ["PROTO", protoNum] = do
    36     (ci, irnc) <- ask
    35     (ci, irnc) <- ask
    37     let cl = irnc `client` ci
    36     let cl = irnc `client` ci
    38     if clientProto cl > 0 then return [ProtocolError "Protocol already known"]
    37     if clientProto cl > 0 then return [ProtocolError "Protocol already known"]