From 62a6cdc9f76bfe3ebcf996905cb904ebd75ac2bf Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 13 Jul 2021 19:14:57 +0200 Subject: [PATCH] allow remote_items to be set via AutoWorld --- BaseClasses.py | 1 - Main.py | 4 ++-- worlds/AutoWorld.py | 6 ++++++ worlds/alttp/Rom.py | 5 +++-- worlds/alttp/__init__.py | 2 ++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index dfe6310f..e06d9b69 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -68,7 +68,6 @@ class MultiWorld(): self.fix_palaceofdarkness_exit = self.AttributeProxy(lambda player: self.shuffle[player] not in ['vanilla', 'simple', 'restricted', 'dungeonssimple']) self.fix_trock_exit = self.AttributeProxy(lambda player: self.shuffle[player] not in ['vanilla', 'simple', 'restricted', 'dungeonssimple']) self.NOTCURSED = self.AttributeProxy(lambda player: not self.CURSED[player]) - self.remote_items = self.AttributeProxy(lambda player: self.game[player] != "A Link to the Past") for player in range(1, players + 1): def set_player_attr(attr, val): diff --git a/Main.py b/Main.py index 6e11aa9f..29c56a2b 100644 --- a/Main.py +++ b/Main.py @@ -525,8 +525,8 @@ def main(args, seed=None): "games": games, "names": parsed_names, "connect_names": connect_names, - "remote_items": {player for player in range(1, world.players + 1) if - world.remote_items[player]}, + "remote_items": {player for player in world.player_ids if + world.worlds[player].remote_items}, "locations": locations_data, "checks_in_area": checks_in_area, "server_options": get_options()["server_options"], diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index 0e821dea..0ac75900 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -58,6 +58,12 @@ class World(metaclass=AutoWorldRegister): hint_blacklist: Set[str] = frozenset() # any names that should not be hintable + # if a world is set to remote_items, then it just needs to send location checks to the server and the server + # sends back the items + # if a world is set to remote_items = False, then the server never sends an item where receiver == finder, + # the client finds its own items in its own world. + remote_items: bool = True + def __init__(self, world: MultiWorld, player: int): self.world = world self.player = player diff --git a/worlds/alttp/Rom.py b/worlds/alttp/Rom.py index 390f096e..ae222f01 100644 --- a/worlds/alttp/Rom.py +++ b/worlds/alttp/Rom.py @@ -790,7 +790,7 @@ def patch_rom(world, rom, player, team, enemized): itemid = 0x33 elif location.item.compass: itemid = 0x25 - if world.remote_items[player]: + if world.worlds[player].remote_items: # remote items does not currently work itemid = list(location_table.keys()).index(location.name) + 1 assert itemid < 0x100 rom.write_byte(location.player_address, 0xFF) @@ -1647,7 +1647,8 @@ def patch_rom(world, rom, player, team, enemized): write_strings(rom, world, player, team) - rom.write_byte(0x18637C, 1 if world.remote_items[player] else 0) + # remote items flag, does not currently work + rom.write_byte(0x18637C, int(world.worlds[player].remote_items)) # set rom name # 21 bytes diff --git a/worlds/alttp/__init__.py b/worlds/alttp/__init__.py index c65ed00b..160bcb58 100644 --- a/worlds/alttp/__init__.py +++ b/worlds/alttp/__init__.py @@ -18,6 +18,8 @@ class ALTTPWorld(World): item_name_to_id = {name: data.item_code for name, data in item_table.items() if type(data.item_code) == int} location_name_to_id = lookup_name_to_id + remote_items: bool = False + def collect(self, state: CollectionState, item: Item) -> bool: if item.name.startswith('Progressive '): if 'Sword' in item.name: