diff --git a/src/ServerState.cc b/src/ServerState.cc index 1fbf8fe4..3b24a10a 100644 --- a/src/ServerState.cc +++ b/src/ServerState.cc @@ -61,7 +61,7 @@ void ServerState::add_client_to_available_lobby(shared_ptr c) { } if (!added_to_lobby.get()) { - for (const auto& lobby_id : this->public_lobby_search_order(c->version())) { + for (const auto& lobby_id : this->public_lobby_search_order(c)) { try { auto l = this->find_lobby(lobby_id); if (l && @@ -317,8 +317,11 @@ const vector>& ServerState::proxy_destinations(Version ve } } -const vector ServerState::public_lobby_search_order(Version version) const { +const vector& ServerState::public_lobby_search_order(Version version, bool is_client_customization) const { static_assert(NUM_VERSIONS == 14, "Don\'t forget to update the public lobby search orders in config.json"); + if (is_client_customization && !this->client_customization_public_lobby_search_order.empty()) { + return this->client_customization_public_lobby_search_order; + } return this->public_lobby_search_orders.at(static_cast(version)); } @@ -973,6 +976,7 @@ void ServerState::load_config_early() { for (auto& order : this->public_lobby_search_orders) { order.clear(); } + this->client_customization_public_lobby_search_order.clear(); try { const auto& orders_json = this->config_json->get_list("LobbySearchOrders"); for (size_t v_s = 0; v_s < orders_json.size(); v_s++) { @@ -984,6 +988,14 @@ void ServerState::load_config_early() { } } catch (const out_of_range&) { } + try { + const auto& order_json = this->config_json->get_list("ClientCustomizationLobbySearchOrder"); + auto& order = this->client_customization_public_lobby_search_order; + for (const auto& it : order_json) { + order.emplace_back(it->as_int()); + } + } catch (const out_of_range&) { + } this->pre_lobby_event = 0; try { diff --git a/src/ServerState.hh b/src/ServerState.hh index 3282b98b..0a1072ee 100644 --- a/src/ServerState.hh +++ b/src/ServerState.hh @@ -251,6 +251,7 @@ struct ServerState : public std::enable_shared_from_this { std::unordered_set> lobbies_to_destroy; std::shared_ptr destroy_lobbies_event; std::array, NUM_VERSIONS> public_lobby_search_orders; + std::vector client_customization_public_lobby_search_order; std::atomic next_lobby_id = 1; uint8_t pre_lobby_event = 0; int32_t ep3_menu_song = -1; @@ -316,7 +317,10 @@ struct ServerState : public std::enable_shared_from_this { std::string describe_item(Version version, const ItemData& item, bool include_color_codes) const; ItemData parse_item_description(Version version, const std::string& description) const; - const std::vector public_lobby_search_order(Version version) const; + const std::vector& public_lobby_search_order(Version version, bool is_client_customization) const; + inline const std::vector& public_lobby_search_order(std::shared_ptr c) const { + return this->public_lobby_search_order(c->version(), c->config.check_flag(Client::Flag::IS_CLIENT_CUSTOMIZATION)); + } inline uint32_t name_color_for_client(Version v, bool is_client_customization) const { if (is_client_customization && this->client_customization_name_color) { diff --git a/system/config.example.json b/system/config.example.json index f422f5ab..370cec40 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -379,6 +379,7 @@ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], // Xbox [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], // BB ], + "ClientCustomizationLobbySearchOrder": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], // Lobby holiday events. The event can be changed in each lobby independently // with the $event command, or in all lobbies with the $allevent command. When diff --git a/tests/config.json b/tests/config.json index a0ff4923..2f27a292 100644 --- a/tests/config.json +++ b/tests/config.json @@ -124,6 +124,7 @@ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], ], + "ClientCustomizationLobbySearchOrder": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], "LobbyEvents": [ "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", "none", ],