Skip to content

Commit

Permalink
Merge pull request #512 from markus-wa/bot-disco
Browse files Browse the repository at this point in the history
fix: dispatch player disconnect events for bots
  • Loading branch information
markus-wa authored Feb 21, 2024
2 parents c873089 + 281c63b commit d689199
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/demoinfocs/game_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,19 +664,24 @@ func (geh gameEventHandler) playerConnect(data map[string]*msg.CSVCMsg_GameEvent
}

func (geh gameEventHandler) playerDisconnect(data map[string]*msg.CSVCMsg_GameEventKeyT) {
uid := int(data["userid"].GetValShort())
pl := geh.playerByUserID(uid)

if geh.parser.isSource2() {
if pl != nil && pl.IsBot {
geh.dispatch(events.PlayerDisconnected{
Player: pl,
})
}
return
}

uid := int(data["userid"].GetValShort())

for k, v := range geh.parser.rawPlayers {
if v.UserID == uid {
delete(geh.parser.rawPlayers, k)
}
}

pl := geh.playerByUserID(uid)
if pl != nil {
// Dispatch this event early since we delete the player on the next line
geh.dispatch(events.PlayerDisconnected{
Expand Down

0 comments on commit d689199

Please sign in to comment.