repparser

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2020 License: Apache-2.0 Imports: 12 Imported by: 3

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:

http://www.staredit.net/wiki/index.php/Scenario.chk

http://blog.naver.com/PostView.nhn?blogId=wisdomswrap&logNo=60119755717&parentCategoryNo=&categoryNo=19&viewDate=&isShowPopularPosts=false&from=postView

Index

Constants

View Source
const (
	// Version is a Semver2 compatible version of the parser.
	Version = "v1.4.2"
)

Variables

View Source
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")
)
View Source
var (
	SectionReplayID = Sections[0]
	SectionHeader   = Sections[1]
	SectionCommands = Sections[2]
	SectionMapData  = Sections[3]
)

Named sections

View Source
var Sections = []*Section{
	{0, 0x04, parseReplayID},
	{1, 0x279, parseHeader},
	{2, 0, parseCommands},
	{3, 0, parseMapData},
}

Sections describes the subsequent Sections of replays

Functions

func Parse

func Parse(repData []byte) (*rep.Replay, error)

Parse parses all sections of an SC:BW replay from the given byte slice.

func ParseConfig added in v1.2.1

func ParseConfig(repData []byte, cfg Config) (*rep.Replay, error)

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 ParseFile

func ParseFile(name string) (r *rep.Replay, err error)

ParseFile parses all sections from an SC:BW replay file.

func ParseFileConfig added in v1.2.1

func ParseFileConfig(name string, cfg Config) (r *rep.Replay, err error)

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

func ParseFileSections(name string, commands, mapData bool) (r *rep.Replay, err error)

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

func ParseSections(repData []byte, commands, mapData bool) (*rep.Replay, error)

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL