Crate s2protocol

source ·
Expand description

S2 Protocol use of the MPQ archive

Re-exports§

Modules§

  • Arrow Specific handling of data.
  • The Bit Packed Decoder. As a difference to the Versioned Decoder, the fields are not tagged.
  • A collection of transformed enum variants to u8s. This is done for space efficiency in the Arrow IPC file.
  • Decodes the Details.
  • Error handling of S2Protocol
  • Provides way to provide common filter operations. This should be use in combination with the iterators and filter(), but helps a lot of the code required to match and dive into types.
  • Decodes the Game Events. These are stored in an embedded file in the MPQ file called ‘replay.game.events’
  • ABANDON ALL HOPE, YE WHO ENTER HERE
  • Decodes the initData
  • Decodes the Message Events. These are stored in an embedded file in the MPQ file called ‘replay.message.events’ Somehow it should 4 bits instead of 3 bits for the GameEMessageId… In our code it translates to 3 bits needed to represent 5 possible enum variants.
  • Re-export to avoid having to also add this crate to other consumers. Nom Parsing the MPQ file format
  • Nom Parsing The S2 Protocol Version This is stored in the MPQ UserData Section and can be decoded with any Protocol Version Decoder. In the original code, in s2protocol from Blizzard, each protocol version has its own version decoder. and whatever protocol is latest would decoded the target file. In this verison we are not yet doing that but we should.
  • Handling of state of SC2 Replay as it steps through game loops
  • Decodes the Tracker Events. These are stored in an embebdded file in the MPQ file called ‘replay.tracker.events’
  • The versioned decoder. The fields on versioned structures are prepend by tags.
  • The known protocol versions

Macros§

  • Many fields are optional, this macro will return an Ok for the nom::IResult but the value will be an Err(S2ProtocolError::MissingField) if the field is not present. This allows for avoiding panic!() and instead can be ?

Structs§

  • The main MPQ object that contains the parsed entries

Constants§

  • Pre-allocating memory is a nice optimization but count fields can’t always be trusted. (Copied from nom::multi source.). This is used for arrays.

Functions§

  • Converts the tracker loop to milliseconds, First scale the tracker loop to the same unit as the game loops. We also need to transform the adjusted game loop to seconds. This was observed in a game with max game_loop = 13735 and a duration of 15:42 = 942 seconds. 942000 / 13735 = 68.58391 loops in a second This will only work for the Faster speed.
  • Returns the 8 bytes following where the error was found for context.
  • Returns the 8 bytes following where the error was found for context.
  • Reads a VLQ Int that is prepend by its tag
  • Creates a colored binary representation of the input. The pre-amble bits are set to blue (these are bits previously processed) The current position, is set to green color. The remaining bits are colored in yellow. These are un-processed bits)
  • Re-export to avoid having to also add this crate to other consumers. A helper function that shows only up to the first 8 bytes of an u8 slice in xxd format.
  • Reads a file into memory.
  • Reads the MPQ file and returns both the MPQ read file and the reference to its contents.
  • Transforms the details MPQ sector time utc and local offset into possibly chrono::NaiveDateTime