@@ -56,7 +56,8 @@ const char *ClientInterface::state2Name(ClientState state)
5656RemoteClient::RemoteClient () :
5757 serialization_version(SER_FMT_VER_INVALID),
5858 m_pending_serialization_version(SER_FMT_VER_INVALID),
59- m_max_simul_sends(g_settings->getU16 (" max_simultaneous_block_sends_per_client" )),
59+ m_max_simul_sends(std::max<u16 >(1 ,
60+ g_settings->getU16 (" max_simultaneous_block_sends_per_client" ))),
6061 m_min_time_from_building(
6162 g_settings->getFloat (" full_block_send_enable_min_time_from_building" )),
6263 m_max_send_distance(g_settings->getS16 (" max_block_send_distance" )),
@@ -149,14 +150,15 @@ void RemoteClient::GetNextBlocks (
149150 u16 max_simul_sends_usually = m_max_simul_sends;
150151
151152 /*
152- Check the time from last addNode/removeNode.
153-
154153 Decrease send rate if player is building stuff.
154+
155+ The idea is that we can save some bandwidth since the player is busy
156+ and not looking around.
155157 */
156158 m_time_from_building += dtime;
157159 if (m_time_from_building < m_min_time_from_building) {
158- max_simul_sends_usually
159- = LIMITED_MAX_SIMULTANEOUS_BLOCK_SENDS ;
160+ max_simul_sends_usually *= LIMITED_BLOCK_SENDS_FACTOR;
161+ max_simul_sends_usually = MYMAX ( 1 , max_simul_sends_usually) ;
160162 }
161163
162164 /*
@@ -223,17 +225,19 @@ void RemoteClient::GetNextBlocks (
223225 s16 d_max = full_d_max;
224226
225227 // Don't loop very much at a time
226- s16 max_d_increment_at_time = 2 ;
228+ const s16 max_d_increment_at_time = 2 ;
227229 if (d_max > d_start + max_d_increment_at_time)
228230 d_max = d_start + max_d_increment_at_time;
229231
230- // cos(angle between velocity and camera) * |velocity|
231- // Limit to 0.0f in case player moves backwards.
232- f32 dot = rangelim (camera_dir.dotProduct (playerspeed), 0 .0f , 300 .0f );
232+ {
233+ // cos(angle between velocity and camera) * |velocity|
234+ // Limit to 0.0f in case player moves backwards.
235+ f32 dot = rangelim (camera_dir.dotProduct (playerspeed), 0 .0f , 300 .0f );
233236
234- // Reduce the field of view when a player moves and looks forward.
235- // limit max fov effect to 50%, 60% at 20n/s fly speed
236- camera_fov = camera_fov / (1 + dot / 300 .0f );
237+ // Reduce the field of view when a player moves and looks forward.
238+ // limit max fov effect to 50%, 60% at 20n/s fly speed
239+ camera_fov = camera_fov / (1 + dot / 300 .0f );
240+ }
237241
238242 s32 nearest_emerged_d = -1 ;
239243 s32 nearest_sent_d = -1 ;
@@ -260,11 +264,9 @@ void RemoteClient::GetNextBlocks (
260264 Also, don't send blocks that are already flying.
261265 */
262266
263- // Start with the usual maximum
264267 u16 max_simul_dynamic = max_simul_sends_usually;
265-
266268 // If block is very close, allow full maximum
267- if (d <= BLOCK_SEND_DISABLE_LIMITS_MAX_D )
269+ if (d <= BLOCK_ALWAYS_SEND_MAX_D )
268270 max_simul_dynamic = m_max_simul_sends;
269271
270272 /*
@@ -388,8 +390,8 @@ void RemoteClient::GetNextBlocks (
388390 new_nearest_unsent_d = 0 ;
389391 m_nothing_to_send_pause_timer = 2 .0f ;
390392 infostream << " Server: Player " << m_name << " , peer_id=" << peer_id
391- << " : full map send completed after " << m_map_send_completion_timer
392- << " s, restarting" << std::endl;
393+ << " : full map send (d= " << d << " ) completed after "
394+ << m_map_send_completion_timer << " s, restarting" << std::endl;
393395 m_map_send_completion_timer = 0 .0f ;
394396 } else {
395397 if (nearest_sent_d != -1 )
0 commit comments