MultiServer: original_cmd to InvalidPacket
This commit is contained in:
parent
60697cc8ba
commit
e8639988ce
|
@ -144,8 +144,8 @@ class Context(CommonContext):
|
||||||
}])
|
}])
|
||||||
|
|
||||||
def on_deathlink(self, data: dict):
|
def on_deathlink(self, data: dict):
|
||||||
snes_buffered_write(self, WRAM_START + 0xF36D, bytes([0]))
|
snes_buffered_write(self, WRAM_START + 0xF36D, bytes([0])) # set current health to 0
|
||||||
snes_buffered_write(self, WRAM_START + 0x0373, bytes([8]))
|
snes_buffered_write(self, WRAM_START + 0x0373, bytes([8])) # deal 1 full heart of damage at next opportunity
|
||||||
asyncio.create_task(snes_flush_writes(self))
|
asyncio.create_task(snes_flush_writes(self))
|
||||||
self.death_state = True
|
self.death_state = True
|
||||||
super(Context, self).on_deathlink(data)
|
super(Context, self).on_deathlink(data)
|
||||||
|
|
|
@ -1203,19 +1203,20 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict):
|
||||||
cmd: str = args["cmd"]
|
cmd: str = args["cmd"]
|
||||||
except:
|
except:
|
||||||
logging.exception(f"Could not get command from {args}")
|
logging.exception(f"Could not get command from {args}")
|
||||||
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "cmd",
|
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "cmd", "original_cmd": None,
|
||||||
"text": f"Could not get command from {args} at `cmd`"}])
|
"text": f"Could not get command from {args} at `cmd`"}])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if type(cmd) is not str:
|
if type(cmd) is not str:
|
||||||
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "cmd",
|
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "cmd", "original_cmd": None,
|
||||||
"text": f"Command should be str, got {type(cmd)}"}])
|
"text": f"Command should be str, got {type(cmd)}"}])
|
||||||
return
|
return
|
||||||
|
|
||||||
if cmd == 'Connect':
|
if cmd == 'Connect':
|
||||||
if not args or 'password' not in args or type(args['password']) not in [str, type(None)] or \
|
if not args or 'password' not in args or type(args['password']) not in [str, type(None)] or \
|
||||||
'game' not in args:
|
'game' not in args:
|
||||||
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "arguments", 'text': 'Connect'}])
|
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "arguments", 'text': 'Connect',
|
||||||
|
"original_cmd": cmd}])
|
||||||
return
|
return
|
||||||
|
|
||||||
errors = set()
|
errors = set()
|
||||||
|
@ -1285,7 +1286,8 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict):
|
||||||
elif client.auth:
|
elif client.auth:
|
||||||
if cmd == "ConnectUpdate":
|
if cmd == "ConnectUpdate":
|
||||||
if not args:
|
if not args:
|
||||||
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "arguments", 'text': cmd}])
|
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "arguments", 'text': cmd,
|
||||||
|
"original_cmd": cmd}])
|
||||||
return
|
return
|
||||||
|
|
||||||
if "tags" in args:
|
if "tags" in args:
|
||||||
|
@ -1301,7 +1303,8 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict):
|
||||||
elif cmd == 'LocationChecks':
|
elif cmd == 'LocationChecks':
|
||||||
if "Tracker" in client.tags:
|
if "Tracker" in client.tags:
|
||||||
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "cmd",
|
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "cmd",
|
||||||
"text": "Trackers can't register new Location Checks"}])
|
"text": "Trackers can't register new Location Checks",
|
||||||
|
"original_cmd": cmd}])
|
||||||
else:
|
else:
|
||||||
register_location_checks(ctx, client.team, client.slot, args["locations"])
|
register_location_checks(ctx, client.team, client.slot, args["locations"])
|
||||||
|
|
||||||
|
@ -1310,7 +1313,8 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict):
|
||||||
for location in args["locations"]:
|
for location in args["locations"]:
|
||||||
if type(location) is not int or location not in lookup_any_location_id_to_name:
|
if type(location) is not int or location not in lookup_any_location_id_to_name:
|
||||||
await ctx.send_msgs(client,
|
await ctx.send_msgs(client,
|
||||||
[{'cmd': 'InvalidPacket', "type": "arguments", "text": 'LocationScouts'}])
|
[{'cmd': 'InvalidPacket', "type": "arguments", "text": 'LocationScouts',
|
||||||
|
"original_cmd": cmd}])
|
||||||
return
|
return
|
||||||
target_item, target_player = ctx.locations[client.slot][location]
|
target_item, target_player = ctx.locations[client.slot][location]
|
||||||
locs.append(NetworkItem(target_item, location, target_player))
|
locs.append(NetworkItem(target_item, location, target_player))
|
||||||
|
@ -1322,7 +1326,8 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict):
|
||||||
|
|
||||||
elif cmd == 'Say':
|
elif cmd == 'Say':
|
||||||
if "text" not in args or type(args["text"]) is not str or not args["text"].isprintable():
|
if "text" not in args or type(args["text"]) is not str or not args["text"].isprintable():
|
||||||
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "arguments", "text": 'Say'}])
|
await ctx.send_msgs(client, [{'cmd': 'InvalidPacket', "type": "arguments", "text": 'Say',
|
||||||
|
"original_cmd": cmd}])
|
||||||
return
|
return
|
||||||
|
|
||||||
client.messageprocessor(args["text"])
|
client.messageprocessor(args["text"])
|
||||||
|
|
|
@ -184,6 +184,7 @@ Sent to clients if the server caught a problem with a packet. This only occurs f
|
||||||
| ---- | ---- | ----- |
|
| ---- | ---- | ----- |
|
||||||
| type | string | "cmd" if the Packet isn't available/allowed, "arguments" if the problem is with the package data. |
|
| type | string | "cmd" if the Packet isn't available/allowed, "arguments" if the problem is with the package data. |
|
||||||
| text | string | Error text explaining the caught error. |
|
| text | string | Error text explaining the caught error. |
|
||||||
|
| original_cmd | string | Echoes the cmd it failed on. May be null if the cmd was not found.
|
||||||
## (Client -> Server)
|
## (Client -> Server)
|
||||||
These packets are sent purely from client to server. They are not accepted by clients.
|
These packets are sent purely from client to server. They are not accepted by clients.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue