From: Perttu Ahola Date: Mon, 2 Jan 2012 18:26:33 +0000 (+0200) Subject: Fix ABM trigger chance being often way too high X-Git-Tag: 0.4.dev-20120106-1~8 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=46302813186253a993b9f901fa5f3097961d3229;p=oweals%2Fminetest.git Fix ABM trigger chance being often way too high --- diff --git a/src/environment.cpp b/src/environment.cpp index 88f1527fc..53a7fdf9b 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -588,15 +588,17 @@ public: float trigger_interval = abm->getTriggerInterval(); if(trigger_interval < 0.001) trigger_interval = 0.001; + float actual_interval = dtime_s; if(use_timers){ i->timer += dtime_s; if(i->timer < trigger_interval) continue; i->timer -= trigger_interval; + actual_interval = trigger_interval; } ActiveABM aabm; aabm.abm = abm; - float intervals = dtime_s / trigger_interval; + float intervals = actual_interval / trigger_interval; float chance = abm->getTriggerChance(); if(chance == 0) chance = 1; diff --git a/src/environment.h b/src/environment.h index 3ebbee910..f8df77f79 100644 --- a/src/environment.h +++ b/src/environment.h @@ -130,7 +130,8 @@ struct ABMWithState float timer; ABMWithState(ActiveBlockModifier *abm_): - abm(abm_) + abm(abm_), + timer(0) {} };