Skip to content

Commit

Permalink
Merge pull request #383 from markus-wa/s2
Browse files Browse the repository at this point in the history
v4: Support Counter-Strike 2
  • Loading branch information
markus-wa authored Sep 1, 2023
2 parents 8eb0227 + 082a961 commit 663d133
Show file tree
Hide file tree
Showing 158 changed files with 102,948 additions and 9,130 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ name: CI

jobs:
ci:
strategy:
matrix:
go-version: [1.18.x]

runs-on: ubuntu-latest

env:
Expand All @@ -18,7 +14,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
go-version: 1.21.x

- name: Install Reviewdog
uses: reviewdog/action-setup@v1
Expand All @@ -37,14 +33,14 @@ jobs:
sudo apt-get install -y p7zip-full
# Install interface generator
go install github.com/vburenin/ifacemaker@v1.1.0
go install github.com/vburenin/ifacemaker@v1.2.1
# Fetch refs for linter
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git fetch
# Install golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2
- name: Build
run: scripts/build.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/protobuf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
if: env.PROTOBUFS_CHANGED == 'true'
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.21.x

- name: Install Protobuf tools
if: env.PROTOBUFS_CHANGED == 'true'
Expand Down
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- exportloopref
Expand All @@ -36,12 +34,10 @@ linters:
- nolintlint
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
- asciicheck
- gocognit
Expand Down
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Counter-Strike 2 support is experimental.

[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://vshymanskyy.github.io/StandWithUkraine)

[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs?tab=doc)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs?tab=doc)
[![Build Status](https://img.shields.io/github/actions/workflow/status/markus-wa/demoinfocs-golang/ci.yml?branch=master&style=flat-square)](https://github.com/markus-wa/demoinfocs-golang/actions)
[![codecov](https://img.shields.io/codecov/c/github/markus-wa/demoinfocs-golang?style=flat-square)](https://codecov.io/gh/markus-wa/demoinfocs-golang)
[![Go Report](https://goreportcard.com/badge/github.com/markus-wa/demoinfocs-golang?style=flat-square)](https://goreportcard.com/report/github.com/markus-wa/demoinfocs-golang)
Expand All @@ -23,13 +23,15 @@ For business inquiries please use the contact information found on the [GitHub p

## Go Get

### CS:GO
### CS2 - ⚠️ Experimental

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

### CS2 - ⚠️ Experimental
⚠️ The CS2 / v4 API may change in backwards incompatible ways without warning.

go get -u github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs@s2
### CS:GO

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

## Table of Contents

Expand All @@ -53,7 +55,7 @@ For business inquiries please use the contact information found on the [GitHub p

## Requirements

This library requires at least `go 1.18` to run.
This library requires at least `go 1.21` to run.
You can download the latest version of Go [here](https://golang.org/).

## Quickstart Guide
Expand All @@ -70,7 +72,7 @@ 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/v3/pkg/demoinfocs
go get -u github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs
```

3. Create a `main.go` file with the example below
Expand All @@ -92,8 +94,8 @@ import (
"log"
"os"

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

func main() {
Expand Down Expand Up @@ -150,24 +152,24 @@ Check out the [examples](examples) folder for more examples, like [how to genera

### Documentation

The full API documentation is available here on [pkg.go.dev](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs).
The full API documentation is available here on [pkg.go.dev](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs).

## Features

* Game events (kills, shots, round starts/ends, footsteps etc.) - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events?tab=doc) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/print-events)
* Tracking of game-state (players, teams, grenades, ConVars etc.) - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs?tab=doc#GameState)
* Grenade projectiles / trajectories - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs?tab=doc#GameState.GrenadeProjectiles) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/nade-trajectories)
* Access to entities, server-classes & data-tables - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/sendtables?tab=doc#ServerClasses) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/entities)
* Access to all net-messages - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs?tab=doc#NetMessageCreator) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/net-messages)
* Chat & console messages <sup id="achat1">1</sup> - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events?tab=doc#ChatMessage) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/print-events)
* Matchmaking ranks (official MM demos only) - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events?tab=doc#RankUpdate)
* Game events (kills, shots, round starts/ends, footsteps etc.) - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events?tab=doc) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/print-events)
* Tracking of game-state (players, teams, grenades, ConVars etc.) - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs?tab=doc#GameState)
* Grenade projectiles / trajectories - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs?tab=doc#GameState.GrenadeProjectiles) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/nade-trajectories)
* Access to entities, server-classes & data-tables - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/sendtables?tab=doc#ServerClasses) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/entities)
* Access to all net-messages - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs?tab=doc#NetMessageCreator) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/net-messages)
* Chat & console messages <sup id="achat1">1</sup> - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events?tab=doc#ChatMessage) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/print-events)
* Matchmaking ranks (official MM demos only) - [docs](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4/pkg/demoinfocs/events?tab=doc#RankUpdate)
* Full POV demo support <sup id="achat1">2</sup>
* Support for encrypted net-messages (if the [decryption key](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3@master/pkg/demoinfocs#ParserConfig) is provided)
* Support for encrypted net-messages (if the [decryption key](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4@master/pkg/demoinfocs#ParserConfig) is provided)
* JavaScript (browser / Node.js) support via WebAssembly - [example](https://github.com/markus-wa/demoinfocs-wasm)
* [Easy debugging via build-flags](#debugging)
* Built with performance & concurrency in mind

1. <small id="f1">In MM demos the chat is encrypted, so [`ParserConfig.NetMessageDecryptionKey`](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3@master/pkg/demoinfocs#ParserConfig) needs to be set - see also [`MatchInfoDecryptionKey()`](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v3@master/pkg/demoinfocs#MatchInfoDecryptionKey).</small>
1. <small id="f1">In MM demos the chat is encrypted, so [`ParserConfig.NetMessageDecryptionKey`](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4@master/pkg/demoinfocs#ParserConfig) needs to be set - see also [`MatchInfoDecryptionKey()`](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v4@master/pkg/demoinfocs#MatchInfoDecryptionKey).</small>
2. <small id="f2">Better than some other parsers at the time of writing.</small>

## Performance / Benchmarks
Expand Down Expand Up @@ -242,7 +244,7 @@ e.g.

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/v3/pkg/demoinfocs.debugServerClasses=YES'"`.
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/v4/pkg/demoinfocs.debugServerClasses=YES'"`.

e.g.

Expand Down
Loading

0 comments on commit 663d133

Please sign in to comment.