Skip to content

Commit

Permalink
Fix certain layouts leaking empty slots into next data
Browse files Browse the repository at this point in the history
  • Loading branch information
Salzkorn authored and MatthewMarinets committed Nov 27, 2024
1 parent 277e471 commit 959c55c
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions worlds/sc2/mission_order/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 959c55c

Please sign in to comment.