Reduce active mgmt interval for a bit when a player joins. (#12925)

This commit is contained in:
lhofhansl 2022-11-10 15:25:38 -08:00 committed by GitHub
parent 00eb65915f
commit 1a045da0dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

@ -633,8 +633,8 @@ PlayerSAO *ServerEnvironment::loadPlayer(RemotePlayer *player, bool *new_player,
/* Add object to environment */
addActiveObject(playersao);
// Update active blocks asap so objects in those blocks appear on the client
m_force_update_active_blocks = true;
// Update active blocks quickly for a bit so objects in those blocks appear on the client
m_fast_active_block_divider = 10;
return playersao;
}
@ -1327,8 +1327,7 @@ void ServerEnvironment::step(float dtime)
/*
Manage active block list
*/
if (m_active_blocks_mgmt_interval.step(dtime, m_cache_active_block_mgmt_interval) ||
m_force_update_active_blocks) {
if (m_active_blocks_mgmt_interval.step(dtime, m_cache_active_block_mgmt_interval / m_fast_active_block_divider)) {
ScopeProfiler sp(g_profiler, "ServerEnv: update active blocks", SPT_AVG);
/*
@ -1397,8 +1396,10 @@ void ServerEnvironment::step(float dtime)
// Some blocks may be removed again by the code above so do this here
m_active_block_gauge->set(m_active_blocks.size());
if (m_fast_active_block_divider > 1)
--m_fast_active_block_divider;
}
m_force_update_active_blocks = false;
/*
Mess around in active blocks

@ -462,7 +462,7 @@ private:
IntervalLimiter m_object_management_interval;
// List of active blocks
ActiveBlockList m_active_blocks;
bool m_force_update_active_blocks = false;
int m_fast_active_block_divider = 1;
IntervalLimiter m_active_blocks_mgmt_interval;
IntervalLimiter m_active_block_modifier_interval;
IntervalLimiter m_active_blocks_nodemetadata_interval;