mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Restart map-send cycle if visible blocks are soon to be unloaded. (#13277)
* Restart map-send cycle if visible blocks are soon to be unloaded. * Reset completion timer when camera or position changed. Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
parent
93898957b6
commit
48fc286a95
@ -101,6 +101,16 @@ void RemoteClient::GetNextBlocks (
|
||||
m_nothing_to_send_pause_timer -= dtime;
|
||||
m_map_send_completion_timer += dtime;
|
||||
|
||||
if (m_map_send_completion_timer > g_settings->getFloat("server_unload_unused_data_timeout") * 0.8f) {
|
||||
infostream << "Server: Player " << m_name << ", peer_id=" << peer_id
|
||||
<< ": full map send is taking too long ("
|
||||
<< m_map_send_completion_timer
|
||||
<< "s), restarting to avoid visible blocks being unloaded."
|
||||
<< std::endl;
|
||||
m_map_send_completion_timer = 0.0f;
|
||||
m_nearest_unsent_d = 0;
|
||||
}
|
||||
|
||||
if (m_nothing_to_send_pause_timer >= 0)
|
||||
return;
|
||||
|
||||
@ -176,12 +186,14 @@ void RemoteClient::GetNextBlocks (
|
||||
if (m_last_center != center) {
|
||||
m_nearest_unsent_d = 0;
|
||||
m_last_center = center;
|
||||
m_map_send_completion_timer = 0.0f;
|
||||
}
|
||||
// reset the unsent distance if the view angle has changed more that 10% of the fov
|
||||
// (this matches isBlockInSight which allows for an extra 10%)
|
||||
if (camera_dir.dotProduct(m_last_camera_dir) < std::cos(camera_fov * 0.1f)) {
|
||||
m_nearest_unsent_d = 0;
|
||||
m_last_camera_dir = camera_dir;
|
||||
m_map_send_completion_timer = 0.0f;
|
||||
}
|
||||
if (m_nearest_unsent_d > 0) {
|
||||
// make sure any blocks modified since the last time we sent blocks are resent
|
||||
@ -259,16 +271,6 @@ void RemoteClient::GetNextBlocks (
|
||||
if (d <= BLOCK_SEND_DISABLE_LIMITS_MAX_D)
|
||||
max_simul_dynamic = m_max_simul_sends;
|
||||
|
||||
// Don't select too many blocks for sending
|
||||
if (num_blocks_selected >= max_simul_dynamic) {
|
||||
//queue_is_full = true;
|
||||
goto queue_full_break;
|
||||
}
|
||||
|
||||
// Don't send blocks that are currently being transferred
|
||||
if (m_blocks_sending.find(p) != m_blocks_sending.end())
|
||||
continue;
|
||||
|
||||
/*
|
||||
Do not go over max mapgen limit
|
||||
*/
|
||||
@ -304,6 +306,16 @@ void RemoteClient::GetNextBlocks (
|
||||
block->resetUsageTimer();
|
||||
}
|
||||
|
||||
// Don't select too many blocks for sending
|
||||
if (num_blocks_selected >= max_simul_dynamic) {
|
||||
//queue_is_full = true;
|
||||
goto queue_full_break;
|
||||
}
|
||||
|
||||
// Don't send blocks that are currently being transferred
|
||||
if (m_blocks_sending.find(p) != m_blocks_sending.end())
|
||||
continue;
|
||||
|
||||
/*
|
||||
Don't send already sent blocks
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user