Skip to content

bug: Battlefield 1942 servers send stale player list entries #743

@cetteup

Description

@cetteup

Describe the bug
Battlefield 1942 servers send stale player list entries, which are not currently filtered out.

Steps To Reproduce
Join an empty Battlefield 1942 (e.g. 108.61.255.31:14567), then leave the server. Now query the server. The server should send numplayers\0 but still provide player list entries.

Note: numplayers is currently overwritten in the state using the length of the player list, so you need to look at the raw response to check the original value for numplayers.

state.numplayers = state.players.length

Expected behavior
Stale player list entries should be filtered out.

Screenshots or Data

Q#0 Starting
Q#0 Protocol: gamespy1
Q#0 Options: {
  socketTimeout: 2000,
  attemptTimeout: 10000,
  maxRetries: 1,
  stripColors: true,
  portCache: true,
  noBreadthOrder: false,
  ipFamily: 0,
  requestPlayers: true,
  port: 23000,
  protocol: 'gamespy1',
  pretty: false,
  debug: true,
  givenPortOnly: false,
  requestRules: false,
  requestRulesRequired: false,
  requestPlayersRequired: false,
  checkOldIDs: false,
  rejectUnauthorized: false,
  type: 'battlefield1942',
  host: '108.61.255.31'
}
Q#0 DNS Lookup: 108.61.255.31
Q#0 Raw IP Address: 108.61.255.31
108.61.255.31:23000 UDP(55690)-->
Buffer length: 20 bytes
5c 73 74 61 74 75 73 5c 78 73 65 72 76 65 72 71 75 65 72 79 
\  s  t  a  t  u  s  \  x  s  e  r  v  e  r  q  u  e  r  y  

