Skip to content

Commit fb3c622

Browse files
authored
Merge pull request #331 from markus-wa/v3
v3.0.0
2 parents 6269293 + 82e8cba commit fb3c622

File tree

106 files changed

+29156
-99678
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+29156
-99678
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
ci:
77
strategy:
88
matrix:
9-
go-version: [1.11.x, 1.18.x]
9+
go-version: [1.18.x]
1010

1111
runs-on: ubuntu-latest
1212

@@ -36,9 +36,8 @@ jobs:
3636
# install 7zip for decompressing test demos
3737
sudo apt-get install -y p7zip-full
3838
39-
# Install interface generator - go 1.11 doesn't allow specifying a version with go get or go install, so we need to manually git clone
40-
git clone https://github.com/vburenin/ifacemaker /tmp/ifacemaker
41-
pushd /tmp/ifacemaker && git checkout v1.1.0 && go install . && popd
39+
# Install interface generator
40+
go install github.com/vburenin/[email protected]
4241
4342
# Fetch refs for linter
4443
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*

.github/workflows/protobuf.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
if: env.PROTOBUFS_CHANGED == 'true'
2727
uses: actions/setup-go@v2
2828
with:
29-
go-version: 1.14.x
29+
go-version: 1.18.x
3030

3131
- name: Install Protobuf tools
3232
if: env.PROTOBUFS_CHANGED == 'true'
@@ -43,14 +43,14 @@ jobs:
4343
if: env.PROTOBUFS_CHANGED == 'true'
4444
run: |
4545
cd pkg/demoinfocs/msg
46-
sed -i '1s/^/option go_package = "msg";\n\n/' proto/cstrike15_usermessages.proto
47-
sed -i '1s/^/option go_package = "msg";\n\n/' proto/cstrike15_gcmessages.proto
48-
sed -i '1s/^/option go_package = "msg";\n\n/' proto/engine_gcmessages.proto
49-
sed -i '1s/^/option go_package = "msg";\n\n/' proto/netmessages.proto
50-
sed -i '1s/^/option go_package = "msg";\n\n/' proto/steammessages.proto
46+
sed -i '1s/^/option go_package = "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/msg";\n\n/' proto/cstrike15_usermessages.proto
47+
sed -i '1s/^/option go_package = "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/msg";\n\n/' proto/cstrike15_gcmessages.proto
48+
sed -i '1s/^/option go_package = "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/msg";\n\n/' proto/engine_gcmessages.proto
49+
sed -i '1s/^/option go_package = "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/msg";\n\n/' proto/netmessages.proto
50+
sed -i '1s/^/option go_package = "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/msg";\n\n/' proto/steammessages.proto
5151
5252
export PATH=/tmp/protoc/bin:$PATH
53-
protoc -I=proto --gogofaster_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:. proto/*.proto
53+
./generate.sh
5454
5555
- name: Commit changes
5656
if: env.PROTOBUFS_CHANGED == 'true'

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ linters-settings:
6464
disabled-checks:
6565
- ifElseChain
6666
gci:
67-
local-prefixes: github.com/markus-wa/demoinfocs-golang/v2
67+
local-prefixes: github.com/markus-wa/demoinfocs-golang/v3

README.md

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A blazing fast, feature complete and production ready Go library for parsing and
44

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

7-
[![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/v2/pkg/demoinfocs?tab=doc)
7+
[![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)
88
[![Build Status](https://img.shields.io/github/workflow/status/markus-wa/demoinfocs-golang/CI/master?style=flat-square)](https://github.com/markus-wa/demoinfocs-golang/actions)
99
[![codecov](https://img.shields.io/codecov/c/github/markus-wa/demoinfocs-golang?style=flat-square)](https://codecov.io/gh/markus-wa/demoinfocs-golang)
1010
[![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)
@@ -25,7 +25,7 @@ If you have been enjoying this library and are considering donating, please chec
2525

2626
## Go Get
2727

28-
go get -u github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs
28+
go get -u github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs
2929

3030
## Table of Contents
3131

@@ -49,7 +49,7 @@ If you have been enjoying this library and are considering donating, please chec
4949

5050
## Requirements
5151

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

5555
## Quickstart Guide
@@ -66,7 +66,7 @@ go mod init github.com/<YOUR_GITHUB_USER>/my-project
6666
# the module name (github.com/<YOUR_GITHUB_USER>/my-project) can always be changed later
6767
# you can also put example.com/my-project or anything else if you don't plan to publish your project
6868
69-
go get -u github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs
69+
go get -u github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs
7070
```
7171

7272
3. Create a `main.go` file with the example below
@@ -88,8 +88,8 @@ import (
8888
"log"
8989
"os"
9090

91-
dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
92-
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
91+
dem "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs"
92+
events "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events"
9393
)
9494

9595
func main() {
@@ -146,24 +146,24 @@ Check out the [examples](examples) folder for more examples, like [how to genera
146146

147147
### Documentation
148148

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

151151
## Features
152152

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

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

169169
## Performance / Benchmarks
@@ -229,7 +229,7 @@ If your project is using this library feel free to submit a PR or send a message
229229
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.<br>
230230
Side-note: The tag isn't called `debug` to avoid naming conflicts with other libs (and underscores in tags don't work, apparently).
231231

232-
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/v2/pkg/demoinfocs.debugServerClasses=YES'"`
232+
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'"`
233233

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

@@ -281,14 +281,9 @@ After adding it to your `PATH` you can use `scripts/generate-interfaces.sh` to u
281281

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

284-
- The latest protobuf generator (`protoc`) from your package manager or https://github.com/google/protobuf/releases
285-
286-
- And `protoc-gen-gogofaster` from [gogoprotobuf](https://github.com/gogo/protobuf) to generate code for go.
287-
288-
go get -u github.com/gogo/protobuf/protoc-gen-gogofaster
289-
290-
[//]: # "The go get above needs two tabs so it's displayed a) as part of the last list entry and b) as a code-block"
291-
[//]: # "Oh and don't try to move these comments above it either"
284+
```
285+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
286+
```
292287

293288
Make sure both are inside your `PATH` variable.
294289

assets/maps/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

assets/maps/de_ancient.jpg

-133 KB
Binary file not shown.

assets/maps/de_cache.jpg

-83.6 KB
Binary file not shown.

assets/maps/de_canals.jpg

-79.6 KB
Binary file not shown.

assets/maps/de_cbble.jpg

-62.3 KB
Binary file not shown.

assets/maps/de_dust.jpg

-61.8 KB
Binary file not shown.

assets/maps/de_dust2.jpg

-82.6 KB
Binary file not shown.

assets/maps/de_inferno.jpg

-93.2 KB
Binary file not shown.

assets/maps/de_lake.jpg

-84.4 KB
Binary file not shown.

assets/maps/de_mirage.jpg

-88.8 KB
Binary file not shown.

assets/maps/de_nuke.jpg

-82.3 KB
Binary file not shown.

assets/maps/de_nuke_lower.jpg

-80.5 KB
Binary file not shown.

assets/maps/de_overpass.jpg

-93.9 KB
Binary file not shown.

assets/maps/de_santorini.jpg

-81.6 KB
Binary file not shown.

assets/maps/de_season.jpg

-99.2 KB
Binary file not shown.

assets/maps/de_shortdust.jpg

-66.3 KB
Binary file not shown.

assets/maps/de_shortnuke.jpg

-75.8 KB
Binary file not shown.

assets/maps/de_shorttrain.jpg

-53.2 KB
Binary file not shown.

assets/maps/de_train.jpg

-88.9 KB
Binary file not shown.

assets/maps/de_vertigo.jpg

-101 KB
Binary file not shown.

assets/maps/de_vertigo_lower.jpg

-84.7 KB
Binary file not shown.

examples/common.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
package examples
22

33
import (
4-
"encoding/json"
54
"flag"
6-
"fmt"
7-
"image"
85
"io"
96
"io/ioutil"
10-
"net/http"
117
"os"
12-
13-
"github.com/golang/geo/r2"
14-
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/metadata"
158
)
169

1710
// DemoPathFromArgs returns the value of the -demo command line flag.
@@ -58,57 +51,3 @@ func RedirectStdout(f func()) {
5851

5952
os.Stdout = old
6053
}
61-
62-
type mapMetadata struct {
63-
PosX float64 `json:"pos_x,string"`
64-
PosY float64 `json:"pos_y,string"`
65-
Scale float64 `json:"scale,string"`
66-
}
67-
68-
// GetMapMetadata fetches metadata for a specific map version from
69-
// `https://radar-overviews.csgo.saiko.tech/<map>/<crc>/info.json`.
70-
// Panics if any error occurs.
71-
func GetMapMetadata(name string, crc uint32) metadata.Map {
72-
url := fmt.Sprintf("https://radar-overviews.csgo.saiko.tech/%s/%d/info.json", name, crc)
73-
74-
resp, err := http.Get(url)
75-
checkError(err)
76-
77-
defer resp.Body.Close()
78-
79-
var data map[string]mapMetadata
80-
81-
err = json.NewDecoder(resp.Body).Decode(&data)
82-
checkError(err)
83-
84-
mapInfo, ok := data[name]
85-
if !ok {
86-
panic(fmt.Sprintf("failed to get map info.json entry for %q", name))
87-
}
88-
89-
return metadata.Map{
90-
Name: name,
91-
PZero: r2.Point{
92-
X: mapInfo.PosX,
93-
Y: mapInfo.PosY,
94-
},
95-
Scale: mapInfo.Scale,
96-
}
97-
}
98-
99-
// GetMapMetadata fetches metadata for a specific map version from
100-
// `https://radar-overviews.csgo.saiko.tech/<map>/<crc>/info.json`.
101-
// Panics if any error occurs.
102-
func GetMapRadar(name string, crc uint32) image.Image {
103-
url := fmt.Sprintf("https://radar-overviews.csgo.saiko.tech/%s/%d/radar.png", name, crc)
104-
105-
resp, err := http.Get(url)
106-
checkError(err)
107-
108-
defer resp.Body.Close()
109-
110-
img, _, err := image.Decode(resp.Body)
111-
checkError(err)
112-
113-
return img
114-
}

examples/common_test.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/encrypted-net-messages/enc_net_msg.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"log"
77
"os"
88

9-
dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
10-
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
9+
dem "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs"
10+
"github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events"
1111
)
1212

1313
func checkErr(err error) {

examples/entities/entities.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import (
55
_ "image/jpeg"
66
"os"
77

8-
ex "github.com/markus-wa/demoinfocs-golang/v2/examples"
9-
demoinfocs "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
10-
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
11-
st "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/sendtables"
8+
ex "github.com/markus-wa/demoinfocs-golang/v3/examples"
9+
demoinfocs "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs"
10+
events "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events"
11+
st "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/sendtables"
1212
)
1313

1414
// Run like this: go run entities.go -demo /path/to/demo.dem

examples/heatmap/heatmap.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ import (
66
"image/jpeg"
77
"os"
88

9-
heatmap "github.com/dustin/go-heatmap"
10-
schemes "github.com/dustin/go-heatmap/schemes"
119
r2 "github.com/golang/geo/r2"
10+
heatmap "github.com/markus-wa/go-heatmap/v2"
11+
schemes "github.com/markus-wa/go-heatmap/v2/schemes"
1212

13-
ex "github.com/markus-wa/demoinfocs-golang/v2/examples"
14-
demoinfocs "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
15-
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
16-
metadata "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/metadata"
17-
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/msg"
13+
ex "github.com/markus-wa/demoinfocs-golang/v3/examples"
14+
demoinfocs "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs"
15+
events "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events"
16+
"github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/msg"
1817
)
1918

2019
const (
@@ -42,16 +41,16 @@ func main() {
4241
checkError(err)
4342

4443
var (
45-
mapMetadata metadata.Map
44+
mapMetadata ex.Map
4645
mapRadarImg image.Image
4746
)
4847

4948
p.RegisterNetMessageHandler(func(msg *msg.CSVCMsg_ServerInfo) {
5049
// Get metadata for the map that the game was played on for coordinate translations
51-
mapMetadata = ex.GetMapMetadata(header.MapName, msg.MapCrc)
50+
mapMetadata = ex.GetMapMetadata(header.MapName, msg.GetMapCrc())
5251

5352
// Load map overview image
54-
mapRadarImg = ex.GetMapRadar(header.MapName, msg.MapCrc)
53+
mapRadarImg = ex.GetMapRadar(header.MapName, msg.GetMapCrc())
5554
})
5655

5756
// Register handler for WeaponFire, triggered every time a shot is fired

examples/heatmap/heatmap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"os"
55
"testing"
66

7-
"github.com/markus-wa/demoinfocs-golang/v2/examples"
7+
"github.com/markus-wa/demoinfocs-golang/v3/examples"
88
)
99

1010
// Just make sure the example runs

0 commit comments

Comments
 (0)