mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[11487] Fix WorldTimer code (previous code causes server time flow speed to be on ~ 1-2% slower than real time)
This commit is contained in:
parent
6833efe12e
commit
7d6b52641b
2 changed files with 4 additions and 17 deletions
|
|
@ -59,24 +59,11 @@ uint32 WorldTimer::getMSTime_internal(bool savetime /*= false*/)
|
||||||
//calculate time diff between two world ticks
|
//calculate time diff between two world ticks
|
||||||
//special case: curr_time < old_time - we suppose that our time has not ticked at all
|
//special case: curr_time < old_time - we suppose that our time has not ticked at all
|
||||||
//this should be constant value otherwise it is possible that our time can start ticking backwards until next world tick!!!
|
//this should be constant value otherwise it is possible that our time can start ticking backwards until next world tick!!!
|
||||||
uint32 diff = 0;
|
uint64 diff = 0;
|
||||||
//regular case: curr_time >= old_time
|
(currTime - g_SystemTickTime).msec(diff);
|
||||||
if(currTime > g_SystemTickTime)
|
|
||||||
diff = (currTime - g_SystemTickTime).msec();
|
|
||||||
|
|
||||||
//reset last system time value
|
|
||||||
if(savetime)
|
|
||||||
g_SystemTickTime = currTime;
|
|
||||||
|
|
||||||
//lets calculate current world time
|
//lets calculate current world time
|
||||||
uint32 iRes = m_iTime;
|
uint32 iRes = uint32(diff % UI64LIT(0x00000000FFFFFFFF));
|
||||||
//normalize world time
|
|
||||||
const uint32 tmp = uint32(0xFFFFFFFF) - iRes;
|
|
||||||
if(tmp < diff)
|
|
||||||
iRes = diff - tmp;
|
|
||||||
else
|
|
||||||
iRes += diff;
|
|
||||||
|
|
||||||
return iRes;
|
return iRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11486"
|
#define REVISION_NR "11487"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue