From ddb4ff4c7222c591aa0171e708d6294fb5cdfe7a Mon Sep 17 00:00:00 2001 From: AkiVer Date: Thu, 8 Aug 2024 06:38:28 +0200 Subject: [PATCH] fix: possible nil player in game events on rare occasion 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 https://github.com/akiver/cs-demo-manager/issues/904 --- pkg/demoinfocs/datatables.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/demoinfocs/datatables.go b/pkg/demoinfocs/datatables.go index 0d12cf42..27ca5828 100644 --- a/pkg/demoinfocs/datatables.go +++ b/pkg/demoinfocs/datatables.go @@ -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