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

15
main.py
View file

@ -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))]:
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))
running.append(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: