ACE3/addons/common/functions/fnc_syncedEventPFH.sqf

67 lines
1.7 KiB
Plaintext
Raw Normal View History

2015-09-20 13:52:40 +00:00
/*
* Author: ?
*
* ?
*
* Arguments:
* ?
*
* Return Value:
* ?
*
* Public: ?
*/
#include "script_component.hpp"
2015-09-20 13:52:40 +00:00
if (!isServer) exitWith {false};
// Walk through the local synced events and clean up anything thats already EOL
// @TODO: This should be iteration limited to prevent FPS lag
2015-09-20 13:52:40 +00:00
{
2015-09-20 13:52:40 +00:00
private ["_name", "_data", "_newEventLog"];
_name = _x;
_data = HASH_GET(GVAR(syncedEvents),_name);
2015-09-20 13:52:40 +00:00
_data params ["_eventTime", "_eventLog", "_globalEventTTL"];
_newEventLog = [];
2015-09-20 13:52:40 +00:00
// @TODO: This should be iteration limited to prevent FPS lag
{
2015-09-20 13:52:40 +00:00
private ["_eventEntry", "_ttlReturn"];
_eventEntry = _x;
_ttlReturn = true;
2015-09-20 13:52:40 +00:00
if (typeName _globalEventTTL == "CODE") then {
_ttlReturn = [_eventTime, _eventEntry] call _globalEventTTL;
} else {
2015-09-20 13:52:40 +00:00
_ttlReturn = call {_globalEventTTL < 1 || {ACE_diagTime < (_eventEntry select 0) + _globalEventTTL}};
};
2015-09-20 13:52:40 +00:00
if (_ttlReturn) then {
// Do event based TTL check
2015-09-20 13:52:40 +00:00
_eventEntry params ["_time", "", "_eventTTL"];
if (typeName _eventTTL == "CODE") then {
_ttlReturn = [_eventTime, _eventEntry] call _eventTTL;
} else {
2015-09-20 13:52:40 +00:00
_ttlReturn = call {_eventTTL < 1 || {ACE_diagTime < _time + _eventTTL}};
};
};
// Finally drop it if the TTL check fails
2015-09-20 13:52:40 +00:00
if (_ttlReturn) then {
_newEventLog pushBack _x;
};
2015-09-20 13:52:40 +00:00
false
} count _eventLog;
2015-09-20 13:52:40 +00:00
_data set [1, _newEventLog];
false
} count (GVAR(syncedEvents) select 0);
// @TODO: Next, detect if we had a new request from a JIP player, and we need to continue syncing events