gameServer/HWProtoLobbyState.hs
changeset 3502 ad38c653b7d9
parent 3501 a3159a410e5c
child 3536 7d99655130ff
--- a/gameServer/HWProtoLobbyState.hs	Sun Jun 06 19:03:06 2010 +0000
+++ b/gameServer/HWProtoLobbyState.hs	Tue Jun 08 18:20:49 2010 +0000
@@ -56,23 +56,25 @@
     s <- roomOthersChans
     return [AnswerClients s ["CHAT", n, msg]]
 
-{-
-handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom, roomPassword]
-    | haveSameRoom = [Warning "Room exists"]
-    | illegalName newRoom = [Warning "Illegal room name"]
-    | otherwise =
-        [RoomRemoveThisClient "", -- leave lobby
-        AddRoom newRoom roomPassword,
-        AnswerThisClient ["NOT_READY", clientNick]
-        ]
-    where
-        clientNick = nick $ clients IntMap.! clID
-        haveSameRoom = isJust $ find (\room -> newRoom == name room) $ IntMap.elems rooms
+handleCmd_lobby ["CREATE_ROOM", newRoom, roomPassword]
+    | illegalName newRoom = return [Warning "Illegal room name"]
+    | otherwise = do
+        rs <- allRoomInfos
+        (ci, irnc) <- ask
+        let cl =  irnc `client` ci
+        return $ if isJust $ find (\room -> newRoom == name room) rs then 
+            [Warning "Room exists"]
+            else
+            [
+                AddRoom newRoom roomPassword,
+                AnswerClients [sendChan cl] ["NOT_READY", nick cl]
+            ]
 
 
-handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom] =
-    handleCmd_lobby clID clients rooms ["CREATE_ROOM", newRoom, ""]
+handleCmd_lobby ["CREATE_ROOM", newRoom] =
+    handleCmd_lobby ["CREATE_ROOM", newRoom, ""]
 
+{-
 
 handleCmd_lobby clID clients rooms ["JOIN_ROOM", roomName, roomPassword]
     | noSuchRoom = [Warning "No such room"]
@@ -185,7 +187,7 @@
         [ClearAccountsCache | isAdministrator client]
     where
         client = clients IntMap.! clID
+-}
 
 
-handleCmd_lobby clID _ _ _ = [ProtocolError "Incorrect command (state: in lobby)"]
--}
+handleCmd_lobby _ = return [ProtocolError "Incorrect command (state: in lobby)"]