From 1f5d1532e31537dd79663dca2fd271e22971b8be Mon Sep 17 00:00:00 2001 From: CaitSith2 Date: Wed, 24 Nov 2021 01:38:58 -0800 Subject: [PATCH] Move Death Link change tag to Common Client --- CommonClient.py | 9 +++++++++ SNIClient.py | 9 +-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CommonClient.py b/CommonClient.py index aaba1a41..c4202491 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -315,6 +315,15 @@ class CommonContext(): self.input_requests -= 1 self.keep_alive_task.cancel() + async def update_death_link(self, death_link): + old_tags = self.tags.copy() + if death_link: + self.tags.add("DeathLink") + else: + self.tags -= {"DeathLink"} + if old_tags != self.tags and self.server and not self.server.socket.closed: + await self.send_msgs([{"cmd": "ConnectUpdate", "tags": self.tags}]) + async def keep_alive(ctx: CommonContext, seconds_between_checks=100): """some ISPs/network configurations drop TCP connections if no payload is sent (ignore TCP-keep-alive) diff --git a/SNIClient.py b/SNIClient.py index a4f9ba2c..f5d9fba2 100644 --- a/SNIClient.py +++ b/SNIClient.py @@ -905,14 +905,7 @@ async def game_watcher(ctx: Context): death_link = await snes_read(ctx, DEATH_LINK_ACTIVE_ADDR if ctx.game == GAME_ALTTP else SM_DEATH_LINK_ACTIVE_ADDR, 1) if death_link: - death_link = bool(death_link[0] & 0b1) - old_tags = ctx.tags.copy() - if death_link: - ctx.tags.add("DeathLink") - else: - ctx.tags -= {"DeathLink"} - if old_tags != ctx.tags and ctx.server and not ctx.server.socket.closed: - await ctx.send_msgs([{"cmd": "ConnectUpdate", "tags": ctx.tags}]) + await ctx.update_death_link(bool(death_link[0] & 0b1)) if not ctx.prev_rom or ctx.prev_rom != ctx.rom: ctx.locations_checked = set() ctx.locations_scouted = set()