Skip to content

Commit ef56e2c

Browse files
committed
Merge branch 'master' into v5
2 parents a53f1fb + ca0ea7f commit ef56e2c

File tree

11 files changed

+56
-24
lines changed

11 files changed

+56
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# demoinfocs-golang - Counter-Strike 2 & CS:GO Demo Parser
1+
# demoinfocs-golang - CS2 Demo Parser
22

33
A blazing fast, feature complete and production ready Go library for parsing and analysing of Counter-Strike 2 and Counter-Strike: Global Offensive (CS:GO) demos (aka replays).
44

examples/nade-trajectories/nade_trajectories.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ import (
1111
"github.com/golang/geo/r2"
1212
"github.com/llgcode/draw2d/draw2dimg"
1313

14-
msg "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/msg"
15-
1614
ex "github.com/markus-wa/demoinfocs-golang/v5/examples"
1715
demoinfocs "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs"
1816
common "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/common"
1917
events "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/events"
18+
msg "github.com/markus-wa/demoinfocs-golang/v5/pkg/demoinfocs/msg"
2019
)
2120

2221
type nadePath struct {
@@ -78,7 +77,7 @@ func main() {
7877
}
7978
}
8079

81-
nadeTrajectories[id].path = e.Projectile.Trajectory2
80+
nadeTrajectories[id].path = e.Projectile.Trajectory
8281
})
8382

8483
var infernos []*common.Inferno
-20.9 KB
Loading

pkg/demoinfocs/common/equipment.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ func (e *Equipment) AmmoReserve() int {
400400
}
401401

402402
s2Prop := e.Entity.Property("m_pReserveAmmo.0000")
403-
if s2Prop != nil {
403+
if s2Prop != nil && s2Prop.Value().Any != nil {
404404
return s2Prop.Value().Int()
405405
}
406406

@@ -413,6 +413,10 @@ func (e *Equipment) AmmoReserve() int {
413413
return 0
414414
}
415415

416+
if e.Class() == EqClassEquipment {
417+
return 0
418+
}
419+
416420
// if the property doesn't exist we return 0 by default
417421
val, _ := e.Entity.PropertyValue("m_iPrimaryReserveAmmoCount")
418422

pkg/demoinfocs/datatables.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,13 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
682682
flashedEntityIDs: []int{},
683683
})
684684

685+
proj.Trajectory = append(proj.Trajectory, common.TrajectoryEntry{
686+
Tick: p.gameState.ingameTick,
687+
Position: proj.Position(),
688+
FrameID: p.CurrentFrame(),
689+
Time: p.CurrentTime(),
690+
})
691+
685692
if !p.disableMimicSource1GameEvents {
686693
p.eventDispatcher.Dispatch(events.WeaponFire{
687694
Shooter: proj.Owner,
@@ -695,6 +702,13 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
695702
})
696703

697704
entity.OnDestroy(func() {
705+
proj.Trajectory = append(proj.Trajectory, common.TrajectoryEntry{
706+
Tick: p.gameState.ingameTick,
707+
Position: proj.Position(),
708+
FrameID: p.CurrentFrame(),
709+
Time: p.CurrentTime(),
710+
})
711+
698712
if wep == common.EqFlash && !p.disableMimicSource1GameEvents {
699713
p.gameEventHandler.dispatch(events.FlashExplode{
700714
GrenadeEvent: events.GrenadeEvent{
@@ -734,15 +748,6 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
734748
proj.Owner = p.gameState.Participants().FindByPawnHandle(val.Handle())
735749
})
736750

737-
entity.OnPositionUpdate(func(newPos r3.Vector) {
738-
proj.Trajectory = append(proj.Trajectory, common.TrajectoryEntry{
739-
Tick: p.gameState.ingameTick,
740-
Position: newPos,
741-
FrameID: p.CurrentFrame(),
742-
Time: p.CurrentTime(),
743-
})
744-
})
745-
746751
// Some demos don't have this property as it seems
747752
// So we need to check for nil and can't send out bounce events if it's missing
748753
if bounceProp := entity.Property("m_nBounces"); bounceProp != nil {
@@ -758,6 +763,13 @@ func (p *parser) bindGrenadeProjectiles(entity st.Entity) {
758763
BounceNr: bounceNumber,
759764
})
760765
}
766+
767+
proj.Trajectory = append(proj.Trajectory, common.TrajectoryEntry{
768+
Tick: p.gameState.ingameTick,
769+
Position: proj.Position(),
770+
FrameID: p.CurrentFrame(),
771+
Time: p.CurrentTime(),
772+
})
761773
})
762774
}
763775
}

pkg/demoinfocs/demoinfocs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func TestS2(t *testing.T) {
214214

215215
if *update {
216216
p.RegisterNetMessageHandler(func(gel *msg.CMsgSource1LegacyGameEventList) {
217-
lo.Must0(os.WriteFile("s2_CMsgSource1LegacyGameEventList.pb.bin", lo.Must(proto.Marshal(gel)), 0600))
217+
lo.Must0(os.WriteFile("event-list-dump/s2_CMsgSource1LegacyGameEventList.pb.bin", lo.Must(proto.Marshal(gel)), 0600))
218218
})
219219
}
220220

15 KB
Binary file not shown.
File renamed without changes.
15 KB
Binary file not shown.

pkg/demoinfocs/parser.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,6 @@ var DefaultParserConfig = ParserConfig{
401401
CSTVTimeout: 10 * time.Second,
402402
}
403403

404-
//go:embed s2_CMsgSource1LegacyGameEventList.pb.bin
405-
var defaultSource2FallbackGameEventListBin []byte
406-
407404
// NewParserWithConfig returns a new Parser with a custom configuration.
408405
//
409406
// See also: NewParser() & ParserConfig
@@ -430,11 +427,6 @@ func NewParserWithConfig(demostream io.Reader, config ParserConfig) Parser {
430427
p.recordingPlayerSlot = -1
431428
p.disableMimicSource1GameEvents = config.DisableMimicSource1Events
432429
p.source2FallbackGameEventListBin = config.Source2FallbackGameEventListBin
433-
434-
if p.source2FallbackGameEventListBin == nil {
435-
p.source2FallbackGameEventListBin = defaultSource2FallbackGameEventListBin
436-
}
437-
438430
p.ignorePacketEntitiesPanic = config.IgnorePacketEntitiesPanic
439431

440432
dispatcherCfg := dp.Config{

0 commit comments

Comments
 (0)