Merge pull request #1092 from acemod/superTime

ACE_time variables for accurate purposeful time use
This commit is contained in:
jaynus 2015-05-12 19:34:20 -07:00
commit d972f14649
3 changed files with 39 additions and 0 deletions

View File

@ -312,6 +312,16 @@ if (hasInterface) then {
}, 0, []] call cba_fnc_addPerFrameHandler;
};
// Time handling
ACE_time = diag_tickTime;
ACE_realTime = diag_tickTime;
ACE_virtualTime = diag_tickTime;
ACE_diagTime = diag_tickTime;
ACE_gameTime = time;
PREP(timePFH);
[FUNC(timePFH), 0, []] call cba_fnc_addPerFrameHandler;
// Init toHex
[0] call FUNC(toHex);

View File

@ -0,0 +1,25 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
private["_lastTime", "_lastRealTime", "_lastVirtualTime", "_lastGameTime", "_delta"];
_lastRealTime = ACE_realTime;
_lastGameTime = ACE_gameTime;
ACE_gameTime = time;
ACE_diagTime = diag_tickTime;
_delta = ACE_diagTime - _lastRealTime;
if(ACE_gameTime <= _lastGameTime) then {
ACE_paused = true;
// Game is paused or not running
ACE_pausedTime = ACE_pausedTime + _delta;
ACE_virtualPausedTime = ACE_pausedTime + (_delta * accTime);
} else {
ACE_paused = false;
// Time is updating
ACE_realTime = ACE_realTime + _delta;
ACE_virtualTime = ACE_virtualTime + (_delta * accTime);
ACE_time = ACE_virtualTime;
};

View File

@ -82,4 +82,8 @@
#define HASHLIST_SET(hashList, index, value) ([hashList, index, value, __FILE__, __LINE__] call EFUNC(common,hashListSet))
#define HASHLIST_PUSH(hashList, value) ([hashList, value, __FILE__, __LINE__] call EFUNC(common,hashListPush))
// Time functions for accuracy per frame
#define ACE_tickTime (ACE_time + (diag_tickTime - ACE_diagTime))
#include "script_debug.hpp"