patch: [#27783] "Problem with clock" at 18:39:00 by Daniel Dionne (mrzeon)
authorDalai Felinto <dfelinto@gmail.com>
Mon, 18 Jul 2011 22:28:42 +0000 (22:28 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Mon, 18 Jul 2011 22:28:42 +0000 (22:28 +0000)
the overflow of the clock was causing crash in the game engine in Linux.
(on June 11 2011, 18:39:00 GMT)

running to the "where is waldo (wally)" bug award of 2011.

intern/ghost/intern/GHOST_SystemX11.cpp

index 3ebd24c008b32abaef3cce4951db212c32bba84d..dd296fa979c5e3a78a00f80d48fffd026ca532cf 100644 (file)
@@ -150,8 +150,9 @@ GHOST_SystemX11(
        if (gettimeofday(&tv,NULL) == -1) {
                GHOST_ASSERT(false,"Could not instantiate timer!");
        }
        if (gettimeofday(&tv,NULL) == -1) {
                GHOST_ASSERT(false,"Could not instantiate timer!");
        }
-
-       m_start_time = GHOST_TUns64(tv.tv_sec*1000 + tv.tv_usec/1000);
+       
+       // Taking care not to overflow the tv.tv_sec*1000
+       m_start_time = GHOST_TUns64(tv.tv_sec)*1000 + tv.tv_usec/1000;
        
        
        /* use detectable autorepeate, mac and windows also do this */
        
        
        /* use detectable autorepeate, mac and windows also do this */
@@ -199,7 +200,8 @@ getMilliSeconds(
                GHOST_ASSERT(false,"Could not compute time!");
        }
 
                GHOST_ASSERT(false,"Could not compute time!");
        }
 
-       return  GHOST_TUns64(tv.tv_sec*1000 + tv.tv_usec/1000) - m_start_time;
+       // Taking care not to overflow the tv.tv_sec*1000
+       return  GHOST_TUns64(tv.tv_sec)*1000 + tv.tv_usec/1000 - m_start_time;
 }
        
        GHOST_TUns8 
 }
        
        GHOST_TUns8