Add a couple of more useful server messages
authorWuzzy <Wuzzy2@mail.ru>
Sun, 26 Aug 2018 14:37:02 +0200
changeset 13703 2df519242d41
parent 13702 dc06ef77a73a
child 13704 54eb4c774ef5
Add a couple of more useful server messages
gameServer/Actions.hs
gameServer/HWProtoInRoomState.hs
--- a/gameServer/Actions.hs	Sat Aug 25 22:02:21 2018 +0200
+++ b/gameServer/Actions.hs	Sun Aug 26 14:37:02 2018 +0200
@@ -266,6 +266,8 @@
           ModifyClient2 (fromJust newMasterId) (\c -> c{isMaster = True})
         , AnswerClients [sendChan $ fromJust newMaster] ["ROOM_CONTROL_ACCESS", "1"]
         , AnswerClients thisRoomChans ["CLIENT_FLAGS", "+h", nick $ fromJust newMaster]
+        -- TODO: Send message to other clients, too (requires proper localization, however)
+        , AnswerClients [sendChan $ fromJust newMaster] ["CHAT", nickServer, loc "You're the new room master!"]
         ]
 
     processAction $
@@ -823,7 +825,7 @@
 processAction CheckRecord = return ()
 processAction (CheckFailed _) = return ()
 processAction (CheckSuccess _) = return ()
-processAction (QueryReplay _) = return ()
+processAction (QueryReplay _) = processAction $ Warning $ loc "This server does not support replays!"
 #endif
 
 processAction (ShowReplay rname) = do
--- a/gameServer/HWProtoInRoomState.hs	Sat Aug 25 22:02:21 2018 +0200
+++ b/gameServer/HWProtoInRoomState.hs	Sun Aug 26 14:37:02 2018 +0200
@@ -350,7 +350,7 @@
         else if (not ((isNothing $ gameInfo rm) || notOnly2Players || teamsInGame kickCl == 0)) then
             [Warning $ loc "You can't kick the only other player!"]
         else if (not sameRoom) then
-            [Warning $ loc "The player you tried to kick is not in your room."]
+            [Warning $ loc "The player is not in your room."]
         else if (hasSuperPower kickCl) then
             [Warning $ loc "This player is protected from being kicked."]
         else
@@ -365,13 +365,17 @@
     thisRoomMasterId <- liftM masterID thisRoom
     let newAdminId = fromJust maybeClientId
     let sameRoom = clientRoom rnc thisClientId == clientRoom rnc newAdminId
-    return
-        [ChangeMaster (Just newAdminId) |
-            (master || serverAdmin)
-                && isJust maybeClientId
-                && (Just newAdminId /= thisRoomMasterId)
-                && sameRoom]
-
+    return $
+        if (not (master || serverAdmin)) then
+            [Warning $ loc "You not the room master or a server admin!"]
+        else if (isNothing maybeClientId) then
+            [Warning $ loc "Player is not online."]
+        else if (Just newAdminId == thisRoomMasterId) then
+            [Warning $ loc "You're already the room master."]
+        else if (not sameRoom) then
+            [Warning $ loc "The player is not in your room."]
+        else
+            [ChangeMaster (Just newAdminId)]
 
 handleCmd_inRoom ["TEAMCHAT", msg] = do
     cl <- thisClient
@@ -412,8 +416,12 @@
 handleCmd_inRoom ["FIX"] = serverAdminOnly $
     return [ModifyRoom (\r -> r{isSpecial = True})]
 
-handleCmd_inRoom ["UNFIX"] = serverAdminOnly $
-    return [ModifyRoom (\r -> r{isSpecial = False})]
+handleCmd_inRoom ["UNFIX"] = serverAdminOnly $ do
+    cl <- thisClient
+    return $ if not $ isMaster cl then
+                 [Warning $ loc "You're not the room master!"]
+             else
+                 [ModifyRoom (\r -> r{isSpecial = False})]
 
 handleCmd_inRoom ["HELP"] = do
     cl <- thisClient