"Registered users only" room flag flibqtfrontend
authorunc0rr
Wed, 05 Dec 2012 23:25:11 +0400
branchflibqtfrontend
changeset 8227 3a2ce574aa3b
parent 8224 48bb7adc42fe
child 8230 bd4b8f9488a4
"Registered users only" room flag
gameServer/Actions.hs
gameServer/CoreTypes.hs
gameServer/HWProtoInRoomState.hs
gameServer/HWProtoLobbyState.hs
--- a/gameServer/Actions.hs	Wed Dec 05 13:31:08 2012 -0500
+++ b/gameServer/Actions.hs	Wed Dec 05 23:25:11 2012 +0400
@@ -267,6 +267,7 @@
                 , name = newRoomName
                 , isRestrictedJoins = False
                 , isRestrictedTeams = False
+                , isRegisteredOnly = False
                 , readyPlayers = if isReady newMaster then readyPlayers r else readyPlayers r + 1})
         , ModifyClient2 newMasterId (\c -> c{isMaster = True, isReady = True})
         , AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"]
--- a/gameServer/CoreTypes.hs	Wed Dec 05 13:31:08 2012 -0500
+++ b/gameServer/CoreTypes.hs	Wed Dec 05 23:25:11 2012 +0400
@@ -100,6 +100,7 @@
         readyPlayers :: !Int,
         isRestrictedJoins :: Bool,
         isRestrictedTeams :: Bool,
+        isRegisteredOnly :: Bool,
         roomBansList :: ![B.ByteString],
         mapParams :: Map.Map B.ByteString B.ByteString,
         params :: Map.Map B.ByteString [B.ByteString]
@@ -118,6 +119,7 @@
         0
         False
         False
+        False
         []
         (
             Map.fromList $ Prelude.zipWith (,)
--- a/gameServer/HWProtoInRoomState.hs	Wed Dec 05 13:31:08 2012 -0500
+++ b/gameServer/HWProtoInRoomState.hs	Wed Dec 05 23:25:11 2012 +0400
@@ -264,6 +264,14 @@
             [ModifyRoom (\r -> r{isRestrictedTeams = not $ isRestrictedTeams r})]
 
 
+handleCmd_inRoom ["TOGGLE_REGISTERED_ONLY"] = do
+    cl <- thisClient
+    return $
+        if not $ isMaster cl then
+            [ProtocolError "Not room master"]
+        else
+            [ModifyRoom (\r -> r{isRegisteredOnly = not $ isRegisteredOnly r})]
+
 handleCmd_inRoom ["ROOM_NAME", newName] = do
     cl <- thisClient
     rs <- allRoomInfos
--- a/gameServer/HWProtoLobbyState.hs	Wed Dec 05 13:31:08 2012 -0500
+++ b/gameServer/HWProtoLobbyState.hs	Wed Dec 05 23:25:11 2012 +0400
@@ -80,6 +80,8 @@
             [Warning "No such room"]
             else if isRestrictedJoins jRoom then
             [Warning "Joining restricted"]
+            else if isRegisteredOnly jRoom then
+            [Warning "Registered users only"]
             else if isBanned then
             [Warning "You are banned in this room"]
             else if roomPassword /= password jRoom then