From e6c4585d8e55723853031086b5549b4fe85ea6f4 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 6 Apr 2023 12:51:22 +0200 Subject: [PATCH] fix incompatible check, more verbose when incompatible detected --- main.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 1a15212..f63de4d 100644 --- a/main.py +++ b/main.py @@ -5,9 +5,9 @@ from threading import Thread from cheat import Cheat, sleep # type: ignore -def do_on_exit(): +def do_on_exit(running: list) -> None: """Called when the program end""" - for fn in [c.cheats_list[i] for i in c_id]: + for fn in running: try: unloader = getattr(c, f"{fn}_unload") except: @@ -62,15 +62,18 @@ if __name__ == "__main__": # Instanciate and run threads, removing incompatibilites running = [] - for fn in [c.cheats_list[i] for i in c_id - if any(map(lambda v: v in c.incompatible[fn], running))]: - print(f"Running {fn}...") - t = Thread(target=getattr(c, fn)) - running.append(fn) - t.daemon = True - t.start() + for fn in [c.cheats_list[i] for i in c_id]: + incompatible = set(c.incompatible[fn]).intersection(running) + if not len(incompatible): + running.append(fn) + print(f"Running {fn}...") + t = Thread(target=getattr(c, fn)) + t.daemon = True + t.start() + else: + print(f"{fn} is incompatible with: {', '.join(incompatible)}") - register(do_on_exit) + register(do_on_exit, running) # Don't close the main thread as cheats are daemons while True: