Skip to content

Commit b26dacd

Browse files
authored
Merge pull request #547 from markus-wa/fix-userid-2
fix: possible nil players in game events (again)
2 parents 90afae5 + e74733c commit b26dacd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/demoinfocs/game_events.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ func (geh gameEventHandler) playerByUserID(userID int) *common.Player {
154154
}
155155

156156
func (geh gameEventHandler) playerByUserID32(userID int32) *common.Player {
157+
if geh.parser.isSource2() && userID <= math.MaxUint16 {
158+
userID &= 0xff
159+
}
160+
157161
return geh.playerByUserID(int(userID))
158162
}
159163

@@ -682,6 +686,10 @@ func (geh gameEventHandler) playerConnect(data map[string]*msg.CSVCMsg_GameEvent
682686

683687
func (geh gameEventHandler) playerDisconnect(data map[string]*msg.CSVCMsg_GameEventKeyT) {
684688
uid := int(data["userid"].GetValShort())
689+
if geh.parser.isSource2() && uid <= math.MaxUint16 {
690+
uid &= 0xff
691+
}
692+
685693
pl := geh.playerByUserID(uid)
686694

687695
if geh.parser.isSource2() {

0 commit comments

Comments
 (0)