]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/timer.cpp
Revert partially (auto) "reformat code! now the code is only ugly on the *inside*"
[xonotic/netradiant.git] / radiant / timer.cpp
index 6978510c0d1069fbe2087065521a6a5a1656956e..8d10b82ba8b36cc8cda79ee82fcc541f0b78f263 100644 (file)
 #include <windows.h>
 
 MillisecondTime MillisecondTime::current(){
-    static class Cached
-    {
-    LONGLONG m_frequency;
-    LONGLONG m_base;
+       static class Cached
+       {
+       LONGLONG m_frequency;
+       LONGLONG m_base;
 public:
-    Cached(){
-        QueryPerformanceFrequency( (LARGE_INTEGER *) &m_frequency );
-        QueryPerformanceCounter( (LARGE_INTEGER *) &m_base );
-    }
-    LONGLONG frequency(){
-        return m_frequency;
-    }
-    LONGLONG base(){
-        return m_base;
-    }
-    } cached;
-
-    if ( cached.frequency() > 0 ) {
-        LONGLONG count;
-        QueryPerformanceCounter( (LARGE_INTEGER *) &count );
-        return time_from_ticks( count - cached.base(), cached.frequency() );
-    }
-    else
-    {
+       Cached(){
+               QueryPerformanceFrequency( (LARGE_INTEGER *) &m_frequency );
+               QueryPerformanceCounter( (LARGE_INTEGER *) &m_base );
+       }
+       LONGLONG frequency(){
+               return m_frequency;
+       }
+       LONGLONG base(){
+               return m_base;
+       }
+       } cached;
+
+       if ( cached.frequency() > 0 ) {
+               LONGLONG count;
+               QueryPerformanceCounter( (LARGE_INTEGER *) &count );
+               return time_from_ticks( count - cached.base(), cached.frequency() );
+       }
+       else
+       {
 #if 1
-        return MillisecondTime();
+               return MillisecondTime();
 #else
-        return time_from_ticks( timeGetTime(), 1000 );
+               return time_from_ticks( timeGetTime(), 1000 );
 #endif
-    }
+       }
 }
 
 
@@ -68,34 +68,32 @@ public:
 #include <time.h>
 #include "sys/time.h"
 
-MillisecondTime MillisecondTime::current()
-{
-    static class Cached {
-        time_t m_base;
-    public:
-        Cached()
-        {
-            time(&m_base);
-        }
-
-        time_t base()
-        {
-            return m_base;
-        }
-    } cached;
-
-    timeval time;
-    gettimeofday(&time, 0);
-    return MillisecondTime((time.tv_sec - cached.base()) * 1000 + time.tv_usec / 1000);
+MillisecondTime MillisecondTime::current(){
+       static class Cached
+       {
+       time_t m_base;
+public:
+       Cached(){
+               time( &m_base );
+       }
+       time_t base(){
+               return m_base;
+       }
+       } cached;
+
+       timeval time;
+       gettimeofday( &time, 0 );
+       return MillisecondTime( ( time.tv_sec - cached.base() ) * 1000 + time.tv_usec / 1000 );
 }
 
 
+
 #else
 
 #include <ctime>
 
 MillisecondTime MillisecondTime::current(){
-    return time_from_ticks<std::clock_t>( std::clock(), CLOCKS_PER_SEC );
+       return time_from_ticks<std::clock_t>( std::clock(), CLOCKS_PER_SEC );
 }