Permalink
Browse files

[10694] Use portable ACE way msecs time value calculation

Avoid use unsafe code for non-Windows platforms
Thanks to Marik for research the problem and Ambal for helping me with this patch
  • Loading branch information...
1 parent 5be43d0 commit 3a82098dad035f9c4a3573ec266bc75b28c51cd5 @SilverIce SilverIce committed Nov 7, 2010
Showing with 5 additions and 22 deletions.
  1. +4 −21 src/shared/Timer.h
  2. +1 −1 src/shared/revision_nr.h
View
@@ -19,31 +19,14 @@
#ifndef MANGOS_TIMER_H
#define MANGOS_TIMER_H
-#include "Platform/CompilerDefs.h"
-
-#if PLATFORM == PLATFORM_WINDOWS
-# include <ace/config-all.h>
-# include <mmsystem.h>
-# include <time.h>
-#else
-# if defined(__APPLE_CC__)
-# include <time.h>
-# endif
-# include <sys/time.h>
-# include <sys/timeb.h>
-#endif
+#include "Common.h"
+#include <ace/OS_NS_sys_time.h>
-#if PLATFORM == PLATFORM_WINDOWS
-inline uint32 getMSTime() { return GetTickCount(); }
-#else
inline uint32 getMSTime()
{
- struct timeval tv;
- struct timezone tz;
- gettimeofday( &tv, &tz );
- return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
+ static const ACE_Time_Value ApplicationStartTime = ACE_OS::gettimeofday();
+ return (ACE_OS::gettimeofday() - ApplicationStartTime).msec();
}
-#endif
inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
{
View
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "10693"
+ #define REVISION_NR "10694"
#endif // __REVISION_NR_H__

0 comments on commit 3a82098

Please sign in to comment.