From d4f296835c6a5dc8273af4f245de5006e97df24c Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 11 Jul 2020 00:52:49 +0200 Subject: [PATCH] Check Enemizer version --- Rom.py | 31 +++++++++++++++++++++++++++++++ WebHost/autolauncher.py | 2 +- WebHost/templates/landing.html | 9 ++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Rom.py b/Rom.py index a5060ef4..299058bc 100644 --- a/Rom.py +++ b/Rom.py @@ -145,7 +145,38 @@ def read_rom(stream) -> bytearray: buffer = buffer[0x200:] return buffer + +def check_enemizer(enemizercli): + if getattr(check_enemizer, "done", None): + return + if not os.path.exists(enemizercli) and not os.path.exists(enemizercli + ".exe"): + raise Exception(f"Enemizer not found at {enemizercli}, please install a multiworld fork of Enemizer. " + f"Such as https://github.com/Ijwu/Enemizer/releases") + if sys.platform == "win32": + try: + import pythoncom + from win32com.client import Dispatch + except ImportError: + logging.info("Could not check Enemizer Version info as pywin32 bindings are missing.") + else: + # version info is saved on the lib, for some reason + library = os.path.join(os.path.dirname(enemizercli), "EnemizerLibrary.dll") + pythoncom.CoInitialize() + ver_parser = Dispatch('Scripting.FileSystemObject') + info = ver_parser.GetFileVersion(library) + + if info == 'No Version Information Available': + info = None + version = tuple(int(part) for part in info.split(".")) + if version < (6, 1, 0, 179): + raise Exception( + f"Enemizer found at {enemizercli} is outdated ({info}), please install a multiworld fork of Enemizer. " + f"Such as https://github.com/Ijwu/Enemizer/releases") + check_enemizer.done = True + + def patch_enemizer(world, player: int, rom: LocalRom, enemizercli, random_sprite_on_hit): + check_enemizer(enemizercli) randopatch_path = os.path.abspath(output_path(f'enemizer_randopatch_{player}.sfc')) options_path = os.path.abspath(output_path(f'enemizer_options_{player}.json')) enemizer_output_path = os.path.abspath(output_path(f'enemizer_output_{player}.sfc')) diff --git a/WebHost/autolauncher.py b/WebHost/autolauncher.py index 76bf5486..ffbad87f 100644 --- a/WebHost/autolauncher.py +++ b/WebHost/autolauncher.py @@ -58,7 +58,7 @@ else: # unix def launch_room(room: Room, config: dict): # requires db_session! - if room.last_activity >= datetime.utcnow() - timedelta(minutes=room.timeout): + if room.last_activity >= datetime.utcnow() - timedelta(seconds=room.timeout): multiworld = multiworlds.get(room.id, None) if not multiworld: multiworld = MultiworldInstance(room, config) diff --git a/WebHost/templates/landing.html b/WebHost/templates/landing.html index 4efd0b6b..63381e83 100644 --- a/WebHost/templates/landing.html +++ b/WebHost/templates/landing.html @@ -17,7 +17,8 @@
-
+ +
@@ -40,9 +41,15 @@

Currently you still require a locally installed client to play, that handles connecting to the server and patching a vanilla game to the randomized one. Get started on the Wiki.

+
+
+ + +