diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-04-10 22:50:31 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-04-10 22:50:31 +0300 |
commit | b0b5c432542ea5f9292f428bb59e2670c0d7c53d (patch) | |
tree | 60b280856a266c0bebef81a79cd5c2e72dcb50af /src/utility.h | |
parent | 3d25fe42f34589bd10a92929c442c2cd7f607309 (diff) | |
download | hax-minetest-server-b0b5c432542ea5f9292f428bb59e2670c0d7c53d.tar.gz hax-minetest-server-b0b5c432542ea5f9292f428bb59e2670c0d7c53d.zip |
better support for old maps
Diffstat (limited to '')
-rw-r--r-- | src/utility.h | 29 |
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 |