Skip to content

Commit 72b4fc4

Browse files
committed
Merge branch 'master' into v1.0.0
2 parents 9eead09 + 7c9e8ae commit 72b4fc4

File tree

10 files changed

+145
-35
lines changed

10 files changed

+145
-35
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
**Describe the bug**
8+
A clear and concise description of what the bug is.
9+
10+
**To Reproduce**
11+
Download link to an affected demo: HLTV, ESEA, Matchmaking share link or other
12+
13+
Code:
14+
```go
15+
func x() {
16+
}
17+
```
18+
19+
**Expected behavior**
20+
A clear and concise description of what you expected to happen.
21+
22+
**Library version**
23+
v1.0.0-beta.0
24+
25+
**Additional context**
26+
Add any other context about the problem here - like your OS if that could be relevant.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Higher goal**
8+
Describe what you're trying to do on a high level. i.e. 'I want to create a heatmap of x but can't get that data' instead of 'I want a new function A() to provide me with data x'.
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Question / Suggestion / Other
3+
about: Anything that isn't exactly a bug or feature
4+
5+
---
6+
7+
<!-- If it's a simple question, you may be able to get help over at https://gitter.im/csgodemos/demoinfo-lib -->

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# demoinfocs-golang
1+
# demoinfocs-golang - A CSGO Demo Parser
22

