Skip to content

Commit

Permalink
fix(net): set server feature policy even without key token
Browse files Browse the repository at this point in the history
This was reported as a case of 'if removing "svadhesive", the <=10 slot
subdir_file_mapping policy wouldn't apply'. As this would also affect
open builds, that's a tad unintended.
  • Loading branch information
blattersturm committed May 25, 2023
1 parent 5979ce4 commit c819448
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions code/components/net/src/NetLibrary.cpp
Expand Up @@ -1378,8 +1378,39 @@ concurrency::task<void> NetLibrary::ConnectToServer(const std::string& rootUrl)
m_connectionState = CS_IDLE;
};

auto policySuccess = [this]()
auto policySuccess = [this, maxClients]()
{
// add forced policies
if (maxClients <= 10)
{
// development/testing servers (<= 10 clients max - see ZAP defaults) get subdir_file_mapping granted
policies.insert("subdir_file_mapping");
}

// dev server
if (maxClients <= 8)
{
policies.insert("local_evaluation");
}

// format policy string and store it
std::stringstream policyStr;

for (const auto& line : policies)
{
policyStr << "[" << line << "]";
}

std::string policy = policyStr.str();

if (!policy.empty())
{
trace("Server feature policy is %s\n", policy);
}

Instance<ICoreGameInit>::Get()->SetData("policy", policy);

// continue connection
m_connectionState = CS_INITRECEIVED;
};

Expand Down Expand Up @@ -1440,36 +1471,6 @@ concurrency::task<void> NetLibrary::ConnectToServer(const std::string& rootUrl)
fact = "Requesting policy failed.";
}

// add forced policies
if (maxClients <= 10)
{
// development/testing servers (<= 10 clients max - see ZAP defaults) get subdir_file_mapping granted
policies.insert("subdir_file_mapping");
}

// dev server
if (maxClients <= 8)
{
policies.insert("local_evaluation");
}

// format policy string and store it
std::stringstream policyStr;

for (const auto& line : policies)
{
policyStr << "[" << line << "]";
}

std::string policy = policyStr.str();

if (!policy.empty())
{
trace("Server feature policy is %s\n", policy);
}

Instance<ICoreGameInit>::Get()->SetData("policy", policy);

// check 1s policy
if (Instance<ICoreGameInit>::Get()->OneSyncEnabled && !onesyncType.empty())
{
Expand Down

0 comments on commit c819448

Please sign in to comment.