Fix ABM handling on block activation
authorPerttu Ahola <celeron55@gmail.com>
Mon, 9 Apr 2012 20:06:24 +0000 (23:06 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 9 Apr 2012 20:06:24 +0000 (23:06 +0300)
src/environment.cpp

index e1f5bb3fbbd9320925b115b983ac9877c93dba9c..43dbb65d07d9cef57ec1aba9a4413dcbf6bab948 100644 (file)
@@ -633,13 +633,15 @@ public:
                                i->timer -= trigger_interval;
                                actual_interval = trigger_interval;
                        }
-                       ActiveABM aabm;
-                       aabm.abm = abm;
                        float intervals = actual_interval / trigger_interval;
+                       if(intervals == 0)
+                               continue;
                        float chance = abm->getTriggerChance();
                        if(chance == 0)
                                chance = 1;
-                       aabm.chance = 1.0 / pow((float)1.0/chance, (float)intervals);
+                       ActiveABM aabm;
+                       aabm.abm = abm;
+                       aabm.chance = chance / intervals;
                        if(aabm.chance == 0)
                                aabm.chance = 1;
                        // Trigger neighbors