X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FTimer.cc;h=69d2405622f7031cf134715b053304b39afb5ea2;hp=7f51510ce60189320383f25272e87da9914dc353;hb=3f6e44698c38b74bb622ad81ea9d2daa636981d2;hpb=c9e20ac06383b20ceb5404c9237e319c2e90d157 diff --git a/src/Moof/Timer.cc b/src/Moof/Timer.cc index 7f51510..69d2405 100644 --- a/src/Moof/Timer.cc +++ b/src/Moof/Timer.cc @@ -64,7 +64,7 @@ void Timer::init(const Function& function, Scalar seconds, Mode mode) { mFunction = function; - if (mode == ABSOLUTEE) + if (mode == ACTUAL) { mAbsolute = seconds; } @@ -152,6 +152,11 @@ bool Timer::isRepeating() const } +void Timer::fireIfExpired() +{ + fireIfExpired(getTicks()); +} + void Timer::fireIfExpired(Scalar t) { std::map::iterator it; @@ -200,12 +205,12 @@ Scalar Timer::getTicks() return Scalar(ts.tv_sec - reference) + Scalar(ts.tv_nsec) / 1000000000.0; } -void Timer::sleep(Scalar seconds, bool absolute) +void Timer::sleep(Scalar seconds, Mode mode) { struct timespec ts; int ret; - if (absolute) seconds -= getTicks(); + if (mode == ACTUAL) seconds -= getTicks(); ts.tv_sec = time_t(seconds); ts.tv_nsec = long((seconds - Scalar(ts.tv_sec)) * 1000000000.0); @@ -230,9 +235,9 @@ Scalar Timer::getTicks() return Scalar(ms / 1000) + Scalar(ms % 1000) / 1000.0; } -void Timer::sleep(Scalar seconds, bool absolute) +void Timer::sleep(Scalar seconds, Mode mode) { - if (absolute) seconds -= getTicks(); + if (mode == ACTUAL) seconds -= getTicks(); SDL_Delay(Uint32(cml::clamp(int(seconds * 1000.0), 0, 1000))); }