remove patches menu in favor of patch switches; closes #623

This commit is contained in:
Martin Michelsen
2025-03-14 22:58:15 -07:00
parent 2cff04943f
commit f0c492abea
4 changed files with 4 additions and 58 deletions
+1 -20
View File
@@ -358,30 +358,11 @@ FunctionCodeIndex::FunctionCodeIndex(const string& directory) {
}
}
shared_ptr<const Menu> FunctionCodeIndex::patch_menu(uint32_t specific_version) const {
auto suffix = phosg::string_printf("-%08" PRIX32, specific_version);
auto ret = make_shared<Menu>(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<const Menu> FunctionCodeIndex::patch_switches_menu(
uint32_t specific_version, const std::unordered_set<std::string>& auto_patches_enabled) const {
auto suffix = phosg::string_printf("-%08" PRIX32, specific_version);
auto ret = make_shared<Menu>(MenuID::PATCH_SWITCHES, "Patch switches");
auto ret = make_shared<Menu>(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;
-1
View File
@@ -71,7 +71,6 @@ struct FunctionCodeIndex {
// Key here is e.g. "PATCHNAME-SPECIFICVERSION", with the latter in hex
std::map<std::string, std::shared_ptr<CompiledFunctionCode>> name_and_specific_version_to_patch_function;
std::shared_ptr<const Menu> patch_menu(uint32_t specific_version) const;
std::shared_ptr<const Menu> patch_switches_menu(uint32_t specific_version, const std::unordered_set<std::string>& auto_patches_enabled) const;
bool patch_menu_empty(uint32_t specific_version) const;
+2 -4
View File
@@ -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;
+1 -33
View File
@@ -373,10 +373,8 @@ static void send_main_menu(shared_ptr<Client> 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<Client> 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<Client> 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<uint64_t>(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);