diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 21:06:38 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 21:06:38 +0200 |
commit | 6286c555d4bd4597e19c8b05d44f0ef364ceffb0 (patch) | |
tree | ee11969199d4176ade20d1d7f5581e2eb8668bb1 /src | |
parent | 46302813186253a993b9f901fa5f3097961d3229 (diff) | |
download | minetest-6286c555d4bd4597e19c8b05d44f0ef364ceffb0.tar.gz minetest-6286c555d4bd4597e19c8b05d44f0ef364ceffb0.tar.bz2 minetest-6286c555d4bd4597e19c8b05d44f0ef364ceffb0.zip |
Initialize ABM timer to random value to spread processing
Diffstat (limited to 'src')
-rw-r--r-- | src/environment.cpp | 13 | ||||
-rw-r--r-- | src/environment.h | 5 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index 53a7fdf9b..20ecaff14 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -204,6 +204,19 @@ u32 Environment::getDayNightRatio() } /* + 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 f8df77f79..beb49885c 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_); }; /* |