demoinfo

package module
v0.0.0-...-e4a45c3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2016 License: BSD-2-Clause Imports: 13 Imported by: 1

README

csgo-demoparser

A Golang utility to parse CSGO demo files.

This is under active development, does not fully function yet.

Requirements

You need a normal golang setup. See https://golang.org/doc/install For OSX users install go via homebrew with brew install go and set all path variables:

	export GOPATH=$gopath
	export GOROOT=/usr/local/opt/go/libexec
	export PATH=$PATH:$GOPATH/bin
	export PATH=$PATH:$GOROOT/bin

Build and Run

go install

csgo-demoparser -f demo.dem

Documentation

Index

Constants

View Source
const (
	MaxOSPath      = 260
	PacketOffset   = 160
	DemoHeaderID   = "HL2DEMO"
	DemSignon      = 1
	DemPacket      = 2
	DemSynctick    = 3
	DemConsoleCMD  = 4
	DemUserCMD     = 5
	DemDatatables  = 6
	DemStop        = 7
	DemCustomdata  = 8
	DemSringTables = 9
)

Variables

This section is empty.

Functions

func CalculateMatchDurationHandler

func CalculateMatchDurationHandler(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

func CollectHandler

func CollectHandler(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

func PlayerConnectHandler

func PlayerConnectHandler(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

func PlayerDisconnectHandler

func PlayerDisconnectHandler(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

func PlayerTeamHandler

func PlayerTeamHandler(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

func PrintAsJson

func PrintAsJson(msg interface{}) error

func RoundAnnounceMatchStartHandler

func RoundAnnounceMatchStartHandler(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

func RoundEndHandler

func RoundEndHandler(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

func RoundOfficiallyEndHandler

func RoundOfficiallyEndHandler(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

func RoundStartHandler

func RoundStartHandler(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

Types

type DemoCmdHeader

type DemoCmdHeader struct {
	Cmd        uint8
	Tick       int32
	Playerslot uint8
}

type DemoContext

type DemoContext struct {
	GameEventList *protom.CSVCMsg_GameEventList
	GameEventChan chan *DemoGameEvent
	StopChan      chan bool
	// contains filtered or unexported fields
}

func NewDemoContext

func NewDemoContext(header *DemoHeader) *DemoContext

func (*DemoContext) GetGameEventDescriptor

func (dc *DemoContext) GetGameEventDescriptor(eventid int32) *protom.CSVCMsg_GameEventListDescriptorT

type DemoEventDispatcher

type DemoEventDispatcher struct {
	// contains filtered or unexported fields
}

func (*DemoEventDispatcher) Dispatch

func (dispatcher *DemoEventDispatcher) Dispatch(eventName string, event *DemoGameEvent)

func (*DemoEventDispatcher) RegisterHandler

func (dispatcher *DemoEventDispatcher) RegisterHandler(eventName string, handler DispatcherFunc)

type DemoGameEvent

type DemoGameEvent struct {
	EventId     int32                  `json:"eventId"`
	Name        string                 `json:"name"`
	Tick        int32                  `json:"-"`
	TimeInRound time.Duration          `json:"timeInRound"`
	Data        map[string]interface{} `json:"data"`
}

func NewDemoGameEvent

func NewDemoGameEvent(eventid int32, name string, tick int32) *DemoGameEvent

type DemoHeader

type DemoHeader struct {
	Demofilestamp   [8]byte
	Demoprotocol    int32
	Networkprotocol int32
	Servername      [MaxOSPath]byte
	Clientname      [MaxOSPath]byte
	Mapname         [MaxOSPath]byte
	Gamedirectory   [MaxOSPath]byte
	PlaybackTime    float32
	PlaybackTicks   int32
	PlaybackFrames  int32
	Signonlength    int32
}

type DemoParser

type DemoParser struct {
	Header  *DemoHeader
	Context *DemoContext
	// contains filtered or unexported fields
}

func NewDemoParser

func NewDemoParser(path string) (*DemoParser, error)

func (*DemoParser) ParseTicks

func (dp *DemoParser) ParseTicks()

func (*DemoParser) PrintHeader

func (dp *DemoParser) PrintHeader()

type DemoStatistic

type DemoStatistic struct {
	MatchInfo      *MatchInfo       `json:"matchInfo"`
	MatchStartTick int32            `json:"-"`
	Rounds         []*Round         `json:"rounds"`
	UnmappedEvents []*DemoGameEvent `json:"unmappedEvents"`
	// contains filtered or unexported fields
}

func NewDemoStatistic

func NewDemoStatistic(demoHeader *DemoHeader) *DemoStatistic

func (*DemoStatistic) AddNewRound

func (ds *DemoStatistic) AddNewRound(startTick int32)

func (*DemoStatistic) FindRoundByTick

func (ds *DemoStatistic) FindRoundByTick(tick int32) (round *Round, found bool)

func (*DemoStatistic) RemoveWarmupRounds

func (ds *DemoStatistic) RemoveWarmupRounds()

func (*DemoStatistic) RenumberRounds

func (ds *DemoStatistic) RenumberRounds()

type DemoStream

type DemoStream struct {
	// contains filtered or unexported fields
}

func NewDemoStream

func NewDemoStream(reader io.ReadSeeker, length int32) *DemoStream

func (*DemoStream) CreatePacketStream

func (d *DemoStream) CreatePacketStream() *DemoStream

func (*DemoStream) GetByte

func (d *DemoStream) GetByte() byte

func (*DemoStream) GetCurrentOffset

func (d *DemoStream) GetCurrentOffset() int

func (*DemoStream) GetDataTableString

func (d *DemoStream) GetDataTableString() string

func (*DemoStream) GetInt

func (d *DemoStream) GetInt() int32

func (*DemoStream) GetInt16

func (d *DemoStream) GetInt16() int16

func (*DemoStream) GetInt64

func (d *DemoStream) GetInt64() int64

func (*DemoStream) GetUInt8

func (d *DemoStream) GetUInt8() uint8

func (*DemoStream) GetVarInt

func (d *DemoStream) GetVarInt() uint64

func (*DemoStream) IsProcessed

func (d *DemoStream) IsProcessed() bool

func (*DemoStream) ParseToStruct

func (d *DemoStream) ParseToStruct(msg proto.Message, messageLength uint64) error

func (*DemoStream) Read

func (d *DemoStream) Read(out []byte) (int, error)

func (*DemoStream) Skip

func (d *DemoStream) Skip(n int64)

type DispatcherFunc

type DispatcherFunc func(context DemoContext, demoStatistic *DemoStatistic, event *DemoGameEvent)

type EventDispatcher

type EventDispatcher interface {
	Dispatch(eventName string, event *DemoGameEvent)
	RegisterHandler(eventName string, handler DispatcherFunc)
}

func NewDemoEventDispatcher

func NewDemoEventDispatcher(statistic *DemoStatistic, context *DemoContext) EventDispatcher

type MatchInfo

type MatchInfo struct {
	Map        string        `json:"map"`
	ServerName string        `json:"serverName"`
	Players    []*Player     `json:"players"`
	Duration   time.Duration `json:"duration"`
	// contains filtered or unexported fields
}

func (*MatchInfo) AddPlayer

func (mi *MatchInfo) AddPlayer(player *Player)

func (*MatchInfo) RemovePlayer

func (mi *MatchInfo) RemovePlayer(playerToDelete *Player) bool

type Player

type Player struct {
	SteamId   string `json:"steamId"`
	Name      string `json:"name"`
	UserId    int32  `json:"userId"`
	Team      int    `json:"team"`
	Connected bool   `json:"-"`
}

type Round

type Round struct {
	Nr        int              `json:"nr"`
	Duration  time.Duration    `json:"duration"`
	Winner    int              `json:"winner"`
	Reason    int              `json:"reason"`
	Events    []*DemoGameEvent `json:"events"`
	StartTick int32            `json:"-"`
	EndTick   int32            `json:"-"`
	// contains filtered or unexported fields
}

func NewRound

func NewRound(startTick int32) *Round

func (*Round) AddEvent

func (r *Round) AddEvent(event *DemoGameEvent)

type ServerClass

type ServerClass struct {
	ClassID     int16
	DataTableID int
	Name        string
	DTName      string
}

Directories

Path Synopsis
cmd
demoparser-cli command
Package main is a generated protocol buffer package.
Package main is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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