demoinfocs-golang

适用于 Go 的高性能 CS:GO 演示解析器(demoinfo)。「High performance CS:GO demo parser for Go (demoinfo)」

Github星跟踪图

demoinfocs-golang - A CS:GO Demo Parser

Is a Go library for super fast parsing and analysing of Counter Strike: Global Offensive (CS:GO) demos (aka replays). It is based on Valve's demoinfogo and SatsHelix's demoinfo.

GoDoc
Build Status
codecov
Go Report
License
FOSSA Status

Discussions / Chat

You can use gitter to ask questions and discuss ideas about this project.

Gitter chat

Requirements

This library is intended to be used with go 1.11 or higher as it is built using Go modules.

It's recommended to use modules for consumers as well if possible.
If you are unfamiliar with Go modules there's a list of recommended resources in the wiki.

Go Get

go get -u github.com/markus-wa/demoinfocs-golang

Example

This is a simple example on how to handle game events using this library.
It prints all kills in a given demo (killer, weapon, victim, was it a wallbang/headshot?) by registering a handler for events.Kill.

Check out the godoc of the events package for some information about the other available events and their purpose.

package main

import (
	"fmt"
	"os"

	dem "github.com/markus-wa/demoinfocs-golang"
	events "github.com/markus-wa/demoinfocs-golang/events"
)

func main() {
	f, err := os.Open("/path/to/demo.dem")
	if err != nil {
		panic(err)
	}
	defer f.Close()

	p := dem.NewParser(f)

	// Register handler on kill events
	p.RegisterEventHandler(func(e events.Kill) {
		var hs string
		if e.IsHeadshot {
			hs = " (HS)"
		}
		var wallBang string
		if e.PenetratedObjects > 0 {
			wallBang = " (WB)"
		}
		fmt.Printf("%s <%v%s%s> %s\n", e.Killer, e.Weapon, hs, wallBang, e.Victim)
	})

	// Parse to end
	err = p.ParseToEnd()
	if err != nil {
		panic(err)
	}
}

Sample output

Running the code above will print something like this:

xms <AK-47 (HS)> crisby
tiziaN <USP-S (HS)> Ex6TenZ
tiziaN <USP-S> mistou
tiziaN <USP-S (HS)> ALEX
xms <Glock-18 (HS)> tiziaN
...
keev <AWP (HS) (WB)> to1nou
...

More examples

Check out the examples folder for more examples, like how to generate heatmaps like this one:

Features

  • Game events (kills, shots, round starts/ends, footsteps etc.) - docs / example
  • Tracking of game-state (players, teams, grenades, ConVars etc.) - docs
  • Grenade projectiles / trajectories - docs / example
  • Access to entities, server-classes & data-tables - docs / example
  • Access to all net-messages - docs / example
  • Chat & console messages 1 - docs / example
  • POV demo support 2
  • Easy debugging via build-flags
  • Built with performance & concurrency in mind
  1. Only for some demos; in MM demos the chat is encrypted for example.
  2. Only partially supported (as good as other parsers), some POV demos seem to be inherently broken

Performance / Benchmarks

Two of the top priorities of this parser are performance and concurrency.

Here are some benchmark results from a system with an Intel i7 6700k CPU and a SSD disk running Windows 10 and a demo with 85'000 frames.

Overview

概览

名称与所有者markus-wa/demoinfocs-golang
主编程语言Go
编程语言Go (语言数: 2)
平台Linux, Mac, Windows
许可证MIT License
发布数110
最新版本名称v4.1.3 (发布于 )
第一版名称v0.1.0 (发布于 )
创建于2017-03-01 07:18:34
推送于2024-05-02 02:04:52
最后一次提交2024-04-28 18:54:28
星数648
关注者数19
派生数91
提交数1.1k
已启用问题?
问题数216
打开的问题数28
拉请求数260
打开的拉请求数6
关闭的拉请求数38
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?
去到顶部