gameServer/Actions.hs
changeset 11582 bee3a2f8e117
parent 11580 db7743e2fad1
child 11585 c8edd93b970f
equal deleted inserted replaced
11581:134113bff264 11582:bee3a2f8e117
   731 processAction (LoadGhost location) = do
   731 processAction (LoadGhost location) = do
   732     points <- io $ loadFile (B.unpack $ "ghosts/" `B.append` sanitizeName location)
   732     points <- io $ loadFile (B.unpack $ "ghosts/" `B.append` sanitizeName location)
   733     ri <- clientRoomA
   733     ri <- clientRoomA
   734     rnc <- gets roomsClients
   734     rnc <- gets roomsClients
   735     thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
   735     thisRoomChans <- liftM (map sendChan) $ roomClientsS ri
       
   736     rm <- io $ room'sM rnc id ri
       
   737     when (roomProto rm > 51) $ do
       
   738         processAction $ ModifyRoom $ \r -> r{params = Map.insert "DRAWNMAP" [prependGhostPoints (toP points) $ head $ (params r) Map.! "DRAWNMAP"] (params r)}
   736     -- inject ghost points into map
   739     -- inject ghost points into map
   737     rm <- io $ room'sM rnc id ri
       
   738     cl <- client's id
   740     cl <- client's id
   739     mapM processAction $ map (replaceChans thisRoomChans) $ answerFullConfigParams cl (mapParams rm) (params rm)
   741     mapM_ processAction $ map (replaceChans thisRoomChans) $ answerFullConfigParams cl (mapParams rm) (params rm)
   740     return ()
       
   741     where
   742     where
   742     loadFile :: String -> IO [Int]
   743     loadFile :: String -> IO [Int]
   743     loadFile fileName = E.handle (\(e :: SomeException) -> return []) $ do
   744     loadFile fileName = E.handle (\(e :: SomeException) -> return []) $ do
   744         points <- liftM read $ readFile fileName
   745         points <- liftM read $ readFile fileName
   745         return (points `deepseq` points)
   746         return (points `deepseq` points)
   746     replaceChans chans (AnswerClients _ msg) = AnswerClients chans msg
   747     replaceChans chans (AnswerClients _ msg) = AnswerClients chans msg
   747     replaceChans _ a = a
   748     replaceChans _ a = a
       
   749     toP [] = []
       
   750     toP (p1:p2:ps) = (fromIntegral p1, fromIntegral p2) : toP ps
   748 {-
   751 {-
   749         let a = map (replaceChans chans) $ answerFullConfigParams cl mp p
   752         let a = map (replaceChans chans) $ answerFullConfigParams cl mp p
   750 -}
   753 -}
   751 #if defined(OFFICIAL_SERVER)
   754 #if defined(OFFICIAL_SERVER)
   752 processAction SaveReplay = do
   755 processAction SaveReplay = do