Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4: Support Counter-Strike 2 #383

Merged
merged 120 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
fdc3c5d
protobuf: updated to 5241dc7ccc9638aa24a5894e2fcabfa42285d255
github-actions[bot] Mar 23, 2023
3cbbb6e
Merge remote-tracking branch 'origin/master' into update-protobufs
markus-wa Mar 23, 2023
1c11b45
revert msg to s1, s2 is in msgs2
markus-wa Mar 23, 2023
4c4228f
WIP: parse Source 2 protos
markus-wa Mar 23, 2023
4bacd8c
s2: fix demo stop command
markus-wa Mar 23, 2023
af45dfa
s2: parse and dispatch net messages
markus-wa Mar 23, 2023
ce626d8
s2 progress
markus-wa Mar 28, 2023
67c9936
s2 event parsing
markus-wa Mar 28, 2023
0717011
s2 entity WIP (crashes)
markus-wa Mar 28, 2023
65d3fa0
tests: add -s2dem flag
markus-wa Mar 30, 2023
3cce79a
s2: some progress on entity parsing
markus-wa Mar 30, 2023
206e60f
s2: more minor progress
markus-wa Mar 30, 2023
227abd0
s2 simplifications
markus-wa Mar 30, 2023
dee997e
try to fix entity parsing
markus-wa May 15, 2023
582d55a
Merge pull request #384 from markus-wa/s2-entities
markus-wa May 18, 2023
f32db38
s2: fix proto name conflict
markus-wa May 18, 2023
cfbc213
fix CI (generated interfaces check)
markus-wa May 18, 2023
21b17a2
fix s1 stringtables
markus-wa May 18, 2023
f22f30b
add s2 test demo to dataset
markus-wa May 18, 2023
8e2146d
remove dead code
markus-wa May 18, 2023
0f49e28
add hltv_versioninfo to known events
markus-wa May 18, 2023
cfd9e52
upgrade golangci-lint
markus-wa May 18, 2023
d3c8779
fix & simplify a bunch of s2 code
markus-wa May 18, 2023
5dc8727
WIP: s2 entities part 2
markus-wa May 18, 2023
f156a8b
wip: serverclass iface
markus-wa May 28, 2023
9a30b33
S2 progress
markus-wa Jun 3, 2023
f425f2f
S2 PlayerController + PlayerPawn
markus-wa Jun 3, 2023
845c1da
fix isSource2()
markus-wa Jun 3, 2023
2c97ec8
S2 progress: parsing with player entities successful
markus-wa Jun 4, 2023
99d885f
S2 fix team scores
markus-wa Jun 4, 2023
0b1b9fe
fix test compilation
markus-wa Jun 4, 2023
7f64986
S2: fix pos + smaller fixes
markus-wa Jun 4, 2023
0eab70a
fix IsAlive()
markus-wa Jun 4, 2023
c2b617a
fix IsAlive test
markus-wa Jun 4, 2023
23ee21a
linting fixes
markus-wa Jun 4, 2023
afe697a
Merge pull request #385 from markus-wa/s2-entities-part2
markus-wa Jun 4, 2023
27d74d4
small s2 fixes
markus-wa Jul 9, 2023
4191c03
questionable S2 fixes
markus-wa Jul 9, 2023
4ce2670
cs2: fix after recent game updates
markus-wa Jul 9, 2023
6954733
cs2: fix namespace conflict (again)
markus-wa Jul 9, 2023
c4f7d82
fix: raise DataTablesParsed on CDemoClassInfo msg
akiver Aug 2, 2023
850ab37
fix: add AnimationData msg to known msg creators list
akiver Aug 2, 2023
5fed1a6
fix: float decoders round/cast issue
akiver Aug 2, 2023
c298f50
fix: entity prop values not updated properly
akiver Aug 2, 2023
3f1ed9e
feat: update header values from CDemoFileInfo
akiver Aug 2, 2023
ae10a7c
Merge pull request #391 from akiver/s2-1
markus-wa Aug 3, 2023
d33a909
tests: fix TestRecoverFromUnexpectedEOF
markus-wa Aug 3, 2023
79b38bd
tests: disable TestPlayer_Armor
markus-wa Aug 3, 2023
29189b5
fix CodeQL go/incorrect-integer-conversion
markus-wa Aug 3, 2023
a9b2d53
fix: working player position
akiver Aug 4, 2023
c43868d
fix: make some player props working
akiver Aug 4, 2023
bf8f7cb
Merge pull request #392 from akiver/s2-2
markus-wa Aug 4, 2023
3e0d48f
feat: update header info from CDemoFileHeader and detect POV demos
akiver Aug 4, 2023
026c2d1
Merge pull request #394 from akiver/s2-3
markus-wa Aug 6, 2023
7371fa2
cs2: implement polyType for CCSGameModeRules_Noop
markus-wa Aug 6, 2023
b19b7f0
cs2: fix poly type serializers
markus-wa Aug 6, 2023
744b6ba
cs2: parseFrameFn
markus-wa Aug 6, 2023
5ea52a2
cs2: PropertyValue.Any for csgo
markus-wa Aug 6, 2023
733c05a
cs2: fix OnDestroy()
markus-wa Aug 6, 2023
f7494ee
cs2: extract polyTypeIndex var for debugging
markus-wa Aug 6, 2023
39d83e4
cs2.md - some notes & docs of cs2 events & net messages
markus-wa Aug 6, 2023
fe2a49f
cs2: add isSource2 method to demoInfoProvider
BestAwperEver Aug 7, 2023
7b0d0ba
fix: return an empty position if pawnEntity is nil
BestAwperEver Aug 7, 2023
961e910
feat: weapons support
akiver Aug 7, 2023
872e473
fix: player pitch/yaw
akiver Aug 5, 2023
557354f
Merge pull request #396 from akiver/s2-bind-weapons
markus-wa Aug 7, 2023
56883fa
Merge pull request #395 from BestAwperEver/demoInfoProvider-isSource2
markus-wa Aug 7, 2023
f1f4260
fix: update player's team based on prop
akiver Aug 7, 2023
44e4611
fix: player's Source 2 props access
akiver Aug 7, 2023
2a2c40d
feat: add OvertimeCount game state prop
akiver Aug 7, 2023
c445646
Merge pull request #397 from akiver/s2-more
markus-wa Aug 7, 2023
1066d6a
cs2: add props to cs2.md
markus-wa Aug 8, 2023
877a3da
examples: clean up
markus-wa Aug 8, 2023
8b28235
cs2: fix grenade projectiles
markus-wa Aug 8, 2023
7c3faa9
cs2: re-fix #42 grenades at end of round
markus-wa Aug 8, 2023
1b802e4
fix: missing mocks test
akiver Aug 8, 2023
87bf84a
csgo: fix nade trajectories
markus-wa Aug 9, 2023
664b09d
Merge branch 's2' into s2-projectiles
markus-wa Aug 10, 2023
ef9e219
Merge pull request #398 from akiver/s2-projectiles
markus-wa Aug 10, 2023
bf4c6e5
fix compilation error after merge
markus-wa Aug 10, 2023
1b0d771
fix: adjust IsSpottedBy for source 2
BestAwperEver Aug 10, 2023
44d447d
Merge pull request #399 from BestAwperEver/s2-is-spotted-by
markus-wa Aug 10, 2023
47e9228
fix: player.isAlive not accurate
akiver Aug 10, 2023
f7e17ad
feat: add missing round end reason values
akiver Aug 10, 2023
ec4cba6
feat: handle convar message
akiver Aug 10, 2023
7c66403
fix: bomb carrier always nil
akiver Aug 10, 2023
a38a979
fix: player pawn entity ID not updated
akiver Aug 10, 2023
5d11edd
feat: update playback values for demos with missing CDemoFileInfo msg
akiver Aug 13, 2023
1dc7546
fix: inferno owner may be nil
akiver Aug 14, 2023
ca102fe
Merge pull request #400 from akiver/s2-fixes
markus-wa Aug 14, 2023
9b19485
fix: fallback for the case of nil entity
BestAwperEver Aug 15, 2023
93932e9
feat: more source 2 player props support
akiver Aug 15, 2023
de76ed0
Merge pull request #402 from akiver/s2-player
markus-wa Aug 16, 2023
cb5c345
Merge pull request #401 from BestAwperEver/s2-is-alive
markus-wa Aug 16, 2023
0f4e5c6
feat: bomb/round events
akiver Aug 11, 2023
4b8aa4f
feat: PlayerFlashed and FlashbandExploded events
akiver Aug 13, 2023
3aa760d
fix: dispatch game events in a more expected order
akiver Aug 13, 2023
59490d9
feat: weapon fire event
akiver Aug 14, 2023
e458206
feat: add MimicSource1GameEvents option
akiver Aug 17, 2023
4c5c033
fix: add missing weapon name to mapping
BestAwperEver Aug 21, 2023
951ee0e
feat: MimicSource1GameEvents to DisableMimicSource1GameEvents
akiver Aug 21, 2023
999291c
Merge pull request #403 from akiver/s2-events
markus-wa Aug 22, 2023
43415bc
Merge pull request #404 from BestAwperEver/s2-missing-weapon-name
markus-wa Aug 22, 2023
4ee6efa
fix: possible crash player props
akiver Aug 24, 2023
fd8b76b
Merge pull request #405 from akiver/s2-fix-player
markus-wa Aug 27, 2023
2a73a06
s2 protos
markus-wa Sep 1, 2023
2e45e53
bump to v4, upgrade go to 1.21
markus-wa Sep 1, 2023
6f75f98
Merge remote-tracking branch 'origin/master' into s2
markus-wa Sep 1, 2023
9da75d8
go mod upgrade
markus-wa Sep 1, 2023
d89c11d
readme: more cs2 warning
markus-wa Sep 1, 2023
b58ebff
upgrade ice-cipher-go to version with license
markus-wa Sep 1, 2023
2dc0bb0
readme: require go 1.21
markus-wa Sep 1, 2023
2a78530
ci: use go 1.21
markus-wa Sep 1, 2023
0d21c36
ci: fix generated interfaces check
markus-wa Sep 1, 2023
3ec2c75
fix tests that need to know if we're on S2 or not
markus-wa Sep 1, 2023
76733a6
s2 test fixes
markus-wa Sep 1, 2023
e7589ec
fix s2 demo path
markus-wa Sep 1, 2023
d4b826a
fix golden file for BombPlantAborted & OvertimeNumberChanged
markus-wa Sep 1, 2023
996c386
fix ErrUnexpectedEndOfDemo test
markus-wa Sep 1, 2023
082a961
s2 demo set
markus-wa Sep 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module github.com/markus-wa/demoinfocs-golang/v3

