diff --git a/Main.py b/Main.py index d7646f83..d375b24b 100644 --- a/Main.py +++ b/Main.py @@ -14,7 +14,7 @@ from Items import ItemFactory from KeyDoorShuffle import validate_key_placement from OverworldGlitchRules import create_owg_connections from PotShuffle import shuffle_pots, shuffle_pot_switches -from Regions import create_regions, create_shops, mark_light_world_regions, mark_dark_world_regions, create_dungeon_regions, adjust_locations +from Regions import create_regions, create_shops, mark_light_dark_world_regions, create_dungeon_regions, adjust_locations from OWEdges import create_owedges from OverworldShuffle import link_overworld, update_world_regions, create_flute_exits from EntranceShuffle import link_entrances @@ -204,10 +204,7 @@ def main(args, seed=None, fish=None): for player in range(1, world.players + 1): link_doors(world, player) - if world.mode[player] != 'inverted': - mark_light_world_regions(world, player) - else: - mark_dark_world_regions(world, player) + mark_light_dark_world_regions(world, player) logger.info(world.fish.translate("cli", "cli", "generating.itempool")) for player in range(1, world.players + 1): diff --git a/OverworldShuffle.py b/OverworldShuffle.py index d88c8d58..aa877f5c 100644 --- a/OverworldShuffle.py +++ b/OverworldShuffle.py @@ -2,7 +2,7 @@ import RaceRandom as random, logging, copy from collections import OrderedDict, defaultdict from DungeonGenerator import GenerationException from BaseClasses import OWEdge, WorldType, RegionType, Direction, Terrain, PolSlot, Entrance -from Regions import mark_dark_world_regions, mark_light_world_regions +from Regions import mark_light_dark_world_regions from OWEdges import OWTileRegions, OWEdgeGroups, OWEdgeGroupsTerrain, OWExitTypes, OpenStd, parallel_links, IsParallel from OverworldGlitchRules import create_owg_connections from Utils import bidict @@ -843,8 +843,7 @@ def categorize_world_regions(world, player): for exitname in OWExitTypes[type]: world.get_entrance(exitname, player).spot_type = type - mark_light_world_regions(world, player) - mark_dark_world_regions(world, player) + mark_light_dark_world_regions(world, player) def update_world_regions(world, player): if world.owMixed[player]: diff --git a/Regions.py b/Regions.py index 027d4e1b..e9755a8c 100644 --- a/Regions.py +++ b/Regions.py @@ -1076,67 +1076,46 @@ def _create_region(player, name, type, hint='Hyrule', locations=None, exits=None ret.locations.append(Location(player, location, address, crystal, hint_text, ret, None, player_address)) return ret -def mark_light_world_regions(world, player): +def mark_light_dark_world_regions(world, player): # cross world caves may have some sections marked as both in_light_world, and in_dark_work. # That is ok. the bunny logic will check for this case and incorporate special rules. - queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.LightWorld) - seen = set(queue) - while queue: - current = queue.popleft() - current.is_light_world = True - for exit in current.exits: - if exit.connected_region is None or exit.connected_region.type == RegionType.DarkWorld: # todo: remove none check - # Don't venture into the dark world - continue - if exit.connected_region not in seen: - seen.add(exit.connected_region) - queue.append(exit.connected_region) + # Note: I don't see why the order would matter, but the original Inverted code reversed the order + if world.mode[player] != 'inverted': + mark_light() + mark_dark() + else: + mark_dark() + mark_light() - queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.DarkWorld) - seen = set(queue) - while queue: - current = queue.popleft() - current.is_dark_world = True - for exit in current.exits: - if exit.connected_region is not None: - if exit.connected_region.type == RegionType.LightWorld: - # Don't venture into the light world - continue - if exit.connected_region not in seen: - seen.add(exit.connected_region) - queue.append(exit.connected_region) - - -def mark_dark_world_regions(world, player): - # cross world caves may have some sections marked as both in_light_world, and in_dark_work. - # That is ok. the bunny logic will check for this case and incorporate special rules. - queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.DarkWorld) - seen = set(queue) - while queue: - current = queue.popleft() - current.is_dark_world = True - for exit in current.exits: - if exit.connected_region is None or exit.connected_region.type == RegionType.LightWorld: # todo: remove none check - # Don't venture into the light world - continue - if exit.connected_region not in seen: - seen.add(exit.connected_region) - queue.append(exit.connected_region) - - queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.LightWorld) - seen = set(queue) - while queue: - current = queue.popleft() - current.is_light_world = True - for exit in current.exits: - if exit.connected_region is not None: - if exit.connected_region.type == RegionType.DarkWorld: + def mark_light(): + queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.LightWorld) + seen = set(queue) + while queue: + current = queue.popleft() + current.is_light_world = True + for exit in current.exits: + if exit.connected_region is None or exit.connected_region.type == RegionType.DarkWorld: # todo: remove none check # Don't venture into the dark world continue if exit.connected_region not in seen: seen.add(exit.connected_region) queue.append(exit.connected_region) + def mark_dark(): + queue = collections.deque(region for region in world.get_regions(player) if region.type == RegionType.DarkWorld) + seen = set(queue) + while queue: + current = queue.popleft() + current.is_dark_world = True + for exit in current.exits: + if exit.connected_region is not None: + if exit.connected_region.type == RegionType.LightWorld: + # Don't venture into the light world + continue + if exit.connected_region not in seen: + seen.add(exit.connected_region) + queue.append(exit.connected_region) + def create_shops(world, player): world.shops[player] = []