diff --git a/MultiClient.py b/MultiClient.py index 6f9bc2e6..763e1014 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -945,6 +945,8 @@ async def process_server_cmd(ctx: Context, args: dict): logger.info(args["text"]) elif cmd == 'PrintJSON': + if not ctx.found_items and args.get("type", None) == "ItemSend" and args["receiving"] == args["sending"]: + pass # don't want info on other player's local pickups. logger.info(ctx.jsontotextparser(args["data"])) elif cmd == 'InvalidArguments': @@ -954,10 +956,9 @@ async def process_server_cmd(ctx: Context, args: dict): logger.debug(f"unknown command {cmd}") +# kept as function for easier wrapping by plugins def get_tags(ctx: Context): tags = ['AP'] - if ctx.found_items: - tags.append('FoundItems') return tags @@ -1201,12 +1202,7 @@ async def track_locations(ctx: Context, roomid, roomdata): async def send_finished_game(ctx: Context): - try: - await ctx.send_msgs([{"cmd": "StatusUpdate", "status": CLientStatus.CLIENT_GOAL}]) - ctx.finished_game = True - except Exception as ex: - logger.exception(ex) - + await ctx.send_msgs([{"cmd": "StatusUpdate", "status": CLientStatus.CLIENT_GOAL}]) async def game_watcher(ctx: Context): prev_game_timer = 0 @@ -1247,7 +1243,8 @@ async def game_watcher(ctx: Context): delay = 7 if ctx.slow_mode else 2 if gameend[0]: if not ctx.finished_game: - await(send_finished_game(ctx)) + await send_finished_game(ctx) + ctx.finished_game = True if time.perf_counter() - perf_counter < delay: continue @@ -1268,13 +1265,9 @@ async def game_watcher(ctx: Context): continue recv_index = data[0] | (data[1] << 8) - assert RECV_ITEM_ADDR == RECV_PROGRESS_ADDR + 2 recv_item = data[2] - assert ROOMID_ADDR == RECV_PROGRESS_ADDR + 4 roomid = data[4] | (data[5] << 8) - assert ROOMDATA_ADDR == RECV_PROGRESS_ADDR + 6 roomdata = data[6] - assert SCOUT_LOCATION_ADDR == RECV_PROGRESS_ADDR + 7 scout_location = data[7] if recv_index < len(ctx.items_received) and recv_item == 0: diff --git a/MultiServer.py b/MultiServer.py index 732171fc..10d61dd0 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -33,7 +33,7 @@ from Utils import get_item_name_from_id, get_location_name_from_address, \ from NetUtils import Node, Endpoint, CLientStatus, NetworkItem, decode colorama.init() -console_names = frozenset(set(Items.item_table) | set(Items.item_name_groups) | set(Regions.lookup_name_to_id)) +lttp_console_names = frozenset(set(Items.item_table) | set(Items.item_name_groups) | set(Regions.lookup_name_to_id)) class Client(Endpoint): @@ -51,10 +51,6 @@ class Client(Endpoint): self.messageprocessor = client_message_processor(ctx, self) self.ctx = weakref.ref(ctx) - @property - def wants_item_notification(self): - return self.auth and "FoundItems" in self.tags - class Context(Node): simple_options = {"hint_cost": int, @@ -537,7 +533,7 @@ def json_format_send_event(net_item: NetworkItem, receiving_player: int): return {"cmd": "PrintJSON", "data": parts, "type": "ItemSend", "receiving": receiving_player, "sending": net_item.player} -def get_intended_text(input_text: str, possible_answers: typing.Iterable[str]= console_names) -> typing.Tuple[str, bool, str]: +def get_intended_text(input_text: str, possible_answers: typing.Iterable[str]= lttp_console_names) -> typing.Tuple[str, bool, str]: picks = fuzzy_process.extract(input_text, possible_answers, limit=2) if len(picks) > 1: dif = picks[0][1] - picks[1][1] @@ -1047,12 +1043,6 @@ async def process_client_cmd(ctx: Context, client: Client, args: dict): # logging.info(f"{client.name} in team {client.team+1} scouted {', '.join([l[0] for l in locs])}") await ctx.send_msgs(client, [{'cmd': 'LocationInfo', 'locations': locs}]) - elif cmd == 'UpdateTags': - if not args or type(args) is not list: - await ctx.send_msgs(client, [{"cmd": "InvalidArguments", "text": 'UpdateTags'}]) - return - client.tags = args - elif cmd == 'StatusUpdate': current = ctx.client_game_state[client.team, client.slot] if current != CLientStatus.CLIENT_GOAL: # can't undo goal completion