implement overflow lobbies

This commit is contained in:
Martin Michelsen
2023-10-07 21:09:55 -07:00
parent c2b2239df0
commit 6bebcc841e
5 changed files with 21 additions and 6 deletions
-1
View File
@@ -3,7 +3,6 @@
- Test PSOX (blocked on Insignia private server support)
- Implement server-side drops on non-BB game versions
- Find a way to silence audio in RunDOL.s
- Implement private and overflow lobbies
- Encapsulate BB server-side random state and make replays deterministic
- Implement character and inventory replacement for battle and challenge modes
- Implement choice search
+1
View File
@@ -45,6 +45,7 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
PUBLIC = 0x01000000,
DEFAULT = 0x02000000,
V2_AND_LATER = 0x04000000, // Lobby does not appear on v1
IS_OVERFLOW = 0x08000000,
};
std::weak_ptr<ServerState> server_state;
+4
View File
@@ -447,6 +447,10 @@ static void on_set_player_visibility(shared_ptr<Client> c, uint8_t command, uint
if (!l->is_game() && !(c->flags & Client::Flag::IS_DC_V1)) {
send_arrow_update(l);
}
if (!l->is_game() && (l->flags & Lobby::Flag::IS_OVERFLOW)) {
send_message_box(c, u"$C6All lobbies are full.\n\n$C7You are in a private lobby. You can use the\nteleporter to join other lobbies if there is space\navailable.");
send_lobby_message_box(c, u"");
}
}
}
+9 -3
View File
@@ -1674,9 +1674,15 @@ void send_join_lobby_t(shared_ptr<Client> c, shared_ptr<Lobby> l,
send_player_records_t<RecordsT>(c, l, joining_client);
}
uint8_t lobby_type = (c->options.override_lobby_number >= 0)
? c->options.override_lobby_number
: l->block - 1;
uint8_t lobby_type;
if (c->options.override_lobby_number >= 0) {
lobby_type = c->options.override_lobby_number;
} else if (l->flags & Lobby::Flag::IS_OVERFLOW) {
lobby_type = (c->flags & Client::Flag::IS_EPISODE_3) ? 15 : 0;
} else {
lobby_type = l->block - 1;
}
// Allow non-canonical lobby types on GC. They may work on other versions too,
// but I haven't verified which values don't crash on each version.
if (c->version() == GameVersion::GC) {
+7 -2
View File
@@ -147,8 +147,13 @@ void ServerState::add_client_to_available_lobby(shared_ptr<Client> c) {
}
if (!added_to_lobby) {
// TODO: Add the user to a dynamically-created private lobby instead
throw out_of_range("all lobbies full");
added_to_lobby = this->create_lobby();
added_to_lobby->flags |= Lobby::Flag::PUBLIC | Lobby::Flag::IS_OVERFLOW;
added_to_lobby->block = 100;
added_to_lobby->name = u"Overflow";
added_to_lobby->max_clients = 12;
added_to_lobby->event = this->pre_lobby_event;
added_to_lobby->add_client(c);
}
// Send a join message to the joining player, and notifications to all others