add lobby order option for client customization
This commit is contained in:
+14
-2
@@ -61,7 +61,7 @@ void ServerState::add_client_to_available_lobby(shared_ptr<Client> 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<pair<string, uint16_t>>& ServerState::proxy_destinations(Version ve
|
||||
}
|
||||
}
|
||||
|
||||
const vector<uint32_t> ServerState::public_lobby_search_order(Version version) const {
|
||||
const vector<uint32_t>& 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<size_t>(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 {
|
||||
|
||||
+5
-1
@@ -251,6 +251,7 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
std::unordered_set<std::shared_ptr<Lobby>> lobbies_to_destroy;
|
||||
std::shared_ptr<struct event> destroy_lobbies_event;
|
||||
std::array<std::vector<uint32_t>, NUM_VERSIONS> public_lobby_search_orders;
|
||||
std::vector<uint32_t> client_customization_public_lobby_search_order;
|
||||
std::atomic<int32_t> 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<ServerState> {
|
||||
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<uint32_t> public_lobby_search_order(Version version) const;
|
||||
const std::vector<uint32_t>& public_lobby_search_order(Version version, bool is_client_customization) const;
|
||||
inline const std::vector<uint32_t>& public_lobby_search_order(std::shared_ptr<const Client> 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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user