From b0b5c432542ea5f9292f428bb59e2670c0d7c53d Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 10 Apr 2011 22:50:31 +0300 Subject: better support for old maps --- src/utility.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/utility.h') 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 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 -- cgit v1.2.3