diff -r a4a17b8df591 -r 7eaf82cf0890 gameServer/HWProtoNEState.hs --- a/gameServer/HWProtoNEState.hs Fri Sep 04 16:39:51 2009 +0000 +++ b/gameServer/HWProtoNEState.hs Fri Sep 04 16:50:52 2009 +0000 @@ -11,35 +11,29 @@ handleCmd_NotEntered :: CmdHandler -handleCmd_NotEntered clID clients _ ["NICK", newNick] = - if not . null $ nick client then - [ProtocolError "Nickname already chosen"] - else if haveSameNick then - [AnswerThisClient ["WARNING", "Nickname collision"]] - ++ [ByeClient ""] - else if illegalName newNick then - [ByeClient "Illegal nickname"] - else - [ModifyClient (\c -> c{nick = newNick}), - AnswerThisClient ["NICK", newNick]] - ++ checkPassword +handleCmd_NotEntered clID clients _ ["NICK", newNick] + | not . null $ nick client = [ProtocolError "Nickname already chosen"] + | haveSameNick = [AnswerThisClient ["WARNING", "Nickname collision"], ByeClient ""] + | illegalName newNick = [ByeClient "Illegal nickname"] + | otherwise = + ModifyClient (\c -> c{nick = newNick}) : + AnswerThisClient ["NICK", newNick] : + [CheckRegistered | clientProto client /= 0] where client = clients IntMap.! clID haveSameNick = isJust $ find (\cl -> newNick == nick cl) $ IntMap.elems clients - checkPassword = [CheckRegistered | clientProto client /= 0] handleCmd_NotEntered clID clients _ ["PROTO", protoNum] | clientProto client > 0 = [ProtocolError "Protocol already known"] | parsedProto == 0 = [ProtocolError "Bad number"] | otherwise = - [ModifyClient (\ c -> c{clientProto = parsedProto}), - AnswerThisClient ["PROTO", show parsedProto]] - ++ checkPassword + ModifyClient (\c -> c{clientProto = parsedProto}) : + AnswerThisClient ["PROTO", show parsedProto] : + [CheckRegistered | (not . null) (nick client)] where client = clients IntMap.! clID parsedProto = fromMaybe 0 (maybeRead protoNum :: Maybe Word16) - checkPassword = [CheckRegistered | (not . null) (nick client)] handleCmd_NotEntered clID clients _ ["PASSWORD", passwd] =