mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
1b2f64473e
commit
7f8f9785d7
3 changed files with 40 additions and 35 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue