mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02: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:
@@ -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);
|
||||
}
|
||||
|
||||
{
|
||||
|
Reference in New Issue
Block a user