Commit 713ae71
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#7271 parent 935fd38 commit 713ae71
1 file changed
+1
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| 529 | + | |
529 | 530 | | |
530 | 531 | | |
531 | 532 | | |
| |||
0 commit comments