add AccurateKillCount patch
This commit is contained in:
@@ -405,18 +405,20 @@ FunctionCodeIndex::FunctionCodeIndex(const string& directory) {
|
||||
}
|
||||
|
||||
shared_ptr<const Menu> FunctionCodeIndex::patch_switches_menu(
|
||||
uint32_t specific_version, const std::unordered_set<std::string>& auto_patches_enabled) const {
|
||||
uint32_t specific_version,
|
||||
const std::unordered_set<std::string>& server_auto_patches_enabled,
|
||||
const std::unordered_set<std::string>& client_auto_patches_enabled) const {
|
||||
auto suffix = std::format("-{:08X}", specific_version);
|
||||
|
||||
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;
|
||||
if (fn->hide_from_patches_menu || !it.first.ends_with(suffix)) {
|
||||
if (fn->hide_from_patches_menu || !it.first.ends_with(suffix) || server_auto_patches_enabled.count(fn->short_name)) {
|
||||
continue;
|
||||
}
|
||||
string name;
|
||||
name.push_back(auto_patches_enabled.count(fn->short_name) ? '*' : '-');
|
||||
name.push_back(client_auto_patches_enabled.count(fn->short_name) ? '*' : '-');
|
||||
name += fn->long_name.empty() ? fn->short_name : fn->long_name;
|
||||
ret->items.emplace_back(fn->menu_item_id, name, fn->description, MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL_RUNS_CODE);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,10 @@ 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_switches_menu(uint32_t specific_version, const std::unordered_set<std::string>& auto_patches_enabled) const;
|
||||
std::shared_ptr<const Menu> patch_switches_menu(
|
||||
uint32_t specific_version,
|
||||
const std::unordered_set<std::string>& server_auto_patches_enabled,
|
||||
const std::unordered_set<std::string>& client_auto_patches_enabled) const;
|
||||
bool patch_menu_empty(uint32_t specific_version) const;
|
||||
|
||||
std::shared_ptr<const CompiledFunctionCode> get_patch(const std::string& name, uint32_t specific_version) const;
|
||||
|
||||
+16
-5
@@ -216,17 +216,21 @@ std::string ItemNameIndex::describe_item(const ItemData& item, uint8_t flags) co
|
||||
}
|
||||
|
||||
} else if (!name_only) { // Not S-rank (extended name bits not set)
|
||||
size_t num_bonuses = 3;
|
||||
|
||||
if (item.data1[10] & 0x80) {
|
||||
ret_tokens.emplace_back(std::format("K:{}", item.get_kill_count()));
|
||||
num_bonuses = 2;
|
||||
}
|
||||
|
||||
parray<int8_t, 5> bonuses(0);
|
||||
for (size_t x = 0; x < 3; x++) {
|
||||
for (size_t x = 0; x < num_bonuses; x++) {
|
||||
uint8_t which = item.data1[6 + 2 * x];
|
||||
uint8_t value = item.data1[7 + 2 * x];
|
||||
if (which == 0) {
|
||||
continue;
|
||||
}
|
||||
if (which & 0x80) {
|
||||
uint16_t kill_count = ((which << 8) & 0x7F00) | (value & 0xFF);
|
||||
ret_tokens.emplace_back(std::format("K:{}", kill_count));
|
||||
} else if (which > 5) {
|
||||
if (which > 5) {
|
||||
ret_tokens.emplace_back(std::format("!PC:{:02X}{:02X}", which, value));
|
||||
} else {
|
||||
bonuses[which - 1] = value;
|
||||
@@ -263,6 +267,10 @@ std::string ItemNameIndex::describe_item(const ItemData& item, uint8_t flags) co
|
||||
ret_tokens.emplace_back(std::format("!MD:{:04X}", modifier));
|
||||
}
|
||||
|
||||
if (item.data1[10] & 0x80) {
|
||||
ret_tokens.emplace_back(std::format("K:{}", item.get_kill_count()));
|
||||
}
|
||||
|
||||
} else if (!name_only) { // Armor/shields
|
||||
if (item.data1[5] > 0) {
|
||||
if (item.data1[5] == 1) {
|
||||
@@ -527,6 +535,9 @@ ItemData ItemNameIndex::parse_item_description_phase(const std::string& descript
|
||||
ret.data1w[4] = phosg::bswap16(0x8000 | (char_indexes[4] & 0x1F) | ((char_indexes[3] & 0x1F) << 5) | ((char_indexes[2] & 0x1F) << 10));
|
||||
ret.data1w[5] = phosg::bswap16(0x8000 | (char_indexes[7] & 0x1F) | ((char_indexes[6] & 0x1F) << 5) | ((char_indexes[5] & 0x1F) << 10));
|
||||
|
||||
} else if (token.starts_with("k:")) {
|
||||
ret.set_kill_count(stoul(token.substr(2), nullptr, 0));
|
||||
|
||||
} else {
|
||||
auto p_tokens = phosg::split(token, '/');
|
||||
if (p_tokens.size() > 5) {
|
||||
|
||||
+15
-6
@@ -232,7 +232,8 @@ static asio::awaitable<void> send_auto_patches_if_needed(shared_ptr<Client> c) {
|
||||
auto s = c->require_server_state();
|
||||
|
||||
if (c->login->account->auto_patches_enabled.empty() &&
|
||||
((c->version() != Version::BB_V4) || s->bb_required_patches.empty())) {
|
||||
((c->version() != Version::BB_V4) || s->bb_required_patches.empty()) &&
|
||||
s->auto_patches.empty()) {
|
||||
c->set_flag(Client::Flag::HAS_AUTO_PATCHES);
|
||||
}
|
||||
|
||||
@@ -240,11 +241,11 @@ static asio::awaitable<void> send_auto_patches_if_needed(shared_ptr<Client> c) {
|
||||
c->set_flag(Client::Flag::HAS_AUTO_PATCHES);
|
||||
co_await prepare_client_for_patches(c);
|
||||
|
||||
vector<shared_ptr<const CompiledFunctionCode>> functions_to_send;
|
||||
unordered_set<shared_ptr<const CompiledFunctionCode>> functions_to_send;
|
||||
if (c->version() == Version::BB_V4) {
|
||||
for (const auto& patch_name : s->bb_required_patches) {
|
||||
try {
|
||||
functions_to_send.emplace_back(s->function_code_index->get_patch(patch_name, c->specific_version));
|
||||
functions_to_send.emplace(s->function_code_index->get_patch(patch_name, c->specific_version));
|
||||
} catch (const out_of_range&) {
|
||||
string message = std::format(
|
||||
"Your client is not compatible with a\nrequired patch on this server.\n\nClient version: {:08X}\nPatch name: {}", c->specific_version, patch_name);
|
||||
@@ -254,9 +255,17 @@ static asio::awaitable<void> send_auto_patches_if_needed(shared_ptr<Client> c) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto& patch_name : s->auto_patches) {
|
||||
try {
|
||||
functions_to_send.emplace(s->function_code_index->get_patch(patch_name, c->specific_version));
|
||||
} catch (const out_of_range&) {
|
||||
c->log.warning_f("Server has auto patch {} enabled, but it is not available for specific_version {:08X}",
|
||||
patch_name, c->specific_version);
|
||||
}
|
||||
}
|
||||
for (const auto& patch_name : c->login->account->auto_patches_enabled) {
|
||||
try {
|
||||
functions_to_send.emplace_back(s->function_code_index->get_patch(patch_name, c->specific_version));
|
||||
functions_to_send.emplace(s->function_code_index->get_patch(patch_name, c->specific_version));
|
||||
} catch (const out_of_range&) {
|
||||
c->log.warning_f("Client has auto patch {} enabled, but it is not available for specific_version {:08X}",
|
||||
patch_name, c->specific_version);
|
||||
@@ -2528,7 +2537,7 @@ static asio::awaitable<void> on_10_main_menu(shared_ptr<Client> c, uint32_t item
|
||||
// don't send them from this mennu, because we need to know the
|
||||
// client's specific_version before sending the menu.
|
||||
co_await prepare_client_for_patches(c);
|
||||
send_menu(c, c->require_server_state()->function_code_index->patch_switches_menu(c->specific_version, c->login->account->auto_patches_enabled));
|
||||
send_menu(c, c->require_server_state()->function_code_index->patch_switches_menu(c->specific_version, s->auto_patches, c->login->account->auto_patches_enabled));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2863,7 +2872,7 @@ static asio::awaitable<void> on_10_patch_switches(shared_ptr<Client> c, uint32_t
|
||||
c->login->account->auto_patches_enabled.erase(fn->short_name);
|
||||
}
|
||||
c->login->account->save();
|
||||
send_menu(c, s->function_code_index->patch_switches_menu(c->specific_version, c->login->account->auto_patches_enabled));
|
||||
send_menu(c, s->function_code_index->patch_switches_menu(c->specific_version, s->auto_patches, c->login->account->auto_patches_enabled));
|
||||
}
|
||||
co_return;
|
||||
}
|
||||
|
||||
+2
-1
@@ -453,7 +453,8 @@ asio::awaitable<C_ExecuteCodeResult_B3> send_function_call(
|
||||
co_return co_await promise->get();
|
||||
}
|
||||
|
||||
asio::awaitable<void> send_function_call_multi(shared_ptr<Client> c, vector<shared_ptr<const CompiledFunctionCode>> codes) {
|
||||
asio::awaitable<void> send_function_call_multi(
|
||||
shared_ptr<Client> c, unordered_set<shared_ptr<const CompiledFunctionCode>> codes) {
|
||||
if (codes.empty()) {
|
||||
co_return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -186,7 +186,7 @@ asio::awaitable<C_ExecuteCodeResult_B3> send_function_call(
|
||||
bool ignore_actually_runs_code_flag = false);
|
||||
asio::awaitable<void> send_function_call_multi(
|
||||
std::shared_ptr<Client> c,
|
||||
std::vector<std::shared_ptr<const CompiledFunctionCode>> codes);
|
||||
std::unordered_set<std::shared_ptr<const CompiledFunctionCode>> codes);
|
||||
asio::awaitable<bool> send_protected_command(std::shared_ptr<Client> c, const void* data, size_t size, bool echo_to_lobby);
|
||||
asio::awaitable<void> send_dol_file(std::shared_ptr<Client> c, std::shared_ptr<DOLFileIndex::File> dol);
|
||||
|
||||
|
||||
+8
-1
@@ -1302,7 +1302,14 @@ void ServerState::load_config_early() {
|
||||
this->bb_required_patches.clear();
|
||||
try {
|
||||
for (const auto& it : this->config_json->get_list("BBRequiredPatches")) {
|
||||
this->bb_required_patches.emplace_back(it->as_string());
|
||||
this->bb_required_patches.emplace(it->as_string());
|
||||
}
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
this->auto_patches.clear();
|
||||
try {
|
||||
for (const auto& it : this->config_json->get_list("AutoPatches")) {
|
||||
this->auto_patches.emplace(it->as_string());
|
||||
}
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
|
||||
+2
-1
@@ -219,7 +219,8 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
std::array<std::shared_ptr<const MapState::RareEnemyRates>, 4> rare_enemy_rates_by_difficulty;
|
||||
std::shared_ptr<const MapState::RareEnemyRates> rare_enemy_rates_challenge;
|
||||
std::array<std::array<size_t, 4>, 3> min_levels_v4; // Indexed as [episode][difficulty]
|
||||
std::vector<std::string> bb_required_patches;
|
||||
std::unordered_set<std::string> bb_required_patches;
|
||||
std::unordered_set<std::string> auto_patches;
|
||||
CheatFlags cheat_flags;
|
||||
|
||||
struct QuestF960Result {
|
||||
|
||||
Reference in New Issue
Block a user