gameServer/Actions.hs
changeset 14287 9f0d81213d65
parent 13730 5f62417a7d84
child 14359 5e28098fb593
equal deleted inserted replaced
14286:7a7c090f96f6 14287:9f0d81213d65
    41 import System.Random
    41 import System.Random
    42 import qualified Data.Traversable as DT
    42 import qualified Data.Traversable as DT
    43 import Text.Regex.TDFA
    43 import Text.Regex.TDFA
    44 import qualified Text.Regex.TDFA as TDFA
    44 import qualified Text.Regex.TDFA as TDFA
    45 import qualified Text.Regex.TDFA.ByteString as TDFAB
    45 import qualified Text.Regex.TDFA.ByteString as TDFAB
    46 import qualified Data.Yaml as YAML
       
    47 -----------------------------
    46 -----------------------------
    48 #if defined(OFFICIAL_SERVER)
    47 #if defined(OFFICIAL_SERVER)
    49 import OfficialServer.GameReplayStore
    48 import OfficialServer.GameReplayStore
       
    49 import qualified Data.Yaml as YAML
    50 #endif
    50 #endif
    51 import CoreTypes
    51 import CoreTypes
    52 import Utils
    52 import Utils
    53 import ClientIO
    53 import ClientIO
    54 import ServerState
    54 import ServerState
   818     (Just ci) <- gets clientIndex
   818     (Just ci) <- gets clientIndex
   819     si <- gets serverInfo
   819     si <- gets serverInfo
   820     uid <- client's clUID
   820     uid <- client's clUID
   821     io $ writeChan (dbQueries si) $ GetReplayName ci (hashUnique uid) rname
   821     io $ writeChan (dbQueries si) $ GetReplayName ci (hashUnique uid) rname
   822 
   822 
   823 #else
       
   824 processAction SaveReplay = return ()
       
   825 processAction CheckRecord = return ()
       
   826 processAction (CheckFailed _) = return ()
       
   827 processAction (CheckSuccess _) = return ()
       
   828 processAction (QueryReplay _) = processAction $ Warning $ loc "This server does not support replays!"
       
   829 #endif
       
   830 
       
   831 processAction (ShowReplay rname) = do
   823 processAction (ShowReplay rname) = do
   832     c <- client's sendChan
   824     c <- client's sendChan
   833     cl <- client's id
   825     cl <- client's id
   834 
   826 
   835     let fileName = B.concat ["checked/", if B.isPrefixOf "replays/" rname then B.drop 8 rname else rname]
   827     let fileName = B.concat ["checked/", if B.isPrefixOf "replays/" rname then B.drop 8 rname else rname]
   858     liftIO $ YAML.encodeFile (B.unpack rname) (greeting rm, roomSaves rm)
   850     liftIO $ YAML.encodeFile (B.unpack rname) (greeting rm, roomSaves rm)
   859 
   851 
   860 processAction (LoadRoom rname) = do
   852 processAction (LoadRoom rname) = do
   861     Right (g, rs) <- io $ YAML.decodeFileEither (B.unpack rname)
   853     Right (g, rs) <- io $ YAML.decodeFileEither (B.unpack rname)
   862     processAction $ ModifyRoom $ \r -> r{greeting = g, roomSaves = rs}
   854     processAction $ ModifyRoom $ \r -> r{greeting = g, roomSaves = rs}
       
   855 	
       
   856 #else
       
   857 processAction SaveReplay = return ()
       
   858 processAction CheckRecord = return ()
       
   859 processAction (CheckFailed _) = return ()
       
   860 processAction (CheckSuccess _) = return ()
       
   861 processAction (QueryReplay _) = processAction $ Warning $ loc "This server does not support replays!"
       
   862 processAction (ShowReplay rname) = return ()
       
   863 processAction (SaveRoom rname) = return ()
       
   864 processAction (LoadRoom rname) = return ()
       
   865 #endif
   863 
   866 
   864 processAction Cleanup = do
   867 processAction Cleanup = do
   865     jm <- gets joinsMonitor
   868     jm <- gets joinsMonitor
   866 
   869 
   867     io $ do
   870     io $ do