Skip to content

Commit

Permalink
Merge branch 'main' into sni_death_text
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvris authored Sep 30, 2023
2 parents 45368bb + 58b696e commit 626528d
Show file tree
Hide file tree
Showing 196 changed files with 5,097 additions and 2,947 deletions.
17 changes: 1 addition & 16 deletions BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,7 @@ def add_group(self, name: str, game: str, players: Set[int] = frozenset()) -> Tu
self.player_types[new_id] = NetUtils.SlotType.group
self._region_cache[new_id] = {}
world_type = AutoWorld.AutoWorldRegister.world_types[game]
for option_key, option in world_type.option_definitions.items():
getattr(self, option_key)[new_id] = option(option.default)
for option_key, option in Options.common_options.items():
getattr(self, option_key)[new_id] = option(option.default)
for option_key, option in Options.per_game_common_options.items():
getattr(self, option_key)[new_id] = option(option.default)

self.worlds[new_id] = world_type(self, new_id)
self.worlds[new_id] = world_type.create_group(self, new_id, players)
self.worlds[new_id].collect_item = classmethod(AutoWorld.World.collect_item).__get__(self.worlds[new_id])
self.player_name[new_id] = name

Expand Down Expand Up @@ -853,14 +846,6 @@ def can_reach(self, state: CollectionState) -> bool:
state.update_reachable_regions(self.player)
return self in state.reachable_regions[self.player]

def can_reach_private(self, state: CollectionState) -> bool:
for entrance in self.entrances:
if entrance.can_reach(state):
if not self in state.path:
state.path[self] = (self.name, state.path.get(entrance, None))
return True
return False

@property
def hint_text(self) -> str:
return self._hint_text if self._hint_text else self.name
Expand Down
14 changes: 4 additions & 10 deletions Fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,6 @@ def failed(warning: str, force: typing.Union[bool, str]) -> None:
else: # not reachable with swept state
non_early_locations[loc.player].append(loc.name)

# TODO: remove. Preferably by implementing key drop
from worlds.alttp.Regions import key_drop_data
world_name_lookup = world.world_name_lookup

block_value = typing.Union[typing.List[str], typing.Dict[str, typing.Any], str]
Expand Down Expand Up @@ -840,12 +838,12 @@ def failed(warning: str, force: typing.Union[bool, str]) -> None:

if "early_locations" in locations:
locations.remove("early_locations")
for player in worlds:
locations += early_locations[player]
for target_player in worlds:
locations += early_locations[target_player]
if "non_early_locations" in locations:
locations.remove("non_early_locations")
for player in worlds:
locations += non_early_locations[player]
for target_player in worlds:
locations += non_early_locations[target_player]

block['locations'] = locations

Expand Down Expand Up @@ -897,10 +895,6 @@ def failed(warning: str, force: typing.Union[bool, str]) -> None:
for item_name in items:
item = world.worlds[player].create_item(item_name)
for location in reversed(candidates):
if location in key_drop_data:
warn(
f"Can't place '{item_name}' at '{placement.location}', as key drop shuffle locations are not supported yet.")
continue
if not location.item:
if location.item_rule(item):
if location.can_fill(world.state, item, False):
Expand Down
15 changes: 11 additions & 4 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,13 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
exclusion_rules(world, player, world.exclude_locations[player].value)
world.priority_locations[player].value -= world.exclude_locations[player].value
for location_name in world.priority_locations[player].value:
world.get_location(location_name, player).progress_type = LocationProgressType.PRIORITY
try:
location = world.get_location(location_name, player)
except KeyError as e: # failed to find the given location. Check if it's a legitimate location
if location_name not in world.worlds[player].location_name_to_id:
raise Exception(f"Unable to prioritize location {location_name} in player {player}'s world.") from e
else:
location.progress_type = LocationProgressType.PRIORITY

# Set local and non-local item rules.
if world.players > 1:
Expand All @@ -159,7 +165,8 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
for player, items in depletion_pool.items():
player_world: AutoWorld.World = world.worlds[player]
for count in items.values():
new_items.append(player_world.create_filler())
for _ in range(count):
new_items.append(player_world.create_filler())
target: int = sum(sum(items.values()) for items in depletion_pool.values())
for i, item in enumerate(world.itempool):
if depletion_pool[item.player].get(item.name, 0):
Expand All @@ -179,6 +186,7 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
if remaining_items:
raise Exception(f"{world.get_player_name(player)}"
f" is trying to remove items from their pool that don't exist: {remaining_items}")
assert len(world.itempool) == len(new_items), "Item Pool amounts should not change."
world.itempool[:] = new_items

# temporary home for item links, should be moved out of Main
Expand Down Expand Up @@ -392,15 +400,14 @@ def precollect_hint(location):
f.write(bytes([3])) # version of format
f.write(multidata)

multidata_task = pool.submit(write_multidata)
output_file_futures.append(pool.submit(write_multidata))
if not check_accessibility_task.result():
if not world.can_beat_game():
raise Exception("Game appears as unbeatable. Aborting.")
else:
logger.warning("Location Accessibility requirements not fulfilled.")

# retrieve exceptions via .result() if they occurred.
multidata_task.result()
for i, future in enumerate(concurrent.futures.as_completed(output_file_futures), start=1):
if i % 10 == 0 or i == len(output_file_futures):
logger.info(f'Generating output files ({i}/{len(output_file_futures)}).')
Expand Down
24 changes: 16 additions & 8 deletions NetUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,22 @@ def get_remaining(self, state: typing.Dict[typing.Tuple[int, int], typing.Set[in
if typing.TYPE_CHECKING: # type-check with pure python implementation until we have a typing stub
LocationStore = _LocationStore
else:
try:
import pyximport
pyximport.install()
except ImportError:
pyximport = None
try:
from _speedups import LocationStore
import _speedups
import os.path
if os.path.isfile("_speedups.pyx") and os.path.getctime(_speedups.__file__) < os.path.getctime("_speedups.pyx"):
warnings.warn(f"{_speedups.__file__} outdated! "
f"Please rebuild with `cythonize -b -i _speedups.pyx` or delete it!")
except ImportError:
warnings.warn("_speedups not available. Falling back to pure python LocationStore. "
"Install a matching C++ compiler for your platform to compile _speedups.")
LocationStore = _LocationStore
try:
import pyximport
pyximport.install()
except ImportError:
pyximport = None
try:
from _speedups import LocationStore
except ImportError:
warnings.warn("_speedups not available. Falling back to pure python LocationStore. "
"Install a matching C++ compiler for your platform to compile _speedups.")
LocationStore = _LocationStore
5 changes: 2 additions & 3 deletions SNIClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ def connect_to_snes(self, snes_options: str = "") -> bool:
options = snes_options.split()
num_options = len(options)

if num_options > 0:
snes_device_number = int(options[0])

if num_options > 1:
snes_address = options[0]
snes_device_number = int(options[1])
elif num_options > 0:
snes_device_number = int(options[0])

self.ctx.snes_reconnect_address = None
if self.ctx.snes_connect_task:
Expand Down
Loading

0 comments on commit 626528d

Please sign in to comment.