gameServer/HWProtoNEState.hs
changeset 2349 ba7a0813c532
parent 2155 d897222d3339
child 2352 7eaf82cf0890
equal deleted inserted replaced
2348:b39d826e1ccd 2349:ba7a0813c532
    24 		AnswerThisClient ["NICK", newNick]]
    24 		AnswerThisClient ["NICK", newNick]]
    25 		++ checkPassword
    25 		++ checkPassword
    26 	where
    26 	where
    27 		client = clients IntMap.! clID
    27 		client = clients IntMap.! clID
    28 		haveSameNick = isJust $ find (\cl -> newNick == nick cl) $ IntMap.elems clients
    28 		haveSameNick = isJust $ find (\cl -> newNick == nick cl) $ IntMap.elems clients
    29 		checkPassword = if clientProto client /= 0 then [CheckRegistered] else []
    29 		checkPassword = [CheckRegistered | clientProto client /= 0]
    30 
    30 
    31 
    31 
    32 handleCmd_NotEntered clID clients _ ["PROTO", protoNum] =
    32 handleCmd_NotEntered clID clients _ ["PROTO", protoNum]
    33 	if clientProto client > 0 then
    33 	| clientProto client > 0 = [ProtocolError "Protocol already known"]
    34 		[ProtocolError "Protocol already known"]
    34 	| parsedProto == 0 = [ProtocolError "Bad number"]
    35 	else if parsedProto == 0 then
    35 	| otherwise =
    36 		[ProtocolError "Bad number"]
    36 		[ModifyClient (\ c -> c{clientProto = parsedProto}),
    37 	else
       
    38 		[ModifyClient (\c -> c{clientProto = parsedProto}),
       
    39 		AnswerThisClient ["PROTO", show parsedProto]]
    37 		AnswerThisClient ["PROTO", show parsedProto]]
    40 		++ checkPassword
    38 		++ checkPassword
    41 	where
    39 	where
    42 		client = clients IntMap.! clID
    40 		client = clients IntMap.! clID
    43 		parsedProto = fromMaybe 0 (maybeRead protoNum :: Maybe Word16)
    41 		parsedProto = fromMaybe 0 (maybeRead protoNum :: Maybe Word16)
    44 		checkPassword = if (not . null) (nick client) then [CheckRegistered] else []
    42 		checkPassword = [CheckRegistered | (not . null) (nick client)]
    45 
    43 
    46 
    44 
    47 handleCmd_NotEntered clID clients _ ["PASSWORD", passwd] =
    45 handleCmd_NotEntered clID clients _ ["PASSWORD", passwd] =
    48 	if passwd == webPassword client then
    46 	if passwd == webPassword client then
    49 		[ModifyClient (\cl -> cl{logonPassed = True}),
    47 		[ModifyClient (\cl -> cl{logonPassed = True}),
    50 		MoveToLobby] ++ adminNotice
    48 		MoveToLobby] ++ adminNotice
    51 	else
    49 	else
    52 		[ByeClient "Authentication failed"]
    50 		[ByeClient "Authentication failed"]
    53 	where
    51 	where
    54 		client = clients IntMap.! clID
    52 		client = clients IntMap.! clID
    55 		adminNotice = if isAdministrator client then [AnswerThisClient ["ADMIN_ACCESS"]] else []
    53 		adminNotice = [AnswerThisClient ["ADMIN_ACCESS"] | isAdministrator client]
    56 
    54 
    57 
    55 
    58 --handleCmd_NotEntered _ _ _ ["DUMP"] =
    56 --handleCmd_NotEntered _ _ _ ["DUMP"] =
    59 --	[Dump]
    57 --	[Dump]
    60 
    58