don't send extra lobbies to v1 clients

This commit is contained in:
Martin Michelsen
2022-09-22 22:51:46 -07:00
parent 5d314f4e96
commit c43fa7a40d
3 changed files with 28 additions and 20 deletions
+22 -7
View File
@@ -25,28 +25,40 @@ ServerState::ServerState()
run_shell_behavior(RunShellBehavior::DEFAULT), next_lobby_id(1),
pre_lobby_event(0),
ep3_menu_song(-1) {
vector<shared_ptr<Lobby>> non_v1_only_lobbies;
vector<shared_ptr<Lobby>> ep3_only_lobbies;
for (size_t x = 0; x < 20; x++) {
auto lobby_name = decode_sjis(string_printf("LOBBY%zu", x + 1));
bool is_non_v1_only = (x > 9);
bool is_ep3_only = (x > 14);
shared_ptr<Lobby> l = this->create_lobby();
l->flags |= Lobby::Flag::PUBLIC | Lobby::Flag::DEFAULT | Lobby::Flag::PERSISTENT |
l->flags |=
Lobby::Flag::PUBLIC |
Lobby::Flag::DEFAULT |
Lobby::Flag::PERSISTENT |
(is_non_v1_only ? Lobby::Flag::NON_V1_ONLY : 0) |
(is_ep3_only ? Lobby::Flag::EPISODE_3_ONLY : 0);
l->block = x + 1;
l->type = x;
l->name = lobby_name;
l->max_clients = 12;
if (!is_non_v1_only) {
this->public_lobby_search_order_v1.emplace_back(l);
}
if (!is_ep3_only) {
this->public_lobby_search_order.emplace_back(l);
this->public_lobby_search_order_non_v1.emplace_back(l);
} else {
ep3_only_lobbies.emplace_back(l);
}
}
this->public_lobby_search_order_ep3 = this->public_lobby_search_order;
// Annoyingly, the CARD lobbies should be searched first, but are sent at the
// end of the lobby list command, so we have to change t he search order
// manually here.
this->public_lobby_search_order_ep3 = this->public_lobby_search_order_non_v1;
this->public_lobby_search_order_ep3.insert(
this->public_lobby_search_order_ep3.begin(),
ep3_only_lobbies.begin(),
@@ -67,10 +79,13 @@ void ServerState::add_client_to_available_lobby(shared_ptr<Client> c) {
}
if (!added_to_lobby.get()) {
const auto& search_order = (c->flags & Client::Flag::EPISODE_3)
? this->public_lobby_search_order_ep3
: this->public_lobby_search_order;
for (const auto& l : search_order) {
const auto* search_order = &this->public_lobby_search_order_non_v1;
if (c->flags & Client::Flag::IS_DC_V1) {
search_order = &this->public_lobby_search_order_v1;
} else if (c->flags & Client::Flag::IS_EPISODE_3) {
search_order = &this->public_lobby_search_order_ep3;
}
for (const auto& l : *search_order) {
try {
l->add_client(c);
added_to_lobby = l;
+2 -1
View File
@@ -84,7 +84,8 @@ struct ServerState {
std::u16string bb_patch_server_message;
std::map<int64_t, std::shared_ptr<Lobby>> id_to_lobby;
std::vector<std::shared_ptr<Lobby>> public_lobby_search_order;
std::vector<std::shared_ptr<Lobby>> public_lobby_search_order_v1;
std::vector<std::shared_ptr<Lobby>> public_lobby_search_order_non_v1;
std::vector<std::shared_ptr<Lobby>> public_lobby_search_order_ep3;
// TODO: Use a free-list instead of an incrementer to prevent wrap-around
// behavioral bugs. This... will probably never be an issue for anyone, but we
+4 -12
View File
@@ -147,18 +147,14 @@ I 69775 2022-08-27 09:36:31 - [Commands] Sending to C-3 (version=DC command=04 f
0010 | 0E 89 2A 49 14 02 00 00 00 00 00 00 FF FF FF FF | *I
0020 | FF FF FF FF FF FF FF FF FF FF FF FF |
I 69775 2022-08-27 09:36:31 - [Commands] Sending to C-3 (version=DC command=83 flag=0F)
0000 | 83 0F B8 00 33 00 00 33 01 00 00 00 00 00 00 00 | 3 3
0000 | 83 0A 7C 00 33 00 00 33 01 00 00 00 00 00 00 00 | 3 3
0010 | 33 00 00 33 02 00 00 00 00 00 00 00 33 00 00 33 | 3 3 3 3
0020 | 03 00 00 00 00 00 00 00 33 00 00 33 04 00 00 00 | 3 3
0030 | 00 00 00 00 33 00 00 33 05 00 00 00 00 00 00 00 | 3 3
0040 | 33 00 00 33 06 00 00 00 00 00 00 00 33 00 00 33 | 3 3 3 3
0050 | 07 00 00 00 00 00 00 00 33 00 00 33 08 00 00 00 | 3 3
0060 | 00 00 00 00 33 00 00 33 09 00 00 00 00 00 00 00 | 3 3
0070 | 33 00 00 33 0A 00 00 00 00 00 00 00 33 00 00 33 | 3 3 3 3
0080 | 0B 00 00 00 00 00 00 00 33 00 00 33 0C 00 00 00 | 3 3
0090 | 00 00 00 00 33 00 00 33 0D 00 00 00 00 00 00 00 | 3 3
00A0 | 33 00 00 33 0E 00 00 00 00 00 00 00 33 00 00 33 | 3 3 3 3
00B0 | 0F 00 00 00 00 00 00 00 |
0070 | 33 00 00 33 0A 00 00 00 00 00 00 00 | 3 3
I 69775 2022-08-27 09:36:31 - [Commands] Sending to C-3 (version=DC command=95 flag=00)
0000 | 95 00 04 00 |
I 69775 2022-08-27 09:36:32 - [Commands] Received from C-3 (version=DC command=61 flag=01)
@@ -640,18 +636,14 @@ I 69775 2022-08-27 09:37:10 - [Commands] Sending to C-5 (version=DC command=04 f
0010 | 0E 89 2A 49 14 02 00 00 00 00 00 00 FF FF FF FF | *I
0020 | FF FF FF FF FF FF FF FF FF FF FF FF |
I 69775 2022-08-27 09:37:10 - [Commands] Sending to C-5 (version=DC command=83 flag=0F)
0000 | 83 0F B8 00 33 00 00 33 01 00 00 00 00 00 00 00 | 3 3
0000 | 83 0A 7C 00 33 00 00 33 01 00 00 00 00 00 00 00 | 3 3
0010 | 33 00 00 33 02 00 00 00 00 00 00 00 33 00 00 33 | 3 3 3 3
0020 | 03 00 00 00 00 00 00 00 33 00 00 33 04 00 00 00 | 3 3
0030 | 00 00 00 00 33 00 00 33 05 00 00 00 00 00 00 00 | 3 3
0040 | 33 00 00 33 06 00 00 00 00 00 00 00 33 00 00 33 | 3 3 3 3
0050 | 07 00 00 00 00 00 00 00 33 00 00 33 08 00 00 00 | 3 3
0060 | 00 00 00 00 33 00 00 33 09 00 00 00 00 00 00 00 | 3 3
0070 | 33 00 00 33 0A 00 00 00 00 00 00 00 33 00 00 33 | 3 3 3 3
0080 | 0B 00 00 00 00 00 00 00 33 00 00 33 0C 00 00 00 | 3 3
0090 | 00 00 00 00 33 00 00 33 0D 00 00 00 00 00 00 00 | 3 3
00A0 | 33 00 00 33 0E 00 00 00 00 00 00 00 33 00 00 33 | 3 3 3 3
00B0 | 0F 00 00 00 00 00 00 00 |
0070 | 33 00 00 33 0A 00 00 00 00 00 00 00 | 3 3
I 69775 2022-08-27 09:37:10 - [Commands] Sending to C-5 (version=DC command=95 flag=00)
0000 | 95 00 04 00 |
I 69775 2022-08-27 09:37:10 - [Commands] Received from C-5 (version=DC command=61 flag=01)