hide patches from menu if they should only run in lobby/game

This commit is contained in:
Martin Michelsen
2023-02-17 22:07:09 -08:00
parent ba4a017ffb
commit 1394dd681e
5 changed files with 21 additions and 4 deletions
+7 -2
View File
@@ -118,6 +118,7 @@ shared_ptr<CompiledFunctionCode> compile_function_code(
ret->arch = arch;
ret->name = name;
ret->index = 0;
ret->hide_from_patches_menu = false;
if (arch == CompiledFunctionCode::Architecture::POWERPC) {
auto assembled = PPC32Emulator::assemble(text, {directory});
@@ -133,6 +134,8 @@ shared_ptr<CompiledFunctionCode> compile_function_code(
reloc_indexes.emplace(it.second / 4);
} else if (starts_with(it.first, "newserv_index_")) {
ret->index = stoul(it.first.substr(14), nullptr, 16);
} else if (it.first == "hide_from_patches_menu") {
ret->hide_from_patches_menu = true;
}
}
@@ -206,8 +209,10 @@ vector<MenuItem> FunctionCodeIndex::patch_menu() const {
ret.emplace_back(PatchesMenuItemID::GO_BACK, u"Go back", u"", 0);
for (const auto& it : this->name_to_patch_function) {
const auto& fn = it.second;
ret.emplace_back(fn->menu_item_id, decode_sjis(fn->name), u"",
MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL);
if (!fn->hide_from_patches_menu) {
ret.emplace_back(fn->menu_item_id, decode_sjis(fn->name), u"",
MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL);
}
}
return ret;
}
+1
View File
@@ -33,6 +33,7 @@ struct CompiledFunctionCode {
std::string name;
uint32_t index; // 0 = unused (not registered in index_to_function)
uint32_t menu_item_id;
bool hide_from_patches_menu;
bool is_big_endian() const;
+10 -1
View File
@@ -1,4 +1,13 @@
# This patch gives you the maximum number of each card in Episode 3 USA.
# This patch gives you the maximum number of each card. It only works if used
# in-game, which means it must be used with the $patch command (and not selected
# from the Patches menu).
# This patch is only for PSO Episode 3 USA, which means it requires the
# EnableEpisode3SendFunctionCall option to be enabled in config.json. If that
# option is disabled, the Patches menu won't appear for the client. If this
# patch is run on a different client version, it will do nothing.
hide_from_patches_menu:
entry_ptr:
reloc0:
+2
View File
@@ -12,6 +12,8 @@
# $patch command, since the client will likely crash if the player is not in a
# game or lobby when the patch runs.
hide_from_patches_menu:
entry_ptr:
reloc0:
.offsetof start
+1 -1
View File
@@ -1,4 +1,4 @@
# This gives you a VIP card in PSO Episode 3 USA.
# This patch gives you a VIP card in PSO Episode 3 USA.
# This patch is only for PSO Episode 3 USA, which means it requires the
# EnableEpisode3SendFunctionCall option to be enabled in config.json. If that