Skip to content

Commit

Permalink
Merge pull request #42 from Dunedan/log-game-names
Browse files Browse the repository at this point in the history
Log the names of hosted games
  • Loading branch information
Dunedan authored May 24, 2024
2 parents 54a78a9 + f683ae4 commit 532bd1b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions xpartamupp/xpartamupp.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,19 @@ def add_game(self, jid, data):
data['nbp-init'] = data['nbp']
data['state'] = 'init'
except (KeyError, TypeError, ValueError):
logger.warning("Received invalid data for add game from 0ad: %s", data)
logger.warning("Received invalid data for add game from %s: %s", jid, data)
return False
else:
if jid not in self.games:
logger.info('%s registered a game with the name "%s"', jid, data.get("name"))
else:
immutable_keys = ["IP", "name", "hostJID", "hostUsername", "mods"]
for key, value in data.items():
if key in immutable_keys and self.games[jid].get(key) != value:
logger.warning(
"Game hosted by %s changed immutable property \"%s\": "
"\"%s\" -> \"%s\"", jid, key, self.games[jid].get(key), value)

self.games[jid] = data
return True

Expand Down Expand Up @@ -128,7 +138,7 @@ def change_game_state(self, jid, data):
self.games[jid]['nbp'] = data['nbp']
self.games[jid]['players'] = data['players']
except (KeyError, ValueError):
logger.warning("Received invalid data for change game state from 0ad: %s", data)
logger.warning("Received invalid data for change game state from %s: %s", jid, data)
return False
else:
if 'startTime' not in self.games[jid]:
Expand Down

0 comments on commit 532bd1b

Please sign in to comment.