optimise the client a bit

This commit is contained in:
Fabian Dill 2020-02-17 07:16:40 +01:00
parent 5c34119293
commit 5c803e911c
2 changed files with 4 additions and 7 deletions

View File

@ -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 = []

View File

@ -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}