def connect_entrance(world, entrancename, exitname, player):
    entrance = world.get_entrance(entrancename, player)
    try:
        region = world.get_region(exitname, player)
        exit = None
    except RuntimeError:
        exit = world.get_entrance(exitname, player)
        region = exit.parent_region
    if (entrance.connected_region is not None):
        entrance.connected_region.entrances.remove(entrance)
    target = (exit_ids[exit.name][0] if (exit is not None) else exit_ids.get(region.name, None))
    addresses = door_addresses[entrance.name][0]
    entrance.connect(region, addresses, target)
    world.spoiler.set_entrance(entrance.name, (exit.name if (exit is not None) else region.name), 'entrance', player)
def connect_entrance(world, entrancename, exitname, player):
    entrance = world.get_entrance(entrancename, player)
    try:
        region = world.get_region(exitname, player)
        exit = None
    except RuntimeError:
        exit = world.get_entrance(exitname, player)
        region = exit.parent_region
    if (entrance.connected_region is not None):
        entrance.connected_region.entrances.remove(entrance)
    target = (exit_ids[exit.name][0] if (exit is not None) else exit_ids.get(region.name, None))
    addresses = door_addresses[entrance.name][0]
    entrance.connect(region, addresses, target)
    world.spoiler.set_entrance(entrance.name, (exit.name if (exit is not None) else region.name), 'entrance', player)