mango

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: MIT Imports: 13 Imported by: 0

README

Mango

A Dota 2 replay parser in Go

Inspired by Smoke and Clarity by Skadistats

A work in progress - can parse the entire replay, returning the unmarshalled protocol buffer packets. "Gatherers" can be attached to the parser to collect data from different kinds of packets. You can write your own or use the default ones provided. I currently don't have many implemented however.

Sendtables are currently not fully decoded so a lot of info will be not be readable just yet.

To be able to write these, check out the file embedded/types.go to see the different packet type names, which you can find the full definitions for in the files pb/*.go.

Example Usage
rp := mango.WithDefaultGatherers(mango.NewReplayParser())
err := rp.Initialise(replayFilename)
if err != nil {
    panic(err)
}
defer rp.Close()

packets, err := rp.ParseReplay()
if err != nil {
    panic(err)
}
results := rp.GetResults() // Results indexed by gatherer name

... <do something with the results>

To add a gatherer

rp.RegisterGatherer(myGatherer)

Gatherers must have the following methods (defined in embedded/gatherer.go):

type Gatherer interface {
	GetName() string
	GetHandlers() map[int]EmbeddedHandler
	GetResults() interface{}
}

With EmbeddedHandler being a function that takes in a protobuf message (defined in embedded/types.go):

type EmbeddedHandler func(proto.Message) error

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadExamplePacketData

func LoadExamplePacketData(name string) map[string]map[string]interface{}

func PrintStruct

func PrintStruct(data any)

Types

type ReplayParser

type ReplayParser struct {
	Lookup    *mappings.LookupObjects
	Gatherers map[string]embedded.Gatherer
	// contains filtered or unexported fields
}

func NewReplayParser

func NewReplayParser() *ReplayParser

func WithDefaultGatherers

func WithDefaultGatherers(rp *ReplayParser) *ReplayParser

func (*ReplayParser) Close

func (rp *ReplayParser) Close() error

func (*ReplayParser) GetResult added in v0.1.3

func (rp *ReplayParser) GetResult(name string) interface{}

Return the results of the given gatherer, or nil if it doesn't exist

func (*ReplayParser) GetResults

func (rp *ReplayParser) GetResults() map[string]interface{}

Return the results of all gatherers in one map, indexed by their names

func (*ReplayParser) GetSummary

func (rp *ReplayParser) GetSummary() (proto.Message, error)

func (*ReplayParser) Initialise

func (rp *ReplayParser) Initialise(filename string) error

func (*ReplayParser) ParseReplay

func (rp *ReplayParser) ParseReplay() ([]*packet.Packet, error)

Parse through the entire replay

func (*ReplayParser) RegisterGatherer

func (rp *ReplayParser) RegisterGatherer(g embedded.Gatherer)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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