diff --git a/Code/server/GameServer.cpp b/Code/server/GameServer.cpp index ba4176b83..b70bc3e3b 100644 --- a/Code/server/GameServer.cpp +++ b/Code/server/GameServer.cpp @@ -32,6 +32,7 @@ Console::Setting bPremiumTickrate{"GameServer:bPremiumMode", "Use premium tick r Console::StringSetting sServerName{"GameServer:sServerName", "Name that shows up in the server list", "Dedicated Together Server"}; Console::StringSetting sAdminPassword{"GameServer:sAdminPassword", "Admin authentication password", ""}; Console::StringSetting sPassword{"GameServer:sPassword", "Server password", ""}; +Console::Setting bAnnounceServer{"LiveServices:bAnnounceServer", "Whether to list the server on the public server list", false}; // Gameplay // TODO: to make this easier for users, use game names for difficulty instead of int @@ -203,6 +204,16 @@ GameServer* GameServer::Get() noexcept return s_pInstance; } +bool GameServer::IsPublicServer() const noexcept +{ + return bAnnounceServer; +} + +bool GameServer::AllowsAutoPartyJoin() const noexcept +{ + return bAutoPartyJoin && !IsPublicServer(); +} + void GameServer::Initialize() { if (!CheckMoPo()) diff --git a/Code/server/GameServer.h b/Code/server/GameServer.h index f7256d7a8..d29365372 100644 --- a/Code/server/GameServer.h +++ b/Code/server/GameServer.h @@ -66,6 +66,8 @@ struct GameServer final : Server bool IsRunning() const noexcept { return !m_requestStop; } bool IsPasswordProtected() const noexcept { return m_isPasswordProtected; } + [[nodiscard]] bool IsPublicServer() const noexcept; + [[nodiscard]] bool AllowsAutoPartyJoin() const noexcept; template void ForEachAdmin(const T& aFunctor) { diff --git a/Code/server/Services/PartyService.cpp b/Code/server/Services/PartyService.cpp index deabdd974..0cdd2ee49 100644 --- a/Code/server/Services/PartyService.cpp +++ b/Code/server/Services/PartyService.cpp @@ -19,12 +19,6 @@ #include #include -#include -namespace -{ -Console::Setting bAutoPartyJoin{"Gameplay:bAutoPartyJoin", "Join parties automatically, as long as there is only one party in the server", true}; -} - PartyService::PartyService(World& aWorld, entt::dispatcher& aDispatcher) noexcept : m_world(aWorld) , m_updateEvent(aDispatcher.sink().connect<&PartyService::OnUpdate>(this)) @@ -122,7 +116,7 @@ void PartyService::OnPartyCreate(const PacketEvent& acPacket spdlog::debug("[PartyService]: Created party for {}", player->GetId()); SendPartyJoinedEvent(party, player); - if (m_parties.size() == 1 && bAutoPartyJoin) + if (m_parties.size() == 1 && GameServer::Get()->AllowsAutoPartyJoin()) { for (Player* otherPlayer : m_world.GetPlayerManager()) { @@ -218,7 +212,7 @@ void PartyService::OnPlayerJoin(const PlayerJoinEvent& acEvent) noexcept GameServer::Get()->SendToPlayers(notify, acEvent.pPlayer); - if (m_parties.size() == 1 && bAutoPartyJoin) + if (m_parties.size() == 1 && GameServer::Get()->AllowsAutoPartyJoin()) { for (Player* player : m_world.GetPlayerManager()) {