demoinfocs-golang

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

Github stars Tracking Chart

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

Overview

Name With Ownermarkus-wa/demoinfocs-golang
Primary LanguageGo
Program languageGo (Language Count: 2)
PlatformLinux, Mac, Windows
License:MIT License
Release Count110
Last Release Namev4.1.3 (Posted on )
First Release Namev0.1.0 (Posted on )
Created At2017-03-01 07:18:34
Pushed At2024-05-02 02:04:52
Last Commit At2024-04-28 18:54:28
Stargazers Count648
Watchers Count19
Fork Count91
Commits Count1.1k
Has Issues Enabled
Issues Count216
Issue Open Count28
Pull Requests Count260
Pull Requests Open Count6
Pull Requests Close Count38
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private
To the top