Removing some permament negative effects of using copy_world

This commit is contained in:
codemann8
2022-07-11 17:44:18 -05:00
parent 91f7bc8cef
commit ae271b0e73
3 changed files with 15 additions and 16 deletions

View File

@@ -1448,9 +1448,8 @@ def junk_fill_inaccessible(world, player):
for p in range(1, world.players + 1):
world.key_logic[p] = {}
base_world = copy_world(world)
base_world = copy_world(world, True)
base_world.override_bomb_check = True
world.key_logic = {}
# remove regions that have a dungeon entrance
accessible_regions = list()
@@ -1617,9 +1616,8 @@ def build_accessible_entrance_list(world, start_region, player, assumed_inventor
for p in range(1, world.players + 1):
world.key_logic[p] = {}
base_world = copy_world(world)
base_world = copy_world(world, True)
base_world.override_bomb_check = True
world.key_logic = {}
connect_simple(base_world, 'Links House S&Q', start_region, player)
blank_state = CollectionState(base_world)
@@ -1727,9 +1725,8 @@ def can_reach(world, entrance_name, region_name, player):
for p in range(1, world.players + 1):
world.key_logic[p] = {}
base_world = copy_world(world)
base_world = copy_world(world, True)
base_world.override_bomb_check = True
world.key_logic = {}
entrance = world.get_entrance(entrance_name, player)
connect_simple(base_world, 'Links House S&Q', entrance.parent_region.name, player)

13
Main.py
View File

@@ -398,7 +398,7 @@ def main(args, seed=None, fish=None):
return world
def copy_world(world):
def copy_world(world, partial_copy=False):
# ToDo: Not good yet
ret = World(world.players, world.owShuffle, world.owCrossed, world.owMixed, world.shuffle, world.doorShuffle, world.logic, world.mode, world.swords,
world.difficulty, world.difficulty_adjustments, world.timer, world.progressive, world.goal, world.algorithm,
@@ -544,9 +544,10 @@ def copy_world(world):
ret.dungeon_layouts = world.dungeon_layouts
ret.key_logic = world.key_logic
ret.dungeon_portals = world.dungeon_portals
for player, portals in world.dungeon_portals.items():
for portal in portals:
connect_portal(portal, ret, player)
if not partial_copy:
for player, portals in world.dungeon_portals.items():
for portal in portals:
connect_portal(portal, ret, player)
ret.sanc_portal = world.sanc_portal
from OverworldShuffle import categorize_world_regions
@@ -554,6 +555,10 @@ def copy_world(world):
categorize_world_regions(ret, player)
set_rules(ret, player)
if partial_copy:
# undo some of the things that unintentionally affect the original world object
world.key_logic = {}
return ret

View File

@@ -882,8 +882,7 @@ def build_sectors(world, player):
# perform accessibility check on duplicate world
for p in range(1, world.players + 1):
world.key_logic[p] = {}
base_world = copy_world(world)
world.key_logic = {}
base_world = copy_world(world, True)
# build lists of contiguous regions accessible with full inventory (excl portals/mirror/flute/entrances)
regions = list(OWTileRegions.copy().keys())
@@ -958,9 +957,8 @@ def build_accessible_region_list(world, start_region, player, build_copy_world=F
if build_copy_world:
for p in range(1, world.players + 1):
world.key_logic[p] = {}
base_world = copy_world(world)
base_world = copy_world(world, True)
base_world.override_bomb_check = True
world.key_logic = {}
else:
base_world = world
@@ -1048,8 +1046,7 @@ def validate_layout(world, player):
for p in range(1, world.players + 1):
world.key_logic[p] = {}
base_world = copy_world(world)
world.key_logic = {}
base_world = copy_world(world, True)
explored_regions = list()
if world.shuffle[player] in ['vanilla', 'dungeonssimple', 'dungeonsfull'] or not world.shufflelinks[player]: