LambdaHack-0.11.0.1: A game engine library for tactical squad ASCII roguelike dungeon crawlers

Safe Haskell | None
Language | Haskell2010

Game.LambdaHack.Common.Save

Contents

- Internal operations

Description

Saving and restoring game state, used by both server and clients.

Synopsis

- type ChanSave a = MVar (Maybe a)
- saveToChan :: ChanSave a -> a -> IO ()
- wrapInSaves :: Binary a => COps -> (a -> FilePath) -> (ChanSave a -> IO ()) -> IO ()
- restoreGame :: Binary a => RuleContent -> ClientOptions -> FilePath -> IO (Maybe a)
- compatibleVersion :: Version -> Version -> Bool
- delayPrint :: Text -> IO ()
- saveNameCli :: RuleContent -> FactionId -> String
- saveNameSer :: RuleContent -> String
- bkpAllSaves :: RuleContent -> ClientOptions -> IO Bool
- loopSave :: Binary a => COps -> (a -> FilePath) -> ChanSave a -> IO ()

# Documentation

type ChanSave a = MVar (Maybe a) Source #

saveToChan :: ChanSave a -> a -> IO () Source #

wrapInSaves :: Binary a => COps -> (a -> FilePath) -> (ChanSave a -> IO ()) -> IO () Source #

restoreGame :: Binary a => RuleContent -> ClientOptions -> FilePath -> IO (Maybe a) Source #

Restore a saved game, if it exists. Initialize directory structure and copy over data files, if needed.

compatibleVersion :: Version -> Version -> Bool Source #

delayPrint :: Text -> IO () Source #

saveNameCli :: RuleContent -> FactionId -> String Source #

saveNameSer :: RuleContent -> String Source #

bkpAllSaves :: RuleContent -> ClientOptions -> IO Bool Source #

# Internal operations

loopSave :: Binary a => COps -> (a -> FilePath) -> ChanSave a -> IO () Source #

Repeatedly save serialized snapshots of current state.

Running with `-N2` ca reduce `Max pause` from 0.2s to 0.01s and `bytes copied during GC` 10-fold, but framerate nor the frequency of not making a backup save are unaffected (at standard backup settings), even with null frontend, because saving takes so few resources. So, generally, backup save settings are relevant only due to latency impact on very slow computers or in JS.