Skip to content

Commit

Permalink
Merge pull request #547 from markus-wa/fix-userid-2
Browse files Browse the repository at this point in the history
fix: possible nil players in game events (again)
  • Loading branch information
akiver authored Jun 15, 2024
2 parents 90afae5 + e74733c commit b26dacd
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 b26dacd

Please sign in to comment.