From 75d5494b6fbbea8fac56ec7d3c059a9c93d7293e Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Tue, 11 Jul 2023 18:19:51 +0800 Subject: [PATCH 1/3] remove console --- mods/dr_game/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mods/dr_game/__init__.py b/mods/dr_game/__init__.py index eac5be3..0a9cbdd 100644 --- a/mods/dr_game/__init__.py +++ b/mods/dr_game/__init__.py @@ -12,7 +12,6 @@ from typing import Optional from Difficult_Rocket import DR_status from Difficult_Rocket.main import Game -from Difficult_Rocket.main import Console from Difficult_Rocket.api.mod import ModInfo from Difficult_Rocket.client import ClientWindow from Difficult_Rocket.api.types import Options, Version -- 2.45.2 From b3385d18408c366bacf67b2adf9b0b9a9722a9bd Mon Sep 17 00:00:00 2001 From: "DESKTOP-UL157US\\13568" <3135351980@qq.com> Date: Tue, 11 Jul 2023 18:34:43 +0800 Subject: [PATCH 2/3] update DR&DR-start.py --- DR-start.py | 41 +++++++++++++++++++++++------------------ DR.py | 3 --- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/DR-start.py b/DR-start.py index f40cd94..13794fb 100644 --- a/DR-start.py +++ b/DR-start.py @@ -3,45 +3,50 @@ # Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com # All rights reserved # ------------------------------- + import os import sys import time +from pathlib import Path + hi = """Difficult Rocket is writen by shenjackyuanjie email: 3695888@qq.com or shyj3695888@163.com QQ: 3695888""" -errors = { - 'TestError': '游戏正在调试中,某处引发了一个 TestError,不是bug造成的原因', - 'AssertionError': '游戏的某处检查未通过,情报告issue', - 'error.unknown': '游戏报错了,现在输出报错信息,请报告issue', - 'error.happen': '游戏出现了一个报错!正在处理' -} - def print_path() -> None: print(f'{__file__=}') print(f'{sys.path=}') print(f'{sys.path[0]=}') print(f'{sys.argv[0]=}') - print(f'{os.getcwd()=}') - print(f'{os.path.abspath(__file__)=}') - print(f'{os.path.realpath(__file__)=}') - print(f'{os.path.split(os.path.split(os.path.realpath(__file__))[0])=}') - # 输出一遍大部分文件位置相关信息 以后可能会加到logs里 + print(f'{Path.cwd()=}') + print(f'{Path(__file__).absolute()=}') def modify_path() -> None: - file_path = os.path.split(os.path.realpath(__file__))[0] - os.chdir(file_path) # 将运行路径切换到文件位置 防止bug - sys.path.append(f'{file_path}/Difficult_Rocket') # 添加local path - sys.path.append(f'{file_path}/libs') # 添加 libs path + os.chdir(Path(__file__)) # 将运行路径切换到文件位置 防止bug + sys.path.append(f'./Difficult_Rocket') # 添加local path + sys.path.append(f'./libs') # 添加 libs path + + +def start(start_time_ns: int) -> None: + from Difficult_Rocket import main + from Difficult_Rocket.runtime import DR_runtime + DR_runtime.start_time_ns = start_time_ns + + try: + main_game = main.Game() + except Exception as exp: + if __name__ == '__main__': - print(hi,f"\n{time.ctime()}") # hi! + print(hi, f"\n{time.ctime()}") # hi! # 记录启动信息 start_time_ns = time.time_ns() - start_time_perf_ns = time.perf_counter_ns() print_path() modify_path() + start(start_time_ns) + + diff --git a/DR.py b/DR.py index b5a9a24..9d41192 100644 --- a/DR.py +++ b/DR.py @@ -62,9 +62,6 @@ def main() -> int: from Difficult_Rocket.runtime import DR_runtime DR_runtime.start_time_ns = start_time_ns - # from pyglet.gl import glClearColor # 调整背景颜色 - # glClearColor(0.5, 0.5, 0.5, 0) - game = main.Game() # 实例化一个游戏 print(time.perf_counter_ns() - start_time_perf_ns, (time.perf_counter_ns() - start_time_perf_ns) / (10 ** 9), 'start') # 输出一下启动用时 -- 2.45.2 From 7792abc243e7106a579be2e80409d7ba6b978974 Mon Sep 17 00:00:00 2001 From: "DESKTOP-UL157US\\13568" <3135351980@qq.com> Date: Tue, 11 Jul 2023 18:54:26 +0800 Subject: [PATCH 3/3] update DR&DR-start.py --- DR-start.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/DR-start.py b/DR-start.py index 13794fb..81954f0 100644 --- a/DR-start.py +++ b/DR-start.py @@ -7,6 +7,8 @@ import os import sys import time +import traceback +import threading from pathlib import Path @@ -31,22 +33,39 @@ def modify_path() -> None: def start(start_time_ns: int) -> None: - from Difficult_Rocket import main + from Difficult_Rocket import crash, DR_status from Difficult_Rocket.runtime import DR_runtime + from Difficult_Rocket.exception import TestError DR_runtime.start_time_ns = start_time_ns - try: + from Difficult_Rocket import main main_game = main.Game() - except Exception as exp: + main_game.start() + if DR_status.crash_report_test: + raise TestError('debug crash test') + except: + trace = traceback.format_exc() + crash.create_crash_report(trace) + crash.write_info_to_cache(sys.stdout) + print(crash.all_thread) + print(crash.all_process) + for a_thread in threading.enumerate(): + print(a_thread) + if a_thread.is_alive() and a_thread != threading.current_thread() and a_thread != threading.main_thread(): + a_thread.join(2) # wait for 2 sec + import pyglet + pyglet.app.exit() # make sure that pyglet has stopped - -if __name__ == '__main__': +def main() -> int: print(hi, f"\n{time.ctime()}") # hi! # 记录启动信息 start_time_ns = time.time_ns() print_path() modify_path() start(start_time_ns) + return 0 +if __name__ == '__main__': + sys.exit(main()) -- 2.45.2