diff options
-rw-r--r-- | src/environment.cpp | 10 | ||||
-rw-r--r-- | src/server.cpp | 39 |
2 files changed, 24 insertions, 25 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index 3bf5e1f0a..081079a79 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1029,7 +1029,8 @@ void ServerEnvironment::step(float dtime) // Update this one // NOTE: This is kind of funny on a singleplayer game, but doesn't // really matter that much. - m_recommended_send_interval = g_settings->getFloat("dedicated_server_step"); + static const float server_step = g_settings->getFloat("dedicated_server_step"); + m_recommended_send_interval = server_step; /* Increment game time @@ -1086,7 +1087,7 @@ void ServerEnvironment::step(float dtime) /* Update list of active blocks, collecting changes */ - const s16 active_block_range = g_settings->getS16("active_block_range"); + static const s16 active_block_range = g_settings->getS16("active_block_range"); std::set<v3s16> blocks_removed; std::set<v3s16> blocks_added; m_active_blocks.update(players_blockpos, active_block_range, @@ -1101,8 +1102,7 @@ void ServerEnvironment::step(float dtime) for(std::set<v3s16>::iterator i = blocks_removed.begin(); - i != blocks_removed.end(); ++i) - { + i != blocks_removed.end(); ++i) { v3s16 p = *i; /* infostream<<"Server: Block " << PP(p) @@ -2636,5 +2636,3 @@ ClientEnvEvent ClientEnvironment::getClientEvent() } #endif // #ifndef SERVER - - diff --git a/src/server.cpp b/src/server.cpp index 572533146..c4ed32253 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -671,16 +671,18 @@ void Server::AsyncRunStep(bool initial_step) ScopeProfiler sp(g_profiler, "Server: checking added and deleted objs"); // Radius inside which objects are active - s16 radius = g_settings->getS16("active_object_send_range_blocks"); - s16 player_radius = g_settings->getS16("player_transfer_distance"); - - if (player_radius == 0 && g_settings->exists("unlimited_player_transfer_distance") && - !g_settings->getBool("unlimited_player_transfer_distance")) + static const s16 radius = + g_settings->getS16("active_object_send_range_blocks") * MAP_BLOCKSIZE; + + // Radius inside which players are active + static const bool is_transfer_limited = + g_settings->exists("unlimited_player_transfer_distance") && + !g_settings->getBool("unlimited_player_transfer_distance"); + static const s16 player_transfer_dist = g_settings->getS16("player_transfer_distance") * MAP_BLOCKSIZE; + s16 player_radius = player_transfer_dist; + if (player_radius == 0 && is_transfer_limited) player_radius = radius; - radius *= MAP_BLOCKSIZE; - player_radius *= MAP_BLOCKSIZE; - for (std::map<u16, RemoteClient*>::iterator i = clients.begin(); i != clients.end(); ++i) { @@ -984,8 +986,7 @@ void Server::AsyncRunStep(bool initial_step) { float &counter = m_emergethread_trigger_timer; counter += dtime; - if(counter >= 2.0) - { + if (counter >= 2.0) { counter = 0.0; m_emerge->startThreads(); @@ -996,8 +997,9 @@ void Server::AsyncRunStep(bool initial_step) { float &counter = m_savemap_timer; counter += dtime; - if(counter >= g_settings->getFloat("server_map_save_interval")) - { + static const float save_interval = + g_settings->getFloat("server_map_save_interval"); + if (counter >= save_interval) { counter = 0.0; MutexAutoLock lock(m_env_mutex); @@ -3512,9 +3514,11 @@ void dedicated_server_loop(Server &server, bool &kill) IntervalLimiter m_profiler_interval; - for(;;) - { - float steplen = g_settings->getFloat("dedicated_server_step"); + static const float steplen = g_settings->getFloat("dedicated_server_step"); + static const float profiler_print_interval = + g_settings->getFloat("profiler_print_interval"); + + for(;;) { // This is kind of a hack but can be done like this // because server.step() is very light { @@ -3536,10 +3540,7 @@ void dedicated_server_loop(Server &server, bool &kill) /* Profiler */ - float profiler_print_interval = - g_settings->getFloat("profiler_print_interval"); - if(profiler_print_interval != 0) - { + if (profiler_print_interval != 0) { if(m_profiler_interval.step(steplen, profiler_print_interval)) { infostream<<"Profiler:"<<std::endl; |