# HG changeset patch
# User unc0rr
# Date 1358617901 -14400
# Node ID fbc6e7602e0517a8371470794089d3c2bb85dcb0
# Parent 659e043da6da351c7f68db4f1f141ef3ad826c19
- Allow server admins to use DELEGATE even when not room owner
- Show number of clients per version table on /stats command
diff -r 659e043da6da -r fbc6e7602e05 gameServer/Actions.hs
--- a/gameServer/Actions.hs Sat Jan 19 00:55:51 2013 +0400
+++ b/gameServer/Actions.hs Sat Jan 19 21:51:41 2013 +0400
@@ -1,9 +1,10 @@
-{-# LANGUAGE CPP, OverloadedStrings #-}
+{-# LANGUAGE CPP, OverloadedStrings, ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Actions where
import Control.Concurrent
import qualified Data.Set as Set
+import qualified Data.Map as Map
import qualified Data.List as L
import qualified Control.Exception as Exception
import System.Log.Logger
@@ -75,6 +76,7 @@
| AddIP2Bans B.ByteString B.ByteString UTCTime
| CheckBanned Bool
| SaveReplay
+ | Stats
type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action]
@@ -640,6 +642,15 @@
return ()
processAction $ ModifyServerInfo (\s -> s{shutdownPending = True})
+processAction Stats = do
+ cls <- allClientsS
+ let stats = versions cls
+ processAction $ Warning stats
+ where
+ versions = B.concat . ((:) "
"])
+ . concatMap (\(p, n :: Int) -> ["", protoNumber2ver p, " | ", showB n, " |
"])
+ . Map.toList . Map.fromListWith (+) . map (\c -> (clientProto c, 1))
+
#if defined(OFFICIAL_SERVER)
processAction SaveReplay = do
ri <- clientRoomA
diff -r 659e043da6da -r fbc6e7602e05 gameServer/HWProtoCore.hs
--- a/gameServer/HWProtoCore.hs Sat Jan 19 00:55:51 2013 +0400
+++ b/gameServer/HWProtoCore.hs Sat Jan 19 21:51:41 2013 +0400
@@ -41,6 +41,7 @@
return []
where
h ["DELEGATE", n] = handleCmd ["DELEGATE", n]
+ h ["STATS"] = handleCmd ["STATS"]
h c = return [Warning . B.concat . L.intersperse " " $ "Unknown cmd" : c]
handleCmd cmd = do
diff -r 659e043da6da -r fbc6e7602e05 gameServer/HWProtoInRoomState.hs
--- a/gameServer/HWProtoInRoomState.hs Sat Jan 19 00:55:51 2013 +0400
+++ b/gameServer/HWProtoInRoomState.hs Sat Jan 19 21:51:41 2013 +0400
@@ -304,10 +304,15 @@
(thisClientId, rnc) <- ask
maybeClientId <- clientByNick newAdmin
master <- liftM isMaster thisClient
+ serverAdmin <- liftM isAdministrator thisClient
let newAdminId = fromJust maybeClientId
let sameRoom = clientRoom rnc thisClientId == clientRoom rnc newAdminId
return
- [ChangeMaster (Just newAdminId) | master && isJust maybeClientId && (newAdminId /= thisClientId) && sameRoom]
+ [ChangeMaster (Just newAdminId) |
+ (master || serverAdmin)
+ && isJust maybeClientId
+ && ((newAdminId /= thisClientId) || (serverAdmin && not master))
+ && sameRoom]
handleCmd_inRoom ["TEAMCHAT", msg] = do
diff -r 659e043da6da -r fbc6e7602e05 gameServer/HWProtoLobbyState.hs
--- a/gameServer/HWProtoLobbyState.hs Sat Jan 19 00:55:51 2013 +0400
+++ b/gameServer/HWProtoLobbyState.hs Sat Jan 19 21:51:41 2013 +0400
@@ -203,5 +203,8 @@
cl <- thisClient
return [RestartServer | isAdministrator cl]
+handleCmd_lobby ["STATS"] = do
+ cl <- thisClient
+ return [Stats | isAdministrator cl]
handleCmd_lobby _ = return [ProtocolError "Incorrect command (state: in lobby)"]