diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2017-09-09 00:36:48 +0200 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-09-09 00:36:48 +0200 |
commit | 745a90dc84339774a37fddff480dd60c69f4cc2a (patch) | |
tree | b856c29bd9fb13f31c3349866f2de9624bf56a3e /src/server.cpp | |
parent | 1105a14bccefb48a0e264fe19190c39629259338 (diff) | |
download | hax-minetest-server-745a90dc84339774a37fddff480dd60c69f4cc2a.tar.gz hax-minetest-server-745a90dc84339774a37fddff480dd60c69f4cc2a.zip |
Server: Calculate maximal total block sends dynamically (#6393)
The block sends per client is 1/2 when reaching the maximal player count.
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/server.cpp b/src/server.cpp index 7bae69d55..c5b7bbd79 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2181,7 +2181,7 @@ void Server::SendBlocks(float dtime) std::vector<PrioritySortedBlockTransfer> queue; - s32 total_sending = 0; + u32 total_sending = 0; { ScopeProfiler sp2(g_profiler, "Server: selecting blocks for sending"); @@ -2195,7 +2195,7 @@ void Server::SendBlocks(float dtime) if (!client) continue; - total_sending += client->SendingCount(); + total_sending += client->getSendingCount(); client->GetNextBlocks(m_env,m_emerge, dtime, queue); } m_clients.unlock(); @@ -2207,11 +2207,13 @@ void Server::SendBlocks(float dtime) std::sort(queue.begin(), queue.end()); m_clients.lock(); - s32 max_blocks_to_send = - g_settings->getS32("max_simultaneous_block_sends_server_total"); + + // Maximal total count calculation + // The per-client block sends is halved with the maximal online users + u32 max_blocks_to_send = (m_env->getPlayerCount() + g_settings->getU32("max_users")) * + g_settings->getU32("max_simultaneous_block_sends_per_client") / 4 + 1; for (const PrioritySortedBlockTransfer &block_to_send : queue) { - //TODO: Calculate limit dynamically if (total_sending >= max_blocks_to_send) break; |