give Mystery.py the create_diff argument, then make MultiMystery.py use them
This commit is contained in:
parent
ad895f045c
commit
a0c4337bac
|
@ -91,7 +91,7 @@ if __name__ == "__main__":
|
|||
elif os.path.exists("BerserkerMultiServer"):
|
||||
basemysterycommand = "BerserkerMystery" # compiled linux
|
||||
else:
|
||||
basemysterycommand = f"py -{py_version} Mystery.py" #source
|
||||
basemysterycommand = f"py -{py_version} Mystery.py" # source
|
||||
|
||||
command = f"{basemysterycommand} --multi {len(player_files)} {player_string} " \
|
||||
f"--rom \"{rom_file}\" --enemizercli \"{enemizer_path}\" " \
|
||||
|
@ -101,6 +101,8 @@ if __name__ == "__main__":
|
|||
command += " --create_spoiler"
|
||||
if create_spoiler == 2:
|
||||
command += " --skip_playthrough"
|
||||
if zip_diffs:
|
||||
command += " --create_diff"
|
||||
if race:
|
||||
command += " --race"
|
||||
if os.path.exists(os.path.join(player_files_path, meta_file_path)):
|
||||
|
@ -108,9 +110,10 @@ if __name__ == "__main__":
|
|||
|
||||
print(command)
|
||||
import time
|
||||
|
||||
start = time.perf_counter()
|
||||
text = subprocess.check_output(command, shell=True).decode()
|
||||
print(f"Took {time.perf_counter()-start:.3f} seconds to generate rom(s).")
|
||||
print(f"Took {time.perf_counter() - start:.3f} seconds to generate multiworld.")
|
||||
seedname = ""
|
||||
|
||||
for segment in text.split():
|
||||
|
@ -161,25 +164,29 @@ if __name__ == "__main__":
|
|||
ipv4 = (host if host else get_public_ipv4()) + ":" + str(port)
|
||||
|
||||
|
||||
def _handle_file(file: str):
|
||||
if zip_diffs:
|
||||
# the main reason for using threading, the patch is created using bsdiff4, which frees the GIL
|
||||
diff = os.path.split(create_patch_file(os.path.join(output_path, file), ipv4))[1]
|
||||
pack_file(diff)
|
||||
if zip_diffs == 2:
|
||||
remove_zipped_file(diff)
|
||||
def _handle_sfc_file(file: str):
|
||||
if zip_roms:
|
||||
pack_file(file)
|
||||
if zip_roms == 2 and player_name.lower() not in file.lower():
|
||||
remove_zipped_file(file)
|
||||
|
||||
|
||||
def _handle_diff_file(file: str):
|
||||
if zip_diffs > 0:
|
||||
pack_file(file)
|
||||
if zip_diffs == 2:
|
||||
remove_zipped_file(file)
|
||||
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor() as pool:
|
||||
futures = []
|
||||
with zipfile.ZipFile(zipname, "w", compression=compression, compresslevel=9) as zf:
|
||||
for file in os.listdir(output_path):
|
||||
if file.endswith(".sfc") and seedname in file:
|
||||
futures.append(pool.submit(_handle_file, file))
|
||||
if seedname in file:
|
||||
if file.endswith(".sfc"):
|
||||
futures.append(pool.submit(_handle_sfc_file, file))
|
||||
elif file.endswith(".bmbp"):
|
||||
futures.append(pool.submit(_handle_diff_file, file))
|
||||
|
||||
if zip_multidata and os.path.exists(os.path.join(output_path, multidataname)):
|
||||
pack_file(multidataname)
|
||||
|
|
|
@ -40,6 +40,7 @@ def mystery_argparse():
|
|||
parser.add_argument('--meta', default=None)
|
||||
parser.add_argument('--log_output_path', help='Path to store output log')
|
||||
parser.add_argument('--loglevel', default='info', help='Sets log level')
|
||||
parser.add_argument('--create_diff', action="store_true")
|
||||
parser.add_argument('--yaml_output', default=0, type=lambda value: min(max(int(value), 0), 255),
|
||||
help='Output rolled mystery results to yaml up to specified number (made for async multiworld)')
|
||||
|
||||
|
@ -93,6 +94,7 @@ def main(args=None, callback = ERmain):
|
|||
erargs.seed = seed
|
||||
erargs.name = {x: "" for x in range(1, args.multi + 1)} # only so it can be overwrittin in mystery
|
||||
erargs.create_spoiler = args.create_spoiler
|
||||
erargs.create_diff = args.create_diff
|
||||
erargs.race = args.race
|
||||
erargs.skip_playthrough = args.skip_playthrough
|
||||
erargs.outputname = seedname
|
||||
|
|
|
@ -71,7 +71,7 @@ multi_mystery_options:
|
|||
#1 -> Create a zip
|
||||
#2 -> Create a zip and delete the ROMs that will be in it, except the hosts (requires player_name to be set correctly)
|
||||
zip_roms: 0
|
||||
# zip diff files, 2-> delete the non-zipped one. Note that diffs are only created if they are placed in a zip.
|
||||
# zip diff files, 2 -> delete the non-zipped one. -1 -> create them without zipping
|
||||
zip_diffs: 2
|
||||
#include the spoiler log in the zip, 2 -> delete the non-zipped one
|
||||
zip_spoiler: 0
|
||||
|
|
Loading…
Reference in New Issue