mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 07:07:33 +00:00
fix(protocol/gamespy1): ignore stale player list entries (#744)
closes #743
This commit is contained in:
parent
35433cd03f
commit
3f1a06638f
2 changed files with 7 additions and 12 deletions
|
|
@ -86,19 +86,7 @@ export default class gamespy1 extends Core {
|
|||
|
||||
const players = Object.values(playersById)
|
||||
|
||||
const seenHashes = new Set()
|
||||
for (const player of players) {
|
||||
// Some servers (bf1942) report the same player multiple times (bug?)
|
||||
// Ignore these duplicates
|
||||
if (player.keyhash) {
|
||||
if (seenHashes.has(player.keyhash)) {
|
||||
this.logger.debug('Rejected player with hash ' + player.keyhash + ' (Duplicate keyhash)')
|
||||
continue
|
||||
} else {
|
||||
seenHashes.add(player.keyhash)
|
||||
}
|
||||
}
|
||||
|
||||
// Convert player's team ID to team name if possible
|
||||
if (Object.prototype.hasOwnProperty.call(player, 'teamId')) {
|
||||
if (Object.keys(teamNamesById).length) {
|
||||
|
|
@ -112,6 +100,12 @@ export default class gamespy1 extends Core {
|
|||
state.players.push(player)
|
||||
}
|
||||
|
||||
// Some servers (bf1942) send stale player entries when players leave the server (including duplicates)
|
||||
// Ignore any player list entries beyond the indicated number of players
|
||||
if (!isNaN(state.raw.numplayers) && state.players.length > state.raw.numplayers) {
|
||||
state.players = state.players.slice(0, state.raw.numplayers)
|
||||
}
|
||||
|
||||
state.numplayers = state.players.length
|
||||
state.version = state.raw.gamever
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue