diff --git a/blcrack/cracker/server.cpp b/blcrack/cracker/server.cpp index 387f40e02..666f875d9 100644 --- a/blcrack/cracker/server.cpp +++ b/blcrack/cracker/server.cpp @@ -1065,6 +1065,17 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/init_without_pause", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance(false); + } catch (std::exception& e) { + SPDLOG_ERROR("Init failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + std::thread([this] { SPDLOG_INFO("Start server on port 23897"); while(true) { diff --git a/blcrack/http/cracker.http b/blcrack/http/cracker.http index f3360158a..5b8443d8c 100644 --- a/blcrack/http/cracker.http +++ b/blcrack/http/cracker.http @@ -227,5 +227,8 @@ POST http://{{Host}}:{{Port}}/is_alive ### POST http://{{Host}}:{{Port}}/init +### +POST http://{{Host}}:{{Port}}/init_without_pause + ### GET http://{{Host}}:{{Port}}/get_config \ No newline at end of file diff --git a/config/template.json b/config/template.json index 3f3000b82..1c442a129 100644 --- a/config/template.json +++ b/config/template.json @@ -204,7 +204,8 @@ "RequestTimeLimit": 10, "UpdateServer": null, "GameLibDir": null, - "HookedLuaFunctionTrace": false + "HookedLuaFunctionTrace": false, + "InitWithoutPause": false }, "Misc": { "GlobalSpeedup": 1.0, diff --git a/module/config/argument/args.json b/module/config/argument/args.json index a1743f0dc..51f4c4797 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -813,6 +813,10 @@ "HookedLuaFunctionTrace": { "type": "checkbox", "value": false + }, + "InitWithoutPause": { + "type": "checkbox", + "value": false } }, "Misc": { diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 72a9431f4..27d78ed26 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -839,6 +839,7 @@ HookGeneral: value: "" type: textarea HookedLuaFunctionTrace: false + InitWithoutPause: false ShipProperty: Method: value: disable diff --git a/module/config/config_generated.py b/module/config/config_generated.py index a78d2752b..ac16a32d8 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -495,6 +495,7 @@ class GeneratedConfig: HookGeneral_UpdateServer = None HookGeneral_GameLibDir = None HookGeneral_HookedLuaFunctionTrace = False + HookGeneral_InitWithoutPause = False # Group `ShipProperty` ShipProperty_Method = 'disable' # disable, gg_factor, final_properties diff --git a/module/config/full_config_generated.py b/module/config/full_config_generated.py index 227cc23e6..cdc67d17c 100644 --- a/module/config/full_config_generated.py +++ b/module/config/full_config_generated.py @@ -140,6 +140,7 @@ class FullGeneratedConfig: Hook_HookGeneral_UpdateServer = None Hook_HookGeneral_GameLibDir = None Hook_HookGeneral_HookedLuaFunctionTrace = None + Hook_HookGeneral_InitWithoutPause = None Hook_Misc_GlobalSpeedup = None Hook_Misc_BetterGlobalSpeedup = None Hook_Misc_ChapterMove = None diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index f017c18a1..c64b48a46 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -2939,6 +2939,10 @@ "HookedLuaFunctionTrace": { "name": "HookGeneral.HookedLuaFunctionTrace.name", "help": "HookGeneral.HookedLuaFunctionTrace.help" + }, + "InitWithoutPause": { + "name": "HookGeneral.InitWithoutPause.name", + "help": "HookGeneral.InitWithoutPause.help" } }, "ShipProperty": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index a7fdfd973..97467a561 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -2939,6 +2939,10 @@ "HookedLuaFunctionTrace": { "name": "HookGeneral.HookedLuaFunctionTrace.name", "help": "HookGeneral.HookedLuaFunctionTrace.help" + }, + "InitWithoutPause": { + "name": "HookGeneral.InitWithoutPause.name", + "help": "HookGeneral.InitWithoutPause.help" } }, "ShipProperty": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 614f3b3ea..3ddfadb5c 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -2939,6 +2939,10 @@ "HookedLuaFunctionTrace": { "name": "Lua函数追踪", "help": "仅供调试使用,平时使用不要开" + }, + "InitWithoutPause": { + "name": "Cracker非暂停初始化", + "help": "正常使用不需要开启" } }, "ShipProperty": { diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index f9ad5c828..338cce0d7 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -2939,6 +2939,10 @@ "HookedLuaFunctionTrace": { "name": "HookGeneral.HookedLuaFunctionTrace.name", "help": "HookGeneral.HookedLuaFunctionTrace.help" + }, + "InitWithoutPause": { + "name": "HookGeneral.InitWithoutPause.name", + "help": "HookGeneral.InitWithoutPause.help" } }, "ShipProperty": { diff --git a/module/luahook/api.py b/module/luahook/api.py index 206297ded..ccc6bf3ea 100644 --- a/module/luahook/api.py +++ b/module/luahook/api.py @@ -367,3 +367,9 @@ class CrackApi: def disable_skip_story(self): self.post("disable_skip_story") + + def init(self): + self.post("init") + + def init_without_pause(self): + self.post("init_without_pause") diff --git a/module/luahook/crack.py b/module/luahook/crack.py index 77a614eab..683d12263 100644 --- a/module/luahook/crack.py +++ b/module/luahook/crack.py @@ -81,6 +81,9 @@ def do_crack_op_on_func( return wrapper +g_cracker_has_inited = False + + def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp.Op], List[Type[CrackOp.Op]]]): if not config.full_config.Hook_HookGeneral_Enable: return @@ -100,6 +103,16 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. base_url = f"http://127.0.0.1:{device.adb.forward_port(REMOTE_PORT)}" timeout = full_config.Hook_HookGeneral_RequestTimeLimit api = CrackApi(base_url, timeout=timeout) + + global g_cracker_has_inited + if not g_cracker_has_inited: + without_pause = full_config.Hook_HookGeneral_InitWithoutPause + if without_pause: + api.init_without_pause() + else: + api.init() + g_cracker_has_inited = True + for op in l: if op == CrackOp.DisableAll: api.disable_all()