# HG changeset patch
# User unc0rr
# Date 1359319800 -14400
# Node ID 170afc3ac39ff7e8e677f0e538c40c717a5a2d24
# Parent 8c7da08df048b5b7657618f1db75fc384d1ef60a
Also rooms per version stats
diff -r 8c7da08df048 -r 170afc3ac39f gameServer/Actions.hs
--- a/gameServer/Actions.hs Sun Jan 27 21:46:25 2013 +0400
+++ b/gameServer/Actions.hs Mon Jan 28 00:50:00 2013 +0400
@@ -85,7 +85,7 @@
rnf (AnswerClients chans msg) = chans `deepseq` msg `deepseq` ()
rnf a = a `seq` ()
---instance NFData B.ByteString
+instance NFData B.ByteString
instance NFData (Chan a)
@@ -648,12 +648,19 @@
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))
+ rms <- allRoomsS
+ let clientsMap = Map.fromListWith (+) . map (\c -> (clientProto c, 1 :: Int)) $ cls
+ let roomsMap = Map.fromListWith (+) . map (\c -> (roomProto c, 1 :: Int)) . filter ((/=) 0 . roomProto) $ rms
+ let keys = Map.keysSet clientsMap `Set.union` Map.keysSet roomsMap
+ let versionsStats = B.concat . ((:) ""])
+ . concatMap (\p -> [
+ "", protoNumber2ver p
+ , " | ", showB $ Map.findWithDefault 0 p clientsMap
+ , " | ", showB $ Map.findWithDefault 0 p roomsMap
+ , " |
"])
+ . Set.toList $ keys
+ processAction $ Warning versionsStats
+
#if defined(OFFICIAL_SERVER)
processAction SaveReplay = do
diff -r 8c7da08df048 -r 170afc3ac39f gameServer/RoomsAndClients.hs
--- a/gameServer/RoomsAndClients.hs Sun Jan 27 21:46:25 2013 +0400
+++ b/gameServer/RoomsAndClients.hs Mon Jan 28 00:50:00 2013 +0400
@@ -23,6 +23,7 @@
room'sM,
allClientsM,
clientsM,
+ roomsM,
roomClientsM,
roomClientsIndicesM,
withRoomsAndClients,
@@ -160,6 +161,9 @@
clientsM :: MRoomsAndClients r c -> IO [c]
clientsM (MRoomsAndClients (_, clients)) = indicesM clients >>= mapM (liftM client' . readElem clients)
+roomsM :: MRoomsAndClients r c -> IO [r]
+roomsM (MRoomsAndClients (rooms, _)) = indicesM rooms >>= mapM (liftM room' . readElem rooms)
+
roomClientsIndicesM :: MRoomsAndClients r c -> RoomIndex -> IO [ClientIndex]
roomClientsIndicesM (MRoomsAndClients (rooms, _)) (RoomIndex ri) = liftM roomClients' (rooms `readElem` ri)
diff -r 8c7da08df048 -r 170afc3ac39f gameServer/ServerState.hs
--- a/gameServer/ServerState.hs Sun Jan 27 21:46:25 2013 +0400
+++ b/gameServer/ServerState.hs Mon Jan 28 00:50:00 2013 +0400
@@ -5,6 +5,7 @@
ServerState(..),
client's,
allClientsS,
+ allRoomsS,
roomClientsS,
sameProtoClientsS,
io
@@ -40,6 +41,9 @@
allClientsS :: StateT ServerState IO [ClientInfo]
allClientsS = gets roomsClients >>= liftIO . clientsM
+allRoomsS :: StateT ServerState IO [RoomInfo]
+allRoomsS = gets roomsClients >>= liftIO . roomsM
+
roomClientsS :: RoomIndex -> StateT ServerState IO [ClientInfo]
roomClientsS ri = do
rnc <- gets roomsClients