Skip to content

Commit 713ae71

Browse files
committed
fix: set player connected flag to false when controller is destroyed
Bot controller entities can be destroyed: ``` 96322 player_controller_destroy 12 Baroud 0 107866 player_controller_destroy 14 Bank 0 ``` If we don't update the prop `Connected`, the bot will still be in the slice returned by `Playing()`. As a result, calling a player's function that relies on its pawn entity such as `EquipmentValueCurrent()` may result in a panic as the pawn doesn't exists anymore. Noticed with this demo https://mega.nz/file/uBdF3TBT#aoGpmJ6PKaNIMqPdZsVxHyhiv7DbxO3M9jJNWAOIhb0 and the following code: ```go p.RegisterEventHandler(func(e events.RoundStart) { fmt.Println(p.GameState().TeamCounterTerrorists().CurrentEquipmentValue()) fmt.Println(p.GameState().TeamTerrorists().CurrentEquipmentValue()) }) ``` ref akiver/cs-demo-manager#727
1 parent 935fd38 commit 713ae71

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

pkg/demoinfocs/datatables.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ func (p *parser) bindNewPlayerControllerS2(controllerEntity st.Entity) {
526526
})
527527

528528
controllerEntity.OnDestroy(func() {
529+
pl.IsConnected = false
529530
delete(p.gameState.playersByEntityID, controllerEntity.ID())
530531
})
531532
}

0 commit comments

Comments
 (0)