# HG changeset patch # User unc0rr # Date 1451335064 -10800 # Node ID f2c36df8c7b14c2655685f30cba5840dcde76d83 # Parent 4b5c7a5c49fd9b45775fe72568e2315f07e33a78 Allow server admins to join passworded/restricted rooms when it is really needed diff -r 4b5c7a5c49fd -r f2c36df8c7b1 gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Mon Dec 28 21:51:12 2015 +0300 +++ b/gameServer/CoreTypes.hs Mon Dec 28 23:37:44 2015 +0300 @@ -142,6 +142,7 @@ isReady :: !Bool, isInGame :: !Bool, isAdministrator :: !Bool, + hasSuperPower :: !Bool, isChecker :: !Bool, isContributor :: !Bool, isKickedFromServer :: !Bool, diff -r 4b5c7a5c49fd -r f2c36df8c7b1 gameServer/HWProtoCore.hs --- a/gameServer/HWProtoCore.hs Mon Dec 28 21:51:12 2015 +0300 +++ b/gameServer/HWProtoCore.hs Mon Dec 28 23:37:44 2015 +0300 @@ -75,11 +75,10 @@ h "QUIT" m | not $ B.null m = handleCmd ["QUIT", m] | otherwise = handleCmd ["QUIT"] h "RND" p = handleCmd ("RND" : B.words p) - h "GLOBAL" p = do - cl <- thisClient + h "GLOBAL" p = serverAdminOnly $ do rnc <- liftM snd ask let chans = map (sendChan . client rnc) $ allClients rnc - return [AnswerClients chans ["CHAT", "[global notice]", p] | isAdministrator cl] + return [AnswerClients chans ["CHAT", "[global notice]", p]] h "WATCH" f = return [QueryReplay f] h "FIX" _ = handleCmd ["FIX"] h "UNFIX" _ = handleCmd ["UNFIX"] @@ -92,14 +91,13 @@ h "MAXTEAMS" n | not $ B.null n = handleCmd ["MAXTEAMS", n] h "INFO" n | not $ B.null n = handleCmd ["INFO", n] h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"] - h "REGISTERED_ONLY" _ = do + h "REGISTERED_ONLY" _ = serverAdminOnly $ do cl <- thisClient - return $ if isAdministrator cl then + return [ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s}) , AnswerClients [sendChan cl] ["CHAT", "[server]", "'Registered only' state toggled"] ] - else - [] + h "SUPER_POWER" _ = serverAdminOnly $ return [ModifyClient (\c -> c{hasSuperPower = True})] h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]] extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b) diff -r 4b5c7a5c49fd -r f2c36df8c7b1 gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Mon Dec 28 21:51:12 2015 +0300 +++ b/gameServer/HWProtoLobbyState.hs Mon Dec 28 23:37:44 2015 +0300 @@ -93,13 +93,13 @@ [Warning $ loc "No such room"] else if (not sameProto) && (not $ isAdministrator cl) then [Warning $ loc "Room version incompatible to your hedgewars version"] - else if isRestrictedJoins jRoom then + else if isRestrictedJoins jRoom && not (hasSuperPower cl) then [Warning $ loc "Joining restricted"] else if isRegisteredOnly jRoom && (B.null . webPassword $ cl) && not (isAdministrator cl) then [Warning $ loc "Registered users only"] else if isBanned then [Warning $ loc "You are banned in this room"] - else if roomPassword /= password jRoom then + else if roomPassword /= password jRoom && not (hasSuperPower cl) then [NoticeMessage WrongPassword] else ( diff -r 4b5c7a5c49fd -r f2c36df8c7b1 gameServer/NetRoutines.hs --- a/gameServer/NetRoutines.hs Mon Dec 28 21:51:12 2015 +0300 +++ b/gameServer/NetRoutines.hs Mon Dec 28 23:37:44 2015 +0300 @@ -73,6 +73,7 @@ False False False + False Nothing Nothing newEventsInfo