108.61.255.31:23000 <--UDP(55690)
Buffer length: 1337 bytes
5c 67 61 6d 65 6e 61 6d 65 5c 62 66 69 65 6c 64 31 39 34 32 5c 
\  g  a  m  e  n  a  m  e  \  b  f  i  e  l  d  1  9  4  2  \  
67 61 6d 65 76 65 72 5c 76 31 2e 36 31 32 5c 61 76 65 72 61 67 
g  a  m  e  v  e  r  \  v  1  .  6  1  2  \  a  v  e  r  a  g  
65 46 50 53 5c 30 5c 63 6f 6e 74 65 6e 74 5f 63 68 65 63 6b 5c 
e  F  P  S  \  0  \  c  o  n  t  e  n  t  _  c  h  e  c  k  \  
30 5c 64 65 64 69 63 61 74 65 64 5c 32 5c 67 61 6d 65 49 64 5c 
0  \  d  e  d  i  c  a  t  e  d  \  2  \  g  a  m  e  I  d  \  
62 66 31 39 34 32 5c 67 61 6d 65 6d 6f 64 65 5c 6f 70 65 6e 70 
b  f  1  9  4  2  \  g  a  m  e  m  o  d  e  \  o  p  e  n  p  
6c 61 79 69 6e 67 5c 67 61 6d 65 74 79 70 65 5c 63 6f 6f 70 5c 
l  a  y  i  n  g  \  g  a  m  e  t  y  p  e  \  c  o  o  p  \  
68 6f 73 74 6e 61 6d 65 5c 4f 7a 20 57 61 6b 65 20 5b 43 44 20 
h  o  s  t  n  a  m  e  \  O  z     W  a  k  e     [  C  D     
31 2e 36 31 2f 4f 72 69 67 69 6e 20 31 2e 36 31 32 5d 5c 68 6f 
1  .  6  1  /  O  r  i  g  i  n     1  .  6  1  2  ]  \  h  o  
73 74 70 6f 72 74 5c 31 34 35 36 37 5c 6d 61 70 49 64 5c 42 46 
s  t  p  o  r  t  \  1  4  5  6  7  \  m  a  p  I  d  \  B  F  
31 39 34 32 5c 6d 61 70 6e 61 6d 65 5c 77 61 6b 65 5c 6d 61 78 
1  9  4  2  \  m  a  p  n  a  m  e  \  w  a  k  e  \  m  a  x  
70 6c 61 79 65 72 73 5c 32 34 5c 6e 75 6d 70 6c 61 79 65 72 73 
p  l  a  y  e  r  s  \  2  4  \  n  u  m  p  l  a  y  e  r  s  
5c 30 5c 70 61 73 73 77 6f 72 64 5c 30 5c 72 65 73 65 72 76 65 
\  0  \  p  a  s  s  w  o  r  d  \  0  \  r  e  s  e  r  v  e  
64 73 6c 6f 74 73 5c 30 5c 72 6f 75 6e 64 54 69 6d 65 5c 35 34 
d  s  l  o  t  s  \  0  \  r  o  u  n  d  T  i  m  e  \  5  4  
30 30 5c 72 6f 75 6e 64 54 69 6d 65 52 65 6d 61 69 6e 5c 32 38 
0  0  \  r  o  u  n  d  T  i  m  e  R  e  m  a  i  n  \  2  8  
38 33 5c 73 74 61 74 75 73 5c 34 5c 73 76 5f 70 75 6e 6b 62 75 
8  3  \  s  t  a  t  u  s  \  4  \  s  v  _  p  u  n  k  b  u  
73 74 65 72 5c 30 5c 74 69 63 6b 65 74 73 31 5c 31 38 31 5c 74 
s  t  e  r  \  0  \  t  i  c  k  e  t  s  1  \  1  8  1  \  t  
69 63 6b 65 74 73 32 5c 33 32 30 5c 75 6e 70 75 72 65 5f 6d 6f 
i  c  k  e  t  s  2  \  3  2  0  \  u  n  p  u  r  e  _  m  o  
64 73 5c 5c 76 65 72 73 69 6f 6e 5c 76 31 2e 36 31 32 5c 61 63 
d  s  \  \  v  e  r  s  i  o  n  \  v  1  .  6  1  2  \  a  c  
74 69 76 65 5f 6d 6f 64 73 5c 62 66 31 39 34 32 5c 61 6c 6c 69 
t  i  v  e  _  m  o  d  s  \  b  f  1  9  4  2  \  a  l  l  i  
65 64 5f 74 65 61 6d 5f 72 61 74 69 6f 5c 31 5c 61 6c 6c 6f 77 
e  d  _  t  e  a  m  _  r  a  t  i  o  \  1  \  a  l  l  o  w  
5f 6e 6f 73 65 5f 63 61 6d 5c 79 65 73 5c 61 75 74 6f 5f 62 61 
_  n  o  s  e  _  c  a  m  \  y  e  s  \  a  u  t  o  _  b  a  
6c 61 6e 63 65 5f 74 65 61 6d 73 5c 6f 66 66 5c 61 78 69 73 5f 
l  a  n  c  e  _  t  e  a  m  s  \  o  f  f  \  a  x  i  s  _  
74 65 61 6d 5f 72 61 74 69 6f 5c 31 5c 62 61 6e 64 77 69 64 74 
t  e  a  m  _  r  a  t  i  o  \  1  \  b  a  n  d  w  i  d  t  
68 5f 63 68 6f 6b 65 5f 6c 69 6d 69 74 5c 30 5c 63 6f 6e 74 65 
h  _  c  h  o  k  e  _  l  i  m  i  t  \  0  \  c  o  n  t  e  
6e 74 5f 63 68 65 63 6b 5c 30 5c 63 70 75 5c 33 31 39 32 5c 65 
n  t  _  c  h  e  c  k  \  0  \  c  p  u  \  3  1  9  2  \  e  
78 74 65 72 6e 61 6c 5f 76 69 65 77 5c 6f 6e 5c 66 72 65 65 5f 
x  t  e  r  n  a  l  _  v  i  e  w  \  o  n  \  f  r  e  e  _  
63 61 6d 65 72 61 5c 6f 66 66 5c 67 61 6d 65 5f 73 74 61 72 74 
c  a  m  e  r  a  \  o  f  f  \  g  a  m  e  _  s  t  a  r  t  
5f 64 65 6c 61 79 5c 31 30 73 5c 68 69 74 5f 69 6e 64 69 63 61 
_  d  e  l  a  y  \  1  0  s  \  h  i  t  _  i  n  d  i  c  a  
74 6f 72 5c 6f 6e 5c 6b 69 63 6b 62 61 63 6b 5c 30 25 5c 6b 69 
t  o  r  \  o  n  \  k  i  c  k  b  a  c  k  \  0  %  \  k  i  
63 6b 62 61 63 6b 5f 6f 6e 5f 73 70 6c 61 73 68 5c 30 25 5c 6e 
c  k  b  a  c  k  _  o  n  _  s  p  l  a  s  h  \  0  %  \  n  
61 6d 65 5f 74 61 67 5f 64 69 73 74 61 6e 63 65 5c 31 30 30 5c 
a  m  e  _  t  a  g  _  d  i  s  t  a  n  c  e  \  1  0  0  \  
6e 61 6d 65 5f 74 61 67 5f 64 69 73 74 61 6e 63 65 5f 73 63 6f 
n  a  m  e  _  t  a  g  _  d  i  s  t  a  n  c  e  _  s  c  o  
70 65 5c 33 30 30 5c 6e 75 6d 62 65 72 5f 6f 66 5f 72 6f 75 6e 
p  e  \  3  0  0  \  n  u  m  b  e  r  _  o  f  _  r  o  u  n  
64 73 5c 31 30 5c 73 6f 6c 64 69 65 72 5f 66 72 69 65 6e 64 6c 
d  s  \  1  0  \  s  o  l  d  i  e  r  _  f  r  i  e  n  d  l  
79 5f 66 69 72 65 5c 30 25 5c 73 6f 6c 64 69 65 72 5f 66 72 69 
y  _  f  i  r  e  \  0  %  \  s  o  l  d  i  e  r  _  f  r  i  
65 6e 64 6c 79 5f 66 69 72 65 5f 6f 6e 5f 73 70 6c 61 73 68 5c 
e  n  d  l  y  _  f  i  r  e  _  o  n  _  s  p  l  a  s  h  \  
30 25 5c 73 70 61 77 6e 5f 64 65 6c 61 79 5c 33 73 5c 73 70 61 
0  %  \  s  p  a  w  n  _  d  e  l  a  y  \  3  s  \  s  p  a  
77 6e 5f 77 61 76 65 5f 74 69 6d 65 5c 33 73 5c 73 76 5f 70 75 
w  n  _  w  a  v  e  _  t  i  m  e  \  3  s  \  s  v  _  p  u  
6e 6b 62 75 73 74 65 72 5c 30 5c 74 69 63 6b 65 74 5f 72 61 74 
n  k  b  u  s  t  e  r  \  0  \  t  i  c  k  e  t  _  r  a  t  
69 6f 5c 32 35 30 25 5c 74 69 6d 65 5f 6c 69 6d 69 74 5c 39 30 
i  o  \  2  5  0  %  \  t  i  m  e  _  l  i  m  i  t  \  9  0  
5c 74 6b 5f 6d 6f 64 65 5c 70 75 6e 69 73 68 5c 75 6e 70 75 72 
\  t  k  _  m  o  d  e  \  p  u  n  i  s  h  \  u  n  p  u  r  
65 5f 6d 6f 64 73 5c 5c 76 65 68 69 63 6c 65 5f 66 72 69 65 6e 
e  _  m  o  d  s  \  \  v  e  h  i  c  l  e  _  f  r  i  e  n  
64 6c 79 5f 66 69 72 65 5c 30 25 5c 76 65 68 69 63 6c 65 5f 66 
d  l  y  _  f  i  r  e  \  0  %  \  v  e  h  i  c  l  e  _  f  
72 69 65 6e 64 6c 79 5f 66 69 72 65 5f 6f 6e 5f 73 70 6c 61 73 
r  i  e  n  d  l  y  _  f  i  r  e  _  o  n  _  s  p  l  a  s  
68 5c 30 25 5c 64 65 61 74 68 73 5f 30 5c 34 5c 6b 65 79 68 61 
h  \  0  %  \  d  e  a  t  h  s  _  0  \  4  \  k  e  y  h  a  
73 68 5f 30 5c 37 64 30 65 37 36 35 63 64 32 36 65 61 30 35 33 
s  h  _  0  \  7  d  0  e  7  6  5  c  d  2  6  e  a  0  5  3  
30 30 34 64 31 35 64 37 64 62 39 30 38 39 38 63 5c 6b 69 6c 6c 
0  0  4  d  1  5  d  7  d  b  9  0  8  9  8  c  \  k  i  l  l  
73 5f 30 5c 33 30 5c 70 69 6e 67 5f 30 5c 39 5c 70 6c 61 79 65 
s  _  0  \  3  0  \  p  i  n  g  _  0  \  9  \  p  l  a  y  e  
72 6e 61 6d 65 5f 30 5c 53 63 68 6c 69 6e 67 65 6c 5c 73 63 6f 
r  n  a  m  e  _  0  \  S  c  h  l  i  n  g  e  l  \  s  c  o  
72 65 5f 30 5c 33 32 5c 74 65 61 6d 5f 30 5c 31 5c 64 65 61 74 
r  e  _  0  \  3  2  \  t  e  a  m  _  0  \  1  \  d  e  a  t  
68 73 5f 31 5c 33 5c 6b 65 79 68 61 73 68 5f 31 5c 37 64 30 65 
h  s  _  1  \  3  \  k  e  y  h  a  s  h  _  1  \  7  d  0  e  
37 36 35 63 64 32 36 65 61 30 35 33 30 30 34 64 31 35 64 37 64 
7  6  5  c  d  2  6  e  a  0  5  3  0  0  4  d  1  5  d  7  d  
62 39 30 38 39 38 63 5c 6b 69 6c 6c 73 5f 31 5c 32 39 5c 70 69 
b  9  0  8  9  8  c  \  k  i  l  l  s  _  1  \  2  9  \  p  i  
6e 67 5f 31 5c 39 5c 70 6c 61 79 65 72 6e 61 6d 65 5f 31 5c 53 
n  g  _  1  \  9  \  p  l  a  y  e  r  n  a  m  e  _  1  \  S  
63 68 6c 69 6e 67 65 6c 5c 73 63 6f 72 65 5f 31 5c 32 39 5c 74 
c  h  l  i  n  g  e  l  \  s  c  o  r  e  _  1  \  2  9  \  t  
65 61 6d 5f 31 5c 31 5c 64 65 61 74 68 73 5f 32 5c 30 5c 6b 65 
e  a  m  _  1  \  1  \  d  e  a  t  h  s  _  2  \  0  \  k  e  
79 68 61 73 68 5f 32 5c 37 64 30 65 37 36 35 63 64 32 36 65 61 
y  h  a  s  h  _  2  \  7  d  0  e  7  6  5  c  d  2  6  e  a  
30 35 33 30 30 34 64 31 35 64 37 64 62 39 30 38 39 38 63 5c 6b 
0  5  3  0  0  4  d  1  5  d  7  d  b  9  0  8  9  8  c  \  k  
69 6c 6c 73 5f 32 5c 31 37 5c 70 69 6e 67 5f 32 5c 31 30 5c 70 
i  l  l  s  _  2  \  1  7  \  p  i  n  g  _  2  \  1  0  \  p  
6c 61 79 65 72 6e 61 6d 65 5f 32 5c 53 63 68 6c 69 6e 67 65 6c 
l  a  y  e  r  n  a  m  e  _  2  \  S  c  h  l  i  n  g  e  l  
5c 73 63 6f 72 65 5f 32 5c 31 37 5c 74 65 61 6d 5f 32 5c 31 5c 
\  s  c  o  r  e  _  2  \  1  7  \  t  e  a  m  _  2  \  1  \  
74 65 61 6d 6e 61 6d 65 5f 30 5c 61 78 69 73 5c 74 65 61 6d 6e 
t  e  a  m  n  a  m  e  _  0  \  a  x  i  s  \  t  e  a  m  n  
61 6d 65 5f 31 5c 61 6c 6c 69 65 64 5c 66 69 6e 61 6c 5c 5c 71 
a  m  e  _  1  \  a  l  l  i  e  d  \  f  i  n  a  l  \  \  q  
75 65 72 79 69 64 5c 32 31 33 38 30 2e 31 
u  e  r  y  i  d  \  2  1  3  8  0  .  1  

