diff --git a/MultiClient.py b/MultiClient.py index e74fd606..20282d04 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -796,15 +796,10 @@ async def console_loop(ctx : Context): await snes_flush_writes(ctx) def get_item_name_from_id(code): - items = [k for k, i in Items.item_table.items() if type(i[3]) is int and i[3] == code] - return items[0] if items else 'Unknown item' + return Items.lookup_id_to_name.get(code, 'Unknown item') def get_location_name_from_address(address): - if type(address) is str: - return address - - locs = [k for k, l in Regions.location_table.items() if type(l[0]) is int and l[0] == address] - return locs[0] if locs else 'Unknown location' + return Regions.lookup_id_to_name.get(address, 'Unknown location') async def track_locations(ctx : Context, roomid, roomdata): new_locations = [] diff --git a/Regions.py b/Regions.py index e46b21c1..4dc2874d 100644 --- a/Regions.py +++ b/Regions.py @@ -615,3 +615,5 @@ location_table = {'Mushroom': (0x180013, 0x186338, False, 'in the woods'), 'Ice Palace - Prize': ([0x120A4, 0x53F5A, 0x53F5B, 0x180059, 0x180073, 0xC705], None, True, 'Ice Palace'), 'Misery Mire - Prize': ([0x120A2, 0x53F48, 0x53F49, 0x180057, 0x180075, 0xC703], None, True, 'Misery Mire'), 'Turtle Rock - Prize': ([0x120A7, 0x53F24, 0x53F25, 0x18005C, 0x180079, 0xC708], None, True, 'Turtle Rock')} + +lookup_id_to_name = {data[0] : name for name, data in location_table.items() if type(data[0]) == int} \ No newline at end of file