Crate s2protocol

Source
Expand description

S2 Protocol use of the MPQ archive

Re-exports§

pub use crate::versions::read_details;
pub use crate::versions::read_game_events;
pub use crate::versions::read_init_data;
pub use crate::versions::read_message_events;
pub use crate::versions::read_tracker_events;
pub use protocol_version_decoder::read_protocol_header;
pub use crate::state::*;
pub use arrow::*;
pub use bit_packed_decoder::*;
pub use cli::*;
pub use common::*;
pub use error::*;
pub use filters::*;
pub use init_data::*;
pub use versioned_decoder::*;

Modules§

arrow
Arrow Specific handling of data.
bit_packed_decoder
The Bit Packed Decoder. As a difference to the Versioned Decoder, the fields are not tagged.
cli
common
A collection of transformed enum variants to u8s. This is done for space efficiency in the Arrow IPC file.
details
Decodes the Details.
error
Error handling of S2Protocol
filters
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.
game_events
Decodes the Game Events. These are stored in an embedded file in the MPQ file called ‘replay.game.events’
generator
ABANDON ALL HOPE, YE WHO ENTER HERE
init_data
Decodes the initData
message_events
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.
parser
Re-export to avoid having to also add this crate to other consumers. Nom Parsing the MPQ file format
protocol_version_decoder
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.
state
Handling of state of SC2 Replay as it steps through game loops
tracker_events
Decodes the Tracker Events. These are stored in an embebdded file in the MPQ file called ‘replay.tracker.events’
versioned_decoder
The versioned decoder. The fields on versioned structures are prepend by tags.
versions
The known protocol versions

Macros§

ok_or_return_missing_field_err
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§

MPQ
The main MPQ object that contains the parsed entries

Constants§

MAX_INITIAL_CAPACITY_BYTES
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§

convert_game_loop_to_seconds
Converts the game loop to milliseconds,
convert_tracker_loop_to_seconds
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.
dbg_peek_bits
Returns the 8 bytes following where the error was found for context.
dbg_peek_hex
Returns the 8 bytes following where the error was found for context.
parse_vlq_int
Reads a VLQ Int that is prepend by its tag
peek_bits
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)
peek_hex
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.
read_file
Reads a file into memory.
read_mpq
Reads the MPQ file and returns both the MPQ read file and the reference to its contents.
transform_to_naivetime
Transforms the details MPQ sector time utc and local offset into possibly chrono::NaiveDateTime