From 277e471f7ddc228b4588c1f2c6e122fcab9130a1 Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 26 Nov 2024 22:44:22 -0800 Subject: [PATCH 1/2] sc2: Fixing a potentially broken CMO depth assert; improving error message on disconnected CMO --- worlds/sc2/mission_order/structs.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/worlds/sc2/mission_order/structs.py b/worlds/sc2/mission_order/structs.py index 675b31324d28..324cde6b2263 100644 --- a/worlds/sc2/mission_order/structs.py +++ b/worlds/sc2/mission_order/structs.py @@ -217,7 +217,8 @@ def fill_depths(self) -> None: # Check for accessible missions cur_missions: Set[SC2MOGenMission] = { mission for mission in next_missions - if mission.is_unlocked(beaten_missions) + if not mission.option_empty + and mission.is_unlocked(beaten_missions) } if len(cur_missions) == 0: raise Exception(f"Mission order ran out of accessible missions during iteration {iterations}") @@ -230,10 +231,12 @@ def fill_depths(self) -> None: # If the beaten missions at depth X unlock a mission, said mission can be beaten at depth X+1 mission.min_depth = mission.entry_rule.get_depth(beaten_missions) + 1 new_next = [ - next_mission for next_mission in mission.next if not ( - next_mission in cur_missions or - next_mission in beaten_missions or - next_mission in new_beaten_missions + next_mission for next_mission in mission.next + if not next_mission.option_empty + and not ( + next_mission in cur_missions + or next_mission in beaten_missions + or next_mission in new_beaten_missions ) ] next_missions.update(new_next) @@ -267,10 +270,11 @@ def fill_depths(self) -> None: # Make sure we didn't miss anything assert len(accessible_campaigns) == len(self.campaigns) assert len(accessible_layouts) == sum(len(campaign.layouts) for campaign in self.campaigns) - assert len(beaten_missions) == sum( + total_missions = sum( len([mission for mission in layout.missions if not mission.option_empty]) for campaign in self.campaigns for layout in campaign.layouts ) + assert len(beaten_missions) == total_missions, f'Can only access {len(beaten_missions)} missions out of {total_missions}' # Fill campaign/layout depth values as min/max of their children for campaign in self.campaigns: From 959c55c5cac07c4f77c9f908d1011055dc92384d Mon Sep 17 00:00:00 2001 From: Salzkorn Date: Wed, 27 Nov 2024 14:47:14 +0100 Subject: [PATCH 2/2] Fix certain layouts leaking empty slots into next data --- worlds/sc2/mission_order/structs.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/worlds/sc2/mission_order/structs.py b/worlds/sc2/mission_order/structs.py index 324cde6b2263..202f780cacd7 100644 --- a/worlds/sc2/mission_order/structs.py +++ b/worlds/sc2/mission_order/structs.py @@ -217,8 +217,7 @@ def fill_depths(self) -> None: # Check for accessible missions cur_missions: Set[SC2MOGenMission] = { mission for mission in next_missions - if not mission.option_empty - and mission.is_unlocked(beaten_missions) + if mission.is_unlocked(beaten_missions) } if len(cur_missions) == 0: raise Exception(f"Mission order ran out of accessible missions during iteration {iterations}") @@ -231,9 +230,7 @@ def fill_depths(self) -> None: # If the beaten missions at depth X unlock a mission, said mission can be beaten at depth X+1 mission.min_depth = mission.entry_rule.get_depth(beaten_missions) + 1 new_next = [ - next_mission for next_mission in mission.next - if not next_mission.option_empty - and not ( + next_mission for next_mission in mission.next if not ( next_mission in cur_missions or next_mission in beaten_missions or next_mission in new_beaten_missions @@ -710,23 +707,15 @@ def __init__(self, world: World, parent: ReferenceType[SC2MOGenCampaign], name: mission.next = [self.missions[idx] for idx in mission.option_next] # Set up missions' prev data - seen_missions: Set[SC2MOGenMission] = set() - cur_missions: List[SC2MOGenMission] = [mission for mission in self.entrances] - while len(cur_missions) > 0: - mission = cur_missions.pop() - seen_missions.add(mission) + for mission in self.missions: for next_mission in mission.next: next_mission.prev.append(mission) - if next_mission not in seen_missions and \ - next_mission not in cur_missions: - cur_missions.append(next_mission) # Remove empty missions from access data for mission in self.missions: if mission.option_empty: for next_mission in mission.next: - if mission in next_mission.prev: - next_mission.prev.remove(mission) + next_mission.prev.remove(mission) mission.next.clear() for prev_mission in mission.prev: prev_mission.next.remove(mission)