Documentation ¶
Overview ¶
Package demoinfocs provides demo parser for the game Counter-Strike: Global Offensive. It is based on the official demoinfogo tool by Valve as well as Stats Helix's demoinfo. A good entry point to using the library is the Parser type. Demo events are documented in the events package.
Index ¶
- func WarnToStdErr(warning string)
- type Parser
- func (p *Parser) CTState() *TeamState
- func (p *Parser) Cancel()
- func (p *Parser) CurrentFrame() int
- func (p *Parser) CurrentTime() float32
- func (p *Parser) FrameRate() float32
- func (p *Parser) FrameTime() float32
- func (p *Parser) IngameTick() int
- func (p *Parser) Map() string
- func (p *Parser) ParseHeader() error
- func (p *Parser) ParseNextFrame() (b bool, err error)
- func (p *Parser) ParseToEnd() (err error)
- func (p *Parser) Participants() []*common.Player
- func (p *Parser) PlayingParticipants() []*common.Player
- func (p *Parser) Progress() float32
- func (p *Parser) RegisterEventHandler(handler interface{})
- func (p *Parser) TState() *TeamState
- type TeamState
- type WarnHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WarnToStdErr ¶
func WarnToStdErr(warning string)
WarnToStdErr is a WarnHandler that prints all warnings to standard error output.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser can parse a CS:GO demo. Creating a Parser is done via NewParser(). To start off use Parser.ParseHeader() to parse the demo header. After parsing the header Parser.ParseNextFrame() and Parser.ParseToEnd() can be used to parse the demo. Use Parser.RegisterEventHandler() to receive notifications about events.
func NewParser ¶
func NewParser(demostream io.Reader, warnHandler WarnHandler) *Parser
NewParser creates a new Parser on the basis of an io.Reader - like os.File or bytes.Reader - that reads demo data. Any warnings that don't stop the Parser from doing it's job will be passed to the warnHandler if it's not nil.
func NewParserWithBufferSize ¶
func NewParserWithBufferSize(demostream io.Reader, msgQueueBufferSize int, warnHandler WarnHandler) *Parser
NewParserWithBufferSize returns a new Parser with a custom msgQueue buffer size. For large demos, fast i/o and slow CPUs higher numbers are suggested and vice versa. The buffer size can easily be in the hundred-thousands to low millions for the best performance. A negative value will make the Parser automatically decide the buffer size during ParseHeader() based on the number of ticks in the demo (nubmer of ticks = buffer size). See also: NewParser()
func (*Parser) CTState ¶
CTState returns the TeamState of the CT team. Make sure you handle swapping sides properly if you keep the reference.
func (*Parser) Cancel ¶
func (p *Parser) Cancel()
Cancel aborts ParseToEnd(). All information that was already read up to this point will still be used (and new events may still be sent).
func (*Parser) CurrentFrame ¶
CurrentFrame return the number of the current frame, aka. 'demo-tick' (Since demos often have a different tick-rate than the game). Starts with frame 0, should go up to DemoHeader.PlaybackFrames but might not be the case (usually it's just close to it).
func (*Parser) CurrentTime ¶
CurrentTime returns the ingame time in seconds since the start of the demo.
func (*Parser) FrameRate ¶
FrameRate returns the frame rate of the demo (frames / demo-ticks per second). Not necessarily the tick-rate the server ran on during the game. VolvoPlx128TixKTnxBye
func (*Parser) IngameTick ¶
IngameTick returns the latest actual tick number of the server during the game. Watch out, I've seen this return wonky negative numbers at the start of demos.
func (*Parser) ParseHeader ¶
ParseHeader attempts to parse the header of the demo. Returns error if the filestamp (first 8 bytes) doesn't match HL2DEMO.
func (*Parser) ParseNextFrame ¶
ParseNextFrame attempts to parse the next frame / demo-tick (not ingame tick). Returns true unless the demo command 'stop' was encountered. Panics if header hasn't been parsed yet - see Parser.ParseHeader().
func (*Parser) ParseToEnd ¶
ParseToEnd attempts to parse the demo until the end. Aborts and returns an error if Cancel() is called before the end. May panic if the demo is corrupt in some way.
func (*Parser) Participants ¶
Participants returns all connected players. This includes spectators.
func (*Parser) PlayingParticipants ¶
PlayingParticipants returns all players that aren't spectating.
func (*Parser) Progress ¶
Progress returns the parsing progress from 0 to 1. Where 0 means nothing has been parsed yet and 1 means the demo has been parsed to the end. Might not actually be reliable since it's just based on the reported tick count of the header.
func (*Parser) RegisterEventHandler ¶
func (p *Parser) RegisterEventHandler(handler interface{})
RegisterEventHandler registers a handler for game events. Must be of type func(<EventType>) where EventType is the kind of event that is handled. To catch all events func(interface{}) can be used. Parameter handler has to be of type interface{} because lolnogenerics.
type TeamState ¶
type TeamState struct {
// contains filtered or unexported fields
}
TeamState contains a team's ID, score, clan name & country flag.
type WarnHandler ¶
type WarnHandler func(string)
WarnHandler is a function that handles warnings of a Parser.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package bitread provides a wrapper for github.com/markus-wa/gobitread with CS:GO demo parsing specific helpers.
|
Package bitread provides a wrapper for github.com/markus-wa/gobitread with CS:GO demo parsing specific helpers. |
Package common contains common types, constants and functions used over different demoinfocs packages.
|
Package common contains common types, constants and functions used over different demoinfocs packages. |
Package events contains all events that can be sent out from demoinfocs.Parser.
|
Package events contains all events that can be sent out from demoinfocs.Parser. |
Package msg is a generated protocol buffer package.
|
Package msg is a generated protocol buffer package. |
Package sendtables contains sendtable specific magic and should really be better documented (TODO).
|
Package sendtables contains sendtable specific magic and should really be better documented (TODO). |