From b82e3f2a8a47f4fbbd2e4d5a2f3794bcb823d253 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 17 Sep 2021 04:32:09 +0200 Subject: [PATCH] MultiServer: Split InvalidSlot out into InvalidGame and document all error codes. --- CommonClient.py | 6 +++++- MultiServer.py | 4 ++-- docs/network protocol.md | 8 +++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CommonClient.py b/CommonClient.py index 456311fa..9187159f 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -195,6 +195,9 @@ class CommonContext(): def event_invalid_slot(self): raise Exception('Invalid Slot; please verify that you have connected to the correct world.') + def event_invalid_game(self): + raise Exception('Invalid Game; please verify that you connected with the right game to the correct world.') + async def server_auth(self, password_requested): if password_requested and not self.password: logger.info('Enter the password required to join this game:') @@ -345,7 +348,8 @@ async def process_server_cmd(ctx: CommonContext, args: dict): errors = args["errors"] if 'InvalidSlot' in errors: ctx.event_invalid_slot() - + elif 'InvalidGame' in errors: + ctx.event_invalid_game() elif 'SlotAlreadyTaken' in errors: raise Exception('Player slot already in use for that team') elif 'IncompatibleVersion' in errors: diff --git a/MultiServer.py b/MultiServer.py index 375fade9..f75ebba6 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -1096,8 +1096,8 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict): else: team, slot = ctx.connect_names[args['name']] game = ctx.games[slot] - if args['game'] != game: - errors.add('InvalidSlot') + if "IgnoreGame" in args["tags"] and args['game'] != game: + errors.add('InvalidGame') # this can only ever be 0 or 1 elements clients = [c for c in ctx.endpoints if c.auth and c.slot == slot and c.team == team] if clients: diff --git a/docs/network protocol.md b/docs/network protocol.md index 82fe2ebf..2c5e556b 100644 --- a/docs/network protocol.md +++ b/docs/network protocol.md @@ -83,7 +83,13 @@ Sent to clients when the server refuses connection. This is sent during the init #### Arguments | Name | Type | Notes | | ---- | ---- | ----- | -| errors | list\[str\] | Optional. When provided, should contain any one of: `InvalidSlot`, `SlotAlreadyTaken`, `IncompatibleVersion`, or `InvalidPassword`. | +| errors | list\[str\] | Optional. When provided, should contain any one of: `InvalidSlot`, `InvalidGame`, `SlotAlreadyTaken`, `IncompatibleVersion`, or `InvalidPassword`. | + +InvalidSlot indicates that the sent 'name' field did not match any auth entry on the server. +InvalidGame indicates that a correctly named slot was found, but the game for it mismatched. +SlotAlreadyTaken indicates a connection with a different uuid is already established. +IncompatibleVersion indicates a version mismatch. +InvalidPassword indicates the wrong, or no password when it was required, was sent. ### Connected Sent to clients when the connection handshake is successfully completed.