def onPlayerConnect(player): id = player.stats.connectionOrderNr #reconnect = id in sessionPlayerMedalMap #reconnect = False # omero, 2006-03-14 # reverting back to original code. # # todo: # leaving reconnect=false has a side-effect of # queries in rapid succession to db at each # gamestatus change which could flood the backend. # needs to be clarified, meantime during testing # there has been no evidence of problems with # reverting back. # reconnect = id in sessionPlayerMedalMap if id in sessionPlayerMedalMap: if g_debug: print "medals.py[216]: Player id=%d found in sessionPlayerMedalMap" % int(id) if not reconnect: newMedalSet = MedalSet() sessionPlayerMedalMap[id] = newMedalSet player.medals = sessionPlayerMedalMap[id] player.medals.connect(reconnect) if not reconnect: #rank player.score.rank = 0 if g_debug: print "medals.py[226]: Added player %d, %s (%s) IP=%s to medal/rank checking" % ( player.index, player.getName(), str(player.getProfileId()), player.getAddress()) else: player.score.rank = player.stats.rank if g_debug: print "medals.py[229]: Readded player %d to medal/rank checking" % player.index # Force gamespy request (due to bug with Glodal Data Update) reconnect = False if player.getProfileId() > 0 and not reconnect: if g_debug: print "medals.py[230]: Getting Stats..." # get persistant stats from gamespy #print "medals.py[236]: host.ss_getParam('ranked') = ", host.ss_getParam('ranked') #if host.ss_getParam('ranked'): player.score.rank = player.stats.rank # STATS if g_debug: print "medals.py[240]: Requesting player STATS" success = host.pers_plrRequestStats(player.index, 1, "&mode=base", 0) #print "medals.py[242]: globalKeyString2 %s" % globalKeyString # fetch player stats from a friendly place if not success: if g_debug: print "medals.py[245]: Retrieving player STATS via HTTP/1.1 miniclient" # AWARDS if g_debug: print "medals.py[274]: Requesting player AWARDS" success = host.pers_plrRequestAwards(player.index, 1, "") # fetch player awards from a friendly place if not success: if g_debug: print "medals.py[279]: Retrieving player AWARDS via HTTP/1.1 miniclient"
def onPlayerConnect(player): global updateTimer id = player.stats.connectionOrderNr # Check if player already in MedalMap, if so reconnect them reconnect = id in sessionPlayerMedalMap if id in sessionPlayerMedalMap: if g_debug: print "Player id=%d found in sessionPlayerMedalMap" % int(id) if not reconnect: newMedalSet = MedalSet() sessionPlayerMedalMap[id] = newMedalSet player.medals = sessionPlayerMedalMap[id] player.medals.connect(reconnect) if not reconnect: #rank player.score.rank = 0 # Added by Chump - for bf2statistics stats #if g_debug: print "Added player %d to medal checking" % (player.index) if g_debug: print "Added player %d, %s (%s) to medal/rank checking" % ( player.index, player.getName(), str(player.getProfileId()) ) else: player.score.rank = player.stats.rank # Added by Chump - for bf2statistics stats #if g_debug: print "Readded player %d to medal checking" % (player.index) if g_debug: print "Readded player %d to medal/rank checking" % player.index # This code is used to reduce the "request storm" generated at the start of a round. # Check if this player's STATS were updated in the last 30 seconds # We only need to do this at the start of a round, just ignore otherwise if player.getGlobalUpdateTime() > 30 and player.stats.wasHereAtStart == 1: # STATS are a bit stale, force gamespy request (this should only occur ONCE per round) # Final check just to make sure player isn't reconnecting mid-round due to a CTD if player.stats.timeOnLine < 30: reconnect = False if player.getProfileId() > 2000 and not reconnect: if g_debug: print "Getting Stats..." # get persistant stats from gamespy # Added by Chump - for bf2statistics stats (plus de-indenting) #if host.ss_getParam('ranked'): player.score.rank = player.stats.rank # STATS success = False if not player.isAIPlayer(): if g_debug: print "Requesting player STATS" success = host.pers_plrRequestStats(player.index, 1, globalKeyString) # Player is either AI or Offline, so we will manually get STATS if not success: if g_debug: print "Retrieving player STATS via HTTP/1.1 miniclient" # URL for retrieving player's awards and stats records via internal miniclient asp_playerinfo = '/ASP/getplayerinfo.aspx?pid=' + str(player.getProfileId()) + globalKeyString # Fetch Data data = http_get( http_backend_addr, http_backend_port, asp_playerinfo ) if data and data[0] == 'O': print "Received STATS data is VALID, length %d" % int(len(data)) stats = {} datalines = data.splitlines() keys = datalines[3].split('\t') vals = datalines[4].split('\t') if (len(keys) == len(vals)): if g_debug: print "Assembling STATS dictionary with %d keys" % int(len(keys)) for idx in range(1,len(keys)): stats[keys[idx]] = vals[idx] # eventually reattach persistent stats records to this player attachPlayerStats(player,stats) else: print "ERROR: Received STATS data is NOT VALID, length %d" % int(len(data)) # AWARDS success = False if not player.isAIPlayer(): if g_debug: print "Requesting player AWARDS" success = host.pers_plrRequestAwards(player.index, 1, "") # Player is either AI or Offline, so we will manually get AWARDS if not success: if g_debug: print "Retrieving player AWARDS via HTTP/1.1 miniclient" # URL for retrieving player's awards and stats records via internal miniclient asp_awardsinfo = '/ASP/getawardsinfo.aspx?pid=' + str(player.getProfileId()) # Fetch Data data = http_get( http_backend_addr, http_backend_port, asp_awardsinfo ) if data and data[0] == 'O': print "Received AWARDS data is VALID, lenght %d" % int(len(data)) awards = {} datalines = data.splitlines() skip = True for dataline in datalines: # the first dataline retrieved only contains pid and nick, # do nothing and mark the skip flag to false. # all subsequent datalines will be processed normally if dataline[0] == 'D' and skip: skip = False elif dataline[0] == 'D': items = dataline.split('\t') medalkey = items[1] medallev = items[2] awards[medalkey] = medallev # eventually reattach persistent awards records to this player attachPlayerAwards(player,awards) else: print "ERROR: Received AWARDS data is NOT VALID, length %d" % int(len(data)) # Record STATS update time player.setGlobalUpdateTime()
def onPlayerConnect(player): global updateTimer id = player.stats.connectionOrderNr # Check if player already in MedalMap, if so reconnect them reconnect = id in sessionPlayerMedalMap if id in sessionPlayerMedalMap: if g_debug: print "Player id=%d found in sessionPlayerMedalMap" % int(id) if not reconnect: newMedalSet = MedalSet() sessionPlayerMedalMap[id] = newMedalSet player.medals = sessionPlayerMedalMap[id] player.medals.connect(reconnect) if not reconnect: #rank player.score.rank = 0 # Added by Chump - for bf2statistics stats #if g_debug: print "Added player %d to medal checking" % (player.index) if g_debug: print "Added player %d, %s (%s) to medal/rank checking" % ( player.index, player.getName(), str(player.getProfileId())) else: player.score.rank = player.stats.rank # Added by Chump - for bf2statistics stats #if g_debug: print "Readded player %d to medal checking" % (player.index) if g_debug: print "Readded player %d to medal/rank checking" % player.index # This code is used to reduce the "request storm" generated at the start of a round. # Check if this player's STATS were updated in the last 30 seconds # We only need to do this at the start of a round, just ignore otherwise if player.getGlobalUpdateTime( ) > 30 and player.stats.wasHereAtStart == 1: # STATS are a bit stale, force gamespy request (this should only occur ONCE per round) # Final check just to make sure player isn't reconnecting mid-round due to a CTD if player.stats.timeOnLine < 30: reconnect = False if player.getProfileId() > 2000 and not reconnect: if g_debug: print "Getting Stats..." # get persistant stats from gamespy # Added by Chump - for bf2statistics stats (plus de-indenting) #if host.ss_getParam('ranked'): player.score.rank = player.stats.rank # STATS success = False if not player.isAIPlayer(): if g_debug: print "Requesting player STATS" success = host.pers_plrRequestStats(player.index, 1, globalKeyString) # Player is either AI or Offline, so we will manually get STATS if not success: if g_debug: print "Retrieving player STATS via HTTP/1.1 miniclient" # URL for retrieving player's awards and stats records via internal miniclient asp_playerinfo = '/ASP/getplayerinfo.aspx?pid=' + str( player.getProfileId()) + globalKeyString # Fetch Data data = http_get(http_backend_addr, http_backend_port, asp_playerinfo) if data and data[0] == 'O': print "Received STATS data is VALID, length %d" % int( len(data)) stats = {} datalines = data.splitlines() keys = datalines[3].split('\t') vals = datalines[4].split('\t') if (len(keys) == len(vals)): if g_debug: print "Assembling STATS dictionary with %d keys" % int( len(keys)) for idx in range(1, len(keys)): stats[keys[idx]] = vals[idx] # eventually reattach persistent stats records to this player attachPlayerStats(player, stats) else: print "ERROR: Received STATS data is NOT VALID, length %d" % int( len(data)) # AWARDS success = False if not player.isAIPlayer(): if g_debug: print "Requesting player AWARDS" success = host.pers_plrRequestAwards(player.index, 1, "") # Player is either AI or Offline, so we will manually get AWARDS if not success: if g_debug: print "Retrieving player AWARDS via HTTP/1.1 miniclient" # URL for retrieving player's awards and stats records via internal miniclient asp_awardsinfo = '/ASP/getawardsinfo.aspx?pid=' + str( player.getProfileId()) # Fetch Data data = http_get(http_backend_addr, http_backend_port, asp_awardsinfo) if data and data[0] == 'O': print "Received AWARDS data is VALID, lenght %d" % int( len(data)) awards = {} datalines = data.splitlines() skip = True for dataline in datalines: # the first dataline retrieved only contains pid and nick, # do nothing and mark the skip flag to false. # all subsequent datalines will be processed normally if dataline[0] == 'D' and skip: skip = False elif dataline[0] == 'D': items = dataline.split('\t') medalkey = items[1] medallev = items[2] awards[medalkey] = medallev # eventually reattach persistent awards records to this player attachPlayerAwards(player, awards) else: print "ERROR: Received AWARDS data is NOT VALID, length %d" % int( len(data)) # Record STATS update time player.setGlobalUpdateTime()
def onPlayerConnect(player): id = player.stats.connectionOrderNr #reconnect = id in sessionPlayerMedalMap #reconnect = False # omero, 2006-03-14 # reverting back to original code. # # todo: # leaving reconnect=false has a side-effect of # queries in rapid succession to db at each # gamestatus change which could flood the backend. # needs to be clarified, meantime during testing # there has been no evidence of problems with # reverting back. # reconnect = id in sessionPlayerMedalMap if id in sessionPlayerMedalMap: if g_debug: print "medals.py[216]: Player id=%d found in sessionPlayerMedalMap" % int( id) if not reconnect: newMedalSet = MedalSet() sessionPlayerMedalMap[id] = newMedalSet player.medals = sessionPlayerMedalMap[id] player.medals.connect(reconnect) if not reconnect: #rank player.score.rank = 0 if g_debug: print "medals.py[226]: Added player %d, %s (%s) IP=%s to medal/rank checking" % ( player.index, player.getName(), str( player.getProfileId()), player.getAddress()) else: player.score.rank = player.stats.rank if g_debug: print "medals.py[229]: Readded player %d to medal/rank checking" % player.index # Force gamespy request (due to bug with Glodal Data Update) reconnect = False if player.getProfileId() > 0 and not reconnect: if g_debug: print "medals.py[230]: Getting Stats..." # get persistant stats from gamespy #print "medals.py[236]: host.ss_getParam('ranked') = ", host.ss_getParam('ranked') #if host.ss_getParam('ranked'): player.score.rank = player.stats.rank # STATS if g_debug: print "medals.py[240]: Requesting player STATS" success = host.pers_plrRequestStats(player.index, 1, "&mode=base", 0) #print "medals.py[242]: globalKeyString2 %s" % globalKeyString # fetch player stats from a friendly place if not success: if g_debug: print "medals.py[245]: Retrieving player STATS via HTTP/1.1 miniclient" # AWARDS if g_debug: print "medals.py[274]: Requesting player AWARDS" success = host.pers_plrRequestAwards(player.index, 1, "") # fetch player awards from a friendly place if not success: if g_debug: print "medals.py[279]: Retrieving player AWARDS via HTTP/1.1 miniclient"