]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Timer.cc
more featureful sound class
[chaz/yoink] / src / Moof / Timer.cc
index fb17f1d66e1ac3a89c99c95a4cec94d9412c0dde..bc7aae220416687747de6f29bf07c39fc39a3f67 100644 (file)
 #include <ctime>
 #include <stdexcept>
 
+#include "Log.hh"
 #include "Timer.hh"
 
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#include <SDL/SDL.h>
+
 
 namespace Mf {
 
@@ -100,8 +103,6 @@ void sleep(Scalar seconds, bool absolute)
 // SDL only promises centisecond accuracy, but that's better than a kick in the
 // butt.
 
-#include <SDL/SDL.h>
-
 Scalar getTicks()
 {
        Uint32 ms = SDL_GetTicks();
@@ -111,8 +112,7 @@ Scalar getTicks()
 void sleep(Scalar seconds, bool absolute)
 {
        if (absolute) seconds -= getTicks();
-
-       SDL_Delay(Uint32(seconds * 1000.0));
+       SDL_Delay(Uint32(cml::clamp(int(seconds * 1000.0), 0, 1000)));
 }
 
 #endif // HAVE_CLOCK_GETTIME
This page took 0.021882 seconds and 4 git commands to generate.