- /greeting command for room greeting message
authorunc0rr
Fri, 13 Dec 2013 00:16:02 +0400
changeset 9787 0da6ba2f1f93
parent 9786 e33ee5ef5d9d
child 9788 af04cfdb1684
- /greeting command for room greeting message - Remove some obsolete stuff, some fixes to special rooms
gameServer/CoreTypes.hs
gameServer/HWProtoCore.hs
gameServer/HWProtoInRoomState.hs
gameServer/HWProtoLobbyState.hs
--- a/gameServer/CoreTypes.hs	Fri Dec 13 00:00:49 2013 +0400
+++ b/gameServer/CoreTypes.hs	Fri Dec 13 00:16:02 2013 +0400
@@ -182,6 +182,7 @@
         isRestrictedTeams :: Bool,
         isRegisteredOnly :: Bool,
         isSpecial :: Bool,
+        greeting :: B.ByteString,
         roomBansList :: ![B.ByteString],
         mapParams :: Map.Map B.ByteString B.ByteString,
         params :: Map.Map B.ByteString [B.ByteString]
@@ -202,6 +203,7 @@
         False
         False
         False
+        ""
         []
         (
             Map.fromList $ Prelude.zip
--- a/gameServer/HWProtoCore.hs	Fri Dec 13 00:00:49 2013 +0400
+++ b/gameServer/HWProtoCore.hs	Fri Dec 13 00:16:02 2013 +0400
@@ -53,6 +53,7 @@
         h "WATCH" f = return [QueryReplay f]
         h "FIX" _ = handleCmd ["FIX"]
         h "UNFIX" _ = handleCmd ["UNFIX"]
+        h "GREETING" msg = handleCmd ["GREETING", msg]
         h c p = return [Warning $ B.concat ["Unknown cmd: /", c, p]]
 
 handleCmd cmd = do
--- a/gameServer/HWProtoInRoomState.hs	Fri Dec 13 00:00:49 2013 +0400
+++ b/gameServer/HWProtoInRoomState.hs	Fri Dec 13 00:16:02 2013 +0400
@@ -378,6 +378,10 @@
     cl <- thisClient
     return [ModifyRoom (\r -> r{isSpecial = False}) | isAdministrator cl]
 
+handleCmd_inRoom ["GREETING", msg] = do
+    cl <- thisClient
+    rm <- thisRoom
+    return [ModifyRoom (\r -> r{greeting = msg}) | isAdministrator cl || (isMaster cl && (not $ isSpecial rm))]
 
 handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17)
 
--- a/gameServer/HWProtoLobbyState.hs	Fri Dec 13 00:00:49 2013 +0400
+++ b/gameServer/HWProtoLobbyState.hs	Fri Dec 13 00:16:02 2013 +0400
@@ -79,18 +79,17 @@
             (
                 MoveToRoom jRI
                 : ModifyClient (\c -> c{isJoinedMidGame = isJust $ gameInfo jRoom})
-                : (AnswerClients [sendChan cl] $ "JOINED" : nicks)
                 : AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl]
-                : [AnswerClients [sendChan cl] $ ["CLIENT_FLAGS", "+h", nick $ fromJust owner] | isJust owner]
+                : [(AnswerClients [sendChan cl] $ "JOINED" : nicks) | not $ null nicks]
             )
-            ++ (if clientProto cl < 38 then map (readynessMessage cl) jRoomClients else [sendStateFlags cl jRoomClients])
+            ++ [AnswerClients [sendChan cl] ["CLIENT_FLAGS", "+h", nick $ fromJust owner] | isJust owner]
+            ++ [sendStateFlags cl jRoomClients | not $ null jRoomClients]
             ++ answerFullConfig cl jRoom
             ++ answerTeams cl jRoom
             ++ watchRound cl jRoom chans
-            ++ []
+            ++ [AnswerClients [sendChan cl] ["CHAT", "[greeting]", greeting jRoom] | greeting jRoom /= ""]
 
         where
-        readynessMessage cl c = AnswerClients [sendChan cl] [if isReady c then "READY" else "NOT_READY", nick c]
         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