Skip to content

Commit 96285c2

Browse files
authored
Merge pull request #254 from markus-wa/impact-data
Operation Broken Fang: RoundImpactScoreData
2 parents d4a3aa3 + ab2c22e commit 96285c2

File tree

8 files changed

+35
-10
lines changed

8 files changed

+35
-10
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ linters:
1717
- gomnd
1818
- exhaustivestruct
1919
- godot
20+
- gofumpt
2021
issues:
2122
exclude-rules:
2223
# Exclude some linters from running on tests files.

pkg/demoinfocs/common/player.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func (p *Player) ViewDirectionY() float32 {
281281
}
282282

283283
// Position returns the in-game coordinates.
284-
//Like the ones you get from cl_showpos 1.
284+
// Like the ones you get from cl_showpos 1.
285285
func (p *Player) Position() r3.Vector {
286286
if p.Entity == nil {
287287
return r3.Vector{}

pkg/demoinfocs/datatables_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func TestParser_BindNewPlayer_Issue98_Reconnect(t *testing.T) {
7272
func TestParser_BindNewPlayer_PlayerSpotted_Under32(t *testing.T) {
7373
testPlayerSpotted(t, "m_bSpottedByMask.000")
7474
}
75+
7576
func TestParser_BindNewPlayer_PlayerSpotted_Over32(t *testing.T) {
7677
testPlayerSpotted(t, "m_bSpottedByMask.001")
7778
}

pkg/demoinfocs/debug_on.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ const (
1818

1919
// Can be overridden via -ldflags '-X github.com/markus-wa/demoinfocs-golang.debugServerClasses=YES'
2020
// Oh and btw we cant use bools for this, Go says 'cannot use -X with non-string symbol'
21-
var debugGameEvents = yes
22-
var debugUnhandledMessages = no
23-
var debugIngameTicks = yes
24-
var debugDemoCommands = no
25-
var debugServerClasses = no
21+
var (
22+
debugGameEvents = yes
23+
debugUnhandledMessages = no
24+
debugIngameTicks = yes
25+
debugDemoCommands = no
26+
debugServerClasses = no
27+
)
2628

2729
func debugGameEvent(d *msg.CSVCMsg_GameEventListDescriptorT, ge *msg.CSVCMsg_GameEvent) {
2830
const (

pkg/demoinfocs/events/events.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,8 @@ type PlayerSpottersChanged struct {
541541
type ConVarsUpdated struct {
542542
UpdatedConVars map[string]string
543543
}
544+
545+
// RoundImpactScoreData contains impact assessments of events that happened during the last round.
546+
type RoundImpactScoreData struct {
547+
RawMessage *msg.CCSUsrMsg_RoundImpactScoreData
548+
}

pkg/demoinfocs/events/events_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func (p demoInfoProviderMock) TickRate() float64 {
6969
func (p demoInfoProviderMock) FindPlayerByHandle(int) *common.Player {
7070
return nil
7171
}
72+
7273
func (p demoInfoProviderMock) PlayerResourceEntity() st.Entity {
7374
return nil
7475
}

pkg/demoinfocs/user_messages.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ func newUserMessageHandler(parser *parser) userMessageHandler {
4444
umh := userMessageHandler{parser: parser}
4545

4646
umh.msgTypeToHandler = map[msg.ECstrike15UserMessages]userMessageHandlerFunc{
47-
msg.ECstrike15UserMessages_CS_UM_SayText: umh.sayText,
48-
msg.ECstrike15UserMessages_CS_UM_SayText2: umh.sayText2,
49-
msg.ECstrike15UserMessages_CS_UM_ServerRankUpdate: umh.rankUpdate,
47+
msg.ECstrike15UserMessages_CS_UM_SayText: umh.sayText,
48+
msg.ECstrike15UserMessages_CS_UM_SayText2: umh.sayText2,
49+
msg.ECstrike15UserMessages_CS_UM_ServerRankUpdate: umh.rankUpdate,
50+
msg.ECstrike15UserMessages_CS_UM_RoundImpactScoreData: umh.roundImpactScoreData,
5051
// TODO: handle more user messages (if they are interesting)
5152
// Maybe msg.ECstrike15UserMessages_CS_UM_RadioText
5253
}
@@ -142,3 +143,17 @@ func (umh userMessageHandler) rankUpdate(um *msg.CSVCMsg_UserMessage) {
142143
})
143144
}
144145
}
146+
147+
func (umh userMessageHandler) roundImpactScoreData(um *msg.CSVCMsg_UserMessage) {
148+
impactData := new(msg.CCSUsrMsg_RoundImpactScoreData)
149+
err := impactData.Unmarshal(um.MsgData)
150+
151+
if err != nil {
152+
umh.dispatch(events.ParserWarn{Message: fmt.Sprintf("failed to decode RoundImpactScoreData message: %s", err.Error())})
153+
unassert.Error("failed to decode RoundImpactScoreData message: %s", err.Error())
154+
}
155+
156+
umh.dispatch(events.RoundImpactScoreData{
157+
RawMessage: impactData,
158+
})
159+
}

test/cs-demos

Submodule cs-demos updated from 87e0ac7 to 110835d

0 commit comments

Comments
 (0)