gameServer/ServerState.hs
changeset 6541 08ed346ed341
parent 4989 4771fed9272e
child 8371 0551b5c3de9a
equal deleted inserted replaced
6540:d04601edf73d 6541:08ed346ed341
     4     clientRoomA,
     4     clientRoomA,
     5     ServerState(..),
     5     ServerState(..),
     6     client's,
     6     client's,
     7     allClientsS,
     7     allClientsS,
     8     roomClientsS,
     8     roomClientsS,
       
     9     sameProtoClientsS,
     9     io
    10     io
    10     ) where
    11     ) where
    11 
    12 
    12 import Control.Monad.State.Strict
    13 import Control.Monad.State.Strict
    13 import Data.Set as Set
    14 import Data.Set as Set(Set)
       
    15 import Data.Word
    14 ----------------------
    16 ----------------------
    15 import RoomsAndClients
    17 import RoomsAndClients
    16 import CoreTypes
    18 import CoreTypes
    17 
    19 
    18 data ServerState = ServerState {
    20 data ServerState = ServerState {
    41 roomClientsS :: RoomIndex -> StateT ServerState IO [ClientInfo]
    43 roomClientsS :: RoomIndex -> StateT ServerState IO [ClientInfo]
    42 roomClientsS ri = do
    44 roomClientsS ri = do
    43     rnc <- gets roomsClients
    45     rnc <- gets roomsClients
    44     io $ roomClientsM rnc ri
    46     io $ roomClientsM rnc ri
    45 
    47 
       
    48 sameProtoClientsS :: Word16 -> StateT ServerState IO [ClientInfo]
       
    49 sameProtoClientsS p = liftM f allClientsS
       
    50     where
       
    51         f = filter (\c -> clientProto c == p)
       
    52     
    46 io :: IO a -> StateT ServerState IO a
    53 io :: IO a -> StateT ServerState IO a
    47 io = liftIO
    54 io = liftIO