Skip to content

Commit

Permalink
balance: fixed data cleanup on player disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
em92 committed May 28, 2018
1 parent 7a4314b commit 295df58
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,21 @@ def f():
f()

def handle_player_disconnect(self, player, reason):
self.clean_player_data(player)

@minqlx.thread
def clean_player_data(self, player):
for p in self.players().copy():
if p.steam_id == player.steam_id and p.id != player.id:
# there is a second client with same steam id
return

if player.steam_id in self.player_info:
del self.player_info[player.steam_id]

if player.steam_id in self.ratings:
del self.ratings[player.steam_id]
with self.ratings_lock:
if player.steam_id in self.ratings:
del self.ratings[player.steam_id]

@minqlx.thread
def fetch_ratings(self, players, request_id):
Expand Down

0 comments on commit 295df58

Please sign in to comment.