This should help with second rejoin bug. (reverting previous workaround over frontend bug and making a new one)
authorunc0rr
Sat, 07 Feb 2015 00:19:54 +0300
changeset 10814 810ac1d21fd0
parent 10812 38dc8445d7a7
child 10815 2a85c551909c
This should help with second rejoin bug. (reverting previous workaround over frontend bug and making a new one)
gameServer/Actions.hs
gameServer/CoreTypes.hs
gameServer/HWProtoLobbyState.hs
--- a/gameServer/Actions.hs	Sat Jan 31 23:14:12 2015 -0500
+++ b/gameServer/Actions.hs	Sat Feb 07 00:19:54 2015 +0300
@@ -356,6 +356,9 @@
                         ) joinedMidGame
                      ) ri
 
+    rteams <- io $ room'sM rnc (L.nub . rejoinedTeams . fromJust . gameInfo) ri
+    mapM_ (processAction . RemoveTeam) rteams
+
     mapM_ processAction $ (
         SaveReplay
         : ModifyRoom
--- a/gameServer/CoreTypes.hs	Sat Jan 31 23:14:12 2015 -0500
+++ b/gameServer/CoreTypes.hs	Sat Feb 07 00:19:54 2015 +0300
@@ -186,6 +186,7 @@
         roundMsgs :: [B.ByteString],
         lastFilteredTimedMsg :: Maybe B.ByteString,
         leftTeams :: [B.ByteString],
+        rejoinedTeams :: [B.ByteString], -- for 0.9.21 frontend workaround
         teamsAtStart :: [TeamInfo],
         teamsInGameNumber :: Int,
         allPlayersHaveRegisteredAccounts :: !Bool,
@@ -206,6 +207,7 @@
         []
         Nothing
         []
+        []
 
 
 data RoomInfo =
--- a/gameServer/HWProtoLobbyState.hs	Sat Jan 31 23:14:12 2015 -0500
+++ b/gameServer/HWProtoLobbyState.hs	Sat Feb 07 00:19:54 2015 +0300
@@ -105,7 +105,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]
+            ++ [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
@@ -117,7 +117,7 @@
         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})
+            , g{leftTeams = leftTeams g \\ cts, rejoinedTeams = rejoinedTeams 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