All Projects → markus-wa → Demoinfocs Golang

markus-wa / Demoinfocs Golang

Licence: mit
High performance CS:GO demo parser for Go (demoinfo)

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Demoinfocs Golang

Demofile
Node.js library for parsing Counter-Strike: Global Offensive demo files
Stars: ✭ 305 (+5.9%)
Mutual labels:  parser, csgo, counter-strike, demo
Csgoverview
A 2D demo replay tool for Counter Strike: Global Offensive.
Stars: ✭ 88 (-69.44%)
Mutual labels:  csgo, counter-strike, demo
Demoinfo
A library to analyze CS:GO demos in C#
Stars: ✭ 306 (+6.25%)
Mutual labels:  parser, csgo, demo
csgo-gsi
A Java library for Counter-Strike: Global Offensive's game state integration
Stars: ✭ 23 (-92.01%)
Mutual labels:  counter-strike, csgo
CallAdmin
CallAdmin is a multilingual sourcemod plugin which provides in-game report functionality
Stars: ✭ 52 (-81.94%)
Mutual labels:  counter-strike, csgo
Sequoia
A neural network for CounterStrike:GlobalOffensive character detection and classification. Built on a custom-made dataset (csgo-data-collector)
Stars: ✭ 60 (-79.17%)
Mutual labels:  counter-strike, csgo
csgo-hud
Custom CS:GO Spectator HUD
Stars: ✭ 40 (-86.11%)
Mutual labels:  counter-strike, csgo
discord-10man
Discord bot for CS:GO Scrims and Pugs
Stars: ✭ 34 (-88.19%)
Mutual labels:  counter-strike, csgo
sourcepawn-navmesh
SourcePawn .NAV file reader.
Stars: ✭ 25 (-91.32%)
Mutual labels:  counter-strike, csgo
RatPoison
Latest Ver: 1.7; Default Menu Key is F1; Charlatano's Successor; dn
Stars: ✭ 302 (+4.86%)
Mutual labels:  counter-strike, csgo
Java-Memory-Manipulation
User friendly, Garbage-free, and cross-platform process, module and memory interfacing via the power of Java
Stars: ✭ 51 (-82.29%)
Mutual labels:  counter-strike, csgo
valve-matchmaking-ip-ranges
Lists of locations & IP addresses of Valve servers
Stars: ✭ 69 (-76.04%)
Mutual labels:  counter-strike, csgo
CSGOItemDB
An API to retrieve accurate CS:GO prices for high- and low-tier items
Stars: ✭ 35 (-87.85%)
Mutual labels:  counter-strike, csgo
Public
The game is about a group of "terrorists" who have traitors among them, out to kill everyone who's not a traitor.
Stars: ✭ 94 (-67.36%)
Mutual labels:  counter-strike, csgo
pengWin
An external cheat for the Linux version of Counter-Strike Global Offensive
Stars: ✭ 28 (-90.28%)
Mutual labels:  counter-strike, csgo
csgo-cli
CS:GO Console shows your user account, stats and latest matches. It also uploads demo sharecodes to csgostats.gg.
Stars: ✭ 31 (-89.24%)
Mutual labels:  counter-strike, csgo
TeamGames
Sourcemod plugin providing team based games for prisoners and some useful things for wardens.
Stars: ✭ 16 (-94.44%)
Mutual labels:  counter-strike, csgo
csgo richpresence
Discord Rich Presence support for Counter-Strike: Global Offensive!
Stars: ✭ 16 (-94.44%)
Mutual labels:  counter-strike, csgo
Csgo Practice Mode
CS:GO Sourcemod plugin for private team/individual practice servers
Stars: ✭ 263 (-8.68%)
Mutual labels:  csgo, counter-strike
Yii Demo
Yii 3 demo application
Stars: ✭ 210 (-27.08%)
Mutual labels:  hacktoberfest, demo

demoinfocs-golang - CS:GO Demo Parser

A blazing fast, feature complete and production ready Go library for parsing and analysing of Counter Strike: Global Offensive (CS:GO) demos (aka replays). It is based on Valve's demoinfogo and SatsHelix's demoinfo but provides many improvements.

go.dev reference Build Status codecov Go Report License FOSSA Status

Discussions / Chat

You can use Gitter or GitHub Discussions to ask questions and discuss ideas about this project.
For business inquiries please use the contact information found on the GitHub profile.

Gitter Chat

Go Get

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

Table of Contents

Requirements

This library should 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.

Quickstart Guide

  1. Download and install Go 1.11 or newer from golang.org or via your favourite package manager

  2. Create a new Go Modules project

mkdir my-project
cd my-project

go mod init github.com/<YOUR_GITHUB_USER>/my-project
# the module name (github.com/<YOUR_GITHUB_USER>/my-project) can always be changed later
# you can also put example.com/my-project or anything else if you don't plan to publish your project

go get -u github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs
  1. Create a main.go file with the example below

  2. Run go run main.go

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/v2/pkg/demoinfocs"
	events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
)

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

	p := dem.NewParser(f)
	defer p.Close()

	// 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:

sample heatmap

Documentation

