From 2581032bf926310543ad63d32bb0b152c249b2f0 Mon Sep 17 00:00:00 2001 From: avolkov Date: Fri, 7 Jan 2005 22:32:48 +0000 Subject: [PATCH] Game clock counter overflow fix (#668) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1435 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/time/sdl/sdltime.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sc2/src/sc2code/libs/time/sdl/sdltime.c b/sc2/src/sc2code/libs/time/sdl/sdltime.c index cd8cc7f7f..35ab85675 100644 --- a/sc2/src/sc2code/libs/time/sdl/sdltime.c +++ b/sc2/src/sc2code/libs/time/sdl/sdltime.c @@ -21,6 +21,10 @@ #include "libs/timelib.h" Uint32 -SDLWrapper_GetTimeCounter (void) { - return (Uint32)(SDL_GetTicks () * ONE_SECOND / 1000.0); +SDLWrapper_GetTimeCounter (void) +{ + Uint32 ticks = SDL_GetTicks (); + return (ticks / 1000) * ONE_SECOND + ((ticks % 1000) * ONE_SECOND / 1000); + // Use the following instead when confirming "random" lockup bugs (see #668) + //return ticks * ONE_SECOND / 1000; }