changed server to do object management at longer intervals (0.5s)

This commit is contained in:
Perttu Ahola 2011-04-10 23:14:41 +03:00
parent 26eb607a11
commit 9d5ccafbb0
2 changed files with 203 additions and 197 deletions

View File

@ -449,6 +449,8 @@ void ServerEnvironment::step(float dtime)
obj->step(dtime, m_active_object_messages, send_recommended); obj->step(dtime, m_active_object_messages, send_recommended);
} }
if(m_object_management_interval.step(dtime, 0.5))
{
/* /*
Remove objects that satisfy (m_removed && m_known_by_count==0) Remove objects that satisfy (m_removed && m_known_by_count==0)
*/ */
@ -624,7 +626,8 @@ void ServerEnvironment::step(float dtime)
MapBlock *oldblock = NULL; MapBlock *oldblock = NULL;
if(obj->m_static_exists) if(obj->m_static_exists)
{ {
MapBlock *block = m_map->getBlockNoCreateNoEx(obj->m_static_block); MapBlock *block = m_map->getBlockNoCreateNoEx
(obj->m_static_block);
if(block) if(block)
{ {
block->m_static_objects.remove(id); block->m_static_objects.remove(id);
@ -672,6 +675,7 @@ void ServerEnvironment::step(float dtime)
m_active_objects.remove(*i); m_active_objects.remove(*i);
} }
} }
}
if(g_settings.getBool("enable_experimental")) if(g_settings.getBool("enable_experimental"))
{ {

View File

@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "player.h" #include "player.h"
#include "map.h" #include "map.h"
#include <ostream> #include <ostream>
#include "utility.h"
class Environment class Environment
{ {
@ -154,6 +155,7 @@ private:
Queue<ActiveObjectMessage> m_active_object_messages; Queue<ActiveObjectMessage> m_active_object_messages;
float m_random_spawn_timer; float m_random_spawn_timer;
float m_send_recommended_timer; float m_send_recommended_timer;
IntervalLimiter m_object_management_interval;
}; };
#ifndef SERVER #ifndef SERVER