From 2c8b17ebf86a5fc42c1d289833af66c8c9349ce8 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 23 Feb 2004 00:04:38 +0000 Subject: [PATCH] RageTimer fixes --- stepmania/src/RageTimer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/stepmania/src/RageTimer.cpp b/stepmania/src/RageTimer.cpp index d720f90abd..15ee941f83 100644 --- a/stepmania/src/RageTimer.cpp +++ b/stepmania/src/RageTimer.cpp @@ -13,6 +13,14 @@ const RageZeroTimer_t RageZeroTimer; void mySDL_GetTicks( unsigned &secs, unsigned &us ) { + static bool bInitialized = false; + if( !bInitialized ) + { + bInitialized = true; + if( !SDL_WasInit(SDL_INIT_TIMER) ) + SDL_InitSubSystem( SDL_INIT_TIMER ); + } + /* Ticks may be less than last for at least two reasons: the time may have wrapped (after * about 49 days), or the system clock may have moved backwards. If the system clock moves * backwards, we can't just clamp the time; if it moved back an hour, we'll sit around for @@ -47,6 +55,12 @@ void mySDL_GetTicks( unsigned &secs, unsigned &us ) offset_us += (offset_ms%1000) * 1000; } + if( offset_us >= TIMESTAMP_RESOLUTION ) + { + offset_us -= TIMESTAMP_RESOLUTION; + ++offset_secs; + } + last = millisecs; secs = millisecs / 1000;