From f9d7e399b23999b4ecec505537efe29fc0cf4fd0 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 3 Jan 2012 13:49:47 +0200 Subject: [PATCH] Limit range of ABM timer initial value randomization --- src/environment.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/environment.cpp b/src/environment.cpp index 20ecaff1..3a294086 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -213,7 +213,10 @@ ABMWithState::ABMWithState(ActiveBlockModifier *abm_): { // Initialize timer to random value to spread processing float itv = abm->getTriggerInterval(); - timer = myrand_range(-0.51*itv, 0.51*itv); + itv = MYMAX(0.001, itv); // No less than 1ms + int minval = MYMAX(-0.51*itv, -60); // Clamp to + int maxval = MYMIN(0.51*itv, 60); // +-60 seconds + timer = myrand_range(minval, maxval); } /* -- 2.30.2