Show who is the room admin on join (no tested, also I don't like how it is done via server warnings, but it seems there's no other solution compatible with .17)
authorunc0rr
Tue, 04 Sep 2012 15:18:22 +0400
changeset 7668 4cb423f42105
parent 7667 4346566c5a58
child 7669 a85e1c167b69
Show who is the room admin on join (no tested, also I don't like how it is done via server warnings, but it seems there's no other solution compatible with .17)
gameServer/Actions.hs
gameServer/HWProtoLobbyState.hs
--- a/gameServer/Actions.hs	Tue Sep 04 12:43:55 2012 +0200
+++ b/gameServer/Actions.hs	Tue Sep 04 15:18:22 2012 +0400
@@ -244,11 +244,13 @@
     newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri
     newMaster <- io $ client'sM rnc id newMasterId
     oldRoomName <- io $ room'sM rnc name ri
+    thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
     let newRoomName = nick newMaster
     mapM_ processAction [
         ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName, isRestrictedJoins = False, isRestrictedTeams = False}),
         ModifyClient2 newMasterId (\c -> c{isMaster = True}),
-        AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"]
+        AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"],
+        AnswerClients thisRoomChans ["WARNING", "New room admin is " `B.append` nick newMaster]
         ]
 
     proto <- client's clientProto
--- a/gameServer/HWProtoLobbyState.hs	Tue Sep 04 12:43:55 2012 +0200
+++ b/gameServer/HWProtoLobbyState.hs	Tue Sep 04 15:18:22 2012 +0400
@@ -6,6 +6,7 @@
 import Data.Maybe
 import Data.List
 import Control.Monad.Reader
+import qualified Data.ByteString.Char8 as B
 --------------------------------------
 import CoreTypes
 import Actions
@@ -69,6 +70,7 @@
     let sameProto = clientProto cl == roomProto jRoom
     let jRoomClients = map (client irnc) $ roomClients irnc jRI
     let nicks = map nick jRoomClients
+    let owner = fromJust $ find isMaster jRoomClients
     let chans = map sendChan (cl : jRoomClients)
     let isBanned = host cl `elem` roomBansList jRoom
     return $
@@ -84,7 +86,8 @@
             [
                 MoveToRoom jRI,
                 AnswerClients [sendChan cl] $ "JOINED" : nicks,
-                AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl]
+                AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl],
+                AnswerClients [sendChan cl] $ ["WARNING", "Room owner is " `B.append` nick owner]
             ]
             ++ map (readynessMessage cl) jRoomClients
             ++ answerFullConfig cl (mapParams jRoom) (params jRoom)