Limit range of ABM timer initial value randomization

experimental
Perttu Ahola 2012-01-03 13:49:47 +02:00
parent 3e6f824e6c
commit f9d7e399b2
1 changed files with 4 additions and 1 deletions

View File

@ -213,7 +213,10 @@ ABMWithState::ABMWithState(ActiveBlockModifier *abm_):
{ {
// Initialize timer to random value to spread processing // Initialize timer to random value to spread processing
float itv = abm->getTriggerInterval(); 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);
} }
/* /*