Only registered players regain their teams on rejoin
authorunc0rr
Fri, 23 Dec 2016 23:29:00 +0300
changeset 12119 cdadc1d487f1
parent 12118 72f5d670bbee
child 12120 771b51cff812
Only registered players regain their teams on rejoin
gameServer/Actions.hs
gameServer/HWProtoInRoomState.hs
gameServer/HWProtoLobbyState.hs
gameServer/Utils.hs
--- a/gameServer/Actions.hs	Fri Dec 23 23:12:00 2016 +0300
+++ b/gameServer/Actions.hs	Fri Dec 23 23:29:00 2016 +0300
@@ -515,12 +515,12 @@
     rnc <- gets roomsClients
     clientNick <- client's nick
     clProto <- client's clientProto
-    isAuthenticated <- liftM (not . B.null) $ client's webPassword
+    isAuthenticated <- liftM isRegistered $ client's id
     isAdmin <- client's isAdministrator
     isContr <- client's isContributor
     loggedInClients <- liftM (Prelude.filter isVisible) $! allClientsS
     let (lobbyNicks, clientsChans) = unzip . L.map (nick &&& sendChan) $ loggedInClients
-    let authenticatedNicks = L.map nick . L.filter (not . B.null . webPassword) $ loggedInClients
+    let authenticatedNicks = L.map nick . L.filter isRegistered $ loggedInClients
     let adminsNicks = L.map nick . L.filter isAdministrator $ loggedInClients
     let contrNicks = L.map nick . L.filter isContributor $ loggedInClients
     inRoomNicks <- io $
--- a/gameServer/HWProtoInRoomState.hs	Fri Dec 23 23:12:00 2016 +0300
+++ b/gameServer/HWProtoInRoomState.hs	Fri Dec 23 23:29:00 2016 +0300
@@ -111,7 +111,6 @@
         clChan <- thisClientChans
         othChans <- roomOthersChans
         roomChans <- roomClientsChans
-        let isRegistered = (<) 0 . B.length . webPassword $ cl
         teamColor <-
             if clientProto cl < 42 then
                 return color
@@ -123,7 +122,7 @@
                     minimum [hhnum $ head roomTeams, canAddNumber roomTeams]
                 else
                     defaultHedgehogsNumber rm
-        let newTeam = clNick `seq` TeamInfo clNick tName teamColor grave fort voicepack flag isRegistered dif hhNum (hhsList hhsInfo)
+        let newTeam = clNick `seq` TeamInfo clNick tName teamColor grave fort voicepack flag (isRegistered cl) dif hhNum (hhsList hhsInfo)
         return $
             if not . null . drop (teamsNumberLimit rm - 1) $ roomTeams then
                 [Warning $ loc "too many teams"]
--- a/gameServer/HWProtoLobbyState.hs	Fri Dec 23 23:12:00 2016 +0300
+++ b/gameServer/HWProtoLobbyState.hs	Fri Dec 23 23:29:00 2016 +0300
@@ -83,7 +83,7 @@
     let chans = map sendChan (cl : jRoomClients)
     let isBanned = host cl `elem` roomBansList jRoom
     let clTeams =
-            if (clientProto cl >= 48) && (isJust $ gameInfo jRoom) then
+            if (clientProto cl >= 48) && (isJust $ gameInfo jRoom) && isRegistered cl then
                 filter (\t -> teamowner t == nick cl) . teamsAtStart . fromJust $ gameInfo jRoom 
                 else
                 []
@@ -95,7 +95,7 @@
             [Warning $ loc "Room version incompatible to your hedgewars version"]
             else if isRestrictedJoins jRoom && not (hasSuperPower cl) then
             [Warning $ loc "Joining restricted"]
-            else if isRegisteredOnly jRoom && (B.null . webPassword $ cl) && not (isAdministrator cl) then
+            else if isRegisteredOnly jRoom && (not $ isRegistered cl) && not (isAdministrator cl) then
             [Warning $ loc "Registered users only"]
             else if isBanned then
             [Warning $ loc "You are banned in this room"]
--- a/gameServer/Utils.hs	Fri Dec 23 23:12:00 2016 +0300
+++ b/gameServer/Utils.hs	Fri Dec 23 23:29:00 2016 +0300
@@ -245,3 +245,6 @@
     where
         sc c | isAlphaNum c = c
              | otherwise = '_'
+
+isRegistered :: ClientInfo -> Bool
+isRegistered = (<) 0 . B.length . webPassword