Documentation
¶
Overview ¶
Package repparser implements StarCraft: Brood War replay parsing.
The package is safe for concurrent use.
Information sources:
BWHF replay parser:
https://github.com/icza/bwhf/tree/master/src/hu/belicza/andras/bwhf/control
BWAPI replay parser:
https://github.com/bwapi/bwapi/tree/master/bwapi/libReplayTool
https://github.com/bwapi/bwapi/tree/master/bwapi/include/BWAPI
https://github.com/bwapi/bwapi/tree/master/bwapi/PKLib
Command models:
https://github.com/icza/bwhf/blob/master/src/hu/belicza/andras/bwhf/model/Action.java
https://github.com/bwapi/bwapi/tree/master/bwapi/libReplayTool
jssuh replay parser:
https://github.com/neivv/jssuh
Map Data format:
Index ¶
- Constants
- Variables
- func Parse(repData []byte) (*rep.Replay, error)
- func ParseConfig(repData []byte, cfg Config) (*rep.Replay, error)
- func ParseFile(name string) (r *rep.Replay, err error)
- func ParseFileConfig(name string, cfg Config) (r *rep.Replay, err error)
- func ParseFileSections(name string, commands, mapData bool) (r *rep.Replay, err error)
- func ParseSections(repData []byte, commands, mapData bool) (*rep.Replay, error)
- type Config
- type Section
Constants ¶
const (
// Version is a Semver2 compatible version of the parser.
Version = "v1.4.2"
)
Variables ¶
var ( // ErrNotReplayFile indicates the given file (or reader) is not a valid // replay file ErrNotReplayFile = errors.New("not a replay file") // ErrParsing indicates that an unexpected error occurred, which may be // due to corrupt / invalid replay file, or some implementation error. ErrParsing = errors.New("parsing") )
var ( SectionReplayID = Sections[0] SectionHeader = Sections[1] SectionCommands = Sections[2] SectionMapData = Sections[3] )
Named sections
var Sections = []*Section{
{0, 0x04, parseReplayID},
{1, 0x279, parseHeader},
{2, 0, parseCommands},
{3, 0, parseMapData},
}
Sections describes the subsequent Sections of replays
Functions ¶
func ParseConfig ¶ added in v1.2.1
ParseConfig parses an SC:BW replay from the given byte sice based on the given parser configuration. Replay ID and header sections are always parsed.
func ParseFileConfig ¶ added in v1.2.1
ParseFileConfig parses an SC:BW replay file based on the given parser configuration. Replay ID and header sections are always parsed.
func ParseFileSections ¶ added in v1.1.0
ParseFileSections parses an SC:BW replay file. Parsing commands and map data sections depends on the given parameters. Replay ID and header sections are always parsed.
func ParseSections ¶ added in v1.1.0
ParseSections parses an SC:BW replay from the given byte slice. Parsing commands and map data sections depends on the given parameters. Replay ID and header sections are always parsed.
Types ¶
type Config ¶ added in v1.2.1
type Config struct { // Commands tells if the commands section is to be parsed Commands bool // MapData tells if the map data section is to be parsed MapData bool // Debug tells if debug and replay internal binaries is to be retained in the returned Replay. Debug bool // contains filtered or unexported fields }
Config holds parser configuration.
type Section ¶ added in v1.1.0
type Section struct { // ID of the section ID int // Size of the uncompressed section in bytes; // 0 means the Size has to be read as a section of 4 bytes Size int32 // ParseFunc defines the function responsible to process (parse / interpret) // the section's data. ParseFunc func(data []byte, r *rep.Replay, cfg Config) error }
Section describes a Section of the replay.
Directories
¶
Path | Synopsis |
---|---|
Package repdecoder implements decoding StarCraft Brood War replay files (*.rep).
|
Package repdecoder implements decoding StarCraft Brood War replay files (*.rep). |