3-
Is a high performance CS:GO demo parser written in Go based on [Valve's demoinfogo](https://github.com/ValveSoftware/csgo-demoinfo) and [SatsHelix's demoinfo](https://github.com/StatsHelix/demoinfo).
3+
Is a Go library for super fast parsing and analysing of Counter Strike: Global Offensive (CSGO) demos (aka replays). It is based on [Valve's demoinfogo](https://github.com/ValveSoftware/csgo-demoinfo) and [SatsHelix's demoinfo](https://github.com/StatsHelix/demoinfo).
44

55
[![GoDoc](https://godoc.org/github.com/markus-wa/demoinfocs-golang?status.svg)](https://godoc.org/github.com/markus-wa/demoinfocs-golang)
66
[![Build Status](https://travis-ci.org/markus-wa/demoinfocs-golang.svg?branch=master)](https://travis-ci.org/markus-wa/demoinfocs-golang)
@@ -10,8 +10,7 @@ Is a high performance CS:GO demo parser written in Go based on [Valve's demoinfo
1010

1111
## Discussions / Chat
1212

13-
You can use gitter to ask questions and discuss ideas about this project.<br>
14-
There are also [some other rooms](https://gitter.im/csgodemos) available around the topic of CS:GO demos.
13+
You can use gitter to ask questions and discuss ideas about this project.
1514

1615
[![Gitter chat](https://badges.gitter.im/csgodemos/demoinfo-lib.png)](https://gitter.im/csgodemos/demoinfo-lib)
1716

@@ -86,12 +85,13 @@ This doesn't look too interesting on it's own but that can be helped by quickly
8685

8786
## Features
8887

89-
* Game events
90-
* Grenade projectiles / trajectories - [doc](https://godoc.org/github.com/markus-wa/demoinfocs-golang#GameState.GrenadeProjectiles) [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/nade-trajectories)
88+
* Game events (kills, shots, round starts/ends, footsteps etc.) - [docs](https://godoc.org/github.com/markus-wa/demoinfocs-golang/events) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/print-events)
89+
* Tracking of game-state (players, teams, grenades etc.) - [docs](https://godoc.org/github.com/markus-wa/demoinfocs-golang#GameState)
90+
* Grenade projectiles / trajectories - [docs](https://godoc.org/github.com/markus-wa/demoinfocs-golang#GameState.GrenadeProjectiles) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/nade-trajectories)
9191
* Access to entities, server-classes & data-tables - [docs](https://godoc.org/github.com/markus-wa/demoinfocs-golang/sendtables#ServerClasses) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/entities)
92-
* Access to all net-messages
93-
* Chat & console messages <sup id="achat1">1</sup>
94-
* [Easy debugging](#debugging) via build-flags
92+
* Access to all net-messages - [docs](https://godoc.org/github.com/markus-wa/demoinfocs-golang#NetMessageCreator) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/net-messages)
93+
* Chat & console messages <sup id="achat1">1</sup> - [docs](https://godoc.org/github.com/markus-wa/demoinfocs-golang/events#ChatMessageEvent) / [example](https://github.com/markus-wa/demoinfocs-golang/tree/master/examples/print-events)
94+
* [Easy debugging via build-flags](#debugging)
9595
* Built with performance & concurrency in mind
9696

9797
1. <small id="f1">Only for some demos; in MM demos the chat is encrypted for example.</small>

events/events.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -317,30 +317,30 @@ type PlayerDisconnectEvent struct {
317317

318318
// SayTextEvent signals a chat message. It contains the raw
319319
// network message data for admin / console messages.
320-
// EntityIndex will probably always be 0
320+
// EntIdx will probably always be 0
321321
// See ChatMessageEvent and SayText2Event for player chat messages.
322322
type SayTextEvent struct {
323-
EntityIndex int
324-
Text string
325-
IsChat bool
326-
IsChatAll bool
323+
EntIdx int // Not sure what this is, doesn't seem to be the entity-ID
324+
Text string
325+
IsChat bool // Not sure, from the net-message
326+
IsChatAll bool // Seems to always be false, team chat might not be recorded
327327
}
328328

329-
// SayText2Event signals a chat message. It just contains the raw network message
330-
// for player chat messages, ChatMessageEvent may be more interesting.
329+
// SayText2Event signals a chat message. It just contains the raw network message.
330+
// For player chat messages, ChatMessageEvent may be more interesting.
331331
// Team chat is generally not recorded so IsChatAll will probably always be false.
332332
// See SayTextEvent for admin / console messages.
333333
type SayText2Event struct {
334-
Sender *common.Player
335-
MsgName string
336-
Params []string
337-
IsChat bool
338-
IsChatAll bool
334+
EntIdx int // Not sure what this is, doesn't seem to be the entity-ID
335+
MsgName string // The message type, e.g. Cstrike_Chat_All for global chat
336+
Params []string // The message's parameters, for Cstrike_Chat_All parameter 1 is the player and 2 the message for example
337+
IsChat bool // Not sure, from the net-message
338+
IsChatAll bool // Seems to always be false, team chat might not be recorded
339339
}
340340

341341
// ChatMessageEvent signals a player generated chat message.
342342
// Since team chat is generally not recorded IsChatAll will probably always be false.
343-
// See SayTextEvent for admin / console messages and SayText2Event for raw network packages.
343+
// See SayTextEvent for admin / console messages and SayText2Event for raw network package data.
344344
type ChatMessageEvent struct {
345345
Sender *common.Player
346346
Text string

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Here you can find a overview of examples on how to use demoinfocs-golang.
88
|[nade-trajectories](nade-trajectories)|Map overview with grenade trajectories|
99
|[entities](entities)|Using unhandled data from entities (`Parser.ServerClasses()`)|
1010
|[net-messages](net-messages)|Parsing and handling custom net-messages|
11-
|[print-events](print-events)|Printig kills & scores|
11+
|[print-events](print-events)|Printing kills, scores & chat messages|

examples/print-events/README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Printing event infos
22

3-
This example shows how to use the library to print out information of some key game events - kills and team scores.
3+
This example shows how to use the library to print out information of some key game events - kills, team scores & chat messages.
44

55
## Running the example
66

@@ -11,6 +11,10 @@ This example shows how to use the library to print out information of some key g
1111
```
1212
Map: de_cache
1313
[T]xms*ASUS ♥ /F/ <AK-47 (HS)> [CT]crisby
14+
Chat - [T]to1nou * Seagate says: hf
15+
Chat - [CT]syrsoNR says: hfhf
16+
Chat - [CT]keev says: ,.+*`*+.,_,.+*`*+., GL & HF ,.+*`*+.,_,.+*`*+.,
17+
Chat - [T]ALEX * Intel says: hfhf
1418
[CT]tiziaN <USP-S (HS)> [T]Ex6TenZ-BALLISTIX
1519
[CT]tiziaN <USP-S> [T]mistou * Cooler Master
1620
[CT]tiziaN <USP-S (HS)> [T]ALEX * Intel
@@ -26,8 +30,10 @@ Round finished: winnerSide=CT ; score=1:0
2630
[CT]crisby <UMP-45 (HS)> [T]to1nou * Seagate
2731
[CT]kzy LJ∼ <FAMAS> [T]Ex6TenZ-BALLISTIX
2832
[CT]kzy LJ∼ <FAMAS (HS)> [T]xms*ASUS ♥ /F/
33+
Chat - [CT]syrsoNR says: ns
2934
[CT]keev <UMP-45> [T]mistou * Cooler Master
3035
Round finished: winnerSide=CT ; score=2:0
36+
Chat - [T]Ex6TenZ-BALLISTIX says: ty
3137
[CT]crisby <UMP-45 (HS)> [T]to1nou * Seagate
3238
[CT]kzy LJ∼ <FAMAS (HS)> [T]Ex6TenZ-BALLISTIX
3339
[CT]crisby <USP-S> [CT]kzy LJ∼
@@ -54,6 +60,9 @@ Round finished: winnerSide=CT ; score=4:0
5460
[CT]tiziaN <AK-47> [T]ALEX * Intel
5561
[CT]keev <AWP> [T]Ex6TenZ-BALLISTIX
5662
Round finished: winnerSide=CT ; score=5:0
63+
Chat - [T]ALEX * Intel says: hp tiz?
64+
Chat - [CT]syrsoNR says: 48
65+
Chat - [T]ALEX * Intel says: ty
5766
[CT]keev <AWP> [T]mistou * Cooler Master
5867
[T]Ex6TenZ-BALLISTIX <Tec-9 (HS)> [CT]keev
5968
[T]Ex6TenZ-BALLISTIX <Tec-9 (HS)> [CT]tiziaN
@@ -130,6 +139,10 @@ Round finished: winnerSide=CT ; score=11:3
130139
[T]to1nou * Seagate <AK-47> [CT]kzy LJ∼
131140
[T]xms*ASUS ♥ /F/ <AK-47> [CT]crisby
132141
Round finished: winnerSide=T ; score=4:11
142+
Chat - [T]to1nou * Seagate says: gh
143+
Chat - [CT]syrsoNR says: gh
144+
Chat - [T]ALEX * Intel says: gh
145+
Chat - [T]keev says: ,.+*`*+.,_,.+*`*+., GL & HF ,.+*`*+.,_,.+*`*+.,
133146
[CT]mistou * Cooler Master <P2000 (HS)> [T]tiziaN
134147
[CT]mistou * Cooler Master <P2000 (HS)> [T]syrsoNR
135148
[CT]mistou * Cooler Master <P2000 (HS)> [T]keev
@@ -203,6 +216,15 @@ Round finished: No winner (tie)
203216
[CT]Ex6TenZ-BALLISTIX <World> [CT]Ex6TenZ-BALLISTIX
204217
[CT]to1nou * Seagate <World> [CT]to1nou * Seagate
205218
Round finished: No winner (tie)
219+
Chat - [T]keev says: we have no money
220+
Chat - [CT]mistou * Cooler Master says: same here
221+
Chat - [CT]ALEX * Intel says: we have everything :/
222+
Chat - [T]crisby says: load backup again
223+
Chat - [CT]ALEX * Intel says: oh mistou dsnt
224+
Chat - [T]keev says: haha
225+
Chat - [T]keev says: need backup agaiN
226+
Chat - [CT]ALEX * Intel says: yy
227+
Chat - [CT]mistou * Cooler Master says: yup
206228
[CT]ALEX * Intel <World> [CT]ALEX * Intel
207229
[CT]xms*ASUS ♥ /F/ <World> [CT]xms*ASUS ♥ /F/
208230
[CT]to1nou * Seagate <World> [CT]to1nou * Seagate
@@ -214,6 +236,22 @@ Round finished: No winner (tie)
214236
[T]keev <World> [T]keev
215237
[T]crisby <World> [T]crisby
216238
Round finished: No winner (tie)
239+
Chat - [CT]mistou * Cooler Master says: good
240+
Chat - [T]keev says: fine
241+
Chat - [T]keev says: rdy?
242+
Chat - [CT]to1nou * Seagate says: 1s
243+
Chat - [CT]Ex6TenZ-BALLISTIX says: 2s
244+
Chat - [T]keev says: 1 or 2
245+
Chat - [CT]ALEX * Intel says: 10
246+
Chat - [CT]to1nou * Seagate says: 3
247+
Chat - [T]keev says: :spazdunno:
248+
Chat - [T]keev says: :D
249+
Chat - [CT]to1nou * Seagate says: hf rdy
250+
Chat - [CT]Ex6TenZ-BALLISTIX says: rdy
251+
Chat - [CT]ALEX * Intel says: !unpause
252+
Chat - [T]keev says: !pause
253+
Chat - [T]keev says: cs buG
254+
Chat - [T]keev says: but liv
217255
[CT]mistou * Cooler Master <AWP> [T]tiziaN
218256
[T]kzy LJ∼ <p250> [CT]mistou * Cooler Master
219257
[T]keev <Tec-9> [CT]xms*ASUS ♥ /F/
@@ -222,6 +260,11 @@ Round finished: No winner (tie)
222260
[CT]to1nou * Seagate <AWP> [T]syrsoNR
223261
[CT]to1nou * Seagate <AWP> [T]crisby
224262
Round finished: winnerSide=T ; score=14:10
263+
Chat - [T]keev says: rdy?
264+
Chat - [CT]to1nou * Seagate says: yes
265+
Chat - [T]keev says: !unpause
266+
Chat - [CT]to1nou * Seagate says: hf
267+
Chat - [T]keev says: hfhf
225268
[CT]to1nou * Seagate <AWP> [T]crisby
226269
[T]tiziaN <AK-47> [CT]Ex6TenZ-BALLISTIX
227270
[CT]mistou * Cooler Master <Five-SeveN (HS)> [T]syrsoNR
@@ -262,4 +305,10 @@ Round finished: winnerSide=CT ; score=13:15
262305
[T]crisby <AK-47 (HS)> [CT]Ex6TenZ-BALLISTIX
263306
[T]keev <Tec-9> [CT]to1nou * Seagate
264307
Round finished: winnerSide=T ; score=16:13
308+
Chat - [CT]xms*ASUS ♥ /F/ says: gg
309+
Chat - [CT]ALEX * Intel says: gg
310+
Chat - [CT]to1nou * Seagate says: gg
311+
Chat - [CT]Ex6TenZ-BALLISTIX says: wp
312+
Chat - [T]tiziaN says: gg
313+
Chat - [T]syrsoNR says: gggg
265314
```

examples/print-events/print_events.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ func main() {
5252
}
5353
})
5454

55+
// Register handler for chat messages to print them
56+
p.RegisterEventHandler(func(e events.ChatMessageEvent) {
57+
fmt.Printf("Chat - %s says: %s\n", formatPlayer(e.Sender), e.Text)
58+
})
59+
5560
// Parse to end
5661
err = p.ParseToEnd()
5762
checkError(err)

game_events.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,10 @@ func (p *Parser) handleUserMessage(um *msg.CSVCMsg_UserMessage) {
487487
}
488488

489489
p.eventDispatcher.Dispatch(events.SayTextEvent{
490-
EntityIndex: int(st.EntIdx),
491-
IsChat: st.Chat,
492-
IsChatAll: st.Textallchat,
493-
Text: st.Text,
490+
EntIdx: int(st.EntIdx),
491+
IsChat: st.Chat,
492+
IsChatAll: st.Textallchat,
493+
Text: st.Text,
494494
})
495495

496496
case msg.ECstrike15UserMessages_CS_UM_SayText2:
@@ -500,9 +500,8 @@ func (p *Parser) handleUserMessage(um *msg.CSVCMsg_UserMessage) {
500500
p.eventDispatcher.Dispatch(events.ParserWarnEvent{Message: fmt.Sprintf("Failed to decode SayText2 message: %s", err.Error())})
501501
}
502502

503-
sender := p.gameState.playersByUserID[int(st.EntIdx)]
504503
p.eventDispatcher.Dispatch(events.SayText2Event{
505-
Sender: sender,
504+
EntIdx: int(st.EntIdx),
506505
IsChat: st.Chat,
507506
IsChatAll: st.Textallchat,
508507
MsgName: st.MsgName,
@@ -513,6 +512,15 @@ func (p *Parser) handleUserMessage(um *msg.CSVCMsg_UserMessage) {
513512
case "Cstrike_Chat_All":
514513
fallthrough
515514
case "Cstrike_Chat_AllDead":
515+
var sender *common.Player
516+
for _, pl := range p.gameState.playersByUserID {
517+
// This could be a problem if the player changed his name
518+
// as the name is only set initially and never updated
519+
if pl.Name == st.Params[0] {
520+
sender = pl
521+
}
522+
}
523+
516524
p.eventDispatcher.Dispatch(events.ChatMessageEvent{
517525
Sender: sender,
518526
Text: st.Params[1],

sendtables/propdecoder.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,15 @@ func (propertyDecoder) decodeArray(fProp *flattenedPropEntry, reader *bit.BitRea
290290
numBits++
291291
}
292292

293-
nElements := int(reader.ReadInt(numBits))
294-
295-
res := make([]PropertyValue, 0, nElements)
293+
res := make([]PropertyValue, int(reader.ReadInt(numBits)))
296294

297295
tmp := &Property{
298296
entry: &flattenedPropEntry{prop: fProp.arrayElementProp},
299297
}
300298

301-
for i := 0; i < nElements; i++ {
299+
for i := range res {
302300
propDecoder.decodeProp(tmp, reader)
303-
res = append(res, tmp.value)
301+
res[i] = tmp.value
304302
}
305303

306304
return res

0 commit comments

Comments
 (0)