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: