Limit range of ABM timer initial value randomization
authorPerttu Ahola <celeron55@gmail.com>
Tue, 3 Jan 2012 11:49:47 +0000 (13:49 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 3 Jan 2012 11:49:47 +0000 (13:49 +0200)
src/environment.cpp

index 20ecaff14d1fd3b54fd1e48a710c7e5f82a53749..3a294086c8ac78a6ee19b9bce7cff7a17868a76c 100644 (file)
@@ -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);
 }
 
 /*