Skip to content

Commit de8e618

Browse files
BestAwperEvermarkus-wa
authored andcommitted
find player by handle: search in playersByUserID as a fallback (fixes #176) (#177)
1 parent 7d64935 commit de8e618

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

game_state.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,19 @@ func (ptcp Participants) FindByHandle(handle int) *common.Player {
266266
return nil
267267
}
268268

269-
return ptcp.playersByEntityID[handle&entityHandleIndexMask]
269+
entityID := handle & entityHandleIndexMask
270+
player := ptcp.playersByEntityID[entityID]
271+
272+
if player == nil {
273+
for _, p := range ptcp.playersByUserID {
274+
if p.EntityID == entityID {
275+
player = p
276+
break
277+
}
278+
}
279+
}
280+
281+
return player
270282
}
271283

272284
func (ptcp Participants) initalizeSliceFromByUserID() ([]*common.Player, map[int]*common.Player) {

0 commit comments

Comments
 (0)