gameServer/CoreTypes.hs
changeset 4963 59c2489afcbd
parent 4960 3b54b1c9b768
child 4975 31da8979e5b1
equal deleted inserted replaced
4958:84afe376a3b3 4963:59c2489afcbd
     1 {-# LANGUAGE OverloadedStrings #-}
     1 {-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}
     2 module CoreTypes where
     2 module CoreTypes where
     3 
     3 
     4 import Control.Concurrent
     4 import Control.Concurrent
     5 import Control.Concurrent.STM
       
     6 import Data.Word
     5 import Data.Word
     7 import qualified Data.Map as Map
     6 import qualified Data.Map as Map
     8 import Data.Sequence(Seq, empty)
     7 import Data.Sequence(Seq, empty)
     9 import Data.Time
     8 import Data.Time
    10 import Network
     9 import Network
    11 import Data.Function
    10 import Data.Function
    12 import Data.ByteString.Char8 as B
    11 import Data.ByteString.Char8 as B
    13 import Data.Unique
    12 import Data.Unique
    14 
    13 import Control.Exception
       
    14 import Data.Typeable
       
    15 -----------------------
    15 import RoomsAndClients
    16 import RoomsAndClients
    16 
    17 
    17 type ClientChan = Chan [B.ByteString]
    18 type ClientChan = Chan [B.ByteString]
    18 
    19 
    19 data ClientInfo =
    20 data ClientInfo =
   133         nextRoomID :: Int,
   134         nextRoomID :: Int,
   134         dbHost :: B.ByteString,
   135         dbHost :: B.ByteString,
   135         dbLogin :: B.ByteString,
   136         dbLogin :: B.ByteString,
   136         dbPassword :: B.ByteString,
   137         dbPassword :: B.ByteString,
   137         lastLogins :: [(B.ByteString, (UTCTime, B.ByteString))],
   138         lastLogins :: [(B.ByteString, (UTCTime, B.ByteString))],
   138         stats :: TMVar StatisticsInfo,
   139         restartPending :: Bool,
   139         coreChan :: Chan CoreMessage,
   140         coreChan :: Chan CoreMessage,
   140         dbQueries :: Chan DBQuery
   141         dbQueries :: Chan DBQuery
   141     }
   142     }
   142 
   143 
   143 instance Show ServerInfo where
   144 instance Show ServerInfo where
   144     show _ = "Server Info"
   145     show _ = "Server Info"
   145 
   146 
   146 newServerInfo :: TMVar StatisticsInfo -> Chan CoreMessage -> Chan DBQuery -> ServerInfo
   147 newServerInfo :: Chan CoreMessage -> Chan DBQuery -> ServerInfo
   147 newServerInfo =
   148 newServerInfo =
   148     ServerInfo
   149     ServerInfo
   149         True
   150         True
   150         "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
   151         "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
   151         "<font color=yellow><h3 align=center>Hedgewars 0.9.14.1 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
   152         "<font color=yellow><h3 align=center>Hedgewars 0.9.14.1 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
   154         0
   155         0
   155         ""
   156         ""
   156         ""
   157         ""
   157         ""
   158         ""
   158         []
   159         []
       
   160         False
   159 
   161 
   160 data AccountInfo =
   162 data AccountInfo =
   161     HasAccount B.ByteString Bool
   163     HasAccount B.ByteString Bool
   162     | Guest
   164     | Guest
   163     | Admin
   165     | Admin
   188 
   190 
   189 data Notice =
   191 data Notice =
   190     NickAlreadyInUse
   192     NickAlreadyInUse
   191     | AdminLeft
   193     | AdminLeft
   192     deriving Enum
   194     deriving Enum
       
   195 
       
   196 data ShutdownException =
       
   197     ShutdownException
       
   198     | RestartException
       
   199      deriving (Show, Typeable)
       
   200 
       
   201 instance Exception ShutdownException