diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2015-03-04 11:46:31 +0100 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2015-03-04 11:46:31 +0100 |
commit | 7f8f9785d7e9e120a6708d2f51e32dfef3e50c19 (patch) | |
tree | 454240229e803e8ca87a75e889fd54d3110ad426 /src/server.cpp | |
parent | 1b2f64473ed4f222d3b7f02df853730d4382105e (diff) | |
download | minetest-7f8f9785d7e9e120a6708d2f51e32dfef3e50c19.tar.gz minetest-7f8f9785d7e9e120a6708d2f51e32dfef3e50c19.tar.bz2 minetest-7f8f9785d7e9e120a6708d2f51e32dfef3e50c19.zip |
ASyncRunStep doesn't need to lock when do setTimeOfDaySpeed.
* setTimeOfDaySpeed already lock a mutex when modify the value, we don't need to lock all environment.
* add a fine grain lock for getTimeOfDay and setTimeOfDay to solve environment multithread modifications on this value
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/server.cpp b/src/server.cpp index 0bb91d758..d2af9f5ac 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -535,23 +535,18 @@ void Server::AsyncRunStep(bool initial_step) /* Update time of day and overall game time */ - { - JMutexAutoLock envlock(m_env_mutex); - - m_env->setTimeOfDaySpeed(g_settings->getFloat("time_speed")); + m_env->setTimeOfDaySpeed(g_settings->getFloat("time_speed")); - /* - Send to clients at constant intervals - */ + /* + Send to clients at constant intervals + */ - m_time_of_day_send_timer -= dtime; - if(m_time_of_day_send_timer < 0.0) - { - m_time_of_day_send_timer = g_settings->getFloat("time_send_interval"); - u16 time = m_env->getTimeOfDay(); - float time_speed = g_settings->getFloat("time_speed"); - SendTimeOfDay(PEER_ID_INEXISTENT, time, time_speed); - } + m_time_of_day_send_timer -= dtime; + if(m_time_of_day_send_timer < 0.0) { + m_time_of_day_send_timer = g_settings->getFloat("time_send_interval"); + u16 time = m_env->getTimeOfDay(); + float time_speed = g_settings->getFloat("time_speed"); + SendTimeOfDay(PEER_ID_INEXISTENT, time, time_speed); } { |