# HG changeset patch # User unc0rr # Date 1358712446 -14400 # Node ID 2784b2610b5c01c687946381a78af666a331e390 # Parent fbc6e7602e0517a8371470794089d3c2bb85dcb0# Parent 286823b10f355f7b15b454b4eeed43f38a368eea Merge diff -r 286823b10f35 -r 2784b2610b5c gameServer/Actions.hs --- a/gameServer/Actions.hs Sat Jan 19 20:01:01 2013 -0500 +++ b/gameServer/Actions.hs Mon Jan 21 00:07:26 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 . ((:) "<table border=1>") . (flip (++) ["</table>"]) + . concatMap (\(p, n :: Int) -> ["<tr><td>", protoNumber2ver p, "</td><td>", showB n, "</td></tr>"]) + . Map.toList . Map.fromListWith (+) . map (\c -> (clientProto c, 1)) + #if defined(OFFICIAL_SERVER) processAction SaveReplay = do ri <- clientRoomA diff -r 286823b10f35 -r 2784b2610b5c gameServer/HWProtoCore.hs --- a/gameServer/HWProtoCore.hs Sat Jan 19 20:01:01 2013 -0500 +++ b/gameServer/HWProtoCore.hs Mon Jan 21 00:07:26 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 286823b10f35 -r 2784b2610b5c gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Sat Jan 19 20:01:01 2013 -0500 +++ b/gameServer/HWProtoInRoomState.hs Mon Jan 21 00:07:26 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 286823b10f35 -r 2784b2610b5c gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Sat Jan 19 20:01:01 2013 -0500 +++ b/gameServer/HWProtoLobbyState.hs Mon Jan 21 00:07:26 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)"]