Skip to content

Commit

Permalink
fix: possible nil players in game events (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
akiver committed Jun 15, 2024
1 parent 2b3dd44 commit 12b55b1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/demoinfocs/game_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ func (geh gameEventHandler) playerByUserID(userID int) *common.Player {
}

func (geh gameEventHandler) playerByUserID32(userID int32) *common.Player {
if geh.parser.isSource2() && userID <= math.MaxUint16 {
userID &= 0xff
}

return geh.playerByUserID(int(userID))
}

Expand Down Expand Up @@ -682,6 +686,10 @@ 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())
if geh.parser.isSource2() && uid <= math.MaxUint16 {
uid &= 0xff
}

pl := geh.playerByUserID(uid)

if geh.parser.isSource2() {
Expand Down

0 comments on commit 12b55b1

Please sign in to comment.