From cdc330629ba0142defb76587e3d8e73b9f04632b Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 19 Mar 2021 04:30:19 +0100 Subject: [PATCH] allow more HK names in console commands --- Main.py | 3 ++- MultiServer.py | 14 ++++++++------ worlds/__init__.py | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Main.py b/Main.py index 7b471a79..6ef8da6c 100644 --- a/Main.py +++ b/Main.py @@ -487,7 +487,8 @@ def main(args, seed=None): multidata = zlib.compress(pickle.dumps({"names": parsed_names, "connect_names": connect_names, "remote_items": {player for player in range(1, world.players + 1) if - world.remote_items[player]}, + world.remote_items[player] or + world.game[player] == "Hollow Knight"}, "locations": { (location.address, location.player): (location.item.code, location.item.player) diff --git a/MultiServer.py b/MultiServer.py index 4e0dd0bd..78cae7b7 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -26,7 +26,8 @@ from prompt_toolkit.patch_stdout import patch_stdout from fuzzywuzzy import process as fuzzy_process from worlds.alttp import Items, Regions -from worlds import network_data_package +from worlds import network_data_package, lookup_any_item_id_to_name, lookup_any_item_name_to_id, \ + lookup_any_location_id_to_name import Utils from Utils import get_item_name_from_id, get_location_name_from_address, \ _version_tuple, restricted_loads, Version @@ -34,8 +35,8 @@ from NetUtils import Node, Endpoint, CLientStatus, NetworkItem, decode colorama.init() lttp_console_names = frozenset(set(Items.item_table) | set(Items.item_name_groups) | set(Regions.lookup_name_to_id)) -all_items = frozenset(network_data_package["lookup_any_item_id_to_name"].values()) -all_locations = frozenset(network_data_package["lookup_any_location_id_to_name"].values()) +all_items = frozenset(lookup_any_item_id_to_name) +all_locations = frozenset(lookup_any_location_id_to_name) all_console_names = frozenset(all_items | all_locations) class Client(Endpoint): @@ -1188,9 +1189,10 @@ class ServerCommandProcessor(CommonCommandProcessor): if usable: for client in self.ctx.endpoints: if client.name == seeked_player: - new_item = NetworkItem(Items.item_table[item][2], -1, client.slot) + new_item = NetworkItem(lookup_any_item_name_to_id[item], -1, client.slot) get_received_items(self.ctx, client.team, client.slot).append(new_item) - self.ctx.notify_all('Cheat console: sending "' + item + '" to ' + self.ctx.get_aliased_name(client.team, client.slot)) + self.ctx.notify_all('Cheat console: sending "' + item + '" to ' + + self.ctx.get_aliased_name(client.team, client.slot)) send_new_items(self.ctx) return True else: @@ -1213,7 +1215,7 @@ class ServerCommandProcessor(CommonCommandProcessor): hints = [] for item in Items.item_name_groups[item]: hints.extend(collect_hints(self.ctx, team, slot, item)) - elif item in Items.item_table: # item name + elif item in all_items: # item name hints = collect_hints(self.ctx, team, slot, item) else: # location name hints = collect_hints_location(self.ctx, team, slot, item) diff --git a/worlds/__init__.py b/worlds/__init__.py index 8c2f0939..ec8b33ab 100644 --- a/worlds/__init__.py +++ b/worlds/__init__.py @@ -14,7 +14,7 @@ lookup_any_item_name_to_id = {name: id for id, name in lookup_any_item_id_to_nam from .alttp import Regions from .hk import Locations lookup_any_location_id_to_name = {**Regions.lookup_id_to_name, **Locations.lookup_id_to_name} - +lookup_any_location_name_to_id = {name: id for id, name in lookup_any_location_id_to_name.items()} network_data_package = {"lookup_any_location_id_to_name": lookup_any_location_id_to_name, "lookup_any_item_id_to_name": lookup_any_item_id_to_name, "version": 1}