diff --git a/SNIClient.py b/SNIClient.py index c97d0d6c..3d90fafc 100644 --- a/SNIClient.py +++ b/SNIClient.py @@ -1196,7 +1196,7 @@ async def game_watcher(ctx: Context): snes_buffered_write(ctx, SM_SEND_QUEUE_RCOUNT, bytes([recv_index & 0xFF, (recv_index >> 8) & 0xFF])) - from worlds.sm.Locations import locations_start_id + from worlds.sm import locations_start_id location_id = locations_start_id + itemIndex ctx.locations_checked.add(location_id) @@ -1211,8 +1211,8 @@ async def game_watcher(ctx: Context): itemOutPtr = data[0] | (data[1] << 8) - from worlds.sm.Items import items_start_id - from worlds.sm.Locations import locations_start_id + from worlds.sm import items_start_id + from worlds.sm import locations_start_id if itemOutPtr < len(ctx.items_received): item = ctx.items_received[itemOutPtr] itemId = item.item - items_start_id diff --git a/worlds/sm/Items.py b/worlds/sm/Items.py deleted file mode 100644 index ff8970b6..00000000 --- a/worlds/sm/Items.py +++ /dev/null @@ -1,14 +0,0 @@ -from worlds.sm.variaRandomizer.rando.Items import ItemManager - -items_start_id = 83000 - -def gen_special_id(): - special_id_value_start = 32 - while True: - yield special_id_value_start - special_id_value_start += 1 - -gen_run = gen_special_id() - -lookup_id_to_name = dict((items_start_id + (value.Id if value.Id != None else next(gen_run)), value.Name) for key, value in ItemManager.Items.items()) -lookup_name_to_id = {item_name: item_id for item_id, item_name in lookup_id_to_name.items()} \ No newline at end of file diff --git a/worlds/sm/Locations.py b/worlds/sm/Locations.py deleted file mode 100644 index 4e80ab00..00000000 --- a/worlds/sm/Locations.py +++ /dev/null @@ -1,14 +0,0 @@ -from worlds.sm.variaRandomizer.graph.location import locationsDict - -locations_start_id = 82000 - -def gen_boss_id(): - boss_id_value_start = 256 - while True: - yield boss_id_value_start - boss_id_value_start += 1 - -gen_run = gen_boss_id() - -lookup_id_to_name = dict((locations_start_id + (value.Id if value.Id != None else next(gen_run)), key) for key, value in locationsDict.items()) -lookup_name_to_id = {location_name: location_id for location_id, location_name in lookup_id_to_name.items()} \ No newline at end of file diff --git a/worlds/sm/__init__.py b/worlds/sm/__init__.py index 5da1c40f..fbf3825e 100644 --- a/worlds/sm/__init__.py +++ b/worlds/sm/__init__.py @@ -11,8 +11,6 @@ from worlds.sm.variaRandomizer.graph.graph_utils import GraphUtils logger = logging.getLogger("Super Metroid") -from .Locations import lookup_name_to_id as locations_lookup_name_to_id -from .Items import lookup_name_to_id as items_lookup_name_to_id from .Regions import create_regions from .Rules import set_rules, add_entrance_rule from .Options import sm_options @@ -68,6 +66,8 @@ class SMWeb(WebWorld): ["Farrak Kilhn"] )] +locations_start_id = 82000 +items_start_id = 83000 class SMWorld(World): """ @@ -78,12 +78,11 @@ class SMWorld(World): game: str = "Super Metroid" topology_present = True - data_version = 1 + data_version = 2 option_definitions = sm_options - item_names: Set[str] = frozenset(items_lookup_name_to_id) - location_names: Set[str] = frozenset(locations_lookup_name_to_id) - item_name_to_id = items_lookup_name_to_id - location_name_to_id = locations_lookup_name_to_id + + item_name_to_id = {value.Name: items_start_id + value.Id for key, value in ItemManager.Items.items() if value.Id != None} + location_name_to_id = {key: locations_start_id + value.Id for key, value in locationsDict.items() if value.Id != None} web = SMWeb() remote_items: bool = False @@ -701,8 +700,8 @@ class SMWorld(World): dest.Name) for src, dest in self.variaRando.randoExec.areaGraph.InterAreaTransitions if src.Boss])) def create_locations(self, player: int): - for name, id in locations_lookup_name_to_id.items(): - self.locations[name] = SMLocation(player, name, id) + for name in locationsDict: + self.locations[name] = SMLocation(player, name, self.location_name_to_id.get(name, None)) def create_region(self, world: MultiWorld, player: int, name: str, locations=None, exits=None):