From: Perttu Ahola Date: Mon, 2 Jan 2012 19:06:38 +0000 (+0200) Subject: Initialize ABM timer to random value to spread processing X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=6286c555d4bd4597e19c8b05d44f0ef364ceffb0;p=zefram%2Fminetest%2Fminetest_engine.git Initialize ABM timer to random value to spread processing --- diff --git a/src/environment.cpp b/src/environment.cpp index 53a7fdf9..20ecaff1 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -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 */ diff --git a/src/environment.h b/src/environment.h index f8df77f7..beb49885 100644 --- a/src/environment.h +++ b/src/environment.h @@ -129,10 +129,7 @@ struct ABMWithState ActiveBlockModifier *abm; float timer; - ABMWithState(ActiveBlockModifier *abm_): - abm(abm_), - timer(0) - {} + ABMWithState(ActiveBlockModifier *abm_); }; /*