--- a/gameServer/Actions.hs Thu Mar 27 23:25:31 2014 +0400
+++ b/gameServer/Actions.hs Fri Mar 28 11:02:06 2014 +0400
@@ -35,7 +35,7 @@
import EngineInteraction
import FloodDetection
import HWProtoCore
-
+import Votes
othersChans :: StateT ServerState IO [ClientChan]
othersChans = do
--- a/gameServer/RoomsAndClients.hs Thu Mar 27 23:25:31 2014 +0400
+++ b/gameServer/RoomsAndClients.hs Fri Mar 28 11:02:06 2014 +0400
@@ -22,6 +22,7 @@
client'sM,
room'sM,
allClientsM,
+ allRoomsM,
clientsM,
roomsM,
roomClientsM,
--- a/gameServer/Votes.hs Thu Mar 27 23:25:31 2014 +0400
+++ b/gameServer/Votes.hs Fri Mar 28 11:02:06 2014 +0400
@@ -2,7 +2,7 @@
module Votes where
import Control.Monad.Reader
-import Control.Monad.State
+import Control.Monad.State.Strict
import ServerState
import qualified Data.ByteString.Char8 as B
import qualified Data.List as L
@@ -93,10 +93,9 @@
checkVotes :: StateT ServerState IO [Action]
checkVotes = do
rnc <- gets roomsClients
- io $ do
+ liftM concat $ io $ do
ris <- allRoomsM rnc
- actions <- mapM (check rnc) ris
- mapM_ processAction actions
+ mapM (check rnc) ris
where
check rnc ri = do
e <- room'sM rnc voting ri
@@ -104,11 +103,11 @@
Just rv -> do
modifyRoom rnc (\r -> r{voting = if voteTTL rv == 0 then Nothing else Just rv{voteTTL = voteTTL rv - 1}}) ri
if voteTTL rv == 0 then do
- chans <- liftM sendChan $ roomClientsM rnc ri
+ chans <- liftM (map sendChan) $ roomClientsM rnc ri
return [AnswerClients chans ["CHAT", "[server]", loc "Voting expired"]]
else
return []
- Nothing -> return []
+ Nothing -> return []
voteInfo :: VoteType -> B.ByteString