Loading...   


diff --git a/common/timer.cpp b/common/timer.cpp
index d5a90a0..03409c9 100644
--- a/common/timer.cpp
+++ b/common/timer.cpp
@@ -16,18 +16,10 @@
 	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
 
-
-// Disgrace: for windows compile
-#ifndef WIN32
-	#include <sys/time.h>
-#else
-	#include <sys/timeb.h>
-#endif
-
 #include "timer.h"
 
-uint32 current_time = 0;
-uint32 last_time = 0;
+uint32 Timer::current_time = 0;
+uint32 Timer::last_time = 0;
 
 Timer::Timer() {
 	timer_time = 0;
@@ -158,39 +150,5 @@ void Timer::Trigger()
 	start_time = current_time-timer_time-1;
 }
 
-const uint32 Timer::GetCurrentTime()
-{
-	return current_time;
-}
-
-//just to keep all time related crap in one place... not really related to timers.
-const uint32 Timer::GetTimeSeconds() {
-	struct timeval read_time;
-
-	gettimeofday(&read_time,0);
-	return(read_time.tv_sec);
-}
-
-const uint32 Timer::SetCurrentTime()
-{
-	struct timeval read_time;
-	uint32 this_time;
-
-	gettimeofday(&read_time,0);
-	this_time = read_time.tv_sec * 1000 + read_time.tv_usec / 1000;
 
-	if (last_time == 0)
-	{
-		current_time = 0;
-	}
-	else
-	{
-		current_time += this_time - last_time;
-	}
-
-	last_time = this_time;
-
-//	cerr << "Current time:" << current_time << endl;
-	return current_time;
-}
 
diff --git a/common/timer.h b/common/timer.h
index f06f5bb..9d721e3 100644
--- a/common/timer.h
+++ b/common/timer.h
@@ -18,10 +18,15 @@
 #ifndef TIMER_H
 #define TIMER_H
 
+#ifndef WIN32
+#include <sys/time.h>
+#else
+#include <sys/timeb.h>
+#endif
+
 #include "types.h"
 #include <chrono>
 
-// Disgrace: for windows compile
 #ifdef _WINDOWS
 	#include "global_define.h"
 	int gettimeofday (timeval *tp, ...);
@@ -50,11 +55,42 @@ public:
 	inline uint32 GetStartTime() { return(start_time); }
 	inline uint32 GetDuration() { return(timer_time); }
 
-	static const uint32 SetCurrentTime();
-	static const uint32 GetCurrentTime();
-	static const uint32 GetTimeSeconds();
+	static const uint32 Timer::SetCurrentTime()
+	{
+		struct timeval read_time;
+		uint32 this_time;
+
+		gettimeofday(&read_time, 0);
+		this_time = read_time.tv_sec * 1000 + read_time.tv_usec / 1000;
+
+		if (last_time == 0)
+		{
+			current_time = 0;
+		}
+		else
+		{
+			current_time += this_time - last_time;
+		}
+
+		last_time = this_time;
+
+		//	cerr << "Current time:" << current_time << endl;
+		return current_time;
+	}
+
+	static uint32 Timer::GetCurrentTime() { return current_time; }
+
+	//just to keep all time related crap in one place... not really related to timers.
+	static uint32 Timer::GetTimeSeconds() {
+		struct timeval read_time;
+
+		gettimeofday(&read_time, 0);
+		return read_time.tv_sec;
+	}
 
 private:
+	static uint32 current_time;
+	static uint32 last_time;
 	uint32	start_time;
 	uint32	timer_time;
 	bool	enabled;

Raw Paste Data