Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Code/server/GameServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 2 additions & 0 deletions Code/server/GameServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class T> void ForEachAdmin(const T& aFunctor)
{
Expand Down
10 changes: 2 additions & 8 deletions Code/server/Services/PartyService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
#include <Messages/PartyKickRequest.h>
#include <Messages/NotifyPlayerJoined.h>

#include <Setting.h>
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<UpdateEvent>().connect<&PartyService::OnUpdate>(this))
Expand Down Expand Up @@ -122,7 +116,7 @@ void PartyService::OnPartyCreate(const PacketEvent<PartyCreateRequest>& 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())
{
Expand Down Expand Up @@ -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())
{
Expand Down
Loading