mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1092 from acemod/superTime
ACE_time variables for accurate purposeful time use
This commit is contained in:
commit
d972f14649
@ -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);
|
||||
|
||||
|
25
addons/common/functions/fnc_timePFH.sqf
Normal file
25
addons/common/functions/fnc_timePFH.sqf
Normal 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;
|
||||
};
|
||||
|
@ -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"
|
Loading…
Reference in New Issue
Block a user