gameServer/HWProtoLobbyState.hs
changeset 10351 0eff41e9f63f
parent 10349 a51de45dcc42
child 10460 8dcea9087d75
--- a/gameServer/HWProtoLobbyState.hs	Fri Jul 04 22:45:59 2014 +0400
+++ b/gameServer/HWProtoLobbyState.hs	Sat Jul 05 15:28:32 2014 +0400
@@ -63,7 +63,7 @@
     let chans = map sendChan (cl : jRoomClients)
     let isBanned = host cl `elem` roomBansList jRoom
     let clTeams =
-            if (isJust $ gameInfo jRoom) then
+            if (clientProto cl >= 48) && (isJust $ gameInfo jRoom) then
                 map teamname . filter (\t -> teamowner t == nick cl) . teamsAtStart . fromJust $ gameInfo jRoom 
                 else
                 []
@@ -87,6 +87,7 @@
                 : AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl]
                 : [(AnswerClients [sendChan cl] $ "JOINED" : nicks) | not $ null nicks]
             )
+                ++ [ModifyRoom (\r -> let (t', g') = moveTeams clTeams . fromJust $ gameInfo r in r{gameInfo = Just g', teams = t'}) | not $ null clTeams]
             ++ [AnswerClients [sendChan cl] ["CLIENT_FLAGS", "+h", nick $ fromJust owner] | isJust owner]
             ++ [sendStateFlags cl jRoomClients | not $ null jRoomClients]
             ++ answerFullConfig cl jRoom
@@ -96,6 +97,9 @@
             ++ map (\t -> AnswerClients chans ["EM", toEngineMsg $ 'G' `B.cons` t]) clTeams
 
         where
+        moveTeams :: [B.ByteString] -> GameInfo -> ([TeamInfo], GameInfo)
+        moveTeams cts g = (deleteFirstsBy2 (\a b -> teamname a == b) (teamsAtStart g) (leftTeams g \\ cts)
+            , g{leftTeams = leftTeams g \\ cts, teamsInGameNumber = teamsInGameNumber g + length cts})
         sendStateFlags cl clients = AnswerClients [sendChan cl] . concat . intersperse [""] . filter (not . null) . concat $
                 [f "+r" ready, f "-r" unready, f "+g" ingame, f "-g" inroomlobby]
             where