727 n <- io $ randomRIO (0, length i - 1) |
727 n <- io $ randomRIO (0, length i - 1) |
728 processAction $ AnswerClients chans ["CHAT", "[random]", i !! n] |
728 processAction $ AnswerClients chans ["CHAT", "[random]", i !! n] |
729 |
729 |
730 |
730 |
731 processAction (LoadGhost location) = do |
731 processAction (LoadGhost location) = do |
732 points <- io $ loadFile (B.unpack $ "ghosts/" `B.append` sanitizeName location) |
|
733 ri <- clientRoomA |
732 ri <- clientRoomA |
734 rnc <- gets roomsClients |
733 rnc <- gets roomsClients |
735 thisRoomChans <- liftM (map sendChan) $ roomClientsS ri |
734 thisRoomChans <- liftM (map sendChan) $ roomClientsS ri |
736 rm <- io $ room'sM rnc id ri |
735 rm <- io $ room'sM rnc id ri |
|
736 #if defined(OFFICIAL_SERVER) |
|
737 points <- io $ loadFile (B.unpack $ "ghosts/" `B.append` sanitizeName location) |
737 when (roomProto rm > 51) $ do |
738 when (roomProto rm > 51) $ do |
738 processAction $ ModifyRoom $ \r -> r{params = Map.insert "DRAWNMAP" [prependGhostPoints (toP points) $ head $ (params r) Map.! "DRAWNMAP"] (params r)} |
739 processAction $ ModifyRoom $ \r -> r{params = Map.insert "DRAWNMAP" [prependGhostPoints (toP points) $ head $ (params r) Map.! "DRAWNMAP"] (params r)} |
739 -- inject ghost points into map |
740 #endif |
740 cl <- client's id |
741 cl <- client's id |
741 mapM_ processAction $ map (replaceChans thisRoomChans) $ answerFullConfigParams cl (mapParams rm) (params rm) |
742 mapM_ processAction $ map (replaceChans thisRoomChans) $ answerFullConfigParams cl (mapParams rm) (params rm) |
742 where |
743 where |
743 loadFile :: String -> IO [Int] |
744 loadFile :: String -> IO [Int] |
744 loadFile fileName = E.handle (\(e :: SomeException) -> return []) $ do |
745 loadFile fileName = E.handle (\(e :: SomeException) -> return []) $ do |