gameServer/Actions.hs
changeset 5143 649d87819682
parent 5119 f475e10c4081
child 5184 bf7bba60ed93
equal deleted inserted replaced
5142:cb822f8d52ff 5143:649d87819682
    15 import qualified Data.ByteString.Char8 as B
    15 import qualified Data.ByteString.Char8 as B
    16 import Control.DeepSeq
    16 import Control.DeepSeq
    17 import Data.Unique
    17 import Data.Unique
    18 import Control.Arrow
    18 import Control.Arrow
    19 import Control.Exception
    19 import Control.Exception
       
    20 import OfficialServer.GameReplayStore
    20 -----------------------------
    21 -----------------------------
    21 import CoreTypes
    22 import CoreTypes
    22 import Utils
    23 import Utils
    23 import ClientIO
    24 import ClientIO
    24 import ServerState
    25 import ServerState
    58     | StatsAction
    59     | StatsAction
    59     | RestartServer Bool
    60     | RestartServer Bool
    60     | AddNick2Bans B.ByteString B.ByteString UTCTime
    61     | AddNick2Bans B.ByteString B.ByteString UTCTime
    61     | AddIP2Bans B.ByteString B.ByteString UTCTime
    62     | AddIP2Bans B.ByteString B.ByteString UTCTime
    62     | CheckBanned
    63     | CheckBanned
       
    64     | SaveReplay
    63 
    65 
    64 
    66 
    65 type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action]
    67 type CmdHandler = [B.ByteString] -> Reader (ClientIndex, IRnC) [Action]
    66 
    68 
    67 instance NFData Action where
    69 instance NFData Action where
   468 processAction (RestartServer force) = do
   470 processAction (RestartServer force) = do
   469     if force then do
   471     if force then do
   470         throw RestartException
   472         throw RestartException
   471         else
   473         else
   472         processAction $ ModifyServerInfo (\s -> s{restartPending=True})
   474         processAction $ ModifyServerInfo (\s -> s{restartPending=True})
       
   475 
       
   476 processAction SaveReplay = do
       
   477     ri <- clientRoomA
       
   478     rnc <- gets roomsClients
       
   479     io $ do
       
   480         r <- room'sM rnc id ri
       
   481         saveReplay r