diff --git a/src/ServerState.cc b/src/ServerState.cc index 5ecfd4fd..679ba299 100644 --- a/src/ServerState.cc +++ b/src/ServerState.cc @@ -64,7 +64,11 @@ void ServerState::add_client_to_available_lobby(shared_ptr c) { void ServerState::remove_client_from_lobby(shared_ptr c) { auto l = this->id_to_lobby.at(c->lobby_id); l->remove_client(c); - send_player_leave_notification(l, c->lobby_client_id); + if (!(l->flags & LobbyFlag::Persistent) && (l->count_clients() == 0)) { + this->remove_lobby(l->lobby_id); + } else { + send_player_leave_notification(l, c->lobby_client_id); + } } void ServerState::change_client_lobby(shared_ptr c, shared_ptr new_lobby) { @@ -83,9 +87,10 @@ void ServerState::change_client_lobby(shared_ptr c, shared_ptr ne } if (current_lobby) { - send_player_leave_notification(current_lobby, old_lobby_client_id); if (!(current_lobby->flags & LobbyFlag::Persistent) && (current_lobby->count_clients() == 0)) { this->remove_lobby(current_lobby->lobby_id); + } else { + send_player_leave_notification(current_lobby, old_lobby_client_id); } } this->send_lobby_join_notifications(new_lobby, c);