gameServer/HWProtoNEState.hs
changeset 1841 fba7210b438b
parent 1834 71cb978dc85f
child 1844 81abed9d4c11
--- a/gameServer/HWProtoNEState.hs	Tue Feb 24 21:47:17 2009 +0000
+++ b/gameServer/HWProtoNEState.hs	Wed Feb 25 17:12:32 2009 +0000
@@ -11,23 +11,6 @@
 
 handleCmd_NotEntered :: CmdHandler
 
-onLoginFinished :: Int -> String -> Word16 -> Clients -> [Action]
-onLoginFinished clID clientNick clProto clients =
-	if (null $ clientNick) || (clProto == 0) then
-		[]
-	else
-		(RoomAddThisClient 0)
-		: CheckRegistered
-		: answerLobbyNicks
-		-- ++ (answerServerMessage client clients)
-	where
-		lobbyNicks = filter (\n -> (not (null n))) $ map nick $ IntMap.elems clients
-		answerLobbyNicks = if not $ null lobbyNicks then
-					[AnswerThisClient (["LOBBY:JOINED"] ++ lobbyNicks)]
-				else
-					[]
-
-
 handleCmd_NotEntered clID clients _ ["NICK", newNick] =
 	if not . null $ nick client then
 		[ProtocolError "Nick already chosen"]
@@ -37,10 +20,11 @@
 	else
 		[ModifyClient (\c -> c{nick = newNick}),
 		AnswerThisClient ["NICK", newNick]]
-		++ (onLoginFinished clID newNick (clientProto client) clients)
+		++ checkPassword
 	where
 		client = clients IntMap.! clID
 		haveSameNick = isJust $ find (\cl -> newNick == nick cl) $ IntMap.elems clients
+		checkPassword = if clientProto client /= 0 then [CheckRegistered] else []
 
 
 handleCmd_NotEntered clID clients _ ["PROTO", protoNum] =
@@ -51,10 +35,15 @@
 	else
 		[ModifyClient (\c -> c{clientProto = parsedProto}),
 		AnswerThisClient ["PROTO", show parsedProto]]
-		++ (onLoginFinished clID (nick client) parsedProto clients)
+		++ checkPassword
 	where
 		client = clients IntMap.! clID
 		parsedProto = fromMaybe 0 (maybeRead protoNum :: Maybe Word16)
+		checkPassword = if (not . null) (nick client) then [CheckRegistered] else []
+
+handleCmd_NotEntered clID clients _ ["PASSWORD"] =
+	[ModifyClient (\cl -> cl{logonPassed = True}),
+	MoveToLobby]
 
 
 handleCmd_NotEntered _ _ _ ["DUMP"] =