Skip to content

Commit

Permalink
fix: possible nil player in game events on rare occasion
Browse files Browse the repository at this point in the history
Make sure to create/update players in gameState (`playersByEntityID`, `playersByUserID`) on connection status changes.
Sometimes players raw info are not available on controller entity creation so it would result in missing players in `gameState.playersByUserID`.
It may be related to player disconnection as the affected player got disconnected at the beginning of the demo.

fix akiver/cs-demo-manager#904
  • Loading branch information
akiver committed Aug 8, 2024
1 parent 894aeb3 commit ddb4ff4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pkg/demoinfocs/datatables.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ func (p *parser) bindNewPlayerControllerS2(controllerEntity st.Entity) {
pl := p.getOrCreatePlayerFromControllerEntity(controllerEntity)

controllerEntity.Property("m_iConnected").OnUpdate(func(val st.PropertyValue) {
pl := p.getOrCreatePlayerFromControllerEntity(controllerEntity)
state := val.S2UInt32()
wasConnected := pl.IsConnected
pl.IsConnected = state == 0
Expand Down

0 comments on commit ddb4ff4

Please sign in to comment.