gameServer/CoreTypes.hs
branchqmlfrontend
changeset 11481 caa1e84c3ac2
parent 11467 f2c36df8c7b1
child 11556 af9aa8d5863c
equal deleted inserted replaced
11480:b0c34402038c 11481:caa1e84c3ac2
   124     }
   124     }
   125 
   125 
   126 data ClientInfo =
   126 data ClientInfo =
   127     ClientInfo
   127     ClientInfo
   128     {
   128     {
   129         clUID :: Unique,
   129         clUID :: !Unique,
   130         sendChan :: ClientChan,
   130         sendChan :: !ClientChan,
   131         clientSocket :: Socket,
   131         clientSocket :: !Socket,
   132         host :: B.ByteString,
   132         host :: !B.ByteString,
   133         connectTime :: UTCTime,
   133         connectTime :: !UTCTime,
   134         nick :: B.ByteString,
   134         nick :: !B.ByteString,
   135         webPassword :: B.ByteString,
   135         webPassword :: !B.ByteString,
   136         serverSalt :: B.ByteString,
   136         serverSalt :: !B.ByteString,
   137         logonPassed :: Bool,
   137         logonPassed :: !Bool,
   138         isVisible :: Bool,
   138         isVisible :: !Bool,
   139         clientProto :: !Word16,
   139         clientProto :: !Word16,
   140         pingsQueue :: !Word,
   140         pingsQueue :: !Word,
   141         isMaster :: Bool,
   141         isMaster :: !Bool,
   142         isReady :: !Bool,
   142         isReady :: !Bool,
   143         isInGame :: Bool,
   143         isInGame :: !Bool,
   144         isAdministrator :: Bool,
   144         isAdministrator :: !Bool,
   145         isChecker :: Bool,
   145         hasSuperPower :: !Bool,
   146         isContributor :: Bool,
   146         isChecker :: !Bool,
   147         isKickedFromServer :: Bool,
   147         isContributor :: !Bool,
   148         isJoinedMidGame :: Bool,
   148         isKickedFromServer :: !Bool,
       
   149         isJoinedMidGame :: !Bool,
       
   150         hasAskedList :: !Bool,
   149         clientClan :: !(Maybe B.ByteString),
   151         clientClan :: !(Maybe B.ByteString),
   150         checkInfo :: Maybe CheckInfo,
   152         checkInfo :: !(Maybe CheckInfo),
   151         eiLobbyChat,
   153         eiLobbyChat,
   152         eiEM,
   154         eiEM,
   153         eiJoin :: EventsInfo,
   155         eiJoin :: !EventsInfo,
   154         teamsInGame :: Word
   156         teamsInGame :: !Word,
       
   157         pendingActions :: ![Action]
   155     }
   158     }
   156 
   159 
   157 instance Eq ClientInfo where
   160 instance Eq ClientInfo where
   158     (==) = (==) `on` clientSocket
   161     (==) = (==) `on` clientSocket
   159 
   162 
   162     deriving (Show, Read)
   165     deriving (Show, Read)
   163 
   166 
   164 data TeamInfo =
   167 data TeamInfo =
   165     TeamInfo
   168     TeamInfo
   166     {
   169     {
   167         teamowner :: B.ByteString,
   170         teamowner :: !B.ByteString,
   168         teamname :: B.ByteString,
   171         teamname :: !B.ByteString,
   169         teamcolor :: B.ByteString,
   172         teamcolor :: !B.ByteString,
   170         teamgrave :: B.ByteString,
   173         teamgrave :: !B.ByteString,
   171         teamfort :: B.ByteString,
   174         teamfort :: !B.ByteString,
   172         teamvoicepack :: B.ByteString,
   175         teamvoicepack :: !B.ByteString,
   173         teamflag :: B.ByteString,
   176         teamflag :: !B.ByteString,
   174         isOwnerRegistered :: Bool,
   177         isOwnerRegistered :: !Bool,
   175         difficulty :: Int,
   178         difficulty :: !Int,
   176         hhnum :: Int,
   179         hhnum :: !Int,
   177         hedgehogs :: [HedgehogInfo]
   180         hedgehogs :: ![HedgehogInfo]
   178     }
   181     }
   179     deriving (Show, Read)
   182     deriving (Show, Read)
   180 
   183 
   181 instance Eq TeamInfo where
   184 instance Eq TeamInfo where
   182     (==) = (==) `on` teamname
   185     (==) = (==) `on` teamname
   212 
   215 
   213 
   216 
   214 data RoomInfo =
   217 data RoomInfo =
   215     RoomInfo
   218     RoomInfo
   216     {
   219     {
   217         masterID :: Maybe ClientIndex,
   220         masterID :: !(Maybe ClientIndex),
   218         name :: B.ByteString,
   221         name :: !B.ByteString,
   219         password :: B.ByteString,
   222         password :: !B.ByteString,
   220         roomProto :: Word16,
   223         roomProto :: !Word16,
   221         teams :: [TeamInfo],
   224         teams :: ![TeamInfo],
   222         gameInfo :: Maybe GameInfo,
   225         gameInfo :: !(Maybe GameInfo),
   223         playersIn :: !Int,
   226         playersIn :: !Int,
   224         readyPlayers :: !Int,
   227         readyPlayers :: !Int,
   225         isRestrictedJoins :: Bool,
   228         isRestrictedJoins :: !Bool,
   226         isRestrictedTeams :: Bool,
   229         isRestrictedTeams :: !Bool,
   227         isRegisteredOnly :: Bool,
   230         isRegisteredOnly :: !Bool,
   228         isSpecial :: Bool,
   231         isSpecial :: !Bool,
   229         defaultHedgehogsNumber :: Int,
   232         defaultHedgehogsNumber :: !Int,
   230         teamsNumberLimit :: Int,
   233         teamsNumberLimit :: !Int,
   231         greeting :: B.ByteString,
   234         greeting :: !B.ByteString,
   232         voting :: Maybe Voting,
   235         voting :: !(Maybe Voting),
   233         roomBansList :: ![B.ByteString],
   236         roomBansList :: ![B.ByteString],
   234         mapParams :: Map.Map B.ByteString B.ByteString,
   237         mapParams :: !(Map.Map B.ByteString B.ByteString),
   235         params :: Map.Map B.ByteString [B.ByteString],
   238         params :: !(Map.Map B.ByteString [B.ByteString]),
   236         roomSaves :: Map.Map B.ByteString (Map.Map B.ByteString B.ByteString, Map.Map B.ByteString [B.ByteString])
   239         roomSaves :: !(Map.Map B.ByteString (Map.Map B.ByteString B.ByteString, Map.Map B.ByteString [B.ByteString]))
   237     }
   240     }
   238 
   241 
   239 newRoom :: RoomInfo
   242 newRoom :: RoomInfo
   240 newRoom =
   243 newRoom =
   241     RoomInfo
   244     RoomInfo
   278 
   281 
   279 data ServerInfo =
   282 data ServerInfo =
   280     ServerInfo
   283     ServerInfo
   281     {
   284     {
   282         isDedicated :: Bool,
   285         isDedicated :: Bool,
       
   286         isRegisteredUsersOnly :: Bool,
   283         serverMessage :: B.ByteString,
   287         serverMessage :: B.ByteString,
   284         serverMessageForOldVersions :: B.ByteString,
   288         serverMessageForOldVersions :: B.ByteString,
   285         latestReleaseVersion :: Word16,
   289         latestReleaseVersion :: Word16,
   286         earliestCompatibleVersion :: Word16,
   290         earliestCompatibleVersion :: Word16,
   287         listenPort :: PortNumber,
   291         listenPort :: PortNumber,
   301 
   305 
   302 newServerInfo :: Chan CoreMessage -> Chan DBQuery -> Maybe Socket -> Maybe Conf -> ServerInfo
   306 newServerInfo :: Chan CoreMessage -> Chan DBQuery -> Maybe Socket -> Maybe Conf -> ServerInfo
   303 newServerInfo =
   307 newServerInfo =
   304     ServerInfo
   308     ServerInfo
   305         True
   309         True
       
   310         False
   306         "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
   311         "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
   307         "<font color=yellow><h3 align=center>Hedgewars 0.9.22 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
   312         "<font color=yellow><h3 align=center>Hedgewars 0.9.22 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
   308         51 -- latestReleaseVersion
   313         51 -- latestReleaseVersion
   309         41 -- earliestCompatibleVersion
   314         41 -- earliestCompatibleVersion
   310         46631
   315         46631