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
發布數109
最新版本名稱v4.1.2 (發布於 )
第一版名稱v0.1.0 (發布於 )
創建於2017-03-01 07:18:34
推送於2024-04-04 10:19:02
最后一次提交2024-04-04 11:18:11
星數640
關注者數18
派生數89
提交數1.1k
已啟用問題?
問題數212
打開的問題數25
拉請求數258
打開的拉請求數5
關閉的拉請求數35
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部