[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
This commit is contained in:
SilverIce 2010-11-08 01:02:57 +02:00
parent e9869e7470
commit bb3663d94f
2 changed files with 5 additions and 22 deletions

View file

@ -19,31 +19,14 @@
#ifndef MANGOS_TIMER_H
#define MANGOS_TIMER_H
#include "Platform/CompilerDefs.h"
#include "Common.h"
#include <ace/OS_NS_sys_time.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
#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 file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10693"
#define REVISION_NR "10694"
#endif // __REVISION_NR_H__