pcacc 2 долоо хоног өмнө
parent
commit
7c0770cde2
2 өөрчлөгдсөн 20 нэмэгдсэн , 7 устгасан
  1. 10 2
      app_dongri.py
  2. 10 5
      dongri_task.py

+ 10 - 2
app_dongri.py

@@ -40,7 +40,11 @@ class GlobalState:
     frp_process: Optional[subprocess.Popen[Any]] = None 
 
 def startup_frpc():
-    GlobalState.frp_process = subprocess.Popen(["tool/frpc.exe", "-c", "tool/frpc-desktop.toml"])
+    try:
+        GlobalState.frp_process = subprocess.Popen(["tool/frpc.exe", "-c", "tool/frpc-desktop.toml"])
+    except Exception as e:
+        print(f"启动frpc失败: {e}")
+        handle_restart_game()
 
 def terminate_frpc():
     if GlobalState.frp_process is not None:
@@ -260,7 +264,11 @@ def handle_read_cfg():
 def restart_game(type=0):
     GlobalState.isGameBegin = False
     while True:
-        task_close_game()
+        try:
+            task_close_game()
+        except Exception as e:
+            print(f"关闭游戏失败: {e}")
+            handle_restart_game()
         if True == task_start_game(type):
             break
         else:

+ 10 - 5
dongri_task.py

@@ -256,11 +256,16 @@ def task_save_compress_pic():
         f.write(compressed_data)
 
 def task_close_game():
-    subprocess.call(f"taskkill /f /im MuMuNxDevice.exe")
-    subprocess.call(f"taskkill /f /im MuMuNxMain.exe")
-    subprocess.call(f"taskkill /f /im MuMuVMMHeadless.exe")
-    subprocess.call(f"taskkill /f /im MuMuVMMSVC.exe")
-    myTimeSleep_big()
+    try:
+        subprocess.call(f"taskkill /f /im MuMuNxDevice.exe")
+        subprocess.call(f"taskkill /f /im MuMuNxMain.exe")
+        subprocess.call(f"taskkill /f /im MuMuVMMHeadless.exe")
+        subprocess.call(f"taskkill /f /im MuMuVMMSVC.exe")
+        myTimeSleep_big()
+        return True
+    except Exception as e:
+        print(f"关闭游戏失败: {e}")
+        return False
 
 def task_start_game(type=0):
     isSuccess = True