packages feed

rattletrap 6.3.2 → 6.4.0

raw patch · 7 files changed

+72/−18 lines, 7 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Rattletrap.Type.Content: defaultContent :: Content
+ Rattletrap.Type.Section: toSection :: (a -> Put) -> a -> Section a
- Rattletrap: decodeReplayFile :: ByteString -> Either String Replay
+ Rattletrap: decodeReplayFile :: Bool -> ByteString -> Either String Replay
- Rattletrap: encodeReplayFile :: Replay -> ByteString
+ Rattletrap: encodeReplayFile :: Bool -> Replay -> ByteString
- Rattletrap.Decode.Replay: decodeReplay :: Decode Replay
+ Rattletrap.Decode.Replay: decodeReplay :: Bool -> Decode Replay
- Rattletrap.Utility.Helper: decodeReplayFile :: ByteString -> Either String Replay
+ Rattletrap.Utility.Helper: decodeReplayFile :: Bool -> ByteString -> Either String Replay
- Rattletrap.Utility.Helper: encodeReplayFile :: Replay -> ByteString
+ Rattletrap.Utility.Helper: encodeReplayFile :: Bool -> Replay -> ByteString

Files

library/Rattletrap/Console/Main.hs view
@@ -39,7 +39,7 @@  getDecoder :: Config -> Bytes.ByteString -> Either String Rattletrap.Replay getDecoder config = case getMode config of-  ModeDecode -> Rattletrap.decodeReplayFile+  ModeDecode -> Rattletrap.decodeReplayFile $ configFast config   ModeEncode -> Rattletrap.decodeReplayJson  getEncoder :: Config -> Rattletrap.Replay -> Bytes.ByteString@@ -47,7 +47,7 @@   ModeDecode -> if configCompact config     then LazyBytes.toStrict . Json.encode     else Rattletrap.encodeReplayJson-  ModeEncode -> Rattletrap.encodeReplayFile+  ModeEncode -> Rattletrap.encodeReplayFile $ configFast config  getInput :: Config -> IO Bytes.ByteString getInput config = case configInput config of@@ -82,6 +82,7 @@ options :: [Option] options =   [ compactOption+  , fastOption   , helpOption   , inputOption   , modeOption@@ -96,6 +97,13 @@   (Console.NoArg (\config -> pure config { configCompact = True }))   "minify JSON output" +fastOption :: Option+fastOption = Console.Option+  ['f']+  ["fast"]+  (Console.NoArg (\config -> pure config { configFast = True }))+  "only encode or decode the header"+ helpOption :: Option helpOption = Console.Option   ['h']@@ -148,6 +156,7 @@  data Config = Config   { configCompact :: Bool+  , configFast :: Bool   , configHelp :: Bool   , configInput :: Maybe String   , configMode :: Maybe Mode@@ -158,6 +167,7 @@ defaultConfig :: Config defaultConfig = Config   { configCompact = False+  , configFast = False   , configHelp = False   , configInput = Nothing   , configMode = Nothing
library/Rattletrap/Decode/Replay.hs view
@@ -7,6 +7,8 @@ import Rattletrap.Decode.Content import Rattletrap.Decode.Header import Rattletrap.Decode.Section+import Rattletrap.Encode.Content+import Rattletrap.Type.Content import Rattletrap.Type.Dictionary import Rattletrap.Type.Header import Rattletrap.Type.Int32le@@ -17,15 +19,19 @@ import Rattletrap.Type.Str import Rattletrap.Type.Word32le -decodeReplay :: Decode Replay-decodeReplay = do+decodeReplay :: Bool -> Decode Replay+decodeReplay fast = do   header <- decodeSection decodeHeader-  Replay header <$> decodeSection-    (decodeContent-      (getVersion (sectionBody header))-      (getNumFrames (sectionBody header))-      (getMaxChannels (sectionBody header))-    )+  content <- if fast+    then pure $ toSection putContent defaultContent+    else+      let body = sectionBody header+      in+        decodeSection $ decodeContent+          (getVersion body)+          (getNumFrames body)+          (getMaxChannels body)+  pure $ Replay header content  getVersion :: Header -> (Int, Int, Int) getVersion header =
library/Rattletrap/Type/Content.hs view
@@ -2,6 +2,7 @@  module Rattletrap.Type.Content   ( Content(..)+  , defaultContent   ) where @@ -52,3 +53,19 @@   } deriving (Eq, Ord, Show)  $(deriveJson ''Content)++defaultContent :: Content+defaultContent = Content+  { contentLevels = List []+  , contentKeyFrames = List []+  , contentStreamSize = Word32le 0+  , contentFrames = []+  , contentMessages = List []+  , contentMarks = List []+  , contentPackages = List []+  , contentObjects = List []+  , contentNames = List []+  , contentClassMappings = List []+  , contentCaches = List []+  , contentUnknown = Nothing+  }
library/Rattletrap/Type/Section.hs view
@@ -2,12 +2,19 @@  module Rattletrap.Type.Section   ( Section(..)+  , toSection   ) where  import Rattletrap.Type.Common import Rattletrap.Type.Word32le+import Rattletrap.Utility.Crc +import qualified Data.Binary as Binary+import qualified Data.Binary.Put as Binary+import qualified Data.ByteString as Bytes+import qualified Data.ByteString.Lazy as LazyBytes+ -- | A section is a large piece of a 'Rattletrap.Replay.Replay'. It has a -- 32-bit size (in bytes), a 32-bit CRC (see "Rattletrap.Utility.Crc"), and then a -- bunch of data (the body). This interface is provided so that you don't have@@ -22,3 +29,12 @@   } deriving (Eq, Ord, Show)  $(deriveJson ''Section)++toSection :: (a -> Binary.Put) -> a -> Section a+toSection encode body = let+  bytes = LazyBytes.toStrict . Binary.runPut $ encode body+  in Section+  { sectionSize = Word32le . fromIntegral $ Bytes.length bytes+  , sectionCrc = Word32le $ getCrc32 bytes+  , sectionBody = body+  }
library/Rattletrap/Utility/Helper.hs view
@@ -9,9 +9,12 @@ where  import Rattletrap.Decode.Common+import Rattletrap.Encode.Content import Rattletrap.Decode.Replay import Rattletrap.Encode.Replay import Rattletrap.Type.Replay+import Rattletrap.Type.Section+import Rattletrap.Type.Content  import qualified Data.Aeson as Json import qualified Data.Aeson.Encode.Pretty as Json@@ -20,8 +23,8 @@ import qualified Data.ByteString.Lazy as LazyBytes  -- | Parses a raw replay.-decodeReplayFile :: Bytes.ByteString -> Either String Replay-decodeReplayFile = runDecode decodeReplay+decodeReplayFile :: Bool -> Bytes.ByteString -> Either String Replay+decodeReplayFile fast = runDecode $ decodeReplay fast  -- | Encodes a replay as JSON. encodeReplayJson :: Replay -> Bytes.ByteString@@ -36,6 +39,8 @@ decodeReplayJson = Json.eitherDecodeStrict'  -- | Encodes a raw replay.-encodeReplayFile :: Replay -> Bytes.ByteString-encodeReplayFile replay =-  LazyBytes.toStrict (Binary.runPut (putReplay replay))+encodeReplayFile :: Bool -> Replay -> Bytes.ByteString+encodeReplayFile fast replay =+  LazyBytes.toStrict . Binary.runPut . putReplay $ if fast+    then replay { replayContent = toSection putContent defaultContent }+    else replay
package.yaml view
@@ -1,5 +1,5 @@ name: rattletrap-version: 6.3.2+version: 6.4.0  category: Game description: Rattletrap parses and generates Rocket League replays.
rattletrap.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: d1e9e72fdcd895e0e8ec255f4395621556c0110c943adcf27ce20d71afe2e849+-- hash: 63f9e1d505db6c0f8a8dc124bd223add14a91d41451c9f8d86a0b5b6e21ece6a  name:           rattletrap-version:        6.3.2+version:        6.4.0 synopsis:       Parse and generate Rocket League replays. description:    Rattletrap parses and generates Rocket League replays. category:       Game