#include "server.hpp" #include #include #include #include #include #include "cracker.hpp" #define CRACK_OK() \ res.body = "Crack OK!"; \ res.status = 200 CrackerServer::CrackerServer() { Post("/disable_all", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().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(); } catch (std::exception& e) { SPDLOG_ERROR("Enable hooked lua function trace failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_hooked_lua_function_trace", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_hooked_lua_function_trace(); } catch (std::exception& e) { SPDLOG_ERROR("Disable hooked lua function trace failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_global_ship_properties_crack", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_global_ship_properties_crack(); } catch (std::exception& e) { SPDLOG_ERROR("Enable global ship properties crack failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_global_ship_properties_crack", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_global_ship_properties_crack(); } catch (std::exception& e) { SPDLOG_ERROR("Disable global ship properties crack failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_global_ship_properties", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::ShipProperties properties = { .armor = j["armor"].asInt(), .speed = j["speed"].asInt(), .antiaircraft = j["antiaircraft"].asInt(), .oxy_recovery_bench = j["oxy_recovery_bench"].asInt(), .torpedo = j["torpedo"].asInt(), .hit = j["hit"].asInt(), .sonarRange = j["sonarRange"].asInt(), .attack_duration = j["attack_duration"].asInt(), .raid_distance = j["raid_distance"].asInt(), .oxy_recovery_surface = j["oxy_recovery_surface"].asInt(), .oxy_recovery = j["oxy_recovery"].asInt(), .dodge = j["dodge"].asInt(), .luck = j["luck"].asInt(), .reload = j["reload"].asInt(), .oxy_cost = j["oxy_cost"].asInt(), .durability = j["durability"].asInt(), .air = j["air"].asInt(), .oxy_max = j["oxy_max"].asInt(), .cannon = j["cannon"].asInt(), .antisub = j["antisub"].asInt(), }; Cracker::Instance().update_global_ship_properties(properties); } catch (std::exception& e) { SPDLOG_ERROR("Update global ship properties failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_fast_stage_move", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().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 { Cracker::Instance().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(); } catch (std::exception& e) { SPDLOG_ERROR("Enable remove hard mode ship properties limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_remove_hard_mode_ship_properties_limit", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_remove_hard_mode_ship_properties_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Disable remove hard mode ship properties limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_remove_hard_mode_ship_type_limit", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_remove_hard_mode_ship_type_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Enable remove hard mode ship type limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_remove_hard_mode_ship_type_limit", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_remove_hard_mode_ship_type_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Disable remove hard mode ship type limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_remove_hard_mode_limit", [](const httplib::Request& req, httplib::Response& res) { try { auto& cracker = Cracker::Instance(); cracker.enable_remove_hard_mode_ship_type_limit(); cracker.enable_remove_hard_mode_ship_properties_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Enable remove hard mode limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_remove_hard_mode_limit", [](const httplib::Request& req, httplib::Response& res) { try { auto& cracker = Cracker::Instance(); cracker.disable_remove_hard_mode_ship_type_limit(); cracker.disable_remove_hard_mode_ship_properties_limit(); } catch (std::exception& e) { SPDLOG_ERROR("Disable remove hard mode limit failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_no_bb_animation", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_no_bb_animation(); } catch (std::exception& e) { SPDLOG_ERROR("Enable no bb animation failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_no_bb_animation", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_no_bb_animation(); } catch (std::exception& e) { SPDLOG_ERROR("Disable no bb animation failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/print_table_field", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); std::vector path; for (auto& key : j["path"]) { path.push_back(key.asString()); } Cracker::Instance().print_table_field(path); } catch (std::exception& e) { SPDLOG_ERROR("Print table field failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Post("/print_value", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); std::vector path; for (auto& key : j["path"]) { path.push_back(key.asString()); } Cracker::Instance().print_value(path); } catch (std::exception& e) { SPDLOG_ERROR("Print value failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Post("/enable_fake_player", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_fake_player(); } catch (std::exception& e) { SPDLOG_ERROR("Enable fake player failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_fake_player", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_fake_player(); } catch (std::exception& e) { SPDLOG_ERROR("Disable fake player failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_fake_player_info", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::FakePlayerInfo info = { .name = j["name"].asString(), .id = j["id"].asString(), .level = j["level"].asString(), }; Cracker::Instance().update_fake_player_info(info); } catch (std::exception& e) { SPDLOG_ERROR("Update fake player info failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_no_emotion_warning", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_no_emotion_warning(); } catch (std::exception& e) { SPDLOG_ERROR("Enable no emotion warning failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_no_emotion_warning", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_no_emotion_warning(); } catch (std::exception& e) { SPDLOG_ERROR("Disable no emotion warning failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_opsi_fast_move", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_opsi_fast_move(); } catch (std::exception& e) { SPDLOG_ERROR("Enable opsi fast move failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_opsi_fast_move", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_opsi_fast_move(); } catch (std::exception& e) { SPDLOG_ERROR("Disable opsi fast move failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/is_alive", [](const httplib::Request& req, httplib::Response& res) { CRACK_OK(); }); Get("/get_coin", [](const httplib::Request& req, httplib::Response& res) { try { auto coin = Cracker::Instance().get_coin(); res.body = std::to_string(coin); } catch (std::exception& e) { SPDLOG_ERROR("Get coin failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_oil", [](const httplib::Request& req, httplib::Response& res) { try { auto oil = Cracker::Instance().get_oil(); res.body = std::to_string(oil); } catch (std::exception& e) { SPDLOG_ERROR("Get oil failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_gems", [](const httplib::Request& req, httplib::Response& res) { try { auto gems = Cracker::Instance().get_gems(); res.body = std::to_string(gems); } catch (std::exception& e) { SPDLOG_ERROR("Get gems failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_level", [](const httplib::Request& req, httplib::Response& res) { try { auto level = Cracker::Instance().get_level(); res.body = std::to_string(level); } catch (std::exception& e) { SPDLOG_ERROR("Get level failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_exp", [](const httplib::Request& req, httplib::Response& res) { try { auto exp = Cracker::Instance().get_exp(); res.body = std::to_string(exp); } catch (std::exception& e) { SPDLOG_ERROR("Get exp failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_merit", [](const httplib::Request& req, httplib::Response& res) { try { auto merit = Cracker::Instance().get_merit(); res.body = std::to_string(merit); } catch (std::exception& e) { SPDLOG_ERROR("Get merit failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_guild_coin", [](const httplib::Request& req, httplib::Response& res) { try { auto guild_coin = Cracker::Instance().get_guild_coin(); res.body = std::to_string(guild_coin); } catch (std::exception& e) { SPDLOG_ERROR("Get guild coin failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_design_prt", [](const httplib::Request& req, httplib::Response& res) { try { auto design_prt = Cracker::Instance().get_design_prt(); res.body = std::to_string(design_prt); } catch (std::exception& e) { SPDLOG_ERROR("Get design prt failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_core_data", [](const httplib::Request& req, httplib::Response& res) { try { auto core_data = Cracker::Instance().get_core_data(); res.body = std::to_string(core_data); } catch (std::exception& e) { SPDLOG_ERROR("Get core data failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_medal", [](const httplib::Request& req, httplib::Response& res) { try { auto medal = Cracker::Instance().get_medal(); res.body = std::to_string(medal); } catch (std::exception& e) { SPDLOG_ERROR("Get medal failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_pt", [](const httplib::Request& req, httplib::Response& res) { try { auto pt = Cracker::Instance().get_pt(); res.body = std::to_string(pt); } catch (std::exception& e) { SPDLOG_ERROR("Get pt failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_specialized_core", [](const httplib::Request& req, httplib::Response& res) { try { auto specialized_core = Cracker::Instance().get_specialized_core(); res.body = std::to_string(specialized_core); } catch (std::exception& e) { SPDLOG_ERROR("Get specialized core failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_curr_action_point", [](const httplib::Request& req, httplib::Response& res) { try { auto curr_action_point = Cracker::Instance().get_curr_action_point(); res.body = std::to_string(curr_action_point); } catch (std::exception& e) { SPDLOG_ERROR("Get curr action point failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/scan_dock", [](const httplib::Request& req, httplib::Response& res) { try { auto dock = Cracker::Instance().scan_dock(); Json::Value j; for (auto& ship : dock) { Json::Value ship_info_j; ship_info_j["config_id"] = ship.second.config_id; ship_info_j["emotion"] = ship.second.emotion; ship_info_j["rarity"] = ship.second.rarity; ship_info_j["level"] = ship.second.level; ship_info_j["exp"] = ship.second.exp; ship_info_j["curr_star"] = ship.second.curr_star; j[std::to_string(ship.first)] = ship_info_j; } Json::FastWriter writer; res.body = writer.write(j); } catch (std::exception& e) { SPDLOG_ERROR("Scan dock failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/scan_storage", [](const httplib::Request& req, httplib::Response& res) { try { auto storage = Cracker::Instance().scan_storage(); Json::Value j; for (auto& item : storage) { j[std::to_string(item.first)] = item.second; } Json::FastWriter writer; res.body = writer.write(j); } catch (std::exception& e) { SPDLOG_ERROR("Scan storage failed: {}", e.what()); res.status = 500; return; } res.status = 200; }); Get("/get_ship_info", [](const httplib::Request& req, httplib::Response& res) { try { auto id = req.get_param_value("id"); if (id.empty()) { res.status = 400; return; } auto ship_info = Cracker::Instance().get_ship_info(std::stoi(id)); if (ship_info.has_value()) { Cracker::ShipInfo& info = ship_info.value(); Json::Value j; j["config_id"] = info.config_id; j["emotion"] = info.emotion; j["rarity"] = info.rarity; j["level"] = info.level; j["exp"] = info.exp; j["curr_star"] = info.curr_star; Json::FastWriter writer; res.body = writer.write(j); res.status = 200; } else { res.status = 400; return; } } catch (std::exception& e) { SPDLOG_ERROR("Get ship info failed: {}", e.what()); res.status = 500; return; } }); Get("/get_storage_item_count", [](const httplib::Request& req, httplib::Response& res) { try { auto item_id = req.get_param_value("item_id"); if (item_id.empty()) { res.status = 400; return; } auto count = Cracker::Instance().get_storage_item_count(std::stoi(item_id)); if (count.has_value()) { res.body = std::to_string(count.value()); res.status = 200; } else { res.status = 400; return; } } catch (std::exception& e) { SPDLOG_ERROR("Get storage item count failed: {}", e.what()); res.status = 500; return; } }); Post("/enable_gg_factor", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_gg_factor(); } catch (std::exception& e) { SPDLOG_ERROR("Enable gg factor failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_gg_factor", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_gg_factor(); } catch (std::exception& e) { SPDLOG_ERROR("Disable gg factor failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_gg_factor", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::Instance().update_gg_factor(j["factor"].asDouble()); } catch (std::exception& e) { SPDLOG_ERROR("Update gg factor failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_global_speedup", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_global_speedup(); } catch (std::exception& e) { SPDLOG_ERROR("Enable global speedup failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_global_speedup_rate", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::Instance().update_global_speedup_rate(j["rate"].asFloat()); } catch (std::exception& e) { SPDLOG_ERROR("Enable global speedup failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_global_speedup", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::Instance().disable_global_speedup(); } catch (std::exception& e) { SPDLOG_ERROR("Disable global speedup failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_exercise_god_mode", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_exercise_god_mode(); } catch (std::exception& e) { SPDLOG_ERROR("Enable exercise god mode failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_exercise_god_mode", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_exercise_god_mode(); } catch (std::exception& e) { SPDLOG_ERROR("Disable exercise god mode failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_exercise_more_power", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_exercise_more_power(); } catch (std::exception& e) { SPDLOG_ERROR("Enable exercise more power failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/update_exercise_more_power_rate", [](const httplib::Request& req, httplib::Response& res) { try { Json::Reader reader; Json::Value j; reader.parse(req.body, j); Cracker::Instance().update_exercise_more_power_rate(j["rate"].asDouble() / 100); } catch (std::exception& e) { SPDLOG_ERROR("Update exercise more power rate failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_exercise_more_power", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_exercise_more_power(); } catch (std::exception& e) { SPDLOG_ERROR("Disable exercise more power failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_fast_wave", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_fast_wave(); } catch (std::exception& e) { SPDLOG_ERROR("Enable fast wave failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_fast_wave", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_fast_wave(); } catch (std::exception& e) { SPDLOG_ERROR("Disable fast wave failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_monster_kill_self", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_monster_kill_self(); } catch (std::exception& e) { SPDLOG_ERROR("Enable monster kill self failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_monster_kill_self", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_monster_kill_self(); } catch (std::exception& e) { SPDLOG_ERROR("Disable monster kill self failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_skip_battle_celebrate", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().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 { Cracker::Instance().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 { Cracker::Instance().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; Json::Value j; reader.parse(req.body, j); Cracker::Instance().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 { Cracker::Instance().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(); } catch (std::exception& e) { SPDLOG_ERROR("Enable no damage failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_no_damage", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_no_damage(); } catch (std::exception& e) { SPDLOG_ERROR("Disable no damage failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_opsi_force_auto", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_opsi_force_auto(); } catch (std::exception& e) { SPDLOG_ERROR("Enable opsi force auto failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_opsi_force_auto", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_opsi_force_auto(); } catch (std::exception& e) { SPDLOG_ERROR("Disable opsi force auto failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_opsi_no_map_fog", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_opsi_no_map_fog(); } catch (std::exception& e) { SPDLOG_ERROR("Enable opsi no map fog failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_opsi_no_map_fog", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_opsi_no_map_fog(); } catch (std::exception& e) { SPDLOG_ERROR("Disable opsi no map fog failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_skip_ship_gain_show", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_skip_ship_gain_show(); } catch (std::exception& e) { SPDLOG_ERROR("Enable skip ship gain show failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_skip_ship_gain_show", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_skip_ship_gain_show(); } catch (std::exception& e) { SPDLOG_ERROR("Disable skip ship gain show failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_chapter_force_enable_auto_fight", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_chapter_force_enable_auto_fight(); } catch (std::exception& e) { SPDLOG_ERROR("Enable chapter force enable auto fight failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_chapter_force_enable_auto_fight", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_chapter_force_enable_auto_fight(); } catch (std::exception& e) { SPDLOG_ERROR("Disable chapter force enable auto fight failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_chapter_skip_precombat", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_chapter_skip_precombat(); } catch (std::exception& e) { SPDLOG_ERROR("Enable chapter skip precombat failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_chapter_skip_precombat", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_chapter_skip_precombat(); } catch (std::exception& e) { SPDLOG_ERROR("Disable chapter skip precombat failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/enable_chapter_auto_next_battle", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().enable_chapter_auto_next_battle(); } catch (std::exception& e) { SPDLOG_ERROR("Enable chapter auto next battle failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/disable_chapter_auto_next_battle", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance().disable_chapter_auto_next_battle(); } catch (std::exception& e) { SPDLOG_ERROR("Disable chapter auto next battle failed: {}", e.what()); res.status = 500; return; } CRACK_OK(); }); Post("/init", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance(); } 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) { try { listen("0.0.0.0", 23897); } catch(std::exception& e) { SPDLOG_ERROR(e.what()); } catch(...) { SPDLOG_ERROR("Unknown exception"); } SPDLOG_INFO("Restart server"); } }).detach(); } void CrackerServer::Start() { new CrackerServer; }