diff --git a/Main.py b/Main.py index 6d416c17..17f16ef0 100644 --- a/Main.py +++ b/Main.py @@ -246,7 +246,7 @@ def main(args, seed=None): return player, team, bytes(rom.name).decode() pool = concurrent.futures.ThreadPoolExecutor() - + multidata_task = None if not args.suppress_rom: rom_futures = [] @@ -302,11 +302,13 @@ def main(args, seed=None): with open(output_path('%s.multidata' % outfilebase), 'wb') as f: f.write(multidata) - pool.submit(write_multidata, rom_futures) + multidata_task = pool.submit(write_multidata, rom_futures) if not args.skip_playthrough: logger.info('Calculating playthrough.') create_playthrough(world) + if multidata_task: + multidata_task.result() # retrieve exception if one exists pool.shutdown() # wait for all queued tasks to complete if args.create_spoiler: # needs spoiler.hashes to be filled, that depend on rom_futures being done world.spoiler.to_file(output_path('%s_Spoiler.txt' % outfilebase)) diff --git a/ModuleUpdate.py b/ModuleUpdate.py index e8abef64..4093d537 100644 --- a/ModuleUpdate.py +++ b/ModuleUpdate.py @@ -10,7 +10,8 @@ def update_command(): subprocess.call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt', '--upgrade']) -naming_specialties = {"PyYAML": "yaml"} # PyYAML is imported as the name yaml +naming_specialties = {"PyYAML": "yaml", # PyYAML is imported as the name yaml + "maseya-z3pr": "maseya"} def update(): diff --git a/Rom.py b/Rom.py index 6e5b17e3..fa16109d 100644 --- a/Rom.py +++ b/Rom.py @@ -25,7 +25,10 @@ from Items import ItemFactory from EntranceShuffle import door_addresses import Patch - +try: + from maseya import z3pr +except: + z3pr = None class LocalRom(object): @@ -1477,16 +1480,33 @@ def apply_rom_settings(rom, beep, color, quickswap, fastmenu, disable_music, spr if sprite is not None: write_sprite(rom, sprite) + # reset palette if it was adjusted already default_ow_palettes(rom) - if ow_palettes == 'random': - randomize_ow_palettes(rom, local_random) - elif ow_palettes == 'blackout': - blackout_ow_palettes(rom) - default_uw_palettes(rom) - if uw_palettes == 'random': - randomize_uw_palettes(rom, local_random) - elif uw_palettes == 'blackout': + + if z3pr: + options = { + "randomize_dungeon": uw_palettes == 'random', + "randomize_overworld": ow_palettes == 'random' + } + if any(options.values()): + ColorF = z3pr.ColorF + + def next_color(): + return ColorF(local_random.random(), local_random.random(), local_random.random()) + + z3pr.randomize(rom.buffer, "maseya", next_color, options) + else: + logging.warning("Could not find z3pr palette shuffle. " + "If you want improved palette shuffling please install the maseya-z3pr package.") + if ow_palettes == 'random': + randomize_ow_palettes(rom, local_random) + if uw_palettes == 'random': + randomize_uw_palettes(rom, local_random) + + if ow_palettes == 'blackout': + blackout_ow_palettes(rom) + if uw_palettes == 'blackout': blackout_uw_palettes(rom) if isinstance(rom, LocalRom):