X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Ftimer.cc;h=74acc1c203a9bc45b7cb894835e55b9e760162fc;hp=89f3e9da825676ef16e8ad94086e52f91615af74;hb=6f1b787a10d8ab1a3117a4b8c004dd2d90599608;hpb=c143f7e806766a73cd69dc6e084e977641019ce6 diff --git a/src/moof/timer.cc b/src/moof/timer.cc index 89f3e9d..74acc1c 100644 --- a/src/moof/timer.cc +++ b/src/moof/timer.cc @@ -139,11 +139,6 @@ bool timer::is_repeating() const } -void timer::fire_expired_timers() -{ - fire_expired_timers(ticks()); -} - void timer::fire_expired_timers(scalar t) { if (next_expiration_ > t) return; @@ -191,7 +186,7 @@ scalar timer::ticks() ASSERT(result == 0 && "cannot access clock"); return scalar(ts.tv_sec - reference_) + - scalar(ts.tv_nsec) / 1000000000.0; + scalar(ts.tv_nsec) * SCALAR(0.000000001); } void timer::sleep(scalar seconds, mode mode) @@ -201,7 +196,7 @@ void timer::sleep(scalar seconds, mode mode) if (mode == absolute) seconds -= ticks(); ts.tv_sec = time_t(seconds); - ts.tv_nsec = long((seconds - scalar(ts.tv_sec)) * 1000000000.0); + ts.tv_nsec = long((seconds - scalar(ts.tv_sec)) * SCALAR(1000000000.0)); do { @@ -221,13 +216,13 @@ void timer::sleep(scalar seconds, mode mode) scalar timer::ticks() { Uint32 ms = SDL_GetTicks(); - return scalar(ms / 1000) + scalar(ms % 1000) / 1000.0; + return scalar(ms / 1000) + scalar(ms % 1000) * SCALAR(0.001); } void timer::sleep(scalar seconds, mode mode) { if (mode == absolute) seconds -= ticks(); - SDL_Delay(Uint32(clamp(int(seconds * 1000.0), 0, 1000))); + SDL_Delay(Uint32(clamp(Uint32(seconds * SCALAR(1000.0)), 0, 1000))); } #endif // USE_CLOCK_GETTIME