Skip to content

Commit dfb9e2f

Browse files
authored
pkg/demoinfocs/msg: move from gogo/protobuf to vtprotobuf (#329)
1 parent 21cc886 commit dfb9e2f

35 files changed

+96712
-99256
lines changed

.github/workflows/protobuf.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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/v2/pkg/demoinfocs/msg";\n\n/' proto/cstrike15_usermessages.proto
47+
sed -i '1s/^/option go_package = "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/msg";\n\n/' proto/cstrike15_gcmessages.proto
48+
sed -i '1s/^/option go_package = "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/msg";\n\n/' proto/engine_gcmessages.proto
49+
sed -i '1s/^/option go_package = "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/msg";\n\n/' proto/netmessages.proto
50+
sed -i '1s/^/option go_package = "github.com/markus-wa/demoinfocs-golang/v2/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'

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,11 @@ After adding it to your `PATH` you can use `scripts/generate-interfaces.sh` to u
280280

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

283-
- The latest protobuf generator (`protoc`) from your package manager or https://github.com/google/protobuf/releases
284-
285-
- And `protoc-gen-gogofaster` from [gogoprotobuf](https://github.com/gogo/protobuf) to generate code for go.
286-
287-
go get -u github.com/gogo/protobuf/protoc-gen-gogofaster
288-
289-
[//]: # "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"
290-
[//]: # "Oh and don't try to move these comments above it either"
283+
```
284+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
285+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
286+
go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@latest
287+
```
291288

292289
Make sure both are inside your `PATH` variable.
293290

examples/net-messages/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ Example: Bullet Decal (`BSPDecal`) messages
3434

3535
```go
3636
import (
37-
"github.com/gogo/protobuf/proto"
37+
"google.golang.org/protobuf/proto"
3838

3939
dem "github.com/markus-wa/demoinfocs-golang"
4040
"github.com/markus-wa/demoinfocs-golang/v2/msg"
4141
)
4242

4343
cfg := dem.DefaultParserConfig
4444
cfg.AdditionalNetMessageCreators = map[int]dem.NetMessageCreator{
45-
int(msg.SVC_Messages_svc_BSPDecal): func() proto.Message {
45+
int(msg.SVC_Messages_svc_BSPDecal): func() dem.VTProtobufMessage {
4646
return new(msg.CSVCMsg_BSPDecal)
4747
},
4848
}

examples/net-messages/netmessages.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/gogo/protobuf/proto"
8-
97
ex "github.com/markus-wa/demoinfocs-golang/v2/examples"
108
demoinfocs "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
119
msg "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/msg"
@@ -20,7 +18,7 @@ func main() {
2018
// Configure parsing of BSPDecal net-message
2119
cfg := demoinfocs.DefaultParserConfig
2220
cfg.AdditionalNetMessageCreators = map[int]demoinfocs.NetMessageCreator{
23-
int(msg.SVC_Messages_svc_BSPDecal): func() proto.Message {
21+
int(msg.SVC_Messages_svc_BSPDecal): func() demoinfocs.VTProtobufMessage {
2422
return new(msg.CSVCMsg_BSPDecal)
2523
},
2624
}
@@ -30,7 +28,7 @@ func main() {
3028

3129
// Register handler for BSPDecal messages
3230
p.RegisterNetMessageHandler(func(m *msg.CSVCMsg_BSPDecal) {
33-
fmt.Printf("bullet decal at x=%f y=%f z=%f\n", m.Pos.X, m.Pos.Y, m.Pos.Z)
31+
fmt.Printf("bullet decal at x=%f y=%f z=%f\n", m.Pos.GetX(), m.Pos.GetY(), m.Pos.GetZ())
3432
})
3533

3634
// Parse to end

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module github.com/markus-wa/demoinfocs-golang/v2
22

33
require (
44
github.com/dustin/go-heatmap v0.0.0-20180603032536-b89dbd73785a
5-
github.com/gogo/protobuf v1.3.2
65
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
76
github.com/llgcode/draw2d v0.0.0-20200930101115-bfaf5d914d1e
87
github.com/markus-wa/go-unassert v0.1.2
@@ -12,6 +11,8 @@ require (
1211
github.com/markus-wa/quickhull-go/v2 v2.1.0
1312
github.com/pkg/errors v0.9.1
1413
github.com/stretchr/testify v1.7.0
14+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
15+
google.golang.org/protobuf v1.28.0
1516
)
1617

1718
require (

go.sum

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
44
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
55
github.com/go-gl/gl v0.0.0-20180407155706-68e253793080/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
66
github.com/go-gl/glfw v0.0.0-20180426074136-46a8d530c326/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
7-
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
8-
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
97
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
108
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
119
github.com/golang/geo v0.0.0-20180826223333-635502111454/go.mod h1:vgWZ7cu0fq0KY3PpEHsocXOWJpRtkcbKemU4IUw0M60=
1210
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
1311
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
12+
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
13+
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
14+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
1415
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
15-
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
16-
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
1716
github.com/llgcode/draw2d v0.0.0-20200930101115-bfaf5d914d1e h1:YRRazju3DMGuZTSWEj0nE2SCRcK3DW/qdHQ4UQx7sgs=
1817
github.com/llgcode/draw2d v0.0.0-20200930101115-bfaf5d914d1e/go.mod h1:mVa0dA29Db2S4LVqDYLlsePDzRJLDfdhVZiI15uY0FA=
1918
github.com/llgcode/ps v0.0.0-20150911083025-f1443b32eedb h1:61ndUreYSlWFeCY44JxDDkngVoI7/1MVhEl98Nm0KOk=
@@ -38,35 +37,14 @@ github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
3837
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
3938
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
4039
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
41-
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
42-
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
43-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
44-
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
45-
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
4640
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81 h1:00VmoueYNlNz/aHIilyyQz/MHSqGoWJzpFv/HW8xpzI=
4741
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
48-
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
49-
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
50-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
51-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
52-
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
53-
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
54-
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
55-
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
56-
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
57-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
58-
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
59-
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
60-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
61-
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
62-
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
63-
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
64-
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
65-
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
66-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
67-
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6842
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
43+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
6944
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
45+
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
46+
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
47+
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
7048
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
7149
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
7250
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=

pkg/demoinfocs/demoinfocs_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"testing"
1818
"time"
1919

20-
"github.com/gogo/protobuf/proto"
2120
dispatch "github.com/markus-wa/godispatch"
2221
"github.com/stretchr/testify/assert"
2322

@@ -57,7 +56,7 @@ func TestDemoInfoCs(t *testing.T) {
5756
p := demoinfocs.NewParserWithConfig(f, demoinfocs.ParserConfig{
5857
MsgQueueBufferSize: 1000,
5958
AdditionalNetMessageCreators: map[int]demoinfocs.NetMessageCreator{
60-
4: func() proto.Message { return new(msg.CNETMsg_Tick) },
59+
4: func() demoinfocs.VTProtobufMessage { return new(msg.CNETMsg_Tick) },
6160
},
6261
})
6362

pkg/demoinfocs/fake/parser_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"time"
66

77
assert "github.com/stretchr/testify/assert"
8+
"google.golang.org/protobuf/proto"
89

910
common "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"
1011
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
@@ -88,7 +89,7 @@ func TestParseNextFrameNetMessages(t *testing.T) {
8889

8990
p.MockNetMessages(expected...)
9091
// Message on second frame that shouldn't be dispatched during the first frame
91-
p.MockNetMessages(msg.CSVCMsg_Menu{DialogType: 1, MenuKeyValues: []byte{1, 55, 99}})
92+
p.MockNetMessages(msg.CSVCMsg_Menu{DialogType: proto.Int32(1), MenuKeyValues: []byte{1, 55, 99}})
9293

9394
var actual []interface{}
9495
p.RegisterNetMessageHandler(func(message interface{}) {
@@ -108,7 +109,7 @@ func TestParseToEndNetMessages(t *testing.T) {
108109
expected := []interface{}{
109110
cmdKey(1, 2, 3),
110111
cmdKey(100, 255, 8),
111-
msg.CSVCMsg_Menu{DialogType: 1, MenuKeyValues: []byte{1, 55, 99}},
112+
msg.CSVCMsg_Menu{DialogType: proto.Int32(1), MenuKeyValues: []byte{1, 55, 99}},
112113
}
113114

114115
p.MockNetMessages(expected[:1]...)

pkg/demoinfocs/game_events.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ func (p *parser) handleGameEvent(ge *msg.CSVCMsg_GameEvent) {
2929
return
3030
}
3131

32-
desc := p.gameEventDescs[ge.Eventid]
32+
desc := p.gameEventDescs[ge.GetEventid()]
3333

3434
debugGameEvent(desc, ge)
3535

3636
data := mapGameEventData(desc, ge)
3737

38-
if handler, eventKnown := p.gameEventHandler.gameEventNameToHandler[desc.Name]; eventKnown {
38+
if handler, eventKnown := p.gameEventHandler.gameEventNameToHandler[desc.GetName()]; eventKnown {
3939
// some events are known but have no handler
4040
// these will just be dispatched as GenericGameEvent
4141
if handler != nil {
4242
handler(data)
4343
}
4444
} else {
45-
p.eventDispatcher.Dispatch(events.ParserWarn{Message: fmt.Sprintf("unknown event %q", desc.Name)})
46-
unassert.Error("unknown event %q", desc.Name)
45+
p.eventDispatcher.Dispatch(events.ParserWarn{Message: fmt.Sprintf("unknown event %q", desc.GetName())})
46+
unassert.Error("unknown event %q", desc.GetName())
4747
}
4848

4949
p.eventDispatcher.Dispatch(events.GenericGameEvent{
50-
Name: desc.Name,
50+
Name: desc.GetName(),
5151
Data: data,
5252
})
5353
}
@@ -227,7 +227,7 @@ func (geh gameEventHandler) roundAnnounceLastRoundHalf(map[string]*msg.CSVCMsg_G
227227
}
228228

229229
func (geh gameEventHandler) roundEnd(data map[string]*msg.CSVCMsg_GameEventKeyT) {
230-
winner := common.Team(data["winner"].ValByte)
230+
winner := common.Team(data["winner"].GetValByte())
231231
winnerState := geh.gameState().Team(winner)
232232

233233
var loserState *common.TeamState
@@ -647,10 +647,10 @@ func (geh gameEventHandler) bombEvent(data map[string]*msg.CSVCMsg_GameEventKeyT
647647
const gameEventKeyTypeLong = 3
648648

649649
var site int
650-
if data["site"].Type == gameEventKeyTypeLong {
651-
site = int(data["site"].ValLong)
650+
if data["site"].GetType() == gameEventKeyTypeLong {
651+
site = int(data["site"].GetValLong())
652652
} else {
653-
site = int(data["site"].ValShort)
653+
site = int(data["site"].GetValShort())
654654
}
655655

656656
switch site {
@@ -751,9 +751,9 @@ func (geh gameEventHandler) bombPickup(data map[string]*msg.CSVCMsg_GameEventKey
751751
func (geh gameEventHandler) nadeEvent(data map[string]*msg.CSVCMsg_GameEventKeyT, nadeType common.EquipmentType) events.GrenadeEvent {
752752
thrower := geh.playerByUserID32(data["userid"].GetValShort())
753753
position := r3.Vector{
754-
X: float64(data["x"].ValFloat),
755-
Y: float64(data["y"].ValFloat),
756-
Z: float64(data["z"].ValFloat),
754+
X: float64(data["x"].GetValFloat()),
755+
Y: float64(data["y"].GetValFloat()),
756+
Z: float64(data["z"].GetValFloat()),
757757
}
758758
nadeEntityID := int(data["entityid"].GetValShort())
759759

@@ -868,7 +868,7 @@ func getPlayerWeapon(player *common.Player, wepType common.EquipmentType) *commo
868868
func mapGameEventData(d *msg.CSVCMsg_GameEventListDescriptorT, e *msg.CSVCMsg_GameEvent) map[string]*msg.CSVCMsg_GameEventKeyT {
869869
data := make(map[string]*msg.CSVCMsg_GameEventKeyT, len(d.Keys))
870870
for i, k := range d.Keys {
871-
data[k.Name] = e.Keys[i]
871+
data[k.GetName()] = e.Keys[i]
872872
}
873873

874874
return data

pkg/demoinfocs/game_events_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/stretchr/testify/assert"
8+
"google.golang.org/protobuf/proto"
89

910
common "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"
1011
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
@@ -34,22 +35,22 @@ func TestRoundEnd_LoserState_Score(t *testing.T) {
3435

3536
p.gameEventDescs = map[int32]*msg.CSVCMsg_GameEventListDescriptorT{
3637
1: {
37-
Name: "round_end",
38+
Name: proto.String("round_end"),
3839
Keys: []*msg.CSVCMsg_GameEventListKeyT{
39-
{Name: "winner"},
40-
{Name: "message"},
41-
{Name: "reason"},
40+
{Name: proto.String("winner")},
41+
{Name: proto.String("message")},
42+
{Name: proto.String("reason")},
4243
},
4344
},
4445
}
4546

4647
ge := new(msg.CSVCMsg_GameEvent)
47-
ge.Eventid = 1
48-
ge.EventName = "round_end"
48+
ge.Eventid = proto.Int32(1)
49+
ge.EventName = proto.String("round_end")
4950
ge.Keys = []*msg.CSVCMsg_GameEventKeyT{
50-
{ValByte: 2},
51-
{ValString: "test"},
52-
{ValByte: 9},
51+
{ValByte: proto.Int32(2)},
52+
{ValString: proto.String("test")},
53+
{ValByte: proto.Int32(9)},
5354
}
5455
p.handleGameEvent(ge)
5556

0 commit comments

Comments
 (0)