fix incompatible check, more verbose when incompatible detected

This commit is contained in:
Mylloon 2023-04-06 12:51:22 +02:00
parent 8442ed67de
commit e6c4585d8e
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

23
main.py
View file

@ -5,9 +5,9 @@ from threading import Thread
from cheat import Cheat, sleep # type: ignore from cheat import Cheat, sleep # type: ignore
def do_on_exit(): def do_on_exit(running: list) -> None:
"""Called when the program end""" """Called when the program end"""
for fn in [c.cheats_list[i] for i in c_id]: for fn in running:
try: try:
unloader = getattr(c, f"{fn}_unload") unloader = getattr(c, f"{fn}_unload")
except: except:
@ -62,15 +62,18 @@ if __name__ == "__main__":
# Instanciate and run threads, removing incompatibilites # Instanciate and run threads, removing incompatibilites
running = [] running = []
for fn in [c.cheats_list[i] for i in c_id for fn in [c.cheats_list[i] for i in c_id]:
if any(map(lambda v: v in c.incompatible[fn], running))]: incompatible = set(c.incompatible[fn]).intersection(running)
print(f"Running {fn}...") if not len(incompatible):
t = Thread(target=getattr(c, fn)) running.append(fn)
running.append(fn) print(f"Running {fn}...")
t.daemon = True t = Thread(target=getattr(c, fn))
t.start() 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 # Don't close the main thread as cheats are daemons
while True: while True: