diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 20:26:33 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-01-02 20:26:33 +0200 |
commit | 46302813186253a993b9f901fa5f3097961d3229 (patch) | |
tree | e06c5cbb895cc2938e0c4e1102c6150fe72df70a | |
parent | cd0019acd28bf7d2b6de44fc366804f0d17c80b2 (diff) | |
download | minetest-46302813186253a993b9f901fa5f3097961d3229.tar.gz minetest-46302813186253a993b9f901fa5f3097961d3229.tar.bz2 minetest-46302813186253a993b9f901fa5f3097961d3229.zip |
Fix ABM trigger chance being often way too high
-rw-r--r-- | src/environment.cpp | 4 | ||||
-rw-r--r-- | src/environment.h | 3 |
2 files changed, 5 insertions, 2 deletions
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) {} }; |