gameServer/HWProtoLobbyState.hs
changeset 9753 9579596cf471
parent 9729 6a3640c4f4b7
child 9787 0da6ba2f1f93
--- a/gameServer/HWProtoLobbyState.hs	Wed Dec 04 12:28:04 2013 +0100
+++ b/gameServer/HWProtoLobbyState.hs	Thu Dec 05 00:51:27 2013 +0400
@@ -21,10 +21,9 @@
     (ci, irnc) <- ask
     let cl = irnc `client` ci
     rooms <- allRoomInfos
-    let roomsInfoList = concatMap (\r -> roomInfo (clientProto cl) (nick $ irnc `client` masterID r) r) . filter (\r -> (roomProto r == clientProto cl))
+    let roomsInfoList = concatMap (\r -> roomInfo (clientProto cl) (maybeNick . liftM (client irnc) $ masterID r) r) . filter (\r -> (roomProto r == clientProto cl))
     return [AnswerClients [sendChan cl] ("ROOMS" : roomsInfoList rooms)]
 
-
 handleCmd_lobby ["CHAT", msg] = do
     n <- clientNick
     s <- roomOthersChans
@@ -60,7 +59,7 @@
     let sameProto = clientProto cl == roomProto jRoom
     let jRoomClients = map (client irnc) $ roomClients irnc jRI
     let nicks = map nick jRoomClients
-    let ownerNick = nick . fromJust $ find isMaster jRoomClients
+    let owner = find isMaster jRoomClients
     let chans = map sendChan (cl : jRoomClients)
     let isBanned = host cl `elem` roomBansList jRoom
     return $
@@ -70,24 +69,25 @@
             [Warning $ loc "Room version incompatible to your hedgewars version"]
             else if isRestrictedJoins jRoom then
             [Warning $ loc "Joining restricted"]
-            else if isRegisteredOnly jRoom && (B.null . webPassword $ cl) then
+            else if isRegisteredOnly jRoom && (B.null . webPassword $ cl) && not (isAdministrator cl) then
             [Warning $ loc "Registered users only"]
             else if isBanned then
             [Warning $ loc "You are banned in this room"]
             else if roomPassword /= password jRoom then
             [NoticeMessage WrongPassword]
             else
-            [
+            (
                 MoveToRoom jRI
-                , ModifyClient (\c -> c{isJoinedMidGame = isJust $ gameInfo jRoom})
-                , AnswerClients [sendChan cl] $ "JOINED" : nicks
-                , AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl]
-                , AnswerClients [sendChan cl] $ ["CLIENT_FLAGS", "+h", ownerNick]
-            ]
+                : ModifyClient (\c -> c{isJoinedMidGame = isJust $ gameInfo jRoom})
+                : (AnswerClients [sendChan cl] $ "JOINED" : nicks)
+                : AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl]
+                : [AnswerClients [sendChan cl] $ ["CLIENT_FLAGS", "+h", nick $ fromJust owner] | isJust owner]
+            )
             ++ (if clientProto cl < 38 then map (readynessMessage cl) jRoomClients else [sendStateFlags cl jRoomClients])
             ++ answerFullConfig cl jRoom
             ++ answerTeams cl jRoom
             ++ watchRound cl jRoom chans
+            ++ []
 
         where
         readynessMessage cl c = AnswerClients [sendChan cl] [if isReady c then "READY" else "NOT_READY", nick c]