Cache some settings

This commit is contained in:
rubenwardy 2015-09-02 20:21:55 +01:00 committed by paramat
parent f77b35b35b
commit 4efb7eb734
2 changed files with 23 additions and 24 deletions

@ -1029,7 +1029,8 @@ void ServerEnvironment::step(float dtime)
// Update this one // Update this one
// NOTE: This is kind of funny on a singleplayer game, but doesn't // NOTE: This is kind of funny on a singleplayer game, but doesn't
// really matter that much. // 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 Increment game time
@ -1086,7 +1087,7 @@ void ServerEnvironment::step(float dtime)
/* /*
Update list of active blocks, collecting changes 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_removed;
std::set<v3s16> blocks_added; std::set<v3s16> blocks_added;
m_active_blocks.update(players_blockpos, active_block_range, m_active_blocks.update(players_blockpos, active_block_range,
@ -1101,8 +1102,7 @@ void ServerEnvironment::step(float dtime)
for(std::set<v3s16>::iterator for(std::set<v3s16>::iterator
i = blocks_removed.begin(); i = blocks_removed.begin();
i != blocks_removed.end(); ++i) i != blocks_removed.end(); ++i) {
{
v3s16 p = *i; v3s16 p = *i;
/* infostream<<"Server: Block " << PP(p) /* infostream<<"Server: Block " << PP(p)
@ -2636,5 +2636,3 @@ ClientEnvEvent ClientEnvironment::getClientEvent()
} }
#endif // #ifndef SERVER #endif // #ifndef SERVER

@ -671,16 +671,18 @@ void Server::AsyncRunStep(bool initial_step)
ScopeProfiler sp(g_profiler, "Server: checking added and deleted objs"); ScopeProfiler sp(g_profiler, "Server: checking added and deleted objs");
// Radius inside which objects are active // Radius inside which objects are active
s16 radius = g_settings->getS16("active_object_send_range_blocks"); static const s16 radius =
s16 player_radius = g_settings->getS16("player_transfer_distance"); g_settings->getS16("active_object_send_range_blocks") * MAP_BLOCKSIZE;
if (player_radius == 0 && g_settings->exists("unlimited_player_transfer_distance") && // Radius inside which players are active
!g_settings->getBool("unlimited_player_transfer_distance")) 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; player_radius = radius;
radius *= MAP_BLOCKSIZE;
player_radius *= MAP_BLOCKSIZE;
for (std::map<u16, RemoteClient*>::iterator for (std::map<u16, RemoteClient*>::iterator
i = clients.begin(); i = clients.begin();
i != clients.end(); ++i) { i != clients.end(); ++i) {
@ -984,8 +986,7 @@ void Server::AsyncRunStep(bool initial_step)
{ {
float &counter = m_emergethread_trigger_timer; float &counter = m_emergethread_trigger_timer;
counter += dtime; counter += dtime;
if(counter >= 2.0) if (counter >= 2.0) {
{
counter = 0.0; counter = 0.0;
m_emerge->startThreads(); m_emerge->startThreads();
@ -996,8 +997,9 @@ void Server::AsyncRunStep(bool initial_step)
{ {
float &counter = m_savemap_timer; float &counter = m_savemap_timer;
counter += dtime; 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; counter = 0.0;
MutexAutoLock lock(m_env_mutex); MutexAutoLock lock(m_env_mutex);
@ -3512,9 +3514,11 @@ void dedicated_server_loop(Server &server, bool &kill)
IntervalLimiter m_profiler_interval; IntervalLimiter m_profiler_interval;
for(;;) static const float steplen = g_settings->getFloat("dedicated_server_step");
{ static const float profiler_print_interval =
float steplen = g_settings->getFloat("dedicated_server_step"); g_settings->getFloat("profiler_print_interval");
for(;;) {
// This is kind of a hack but can be done like this // This is kind of a hack but can be done like this
// because server.step() is very light // because server.step() is very light
{ {
@ -3536,10 +3540,7 @@ void dedicated_server_loop(Server &server, bool &kill)
/* /*
Profiler Profiler
*/ */
float profiler_print_interval = if (profiler_print_interval != 0) {
g_settings->getFloat("profiler_print_interval");
if(profiler_print_interval != 0)
{
if(m_profiler_interval.step(steplen, profiler_print_interval)) if(m_profiler_interval.step(steplen, profiler_print_interval))
{ {
infostream<<"Profiler:"<<std::endl; infostream<<"Profiler:"<<std::endl;