summaryrefslogtreecommitdiff
path: root/src/utility.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-04-10 22:50:31 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-04-10 22:50:31 +0300
commitb0b5c432542ea5f9292f428bb59e2670c0d7c53d (patch)
tree60b280856a266c0bebef81a79cd5c2e72dcb50af /src/utility.h
parent3d25fe42f34589bd10a92929c442c2cd7f607309 (diff)
downloadminetest-b0b5c432542ea5f9292f428bb59e2670c0d7c53d.tar.gz
minetest-b0b5c432542ea5f9292f428bb59e2670c0d7c53d.tar.bz2
minetest-b0b5c432542ea5f9292f428bb59e2670c0d7c53d.zip
better support for old maps
Diffstat (limited to 'src/utility.h')
-rw-r--r--src/utility.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/utility.h b/src/utility.h
index f2f3018df..19946354c 100644
--- a/src/utility.h
+++ b/src/utility.h
@@ -2015,6 +2015,35 @@ inline core::aabbox3d<f32> getNodeBox(v3s16 p, float d)
);
}
+class IntervalLimiter
+{
+public:
+ IntervalLimiter():
+ m_accumulator(0)
+ {
+ }
+ /*
+ dtime: time from last call to this method
+ wanted_interval: interval wanted
+ return value:
+ true: action should be skipped
+ false: action should be done
+ */
+ bool step(float dtime, float wanted_interval)
+ {
+ m_accumulator += dtime;
+ if(m_accumulator < wanted_interval)
+ {
+ dtime = 0;
+ return true;
+ }
+ m_accumulator -= wanted_interval;
+ return false;
+ }
+protected:
+ float m_accumulator;
+};
+
#endif