The full API documentation is available here on pkg.go.dev.

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
  • Matchmaking ranks (official MM demos only) - docs
  • Full POV demo support 2
  • JavaScript (browser / Node.js) support via WebAssembly - example
  • 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. Better than some other parsers at the time of writing.

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

Benchmark Description Average Duration Speed
BenchmarkConcurrent Read and parse 8 demos concurrently 2.06 s (per 8 demos) ~330'000 ticks / s
BenchmarkDemoInfoCs Read demo from drive and parse 0.89 s ~95'000 ticks / s
BenchmarkInMemory Read demo from memory and parse 0.88 s ~96'000 ticks / s

That's almost 1.5 hours of gameplay per second when parsing in parallel (recorded at 64 ticks per second) - or 25 minues per second when only parsing a single demo at a time.

Raw Output

$ go test -run _NONE_ -bench . -benchtime 30s -benchmem -concurrentdemos 8
goos: windows
goarch: amd64
pkg: github.com/markus-wa/demoinfocs-golang
BenchmarkDemoInfoCs-8             50     894500010 ns/op    257610127 B/op    914355 allocs/op
BenchmarkInMemory-8               50     876279984 ns/op    257457271 B/op    914143 allocs/op
BenchmarkConcurrent-8             20    2058303680 ns/op    2059386582 B/op  7313145 allocs/op
--- BENCH: BenchmarkConcurrent-8
    demoinfocs_test.go:315: Running concurrency benchmark with 8 demos
    demoinfocs_test.go:315: Running concurrency benchmark with 8 demos
PASS
ok      github.com/markus-wa/demoinfocs-golang  134.244s

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository. There is one caveat however: Beta features - which are marked as such via comments and in release notes - may change in minor releases.

Projects Using demoinfocs-golang

  • noesis.gg - A suite of explorative tools to help you analyze and improve your CS:GO performance
  • esportal.se - An alternative Matchmaking service that aims to provide a friendly environment free from trolls and misbehaving individuals
  • esportslab.gg - Building ML/AI tools for professional esports players
  • scope.gg - Analytical and advisory service for advanced CS:GO players
  • cs-demo-minifier - Converts demos to JSON, MessagePack and more
  • csgo_spray_pattern_plotter - A tool to extract and plot spray patterns from CS:GO replays
  • CS:GO Player Skill Prediction - Machine learning master thesis by @quancore about predicting player performance
  • csgoverview - A 2D demo replay tool for CS:GO
  • csgo-coach-bug-detector - Detects the abuse of an exploit used by some team coaches in professional matches
  • megaclan3000 - A CS:GO stats page for clans with recent matches and player statistics

If your project is using this library feel free to submit a PR or send a message in Gitter to be included in the list.

Development

Debugging

You can use the build tag debugdemoinfocs (i.e. go test -tags debugdemoinfocs -v) to print out debugging information - such as game events or unhandled demo-messages - during the parsing process.
Side-note: The tag isn't called debug to avoid naming conflicts with other libs (and underscores in tags don't work, apparently).

To change the default debugging behavior, Go's ldflags parameter can be used. Example for additionally printing out all server-classes with their properties: -ldflags '-X github.com/markus-wa/demoinfocs-golang.debugServerClasses=YES'

Check out debug_on.go for any other settings that can be changed.

Testing

Unit Tests

For any new features, Test Driven Development should be practiced where possible. However, due to some design flaws in some parts of the code it's currently not always practical to do so.

Running unit tests:

scripts/unit-tests.sh
# or (identical)
go test -short ./...

Regression Tests

For the full regression suite you will need to download the test demo-set.

Prerequisites:

  • Git LFS must be installed
  • 7z must be in your PATH environment variable (p7zip or p7zip-full package on most Linux distros)

Downloading demos + running regression tests:

scripts/regression-tests.sh

Updating the default.golden File

The file test/default.golden file contains a serialized output of all expected game events in test/cs-demos/default.dem.

If there is a change to game events (new fields etc.) it is necessary to update this file so the regression tests pass. To update it you can run the following command:

go test -run TestDemoInfoCs -update

Please don't update the .golden file if you are not sure it's required. Maybe the failing CI is just pointing out a regression.

Generating Interfaces

We generate interfaces such as GameState from structs to make it easier to keep docs in synch over structs and interfaces. For this we use @vburenin's ifacemaker tool.

You can download the latest version here. After adding it to your PATH you can use scripts/generate-interfaces.sh to update interfaces.

Generating Protobuf Code

Should you need to re-generate the protobuf generated code in the msg package, you will need the following tools:

Make sure both are inside your PATH variable.

After installing these use go generate ./msg to generate the protobuf code. If you're on Windows you'll need to run go generate from CMD, not Bash.

Git Hooks

To install some (optional, but quite handy) pre-commit and pre-push hooks, you can run the following script.

scripts/git-hooks/link-git-hooks.sh

pre-commit:

pre-push:

  • run regression tests

Acknowledgements

Thanks to @JetBrains for sponsoring a license of their awesome GoLand IDE for this project - go check it out!

And a very special thanks goes out to all the ⭐contributors⭐️, be it in the form of PRs, issues or anything else.

License

This project is licensed under the MIT license.

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].