gameServer/HWProtoLobbyState.hs
changeset 10342 16122539d2ea
parent 10338 9558b0380779
child 10349 a51de45dcc42
--- a/gameServer/HWProtoLobbyState.hs	Thu Jun 26 00:48:44 2014 +0400
+++ b/gameServer/HWProtoLobbyState.hs	Thu Jun 26 21:43:36 2014 +0400
@@ -50,6 +50,7 @@
 
 handleCmd_lobby ["JOIN_ROOM", roomName, roomPassword] = do
     (_, irnc) <- ask
+
     let ris = allRooms irnc
     cl <- thisClient
     let maybeRI = find (\ri -> roomName == name (irnc `room` ri)) ris
@@ -61,7 +62,11 @@
     let owner = find isMaster jRoomClients
     let chans = map sendChan (cl : jRoomClients)
     let isBanned = host cl `elem` roomBansList jRoom
-    let hasTeamsInGame = (isJust $ gameInfo jRoom) && (or . map (\t -> teamowner t == nick cl) . teamsAtStart . fromJust $ gameInfo jRoom)
+    let clTeams =
+            if (isJust $ gameInfo jRoom) then
+                map teamname . filter (\t -> teamowner t == nick cl) . teamsAtStart . fromJust $ gameInfo jRoom 
+                else
+                []
     return $
         if isNothing maybeRI then
             [Warning $ loc "No such room"]
@@ -88,7 +93,7 @@
             ++ answerTeams cl jRoom
             ++ watchRound cl jRoom chans
             ++ [AnswerClients [sendChan cl] ["CHAT", "[greeting]", greeting jRoom] | greeting jRoom /= ""]
-            ++ if hasTeamsInGame then ["EM", toEngineMsg $ 'G' `B.cons` nick cl] else []
+            ++ map (\t -> AnswerClients chans ["EM", toEngineMsg $ 'G' `B.cons` t]) clTeams
 
         where
         sendStateFlags cl clients = AnswerClients [sendChan cl] . concat . intersperse [""] . filter (not . null) . concat $