1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-23 08:08:47 -05:00

Initialize ABM timer to random value to spread processing

This commit is contained in:
Perttu Ahola 2012-01-02 21:06:38 +02:00
parent 4630281318
commit 6286c555d4
2 changed files with 14 additions and 4 deletions

View File

@ -203,6 +203,19 @@ u32 Environment::getDayNightRatio()
return time_to_daynight_ratio(m_time_of_day);
}
/*
ABMWithState
*/
ABMWithState::ABMWithState(ActiveBlockModifier *abm_):
abm(abm_),
timer(0)
{
// Initialize timer to random value to spread processing
float itv = abm->getTriggerInterval();
timer = myrand_range(-0.51*itv, 0.51*itv);
}
/*
ActiveBlockList
*/

View File

@ -129,10 +129,7 @@ struct ABMWithState
ActiveBlockModifier *abm;
float timer;
ABMWithState(ActiveBlockModifier *abm_):
abm(abm_),
timer(0)
{}
ABMWithState(ActiveBlockModifier *abm_);
};
/*