require (
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
github.com/golang/snappy v0.0.4
github.com/llgcode/draw2d v0.0.0-20210904075650-80aa0a2a901d
github.com/markus-wa/go-heatmap/v2 v2.0.0
github.com/markus-wa/go-unassert v0.1.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/golang/geo v0.0.0-20180826223333-635502111454/go.mod h1:vgWZ7cu0fq0KY
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
Expand Down
4 changes: 4 additions & 0 deletions pkg/demoinfocs/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ func NewTeamState(team Team, membersCallback func(Team) []*Player) TeamState {
// ConvertSteamIDTxtTo32 converts a Steam-ID in text format to a 32-bit variant.
// See https://developer.valvesoftware.com/wiki/SteamID
func ConvertSteamIDTxtTo32(steamID string) (uint32, error) {
if strings.HasSuffix(steamID, "]") {
steamID = strings.TrimSuffix(steamID, "]") // Source 2 has [U:1:397560266] instead of STEAM_0:1:198780133
}

arr := strings.Split(steamID, ":")

if len(arr) != 3 {
Expand Down
35 changes: 35 additions & 0 deletions pkg/demoinfocs/demoinfocs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,41 @@ func TestDemoInfoCs(t *testing.T) {
assertGolden(t, assertions, "default", actual.Bytes())
}

var s2Dem = flag.String("s2dem", "", "source 2 demo to parse")

func TestS2(t *testing.T) {
t.Parallel()

if testing.Short() {
t.Skip("skipping test due to -short flag")
}

s2DemPath := *s2Dem

f, err := os.Open(s2DemPath)
assertions := assert.New(t)
assertions.NoError(err, "error opening demo %q", s2DemPath)

defer mustClose(t, f)

cfg := demoinfocs.DefaultParserConfig
cfg.MsgQueueBufferSize = 0

p := demoinfocs.NewParserWithConfig(f, cfg)

t.Log("Parsing header")
_, err = p.ParseHeader()
assertions.NoError(err, "error returned by Parser.ParseHeader()")

p.RegisterEventHandler(func(event events.GenericGameEvent) {
fmt.Println(event.Name, event)
})

t.Log("Parsing to end")
err = p.ParseToEnd()
assertions.NoError(err, "error occurred in ParseToEnd()")
}

func TestEncryptedNetMessages(t *testing.T) {
t.Parallel()

Expand Down
50 changes: 50 additions & 0 deletions pkg/demoinfocs/game_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
common "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/common"
events "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events"
msg "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/msg"
"github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/msgs2"
)

func (p *parser) handleGameEventList(gel *msg.CSVCMsg_GameEventList) {
Expand All @@ -19,6 +20,31 @@ func (p *parser) handleGameEventList(gel *msg.CSVCMsg_GameEventList) {
}
}

func (p *parser) handleGameEventListS2(gel *msgs2.CMsgSource1LegacyGameEventList) {
s1desc := make([]*msg.CSVCMsg_GameEventListDescriptorT, 0, len(gel.GetDescriptors()))

for _, d := range gel.GetDescriptors() {
s1keys := make([]*msg.CSVCMsg_GameEventListKeyT, 0, len(d.Keys))

for _, k := range d.Keys {
s1keys = append(s1keys, &msg.CSVCMsg_GameEventListKeyT{
Type: k.Type,
Name: k.Name,
})
}

s1desc = append(s1desc, &msg.CSVCMsg_GameEventListDescriptorT{
Eventid: d.Eventid,
Name: d.Name,
Keys: s1keys,
})
}

p.handleGameEventList(&msg.CSVCMsg_GameEventList{
Descriptors: s1desc,
})
}

func (p *parser) handleGameEvent(ge *msg.CSVCMsg_GameEvent) {
if p.gameEventDescs == nil {
p.eventDispatcher.Dispatch(events.ParserWarn{
Expand Down Expand Up @@ -52,6 +78,30 @@ func (p *parser) handleGameEvent(ge *msg.CSVCMsg_GameEvent) {
})
}

func (p *parser) handleGameEventS2(ge *msgs2.CMsgSource1LegacyGameEvent) {
keys := make([]*msg.CSVCMsg_GameEventKeyT, 0, len(ge.Keys))

for _, k := range ge.Keys {
keys = append(keys, &msg.CSVCMsg_GameEventKeyT{
Type: k.Type,
ValString: k.ValString,
ValFloat: k.ValFloat,
ValLong: k.ValLong,
ValShort: k.ValShort,
ValByte: k.ValByte,
ValBool: k.ValBool,
ValUint64: k.ValUint64,
})
}

p.handleGameEvent(&msg.CSVCMsg_GameEvent{
EventName: ge.EventName,
Eventid: ge.Eventid,
Keys: keys,
Passthrough: ge.Passthrough,
})
}

type gameEventHandler struct {
parser *parser
gameEventNameToHandler map[string]gameEventHandlerFunc
Expand Down
Loading