From f0c492abea8b7da65d8d181be7bf46658fd6b239 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 14 Mar 2025 22:58:15 -0700 Subject: [PATCH] remove patches menu in favor of patch switches; closes #623 --- src/FunctionCompiler.cc | 21 +-------------------- src/FunctionCompiler.hh | 1 - src/Menu.hh | 6 ++---- src/ReceiveCommands.cc | 34 +--------------------------------- 4 files changed, 4 insertions(+), 58 deletions(-) diff --git a/src/FunctionCompiler.cc b/src/FunctionCompiler.cc index 08c51f51..81e4f4f0 100644 --- a/src/FunctionCompiler.cc +++ b/src/FunctionCompiler.cc @@ -358,30 +358,11 @@ FunctionCodeIndex::FunctionCodeIndex(const string& directory) { } } -shared_ptr FunctionCodeIndex::patch_menu(uint32_t specific_version) const { - auto suffix = phosg::string_printf("-%08" PRIX32, specific_version); - - auto ret = make_shared(MenuID::PATCHES, "Patches"); - ret->items.emplace_back(PatchesMenuItemID::GO_BACK, "Go back", "Return to the\nmain menu", 0); - for (const auto& it : this->name_and_specific_version_to_patch_function) { - const auto& fn = it.second; - if (fn->hide_from_patches_menu || !phosg::ends_with(it.first, suffix)) { - continue; - } - ret->items.emplace_back( - fn->menu_item_id, - fn->long_name.empty() ? fn->short_name : fn->long_name, - fn->description, - MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE); - } - return ret; -} - shared_ptr FunctionCodeIndex::patch_switches_menu( uint32_t specific_version, const std::unordered_set& auto_patches_enabled) const { auto suffix = phosg::string_printf("-%08" PRIX32, specific_version); - auto ret = make_shared(MenuID::PATCH_SWITCHES, "Patch switches"); + auto ret = make_shared(MenuID::PATCH_SWITCHES, "Patches"); ret->items.emplace_back(PatchesMenuItemID::GO_BACK, "Go back", "Return to the\nmain menu", 0); for (const auto& it : this->name_and_specific_version_to_patch_function) { const auto& fn = it.second; diff --git a/src/FunctionCompiler.hh b/src/FunctionCompiler.hh index 13bb2ffb..cfadfe90 100644 --- a/src/FunctionCompiler.hh +++ b/src/FunctionCompiler.hh @@ -71,7 +71,6 @@ struct FunctionCodeIndex { // Key here is e.g. "PATCHNAME-SPECIFICVERSION", with the latter in hex std::map> name_and_specific_version_to_patch_function; - std::shared_ptr patch_menu(uint32_t specific_version) const; std::shared_ptr patch_switches_menu(uint32_t specific_version, const std::unordered_set& auto_patches_enabled) const; bool patch_menu_empty(uint32_t specific_version) const; diff --git a/src/Menu.hh b/src/Menu.hh index 00be47c6..c1e61bbf 100644 --- a/src/Menu.hh +++ b/src/Menu.hh @@ -26,8 +26,7 @@ constexpr uint32_t QUEST_CATEGORIES_EP1 = 0x01000001; constexpr uint32_t QUEST_CATEGORIES_EP2 = 0x02000002; constexpr uint32_t PROXY_DESTINATIONS = 0x77000077; constexpr uint32_t PROGRAMS = 0x88000088; -constexpr uint32_t PATCHES = 0x99000099; -constexpr uint32_t PATCH_SWITCHES = 0x99010199; +constexpr uint32_t PATCH_SWITCHES = 0x99000099; constexpr uint32_t PROXY_OPTIONS = 0xAA0000AA; constexpr uint32_t TOURNAMENTS = 0xBB0000BB; constexpr uint32_t TOURNAMENTS_FOR_SPEC = 0xBB1111BB; @@ -39,8 +38,7 @@ constexpr uint32_t GO_TO_LOBBY = 0x11222211; constexpr uint32_t INFORMATION = 0x11333311; constexpr uint32_t DOWNLOAD_QUESTS = 0x11444411; constexpr uint32_t PROXY_DESTINATIONS = 0x11555511; -constexpr uint32_t PATCHES = 0x11666611; -constexpr uint32_t PATCH_SWITCHES = 0x11676711; +constexpr uint32_t PATCH_SWITCHES = 0x11666611; constexpr uint32_t PROGRAMS = 0x11777711; constexpr uint32_t DISCONNECT = 0x11888811; constexpr uint32_t CLEAR_LICENSE = 0x11999911; diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index b11520e3..f6e43a67 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -373,10 +373,8 @@ static void send_main_menu(shared_ptr c) { "Download quests", MenuItem::Flag::INVISIBLE_ON_DC_PROTOS | MenuItem::Flag::INVISIBLE_ON_PC_NTE | MenuItem::Flag::INVISIBLE_ON_BB); if (!s->is_replay) { if (!s->function_code_index->patch_menu_empty(c->config.specific_version)) { - main_menu->items.emplace_back(MainMenuItemID::PATCHES, "Patches", + main_menu->items.emplace_back(MainMenuItemID::PATCH_SWITCHES, "Patches", "Change game\nbehaviors", MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE); - main_menu->items.emplace_back(MainMenuItemID::PATCH_SWITCHES, "Patch switches", - "Automatically\napply patches every\ntime you connect", MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE); } if (!s->dol_file_index->empty()) { main_menu->items.emplace_back(MainMenuItemID::PROGRAMS, "Programs", @@ -2361,18 +2359,6 @@ static void on_10(shared_ptr c, uint16_t, uint32_t, string& data) { break; } - case MainMenuItemID::PATCHES: - if (!function_compiler_available()) { - throw runtime_error("function compiler not available"); - } - if (!c->config.check_flag(Client::Flag::HAS_SEND_FUNCTION_CALL)) { - throw runtime_error("client does not support send_function_call"); - } - prepare_client_for_patches(c, [c]() -> void { - send_menu(c, c->require_server_state()->function_code_index->patch_menu(c->config.specific_version)); - }); - break; - case MainMenuItemID::PATCH_SWITCHES: if (!function_compiler_available()) { throw runtime_error("function compiler not available"); @@ -2746,24 +2732,6 @@ static void on_10(shared_ptr c, uint16_t, uint32_t, string& data) { break; } - case MenuID::PATCHES: - if (item_id == PatchesMenuItemID::GO_BACK) { - send_main_menu(c); - - } else { - if (!c->config.check_flag(Client::Flag::HAS_SEND_FUNCTION_CALL)) { - throw runtime_error("client does not support send_function_call"); - } - - auto s = c->require_server_state(); - uint64_t key = (static_cast(item_id) << 32) | c->config.specific_version; - send_function_call( - c, s->function_code_index->menu_item_id_and_specific_version_to_patch_function.at(key)); - c->function_call_response_queue.emplace_back(empty_function_call_response_handler); - send_menu(c, s->function_code_index->patch_menu(c->config.specific_version)); - } - break; - case MenuID::PATCH_SWITCHES: if (item_id == PatchesMenuItemID::GO_BACK) { send_main_menu(c);