From ccb78ec341a46745f909cd8e9704cc59197a465c Mon Sep 17 00:00:00 2001 From: 0O0o0oOoO00 <11174151+0O0o0oOoO00@users.noreply.github.com> Date: Sun, 23 Nov 2025 15:31:17 +0800 Subject: [PATCH] add: operate cracker without pause --- blcrack/cracker/server.cpp | 109 +++++++++++++++++++++++++ blcrack/http/cracker.http | 28 +++++++ config/template.json | 2 +- module/config/argument/args.json | 2 +- module/config/argument/argument.yaml | 2 +- module/config/config_generated.py | 2 +- module/config/full_config_generated.py | 2 +- module/config/i18n/en-US.json | 6 +- module/config/i18n/ja-JP.json | 6 +- module/config/i18n/zh-CN.json | 4 +- module/config/i18n/zh-TW.json | 6 +- module/luahook/api.py | 24 ++++++ module/luahook/crack.py | 41 ++++++++-- 13 files changed, 209 insertions(+), 25 deletions(-) diff --git a/blcrack/cracker/server.cpp b/blcrack/cracker/server.cpp index 69e8e938f..a558c68cb 100644 --- a/blcrack/cracker/server.cpp +++ b/blcrack/cracker/server.cpp @@ -28,6 +28,21 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/disable_all_without_pause", [](const httplib::Request& req, httplib::Response& res) { + try { + auto& ins = Cracker::Instance(false); + ins.better_global_speedup_pause(false); + ins.skip_battle_celebrate_pause(false); + ins.fast_stage_move_pause(false); + ins.disable_all(); + } catch (std::exception& e) { + SPDLOG_ERROR("Disable all failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/enable_hooked_lua_function_trace", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_hooked_lua_function_trace(); @@ -121,6 +136,19 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/enable_fast_stage_move_without_pause", [](const httplib::Request& req, httplib::Response& res) { + try { + auto& ins = Cracker::Instance(false); + ins.fast_stage_move_pause(false); + ins.enable_fast_stage_move(); + } catch (std::exception& e) { + SPDLOG_ERROR("Enable fast stage move failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/disable_fast_stage_move", [](const httplib::Request& req, httplib::Response& res) { try { auto& ins = Cracker::Instance(); @@ -134,6 +162,19 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/disable_fast_stage_move_without_pause", [](const httplib::Request& req, httplib::Response& res) { + try { + auto& ins = Cracker::Instance(false); + ins.fast_stage_move_pause(false); + ins.disable_fast_stage_move(); + } catch (std::exception& e) { + SPDLOG_ERROR("Disable fast stage move failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/enable_remove_hard_mode_ship_properties_limit", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_remove_hard_mode_ship_properties_limit(); @@ -791,6 +832,19 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/enable_skip_battle_celebrate_without_pause", [](const httplib::Request& req, httplib::Response& res) { + try { + auto& ins = Cracker::Instance(false); + ins.skip_battle_celebrate_pause(false); + ins.enable_skip_battle_celebrate(); + } catch (std::exception& e) { + SPDLOG_ERROR("Enable skip battle celebrate failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/disable_skip_battle_celebrate", [](const httplib::Request& req, httplib::Response& res) { try { auto& ins = Cracker::Instance(); @@ -804,6 +858,19 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/disable_skip_battle_celebrate_without_pause", [](const httplib::Request& req, httplib::Response& res) { + try { + auto& ins = Cracker::Instance(false); + ins.skip_battle_celebrate_pause(false); + ins.disable_skip_battle_celebrate(); + } catch (std::exception& e) { + SPDLOG_ERROR("Disable skip battle celebrate failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/enable_better_global_speedup", [](const httplib::Request& req, httplib::Response& res) { try { auto& ins = Cracker::Instance(); @@ -817,6 +884,19 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/enable_better_global_speedup_without_pause", [](const httplib::Request& req, httplib::Response& res) { + try { + auto& ins = Cracker::Instance(false); + ins.better_global_speedup_pause(false); + ins.enable_better_global_speedup(); + } catch (std::exception& e) { + SPDLOG_ERROR("Enable better global speedup failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/update_better_global_speedup_rate", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; @@ -833,6 +913,22 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/update_better_global_speedup_rate_without_pause", [](const httplib::Request& req, httplib::Response& res) { + try { + Json::Reader reader; + Json::Value j; + reader.parse(req.body, j); + auto& ins = Cracker::Instance(false); + ins.better_global_speedup_pause(false); + ins.update_better_global_speedup_rate(j["rate"].asDouble()); + } catch (std::exception& e) { + SPDLOG_ERROR("Update better global speedup rate failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/disable_better_global_speedup", [](const httplib::Request& req, httplib::Response& res) { try { auto& ins = Cracker::Instance(); @@ -846,6 +942,19 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/disable_better_global_speedup_without_pause", [](const httplib::Request& req, httplib::Response& res) { + try { + auto& ins = Cracker::Instance(false); + ins.better_global_speedup_pause(false); + ins.disable_better_global_speedup(); + } catch (std::exception& e) { + SPDLOG_ERROR("Disable better global speedup failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/enable_no_damage", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_no_damage(); diff --git a/blcrack/http/cracker.http b/blcrack/http/cracker.http index 5b8443d8c..149466650 100644 --- a/blcrack/http/cracker.http +++ b/blcrack/http/cracker.http @@ -3,6 +3,9 @@ POST http://{{Host}}:{{Port}}/disable_all +### +POST http://{{Host}}:{{Port}}/disable_all_without_pause + ### POST http://{{Host}}:{{Port}}/enable_hooked_lua_function_trace @@ -44,9 +47,15 @@ POST http://{{Host}}:{{Port}}/update_global_ship_properties ### POST http://{{Host}}:{{Port}}/enable_fast_stage_move +### +POST http://{{Host}}:{{Port}}/enable_fast_stage_move_without_pause + ### POST http://{{Host}}:{{Port}}/disable_fast_stage_move +### +POST http://{{Host}}:{{Port}}/disable_fast_stage_move_without_pause + ### POST http://{{Host}}:{{Port}}/enable_remove_hard_mode_ship_properties_limit @@ -145,12 +154,21 @@ POST http://{{Host}}:{{Port}}/disable_monster_kill_self ### POST http://{{Host}}:{{Port}}/enable_skip_battle_celebrate +### +POST http://{{Host}}:{{Port}}/enable_skip_battle_celebrate_without_pause + ### POST http://{{Host}}:{{Port}}/disable_skip_battle_celebrate +### +POST http://{{Host}}:{{Port}}/disable_skip_battle_celebrate_without_pause + ### POST http://{{Host}}:{{Port}}/enable_better_global_speedup +### +POST http://{{Host}}:{{Port}}/enable_better_global_speedup_without_pause + ### POST http://{{Host}}:{{Port}}/update_better_global_speedup_rate @@ -158,9 +176,19 @@ POST http://{{Host}}:{{Port}}/update_better_global_speedup_rate "rate": 5.0 } +### +POST http://{{Host}}:{{Port}}/update_better_global_speedup_rate_without_pause + +{ + "rate": 5.0 +} + ### POST http://{{Host}}:{{Port}}/disable_better_global_speedup +### +POST http://{{Host}}:{{Port}}/disable_better_global_speedup_without_pause + ### POST http://{{Host}}:{{Port}}/enable_no_damage diff --git a/config/template.json b/config/template.json index 1c442a129..8bedf2efa 100644 --- a/config/template.json +++ b/config/template.json @@ -205,7 +205,7 @@ "UpdateServer": null, "GameLibDir": null, "HookedLuaFunctionTrace": false, - "InitWithoutPause": false + "OperateWithoutPause": false }, "Misc": { "GlobalSpeedup": 1.0, diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 51f4c4797..8e309d1aa 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -814,7 +814,7 @@ "type": "checkbox", "value": false }, - "InitWithoutPause": { + "OperateWithoutPause": { "type": "checkbox", "value": false } diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 27d78ed26..57a84af4b 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -839,7 +839,7 @@ HookGeneral: value: "" type: textarea HookedLuaFunctionTrace: false - InitWithoutPause: false + OperateWithoutPause: false ShipProperty: Method: value: disable diff --git a/module/config/config_generated.py b/module/config/config_generated.py index ac16a32d8..18d3141c1 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -495,7 +495,7 @@ class GeneratedConfig: HookGeneral_UpdateServer = None HookGeneral_GameLibDir = None HookGeneral_HookedLuaFunctionTrace = False - HookGeneral_InitWithoutPause = False + HookGeneral_OperateWithoutPause = 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 cdc67d17c..9b9f5fc8c 100644 --- a/module/config/full_config_generated.py +++ b/module/config/full_config_generated.py @@ -140,7 +140,7 @@ class FullGeneratedConfig: Hook_HookGeneral_UpdateServer = None Hook_HookGeneral_GameLibDir = None Hook_HookGeneral_HookedLuaFunctionTrace = None - Hook_HookGeneral_InitWithoutPause = None + Hook_HookGeneral_OperateWithoutPause = 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 c64b48a46..c97378261 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -2940,9 +2940,9 @@ "name": "HookGeneral.HookedLuaFunctionTrace.name", "help": "HookGeneral.HookedLuaFunctionTrace.help" }, - "InitWithoutPause": { - "name": "HookGeneral.InitWithoutPause.name", - "help": "HookGeneral.InitWithoutPause.help" + "OperateWithoutPause": { + "name": "HookGeneral.OperateWithoutPause.name", + "help": "HookGeneral.OperateWithoutPause.help" } }, "ShipProperty": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 97467a561..9b6ebb543 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -2940,9 +2940,9 @@ "name": "HookGeneral.HookedLuaFunctionTrace.name", "help": "HookGeneral.HookedLuaFunctionTrace.help" }, - "InitWithoutPause": { - "name": "HookGeneral.InitWithoutPause.name", - "help": "HookGeneral.InitWithoutPause.help" + "OperateWithoutPause": { + "name": "HookGeneral.OperateWithoutPause.name", + "help": "HookGeneral.OperateWithoutPause.help" } }, "ShipProperty": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 3ddfadb5c..58794fbf5 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -2940,8 +2940,8 @@ "name": "Lua函数追踪", "help": "仅供调试使用,平时使用不要开" }, - "InitWithoutPause": { - "name": "Cracker非暂停初始化", + "OperateWithoutPause": { + "name": "非暂停操作", "help": "正常使用不需要开启" } }, diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 338cce0d7..73aa057fe 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -2940,9 +2940,9 @@ "name": "HookGeneral.HookedLuaFunctionTrace.name", "help": "HookGeneral.HookedLuaFunctionTrace.help" }, - "InitWithoutPause": { - "name": "HookGeneral.InitWithoutPause.name", - "help": "HookGeneral.InitWithoutPause.help" + "OperateWithoutPause": { + "name": "HookGeneral.OperateWithoutPause.name", + "help": "HookGeneral.OperateWithoutPause.help" } }, "ShipProperty": { diff --git a/module/luahook/api.py b/module/luahook/api.py index 9bc3a0616..0c8ce965f 100644 --- a/module/luahook/api.py +++ b/module/luahook/api.py @@ -188,6 +188,9 @@ class CrackApi: def disable_all(self): self.post('disable_all') + def disable_all_without_pause(self): + self.post('disable_all_without_pause') + def enable_global_ship_properties_crack(self): self.post('enable_global_ship_properties_crack') @@ -200,9 +203,15 @@ class CrackApi: def enable_fast_stage_move(self): self.post("enable_fast_stage_move") + def enable_fast_stage_move_without_pause(self): + self.post("enable_fast_stage_move_without_pause") + def disable_fast_stage_move(self): self.post("disable_fast_stage_move") + def disable_fast_stage_move_without_pause(self): + self.post("disable_fast_stage_move_without_pause") + def enable_remove_hard_mode_ship_properties_limit(self): self.post("enable_remove_hard_mode_ship_properties_limit") @@ -260,12 +269,21 @@ class CrackApi: def enable_better_global_speedup(self): self.post("enable_better_global_speedup") + def enable_better_global_speedup_without_pause(self): + self.post("enable_better_global_speedup_without_pause") + def update_better_global_speedup_rate(self, rate: BetterGlobalSpeedupRate): self.post("update_better_global_speedup_rate", data=rate.json()) + def update_better_global_speedup_rate_without_pause(self, rate: BetterGlobalSpeedupRate): + self.post("update_better_global_speedup_rate_without_pause", data=rate.json()) + def disable_better_global_speedup(self): self.post("disable_better_global_speedup") + def disable_better_global_speedup_without_pause(self): + self.post("disable_better_global_speedup_without_pause") + def is_alive(self): self.post("is_alive") @@ -299,9 +317,15 @@ class CrackApi: def enable_skip_battle_celebrate(self): self.post("enable_skip_battle_celebrate") + def enable_skip_battle_celebrate_without_pause(self): + self.post("enable_skip_battle_celebrate_without_pause") + def disable_skip_battle_celebrate(self): self.post("disable_skip_battle_celebrate") + def disable_skip_battle_celebrate_without_pause(self): + self.post("disable_skip_battle_celebrate_without_pause") + def enable_no_damage(self): self.post("enable_no_damage") diff --git a/module/luahook/crack.py b/module/luahook/crack.py index 683d12263..1231c4055 100644 --- a/module/luahook/crack.py +++ b/module/luahook/crack.py @@ -104,9 +104,10 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. timeout = full_config.Hook_HookGeneral_RequestTimeLimit api = CrackApi(base_url, timeout=timeout) + without_pause = full_config.Hook_HookGeneral_OperateWithoutPause + 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: @@ -115,7 +116,10 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. for op in l: if op == CrackOp.DisableAll: - api.disable_all() + if without_pause: + api.disable_all_without_pause() + else: + api.disable_all() elif op == CrackOp.EnableHookedLuaFunctionTrace: if full_config.Hook_HookGeneral_HookedLuaFunctionTrace: api.enable_hooked_lua_function_trace() @@ -154,9 +158,15 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. elif op == CrackOp.EnableChapterFastMove: if not full_config.Hook_Misc_ChapterMove: continue - api.enable_fast_stage_move() + if without_pause: + api.enable_fast_stage_move_without_pause() + else: + api.enable_fast_stage_move() elif op == CrackOp.DisableChapterFastMove: - api.disable_fast_stage_move() + if without_pause: + api.disable_fast_stage_move_without_pause() + else: + api.disable_fast_stage_move() elif op == CrackOp.EnableRemoveHardModeShipPropertiesLimit: if full_config.Hook_Misc_RemoveHardMapLimit != "remove_ship_properties_limit": continue @@ -225,10 +235,17 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. rate = float(full_config.Hook_Misc_BetterGlobalSpeedup) if rate == 1.0: continue - api.update_better_global_speedup_rate(CrackApi.BetterGlobalSpeedupRate(rate=rate)) - api.enable_better_global_speedup() + if without_pause: + api.update_better_global_speedup_rate_without_pause(CrackApi.BetterGlobalSpeedupRate(rate=rate)) + api.enable_better_global_speedup_without_pause() + else: + api.update_better_global_speedup_rate(CrackApi.BetterGlobalSpeedupRate(rate=rate)) + api.enable_better_global_speedup() elif op == CrackOp.DisableBetterGlobalSpeedup: - api.disable_better_global_speedup() + if without_pause: + api.disable_better_global_speedup_without_pause() + else: + api.disable_better_global_speedup() elif op == CrackOp.EnableExerciseGodMod: if full_config.Hook_Misc_ExerciseGodMod: api.enable_exercise_god_mode() @@ -254,9 +271,15 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. api.disable_monster_kill_self() elif op == CrackOp.EnableSkipBattleCelebrate: if full_config.Hook_Misc_SkipBattleCelebrate: - api.enable_skip_battle_celebrate() + if without_pause: + api.enable_skip_battle_celebrate_without_pause() + else: + api.enable_skip_battle_celebrate() elif op == CrackOp.DisableSkipBattleCelebrate: - api.disable_skip_battle_celebrate() + if without_pause: + api.disable_skip_battle_celebrate_without_pause() + else: + api.disable_skip_battle_celebrate() elif op == CrackOp.EnableNoDamage: if full_config.Hook_Misc_NoDamage: api.enable_no_damage()