Q#0 Registered RTT: 18ms
Q#0 Received part num=1 queryId=21380 final=true
Q#0 Received part #1 of 1
Q#0 Received all parts
Q#0 {
  gamename: 'bfield1942',
  gamever: 'v1.612',
  averageFPS: '0',
  content_check: '0',
  dedicated: '2',
  gameId: 'bf1942',
  gamemode: 'openplaying',
  gametype: 'coop',
  hostname: 'Oz Wake [CD 1.61/Origin 1.612]',
  hostport: '14567',
  mapId: 'BF1942',
  mapname: 'wake',
  maxplayers: '24',
  numplayers: '0',
  password: '0',
  reservedslots: '0',
  roundTime: '5400',
  roundTimeRemain: '2883',
  status: '4',
  sv_punkbuster: '0',
  tickets1: '181',
  tickets2: '320',
  unpure_mods: '',
  version: 'v1.612',
  active_mods: 'bf1942',
  allied_team_ratio: '1',
  allow_nose_cam: 'yes',
  auto_balance_teams: 'off',
  axis_team_ratio: '1',
  bandwidth_choke_limit: '0',
  cpu: '3192',
  external_view: 'on',
  free_camera: 'off',
  game_start_delay: '10s',
  hit_indicator: 'on',
  kickback: '0%',
  kickback_on_splash: '0%',
  name_tag_distance: '100',
  name_tag_distance_scope: '300',
  number_of_rounds: '10',
  soldier_friendly_fire: '0%',
  soldier_friendly_fire_on_splash: '0%',
  spawn_delay: '3s',
  spawn_wave_time: '3s',
  ticket_ratio: '250%',
  time_limit: '90',
  tk_mode: 'punish',
  vehicle_friendly_fire: '0%',
  vehicle_friendly_fire_on_splash: '0%',
  deaths_0: '4',
  keyhash_0: '7d0e765cd26ea053004d15d7db90898c',
  kills_0: '30',
  ping_0: '9',
  playername_0: 'Schlingel',
  score_0: '32',
  team_0: '1',
  deaths_1: '3',
  keyhash_1: '7d0e765cd26ea053004d15d7db90898c',
  kills_1: '29',
  ping_1: '9',
  playername_1: 'Schlingel',
  score_1: '29',
  team_1: '1',
  deaths_2: '0',
  keyhash_2: '7d0e765cd26ea053004d15d7db90898c',
  kills_2: '17',
  ping_2: '10',
  playername_2: 'Schlingel',
  score_2: '17',
  team_2: '1',
  teamname_0: 'axis',
  teamname_1: 'allied'
}
Q#0 UDP send finished by callback
Q#0 Rejected player with hash 7d0e765cd26ea053004d15d7db90898c (Duplicate keyhash)
Q#0 Rejected player with hash 7d0e765cd26ea053004d15d7db90898c (Duplicate keyhash)
Q#0 Size of players array: 1
Q#0 Size of bots array: 0
Q#0 Query was successful
{
  "name": "Oz Wake [CD 1.61/Origin 1.612]",
  "map": "wake",
  "password": false,
  "raw": {
    "gamename": "bfield1942",
    "gamever": "v1.612",
    "averagefps": 0,
    "content_check": 0,
    "dedicated": 2,
    "gameid": "bf1942",
    "gamemode": "openplaying",
    "gametype": "coop",
    "hostname": "Oz Wake [CD 1.61/Origin 1.612]",
    "hostport": 14567,
    "mapid": "BF1942",
    "mapname": "wake",
    "maxplayers": 24,
    "numplayers": 0,
    "password": 0,
    "reservedslots": 0,
    "roundtime": 5400,
    "roundtimeremain": 2883,
    "status": 4,
    "sv_punkbuster": 0,
    "tickets1": 181,
    "tickets2": 320,
    "unpure_mods": "",
    "version": "v1.612",
    "active_mods": "bf1942",
    "allied_team_ratio": 1,
    "allow_nose_cam": "yes",
    "auto_balance_teams": "off",
    "axis_team_ratio": 1,
    "bandwidth_choke_limit": 0,
    "cpu": 3192,
    "external_view": "on",
    "free_camera": "off",
    "game_start_delay": "10s",
    "hit_indicator": "on",
    "kickback": "0%",
    "kickback_on_splash": "0%",
    "name_tag_distance": "100",
    "name_tag_distance_scope": "300",
    "number_of_rounds": 10,
    "soldier_friendly_fire": "0%",
    "soldier_friendly_fire_on_splash": "0%",
    "spawn_delay": "3s",
    "spawn_wave_time": "3s",
    "ticket_ratio": "250%",
    "time_limit": 90,
    "tk_mode": "punish",
    "vehicle_friendly_fire": "0%",
    "vehicle_friendly_fire_on_splash": "0%",
    "teams": {
      "0": "axis",
      "1": "allied"
    }
  },
  "version": "v1.612",
  "maxplayers": 24,
  "numplayers": 1,
  "players": [
    {
      "name": "Schlingel",
      "raw": {
        "deaths": 4,
        "keyhash": "7d0e765cd26ea053004d15d7db90898c",
        "kills": 30,
        "ping": 9,
        "score": 32,
        "teamId": 0,
        "team": "axis"
      }
    }
  ],
  "bots": [],
  "queryPort": 23000,
  "connect": "108.61.255.31:14567",
  "ping": 18
}

Additional context
There is existing code that was likely added to address a side effect of this server behaviour:

// 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)
}
}

These duplicates are caused by the stale player list. If the server had three players online and two leave, the server will/might return the current data for the one remaining player first - followed by two stale entries for the same player. You can see this behaviour in the debug output above.

Potential fix
Only read as many as numplayers entries from the player list, as numplayers is always reported correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions