gameServer/CoreTypes.hs
changeset 8519 98e2dbdda8c0
parent 8509 eda9f2106d8d
child 8897 d6c310c65c91
equal deleted inserted replaced
8517:648bb1cb7ebc 8519:98e2dbdda8c0
     1 {-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}
     1 {-# LANGUAGE CPP, OverloadedStrings, DeriveDataTypeable #-}
     2 module CoreTypes where
     2 module CoreTypes where
     3 
     3 
     4 import Control.Concurrent
     4 import Control.Concurrent
     5 import Data.Word
     5 import Data.Word
     6 import qualified Data.Map as Map
     6 import qualified Data.Map as Map
    10 import Data.ByteString.Char8 as B
    10 import Data.ByteString.Char8 as B
    11 import Data.Unique
    11 import Data.Unique
    12 import Control.Exception
    12 import Control.Exception
    13 import Data.Typeable
    13 import Data.Typeable
    14 import Data.TConfig
    14 import Data.TConfig
       
    15 import Control.DeepSeq
    15 -----------------------
    16 -----------------------
    16 import RoomsAndClients
    17 import RoomsAndClients
       
    18 
       
    19 
       
    20 #if __GLASGOW_HASKELL__ < 706
       
    21 instance NFData B.ByteString
       
    22 #endif
       
    23 
       
    24 instance NFData (Chan a)
       
    25 
       
    26 instance NFData Action where
       
    27     rnf (AnswerClients chans msg) = chans `deepseq` msg `deepseq` ()
       
    28     rnf a = a `seq` ()
       
    29 
       
    30 data Action =
       
    31     AnswerClients ![ClientChan] ![B.ByteString]
       
    32     | SendServerMessage
       
    33     | SendServerVars
       
    34     | MoveToRoom RoomIndex
       
    35     | MoveToLobby B.ByteString
       
    36     | RemoveTeam B.ByteString
       
    37     | SendTeamRemovalMessage B.ByteString
       
    38     | RemoveRoom
       
    39     | FinishGame
       
    40     | UnreadyRoomClients
       
    41     | JoinLobby
       
    42     | ProtocolError B.ByteString
       
    43     | Warning B.ByteString
       
    44     | NoticeMessage Notice
       
    45     | ByeClient B.ByteString
       
    46     | KickClient ClientIndex
       
    47     | KickRoomClient ClientIndex
       
    48     | BanClient NominalDiffTime B.ByteString ClientIndex
       
    49     | BanIP B.ByteString NominalDiffTime B.ByteString
       
    50     | BanNick B.ByteString NominalDiffTime B.ByteString
       
    51     | BanList
       
    52     | Unban B.ByteString
       
    53     | ChangeMaster (Maybe ClientIndex)
       
    54     | RemoveClientTeams
       
    55     | ModifyClient (ClientInfo -> ClientInfo)
       
    56     | ModifyClient2 ClientIndex (ClientInfo -> ClientInfo)
       
    57     | ModifyRoomClients (ClientInfo -> ClientInfo)
       
    58     | ModifyRoom (RoomInfo -> RoomInfo)
       
    59     | ModifyServerInfo (ServerInfo -> ServerInfo)
       
    60     | AddRoom B.ByteString B.ByteString
       
    61     | SendUpdateOnThisRoom
       
    62     | CheckRegistered
       
    63     | ClearAccountsCache
       
    64     | ProcessAccountInfo AccountInfo
       
    65     | AddClient ClientInfo
       
    66     | DeleteClient ClientIndex
       
    67     | PingAll
       
    68     | StatsAction
       
    69     | RestartServer
       
    70     | AddNick2Bans B.ByteString B.ByteString UTCTime
       
    71     | AddIP2Bans B.ByteString B.ByteString UTCTime
       
    72     | CheckBanned Bool
       
    73     | SaveReplay
       
    74     | Stats
       
    75     | CheckRecord
       
    76     | CheckFailed B.ByteString
       
    77     | CheckSuccess [B.ByteString]
    17 
    78 
    18 type ClientChan = Chan [B.ByteString]
    79 type ClientChan = Chan [B.ByteString]
    19 
    80 
    20 data CheckInfo =
    81 data CheckInfo =
    21     CheckInfo
    82     CheckInfo
    45         isAdministrator :: Bool,
   106         isAdministrator :: Bool,
    46         isChecker :: Bool,
   107         isChecker :: Bool,
    47         isKickedFromServer :: Bool,
   108         isKickedFromServer :: Bool,
    48         clientClan :: !(Maybe B.ByteString),
   109         clientClan :: !(Maybe B.ByteString),
    49         checkInfo :: Maybe CheckInfo,
   110         checkInfo :: Maybe CheckInfo,
    50         teamsInGame :: Word
   111         teamsInGame :: Word,
       
   112         actionsPending :: [Action]
    51     }
   113     }
    52 
   114 
    53 instance Eq ClientInfo where
   115 instance Eq ClientInfo where
    54     (==) = (==) `on` clientSocket
   116     (==) = (==) `on` clientSocket
    55 
   117