From 6286c555d4bd4597e19c8b05d44f0ef364ceffb0 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 2 Jan 2012 21:06:38 +0200 Subject: [PATCH] Initialize ABM timer to random value to spread processing --- src/environment.cpp | 13 +++++++++++++ src/environment.h | 5 +---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index 53a7fdf..20ecaff 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 f8df77f..beb4988 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_); }; /*