/registered_only now tells in chat whether the state is on or off
authorWuzzy <Wuzzy2@mail.ru>
Sat, 08 Dec 2018 14:19:11 +0100
changeset 14380 8ad85859dd3f
parent 14379 b33127bc2424
child 14381 32e8c81ca35c
/registered_only now tells in chat whether the state is on or off
gameServer/Actions.hs
gameServer/CoreTypes.hs
gameServer/HWProtoCore.hs
--- a/gameServer/Actions.hs	Sat Dec 08 14:13:18 2018 +0100
+++ b/gameServer/Actions.hs	Sat Dec 08 14:19:11 2018 +0100
@@ -885,3 +885,13 @@
 
 processAction CheckVotes =
     checkVotes >>= mapM_ processAction
+
+processAction (ShowRegisteredOnlyState chans) = do
+    si <- gets serverInfo
+    processAction $ AnswerClients chans
+        ["CHAT", nickServer,
+        if isRegisteredUsersOnly si then
+            loc "This server no longer allows unregistered players to join."
+        else
+            loc "This server now allows unregistered players to join."
+        ]
--- a/gameServer/CoreTypes.hs	Sat Dec 08 14:13:18 2018 +0100
+++ b/gameServer/CoreTypes.hs	Sat Dec 08 14:19:11 2018 +0100
@@ -103,6 +103,7 @@
     | ReactCmd [B.ByteString]
     | CheckVotes
     | SetRandomSeed
+    | ShowRegisteredOnlyState [ClientChan]
 
 
 data Event = LobbyChatMessage
--- a/gameServer/HWProtoCore.hs	Sat Dec 08 14:13:18 2018 +0100
+++ b/gameServer/HWProtoCore.hs	Sat Dec 08 14:19:11 2018 +0100
@@ -120,11 +120,11 @@
         h "INFO" n | not $ B.null n = handleCmd ["INFO", n]
         h "HELP" _ = handleCmd ["HELP"]
         h "REGISTERED_ONLY" _ = serverAdminOnly $ do
-            cl <- thisClient
+            rnc <- liftM snd ask
+            let chans = map (sendChan . client rnc) $ allClients rnc
             return
                 [ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s})
-                -- TODO: Say whether 'registered only' state is on or off
-                , AnswerClients [sendChan cl] ["CHAT", nickServer, loc "'Registered only' state toggled."]
+                , ShowRegisteredOnlyState chans
                 ]
         h "SUPER_POWER" _ = serverAdminOnly $ do
             cl <- thisClient