From 64f2cb8f9e6f5b0fafbdf24e4b2e1035035389db Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sat, 9 Mar 2024 09:21:36 -0800 Subject: [PATCH] add ServerGlobalDropRateMultiplier --- README.md | 2 +- src/ServerState.cc | 15 +++++++++++++-- src/ServerState.hh | 1 + system/config.example.json | 5 +++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index adced709..59984059 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Independently of this project, there are many other PSO servers out there. Those # Compatibility -newserv supports several versions of PSO, including various development prototypes. Specifically: +newserv supports all known versions of PSO, including development prototypes. Specifically: | Version | Lobbies | Games | Proxy | |-----------------|----------|----------|----------| | DC NTE | Yes | Yes | No | diff --git a/src/ServerState.cc b/src/ServerState.cc index 6f17eeeb..5f60f38c 100644 --- a/src/ServerState.cc +++ b/src/ServerState.cc @@ -874,6 +874,7 @@ void ServerState::load_config_early() { } this->bb_global_exp_multiplier = this->config_json->get_int("BBGlobalEXPMultiplier", 1); + this->server_global_drop_rate_multiplier = this->config_json->get_float("ServerGlobalDropRateMultiplier", 1); set_log_levels_from_json(this->config_json->get("LogLevels", JSON::dict())); @@ -1489,7 +1490,7 @@ void ServerState::load_item_name_indexes(bool from_non_event_thread) { void ServerState::load_drop_tables(bool from_non_event_thread) { config_log.info("Loading rare item sets"); - unordered_map> new_rare_item_sets; + unordered_map> new_rare_item_sets; for (const auto& filename : list_directory_sorted("system/item-tables")) { if (!starts_with(filename, "rare-table-")) { continue; @@ -1574,7 +1575,17 @@ void ServerState::load_drop_tables(bool from_non_event_thread) { new_tool_random_set = std::move(new_tool_random_set), new_weapon_random_sets = std::move(new_weapon_random_sets), new_tekker_adjustment_set = std::move(new_tekker_adjustment_set)]() { - s->rare_item_sets = std::move(new_rare_item_sets); + if (s->server_global_drop_rate_multiplier != 1.0) { + for (auto& it : new_rare_item_sets) { + it.second->multiply_all_rates(s->server_global_drop_rate_multiplier); + } + } + // We can't just move() new_rare_item_sets into place because its values are + // not const :( + s->rare_item_sets.clear(); + for (auto& it : new_rare_item_sets) { + s->rare_item_sets.emplace(it.first, std::move(it.second)); + } s->common_item_set_v2 = std::move(new_common_item_set_v2); s->common_item_set_v3_v4 = std::move(new_common_item_set_v3_v4); s->armor_random_set = std::move(new_armor_random_set); diff --git a/src/ServerState.hh b/src/ServerState.hh index bb8a1b81..0c1657af 100644 --- a/src/ServerState.hh +++ b/src/ServerState.hh @@ -182,6 +182,7 @@ struct ServerState : public std::enable_shared_from_this { QuestF960Result quest_F960_failure_results; std::vector secret_lottery_results; uint16_t bb_global_exp_multiplier = 1; + double server_global_drop_rate_multiplier = 1.0; std::shared_ptr ep3_tournament_index; diff --git a/system/config.example.json b/system/config.example.json index a9a804e1..6329f794 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -810,6 +810,11 @@ // EXP multiplier for BB games. This must be an integer due to a client // limitation, and must be at least 1. "BBGlobalEXPMultiplier": 1, + // Drop rate multiplier for all server drop tables. This applies to server + // drop modes in all game versions. If you want to scale the drop rates for + // only some versions, use the --multiply option to the convert-rare-item-set + // action instead. + "ServerGlobalDropRateMultiplier": 1, // BB team reward definitions. Team rewards have the following fields: // Key: Internal name of the reward. Must be unique across all rewards.